spirv-reader: texture level and array index are signed

Fixed: tint:394
Change-Id: Ic81c7167d65e7a8d09363a62848b74928fdc2798
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35043
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
David Neto 2020-12-07 18:17:14 +00:00 committed by Commit Bot service account
parent c35176eadf
commit 4f8b96e13c
2 changed files with 22 additions and 21 deletions

View File

@ -55,6 +55,7 @@
#include "src/ast/type/bool_type.h"
#include "src/ast/type/depth_texture_type.h"
#include "src/ast/type/f32_type.h"
#include "src/ast/type/i32_type.h"
#include "src/ast/type/pointer_type.h"
#include "src/ast/type/storage_texture_type.h"
#include "src/ast/type/texture_type.h"
@ -3748,9 +3749,9 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) {
// When sampling from a depth texture, the Lod operand must be an unsigned
// integer.
if (texture_type->Is<ast::type::DepthTexture>()) {
// Convert it to an unsigned integer type.
// Convert it to a signed integer type.
lod_operand = ast_module_.create<ast::TypeConstructorExpression>(
ast_module_.create<ast::type::U32>(),
ast_module_.create<ast::type::I32>(),
ast::ExpressionList{lod_operand});
}
params.push_back(lod_operand);
@ -3902,9 +3903,9 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
ast::Expression* array_index =
ast_module_.create<ast::MemberAccessorExpression>(raw_coords.expr,
Swizzle(num_axes));
// Convert it to an unsigned integer type.
// Convert it to a signed integer type.
result.push_back(ast_module_.create<ast::TypeConstructorExpression>(
ast_module_.create<ast::type::U32>(),
ast_module_.create<ast::type::I32>(),
ast::ExpressionList{array_index}));
} else {
if (num_coords_supplied == num_coords_required) {

View File

@ -1387,7 +1387,7 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{xy}
}
TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{coords123}
Identifier[not set]{z}
@ -1466,7 +1466,7 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{xy}
}
TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{coords123}
Identifier[not set]{z}
@ -1544,7 +1544,7 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{xy}
}
TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{coords123}
Identifier[not set]{z}
@ -1626,7 +1626,7 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{xy}
}
TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{coords123}
Identifier[not set]{z}
@ -1789,7 +1789,7 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{xy}
}
TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{coords123}
Identifier[not set]{z}
@ -1868,7 +1868,7 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{xy}
}
TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{coords123}
Identifier[not set]{z}
@ -1952,7 +1952,7 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{xy}
}
TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{coords123}
Identifier[not set]{z}
@ -2035,7 +2035,7 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{xy}
}
TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{coords123}
Identifier[not set]{z}
@ -2117,7 +2117,7 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{xy}
}
TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{coords123}
Identifier[not set]{z}
@ -2203,7 +2203,7 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{xy}
}
TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{coords123}
Identifier[not set]{z}
@ -2289,7 +2289,7 @@ INSTANTIATE_TEST_SUITE_P(
Identifier[not set]{x_10}
Identifier[not set]{vf12}
TypeConstructor[not set]{
__u32
__i32
Identifier[not set]{f1}
}
)
@ -3122,7 +3122,7 @@ INSTANTIATE_TEST_SUITE_P(Good_1DArray,
}
)",
R"(TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{vf12}
Identifier[not set]{y}
@ -3140,7 +3140,7 @@ INSTANTIATE_TEST_SUITE_P(Good_1DArray,
}
)",
R"(TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{vf123}
Identifier[not set]{y}
@ -3158,7 +3158,7 @@ INSTANTIATE_TEST_SUITE_P(Good_1DArray,
}
)",
R"(TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{vf1234}
Identifier[not set]{y}
@ -3207,7 +3207,7 @@ INSTANTIATE_TEST_SUITE_P(Good_2DArray,
}
)",
R"(TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{vf123}
Identifier[not set]{z}
@ -3225,7 +3225,7 @@ INSTANTIATE_TEST_SUITE_P(Good_2DArray,
}
)",
R"(TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{vf1234}
Identifier[not set]{z}
@ -3289,7 +3289,7 @@ INSTANTIATE_TEST_SUITE_P(Good_CubeArray,
}
)",
R"(TypeConstructor[not set]{
__u32
__i32
MemberAccessor[not set]{
Identifier[not set]{vf1234}
Identifier[not set]{w}