struct util_live_shader *shader = entry ? entry->data : NULL;
/* Increase the refcount. */
- if (shader)
+ if (shader) {
pipe_reference(NULL, &shader->reference);
+ cache->hits++;
+ }
simple_mtx_unlock(&cache->lock);
/* Return if the shader already exists. */
} else {
_mesa_hash_table_insert(cache->hashtable, shader->sha1, shader);
}
+ cache->misses++;
simple_mtx_unlock(&cache->lock);
return shader;
void *(*create_shader)(struct pipe_context *,
const struct pipe_shader_state *state);
void (*destroy_shader)(struct pipe_context *, void *);
+
+ unsigned hits, misses;
};
struct util_live_shader {
{ "tex", DBG(TEX), "Print texture info" },
{ "compute", DBG(COMPUTE), "Print compute info" },
{ "vm", DBG(VM), "Print virtual addresses when creating resources" },
+ { "cache_stats", DBG(CACHE_STATS), "Print shader cache statistics." },
/* Driver options: */
{ "forcedma", DBG(FORCE_SDMA), "Use SDMA for all operations when possible." },
if (!sscreen->ws->unref(sscreen->ws))
return;
+ if (sscreen->debug_flags & DBG(CACHE_STATS)) {
+ printf("live shader cache: hits = %u, misses = %u\n",
+ sscreen->live_shader_cache.hits,
+ sscreen->live_shader_cache.misses);
+ printf("memory shader cache: hits = %u, misses = %u\n",
+ sscreen->num_memory_shader_cache_hits,
+ sscreen->num_memory_shader_cache_misses);
+ printf("disk shader cache: hits = %u, misses = %u\n",
+ sscreen->num_disk_shader_cache_hits,
+ sscreen->num_disk_shader_cache_misses);
+ }
+
simple_mtx_destroy(&sscreen->aux_context_lock);
struct u_log_context *aux_log = ((struct si_context *)sscreen->aux_context)->log;
DBG_TEX,
DBG_COMPUTE,
DBG_VM,
+ DBG_CACHE_STATS,
/* Driver options: */
DBG_FORCE_SDMA,
* are loading shaders on demand. This is a monotonic counter.
*/
unsigned num_shaders_created;
- unsigned num_shader_cache_hits;
+ unsigned num_memory_shader_cache_hits;
+ unsigned num_memory_shader_cache_misses;
+ unsigned num_disk_shader_cache_hits;
+ unsigned num_disk_shader_cache_misses;
/* GPU load thread. */
simple_mtx_t gpu_load_mutex;
break;
case SI_QUERY_NUM_SHADER_CACHE_HITS:
query->begin_result =
- p_atomic_read(&sctx->screen->num_shader_cache_hits);
+ p_atomic_read(&sctx->screen->num_memory_shader_cache_hits);
break;
case SI_QUERY_PD_NUM_PRIMS_ACCEPTED:
query->begin_result = sctx->compute_num_verts_accepted;
break;
case SI_QUERY_NUM_SHADER_CACHE_HITS:
query->end_result =
- p_atomic_read(&sctx->screen->num_shader_cache_hits);
+ p_atomic_read(&sctx->screen->num_memory_shader_cache_hits);
break;
case SI_QUERY_PD_NUM_PRIMS_ACCEPTED:
query->end_result = sctx->compute_num_verts_accepted;
if (entry) {
if (si_load_shader_binary(shader, entry->data)) {
- p_atomic_inc(&sscreen->num_shader_cache_hits);
+ p_atomic_inc(&sscreen->num_memory_shader_cache_hits);
return true;
}
}
+ p_atomic_inc(&sscreen->num_memory_shader_cache_misses);
if (!sscreen->disk_shader_cache)
return false;
free(buffer);
si_shader_cache_insert_shader(sscreen, ir_sha1_cache_key,
shader, false);
- p_atomic_inc(&sscreen->num_shader_cache_hits);
+ p_atomic_inc(&sscreen->num_disk_shader_cache_hits);
return true;
}
} else {
}
free(buffer);
+ p_atomic_inc(&sscreen->num_disk_shader_cache_misses);
return false;
}