<div dir="ltr"><div>That's reasonably subtle..<br><br></div>Reviewed-by: Chris Forbes <<a href="mailto:chrisf@ijw.co.nz">chrisf@ijw.co.nz</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 31, 2015 at 11:24 PM, Timothy Arceri <span dir="ltr"><<a href="mailto:t_arceri@yahoo.com.au" target="_blank">t_arceri@yahoo.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Trips an assert in nir when a chance to have optimised out a<br>
redundant assignment of a function inout array element is missed.<br>
---<br>
...unction-inout-array-self-assignment.shader_test | 50 ++++++++++++++++++++++<br>
1 file changed, 50 insertions(+)<br>
create mode 100644 tests/spec/glsl-1.20/execution/vs-function-inout-array-self-assignment.shader_test<br>
<br>
diff --git a/tests/spec/glsl-1.20/execution/vs-function-inout-array-self-assignment.shader_test b/tests/spec/glsl-1.20/execution/vs-function-inout-array-self-assignment.shader_test<br>
new file mode 100644<br>
index 0000000..42c9d42<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.20/execution/vs-function-inout-array-self-assignment.shader_test<br>
@@ -0,0 +1,50 @@<br>
+// Tests a scenario in Mesa with function inout parameters which only<br>
+// seems to appear when an assignment is done to an array element followed by<br>
+// an assignment to another element where the element itself is either<br>
+// multiplied or divided by 1.<br>
+//<br>
+// The result is we end up with an assignment in the IR where the lhs and rhs<br>
+// are referencing the same variable. This ends up tripping an assert,<br>
+// presumably the assignment should just be detected and optimised out.<br>
+[require]<br>
+GLSL >= 1.20<br>
+<br>
+[vertex shader]<br>
+#version 120<br>
+varying vec4 color;<br>
+<br>
+void array_mod(inout int b[2])<br>
+{<br>
+ b[0] = int(2);<br>
+ b[1] = b[1] * int(1);<br>
+}<br>
+<br>
+void main()<br>
+{<br>
+ int a[2];<br>
+<br>
+ a[0] = int(1);<br>
+ a[1] = int(2);<br>
+ array_mod(a);<br>
+<br>
+ if (a[0] == int(2) && a[1] == int(2)) {<br>
+ color = vec4(0, 1, 0, 1);<br>
+ } else {<br>
+ color = vec4(1, 0, 0, 1);<br>
+ }<br>
+<br>
+ gl_Position = gl_Vertex;<br>
+}<br>
+<br>
+[fragment shader]<br>
+#version 120<br>
+varying vec4 color;<br>
+<br>
+void main()<br>
+{<br>
+ gl_FragColor = color;<br>
+}<br>
+<br>
+[test]<br>
+draw rect -1 -1 2 2<br>
+probe all rgb 0 1 0<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.4.3<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div>