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) {
dims_args.push_back(ToI32(MakeOperand(inst, 1)).expr);
}
exprs.push_back(
create<ast::CallExpression>(Source{}, dims_ident, dims_args));
if (ast::IsTextureArray(texture_type->dims)) {
ast::Expression* dims_call =
create<ast::CallExpression>(Source{}, dims_ident, dims_args);
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>(
Source{}, builder_.Symbols().Register("textureNumLayers"));
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;
const bool is_1d =
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) {
p->SkipDumpingPending("crbug.com/tint/788");
}
@ -4132,11 +4127,9 @@ INSTANTIATE_TEST_SUITE_P(
// Not in WebGPU
}));
INSTANTIATE_TEST_SUITE_P(
ImageQuerySizeLod_NonArrayed_SignedResult_SignedLevel,
// ImageQuerySize requires storage image or multisampled
// For storage image, use another instruction to indicate whether it
// is readonly or writeonly.
INSTANTIATE_TEST_SUITE_P(ImageQuerySizeLod_NonArrayed_SignedResult_SignedLevel,
// From VUID-StandaloneSpirv-OpImageQuerySizeLod-04659:
// ImageQuerySizeLod requires Sampled=1
SpvParserHandleTest_SampledImageAccessTest,
::testing::ValuesIn(std::vector<ImageAccessCase>{
@ -4238,7 +4231,7 @@ INSTANTIATE_TEST_SUITE_P(
// Cube
{"%float Cube 0 0 0 1 Unknown",
"%99 = OpImageQuerySizeLod %v3int %im %i1\n",
"%99 = OpImageQuerySizeLod %v2int %im %i1\n",
R"(Variable{
Decorations{
GroupDecoration{2}
@ -4252,10 +4245,11 @@ INSTANTIATE_TEST_SUITE_P(
VariableConst{
x_99
none
__vec_3__i32
__vec_2__i32
{
TypeConstructor[not set]{
__vec_3__i32
__vec_2__i32
MemberAccessor[not set]{
Call[not set]{
Identifier[not set]{textureDimensions}
(
@ -4263,6 +4257,8 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{i1}
)
}
Identifier[not set]{xy}
}
}
}
}
@ -4302,7 +4298,7 @@ INSTANTIATE_TEST_SUITE_P(
// Depth Cube
{"%float Cube 1 0 0 1 Unknown",
"%99 = OpImageQuerySizeLod %v3int %im %i1\n",
"%99 = OpImageQuerySizeLod %v2int %im %i1\n",
R"(Variable{
Decorations{
GroupDecoration{2}
@ -4316,10 +4312,11 @@ INSTANTIATE_TEST_SUITE_P(
VariableConst{
x_99
none
__vec_3__i32
__vec_2__i32
{
TypeConstructor[not set]{
__vec_3__i32
__vec_2__i32
MemberAccessor[not set]{
Call[not set]{
Identifier[not set]{textureDimensions}
(
@ -4327,6 +4324,8 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{i1}
)
}
Identifier[not set]{xy}
}
}
}
}
@ -4406,6 +4405,7 @@ INSTANTIATE_TEST_SUITE_P(
{
TypeConstructor[not set]{
__vec_3__i32
MemberAccessor[not set]{
Call[not set]{
Identifier[not set]{textureDimensions}
(
@ -4413,6 +4413,8 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{i1}
)
}
Identifier[not set]{xy}
}
Call[not set]{
Identifier[not set]{textureNumLayers}
(
@ -4486,6 +4488,7 @@ INSTANTIATE_TEST_SUITE_P(
{
TypeConstructor[not set]{
__vec_3__i32
MemberAccessor[not set]{
Call[not set]{
Identifier[not set]{textureDimensions}
(
@ -4493,6 +4496,8 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{i1}
)
}
Identifier[not set]{xy}
}
Call[not set]{
Identifier[not set]{textureNumLayers}
(