radeonsi: add a driver query for shader cache hits
authorMarek Olšák <marek.olsak@amd.com>
Thu, 11 Feb 2016 23:58:46 +0000 (00:58 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 1 Nov 2016 21:33:13 +0000 (22:33 +0100)
This is an 8-month old patch.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/r600_query.c
src/gallium/drivers/radeon/r600_query.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index d49f9d3597a84c208d9dc9619a74777c1d118017..9356274791a20941a9552c12e82819d15b1467b4 100644 (file)
@@ -380,6 +380,7 @@ struct r600_common_screen {
         * are loading shaders on demand. This is a monotonic counter.
         */
        unsigned                        num_shaders_created;
+       unsigned                        num_shader_cache_hits;
 
        /* GPU load thread. */
        pipe_mutex                      gpu_load_mutex;
index 047f597a23532f3a776608d491981a5eb5607d7b..9c9694a1cf485975f5b85dfb1e3d3237e1838140 100644 (file)
@@ -139,6 +139,10 @@ static bool r600_query_sw_begin(struct r600_common_context *rctx,
        case R600_QUERY_NUM_SHADERS_CREATED:
                query->begin_result = p_atomic_read(&rctx->screen->num_shaders_created);
                break;
+       case R600_QUERY_NUM_SHADER_CACHE_HITS:
+               query->begin_result =
+                       p_atomic_read(&rctx->screen->num_shader_cache_hits);
+               break;
        case R600_QUERY_GPIN_ASIC_ID:
        case R600_QUERY_GPIN_NUM_SIMD:
        case R600_QUERY_GPIN_NUM_RB:
@@ -218,6 +222,10 @@ static bool r600_query_sw_end(struct r600_common_context *rctx,
        case R600_QUERY_BACK_BUFFER_PS_DRAW_RATIO:
                query->end_result = rctx->last_tex_ps_draw_ratio;
                break;
+       case R600_QUERY_NUM_SHADER_CACHE_HITS:
+               query->end_result =
+                       p_atomic_read(&rctx->screen->num_shader_cache_hits);
+               break;
        case R600_QUERY_GPIN_ASIC_ID:
        case R600_QUERY_GPIN_NUM_SIMD:
        case R600_QUERY_GPIN_NUM_RB:
@@ -1641,6 +1649,7 @@ err:
 static struct pipe_driver_query_info r600_driver_query_list[] = {
        X("num-compilations",           NUM_COMPILATIONS,       UINT64, CUMULATIVE),
        X("num-shaders-created",        NUM_SHADERS_CREATED,    UINT64, CUMULATIVE),
+       X("num-shader-cache-hits",      NUM_SHADER_CACHE_HITS,  UINT64, CUMULATIVE),
        X("draw-calls",                 DRAW_CALLS,             UINT64, AVERAGE),
        X("spill-draw-calls",           SPILL_DRAW_CALLS,       UINT64, AVERAGE),
        X("compute-calls",              COMPUTE_CALLS,          UINT64, AVERAGE),
index 14c433d91d8b73f916df62300cdf73f461159f65..0e14753754c62095f5e90027bd8f6658b7bebd74 100644 (file)
@@ -68,6 +68,7 @@ enum {
        R600_QUERY_NUM_COMPILATIONS,
        R600_QUERY_NUM_SHADERS_CREATED,
        R600_QUERY_BACK_BUFFER_PS_DRAW_RATIO,
+       R600_QUERY_NUM_SHADER_CACHE_HITS,
        R600_QUERY_GPIN_ASIC_ID,
        R600_QUERY_GPIN_NUM_SIMD,
        R600_QUERY_GPIN_NUM_RB,
index e4ceb3b8150dc657aea149d43d4251ca4d4fdf1e..9976085cd015b2d4d3af89e723ea25f6499a7f5a 100644 (file)
@@ -213,7 +213,11 @@ static bool si_shader_cache_load_shader(struct si_screen *sscreen,
        if (!entry)
                return false;
 
-       return si_load_shader_binary(shader, entry->data);
+       if (!si_load_shader_binary(shader, entry->data))
+               return false;
+
+       p_atomic_inc(&sscreen->b.num_shader_cache_hits);
+       return true;
 }
 
 static uint32_t si_shader_cache_key_hash(const void *key)