Commit 371f419
committed
VIDEO/D3D12: GPU tonemap path for HDR screenshots
Counterpart to 5fbe019 (D3D11 GPU tonemap). Moves the HDR->SDR
conversion in d3d12_gfx_read_viewport from the CPU decoder in
dxgi_hdr_readback_to_bgr24() to a GPU render using the shared
PSMainToSDR entry point in hdr_sm5.hlsl.h.
The GPU path:
- Lazily creates a dedicated tonemap PSO into d3d12->hdr.pso_readback
on the first HDR screenshot. The PSO targets B8G8R8A8_UNORM, reuses
the existing HDR root signature and vertex layout, and runs the
PSMainToSDR pixel shader.
- Allocates a transient HDR source texture (PIXEL_SHADER_RESOURCE) and
copies the swapchain backbuffer into it; the swapchain itself has no
SRV bind flag.
- Allocates a transient SDR render target using a fixed RTV slot
reserved at heap init time (one past the last per-pass slot).
- Records a command list that does the tonemap draw, transitions the
SDR RT to COPY_SOURCE, and copies into a D3D12_HEAP_TYPE_READBACK
buffer with a GetCopyableFootprints-computed layout.
- Signals the queue fence, waits, maps the readback buffer, and
unswizzles BGRA8 -> BGR24 bottom-up.
On any failure (PSO compile, OOM, resource creation, Map) the caller
logs RARCH_WARN and falls through to the existing CPU decoder. HDR
screenshots keep working even if the GPU path breaks on a particular
driver or hardware combination.
RTV heap size is bumped by 1 to reserve the readback slot. All other
HDR-era screenshot infrastructure (UBO, vertex buffer, root signature,
sampler) is reused as-is.1 parent 5fbe019 commit 371f419
1 file changed
Lines changed: 368 additions & 8 deletions
0 commit comments