[Mesa-dev] [PATCH] anv/pipeline: honor the pipeline_cache_enabled run-time flag

Iago Toral itoral at igalia.com
Mon Jul 9 06:31:21 UTC 2018


On Mon, 2018-07-09 at 08:22 +0200, Iago Toral wrote:
> On Fri, 2018-07-06 at 15:50 +0100, Lionel Landwerlin wrote:
> > On 04/07/18 09:44, Iago Toral Quiroga wrote:
> > > ---
> > >   src/intel/vulkan/anv_pipeline_cache.c | 37 +++++++++++++++++++-
> > > --
> > > -------------
> > >   1 file changed, 20 insertions(+), 17 deletions(-)
> > > 
> > > diff --git a/src/intel/vulkan/anv_pipeline_cache.c
> > > b/src/intel/vulkan/anv_pipeline_cache.c
> > > index d4c7262dc0..5825bf9f01 100644
> > > --- a/src/intel/vulkan/anv_pipeline_cache.c
> > > +++ b/src/intel/vulkan/anv_pipeline_cache.c
> > > @@ -570,23 +570,26 @@ anv_device_search_for_kernel(struct
> > > anv_device *device,
> > >      }
> > >   
> > 
> > I guess you could do :
> > 
> > if (disk_cache && device->instance->pipeline_cache_enabled) {
> > ...
> > 
> > to minimize the diff.
> 
> Sure, will do that.
> 
> > Do we still want to save stuff in the cache
> > (anv_device_upload_kernel) 
> > when cache is disabled?
> 
> Good question... looking at the implementation it looks that the
> intent
> behind the flag was to also control in-memory cache, so it is
> probably
> a good idea. I'll send a v2 disabling that too.


Actually, we are already disabling that, we have this code in
anv_pipeline_init:

   /* Use the default pipeline cache if none is specified */
   if (cache == NULL && device->instance->pipeline_cache_enabled)
      cache = &device->default_pipeline_cache;

So when pipeline_cache_enabled is False we don't have a memory cache
unless one is provided by the application, in which case we would want
to use it.

I'l, push the v1 then.

Iago

> Iago
> 
> > Regardless :
> > 
> > Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> > 
> > Thanks!
> > 
> > >   #ifdef ENABLE_SHADER_CACHE
> > > -   struct disk_cache *disk_cache = device->instance-
> > > > physicalDevice.disk_cache;
> > > 
> > > -   if (disk_cache) {
> > > -      cache_key cache_key;
> > > -      disk_cache_compute_key(disk_cache, key_data, key_size,
> > > cache_key);
> > > -
> > > -      size_t buffer_size;
> > > -      uint8_t *buffer = disk_cache_get(disk_cache, cache_key,
> > > &buffer_size);
> > > -      if (buffer) {
> > > -         struct blob_reader blob;
> > > -         blob_reader_init(&blob, buffer, buffer_size);
> > > -         bin = anv_shader_bin_create_from_blob(device, &blob);
> > > -         free(buffer);
> > > -
> > > -         if (bin) {
> > > -            if (cache)
> > > -               anv_pipeline_cache_add_shader_bin(cache, bin);
> > > -            return bin;
> > > +   if (device->instance->pipeline_cache_enabled) {
> > > +      struct disk_cache *disk_cache =
> > > +         device->instance->physicalDevice.disk_cache;
> > > +      if (disk_cache) {
> > > +         cache_key cache_key;
> > > +         disk_cache_compute_key(disk_cache, key_data, key_size,
> > > cache_key);
> > > +
> > > +         size_t buffer_size;
> > > +         uint8_t *buffer = disk_cache_get(disk_cache, cache_key,
> > > &buffer_size);
> > > +         if (buffer) {
> > > +            struct blob_reader blob;
> > > +            blob_reader_init(&blob, buffer, buffer_size);
> > > +            bin = anv_shader_bin_create_from_blob(device,
> > > &blob);
> > > +            free(buffer);
> > > +
> > > +            if (bin) {
> > > +               if (cache)
> > > +                  anv_pipeline_cache_add_shader_bin(cache, bin);
> > > +               return bin;
> > > +            }
> > >            }
> > >         }
> > >      }
> > 
> > 


More information about the mesa-dev mailing list