[Mesa-dev] [PATCH 3/6] glsl/tests: Verify fragment shader built-ins generated by _mesa_glsl_initialize_variables

Paul Berry stereotype441 at gmail.com
Fri Oct 18 22:16:50 CEST 2013


On 11 October 2013 11:18, Ian Romanick <idr at freedesktop.org> wrote:

> From: Ian Romanick <ian.d.romanick at intel.com>
>
> 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.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
>  src/glsl/tests/builtin_variable_test.cpp | 76
> ++++++++++++++++++++++++++++++++
>  1 file changed, 76 insertions(+)
>
> diff --git a/src/glsl/tests/builtin_variable_test.cpp
> b/src/glsl/tests/builtin_variable_test.cpp
> index c4711ab..37c8f25 100644
> --- a/src/glsl/tests/builtin_variable_test.cpp
> +++ b/src/glsl/tests/builtin_variable_test.cpp
> @@ -233,3 +233,79 @@ 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_NE(VARYING_SLOT_PSIZ, var->location);
> +      EXPECT_NE(VARYING_SLOT_BFC0, var->location);
> +      EXPECT_NE(VARYING_SLOT_BFC1, var->location);
> +      EXPECT_NE(VARYING_SLOT_EDGE, var->location);
> +      EXPECT_NE(VARYING_SLOT_CLIP_VERTEX, var->location);
> +      EXPECT_NE(VARYING_SLOT_LAYER, var->location);
>

You can use

EXPECT_TRUE(_mesa_varying_slot_in_fs((gl_varying_slot) var->location);

instead.

With that fixed,

Reviewed-by: Paul Berry <stereotype441 at gmail.com>


> +   }
> +}
> +
> +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();
> +}
> --
> 1.8.1.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131018/ee91b104/attachment-0001.html>


More information about the mesa-dev mailing list