116 std::function<void(SDL_GPUCommandBuffer *, SDL_GPUTexture *, Uint32, Uint32)>;
141 return m_options.fieldOfViewScale;
146 return m_options.drawDistanceScale;
151 return m_options.n64Effects;
156 return m_options.n64WindowReflections;
177 return m_window.get();
182 return m_device.get();
190 return m_gpuMemoryBytes;
198 return m_options.gpuPreference;
206 return m_options.aspectRatio;
218 return m_options.unlockedFramerate;
223 return m_presentationWait;
228 return (SDL_GetWindowFlags(m_window.get()) & SDL_WINDOW_FULLSCREEN) != 0;
242 return m_options.presentMode;
288 return SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM;
298 return m_frameHeight;
315 return m_options.textureFilter;
320 return m_options.alphaToCoverage;
325 return m_options.anisotropy;
330 const SDL_GPUTextureCreateInfo *info);
332 const SDL_GPUBufferCreateInfo *info);
333 friend SDL_GPUTransferBuffer *
339 static GpuWindow *ForDevice(SDL_GPUDevice *device);
340 void AddGpuMemory(
const void *
object, Uint64 bytes);
341 void RemoveGpuMemory(
const void *
object);
344 struct WindowDeleter {
346 void operator()(SDL_Window *window)
const {
347 SDL_DestroyWindow(window);
351 struct DeviceDeleter {
353 void operator()(SDL_GPUDevice *device)
const {
354 SDL_DestroyGPUDevice(device);
359 bool SaveFrame(SDL_GPUCommandBuffer *commands,
360 SDL_GPUTexture *source,
363 const std::filesystem::path &path);
364 bool CreateFrame(Uint32 width, Uint32 height);
365 bool CreatePostPasses();
366 SDL_GPUTexture *AntialiasFrame(SDL_GPUCommandBuffer *commands);
367 bool CreatePresentationPass();
368 bool CreateHdrPass();
369 SDL_GPUTexture *FilterFrame(SDL_GPUCommandBuffer *commands,
370 SDL_GPUTexture *source,
374 std::unordered_map<const void *, Uint64> m_gpuMemoryObjects;
375 Uint64 m_gpuMemoryBytes = 0;
376 unsigned m_texturesSincePresent = 0;
377 std::unique_ptr<SDL_Window, WindowDeleter> m_window;
378 std::unique_ptr<SDL_GPUDevice, DeviceDeleter> m_device;
379 SDL_GPUTexture *m_frame =
nullptr;
381 SDL_GPUTexture *m_antialiased =
nullptr;
382 SDL_GPUGraphicsPipeline *m_antialiasPipeline =
nullptr;
383 SDL_GPUSampler *m_postSampler =
nullptr;
384 SDL_GPUTexture *m_filtered =
nullptr;
385 SDL_GPUGraphicsPipeline *m_presentationPipeline =
nullptr;
386 SDL_GPUSampler *m_presentationSampler =
nullptr;
387 SDL_GPUGraphicsPipeline *m_hdrPipeline =
nullptr;
388 SDL_GPUSampler *m_hdrSampler =
nullptr;
389 Uint32 m_filteredWidth = 0;
390 Uint32 m_filteredHeight = 0;
391 SDL_GPUTexture *m_composite =
nullptr;
392 Uint32 m_compositeWidth = 0;
393 Uint32 m_compositeHeight = 0;
394 Uint32 m_frameWidth = 0;
395 Uint32 m_frameHeight = 0;
396 DisplayOptions m_options;
397 Uint64 m_presentationWait = 0;
399 bool m_exclusive =
false;
400 int m_refreshRate = 0;
401 bool m_pacedToRefresh =
false;
402 bool m_hdrActive =
false;
404 std::vector<std::future<void>> m_frameSaves;
414SDL_GPUTexture *
CreateGpuTexture(SDL_GPUDevice *device,
const SDL_GPUTextureCreateInfo *info);
423SDL_GPUBuffer *
CreateGpuBuffer(SDL_GPUDevice *device,
const SDL_GPUBufferCreateInfo *info);
433 const SDL_GPUTransferBufferCreateInfo *info);
bool N64WindowReflections() const
Definition gpu.h:155
Uint64 RefreshPeriod() const
friend void ReleaseGpuBuffer(SDL_GPUDevice *device, SDL_GPUBuffer *buffer)
SDL_ReleaseGPUBuffer(), subtracting its bytes from GpuWindow::GpuMemoryBytes().
Uint64 GpuMemoryBytes() const
Definition gpu.h:189
bool AlphaToCoverage() const
Definition gpu.h:319
int Antialias() const
Definition gpu.h:309
SDL_GPUPresentMode PresentMode() const
Definition gpu.h:241
static constexpr SDL_GPUTextureFormat FrameFormat()
Definition gpu.h:287
friend void ReleaseGpuTexture(SDL_GPUDevice *device, SDL_GPUTexture *texture)
SDL_ReleaseGPUTexture(), subtracting its bytes from GpuWindow::GpuMemoryBytes().
Uint32 FrameHeight() const
Definition gpu.h:297
bool ApplyLiveOptions(const DisplayOptions &options)
Apply camera, particle, frame-size, post-processing, and pacing settings between frames.
std::string DeviceName() const
bool PresentClear(SDL_FColor color, const std::filesystem::path *capture=nullptr)
Clear the frame texture to color, present it, and save it when capture is given.
float DrawDistanceScale() const
Definition gpu.h:145
float FieldOfViewScale() const
Definition gpu.h:140
TextureFilter Filter() const
Definition gpu.h:314
static std::unique_ptr< GpuWindow > Create(const char *title, const DisplayOptions &options)
Create the window, a GPU device for it, and the frame texture.
SDL_GPUDevice * Device() const
Definition gpu.h:181
bool N64Effects() const
Definition gpu.h:150
bool Fullscreen() const
Definition gpu.h:227
int Anisotropy() const
Definition gpu.h:324
bool ApplyRendererOptions(const DisplayOptions &options)
Update sampling and texture filtering, then apply live settings.
SDL_Window * Window() const
Definition gpu.h:176
GpuWindow & operator=(const GpuWindow &)=delete
Prevent assignment of the window and GPU device.
friend SDL_GPUTexture * CreateGpuTexture(SDL_GPUDevice *device, const SDL_GPUTextureCreateInfo *info)
SDL_CreateGPUTexture(), recording bytes of every level and sample in GpuWindow::GpuMemoryBytes().
std::function< void(SDL_GPUCommandBuffer *, SDL_GPUTexture *, Uint32, Uint32)> OutputOverlay
Draw directly over the output texture after scaling and screen filters.
Definition gpu.h:115
void SetFramerateUnlocked(bool unlocked)
Set uncapped presentation while retaining the configured present mode.
friend SDL_GPUTransferBuffer * CreateGpuTransferBuffer(SDL_GPUDevice *device, const SDL_GPUTransferBufferCreateInfo *info)
SDL_CreateGPUTransferBuffer(), recording its size in GpuWindow::GpuMemoryBytes().
bool SetFullscreen(bool fullscreen)
Cover the display, at the desktop mode or the exclusive mode of the options, or return to a window.
~GpuWindow()
Release presentation resources and the window after all device-dependent users.
friend SDL_GPUBuffer * CreateGpuBuffer(SDL_GPUDevice *device, const SDL_GPUBufferCreateInfo *info)
SDL_CreateGPUBuffer(), recording its size in GpuWindow::GpuMemoryBytes().
const std::string & GpuPreference() const
Definition gpu.h:197
float AspectRatio() const
Definition gpu.h:205
void SetPresentMode(SDL_GPUPresentMode mode)
Present the frames with mode, with the other mode that does not wait and then vertical sync in the pl...
SDL_GPUTexture * FrameTexture() const
Definition gpu.h:282
void UpdateFrameSize()
Give the frame the size of the window in pixels times the render scale, or the size of the options,...
bool Present(SDL_GPUCommandBuffer *commands, const std::filesystem::path *capture=nullptr, const OutputOverlay &overlay={})
Scale the frame texture to the window and submit commands, which drew the frame.
GpuWindow(const GpuWindow &)=delete
Prevent copying the window and GPU device.
friend void ReleaseGpuTransferBuffer(SDL_GPUDevice *device, SDL_GPUTransferBuffer *buffer)
SDL_ReleaseGPUTransferBuffer(), subtracting its bytes from GpuWindow::GpuMemoryBytes().
Uint64 PresentationWaitNanoseconds() const
Definition gpu.h:222
Uint32 FrameWidth() const
Definition gpu.h:292
bool FramerateUnlocked() const
Definition gpu.h:217
Definition assetimport.h:11
ScaleFilter
How the frame is scaled to the window.
Definition gpu.h:17
@ EdgeAdaptive
Definition gpu.h:20
@ Linear
Definition gpu.h:18
@ Nearest
Definition gpu.h:19
SDL_GPUTexture * CreateGpuTexture(SDL_GPUDevice *device, const SDL_GPUTextureCreateInfo *info)
SDL_CreateGPUTexture(), recording bytes of every level and sample in GpuWindow::GpuMemoryBytes().
SDL_GPUTransferBuffer * CreateGpuTransferBuffer(SDL_GPUDevice *device, const SDL_GPUTransferBufferCreateInfo *info)
SDL_CreateGPUTransferBuffer(), recording its size in GpuWindow::GpuMemoryBytes().
ScreenShader
Display simulation applied after the internal frame is scaled to the window.
Definition gpu.h:37
@ None
Definition gpu.h:38
@ ConsumerCrt
Definition gpu.h:39
@ PcCrt
Definition gpu.h:42
@ ApertureGrille
Definition gpu.h:41
void ReleaseGpuTransferBuffer(SDL_GPUDevice *device, SDL_GPUTransferBuffer *buffer)
SDL_ReleaseGPUTransferBuffer(), subtracting its bytes from GpuWindow::GpuMemoryBytes().
PostAntialias
The anti-aliasing of the finished frame, before it is scaled to the window.
Definition gpu.h:31
@ None
Definition gpu.h:32
@ Fxaa
Definition gpu.h:33
TextureFilter
How the textures the game filters are filtered.
Definition gpu.h:24
@ Modern
Definition gpu.h:26
void ReleaseGpuTexture(SDL_GPUDevice *device, SDL_GPUTexture *texture)
SDL_ReleaseGPUTexture(), subtracting its bytes from GpuWindow::GpuMemoryBytes().
HdrOutput
Whether HDR output follows the window, is requested, or is disabled.
Definition gpu.h:46
@ Auto
Definition gpu.h:47
SDL_GPUBuffer * CreateGpuBuffer(SDL_GPUDevice *device, const SDL_GPUBufferCreateInfo *info)
SDL_CreateGPUBuffer(), recording its size in GpuWindow::GpuMemoryBytes().
void ReleaseGpuBuffer(SDL_GPUDevice *device, SDL_GPUBuffer *buffer)
SDL_ReleaseGPUBuffer(), subtracting its bytes from GpuWindow::GpuMemoryBytes().
The options of the window and the GPU device.
Definition gpu.h:53
bool wideMenus
Definition gpu.h:56
bool gpuDebug
Whether the GPU device checks its use, with the validation layers of Vulkan when they are installed.
Definition gpu.h:83
std::string gpuPreference
Definition gpu.h:60
ScaleFilter scaleFilter
Definition gpu.h:70
bool fixedFrame
Whether the frame stays at the width and the height, for captures that are the same on every machine.
Definition gpu.h:75
bool minimized
Whether the window starts minimized, for runs that save their frames unattended.
Definition gpu.h:85
float renderScale
The pixels of the frame for each pixel of the window, when the frame follows the window.
Definition gpu.h:69
int frameWidth
Definition gpu.h:66
bool autoWideMenus
Definition gpu.h:57
SDL_GPUPresentMode presentMode
How frames are presented, with the other mode that does not wait and then vertical sync taking the pl...
Definition gpu.h:93
bool fifo
Whether vertical sync of a Wayland window waits for the vertical blank as on other systems,...
Definition gpu.h:96
ScreenShader screenShader
Definition gpu.h:72
float aspectRatio
The width over the height the frame keeps in a window and in the full screen, with bars around it,...
Definition gpu.h:80
bool lowestFrame
Whether the frame expands from 320x240 to the selected aspect ratio.
Definition gpu.h:77
bool exclusive
Whether the window covers the display in a mode of the width, the height, and the refresh rate,...
Definition gpu.h:89
int anisotropy
The most samples of anisotropic filtering of the textures of models, which are then mipmapped,...
Definition gpu.h:100
std::optional< std::string > driver
Definition gpu.h:105
int height
Definition gpu.h:65
bool fullscreen
Definition gpu.h:86
bool n64Effects
Definition gpu.h:54
PostAntialias postAntialias
Definition gpu.h:71
bool n64WindowReflections
Definition gpu.h:55
float drawDistanceScale
Definition gpu.h:59
int refreshRate
Definition gpu.h:90
bool unlockedFramerate
Definition gpu.h:62
TextureFilter textureFilter
Definition gpu.h:101
bool alphaToCoverage
Whether the alpha of the texels a model cuts covers the samples of a multisampled pixel.
Definition gpu.h:103
HdrOutput hdrOutput
Definition gpu.h:61
float fieldOfViewScale
Definition gpu.h:58
int width
Definition gpu.h:64
int frameHeight
Definition gpu.h:67
int antialias
Definition gpu.h:97