radeonsi: add a HUD query showing the number of compiler invocations
authorMarek Olšák <marek.olsak@amd.com>
Sun, 2 Aug 2015 14:57:39 +0000 (16:57 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 6 Aug 2015 18:44:37 +0000 (20:44 +0200)
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/r600_query.c
src/gallium/drivers/radeonsi/si_state_shaders.c

index 571adaa7f4540554412775f78d6bb80e4b5aad54..66cb4ed961cb75480fb6d823e54b28a80e4fc65d 100644 (file)
@@ -689,6 +689,8 @@ static int r600_get_driver_query_info(struct pipe_screen *screen,
 {
        struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
        struct pipe_driver_query_info list[] = {
+               {"num-compilations", R600_QUERY_NUM_COMPILATIONS, {0}, PIPE_DRIVER_QUERY_TYPE_UINT64,
+                PIPE_DRIVER_QUERY_RESULT_TYPE_CUMULATIVE},
                {"draw-calls", R600_QUERY_DRAW_CALLS, {0}},
                {"requested-VRAM", R600_QUERY_REQUESTED_VRAM, {rscreen->info.vram_size}, PIPE_DRIVER_QUERY_TYPE_BYTES},
                {"requested-GTT", R600_QUERY_REQUESTED_GTT, {rscreen->info.gart_size}, PIPE_DRIVER_QUERY_TYPE_BYTES},
@@ -709,7 +711,7 @@ static int r600_get_driver_query_info(struct pipe_screen *screen,
        if (rscreen->info.drm_major == 2 && rscreen->info.drm_minor >= 42)
                num_queries = Elements(list);
        else
-               num_queries = 8;
+               num_queries = 9;
 
        if (!info)
                return num_queries;
index fbd2a21da177b726f75c4e8092b7edde1995f78a..1a15cb92600cbf8f351c01a8214dedaa9912c8aa 100644 (file)
@@ -59,6 +59,7 @@
 #define R600_QUERY_CURRENT_GPU_SCLK    (PIPE_QUERY_DRIVER_SPECIFIC + 9)
 #define R600_QUERY_CURRENT_GPU_MCLK    (PIPE_QUERY_DRIVER_SPECIFIC + 10)
 #define R600_QUERY_GPU_LOAD            (PIPE_QUERY_DRIVER_SPECIFIC + 11)
+#define R600_QUERY_NUM_COMPILATIONS    (PIPE_QUERY_DRIVER_SPECIFIC + 12)
 
 #define R600_CONTEXT_STREAMOUT_FLUSH           (1u << 0)
 #define R600_CONTEXT_PRIVATE_FLAG              (1u << 1)
@@ -288,6 +289,11 @@ struct r600_common_screen {
        uint32_t                        *trace_ptr;
        unsigned                        cs_count;
 
+       /* This must be in the screen, because UE4 uses one context for
+        * compilation and another one for rendering.
+        */
+       unsigned                        num_compilations;
+
        /* GPU load thread. */
        pipe_mutex                      gpu_load_mutex;
        pipe_thread                     gpu_load_thread;
index 11f838f38a7e7df9ebc7d30d8d0a55eda236145a..5f64ec660c607d2c7765b28bb902de52ed9f4378 100644 (file)
@@ -92,6 +92,7 @@ static struct r600_resource *r600_new_query_buffer(struct r600_common_context *c
        case R600_QUERY_CURRENT_GPU_SCLK:
        case R600_QUERY_CURRENT_GPU_MCLK:
        case R600_QUERY_GPU_LOAD:
+       case R600_QUERY_NUM_COMPILATIONS:
                return NULL;
        }
 
@@ -408,6 +409,7 @@ static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned q
        case R600_QUERY_CURRENT_GPU_SCLK:
        case R600_QUERY_CURRENT_GPU_MCLK:
        case R600_QUERY_GPU_LOAD:
+       case R600_QUERY_NUM_COMPILATIONS:
                skip_allocation = true;
                break;
        default:
@@ -483,6 +485,9 @@ static boolean r600_begin_query(struct pipe_context *ctx,
        case R600_QUERY_GPU_LOAD:
                rquery->begin_result = r600_gpu_load_begin(rctx->screen);
                return true;
+       case R600_QUERY_NUM_COMPILATIONS:
+               rquery->begin_result = p_atomic_read(&rctx->screen->num_compilations);
+               return true;
        }
 
        /* Discard the old query buffers. */
@@ -560,6 +565,9 @@ static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query)
        case R600_QUERY_GPU_LOAD:
                rquery->end_result = r600_gpu_load_end(rctx->screen, rquery->begin_result);
                return;
+       case R600_QUERY_NUM_COMPILATIONS:
+               rquery->end_result = p_atomic_read(&rctx->screen->num_compilations);
+               return;
        }
 
        r600_emit_query_end(rctx, rquery);
@@ -619,6 +627,7 @@ static boolean r600_get_query_buffer_result(struct r600_common_context *ctx,
        case R600_QUERY_GPU_TEMPERATURE:
        case R600_QUERY_CURRENT_GPU_SCLK:
        case R600_QUERY_CURRENT_GPU_MCLK:
+       case R600_QUERY_NUM_COMPILATIONS:
                result->u64 = query->end_result - query->begin_result;
                return TRUE;
        case R600_QUERY_GPU_LOAD:
index 1a6854e069db44694cd8bf5107ef41a7b14be584..f2c8d6c898fbd47393c6e752791ab44d3b9b23c8 100644 (file)
@@ -635,6 +635,7 @@ static int si_shader_select(struct pipe_context *ctx,
                }
                si_shader_init_pm4_state(shader);
                sel->num_shaders++;
+               p_atomic_inc(&sctx->screen->b.num_compilations);
        }
 
        return 0;