From: Mikko Rasa Date: Sun, 16 Jul 2023 17:29:25 +0000 (+0300) Subject: Fix sizing of implicitly sized arrays X-Git-Url: https://git.tdb.fi/?a=commitdiff_plain;h=bce9fffb1c658c076a026236c6ecd99b9503d094;p=libs%2Fgl.git Fix sizing of implicitly sized arrays Max index was being initialized to 0, so the sizing code thought every array was being accessed with a literal 0. --- diff --git a/source/glsl/generate.cpp b/source/glsl/generate.cpp index a6758fbd..ff43b99f 100644 --- a/source/glsl/generate.cpp +++ b/source/glsl/generate.cpp @@ -493,7 +493,7 @@ void ArraySizer::visit(InterfaceLayout &layout) void ArraySizer::visit(VariableDeclaration &var) { if(var.array && !var.array_size) - max_indices[&var] = 0; + max_indices[&var] = -1; } } // namespace SL diff --git a/tests/glsl/unsized_array_access.glsl b/tests/glsl/unsized_array_access.glsl new file mode 100644 index 00000000..b7b16387 --- /dev/null +++ b/tests/glsl/unsized_array_access.glsl @@ -0,0 +1,12 @@ +uniform vec4 array[]; + +#pragma MSP stage(vertex) +layout(location=0) in int i; +void main() +{ + gl_Position = array[i]; +} + +/* Expected error: +:1: Array must have a size +*/