[Mesa-dev] [PATCH] glsl: fix shader cache for packed param list

Marek Olšák maraeo at gmail.com
Thu Feb 28 00:19:16 UTC 2019


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Wed, Feb 27, 2019 at 2:26 AM Timothy Arceri <tarceri at itsqueeze.com>
wrote:

> Some types of params such as some builtins are always padded. We
> need to keep track of this so we can restore the list correctly.
>
> Here we also remove a couple of cache entries that are not actually
> required as they get rebuilt by the _mesa_add_parameter() calls.
>
> This patch fixes a bunch of arb_texture_multisample and
> arb_sample_shading piglit test for the radeonsi NIR backend.
>
> Fixes: edded1237607 ("mesa: rework ParameterList to allow packing")
> ---
>  src/compiler/glsl/serialize.cpp   | 15 ++++-----------
>  src/mesa/program/prog_parameter.c |  1 +
>  src/mesa/program/prog_parameter.h |  6 ++++++
>  3 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/src/compiler/glsl/serialize.cpp
> b/src/compiler/glsl/serialize.cpp
> index fdd99ec59da..ad258f8bcb1 100644
> --- a/src/compiler/glsl/serialize.cpp
> +++ b/src/compiler/glsl/serialize.cpp
> @@ -996,15 +996,14 @@ write_shader_parameters(struct blob *metadata,
>                          struct gl_program_parameter_list *params)
>  {
>     blob_write_uint32(metadata, params->NumParameters);
> -   blob_write_uint32(metadata, params->NumParameterValues);
>     uint32_t i = 0;
>
>     while (i < params->NumParameters) {
>        struct gl_program_parameter *param = &params->Parameters[i];
> -
>        blob_write_uint32(metadata, param->Type);
>        blob_write_string(metadata, param->Name);
>        blob_write_uint32(metadata, param->Size);
> +      blob_write_uint32(metadata, param->Padded);
>        blob_write_uint32(metadata, param->DataType);
>        blob_write_bytes(metadata, param->StateIndexes,
>                         sizeof(param->StateIndexes));
> @@ -1015,9 +1014,6 @@ write_shader_parameters(struct blob *metadata,
>     blob_write_bytes(metadata, params->ParameterValues,
>                      sizeof(gl_constant_value) *
> params->NumParameterValues);
>
> -   blob_write_bytes(metadata, params->ParameterValueOffset,
> -                    sizeof(uint32_t) * params->NumParameters);
> -
>     blob_write_uint32(metadata, params->StateFlags);
>  }
>
> @@ -1028,28 +1024,25 @@ read_shader_parameters(struct blob_reader
> *metadata,
>     gl_state_index16 state_indexes[STATE_LENGTH];
>     uint32_t i = 0;
>     uint32_t num_parameters = blob_read_uint32(metadata);
> -   uint32_t num_parameters_values = blob_read_uint32(metadata);
>
>     _mesa_reserve_parameter_storage(params, num_parameters);
>     while (i < num_parameters) {
>        gl_register_file type = (gl_register_file)
> blob_read_uint32(metadata);
>        const char *name = blob_read_string(metadata);
>        unsigned size = blob_read_uint32(metadata);
> +      bool padded = blob_read_uint32(metadata);
>        unsigned data_type = blob_read_uint32(metadata);
>        blob_copy_bytes(metadata, (uint8_t *) state_indexes,
>                        sizeof(state_indexes));
>
>        _mesa_add_parameter(params, type, name, size, data_type,
> -                          NULL, state_indexes, false);
> +                          NULL, state_indexes, padded);
>
>        i++;
>     }
>
>     blob_copy_bytes(metadata, (uint8_t *) params->ParameterValues,
> -                   sizeof(gl_constant_value) * num_parameters_values);
> -
> -   blob_copy_bytes(metadata, (uint8_t *) params->ParameterValueOffset,
> -                   sizeof(uint32_t) * num_parameters);
> +                   sizeof(gl_constant_value) *
> params->NumParameterValues);
>
>     params->StateFlags = blob_read_uint32(metadata);
>  }
> diff --git a/src/mesa/program/prog_parameter.c
> b/src/mesa/program/prog_parameter.c
> index 62f31f205af..2f3520bf750 100644
> --- a/src/mesa/program/prog_parameter.c
> +++ b/src/mesa/program/prog_parameter.c
> @@ -275,6 +275,7 @@ _mesa_add_parameter(struct gl_program_parameter_list
> *paramList,
>     p->Name = strdup(name ? name : "");
>     p->Type = type;
>     p->Size = size;
> +   p->Padded = pad_and_align;
>     p->DataType = datatype;
>
>     paramList->ParameterValueOffset[oldNum] = oldValNum;
> diff --git a/src/mesa/program/prog_parameter.h
> b/src/mesa/program/prog_parameter.h
> index 78c9909f5cc..57050042012 100644
> --- a/src/mesa/program/prog_parameter.h
> +++ b/src/mesa/program/prog_parameter.h
> @@ -104,6 +104,12 @@ struct gl_program_parameter
>      * A sequence of STATE_* tokens and integers to identify GL state.
>      */
>     gl_state_index16 StateIndexes[STATE_LENGTH];
> +
> +   /**
> +    * We need to keep track of whether the param is padded for use in the
> +    * shader cache.
> +    */
> +   bool Padded;
>  };
>
>
> --
> 2.20.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20190227/c05eec20/attachment.html>


More information about the mesa-dev mailing list