[wgsl-writer] Emit array stride decoration.
This CL adds array stride decorations to the WGSL writer. Bug: tint:179 Change-Id: I39d7625e1bdc876bbf9a83da7af76eb98bd09c28 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26002 Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
a8e4e2ad5d
commit
ac4a2894fe
|
@ -356,6 +356,11 @@ bool GeneratorImpl::EmitType(ast::type::Type* type) {
|
||||||
out_ << alias->name();
|
out_ << alias->name();
|
||||||
} else if (type->IsArray()) {
|
} else if (type->IsArray()) {
|
||||||
auto* ary = type->AsArray();
|
auto* ary = type->AsArray();
|
||||||
|
|
||||||
|
if (ary->has_array_stride()) {
|
||||||
|
out_ << "[[stride " << ary->array_stride() << "]] ";
|
||||||
|
}
|
||||||
|
|
||||||
out_ << "array<";
|
out_ << "array<";
|
||||||
if (!EmitType(ary->type())) {
|
if (!EmitType(ary->type())) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -55,6 +55,16 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array) {
|
||||||
EXPECT_EQ(g.result(), "array<bool, 4>");
|
EXPECT_EQ(g.result(), "array<bool, 4>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(WgslGeneratorImplTest, EmitType_Array_WithStride) {
|
||||||
|
ast::type::BoolType b;
|
||||||
|
ast::type::ArrayType a(&b, 4);
|
||||||
|
a.set_array_stride(16);
|
||||||
|
|
||||||
|
GeneratorImpl g;
|
||||||
|
ASSERT_TRUE(g.EmitType(&a)) << g.error();
|
||||||
|
EXPECT_EQ(g.result(), "[[stride 16]] array<bool, 4>");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) {
|
TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) {
|
||||||
ast::type::BoolType b;
|
ast::type::BoolType b;
|
||||||
ast::type::ArrayType a(&b);
|
ast::type::ArrayType a(&b);
|
||||||
|
|
Loading…
Reference in New Issue