i965: Add flag_state param to brw_search_cache

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>
This commit is contained in:
Jordan Justen 2018-02-28 21:43:22 -08:00
parent 48ce7745dc
commit eb5b4b0fd1
No known key found for this signature in database
GPG key ID: 37F99F68CAF992EB
12 changed files with 35 additions and 45 deletions

View 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

View 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 );
}
}

View 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))

View 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);
}
}

View 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))

View 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;
}

View 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 );
}
}

View 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,

View 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))

View 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))

View 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))

View 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))