<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>