Differentiate size and stride in array type name.
This CL adds a `_stride_` into the array type name to differentiate an array of 8 elements and a runtime array of stride 8. Bug: tint:102 Change-Id: Iaf10fe5957acde16a9ccdf2a0fd8a83e47bb57bc Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24962 Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
aa601387a2
commit
4556cbe24f
|
@ -38,7 +38,7 @@ std::string ArrayType::type_name() const {
|
|||
if (!IsRuntimeArray())
|
||||
type_name += "_" + std::to_string(size_);
|
||||
if (has_array_stride())
|
||||
type_name += "_" + std::to_string(array_stride_);
|
||||
type_name += "_stride_" + std::to_string(array_stride_);
|
||||
|
||||
return type_name;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ TEST_F(ArrayTypeTest, TypeName_WithStride) {
|
|||
I32Type i32;
|
||||
ArrayType arr{&i32, 3};
|
||||
arr.set_array_stride(16);
|
||||
EXPECT_EQ(arr.type_name(), "__array__i32_3_16");
|
||||
EXPECT_EQ(arr.type_name(), "__array__i32_3_stride_16");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -462,10 +462,10 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType) {
|
|||
Variable{
|
||||
x_200
|
||||
function
|
||||
__alias_Arr__array__u32_2_16
|
||||
__alias_Arr__array__u32_2_stride_16
|
||||
{
|
||||
TypeConstructor{
|
||||
__alias_Arr__array__u32_2_16
|
||||
__alias_Arr__array__u32_2_stride_16
|
||||
ScalarConstructor{1}
|
||||
ScalarConstructor{2}
|
||||
}
|
||||
|
@ -529,10 +529,10 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType_Null) {
|
|||
Variable{
|
||||
x_200
|
||||
function
|
||||
__alias_Arr__array__u32_2_16
|
||||
__alias_Arr__array__u32_2_stride_16
|
||||
{
|
||||
TypeConstructor{
|
||||
__alias_Arr__array__u32_2_16
|
||||
__alias_Arr__array__u32_2_stride_16
|
||||
ScalarConstructor{0}
|
||||
ScalarConstructor{0}
|
||||
}
|
||||
|
|
|
@ -75,9 +75,8 @@ TEST_F(SpvParserTest, NamedTypes_AnonRTArrayWithDecoration) {
|
|||
%arr = OpTypeRuntimeArray %uint
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
// TODO(dneto): this is a string collision with array<u32,8>
|
||||
// https://bugs.chromium.org/p/tint/issues/detail?id=102
|
||||
EXPECT_THAT(p->module().to_str(), HasSubstr("RTArr -> __array__u32_8\n"));
|
||||
EXPECT_THAT(p->module().to_str(),
|
||||
HasSubstr("RTArr -> __array__u32_stride_8\n"));
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_AnonRTArray_Dup_EmitBoth) {
|
||||
|
@ -89,9 +88,9 @@ TEST_F(SpvParserTest, NamedTypes_AnonRTArray_Dup_EmitBoth) {
|
|||
%arr2 = OpTypeRuntimeArray %uint
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(
|
||||
p->module().to_str(),
|
||||
HasSubstr("RTArr -> __array__u32_8\nRTArr_1 -> __array__u32_8\n"));
|
||||
EXPECT_THAT(p->module().to_str(),
|
||||
HasSubstr("RTArr -> __array__u32_stride_8\nRTArr_1 -> "
|
||||
"__array__u32_stride_8\n"));
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_NamedRTArray) {
|
||||
|
@ -102,7 +101,8 @@ TEST_F(SpvParserTest, NamedTypes_NamedRTArray) {
|
|||
%arr = OpTypeRuntimeArray %uint
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(p->module().to_str(), HasSubstr("myrtarr -> __array__u32_8\n"));
|
||||
EXPECT_THAT(p->module().to_str(),
|
||||
HasSubstr("myrtarr -> __array__u32_stride_8\n"));
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_NamedArray) {
|
||||
|
@ -115,7 +115,8 @@ TEST_F(SpvParserTest, NamedTypes_NamedArray) {
|
|||
%arr2 = OpTypeArray %uint %uint_5
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(p->module().to_str(), HasSubstr("myarr -> __array__u32_5_8"));
|
||||
EXPECT_THAT(p->module().to_str(),
|
||||
HasSubstr("myarr -> __array__u32_5_stride_8"));
|
||||
}
|
||||
|
||||
TEST_F(SpvParserTest, NamedTypes_AnonArray_Dup_EmitBoth) {
|
||||
|
@ -128,8 +129,10 @@ TEST_F(SpvParserTest, NamedTypes_AnonArray_Dup_EmitBoth) {
|
|||
%arr2 = OpTypeArray %uint %uint_5
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
EXPECT_THAT(p->module().to_str(),
|
||||
HasSubstr("Arr -> __array__u32_5_8\nArr_1 -> __array__u32_5_8"));
|
||||
EXPECT_THAT(
|
||||
p->module().to_str(),
|
||||
HasSubstr(
|
||||
"Arr -> __array__u32_5_stride_8\nArr_1 -> __array__u32_5_stride_"));
|
||||
}
|
||||
|
||||
// TODO(dneto): Handle arrays sized by a spec constant.
|
||||
|
|
Loading…
Reference in New Issue