Fix hooked video darkening for *_SRGB-backbuffer games

The host sampled the shared backbuffer copy through a view typed exactly like the
game's backbuffer. For games whose backbuffer is an *_SRGB format (e.g. Life is
Strange: Before the Storm -- confirmed R8G8B8A8_UNORM_SRGB / fmt 29 via the hook
log), the GPU decoded sRGB->linear on the sample, and the host then wrote those
linear values straight to its plain-UNORM swapchain with no re-encode, so the
mirror came out noticeably darker than the game.

Sample the copy as the plain-UNORM sibling of the format (srgb_to_unorm) so the
bytes pass through unchanged -- matching what WGC already does. The UNORM and
*_SRGB formats share a typeless group, so CopyResource from the producer's sRGB
texture into the host's UNORM copy is allowed. Non-sRGB formats are unaffected.

Adds srgb_format_test locking the mapping. All 6 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-20 14:22:31 +02:00
parent edf2da69d8
commit 24d66020f6
5 changed files with 99 additions and 2 deletions

View File

@@ -145,7 +145,10 @@ Done:
swapchains with an `ID3D11Texture2D` backbuffer are caught (the common D3D11
case); D3D9 / pure-D3D12 games keep WGC. Validated by `present_hook_test`
(drives a real D3D11 swapchain end-to-end and reads the pixels back through the
shared texture).
shared texture). The host samples the shared copy as plain UNORM (see
`srgb_to_unorm`) so games with an `*_SRGB` backbuffer (e.g. Life is Strange:
Before the Storm, whose backbuffer is `R8G8B8A8_UNORM_SRGB`) mirror with correct
brightness instead of being darkened by an sRGB→linear decode.
- **x86 (32-bit) game support. ✅** A nested Win32 sub-build (CMake
`ExternalProject`, driven from the normal x64 build) produces `coop_hook_x86.dll`