[Mesa-dev] [PATCH] gallium/radeon: add driver queries for compute/dma call stats and spills

Nicolai Hähnle nhaehnle at gmail.com
Tue Jun 14 10:42:40 UTC 2016


Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

On 13.06.2016 18:18, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> also print the average count per frame
> ---
>   src/gallium/drivers/radeon/r600_pipe_common.h |  3 +++
>   src/gallium/drivers/radeon/r600_query.c       | 30 ++++++++++++++++++++++++++-
>   src/gallium/drivers/radeon/r600_query.h       |  4 ++++
>   src/gallium/drivers/radeonsi/si_compute.c     |  6 ++++++
>   src/gallium/drivers/radeonsi/si_pipe.h        |  1 +
>   src/gallium/drivers/radeonsi/si_state_draw.c  |  2 ++
>   6 files changed, 45 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
> index eb8a25a..77dfc4f 100644
> --- a/src/gallium/drivers/radeon/r600_pipe_common.h
> +++ b/src/gallium/drivers/radeon/r600_pipe_common.h
> @@ -509,6 +509,9 @@ struct r600_common_context {
>   	unsigned			max_db; /* for OQ */
>   	/* Misc stats. */
>   	unsigned			num_draw_calls;
> +	unsigned			num_spill_draw_calls;
> +	unsigned			num_compute_calls;
> +	unsigned			num_spill_compute_calls;
>   	unsigned			num_dma_calls;
>   	uint64_t			num_alloc_tex_transfer_bytes;
>
> diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c
> index e362614..f090f1c 100644
> --- a/src/gallium/drivers/radeon/r600_query.c
> +++ b/src/gallium/drivers/radeon/r600_query.c
> @@ -75,6 +75,18 @@ static boolean r600_query_sw_begin(struct r600_common_context *rctx,
>   	case R600_QUERY_DRAW_CALLS:
>   		query->begin_result = rctx->num_draw_calls;
>   		break;
> +	case R600_QUERY_SPILL_DRAW_CALLS:
> +		query->begin_result = rctx->num_spill_draw_calls;
> +		break;
> +	case R600_QUERY_COMPUTE_CALLS:
> +		query->begin_result = rctx->num_compute_calls;
> +		break;
> +	case R600_QUERY_SPILL_COMPUTE_CALLS:
> +		query->begin_result = rctx->num_spill_compute_calls;
> +		break;
> +	case R600_QUERY_DMA_CALLS:
> +		query->begin_result = rctx->num_dma_calls;
> +		break;
>   	case R600_QUERY_REQUESTED_VRAM:
>   	case R600_QUERY_REQUESTED_GTT:
>   	case R600_QUERY_VRAM_USAGE:
> @@ -127,6 +139,18 @@ static bool r600_query_sw_end(struct r600_common_context *rctx,
>   	case R600_QUERY_DRAW_CALLS:
>   		query->end_result = rctx->num_draw_calls;
>   		break;
> +	case R600_QUERY_SPILL_DRAW_CALLS:
> +		query->end_result = rctx->num_spill_draw_calls;
> +		break;
> +	case R600_QUERY_COMPUTE_CALLS:
> +		query->end_result = rctx->num_compute_calls;
> +		break;
> +	case R600_QUERY_SPILL_COMPUTE_CALLS:
> +		query->end_result = rctx->num_spill_compute_calls;
> +		break;
> +	case R600_QUERY_DMA_CALLS:
> +		query->end_result = rctx->num_dma_calls;
> +		break;
>   	case R600_QUERY_REQUESTED_VRAM:
>   	case R600_QUERY_REQUESTED_GTT:
>   	case R600_QUERY_VRAM_USAGE:
> @@ -1139,7 +1163,11 @@ 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("draw-calls",			DRAW_CALLS,		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),
> +	X("spill-compute-calls",	SPILL_COMPUTE_CALLS,	UINT64, AVERAGE),
> +	X("dma-calls",			DMA_CALLS,		UINT64, AVERAGE),
>   	X("requested-VRAM",		REQUESTED_VRAM,		BYTES, AVERAGE),
>   	X("requested-GTT",		REQUESTED_GTT,		BYTES, AVERAGE),
>   	X("buffer-wait-time",		BUFFER_WAIT_TIME,	MICROSECONDS, CUMULATIVE),
> diff --git a/src/gallium/drivers/radeon/r600_query.h b/src/gallium/drivers/radeon/r600_query.h
> index a3c9aa2..b573a17 100644
> --- a/src/gallium/drivers/radeon/r600_query.h
> +++ b/src/gallium/drivers/radeon/r600_query.h
> @@ -42,6 +42,10 @@ struct r600_resource;
>
>   enum {
>   	R600_QUERY_DRAW_CALLS = PIPE_QUERY_DRIVER_SPECIFIC,
> +	R600_QUERY_SPILL_DRAW_CALLS,
> +	R600_QUERY_COMPUTE_CALLS,
> +	R600_QUERY_SPILL_COMPUTE_CALLS,
> +	R600_QUERY_DMA_CALLS,
>   	R600_QUERY_REQUESTED_VRAM,
>   	R600_QUERY_REQUESTED_GTT,
>   	R600_QUERY_BUFFER_WAIT_TIME,
> diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c
> index 09cbe13..2f7e172 100644
> --- a/src/gallium/drivers/radeonsi/si_compute.c
> +++ b/src/gallium/drivers/radeonsi/si_compute.c
> @@ -308,6 +308,8 @@ static bool si_switch_compute_shader(struct si_context *sctx,
>
>   	sctx->cs_shader_state.emitted_program = program;
>   	sctx->cs_shader_state.offset = offset;
> +	sctx->cs_shader_state.uses_scratch =
> +		config->scratch_bytes_per_wave != 0;
>
>   	return true;
>   }
> @@ -487,6 +489,10 @@ static void si_launch_grid(
>   	si_emit_dispatch_packets(sctx, info);
>
>   	si_ce_post_draw_synchronization(sctx);
> +
> +	sctx->b.num_compute_calls++;
> +	if (sctx->cs_shader_state.uses_scratch)
> +		sctx->b.num_spill_compute_calls++;
>   }
>
>
> diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
> index d4c5514..7e68bb7 100644
> --- a/src/gallium/drivers/radeonsi/si_pipe.h
> +++ b/src/gallium/drivers/radeonsi/si_pipe.h
> @@ -136,6 +136,7 @@ struct si_cs_shader_state {
>   	struct si_compute		*emitted_program;
>   	unsigned			offset;
>   	bool				initialized;
> +	bool				uses_scratch;
>   };
>
>   struct si_textures_info {
> diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c
> index 0a85d5a..641becf 100644
> --- a/src/gallium/drivers/radeonsi/si_state_draw.c
> +++ b/src/gallium/drivers/radeonsi/si_state_draw.c
> @@ -987,6 +987,8 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
>
>   	pipe_resource_reference(&ib.buffer, NULL);
>   	sctx->b.num_draw_calls++;
> +	if (G_0286E8_WAVESIZE(sctx->spi_tmpring_size))
> +		sctx->b.num_spill_draw_calls++;
>   }
>
>   void si_trace_emit(struct si_context *sctx)
>


More information about the mesa-dev mailing list