// Unit test for srgb_to_unorm (host/src/capture/dxgi_format.hpp): the hooked // video path samples the shared backbuffer copy as plain UNORM so an *_SRGB game // backbuffer isn't darkened by an sRGB->linear decode the host never re-encodes. // Locks the format mapping that fix depends on. No device needed. #include #include "capture/dxgi_format.hpp" using namespace coop; namespace { int g_failures = 0; void expect(DXGI_FORMAT in, DXGI_FORMAT want, const char* what) { const DXGI_FORMAT got = srgb_to_unorm(in); if (got != want) { std::printf(" FAIL: %s (got %d, want %d)\n", what, static_cast(got), static_cast(want)); ++g_failures; } } } // namespace int main() { // sRGB formats map to their plain-UNORM sibling. expect(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_R8G8B8A8_UNORM, "R8G8B8A8 sRGB -> UNORM"); expect(DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, DXGI_FORMAT_B8G8R8A8_UNORM, "B8G8R8A8 sRGB -> UNORM"); expect(DXGI_FORMAT_B8G8R8X8_UNORM_SRGB, DXGI_FORMAT_B8G8R8X8_UNORM, "B8G8R8X8 sRGB -> UNORM"); // Non-sRGB formats pass through unchanged. expect(DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, "R8G8B8A8 UNORM passthrough"); expect(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, "B8G8R8A8 UNORM passthrough"); expect(DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_R10G10B10A2_UNORM, "R10G10B10A2 passthrough"); expect(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, "RGBA16F passthrough"); std::printf(g_failures == 0 ? "SRGB FORMAT TEST PASS\n" : "SRGB FORMAT TEST FAILED (%d)\n", g_failures); return g_failures == 0 ? 0 : 1; }