[Mesa-dev] [PATCH] glsl: Allow ES2 function parameters to be hidden by variable declarations.
Ian Romanick
idr at freedesktop.org
Wed Jul 18 21:37:01 UTC 2018
On 07/16/2018 02:46 PM, Eric Anholt wrote:
> This fixes dEQP case:
>
> dEQP-GLES2.functional.shaders.scoping.valid.local_variable_hides_function_parameter_fragment
Are we sure that test is correct? I'm sure I already know the answer,
but does the test contain any justification or spec references? I just
re-read section 4.2 (Scoping) of the ESSL 1.00 spec, and I don't see
anything to support this. Did I miss something?
In fact, the grammar says:
function_definition:
function_prototype compound_statement_no_new_scope
So... I think this test is just wrong.
> without breaking
>
> dEQP-GLES3.functional.shaders.scoping.invalid.local_variable_hides_function_parameter_fragment
> ---
> src/compiler/glsl/ast_to_hir.cpp | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
> index dd60a2a87fd5..28f074ca8a39 100644
> --- a/src/compiler/glsl/ast_to_hir.cpp
> +++ b/src/compiler/glsl/ast_to_hir.cpp
> @@ -6180,10 +6180,19 @@ ast_function_definition::hir(exec_list *instructions,
> }
> }
>
> + /* On ES2, function parameters may be redeclared to be hidden within the
> + * function. Do this by creating a new scope inside the function.
> + */
> + if (state->is_version(0, 100) && !state->is_version(0, 300))
> + state->symbols->push_scope();
> +
> /* Convert the body of the function to HIR. */
> this->body->hir(&signature->body, state);
> signature->is_defined = true;
>
> + if (state->is_version(0, 100) && !state->is_version(0, 300))
> + state->symbols->pop_scope();
> +
> state->symbols->pop_scope();
>
> assert(state->current_function == signature);
>
More information about the mesa-dev
mailing list