<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000'><font face="arial, helvetica, sans-serif" size="3">Yep. I still couldn't find a way of using signature/templates effectively for these tags, so end up avoid typing them, but here it is:</font><div><font face="arial, helvetica, sans-serif"><br></font><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt; ">Reviewed-by: Jose Fonseca <jfonseca@vmware.com></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt; "><br></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt; ">Jose</div><div><font face="arial, helvetica, sans-serif"><br></font><br><hr id="zwchr" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt; "><blockquote style="border-left-width: 2px; border-left-style: solid; border-left-color: rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica, Arial, sans-serif; font-size: 12pt; ">On 19 May 2012 13:05, Jose Fonseca <span dir="ltr"><<a href="mailto:jfonseca@vmware.com" target="_blank">jfonseca@vmware.com</a>></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 "reviewed-by"?<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>
> As of 5/19/12, Mesa's constant propagation optimization pass fails to<br>
> properly account for the behaviour of array indexing applied to<br>
> vectors. If v is a vector and i is an integer, it assumes that<br>
><br>
> v[i] = ...;<br>
><br>
> kills the x component of v. This is not necessarily the case--it<br>
> might kill any component of v, depending on the value of i.<br>
> ---<br>
> ...-vector-indexing-kills-all-channels.shader_test | 39<br>
> +++++++++++++++++++<br>
> ...-vector-indexing-kills-all-channels.shader_test | 41<br>
> ++++++++++++++++++++<br>
> 2 files changed, 80 insertions(+), 0 deletions(-)<br>
> create mode 100644<br>
> tests/spec/glsl-1.10/execution/fs-vector-indexing-kills-all-channels.shader_test<br>
> create mode 100644<br>
> tests/spec/glsl-1.10/execution/vs-vector-indexing-kills-all-channels.shader_test<br>
><br>
> diff --git<br>
> a/tests/spec/glsl-1.10/execution/fs-vector-indexing-kills-all-channels.shader_test<br>
> b/tests/spec/glsl-1.10/execution/fs-vector-indexing-kills-all-channels.shader_test<br>
> new file mode 100644<br>
> index 0000000..b22405a<br>
> --- /dev/null<br>
> +++<br>
> b/tests/spec/glsl-1.10/execution/fs-vector-indexing-kills-all-channels.shader_test<br>
> @@ -0,0 +1,39 @@<br>
> +# This test exercises a bug in mesa as of 5/19.12: constant<br>
> +# propagation fails to detect that array indexing into a vector<br>
> might<br>
> +# kill any component of the vector.<br>
> +<br>
> +[vertex shader]<br>
> +void main()<br>
> +{<br>
> + gl_Position = gl_Vertex;<br>
> +}<br>
> +<br>
> +[fragment shader]<br>
> +#define RED vec4(1.0, 0.0, 0.0, 0.0)<br>
> +#define GREEN vec4(0.0, 1.0, 0.0, 0.0)<br>
> +<br>
> +uniform int three;<br>
> +uniform float five;<br>
> +<br>
> +void main()<br>
> +{<br>
> + vec4 v = vec4(1.0, 2.0, 3.0, 4.0);<br>
> +<br>
> + // If the bug is present, constant propagation will see a scalar<br>
> on<br>
> + // the RHS, and incorrectly conclude that therefore only v.x is<br>
> + // killed.<br>
> + v[three] = five;<br>
> +<br>
> + vec4 color = v.a == 5.0 ? GREEN : RED;<br>
> +<br>
> + // If the bug is present, then index and new_value will be<br>
> optimized<br>
> + // away, making shader_runner fail to assign uniforms. To avoid<br>
> + // that, multiply color by (five - three - 1.0).<br>
> + gl_FragColor = color * (five - float(three) - 1.0);<br>
> +}<br>
> +<br>
> +[test]<br>
> +uniform int three 3<br>
> +uniform float five 5.0<br>
> +draw rect -1 -1 2 2<br>
> +probe all rgba 0.0 1.0 0.0 0.0<br>
> diff --git<br>
> a/tests/spec/glsl-1.10/execution/vs-vector-indexing-kills-all-channels.shader_test<br>
> b/tests/spec/glsl-1.10/execution/vs-vector-indexing-kills-all-channels.shader_test<br>
> new file mode 100644<br>
> index 0000000..6838f78<br>
> --- /dev/null<br>
> +++<br>
> b/tests/spec/glsl-1.10/execution/vs-vector-indexing-kills-all-channels.shader_test<br>
> @@ -0,0 +1,41 @@<br>
> +# This test exercises a bug in mesa as of 5/19/12: constant<br>
> +# propagation fails to detect that array indexing into a vector<br>
> might<br>
> +# kill any component of the vector.<br>
> +<br>
> +[vertex shader]<br>
> +#define RED vec4(1.0, 0.0, 0.0, 0.0)<br>
> +#define GREEN vec4(0.0, 1.0, 0.0, 0.0)<br>
> +<br>
> +uniform int three;<br>
> +uniform float five;<br>
> +<br>
> +void main()<br>
> +{<br>
> + gl_Position = gl_Vertex;<br>
> +<br>
> + vec4 v = vec4(1.0, 2.0, 3.0, 4.0);<br>
> +<br>
> + // If the bug is present, constant propagation will see a scalar<br>
> on<br>
> + // the RHS, and incorrectly conclude that therefore only v.x is<br>
> + // killed.<br>
> + v[three] = five;<br>
> +<br>
> + vec4 color = v.a == 5.0 ? GREEN : RED;<br>
> +<br>
> + // If the bug is present, then index and new_value will be<br>
> optimized<br>
> + // away, making shader_runner fail to assign uniforms. To avoid<br>
> + // that, multiply color by (five - three - 1.0).<br>
> + gl_FrontColor = color * (five - float(three) - 1.0);<br>
> +}<br>
> +<br>
> +[fragment shader]<br>
> +void main()<br>
> +{<br>
> + gl_FragColor = gl_Color;<br>
> +}<br>
> +<br>
> +[test]<br>
> +uniform int three 3<br>
> +uniform float five 5.0<br>
> +draw rect -1 -1 2 2<br>
> +probe all rgba 0.0 1.0 0.0 0.0<br>
> --<br>
> 1.7.7.6<br>
><br>
</div></div>> _______________________________________________<br>
> Piglit mailing list<br>
> <a href="mailto:Piglit@lists.freedesktop.org" target="_blank">Piglit@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
><br>
</blockquote></div><br>
</blockquote><br></div></div></div></body></html>