<div dir="ltr">On 11 October 2013 11:18, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
<br>
Checks that the variables generated meet certain criteria.<br>
<br>
 - Fragment shader inputs have an explicit location.<br>
<br>
 - Fragment shader outputs have an explicit location.<br>
<br>
 - Vertex / geometry shader-only varying locations are not used.<br>
<br>
 - Fragment shader uniforms and system values don't have an explicit<br>
   location.<br>
<br>
 - Fragment shader constants don't have an explicit location and are<br>
   read-only.<br>
<br>
 - No other kinds of fragment variables exist.<br>
<br>
It does not verify that an specific variables exist.<br>
<br>
Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
---<br>
 src/glsl/tests/builtin_variable_test.cpp | 76 ++++++++++++++++++++++++++++++++<br>
 1 file changed, 76 insertions(+)<br>
<br>
diff --git a/src/glsl/tests/builtin_variable_test.cpp b/src/glsl/tests/builtin_variable_test.cpp<br>
index c4711ab..37c8f25 100644<br>
--- a/src/glsl/tests/builtin_variable_test.cpp<br>
+++ b/src/glsl/tests/builtin_variable_test.cpp<br>
@@ -233,3 +233,79 @@ TEST_F(vertex_builtin, no_invalid_variable_modes)<br>
 {<br>
    common_builtin::no_invalid_variable_modes();<br>
 }<br>
+<br>
+/********************************************************************/<br>
+<br>
+class fragment_builtin : public common_builtin {<br>
+public:<br>
+   fragment_builtin()<br>
+      : common_builtin(GL_FRAGMENT_SHADER)<br>
+   {<br>
+      /* empty */<br>
+   }<br>
+};<br>
+<br>
+TEST_F(fragment_builtin, names_start_with_gl)<br>
+{<br>
+   common_builtin::names_start_with_gl();<br>
+}<br>
+<br>
+TEST_F(fragment_builtin, inputs_have_explicit_location)<br>
+{<br>
+   foreach_list(node, &this->ir) {<br>
+      ir_variable *const var = ((ir_instruction *) node)->as_variable();<br>
+<br>
+      if (var->mode != ir_var_shader_in)<br>
+        continue;<br>
+<br>
+      EXPECT_TRUE(var->explicit_location);<br>
+      EXPECT_NE(-1, var->location);<br>
+      EXPECT_GT(VARYING_SLOT_VAR0, var->location);<br>
+      EXPECT_EQ(0u, var->location_frac);<br>
+<br>
+      /* Several varyings only exist in the vertex / geometry shader.  Be sure<br>
+       * that no inputs with these locations exist.<br>
+       */<br>
+      EXPECT_NE(VARYING_SLOT_PSIZ, var->location);<br>
+      EXPECT_NE(VARYING_SLOT_BFC0, var->location);<br>
+      EXPECT_NE(VARYING_SLOT_BFC1, var->location);<br>
+      EXPECT_NE(VARYING_SLOT_EDGE, var->location);<br>
+      EXPECT_NE(VARYING_SLOT_CLIP_VERTEX, var->location);<br>
+      EXPECT_NE(VARYING_SLOT_LAYER, var->location);<br></blockquote><div><br></div><div>You can use<br><br>EXPECT_TRUE(_mesa_varying_slot_in_fs((gl_varying_slot) var->location);<br><br></div><div>instead.<br><br></div>
<div>With that fixed,<br><br></div><div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

+   }<br>
+}<br>
+<br>
+TEST_F(fragment_builtin, outputs_have_explicit_location)<br>
+{<br>
+   foreach_list(node, &this->ir) {<br>
+      ir_variable *const var = ((ir_instruction *) node)->as_variable();<br>
+<br>
+      if (var->mode != ir_var_shader_out)<br>
+        continue;<br>
+<br>
+      EXPECT_TRUE(var->explicit_location);<br>
+      EXPECT_NE(-1, var->location);<br>
+<br>
+      /* gl_FragData[] has location FRAG_RESULT_DATA0.  Locations beyond that<br>
+       * are invalid.<br>
+       */<br>
+      EXPECT_GE(FRAG_RESULT_DATA0, var->location);<br>
+<br>
+      EXPECT_EQ(0u, var->location_frac);<br>
+   }<br>
+}<br>
+<br>
+TEST_F(fragment_builtin, uniforms_and_system_values_dont_have_explicit_location)<br>
+{<br>
+   common_builtin::uniforms_and_system_values_dont_have_explicit_location();<br>
+}<br>
+<br>
+TEST_F(fragment_builtin, constants_are_constant)<br>
+{<br>
+   common_builtin::constants_are_constant();<br>
+}<br>
+<br>
+TEST_F(fragment_builtin, no_invalid_variable_modes)<br>
+{<br>
+   common_builtin::no_invalid_variable_modes();<br>
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.1.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>