tint: Improve error message for array element stride in uniform storage
Bug: tint:1806 Change-Id: I673c41ce64c1cd2eb75ac93bf1ff9c51dab1c1d0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121042 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: dan sinclair <dsinclair@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
182a7e89a6
commit
9776edf161
|
@ -410,7 +410,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
|||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(34:56 error: uniform storage requires that array elements be aligned to 16 bytes, but array element alignment is currently 4. Consider using a vector or struct as the element type instead.
|
||||
R"(34:56 error: uniform storage requires that array elements are aligned to 16 bytes, but array element of type 'f32' has a stride of 4 bytes. Consider using a vector or struct as the element type instead.
|
||||
12:34 note: see layout of struct:
|
||||
/* align(4) size(44) */ struct Outer {
|
||||
/* offset( 0) align(4) size(40) */ inner : array<f32, 10>;
|
||||
|
@ -444,7 +444,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
|||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(34:56 error: uniform storage requires that array elements be aligned to 16 bytes, but array element alignment is currently 8. Consider using a vec4 instead.
|
||||
R"(34:56 error: uniform storage requires that array elements are aligned to 16 bytes, but array element of type 'vec2<f32>' has a stride of 8 bytes. Consider using a vec4 instead.
|
||||
12:34 note: see layout of struct:
|
||||
/* align(8) size(88) */ struct Outer {
|
||||
/* offset( 0) align(8) size(80) */ inner : array<vec2<f32>, 10>;
|
||||
|
@ -487,7 +487,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
|||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(34:56 error: uniform storage requires that array elements be aligned to 16 bytes, but array element alignment is currently 8. Consider using the @size attribute on the last struct member.
|
||||
R"(34:56 error: uniform storage requires that array elements are aligned to 16 bytes, but array element of type 'ArrayElem' has a stride of 8 bytes. Consider using the @size attribute on the last struct member.
|
||||
12:34 note: see layout of struct:
|
||||
/* align(4) size(84) */ struct Outer {
|
||||
/* offset( 0) align(4) size(80) */ inner : array<ArrayElem, 10>;
|
||||
|
@ -505,7 +505,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
|||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(78:90 error: uniform storage requires that array elements be aligned to 16 bytes, but array element alignment is currently 4. Consider using a vector or struct as the element type instead.)");
|
||||
R"(78:90 error: uniform storage requires that array elements are aligned to 16 bytes, but array element of type 'f32' has a stride of 4 bytes. Consider using a vector or struct as the element type instead.)");
|
||||
}
|
||||
|
||||
TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStride_NestedArray) {
|
||||
|
@ -527,7 +527,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid
|
|||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(34:56 error: uniform storage requires that array elements be aligned to 16 bytes, but array element alignment is currently 4. Consider using a vector or struct as the element type instead.
|
||||
R"(34:56 error: uniform storage requires that array elements are aligned to 16 bytes, but array element of type 'f32' has a stride of 4 bytes. Consider using a vector or struct as the element type instead.
|
||||
12:34 note: see layout of struct:
|
||||
/* align(4) size(64) */ struct Outer {
|
||||
/* offset( 0) align(4) size(64) */ inner : array<array<f32, 4>, 4>;
|
||||
|
|
|
@ -567,7 +567,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBuffer_Struct_Run
|
|||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: uniform storage requires that array elements be aligned to 16 bytes, but array element alignment is currently 4. Consider using a vector or struct as the element type instead.
|
||||
R"(12:34 error: uniform storage requires that array elements are aligned to 16 bytes, but array element of type 'i32' has a stride of 4 bytes. Consider using a vector or struct as the element type instead.
|
||||
note: see layout of struct:
|
||||
/* align(4) size(4) */ struct S {
|
||||
/* offset(0) align(4) size(4) */ m : array<i32>;
|
||||
|
|
|
@ -546,9 +546,10 @@ bool Validator::AddressSpaceLayout(const type::Type* store_ty,
|
|||
"attribute.";
|
||||
}
|
||||
AddError(
|
||||
"uniform storage requires that array elements be aligned to 16 "
|
||||
"bytes, but array element alignment is currently " +
|
||||
std::to_string(arr->Stride()) + ". " + hint,
|
||||
"uniform storage requires that array elements are aligned to 16 bytes, but "
|
||||
"array element of type '" +
|
||||
arr->ElemType()->FriendlyName(symbols_) + "' has a stride of " +
|
||||
std::to_string(arr->Stride()) + " bytes. " + hint,
|
||||
source);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue