From 52c8ff18d0b79f4b1ca86d8cfeda19fbb40ec3cc Mon Sep 17 00:00:00 2001 From: rocketrobot99 Date: Sat, 3 Oct 2026 13:57:59 +0100 Subject: [PATCH] Update gpu_format.cpp (#1003) * Update gpu_format.cpp Fix SRGB render-target formats (k8Srgb, k8_8Srgb) Corrects render_target_bytes_per_element for SRGB formats: - k8Srgb: 1 byte (was 0) - k8_8Srgb: 2 bytes (was 0) These formats appear in ChannelLayout::k8 and k8_8 render-target paths. Incorrect RT byte sizes caused TextureCache render-target validation failures in Lucky's Tale * Fix narrow sRGB render-target format tests --------- Co-authored-by: nmzik --- src/graphics/guest_gpu/gpu_format.cpp | 4 ++-- tests/ShaderRecompilerComputeTests.cpp | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/graphics/guest_gpu/gpu_format.cpp b/src/graphics/guest_gpu/gpu_format.cpp index 5eb99ff0..4fdaaac8 100644 --- a/src/graphics/guest_gpu/gpu_format.cpp +++ b/src/graphics/guest_gpu/gpu_format.cpp @@ -61,8 +61,8 @@ constexpr FormatInfo kFormatInfo[] = { {BufferFormat::k32_32_32_32UInt, 16, 0, 16, true, true}, {BufferFormat::k32_32_32_32SInt, 16, 0, 16, true, false, true}, {BufferFormat::k32_32_32_32Float, 16, 0, 16, true, false}, - {BufferFormat::k8Srgb, 1, 0, 0, true, false}, - {BufferFormat::k8_8Srgb, 2, 0, 0, true, false}, + {BufferFormat::k8Srgb, 1, 0, 1, true, false}, + {BufferFormat::k8_8Srgb, 2, 0, 2, true, false}, {BufferFormat::k8_8_8_8Srgb, 4, 0, 4, true, false}, {BufferFormat::k9_9_9_5Float, 4, 0, 0, true, false}, {BufferFormat::k5_6_5UNorm, 2, 0, 2, true, false}, diff --git a/tests/ShaderRecompilerComputeTests.cpp b/tests/ShaderRecompilerComputeTests.cpp index e7e3cc0c..2b4ffa7a 100644 --- a/tests/ShaderRecompilerComputeTests.cpp +++ b/tests/ShaderRecompilerComputeTests.cpp @@ -16033,15 +16033,26 @@ public: {Prospero::TileMode::kStandard64KB, TileBlockFamily::Standard64KB}, {Prospero::TileMode::kPrt, TileBlockFamily::Prt64KB}, }; - for (const auto format : - {Prospero::BufferFormat::k8Srgb, Prospero::BufferFormat::k8_8Srgb, - Prospero::BufferFormat::k9_9_9_5Float}) { + struct RenderTargetFormatCase { + Prospero::BufferFormat format; + u32 bytes_per_element; + }; + constexpr RenderTargetFormatCase render_target_formats[] = { + {Prospero::BufferFormat::k8Srgb, 1}, + {Prospero::BufferFormat::k8_8Srgb, 2}, + {Prospero::BufferFormat::k9_9_9_5Float, 0}, + }; + for (const auto &test : render_target_formats) { for (const auto tile : {Prospero::TileMode::kDepth, Prospero::TileMode::kRenderTarget}) { TileTextureBlockLayout texture{}; + const bool supported = + TileGetTextureBlockLayout(test.format, tile, false, texture); Require(name, "RT format policy", - !TileGetTextureBlockLayout(format, tile, false, texture), - "non-render-target format admitted by an RT/depth tile family"); + supported == (test.bytes_per_element != 0) && + (!supported || texture.block.bytes_per_element == + test.bytes_per_element), + "RT/depth tile format support or element size is incorrect"); } } {