glsl: Make #pragma STDGL invariant(all) only modify outputs.

Submitted by Kenneth Graunke on Nov. 7, 2017, 9:52 a.m.

Details

Message ID 20171107095237.19149-1-kenneth@whitecape.org
State New
Headers show
Series "glsl: Make #pragma STDGL invariant(all) only modify outputs." ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Kenneth Graunke Nov. 7, 2017, 9:52 a.m.
According to the GLSL ES 3.20, GLSL 4.50, and GLSL 1.20 specs:

   "To force all output variables to be invariant, use the pragma

       #pragma STDGL invariant(all)

    before all declarations in a shader."

Notably, this is only supposed to affect output variables.  Furthermore,

   "Only variables output from a shader can be candidates for invariance."

It looks like this has been wrong since we first supported the pragma in
2011 (commit 86b4398cd158024f6be9fa830554a11c2a7ebe0c).

Fixes dEQP-GLES2.functional.shaders.preprocessor.pragmas.pragma_fragment
---
 src/compiler/glsl/ast_to_hir.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 441404f86d3..98af6bb7239 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -4086,12 +4086,11 @@  apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
       case MESA_SHADER_TESS_CTRL:
       case MESA_SHADER_TESS_EVAL:
       case MESA_SHADER_GEOMETRY:
-         if ((var->data.mode == ir_var_shader_in)
-             || (var->data.mode == ir_var_shader_out))
+         if (var->data.mode == ir_var_shader_out)
             var->data.invariant = true;
          break;
       case MESA_SHADER_FRAGMENT:
-         if (var->data.mode == ir_var_shader_in)
+         if (var->data.mode == ir_var_shader_out)
             var->data.invariant = true;
          break;
       case MESA_SHADER_COMPUTE:

Comments

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>

On Tue, 2017-11-07 at 01:52 -0800, Kenneth Graunke wrote:
> According to the GLSL ES 3.20, GLSL 4.50, and GLSL 1.20 specs:
> 
>    "To force all output variables to be invariant, use the pragma
> 
>        #pragma STDGL invariant(all)
> 
>     before all declarations in a shader."
> 
> Notably, this is only supposed to affect output
> variables.  Furthermore,
> 
>    "Only variables output from a shader can be candidates for
> invariance."
> 
> It looks like this has been wrong since we first supported the pragma
> in
> 2011 (commit 86b4398cd158024f6be9fa830554a11c2a7ebe0c).
> 
> Fixes dEQP-
> GLES2.functional.shaders.preprocessor.pragmas.pragma_fragment
> ---
>  src/compiler/glsl/ast_to_hir.cpp | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/src/compiler/glsl/ast_to_hir.cpp
> b/src/compiler/glsl/ast_to_hir.cpp
> index 441404f86d3..98af6bb7239 100644
> --- a/src/compiler/glsl/ast_to_hir.cpp
> +++ b/src/compiler/glsl/ast_to_hir.cpp
> @@ -4086,12 +4086,11 @@ apply_type_qualifier_to_variable(const struct
> ast_type_qualifier *qual,
>        case MESA_SHADER_TESS_CTRL:
>        case MESA_SHADER_TESS_EVAL:
>        case MESA_SHADER_GEOMETRY:
> -         if ((var->data.mode == ir_var_shader_in)
> -             || (var->data.mode == ir_var_shader_out))
> +         if (var->data.mode == ir_var_shader_out)
>              var->data.invariant = true;
>           break;
>        case MESA_SHADER_FRAGMENT:
> -         if (var->data.mode == ir_var_shader_in)
> +         if (var->data.mode == ir_var_shader_out)
>              var->data.invariant = true;
>           break;
>        case MESA_SHADER_COMPUTE:
On Tue, Nov 7, 2017 at 4:52 AM, Kenneth Graunke <kenneth@whitecape.org> wrote:
> According to the GLSL ES 3.20, GLSL 4.50, and GLSL 1.20 specs:
>
>    "To force all output variables to be invariant, use the pragma
>
>        #pragma STDGL invariant(all)
>
>     before all declarations in a shader."
>
> Notably, this is only supposed to affect output variables.  Furthermore,
>
>    "Only variables output from a shader can be candidates for invariance."
>
> It looks like this has been wrong since we first supported the pragma in
> 2011 (commit 86b4398cd158024f6be9fa830554a11c2a7ebe0c).
>
> Fixes dEQP-GLES2.functional.shaders.preprocessor.pragmas.pragma_fragment
> ---
>  src/compiler/glsl/ast_to_hir.cpp | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
> index 441404f86d3..98af6bb7239 100644
> --- a/src/compiler/glsl/ast_to_hir.cpp
> +++ b/src/compiler/glsl/ast_to_hir.cpp
> @@ -4086,12 +4086,11 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
>        case MESA_SHADER_TESS_CTRL:
>        case MESA_SHADER_TESS_EVAL:
>        case MESA_SHADER_GEOMETRY:
> -         if ((var->data.mode == ir_var_shader_in)
> -             || (var->data.mode == ir_var_shader_out))
> +         if (var->data.mode == ir_var_shader_out)
>              var->data.invariant = true;
>           break;
>        case MESA_SHADER_FRAGMENT:
> -         if (var->data.mode == ir_var_shader_in)
> +         if (var->data.mode == ir_var_shader_out)
>              var->data.invariant = true;
>           break;

Perhaps combine the two cases now that they're identical? With that,

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>

>        case MESA_SHADER_COMPUTE:
> --
> 2.15.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev