[Mesa-dev] [PATCH v2 14/32] glsl/shader_cache: Save and restore serialized nir in gl_program

Timothy Arceri tarceri at itsqueeze.com
Fri Oct 20 01:42:42 UTC 2017


On 20/10/17 09:03, Timothy Arceri wrote:
> This and the previous patch feels wrong. The glsl shader cache shouldn't 
> be handling writing nir to disk. IMO you should add this functionality 
> to nir_serialize.c (maybe rename is nir_cache.c ??). That way we have 
> continue with the nir is a toolkit theme and we can easily reused the 
> util to write nir to disk in Vulkan which could be useful for reducing 
> compile times.
> 
> Doing it this way we could deserialize it in brw_link() and serialize it 
> in glsl_to_nir() no need for the extra serialized_nir params.

After discussing this on IRC Jordan has changed my mind.

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

> 
> On 19/10/17 16:32, Jordan Justen wrote:
>> Signed-off-by: Jordan Justen <jordan.l.justen at inir_serialize.cntel.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 ca90cfde35..f43bd6b17e 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->serialized_nir == NULL) ==
>> +          (glprog->serialized_nir_size == 0));
>> +   blob_write_uint32(metadata, (uint32_t)glprog->serialized_nir_size);
>> +   if (glprog->serialized_nir_size > 0) {
>> +      blob_write_bytes(metadata, glprog->serialized_nir,
>> +                       glprog->serialized_nir_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->serialized_nir_size = (size_t)blob_read_uint32(metadata);
>> +   if (glprog->serialized_nir_size > 0) {
>> +      glprog->serialized_nir =
>> +         (uint8_t*)ralloc_size(glprog, glprog->serialized_nir_size);
>> +      blob_copy_bytes(metadata, glprog->serialized_nir,
>> +                      glprog->serialized_nir_size);
>> +   }
>>   }
>>   static void
>>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list