summaryrefslogtreecommitdiffstats
path: root/src/glsl/tests
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2013-10-03 15:14:35 -0700
committerIan Romanick <ian.d.romanick@intel.com>2013-10-22 15:23:30 -0700
commitf094a0f825abd261109ee566a760089dd4da64e6 (patch)
tree067cc33369111db54bcb4497e9199a306d698605 /src/glsl/tests
parentd05202900bcbe2d0bb8dabcbb3048f3a31b82bbd (diff)
downloadexternal_mesa3d-f094a0f825abd261109ee566a760089dd4da64e6.zip
external_mesa3d-f094a0f825abd261109ee566a760089dd4da64e6.tar.gz
external_mesa3d-f094a0f825abd261109ee566a760089dd4da64e6.tar.bz2
glsl/tests: Verify fragment shader built-ins generated by _mesa_glsl_initialize_variables
Checks that the variables generated meet certain criteria. - Fragment shader inputs have an explicit location. - Fragment shader outputs have an explicit location. - Vertex / geometry shader-only varying locations are not used. - Fragment shader uniforms and system values don't have an explicit location. - Fragment shader constants don't have an explicit location and are read-only. - No other kinds of fragment variables exist. It does not verify that an specific variables exist. v2: Use _mesa_varying_slot_in_fs in fragment_builtin.inputs_have_explicit_location. Suggested by Paul. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Paul Berry <stereotype441@gmail.com>
Diffstat (limited to 'src/glsl/tests')
-rw-r--r--src/glsl/tests/builtin_variable_test.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/glsl/tests/builtin_variable_test.cpp b/src/glsl/tests/builtin_variable_test.cpp
index af0ba1e..4dbccdc 100644
--- a/src/glsl/tests/builtin_variable_test.cpp
+++ b/src/glsl/tests/builtin_variable_test.cpp
@@ -222,3 +222,74 @@ TEST_F(vertex_builtin, no_invalid_variable_modes)
{
common_builtin::no_invalid_variable_modes();
}
+
+/********************************************************************/
+
+class fragment_builtin : public common_builtin {
+public:
+ fragment_builtin()
+ : common_builtin(GL_FRAGMENT_SHADER)
+ {
+ /* empty */
+ }
+};
+
+TEST_F(fragment_builtin, names_start_with_gl)
+{
+ common_builtin::names_start_with_gl();
+}
+
+TEST_F(fragment_builtin, inputs_have_explicit_location)
+{
+ foreach_list(node, &this->ir) {
+ ir_variable *const var = ((ir_instruction *) node)->as_variable();
+
+ if (var->mode != ir_var_shader_in)
+ continue;
+
+ EXPECT_TRUE(var->explicit_location);
+ EXPECT_NE(-1, var->location);
+ EXPECT_GT(VARYING_SLOT_VAR0, var->location);
+ EXPECT_EQ(0u, var->location_frac);
+
+ /* Several varyings only exist in the vertex / geometry shader. Be sure
+ * that no inputs with these locations exist.
+ */
+ EXPECT_TRUE(_mesa_varying_slot_in_fs((gl_varying_slot) var->location));
+ }
+}
+
+TEST_F(fragment_builtin, outputs_have_explicit_location)
+{
+ foreach_list(node, &this->ir) {
+ ir_variable *const var = ((ir_instruction *) node)->as_variable();
+
+ if (var->mode != ir_var_shader_out)
+ continue;
+
+ EXPECT_TRUE(var->explicit_location);
+ EXPECT_NE(-1, var->location);
+
+ /* gl_FragData[] has location FRAG_RESULT_DATA0. Locations beyond that
+ * are invalid.
+ */
+ EXPECT_GE(FRAG_RESULT_DATA0, var->location);
+
+ EXPECT_EQ(0u, var->location_frac);
+ }
+}
+
+TEST_F(fragment_builtin, uniforms_and_system_values_dont_have_explicit_location)
+{
+ common_builtin::uniforms_and_system_values_dont_have_explicit_location();
+}
+
+TEST_F(fragment_builtin, constants_are_constant)
+{
+ common_builtin::constants_are_constant();
+}
+
+TEST_F(fragment_builtin, no_invalid_variable_modes)
+{
+ common_builtin::no_invalid_variable_modes();
+}