[Mesa-dev] [PATCH 8/8] glsl: stop adding pointers from bindless structs to the cache

Samuel Pitoiset samuel.pitoiset at gmail.com
Wed Aug 23 09:28:50 UTC 2017


Assuming this doesn't introduce regressions, series is:

Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

On 08/14/2017 01:49 AM, Timothy Arceri wrote:
> This is so we always create reproducible cache entries. Consistency
> is required for verification of any third party distributed shaders.
> ---
>   src/compiler/glsl/shader_cache.cpp | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
> index aa63bdcf01..aa6c067d04 100644
> --- a/src/compiler/glsl/shader_cache.cpp
> +++ b/src/compiler/glsl/shader_cache.cpp
> @@ -1212,32 +1212,34 @@ write_shader_metadata(struct blob *metadata, gl_linked_shader *shader)
>                       sizeof(glprog->SamplerUnits));
>      blob_write_bytes(metadata, glprog->sh.SamplerTargets,
>                       sizeof(glprog->sh.SamplerTargets));
>      blob_write_uint32(metadata, glprog->ShadowSamplers);
>   
>      blob_write_bytes(metadata, glprog->sh.ImageAccess,
>                       sizeof(glprog->sh.ImageAccess));
>      blob_write_bytes(metadata, glprog->sh.ImageUnits,
>                       sizeof(glprog->sh.ImageUnits));
>   
> +   size_t ptr_size = sizeof(GLvoid *);
> +
>      blob_write_uint32(metadata, glprog->sh.NumBindlessSamplers);
>      blob_write_uint32(metadata, glprog->sh.HasBoundBindlessSampler);
>      for (i = 0; i < glprog->sh.NumBindlessSamplers; i++) {
>         blob_write_bytes(metadata, &glprog->sh.BindlessSamplers[i],
> -                       sizeof(struct gl_bindless_sampler));
> +                       sizeof(struct gl_bindless_sampler) - ptr_size);
>      }
>   
>      blob_write_uint32(metadata, glprog->sh.NumBindlessImages);
>      blob_write_uint32(metadata, glprog->sh.HasBoundBindlessImage);
>      for (i = 0; i < glprog->sh.NumBindlessImages; i++) {
>         blob_write_bytes(metadata, &glprog->sh.BindlessImages[i],
> -                       sizeof(struct gl_bindless_image));
> +                       sizeof(struct gl_bindless_image) - ptr_size);
>      }
>   
>      write_shader_parameters(metadata, glprog->Parameters);
>   }
>   
>   static void
>   read_shader_metadata(struct blob_reader *metadata,
>                        struct gl_program *glprog,
>                        gl_linked_shader *linked)
>   {
> @@ -1251,43 +1253,45 @@ read_shader_metadata(struct blob_reader *metadata,
>                      sizeof(glprog->SamplerUnits));
>      blob_copy_bytes(metadata, (uint8_t *) glprog->sh.SamplerTargets,
>                      sizeof(glprog->sh.SamplerTargets));
>      glprog->ShadowSamplers = blob_read_uint32(metadata);
>   
>      blob_copy_bytes(metadata, (uint8_t *) glprog->sh.ImageAccess,
>                      sizeof(glprog->sh.ImageAccess));
>      blob_copy_bytes(metadata, (uint8_t *) glprog->sh.ImageUnits,
>                      sizeof(glprog->sh.ImageUnits));
>   
> +   size_t ptr_size = sizeof(GLvoid *);
> +
>      glprog->sh.NumBindlessSamplers = blob_read_uint32(metadata);
>      glprog->sh.HasBoundBindlessSampler = blob_read_uint32(metadata);
>      if (glprog->sh.NumBindlessSamplers > 0) {
>         glprog->sh.BindlessSamplers =
>            rzalloc_array(glprog, gl_bindless_sampler,
>                          glprog->sh.NumBindlessSamplers);
>   
>         for (i = 0; i < glprog->sh.NumBindlessSamplers; i++) {
>            blob_copy_bytes(metadata, (uint8_t *) &glprog->sh.BindlessSamplers[i],
> -                         sizeof(struct gl_bindless_sampler));
> +                         sizeof(struct gl_bindless_sampler) - ptr_size);
>         }
>      }
>   
>      glprog->sh.NumBindlessImages = blob_read_uint32(metadata);
>      glprog->sh.HasBoundBindlessImage = blob_read_uint32(metadata);
>      if (glprog->sh.NumBindlessImages > 0) {
>         glprog->sh.BindlessImages =
>            rzalloc_array(glprog, gl_bindless_image,
>                          glprog->sh.NumBindlessImages);
>   
>         for (i = 0; i < glprog->sh.NumBindlessImages; i++) {
>            blob_copy_bytes(metadata, (uint8_t *) &glprog->sh.BindlessImages[i],
> -                        sizeof(struct gl_bindless_image));
> +                        sizeof(struct gl_bindless_image) - ptr_size);
>         }
>      }
>   
>      glprog->Parameters = _mesa_new_parameter_list();
>      read_shader_parameters(metadata, glprog->Parameters);
>   }
>   
>   static void
>   create_binding_str(const char *key, unsigned value, void *closure)
>   {
> 


More information about the mesa-dev mailing list