[Mesa-dev] [PATCH 1/3] r600g: skip repeating vs, gs, and tes shader binds

Constantine Kharlamov Hi-Angel at yandex.ru
Sun Apr 9 14:18:59 UTC 2017


The idea is taken from radeonsi. The code lacks some checks for null vs,
and I'm unsure about some changes against that, so I left it in place.

Some statistics for GTAⅣ:
Average tesselation shaders bind skip per frame: ≈350
Average geometric shaders bind skip per frame: ≈260
Skip of binding vertex ones occurs rarely enough to not get into per-frame
counter at all, so I just gonna say: it happens.

Signed-off-by: Constantine Kharlamov <Hi-Angel at yandex.ru>
---
 src/gallium/drivers/r600/r600_state_common.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 4de2a7344b..dab39f19e3 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -926,12 +926,11 @@ static struct tgsi_shader_info *r600_get_vs_info(struct r600_context *rctx)
 	else
 		return NULL;
 }
-
 static void r600_bind_vs_state(struct pipe_context *ctx, void *state)
 {
 	struct r600_context *rctx = (struct r600_context *)ctx;
 
-	if (!state)
+	if (!state || rctx->vs_shader == state)
 		return;
 
 	rctx->vs_shader = (struct r600_pipe_shader_selector *)state;
@@ -943,11 +942,12 @@ static void r600_bind_gs_state(struct pipe_context *ctx, void *state)
 {
 	struct r600_context *rctx = (struct r600_context *)ctx;
 
+	if (state == rctx->gs_shader)
+		return;
+
 	rctx->gs_shader = (struct r600_pipe_shader_selector *)state;
 	r600_update_vs_writes_viewport_index(&rctx->b, r600_get_vs_info(rctx));
 
-	if (!state)
-		return;
 	rctx->b.streamout.stride_in_dw = rctx->gs_shader->so.stride;
 }
 
@@ -962,11 +962,12 @@ static void r600_bind_tes_state(struct pipe_context *ctx, void *state)
 {
 	struct r600_context *rctx = (struct r600_context *)ctx;
 
+	if (state == rctx->tes_shader)
+		return;
+
 	rctx->tes_shader = (struct r600_pipe_shader_selector *)state;
 	r600_update_vs_writes_viewport_index(&rctx->b, r600_get_vs_info(rctx));
 
-	if (!state)
-		return;
 	rctx->b.streamout.stride_in_dw = rctx->tes_shader->so.stride;
 }
 
-- 
2.12.2



More information about the mesa-dev mailing list