Module: Mesa Branch: master Commit: af229c94e357fb4747f108603382168e49b6fd02 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=af229c94e357fb4747f108603382168e49b6fd02
Author: Ian Romanick <[email protected]> Date: Thu Oct 3 15:21:53 2013 -0700 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 <[email protected]> Reviewed-by: Paul Berry <[email protected]> --- src/glsl/tests/builtin_variable_test.cpp | 98 ++++++++++++++++++++++++++++++ 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(); +} _______________________________________________ mesa-commit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-commit
