gpu: validate depth and cube texture descriptors

Accept SDK-valid depth sampler modulation and validate cube storage images as complete six-layer groups.
This commit is contained in:
nmzik
2026-08-11 16:45:32 +02:00
parent 472c8213db
commit 9a76719544
2 changed files with 43 additions and 8 deletions
@@ -282,13 +282,13 @@ bool IsSupportedDepthTextureEncoding(const ShaderTextureResource& descriptor, co
(static_cast<uint32_t>(descriptor.TileMode()) << 20u) |
(static_cast<uint32_t>(descriptor.Type()) << 28u);
const uint32_t field4_expected = descriptor.Depth() | (descriptor.BaseArray5() << 16u);
const uint32_t field5_expected =
0x00700000u | (static_cast<uint32_t>(descriptor.MaxMip()) << 4u);
const bool common = (descriptor.fields[1] & field1_reserved_mask) == 0 &&
(descriptor.fields[2] & field2_reserved_mask) == 0 &&
descriptor.fields[3] == field3_expected &&
descriptor.fields[4] == field4_expected &&
descriptor.fields[5] == field5_expected;
const uint32_t field5_expected = (static_cast<uint32_t>(descriptor.PerfMod5()) << 20u) |
(static_cast<uint32_t>(descriptor.MaxMip()) << 4u);
const bool common = (descriptor.fields[1] & field1_reserved_mask) == 0 &&
(descriptor.fields[2] & field2_reserved_mask) == 0 &&
descriptor.fields[3] == field3_expected &&
descriptor.fields[4] == field4_expected &&
descriptor.fields[5] == field5_expected;
if (!common || (descriptor.fields[6] == 0 && descriptor.fields[7] != 0)) {
return false;
}
@@ -362,9 +362,14 @@ static bool IsSupportedStorageTextureDescriptor(const ShaderRecompiler::IR::Imag
(is_color_2d_array && descriptor.BaseArray5() <= descriptor.Depth());
const bool is_2d =
resource.dimension == ShaderRecompiler::Decoder::ImageDimension::Dim2D && valid_2d_slice;
const bool is_cube = resource.cube && descriptor.Type() == Prospero::ImageType::kCube &&
descriptor.Width5() == descriptor.Height5() &&
descriptor.BaseArray5() <= descriptor.Depth() &&
(descriptor.Depth() - descriptor.BaseArray5() + 1u) % 6u == 0;
const bool is_2d_array =
resource.dimension == ShaderRecompiler::Decoder::ImageDimension::Dim2DArray &&
is_color_2d_array && descriptor.BaseArray5() <= descriptor.Depth();
((!resource.cube && is_color_2d_array && descriptor.BaseArray5() <= descriptor.Depth()) ||
is_cube);
const bool is_3d = resource.dimension == ShaderRecompiler::Decoder::ImageDimension::Dim3D &&
descriptor.Type() == Prospero::ImageType::kColor3D &&
descriptor.BaseArray5() == 0;
+30
View File
@@ -16763,6 +16763,21 @@ void CheckSampledDepthDescriptor(RenderContext& renderer) {
IsSupportedDepthTargetDescriptor(descriptor, image),
"normalized depth image rejected a valid padded descriptor");
const ShaderTextureResource disabled_sampler_tweaks {{
0x05135600u,
0xc1600000u,
0x010dc1dfu,
0x91800924u,
0x00000000u,
0x00000000u,
0x00000000u,
0x00000000u,
}};
Require("SampledDepthDescriptor", "disabled sampler tweaks",
disabled_sampler_tweaks.PerfMod5() == 0 &&
IsSupportedDepthTextureEncoding(disabled_sampler_tweaks, image),
"valid sampler modulation factor zero was rejected");
const ShaderTextureResource uncompressed_msaa {{
0x00705d00u,
0xc1600000u,
@@ -17223,6 +17238,21 @@ void CheckBasicStorageTextureDescriptor() {
Require("BasicStorageTexture", "all write swizzles", valid_storage_swizzles == 1296,
"valid write-only storage image mappings were rejected");
const ShaderTextureResource cube {{0x025bca00u, 0xc4700000u, 0x003fc03fu, 0xb1b00facu,
0x00000005u, 0x00700080u, 0x00000000u, 0x00000000u}};
auto cube_resource = BasicArrayStorageTextureResource();
cube_resource.cube = true;
Require("BasicStorageTexture", "PPSA07429 cube descriptor",
cube.Base40() == 0x25bca0000ull && cube.Width5() + 1u == 256 &&
cube.Height5() + 1u == 256 && cube.Depth() + 1u == 6 &&
cube.BaseArray5() == 0 && cube.MaxMip() == 8 &&
cube.Type() == Prospero::ImageType::kCube &&
cube.Format() == Prospero::BufferFormat::k16_16_16_16Float &&
cube.TileMode() == Prospero::TileMode::kRenderTarget &&
cube.DstSelXYZW() == DstSel(4, 5, 6, 7),
"PPSA07429 cube storage descriptor fixture is malformed");
ValidateStorageTexture(cube_resource, cube, 0x420000);
const auto array = BasicArrayStorageTextureDescriptor();
Require("BasicStorageTexture", "2D-array descriptor",
array.Base40() == 0x2017900000ull && array.Width5() + 1u == 1 &&