]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix sizing of implicitly sized arrays
authorMikko Rasa <tdb@tdb.fi>
Sun, 16 Jul 2023 17:29:25 +0000 (20:29 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 16 Jul 2023 23:15:44 +0000 (02:15 +0300)
Max index was being initialized to 0, so the sizing code thought every
array was being accessed with a literal 0.

source/glsl/generate.cpp
tests/glsl/unsized_array_access.glsl [new file with mode: 0644]

index a6758fbd9cd58a5c3f0c72e596a1bc7d835a91ef..ff43b99f164c3e8da7df4055175b2fd0deb1f3ba 100644 (file)
@@ -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 (file)
index 0000000..b7b1638
--- /dev/null
@@ -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:
+<test>:1: Array must have a size
+*/