Add @index Attribute to WGSL Writer
Adds @index attribute to WGSL writer.
Bug: dawn:1709
Change-Id: Ia92d18d48119b83f2d7d2030d3b58efb3ca2d700
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/139340
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
diff --git a/src/tint/writer/syntax_tree/generator_impl.cc b/src/tint/writer/syntax_tree/generator_impl.cc
index 4574c14..b6ba3ea 100644
--- a/src/tint/writer/syntax_tree/generator_impl.cc
+++ b/src/tint/writer/syntax_tree/generator_impl.cc
@@ -520,6 +520,14 @@
}
Line() << "]";
},
+ [&](const ast::IndexAttribute* index) {
+ line() << "IndexAttribute [";
+ {
+ ScopedIndent idx(this);
+ EmitExpression(index->expr);
+ }
+ line() << "]";
+ },
[&](const ast::BuiltinAttribute* builtin) {
Line() << "BuiltinAttribute [";
{
diff --git a/src/tint/writer/wgsl/generator_impl.cc b/src/tint/writer/wgsl/generator_impl.cc
index 59aa35c..b36994a 100644
--- a/src/tint/writer/wgsl/generator_impl.cc
+++ b/src/tint/writer/wgsl/generator_impl.cc
@@ -430,6 +430,11 @@
EmitExpression(out, location->expr);
out << ")";
},
+ [&](const ast::IndexAttribute* index) {
+ out << "index(";
+ EmitExpression(out, index->expr);
+ out << ")";
+ },
[&](const ast::BuiltinAttribute* builtin) {
out << "builtin(";
EmitExpression(out, builtin->builtin);