From e9216ce595b6288ec1160a617e6ac2a856e9443d Mon Sep 17 00:00:00 2001 From: Stephen White Date: Mon, 1 Nov 2021 19:23:46 +0000 Subject: [PATCH] GLSL: emit [] for runtime-sized arrays, not [0]. Bug: tint:1262 Change-Id: Ic58729f075353f957c5d974c742b531e1e2cf518 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67940 Kokoro: Kokoro Reviewed-by: Ben Clayton Commit-Queue: Stephen White --- src/writer/glsl/generator_impl.cc | 6 +++++- src/writer/glsl/generator_impl_sanitizer_test.cc | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/writer/glsl/generator_impl.cc b/src/writer/glsl/generator_impl.cc index 0909adc12a..e16b3d769d 100644 --- a/src/writer/glsl/generator_impl.cc +++ b/src/writer/glsl/generator_impl.cc @@ -2310,7 +2310,11 @@ bool GeneratorImpl::EmitType(std::ostream& out, } } for (uint32_t size : sizes) { - out << "[" << size << "]"; + if (size > 0) { + out << "[" << size << "]"; + } else { + out << "[]"; + } } } else if (type->Is()) { out << "bool"; diff --git a/src/writer/glsl/generator_impl_sanitizer_test.cc b/src/writer/glsl/generator_impl_sanitizer_test.cc index b85bde6f2e..23247936f6 100644 --- a/src/writer/glsl/generator_impl_sanitizer_test.cc +++ b/src/writer/glsl/generator_impl_sanitizer_test.cc @@ -53,7 +53,7 @@ precision mediump float; layout (binding = 1) buffer my_struct_1 { - float a[0]; + float a[]; } b; void a_func() { @@ -105,7 +105,7 @@ precision mediump float; layout (binding = 1) buffer my_struct_1 { float z; - float a[0]; + float a[]; } b; void a_func() { @@ -158,7 +158,7 @@ precision mediump float; layout (binding = 1) buffer my_struct_1 { - float a[0]; + float a[]; } b; void a_func() {