On 19 May 2012 13:05, Jose Fonseca <span dir="ltr">&lt;<a href="mailto:jfonseca@vmware.com" target="_blank">jfonseca@vmware.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Good find and nice test IMO.<br>
<br>
Jose<br></blockquote><div><br>Thanks, Jose.  Can I consider that a &quot;reviewed-by&quot;?<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<div><div class="h5"><br>
----- Original Message -----<br>
&gt; As of 5/19/12, Mesa&#39;s constant propagation optimization pass fails to<br>
&gt; properly account for the behaviour of array indexing applied to<br>
&gt; vectors.  If v is a vector and i is an integer, it assumes that<br>
&gt;<br>
&gt; v[i] = ...;<br>
&gt;<br>
&gt; kills the x component of v.  This is not necessarily the case--it<br>
&gt; might kill any component of v, depending on the value of i.<br>
&gt; ---<br>
&gt;  ...-vector-indexing-kills-all-channels.shader_test |   39<br>
&gt;  +++++++++++++++++++<br>
&gt;  ...-vector-indexing-kills-all-channels.shader_test |   41<br>
&gt;  ++++++++++++++++++++<br>
&gt;  2 files changed, 80 insertions(+), 0 deletions(-)<br>
&gt;  create mode 100644<br>
&gt;  tests/spec/glsl-1.10/execution/fs-vector-indexing-kills-all-channels.shader_test<br>
&gt;  create mode 100644<br>
&gt;  tests/spec/glsl-1.10/execution/vs-vector-indexing-kills-all-channels.shader_test<br>
&gt;<br>
&gt; diff --git<br>
&gt; a/tests/spec/glsl-1.10/execution/fs-vector-indexing-kills-all-channels.shader_test<br>
&gt; b/tests/spec/glsl-1.10/execution/fs-vector-indexing-kills-all-channels.shader_test<br>
&gt; new file mode 100644<br>
&gt; index 0000000..b22405a<br>
&gt; --- /dev/null<br>
&gt; +++<br>
&gt; b/tests/spec/glsl-1.10/execution/fs-vector-indexing-kills-all-channels.shader_test<br>
&gt; @@ -0,0 +1,39 @@<br>
&gt; +# This test exercises a bug in mesa as of 5/19.12: constant<br>
&gt; +# propagation fails to detect that array indexing into a vector<br>
&gt; might<br>
&gt; +# kill any component of the vector.<br>
&gt; +<br>
&gt; +[vertex shader]<br>
&gt; +void main()<br>
&gt; +{<br>
&gt; +  gl_Position = gl_Vertex;<br>
&gt; +}<br>
&gt; +<br>
&gt; +[fragment shader]<br>
&gt; +#define RED vec4(1.0, 0.0, 0.0, 0.0)<br>
&gt; +#define GREEN vec4(0.0, 1.0, 0.0, 0.0)<br>
&gt; +<br>
&gt; +uniform int three;<br>
&gt; +uniform float five;<br>
&gt; +<br>
&gt; +void main()<br>
&gt; +{<br>
&gt; +  vec4 v = vec4(1.0, 2.0, 3.0, 4.0);<br>
&gt; +<br>
&gt; +  // If the bug is present, constant propagation will see a scalar<br>
&gt; on<br>
&gt; +  // the RHS, and incorrectly conclude that therefore only v.x is<br>
&gt; +  // killed.<br>
&gt; +  v[three] = five;<br>
&gt; +<br>
&gt; +  vec4 color = v.a == 5.0 ? GREEN : RED;<br>
&gt; +<br>
&gt; +  // If the bug is present, then index and new_value will be<br>
&gt; optimized<br>
&gt; +  // away, making shader_runner fail to assign uniforms.  To avoid<br>
&gt; +  // that, multiply color by (five - three - 1.0).<br>
&gt; +  gl_FragColor = color * (five - float(three) - 1.0);<br>
&gt; +}<br>
&gt; +<br>
&gt; +[test]<br>
&gt; +uniform int three 3<br>
&gt; +uniform float five 5.0<br>
&gt; +draw rect -1 -1 2 2<br>
&gt; +probe all rgba 0.0 1.0 0.0 0.0<br>
&gt; diff --git<br>
&gt; a/tests/spec/glsl-1.10/execution/vs-vector-indexing-kills-all-channels.shader_test<br>
&gt; b/tests/spec/glsl-1.10/execution/vs-vector-indexing-kills-all-channels.shader_test<br>
&gt; new file mode 100644<br>
&gt; index 0000000..6838f78<br>
&gt; --- /dev/null<br>
&gt; +++<br>
&gt; b/tests/spec/glsl-1.10/execution/vs-vector-indexing-kills-all-channels.shader_test<br>
&gt; @@ -0,0 +1,41 @@<br>
&gt; +# This test exercises a bug in mesa as of 5/19/12: constant<br>
&gt; +# propagation fails to detect that array indexing into a vector<br>
&gt; might<br>
&gt; +# kill any component of the vector.<br>
&gt; +<br>
&gt; +[vertex shader]<br>
&gt; +#define RED vec4(1.0, 0.0, 0.0, 0.0)<br>
&gt; +#define GREEN vec4(0.0, 1.0, 0.0, 0.0)<br>
&gt; +<br>
&gt; +uniform int three;<br>
&gt; +uniform float five;<br>
&gt; +<br>
&gt; +void main()<br>
&gt; +{<br>
&gt; +  gl_Position = gl_Vertex;<br>
&gt; +<br>
&gt; +  vec4 v = vec4(1.0, 2.0, 3.0, 4.0);<br>
&gt; +<br>
&gt; +  // If the bug is present, constant propagation will see a scalar<br>
&gt; on<br>
&gt; +  // the RHS, and incorrectly conclude that therefore only v.x is<br>
&gt; +  // killed.<br>
&gt; +  v[three] = five;<br>
&gt; +<br>
&gt; +  vec4 color = v.a == 5.0 ? GREEN : RED;<br>
&gt; +<br>
&gt; +  // If the bug is present, then index and new_value will be<br>
&gt; optimized<br>
&gt; +  // away, making shader_runner fail to assign uniforms.  To avoid<br>
&gt; +  // that, multiply color by (five - three - 1.0).<br>
&gt; +  gl_FrontColor = color * (five - float(three) - 1.0);<br>
&gt; +}<br>
&gt; +<br>
&gt; +[fragment shader]<br>
&gt; +void main()<br>
&gt; +{<br>
&gt; +  gl_FragColor = gl_Color;<br>
&gt; +}<br>
&gt; +<br>
&gt; +[test]<br>
&gt; +uniform int three 3<br>
&gt; +uniform float five 5.0<br>
&gt; +draw rect -1 -1 2 2<br>
&gt; +probe all rgba 0.0 1.0 0.0 0.0<br>
&gt; --<br>
&gt; 1.7.7.6<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Piglit mailing list<br>
&gt; <a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
&gt; <a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
&gt;<br>
</blockquote></div><br>