<div dir="ltr"><div>Hello,</div><div><br></div><div>Thanks a lot for review.</div><div><br></div><div>Regards,</div><div>Andrii.<br></div><br><br><div class="gmail_quote"><div dir="ltr">On Sat, Nov 10, 2018 at 5:38 AM Timothy Arceri <<a href="mailto:tarceri@itsqueeze.com">tarceri@itsqueeze.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Nice! Series is:<br>
<br>
Reviewed-by: Timothy Arceri <<a href="mailto:tarceri@itsqueeze.com" target="_blank">tarceri@itsqueeze.com</a>><br>
<br>
On 10/10/18 9:07 am, Ian Romanick wrote:<br>
> From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><br>
> <br>
> Section 3.7 (Identifiers) of the GLSL spec says:<br>
> <br>
>      However, as noted in the specification, there are some cases where<br>
>      previously declared variables can be redeclared to change or add<br>
>      some property, and predeclared "gl_" names are allowed to be<br>
>      redeclared in a shader only for these specific purposes.  More<br>
>      generally, it is an error to redeclare a variable, including those<br>
>      starting "gl_".<br>
> <br>
> This patch should fix piglit tests:<br>
> clip-distance-redeclare-without-inout.frag<br>
> clip-distance-redeclare-without-inout.vert<br>
> <br>
> However, this causes a regression in<br>
> clip-distance-out-values.shader_test.  A fix for that test has been sent<br>
> to the piglit list for review:<br>
> <br>
>      <a href="https://patchwork.freedesktop.org/patch/255201/" rel="noreferrer" target="_blank">https://patchwork.freedesktop.org/patch/255201/</a><br>
> <br>
> As far as I understood following mailing thread:<br>
> <a href="https://lists.freedesktop.org/archives/piglit/2013-October/007935.html" rel="noreferrer" target="_blank">https://lists.freedesktop.org/archives/piglit/2013-October/007935.html</a><br>
> looks like we have accepted to remove an ability to change qualifiers<br>
> but have not done it yet. Unless I missed something)<br>
> <br>
> v2 (idr): Move 'earlier->data.mode != var->data.mode' test much earlier<br>
> in the function.  Add special handling for gl_LastFragData.<br>
> <br>
> Signed-off-by: Andrii Simiklit <<a href="mailto:andrii.simiklit@globallogic.com" target="_blank">andrii.simiklit@globallogic.com</a>><br>
> Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><br>
> ---<br>
>   src/compiler/glsl/ast_to_hir.cpp | 51 +++++++++++++++++++++-------------------<br>
>   1 file changed, 27 insertions(+), 24 deletions(-)<br>
> <br>
> diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp<br>
> index 1082d6c91cf..2e4c9ef6776 100644<br>
> --- a/src/compiler/glsl/ast_to_hir.cpp<br>
> +++ b/src/compiler/glsl/ast_to_hir.cpp<br>
> @@ -4238,6 +4238,29 @@ get_variable_being_redeclared(ir_variable **var_ptr, YYLTYPE loc,<br>
>   <br>
>      *is_redeclaration = true;<br>
>   <br>
> +   if (earlier->data.how_declared == ir_var_declared_implicitly) {<br>
> +      /* Verify that the redeclaration of a built-in does not change the<br>
> +       * storage qualifier.  There are a couple special cases.<br>
> +       *<br>
> +       * 1. Some built-in variables that are defined as 'in' in the<br>
> +       *    specification are implemented as system values.  Allow<br>
> +       *    ir_var_system_value -> ir_var_shader_in.<br>
> +       *<br>
> +       * 2. gl_LastFragData is implemented as a ir_var_shader_out, but the<br>
> +       *    specification requires that redeclarations omit any qualifier.<br>
> +       *    Allow ir_var_shader_out -> ir_var_auto for this one variable.<br>
> +       */<br>
> +      if (earlier->data.mode != var->data.mode &&<br>
> +          !(earlier->data.mode == ir_var_system_value &&<br>
> +            var->data.mode == ir_var_shader_in) &&<br>
> +          !(strcmp(var->name, "gl_LastFragData") == 0 &&<br>
> +            var->data.mode == ir_var_auto)) {<br>
> +         _mesa_glsl_error(&loc, state,<br>
> +                          "redeclaration cannot change qualification of `%s'",<br>
> +                          var->name);<br>
> +      }<br>
> +   }<br>
> +<br>
>      /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec,<br>
>       *<br>
>       * "It is legal to declare an array without a size and then<br>
> @@ -4246,11 +4269,6 @@ get_variable_being_redeclared(ir_variable **var_ptr, YYLTYPE loc,<br>
>       */<br>
>      if (earlier->type->is_unsized_array() && var->type->is_array()<br>
>          && (var->type->fields.array == earlier->type->fields.array)) {<br>
> -      /* FINISHME: This doesn't match the qualifiers on the two<br>
> -       * FINISHME: declarations.  It's not 100% clear whether this is<br>
> -       * FINISHME: required or not.<br>
> -       */<br>
> -<br>
>         const int size = var->type->array_size();<br>
>         check_builtin_array_max_size(var->name, size, loc, state);<br>
>         if ((size > 0) && (size <= earlier->data.max_array_access)) {<br>
> @@ -4342,28 +4360,13 @@ get_variable_being_redeclared(ir_variable **var_ptr, YYLTYPE loc,<br>
>         earlier->data.precision = var->data.precision;<br>
>         earlier->data.memory_coherent = var->data.memory_coherent;<br>
>   <br>
> -   } else if (earlier->data.how_declared == ir_var_declared_implicitly &&<br>
> -              state->allow_builtin_variable_redeclaration) {<br>
> +   } else if ((earlier->data.how_declared == ir_var_declared_implicitly &&<br>
> +               state->allow_builtin_variable_redeclaration) ||<br>
> +              allow_all_redeclarations) {<br>
>         /* Allow verbatim redeclarations of built-in variables. Not explicitly<br>
>          * valid, but some applications do it.<br>
>          */<br>
> -      if (earlier->data.mode != var->data.mode &&<br>
> -          !(earlier->data.mode == ir_var_system_value &&<br>
> -            var->data.mode == ir_var_shader_in)) {<br>
> -         _mesa_glsl_error(&loc, state,<br>
> -                          "redeclaration of `%s' with incorrect qualifiers",<br>
> -                          var->name);<br>
> -      } else if (earlier->type != var->type) {<br>
> -         _mesa_glsl_error(&loc, state,<br>
> -                          "redeclaration of `%s' has incorrect type",<br>
> -                          var->name);<br>
> -      }<br>
> -   } else if (allow_all_redeclarations) {<br>
> -      if (earlier->data.mode != var->data.mode) {<br>
> -         _mesa_glsl_error(&loc, state,<br>
> -                          "redeclaration of `%s' with incorrect qualifiers",<br>
> -                          var->name);<br>
> -      } else if (earlier->type != var->type) {<br>
> +      if (earlier->type != var->type) {<br>
>            _mesa_glsl_error(&loc, state,<br>
>                             "redeclaration of `%s' has incorrect type",<br>
>                             var->name);<br>
> <br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>