[Mesa-dev] [PATCH v3 13/34] glsl/shader_cache: Save and restore serialized nir in gl_program

Kenneth Graunke kenneth at whitecape.org
Sun Oct 29 08:24:37 UTC 2017


On Sunday, October 22, 2017 1:01:21 PM PDT Jordan Justen wrote:
> v3:
>  * Rename serialized_nir* to driver_cache_blob*. (Tim)
> 
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
> ---
>  src/compiler/glsl/shader_cache.cpp | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
> index ca90cfde350..1d208fb0911 100644
> --- a/src/compiler/glsl/shader_cache.cpp
> +++ b/src/compiler/glsl/shader_cache.cpp
> @@ -1062,6 +1062,14 @@ write_shader_metadata(struct blob *metadata, gl_linked_shader *shader)
>     }
>  
>     write_shader_parameters(metadata, glprog->Parameters);
> +
> +   assert((glprog->driver_cache_blob == NULL) ==
> +          (glprog->driver_cache_blob_size == 0));
> +   blob_write_uint32(metadata, (uint32_t)glprog->driver_cache_blob_size);
> +   if (glprog->driver_cache_blob_size > 0) {
> +      blob_write_bytes(metadata, glprog->driver_cache_blob,
> +                       glprog->driver_cache_blob_size);
> +   }
>  }
>  
>  static void
> @@ -1116,6 +1124,14 @@ read_shader_metadata(struct blob_reader *metadata,
>  
>     glprog->Parameters = _mesa_new_parameter_list();
>     read_shader_parameters(metadata, glprog->Parameters);
> +
> +   glprog->driver_cache_blob_size = (size_t)blob_read_uint32(metadata);
> +   if (glprog->driver_cache_blob_size > 0) {
> +      glprog->driver_cache_blob =
> +         (uint8_t*)ralloc_size(glprog, glprog->driver_cache_blob_size);
> +      blob_copy_bytes(metadata, glprog->driver_cache_blob,
> +                      glprog->driver_cache_blob_size);
> +   }

Shouldn't you check for overrun here, and leave things in a consistent
state (passing the assertion above)?

>  }
>  
>  static void
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20171029/28d04cd2/attachment.sig>


More information about the mesa-dev mailing list