tint/writer/wgsl: Print @offset attributes as comment

We use WGSL to visualize the AST. Make sure we don't hide anything.

Bug: tint:1776
Change-Id: Iedd7ca797fb745d9db7d0aba8a5718039241afbb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/112602
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2022-12-01 17:37:56 +00:00
committed by Dawn LUCI CQ
parent f745e4e2bf
commit efb17b0254
74 changed files with 240 additions and 1 deletions

View File

@@ -953,7 +953,9 @@ TEST_F(SpvParserMemoryTest, RemapStorageBuffer_TypesAndVarDeclarations) {
EXPECT_THAT(module_str, HasSubstr(R"(type RTArr = @stride(4) array<u32>;
struct S {
/* @offset(0) */
field0 : u32,
/* @offset(4) */
field1 : RTArr,
}

View File

@@ -1254,8 +1254,11 @@ TEST_F(SpvModuleScopeVarParserTest, StructMember_NonReadableDecoration_Dropped)
EXPECT_THAT(module_str, HasSubstr(R"(type Arr = @stride(4) array<u32, 2u>;
struct S {
/* @offset(0) */
field0 : u32,
/* @offset(4) */
field1 : f32,
/* @offset(8) */
field2 : Arr,
}
@@ -1286,6 +1289,7 @@ TEST_F(SpvModuleScopeVarParserTest, ColMajorDecoration_Dropped) {
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(struct S {
/* @offset(0) */
field0 : mat3x2<f32>,
}
@@ -1316,6 +1320,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixStrideDecoration_Natural_Dropped) {
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(struct S {
/* @offset(0) */
field0 : mat3x2<f32>,
}
@@ -1346,6 +1351,7 @@ TEST_F(SpvModuleScopeVarParserTest, MatrixStrideDecoration) {
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(struct S {
/* @offset(0) */
@stride(64) @internal(disable_validation__ignore_stride)
field0 : mat3x2<f32>,
}
@@ -1399,7 +1405,9 @@ TEST_F(SpvModuleScopeVarParserTest, StorageBuffer_NonWritable_AllMembers) {
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(struct S {
/* @offset(0) */
field0 : f32,
/* @offset(4) */
field1 : f32,
}
@@ -1428,7 +1436,9 @@ TEST_F(SpvModuleScopeVarParserTest, StorageBuffer_NonWritable_NotAllMembers) {
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(struct S {
/* @offset(0) */
field0 : f32,
/* @offset(4) */
field1 : f32,
}
@@ -1459,7 +1469,9 @@ TEST_F(SpvModuleScopeVarParserTest,
EXPECT_TRUE(p->error().empty());
const auto module_str = test::ToString(p->program());
EXPECT_THAT(module_str, HasSubstr(R"(struct S {
/* @offset(0) */
field0 : f32,
/* @offset(4) */
field1 : f32,
}