GLSL: don't emit structs w/runtime-sized arrays.

In GLSL, runtime-sized arrays are only valid in interface blocks, not
in structs. The existing code was attempting to avoid emitting structs
containing runtime-sized arrays but was confused by type aliases in
the AST resulting in arrays being missed.

The fix is to do the work on the semantic types instead, where type
aliases have been resolved.

Bug: tint:1339
Change-Id: I8c305ee9bddd75f975dd13f1d19d623d71410693
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82360
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Stephen White
2022-03-02 14:09:22 +00:00
committed by Tint LUCI CQ
parent 93f686617e
commit 66abf3ed14
50 changed files with 10 additions and 635 deletions

View File

@@ -164,11 +164,13 @@ bool GeneratorImpl::Generate() {
// elsewhere.
// TODO(crbug.com/tint/1339): We could also avoid emitting any other
// struct that is only used as a buffer store type.
TINT_ASSERT(Writer, str->members.size() > 0);
auto* last_member = str->members[str->members.size() - 1];
auto* arr = last_member->type->As<ast::Array>();
if (!arr || !arr->IsRuntimeArray()) {
if (!EmitStructType(current_buffer_, builder_.Sem().Get(str))) {
const sem::Struct* sem_str = builder_.Sem().Get(str);
const auto& members = sem_str->Members();
TINT_ASSERT(Writer, members.size() > 0);
auto* last_member = members[members.size() - 1];
auto* arr = last_member->Type()->As<sem::Array>();
if (!arr || !arr->IsRuntimeSized()) {
if (!EmitStructType(current_buffer_, sem_str)) {
return false;
}
}