i965: Add flag_state param to brw_search_cache
authorJordan Justen <jordan.l.justen@intel.com>
Thu, 1 Mar 2018 05:43:22 +0000 (21:43 -0800)
committerJordan Justen <jordan.l.justen@intel.com>
Tue, 10 Jul 2018 06:02:33 +0000 (23:02 -0700)
This allows brw_search_cache to be used to find programs without
causing extra state to be emitted in the case where the program isn't
being made active. (For example, to find the program to save out with
the ARB_get_program_binary interface.)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
12 files changed:
src/mesa/drivers/dri/i965/brw_blorp.c
src/mesa/drivers/dri/i965/brw_clip.c
src/mesa/drivers/dri/i965/brw_cs.c
src/mesa/drivers/dri/i965/brw_ff_gs.c
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_program_cache.c
src/mesa/drivers/dri/i965/brw_sf.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_tcs.c
src/mesa/drivers/dri/i965/brw_tes.c
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_wm.c

index 5f99e51bc286956d2bc9815ca37f6a048cc9237d..4b0b15cf4f63331f977af2cf0df9a01571d8fb17 100644 (file)
@@ -48,8 +48,8 @@ brw_blorp_lookup_shader(struct blorp_context *blorp,
                         uint32_t *kernel_out, void *prog_data_out)
 {
    struct brw_context *brw = blorp->driver_ctx;
-   return brw_search_cache(&brw->cache, BRW_CACHE_BLORP_PROG,
-                           key, key_size, kernel_out, prog_data_out);
+   return brw_search_cache(&brw->cache, BRW_CACHE_BLORP_PROG, key, key_size,
+                           kernel_out, prog_data_out, true);
 }
 
 static bool
index 3a7c4829ed775828e2bd8c3e60405ad81ec2df05..49c41d8c2e44ba72928118d9d2751131d1c235c6 100644 (file)
@@ -203,9 +203,8 @@ brw_upload_clip_prog(struct brw_context *brw)
       }
    }
 
-   if (!brw_search_cache(&brw->cache, BRW_CACHE_CLIP_PROG,
-                        &key, sizeof(key),
-                        &brw->clip.prog_offset, &brw->clip.prog_data)) {
+   if (!brw_search_cache(&brw->cache, BRW_CACHE_CLIP_PROG, &key, sizeof(key),
+                         &brw->clip.prog_offset, &brw->clip.prog_data, true)) {
       compile_clip_prog( brw, &key );
    }
 }
index 614eb64bca94200710069e3a010e2f6d5500a410..498c80d46a529db87cd3a3e59e9a0ede2d3a4693 100644 (file)
@@ -168,10 +168,9 @@ brw_upload_cs_prog(struct brw_context *brw)
 
    brw_cs_populate_key(brw, &key);
 
-   if (brw_search_cache(&brw->cache, BRW_CACHE_CS_PROG,
-                        &key, sizeof(key),
-                        &brw->cs.base.prog_offset,
-                        &brw->cs.base.prog_data))
+   if (brw_search_cache(&brw->cache, BRW_CACHE_CS_PROG, &key, sizeof(key),
+                        &brw->cs.base.prog_offset, &brw->cs.base.prog_data,
+                        true))
       return;
 
    if (brw_disk_cache_upload_program(brw, MESA_SHADER_COMPUTE))
index 174418a4748d27df1e7e3001bf49294723cf9036..b2c4ee12f4d1844f993df419fd5bcf86bc62d668 100644 (file)
@@ -251,9 +251,9 @@ brw_upload_ff_gs_prog(struct brw_context *brw)
    }
 
    if (brw->ff_gs.prog_active) {
-      if (!brw_search_cache(&brw->cache, BRW_CACHE_FF_GS_PROG,
-                           &key, sizeof(key),
-                           &brw->ff_gs.prog_offset, &brw->ff_gs.prog_data)) {
+      if (!brw_search_cache(&brw->cache, BRW_CACHE_FF_GS_PROG, &key,
+                            sizeof(key), &brw->ff_gs.prog_offset,
+                            &brw->ff_gs.prog_data, true)) {
          brw_codegen_ff_gs_prog(brw, &key);
       }
    }
index 9d4dc942d34be69dc912aabe61b46162c909a0e8..9acb0337e20f974575c84f55dcba72123827089d 100644 (file)
@@ -192,10 +192,9 @@ brw_upload_gs_prog(struct brw_context *brw)
 
    brw_gs_populate_key(brw, &key);
 
-   if (brw_search_cache(&brw->cache, BRW_CACHE_GS_PROG,
-                        &key, sizeof(key),
-                        &stage_state->prog_offset,
-                        &brw->gs.base.prog_data))
+   if (brw_search_cache(&brw->cache, BRW_CACHE_GS_PROG, &key, sizeof(key),
+                        &stage_state->prog_offset, &brw->gs.base.prog_data,
+                        true))
       return;
 
    if (brw_disk_cache_upload_program(brw, MESA_SHADER_GEOMETRY))
index 54865f8b1b9e65d54f536056dedec44ad3849569..600b0611c8b89095e39395710b859fe397812910 100644 (file)
@@ -194,12 +194,10 @@ rehash(struct brw_cache *cache)
  * Returns the buffer object matching cache_id and key, or NULL.
  */
 bool
-brw_search_cache(struct brw_cache *cache,
-                 enum brw_cache_id cache_id,
-                 const void *key, GLuint key_size,
-                 uint32_t *inout_offset, void *inout_prog_data)
+brw_search_cache(struct brw_cache *cache, enum brw_cache_id cache_id,
+                 const void *key, GLuint key_size, uint32_t *inout_offset,
+                 void *inout_prog_data, bool flag_state)
 {
-   struct brw_context *brw = cache->brw;
    struct brw_cache_item *item;
    struct brw_cache_item lookup;
    GLuint hash;
@@ -219,7 +217,8 @@ brw_search_cache(struct brw_cache *cache,
 
    if (item->offset != *inout_offset ||
        prog_data != *((void **) inout_prog_data)) {
-      brw->ctx.NewDriverState |= (1 << cache_id);
+      if (likely(flag_state))
+         cache->brw->ctx.NewDriverState |= (1 << cache_id);
       *inout_offset = item->offset;
       *((void **) inout_prog_data) = prog_data;
    }
index 37ce999dc0725ea62531b63c6a96d73bdfd8dd69..73bc663f29ff252c455b55ed146e1a3b0ac2e894 100644 (file)
@@ -164,9 +164,8 @@ brw_upload_sf_prog(struct brw_context *brw)
       key.frontface_ccw = brw->polygon_front_bit == render_to_fbo;
    }
 
-   if (!brw_search_cache(&brw->cache, BRW_CACHE_SF_PROG,
-                        &key, sizeof(key),
-                        &brw->sf.prog_offset, &brw->sf.prog_data)) {
+   if (!brw_search_cache(&brw->cache, BRW_CACHE_SF_PROG, &key, sizeof(key),
+                         &brw->sf.prog_offset, &brw->sf.prog_data, true)) {
       compile_sf_prog( brw, &key );
    }
 }
index 445f5e0b5103225af2125e10b08a8a7686146a53..f6acf81b899d990f30753f32615f7ef36865a129 100644 (file)
@@ -163,11 +163,9 @@ void brw_upload_cache(struct brw_cache *cache,
                       GLuint aux_sz,
                       uint32_t *out_offset, void *out_aux);
 
-bool brw_search_cache(struct brw_cache *cache,
-                      enum brw_cache_id cache_id,
-                      const void *key,
-                      GLuint key_size,
-                      uint32_t *inout_offset, void *inout_aux);
+bool brw_search_cache(struct brw_cache *cache, enum brw_cache_id cache_id,
+                      const void *key, GLuint key_size, uint32_t *inout_offset,
+                      void *inout_aux, bool flag_state);
 
 const void *brw_find_previous_compile(struct brw_cache *cache,
                                       enum brw_cache_id cache_id,
index eaea00e9e4879408d05cbed07ed1ff92f8d071d2..3b4642033fe9a97a6168beb5b2d4a565a92efc89 100644 (file)
@@ -337,10 +337,9 @@ brw_upload_tcs_prog(struct brw_context *brw)
 
    brw_tcs_populate_key(brw, &key);
 
-   if (brw_search_cache(&brw->cache, BRW_CACHE_TCS_PROG,
-                        &key, sizeof(key),
-                        &stage_state->prog_offset,
-                        &brw->tcs.base.prog_data))
+   if (brw_search_cache(&brw->cache, BRW_CACHE_TCS_PROG, &key, sizeof(key),
+                        &stage_state->prog_offset, &brw->tcs.base.prog_data,
+                        true))
       return;
 
    if (brw_disk_cache_upload_program(brw, MESA_SHADER_TESS_CTRL))
index 2811dbd649a992dabab3d8970e204eed1c8b13fd..6f37dfabbf8f9a1dda4845c39e56d4cecd2e8552 100644 (file)
@@ -195,10 +195,9 @@ brw_upload_tes_prog(struct brw_context *brw)
 
    brw_tes_populate_key(brw, &key);
 
-   if (brw_search_cache(&brw->cache, BRW_CACHE_TES_PROG,
-                        &key, sizeof(key),
-                        &stage_state->prog_offset,
-                        &brw->tes.base.prog_data))
+   if (brw_search_cache(&brw->cache, BRW_CACHE_TES_PROG, &key, sizeof(key),
+                        &stage_state->prog_offset, &brw->tes.base.prog_data,
+                        true))
       return;
 
    if (brw_disk_cache_upload_program(brw, MESA_SHADER_TESS_EVAL))
index 21e75664ae955d5fbd990564193803816672c94e..f518649e7518113190ef390aa0e80f599870186f 100644 (file)
@@ -341,9 +341,9 @@ brw_upload_vs_prog(struct brw_context *brw)
 
    brw_vs_populate_key(brw, &key);
 
-   if (brw_search_cache(&brw->cache, BRW_CACHE_VS_PROG,
-                        &key, sizeof(key),
-                        &brw->vs.base.prog_offset, &brw->vs.base.prog_data))
+   if (brw_search_cache(&brw->cache, BRW_CACHE_VS_PROG, &key, sizeof(key),
+                        &brw->vs.base.prog_offset, &brw->vs.base.prog_data,
+                        true))
       return;
 
    if (brw_disk_cache_upload_program(brw, MESA_SHADER_VERTEX))
index a8cf07ce7e26f2210f4680243af6feef8bdb4880..c65ca166286d9aacac44710e313dbb9bc8e52512 100644 (file)
@@ -590,10 +590,9 @@ brw_upload_wm_prog(struct brw_context *brw)
 
    brw_wm_populate_key(brw, &key);
 
-   if (brw_search_cache(&brw->cache, BRW_CACHE_FS_PROG,
-                        &key, sizeof(key),
-                        &brw->wm.base.prog_offset,
-                        &brw->wm.base.prog_data))
+   if (brw_search_cache(&brw->cache, BRW_CACHE_FS_PROG, &key, sizeof(key),
+                        &brw->wm.base.prog_offset, &brw->wm.base.prog_data,
+                        true))
       return;
 
    if (brw_disk_cache_upload_program(brw, MESA_SHADER_FRAGMENT))