writer/hlsl: Don't explode on unhandled member decorations
[[align(n)]], [[size(n)]] are valid decorations that should not cause the writer to fail.
Instead of allow-listing these, just handle the cases it actually cares about.
Fixed: tint:686
Change-Id: I7c60d251fcaee424fe1c1a1f1f58123eea8c99aa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46380
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index f969e5f..f7a7e96 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -2610,8 +2610,7 @@
out << " " << namer_.NameFor(builder_.Symbols().NameFor(mem->symbol()));
}
- if (mem->decorations().size() > 0) {
- auto* deco = mem->decorations()[0];
+ for (auto* deco : mem->decorations()) {
if (auto* location = deco->As<ast::LocationDecoration>()) {
out << " : TEXCOORD" << location->value();
} else if (auto* builtin = deco->As<ast::BuiltinDecoration>()) {
@@ -2621,11 +2620,6 @@
return false;
}
out << " : " << attr;
- } else if (deco->Is<ast::StructMemberOffsetDecoration>()) {
- // Nothing to do, offsets are handled at the point of access.
- } else {
- diagnostics_.add_error("unsupported struct member decoration");
- return false;
}
}