summaryrefslogtreecommitdiffstats
path: root/src/glsl/tests
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2013-10-03 15:21:53 -0700
committerIan Romanick <ian.d.romanick@intel.com>2013-10-22 15:23:30 -0700
commitaf229c94e357fb4747f108603382168e49b6fd02 (patch)
tree7eaae3bfb494a717abc49dfcc7d43437b3d1d119 /src/glsl/tests
parentf094a0f825abd261109ee566a760089dd4da64e6 (diff)
downloadexternal_mesa3d-af229c94e357fb4747f108603382168e49b6fd02.zip
external_mesa3d-af229c94e357fb4747f108603382168e49b6fd02.tar.gz
external_mesa3d-af229c94e357fb4747f108603382168e49b6fd02.tar.bz2
glsl/tests: Verify geometry shader built-ins generated by _mesa_glsl_initialize_variables
Checks that the variables generated meet certain criteria. - Geometry shader inputs have an explicit location. - Geometry shader outputs have an explicit location. - Fragment shader-only varying locations are not used. - Geometry shader uniforms and system values don't have an explicit location. - Geometry shader constants don't have an explicit location and are read-only. - No other kinds of geometry variables exist. It does not verify that an specific variables exist. 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.cpp98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/glsl/tests/builtin_variable_test.cpp b/src/glsl/tests/builtin_variable_test.cpp
index 4dbccdc..366fbce 100644
--- a/src/glsl/tests/builtin_variable_test.cpp
+++ b/src/glsl/tests/builtin_variable_test.cpp
@@ -293,3 +293,101 @@ TEST_F(fragment_builtin, no_invalid_variable_modes)
{
common_builtin::no_invalid_variable_modes();
}
+
+/********************************************************************/
+
+class geometry_builtin : public common_builtin {
+public:
+ geometry_builtin()
+ : common_builtin(GL_GEOMETRY_SHADER)
+ {
+ /* empty */
+ }
+};
+
+TEST_F(geometry_builtin, names_start_with_gl)
+{
+ common_builtin::names_start_with_gl();
+}
+
+TEST_F(geometry_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;
+
+ if (var->is_interface_instance()) {
+ EXPECT_STREQ("gl_in", var->name);
+ EXPECT_FALSE(var->explicit_location);
+ EXPECT_EQ(-1, var->location);
+
+ ASSERT_TRUE(var->type->is_array());
+
+ const glsl_type *const instance_type = var->type->fields.array;
+
+ for (unsigned i = 0; i < instance_type->length; i++) {
+ const glsl_struct_field *const input =
+ &instance_type->fields.structure[i];
+
+ string_starts_with_prefix(input->name, "gl_");
+ EXPECT_NE(-1, input->location);
+ EXPECT_GT(VARYING_SLOT_VAR0, input->location);
+
+ /* Several varyings only exist in the fragment shader. Be sure
+ * that no inputs with these locations exist.
+ */
+ EXPECT_NE(VARYING_SLOT_PNTC, input->location);
+ EXPECT_NE(VARYING_SLOT_FACE, input->location);
+ }
+ } else {
+ 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 fragment shader. Be sure that no
+ * inputs with these locations exist.
+ */
+ EXPECT_NE(VARYING_SLOT_PNTC, var->location);
+ EXPECT_NE(VARYING_SLOT_FACE, var->location);
+ }
+}
+
+TEST_F(geometry_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);
+ EXPECT_GT(VARYING_SLOT_VAR0, var->location);
+ EXPECT_EQ(0u, var->location_frac);
+
+ /* Several varyings only exist in the fragment shader. Be sure that no
+ * outputs with these locations exist.
+ */
+ EXPECT_NE(VARYING_SLOT_PNTC, var->location);
+ EXPECT_NE(VARYING_SLOT_FACE, var->location);
+ }
+}
+
+TEST_F(geometry_builtin, uniforms_and_system_values_dont_have_explicit_location)
+{
+ common_builtin::uniforms_and_system_values_dont_have_explicit_location();
+}
+
+TEST_F(geometry_builtin, constants_are_constant)
+{
+ common_builtin::constants_are_constant();
+}
+
+TEST_F(geometry_builtin, no_invalid_variable_modes)
+{
+ common_builtin::no_invalid_variable_modes();
+}