<div dir="ltr"><div><div><div>Reviewed-by: Mike Stroyan <<a href="mailto:mike@lunarg.com" target="_blank">mike@lunarg.com</a>><br><br></div>That does show the math dependency problem.<br></div>The same problem can also be demonstrated with other math opcodes than exp2.<br>
</div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 31, 2014 at 5:21 PM, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
tests/shaders/dependency-hints/exp2.shader_test | 72 +++++++++++++++++++++++++<br>
1 file changed, 72 insertions(+)<br>
create mode 100644 tests/shaders/dependency-hints/exp2.shader_test<br>
<br>
diff --git a/tests/shaders/dependency-hints/exp2.shader_test b/tests/shaders/dependency-hints/exp2.shader_test<br>
new file mode 100644<br>
index 0000000..c7584e6<br>
--- /dev/null<br>
+++ b/tests/shaders/dependency-hints/exp2.shader_test<br>
@@ -0,0 +1,72 @@<br>
+[require]<br>
+GLSL >= 1.10<br>
+<br>
+[vertex shader]<br>
+/* On Sandybridge and newer chips in the i965 family, writes into separate<br>
+ * channels of the same register stall. The compiler marks independent writes<br>
+ * with NoDDClr and/or NoDDChk to allow the instructions to issue without<br>
+ * stalling.<br>
+ *<br>
+ * Empirically, marking "math" instructions with these dependency control<br>
+ * hints leads to broken dependency tracking. The following shader, compiled<br>
+ * with the i965/vec4 backend unaware of this fact generates the following<br>
+ * assembly:<br>
+ *<br>
+ * math exp(8) g3<1>.xF g1<0,4,1>.xF null { align16 WE_normal NoDDClr 1Q };<br>
+ * add(8) g7<1>F g1<0,4,1>.yF 1e-08F { align16 WE_normal 1Q };<br>
+ * math exp(8) g3<1>.yF g7<4,4,1>F null { align16 WE_normal NoDDClr,NoDDChk 1Q };<br>
+ * math exp(8) g3<1>.zF g1<0,4,1>.zF null { align16 WE_normal NoDDChk 1Q };<br>
+ * mul.sat(8) g116<1>.xyzF g3<4,4,1>.xyzzF 0.5F { align16 WE_normal NoDDClr 1Q };<br>
+ * mov.sat(8) g116<1>.wF 1F { align16 WE_normal NoDDChk 1Q };<br>
+ * mov(8) g114<1>D 0D { align16 WE_normal 1Q };<br>
+ * mov(8) g115<1>F g2<4,4,1>F { align16 WE_normal 1Q };<br>
+ * mov(8) g113<1>UD g0<4,4,1>UD { align16 WE_all 1Q };<br>
+ * or(1) g113.5<1>UD g0.5<0,1,0>UD 0x0000ff00UD { align1 WE_all };<br>
+ * send(8) null g113<4,4,1>F<br>
+ * urb 0 urb_write used complete mlen 5 rlen 0 { align16 WE_normal 1Q EOT };<br>
+ *<br>
+ * The shader calculates the color exp2(vec3(0.1, 0.2 + 0.00000001, 0.3)) * 0.5<br>
+ * and expects to read back (0.535886, 0.5743491, 0.6155722).<br>
+ *<br>
+ * On affected platforms, the .x and .y components are correctly calculated,<br>
+ * but .z is left to be 0.0.<br>
+ */<br>
+<br>
+uniform vec3 exp;<br>
+<br>
+void main(){<br>
+ gl_Position = gl_Vertex;<br>
+<br>
+ /* Calling exp2() on a single component swizzle and then picking a single<br>
+ * channel from its result works around the vec4 backend's inability to<br>
+ * properly register coalesce.<br>
+ */<br>
+ gl_FrontColor.x = exp2(exp.xxxx).x;<br>
+<br>
+ /* Adding 0.00000001 is essentially a no-op, but it prevents the GLSL<br>
+ * compiler's opt_vectorize pass from combining the three exp2() calls<br>
+ * into a single one.<br>
+ */<br>
+ gl_FrontColor.y = exp2(exp.yyyy + 0.00000001).y;<br>
+<br>
+ gl_FrontColor.z = exp2(exp.zzzz).z;<br>
+<br>
+ /* Scale the result back into the 0.0 to 1.0 range */<br>
+ gl_FrontColor.xyz *= 0.5;<br>
+<br>
+ /* Moving this assignment before the previous statement causes the test<br>
+ * to sporadically fail, returning 1.0 (unrelated to value stored in .w)<br>
+ * in all channels.<br>
+ */<br>
+ gl_FrontColor.w = 1.0;<br>
+}<br>
+<br>
+[fragment shader]<br>
+void main() {<br>
+ gl_FragColor = gl_Color;<br>
+}<br>
+<br>
+[test]<br>
+uniform vec3 exp 0.1 0.2 0.3<br>
+draw rect -1 -1 2 2<br>
+probe rgb 1 1 0.535886 0.5743491 0.6155722<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.2<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" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><br> Mike Stroyan - Software Architect<br> LunarG, Inc. - The Graphics Experts<br> Cell: (970) 219-7905<br> Email: Mike@LunarG.com<br> Website: <a href="http://www.lunarg.com">http://www.lunarg.com</a>
</div>