diff --git a/src/graphics/host_gpu/renderer/pipeline/descriptors.cpp b/src/graphics/host_gpu/renderer/pipeline/descriptors.cpp index d85623975..4bd9c0c93 100644 --- a/src/graphics/host_gpu/renderer/pipeline/descriptors.cpp +++ b/src/graphics/host_gpu/renderer/pipeline/descriptors.cpp @@ -184,17 +184,18 @@ bool IsSupportedDepthTextureEncoding(const ShaderTextureResource& descriptor, bo } const bool full = common && descriptor.fields[4] == field4_expected && descriptor.fields[5] == field5_expected; - if (!full || (descriptor.fields[6] == 0 && descriptor.fields[7] != 0) || + if (!full || (descriptor.MsaaDepth() && !IsMultisampledTexture(descriptor.Type()))) { return false; } - if (descriptor.fields[6] == 0) { + const auto metadata_control = descriptor.fields[6] & 0x00ffffffu; + if (metadata_control == 0) { return true; } constexpr uint32_t htile_control = 0x00280000u; const uint32_t expected_control = htile_control | (descriptor.MsaaDepth() ? (1u << 10u) : 0u); const auto metadata_addr = descriptor.MetaAddr() << 8u; - return (descriptor.fields[6] & 0x00ffffffu) == expected_control && metadata_addr != 0 && + return metadata_control == expected_control && metadata_addr != 0 && metadata_addr < TRACKER_ADDRESS_SIZE && (metadata_addr & 0x7fffu) == 0 && descriptor.TileMode() == Prospero::TileMode::kDepth; } diff --git a/tests/ShaderRecompilerComputeTests.cpp b/tests/ShaderRecompilerComputeTests.cpp index 69a0fe8ec..219050959 100644 --- a/tests/ShaderRecompilerComputeTests.cpp +++ b/tests/ShaderRecompilerComputeTests.cpp @@ -29200,6 +29200,17 @@ void CheckDepthTextureEncoding() { IsSupportedDepthTextureEncoding(compressed_descriptor), "valid compressed depth descriptor required a prior depth target"); + const ShaderTextureResource disabled_metadata{{ + 0x20018100u, 0xc1600000u, 0x021bc1dfu, 0x91800204u, + 0x00000000u, 0x00700000u, 0x00000000u, 0x0020037fu, + }}; + auto retained_metadata_address = compressed_descriptor; + retained_metadata_address.fields[6] &= 0xff000000u; + Require("DepthTextureEncoding", "disabled metadata with retained address", + IsSupportedDepthTextureEncoding(disabled_metadata) && + IsSupportedDepthTextureEncoding(retained_metadata_address), + "uncompressed depth rejected inactive metadata address bits"); + const ShaderTextureResource first_use_depth{{ 0x0225fc00u, 0x01600000u, 0x00000000u, 0x91800924u, 0x00000000u, 0x00700000u, 0x80280000u, 0x000225fdu,