spirv-reader: textureDimensions returns 3-elem vec for Cube,CubeArray

Fixed: tint:787
Bug: tint:765
Change-Id: If5cebb21bf169765f3baf8a5aec4a3dace19d707
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50601
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: David Neto <dneto@google.com>
This commit is contained in:
David Neto 2021-05-11 23:16:31 +00:00 committed by Commit Bot service account
parent b5236b2783
commit facd33199a
2 changed files with 86 additions and 73 deletions

View File

@ -4755,9 +4755,17 @@ bool FunctionEmitter::EmitImageQuery(const spvtools::opt::Instruction& inst) {
if (opcode == SpvOpImageQuerySizeLod) { if (opcode == SpvOpImageQuerySizeLod) {
dims_args.push_back(ToI32(MakeOperand(inst, 1)).expr); dims_args.push_back(ToI32(MakeOperand(inst, 1)).expr);
} }
exprs.push_back( ast::Expression* dims_call =
create<ast::CallExpression>(Source{}, dims_ident, dims_args)); create<ast::CallExpression>(Source{}, dims_ident, dims_args);
if (ast::IsTextureArray(texture_type->dims)) { auto dims = texture_type->dims;
if ((dims == ast::TextureDimension::kCube) ||
(dims == ast::TextureDimension::kCubeArray)) {
// textureDimension returns a 3-element vector but SPIR-V expects 2.
dims_call = create<ast::MemberAccessorExpression>(Source{}, dims_call,
PrefixSwizzle(2));
}
exprs.push_back(dims_call);
if (ast::IsTextureArray(dims)) {
auto* layers_ident = create<ast::IdentifierExpression>( auto* layers_ident = create<ast::IdentifierExpression>(
Source{}, builder_.Symbols().Register("textureNumLayers")); Source{}, builder_.Symbols().Register("textureNumLayers"));
exprs.push_back(create<ast::CallExpression>( exprs.push_back(create<ast::CallExpression>(

View File

@ -1592,11 +1592,6 @@ TEST_P(SpvParserHandleTest_SampledImageAccessTest, Variable) {
GetParam().spirv_image_access.find("ImageQuerySize") != std::string::npos; GetParam().spirv_image_access.find("ImageQuerySize") != std::string::npos;
const bool is_1d = const bool is_1d =
GetParam().spirv_image_type_details.find("1D") != std::string::npos; GetParam().spirv_image_type_details.find("1D") != std::string::npos;
const bool is_cube =
GetParam().spirv_image_type_details.find("Cube") != std::string::npos;
if (is_query_size && is_cube) {
p->SkipDumpingPending("crbug.com/tint/787");
}
if (is_query_size && is_1d) { if (is_query_size && is_1d) {
p->SkipDumpingPending("crbug.com/tint/788"); p->SkipDumpingPending("crbug.com/tint/788");
} }
@ -4132,11 +4127,9 @@ INSTANTIATE_TEST_SUITE_P(
// Not in WebGPU // Not in WebGPU
})); }));
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(ImageQuerySizeLod_NonArrayed_SignedResult_SignedLevel,
ImageQuerySizeLod_NonArrayed_SignedResult_SignedLevel, // From VUID-StandaloneSpirv-OpImageQuerySizeLod-04659:
// ImageQuerySize requires storage image or multisampled // ImageQuerySizeLod requires Sampled=1
// For storage image, use another instruction to indicate whether it
// is readonly or writeonly.
SpvParserHandleTest_SampledImageAccessTest, SpvParserHandleTest_SampledImageAccessTest,
::testing::ValuesIn(std::vector<ImageAccessCase>{ ::testing::ValuesIn(std::vector<ImageAccessCase>{
@ -4238,7 +4231,7 @@ INSTANTIATE_TEST_SUITE_P(
// Cube // Cube
{"%float Cube 0 0 0 1 Unknown", {"%float Cube 0 0 0 1 Unknown",
"%99 = OpImageQuerySizeLod %v3int %im %i1\n", "%99 = OpImageQuerySizeLod %v2int %im %i1\n",
R"(Variable{ R"(Variable{
Decorations{ Decorations{
GroupDecoration{2} GroupDecoration{2}
@ -4252,10 +4245,11 @@ INSTANTIATE_TEST_SUITE_P(
VariableConst{ VariableConst{
x_99 x_99
none none
__vec_3__i32 __vec_2__i32
{ {
TypeConstructor[not set]{ TypeConstructor[not set]{
__vec_3__i32 __vec_2__i32
MemberAccessor[not set]{
Call[not set]{ Call[not set]{
Identifier[not set]{textureDimensions} Identifier[not set]{textureDimensions}
( (
@ -4263,6 +4257,8 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{i1} Identifier[not set]{i1}
) )
} }
Identifier[not set]{xy}
}
} }
} }
} }
@ -4302,7 +4298,7 @@ INSTANTIATE_TEST_SUITE_P(
// Depth Cube // Depth Cube
{"%float Cube 1 0 0 1 Unknown", {"%float Cube 1 0 0 1 Unknown",
"%99 = OpImageQuerySizeLod %v3int %im %i1\n", "%99 = OpImageQuerySizeLod %v2int %im %i1\n",
R"(Variable{ R"(Variable{
Decorations{ Decorations{
GroupDecoration{2} GroupDecoration{2}
@ -4316,10 +4312,11 @@ INSTANTIATE_TEST_SUITE_P(
VariableConst{ VariableConst{
x_99 x_99
none none
__vec_3__i32 __vec_2__i32
{ {
TypeConstructor[not set]{ TypeConstructor[not set]{
__vec_3__i32 __vec_2__i32
MemberAccessor[not set]{
Call[not set]{ Call[not set]{
Identifier[not set]{textureDimensions} Identifier[not set]{textureDimensions}
( (
@ -4327,6 +4324,8 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{i1} Identifier[not set]{i1}
) )
} }
Identifier[not set]{xy}
}
} }
} }
} }
@ -4406,6 +4405,7 @@ INSTANTIATE_TEST_SUITE_P(
{ {
TypeConstructor[not set]{ TypeConstructor[not set]{
__vec_3__i32 __vec_3__i32
MemberAccessor[not set]{
Call[not set]{ Call[not set]{
Identifier[not set]{textureDimensions} Identifier[not set]{textureDimensions}
( (
@ -4413,6 +4413,8 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{i1} Identifier[not set]{i1}
) )
} }
Identifier[not set]{xy}
}
Call[not set]{ Call[not set]{
Identifier[not set]{textureNumLayers} Identifier[not set]{textureNumLayers}
( (
@ -4486,6 +4488,7 @@ INSTANTIATE_TEST_SUITE_P(
{ {
TypeConstructor[not set]{ TypeConstructor[not set]{
__vec_3__i32 __vec_3__i32
MemberAccessor[not set]{
Call[not set]{ Call[not set]{
Identifier[not set]{textureDimensions} Identifier[not set]{textureDimensions}
( (
@ -4493,6 +4496,8 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{i1} Identifier[not set]{i1}
) )
} }
Identifier[not set]{xy}
}
Call[not set]{ Call[not set]{
Identifier[not set]{textureNumLayers} Identifier[not set]{textureNumLayers}
( (