[Mesa-dev] [PATCH] glsl: enforce invariant conditions for built-in variables
Tapani Pälli
tapani.palli at intel.com
Mon May 9 04:50:56 UTC 2016
IMO you will need to check for the ES version too, something like this:
https://patchwork.freedesktop.org/patch/36417/
On 05/06/2016 11:22 PM, Lars Hamre wrote:
> The conditions for which certain built-in special variables
> can be declared invariant were not being checked.
>
> OpenGL ES 1.00 specification "Invariance and linkage":
>
> For the built-in special variables, gl_FragCoord can
> only be declared invariant if and only if gl_Position is
> declared invariant. Similarly gl_PointCoord can only be
> declared invariant if and only if gl_PointSize is declared
> invariant. It is an error to declare gl_FrontFacing as invariant.
>
> This fixes the following piglit tests in spec/glsl-es-1.00/linker:
> glsl-fcoord-invariant
> glsl-fface-invariant
> glsl-pcoord-invariant
>
> ---
>
> NOTE: Someone with access will need to commit this after the
> review process
>
> src/compiler/glsl/link_varyings.cpp | 46 +++++++++++++++++++++++++++++++++++--
> 1 file changed, 44 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
> index 34e82c7..8ef815c 100644
> --- a/src/compiler/glsl/link_varyings.cpp
> +++ b/src/compiler/glsl/link_varyings.cpp
> @@ -352,13 +352,23 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
> glsl_symbol_table parameters;
> ir_variable *explicit_locations[MAX_VARYING][4] = { {NULL, NULL} };
>
> + bool is_gl_position_invariant = false;
> + bool is_gl_point_size_invariant = false;
> +
> /* Find all shader outputs in the "producer" stage.
> */
> foreach_in_list(ir_instruction, node, producer->ir) {
> ir_variable *const var = node->as_variable();
>
> if ((var == NULL) || (var->data.mode != ir_var_shader_out))
> - continue;
> + continue;
> +
> + if (prog->IsES) {
> + if (!strcmp(var->name, "gl_Position"))
> + is_gl_position_invariant = var->data.invariant;
> + if (!strcmp(var->name, "gl_PointSize"))
> + is_gl_point_size_invariant = var->data.invariant;
> + }
>
> if (!var->data.explicit_location
> || var->data.location < VARYING_SLOT_VAR0)
> @@ -442,7 +452,39 @@ cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
> ir_variable *const input = node->as_variable();
>
> if ((input == NULL) || (input->data.mode != ir_var_shader_in))
> - continue;
> + continue;
> +
> + /*
> + * OpenGL ES 1.00 specification "Invariance and linkage":
> + *
> + * "For the built-in special variables, gl_FragCoord can
> + * only be declared invariant if and only if gl_Position is
> + * declared invariant. Similarly gl_PointCoord can only be
> + * declared invariant if and only if gl_PointSize is declared
> + * invariant. It is an error to declare gl_FrontFacing as invariant."
> + */
> + if (prog->IsES) {
> + if (!strcmp(input->name, "gl_FrontFacing") &&
> + input->data.invariant) {
> + linker_error(prog,
> + "gl_FrontFacing cannot be declared invariant");
> + return;
> + } else if (!strcmp(input->name, "gl_FragCoord") &&
> + input->data.invariant &&
> + !is_gl_position_invariant) {
> + linker_error(prog,
> + "gl_FragCoord cannot be declared invariant "
> + "unless gl_Position is also invariant");
> + return;
> + } else if (!strcmp(input->name, "gl_PointCoord") &&
> + input->data.invariant &&
> + !is_gl_point_size_invariant) {
> + linker_error(prog,
> + "gl_PointCoord cannot be declared invariant "
> + "unless gl_PointSize is also invariant");
> + return;
> + }
> + }
>
> if (strcmp(input->name, "gl_Color") == 0 && input->data.used) {
> const ir_variable *const front_color =
> --
> 2.5.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
More information about the mesa-dev
mailing list