mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 22:56:09 +00:00
glsl: Don't emit structs with runtime-sized arrays
The GLSL emitted for these was invalid, and we don't need these structs since they're only used as the store types of buffers, which are handled elsewhere. Change-Id: I17c15e408b5c36e9b895e5950528a6d02d1802a6 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/72381 Reviewed-by: Stephen White <senorblanco@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -123,8 +123,18 @@ bool GeneratorImpl::Generate() {
|
||||
return false;
|
||||
}
|
||||
} else if (auto* str = decl->As<ast::Struct>()) {
|
||||
if (!EmitStructType(current_buffer_, builder_.Sem().Get(str))) {
|
||||
return false;
|
||||
// Skip emission if the struct contains a runtime-sized array, since its
|
||||
// only use will be as the store-type of a buffer and we emit those
|
||||
// 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))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (auto* func = decl->As<ast::Function>()) {
|
||||
if (func->IsEntryPoint()) {
|
||||
|
||||
@@ -51,9 +51,6 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength) {
|
||||
auto* expect = R"(#version 310 es
|
||||
precision mediump float;
|
||||
|
||||
struct my_struct {
|
||||
float a[];
|
||||
};
|
||||
|
||||
layout (binding = 1) buffer my_struct_1 {
|
||||
float a[];
|
||||
@@ -105,10 +102,6 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
|
||||
auto* expect = R"(#version 310 es
|
||||
precision mediump float;
|
||||
|
||||
struct my_struct {
|
||||
float z;
|
||||
float a[];
|
||||
};
|
||||
|
||||
layout (binding = 1) buffer my_struct_1 {
|
||||
float z;
|
||||
@@ -163,9 +156,6 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) {
|
||||
auto* expect = R"(#version 310 es
|
||||
precision mediump float;
|
||||
|
||||
struct my_struct {
|
||||
float a[];
|
||||
};
|
||||
|
||||
layout (binding = 1) buffer my_struct_1 {
|
||||
float a[];
|
||||
|
||||
Reference in New Issue
Block a user