tint: Fix HLSL texture queries and re-add textureNumLayers()

... overloads for texture cube arrays

FXC is telling porkies, when it says "The array element count
of GetDimensions on TextureCubeArray objects is unavailable
on ps_5_1".

The actual issue, as identified by Teodor Tanasoaia at Mozilla,
is that the argument needs to be unsigned.

In fact, *all* the texture queries should have used an unsigned
scalar or vector for the output value. This has been broken
forever!

This reverts commit bd9f6e6684.

Change-Id: I3e217bec17c6fd203cff618b143ebef3d8a61927
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122980
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2023-03-08 02:48:34 +00:00
committed by Dawn LUCI CQ
parent 4f98dd4706
commit 068eb3ebda
834 changed files with 4944 additions and 1740 deletions

View File

@@ -851,6 +851,17 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
[](ProgramBuilder* b) { return b->ExprList(kTextureName); },
/* returns value */ true,
},
{
ValidTextureOverload::kNumLayersCubeArray,
"textureNumLayers(t : texture_cube_array<f32>) -> u32",
TextureKind::kRegular,
type::SamplerKind::kSampler,
type::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureNumLayers",
[](ProgramBuilder* b) { return b->ExprList(kTextureName); },
/* returns value */ true,
},
{
ValidTextureOverload::kNumLayersDepth2dArray,
"textureNumLayers(t : texture_depth_2d_array) -> u32",
@@ -862,6 +873,17 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
[](ProgramBuilder* b) { return b->ExprList(kTextureName); },
/* returns value */ true,
},
{
ValidTextureOverload::kNumLayersDepthCubeArray,
"textureNumLayers(t : texture_depth_cube_array) -> u32",
TextureKind::kDepth,
type::SamplerKind::kSampler,
type::TextureDimension::kCubeArray,
TextureDataType::kF32,
"textureNumLayers",
[](ProgramBuilder* b) { return b->ExprList(kTextureName); },
/* returns value */ true,
},
{
ValidTextureOverload::kNumLayersStorageWO2dArray,
"textureNumLayers(t : texture_storage_2d_array<rgba32float>) -> u32",

View File

@@ -83,7 +83,9 @@ enum class ValidTextureOverload {
kGatherCompareDepthCubeF32,
kGatherCompareDepthCubeArrayF32,
kNumLayers2dArray,
kNumLayersCubeArray,
kNumLayersDepth2dArray,
kNumLayersDepthCubeArray,
kNumLayersStorageWO2dArray,
kNumLevels2d,
kNumLevels2dArray,

View File

@@ -739,7 +739,9 @@ match workgroup
@must_use fn textureGatherCompare(texture: texture_depth_cube, sampler: sampler_comparison, coords: vec3<f32>, depth_ref: f32) -> vec4<f32>
@must_use fn textureGatherCompare<A: iu32>(texture: texture_depth_cube_array, sampler: sampler_comparison, coords: vec3<f32>, array_index: A, depth_ref: f32) -> vec4<f32>
@must_use fn textureNumLayers<T: fiu32>(texture: texture_2d_array<T>) -> u32
@must_use fn textureNumLayers<T: fiu32>(texture: texture_cube_array<T>) -> u32
@must_use fn textureNumLayers(texture: texture_depth_2d_array) -> u32
@must_use fn textureNumLayers(texture: texture_depth_cube_array) -> u32
@must_use fn textureNumLayers<F: texel_format, A: write>(texture: texture_storage_2d_array<F, A>) -> u32
@must_use fn textureNumLevels<T: fiu32>(texture: texture_1d<T>) -> u32
@must_use fn textureNumLevels<T: fiu32>(texture: texture_2d<T>) -> u32

View File

@@ -2263,7 +2263,9 @@ static const char* expected_texture_overload(ast::builtin::test::ValidTextureOve
case ValidTextureOverload::kGatherCompareDepthCubeArrayF32:
return R"(textureGatherCompare(texture, sampler, coords, array_index, depth_ref))";
case ValidTextureOverload::kNumLayers2dArray:
case ValidTextureOverload::kNumLayersCubeArray:
case ValidTextureOverload::kNumLayersDepth2dArray:
case ValidTextureOverload::kNumLayersDepthCubeArray:
case ValidTextureOverload::kNumLayersStorageWO2dArray:
return R"(textureNumLayers(texture))";
case ValidTextureOverload::kNumLevels2d:

File diff suppressed because it is too large Load Diff

View File

@@ -98,6 +98,8 @@ ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverloa
return R"(textureGather(Texture_Sampler, vec4(1.0f, 2.0f, 3.0f, float(4u)), 5.0f))";
case ValidTextureOverload::kNumLayers2dArray:
case ValidTextureOverload::kNumLayersDepth2dArray:
case ValidTextureOverload::kNumLayersCubeArray:
case ValidTextureOverload::kNumLayersDepthCubeArray:
return {"textureSize"};
case ValidTextureOverload::kNumLayersStorageWO2dArray:
return {"imageSize"};

View File

@@ -2427,9 +2427,9 @@ bool GeneratorImpl::EmitTextureCall(utils::StringStream& out,
// Declare a variable to hold the queried texture info
auto dims = UniqueIdentifier(kTempNamePrefix);
if (num_dimensions == 1) {
line() << "int " << dims << ";";
line() << "uint " << dims << ";";
} else {
line() << "int" << num_dimensions << " " << dims << ";";
line() << "uint" << num_dimensions << " " << dims << ";";
}
{ // texture.GetDimensions(...)

View File

@@ -170,6 +170,8 @@ ExpectedResult expected_texture_overload(ast::builtin::test::ValidTextureOverloa
return R"(tint_symbol.GatherCmp(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4u)), 5.0f))";
case ValidTextureOverload::kNumLayers2dArray:
case ValidTextureOverload::kNumLayersDepth2dArray:
case ValidTextureOverload::kNumLayersCubeArray:
case ValidTextureOverload::kNumLayersDepthCubeArray:
case ValidTextureOverload::kNumLayersStorageWO2dArray:
return {
R"(int3 tint_tmp;

View File

@@ -90,7 +90,9 @@ std::string expected_texture_overload(ast::builtin::test::ValidTextureOverload o
case ValidTextureOverload::kGatherCompareDepthCubeArrayF32:
return R"(Texture.gather_compare(Sampler, float3(1.0f, 2.0f, 3.0f), 4u, 5.0f))";
case ValidTextureOverload::kNumLayers2dArray:
case ValidTextureOverload::kNumLayersCubeArray:
case ValidTextureOverload::kNumLayersDepth2dArray:
case ValidTextureOverload::kNumLayersDepthCubeArray:
case ValidTextureOverload::kNumLayersStorageWO2dArray:
return R"(Texture.get_array_size())";
case ValidTextureOverload::kNumLevels2d:

View File

@@ -1131,6 +1131,29 @@ OpCapability SampledCubeArray
)",
R"(
OpCapability ImageQuery
)"};
case ValidTextureOverload::kNumLayersCubeArray:
return {R"(
%4 = OpTypeFloat 32
%3 = OpTypeImage %4 Cube 0 1 0 1 Unknown
%2 = OpTypePointer UniformConstant %3
%1 = OpVariable %2 UniformConstant
%7 = OpTypeSampler
%6 = OpTypePointer UniformConstant %7
%5 = OpVariable %6 UniformConstant
%9 = OpTypeInt 32 0
%11 = OpTypeVector %9 3
%13 = OpTypeInt 32 1
%14 = OpConstant %13 0
)",
R"(
%12 = OpLoad %3 %1
%10 = OpImageQuerySizeLod %11 %12 %14
%8 = OpCompositeExtract %9 %10 2
)",
R"(
OpCapability SampledCubeArray
OpCapability ImageQuery
)"};
case ValidTextureOverload::kNumLayersDepth2dArray:
return {R"(
@@ -1153,6 +1176,29 @@ OpCapability ImageQuery
)",
R"(
OpCapability ImageQuery
)"};
case ValidTextureOverload::kNumLayersDepthCubeArray:
return {R"(
%4 = OpTypeFloat 32
%3 = OpTypeImage %4 Cube 0 1 0 1 Unknown
%2 = OpTypePointer UniformConstant %3
%1 = OpVariable %2 UniformConstant
%7 = OpTypeSampler
%6 = OpTypePointer UniformConstant %7
%5 = OpVariable %6 UniformConstant
%9 = OpTypeInt 32 0
%11 = OpTypeVector %9 3
%13 = OpTypeInt 32 1
%14 = OpConstant %13 0
)",
R"(
%12 = OpLoad %3 %1
%10 = OpImageQuerySizeLod %11 %12 %14
%8 = OpCompositeExtract %9 %10 2
)",
R"(
OpCapability SampledCubeArray
OpCapability ImageQuery
)"};
case ValidTextureOverload::kNumLayersStorageWO2dArray:
return {R"(