[Mesa-dev] [PATCH] nir: Fix output variable names

Iago Toral itoral at igalia.com
Fri Sep 11 03:53:56 PDT 2015


On Fri, 2015-09-11 at 09:24 +0200, Eduardo Lima Mitev wrote:
> Commit 1dbe4af9c9e318525fc082b542b93fb7f1e5efba
> "nir: Add a pass to lower outputs to temporary variables" messed up output
> variable names. The issue can be reproduced by dumping the NIR shaders
> with INTEL_DEBUG="vs,fs".
> ---
>  src/glsl/nir/nir_lower_outputs_to_temporaries.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/glsl/nir/nir_lower_outputs_to_temporaries.c b/src/glsl/nir/nir_lower_outputs_to_temporaries.c
> index b730cad..e9c4c0d 100644
> --- a/src/glsl/nir/nir_lower_outputs_to_temporaries.c
> +++ b/src/glsl/nir/nir_lower_outputs_to_temporaries.c
> @@ -87,12 +87,13 @@ nir_lower_outputs_to_temporaries(nir_shader *shader)
>     foreach_list_typed(nir_variable, var, node, &state.old_outputs) {
>        nir_variable *output = ralloc(shader, nir_variable);
>        memcpy(output, var, sizeof *output);
> +      output->name = ralloc_strdup(output, var->name);
>  
>        /* The orignal is now the temporary */
>        nir_variable *temp = var;
>  
>        /* Give the output a new name with @out-temp appended */
> -      temp->name = ralloc_asprintf(var, "%s at out-temp", output->name);
> +      temp->name = ralloc_asprintf(output, "%s at out-temp", output->name);
>        temp->data.mode = nir_var_global;
>        temp->constant_initializer = NULL;

I think I saw some instances of this happening today... however, isn't
the problem bigger than just the variable name? I see that nir_variable
has other fields that are also dynamically allocated so they are bound
to point to trashed memory as soon as some opt pass kills the old
variable (which is what is happening with the name).
 
Iago



More information about the mesa-dev mailing list