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 5f99e51..4b0b15c 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 3a7c482..49c41d8 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 614eb64..498c80d 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 174418a..b2c4ee1 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 9d4dc94..9acb033 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 54865f8..600b061 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 37ce999..73bc663 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 445f5e0..f6acf81 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 eaea00e..3b46420 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 2811dbd..6f37dfa 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 21e7566..f518649 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 a8cf07c..c65ca16 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))