[Mesa-dev] [PATCH 3/3] r600g: get rid of dummy pixel shader

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


The idea is taken from radeonsi. The code mostly was already checking for null
pixel shader, so little checks had to be added.

Interestingly, acc. to testing with GTAⅣ, though binding of null shader happens
a lot at the start (then just stops), but draw_vbo() never actually sees null
ps.

Signed-off-by: Constantine Kharlamov <Hi-Angel at yandex.ru>
---
 src/gallium/drivers/r600/r600_pipe.c         |  9 ---------
 src/gallium/drivers/r600/r600_pipe.h         |  3 ---
 src/gallium/drivers/r600/r600_state_common.c | 17 ++++++++---------
 3 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index 5014f2525c..7d8efd2c9b 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -82,9 +82,6 @@ static void r600_destroy_context(struct pipe_context *context)
 	if (rctx->fixed_func_tcs_shader)
 		rctx->b.b.delete_tcs_state(&rctx->b.b, rctx->fixed_func_tcs_shader);
 
-	if (rctx->dummy_pixel_shader) {
-		rctx->b.b.delete_fs_state(&rctx->b.b, rctx->dummy_pixel_shader);
-	}
 	if (rctx->custom_dsa_flush) {
 		rctx->b.b.delete_depth_stencil_alpha_state(&rctx->b.b, rctx->custom_dsa_flush);
 	}
@@ -209,12 +206,6 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen,
 
 	r600_begin_new_cs(rctx);
 
-	rctx->dummy_pixel_shader =
-		util_make_fragment_cloneinput_shader(&rctx->b.b, 0,
-						     TGSI_SEMANTIC_GENERIC,
-						     TGSI_INTERPOLATE_CONSTANT);
-	rctx->b.b.bind_fs_state(&rctx->b.b, rctx->dummy_pixel_shader);
-
 	return &rctx->b.b;
 
 fail:
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index 7f1ecc278b..e636ef0024 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -432,9 +432,6 @@ struct r600_context {
 	void				*custom_blend_resolve;
 	void				*custom_blend_decompress;
 	void                            *custom_blend_fastclear;
-	/* With rasterizer discard, there doesn't have to be a pixel shader.
-	 * In that case, we bind this one: */
-	void				*dummy_pixel_shader;
 	/* These dummy CMASK and FMASK buffers are used to get around the R6xx hardware
 	 * bug where valid CMASK and FMASK are required to be present to avoid
 	 * a hardlock in certain operations but aren't actually used
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index c4b1a22d95..be7db361d1 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -725,7 +725,8 @@ static inline void r600_shader_selector_key(const struct pipe_context *ctx,
 		if (!key->vs.as_ls)
 			key->vs.as_es = (rctx->gs_shader != NULL);
 
-		if (rctx->ps_shader->current->shader.gs_prim_id_input && !rctx->gs_shader) {
+		if (rctx->ps_shader && rctx->ps_shader->current->shader.gs_prim_id_input &&
+		    !rctx->gs_shader) {
 			key->vs.as_gs_a = true;
 			key->vs.prim_id_out = rctx->ps_shader->current->shader.input[rctx->ps_shader->current->shader.ps_prim_id_input].spi_sid;
 		}
@@ -909,9 +910,6 @@ static void r600_bind_ps_state(struct pipe_context *ctx, void *state)
 {
 	struct r600_context *rctx = (struct r600_context *)ctx;
 
-	if (!state)
-		state = rctx->dummy_pixel_shader;
-
 	rctx->ps_shader = (struct r600_pipe_shader_selector *)state;
 }
 
@@ -1550,9 +1548,10 @@ static bool r600_update_derived_state(struct r600_context *rctx)
 		rctx->b.streamout.enabled_stream_buffers_mask = clip_so_current->enabled_stream_buffers_mask;
 	}
 
-	if (unlikely(ps_dirty || rctx->hw_shader_stages[R600_HW_STAGE_PS].shader != rctx->ps_shader->current ||
-		rctx->rasterizer->sprite_coord_enable != rctx->ps_shader->current->sprite_coord_enable ||
-		rctx->rasterizer->flatshade != rctx->ps_shader->current->flatshade)) {
+	if (unlikely(rctx->ps_shader &&
+		     (ps_dirty || rctx->hw_shader_stages[R600_HW_STAGE_PS].shader != rctx->ps_shader->current ||
+		      rctx->rasterizer->sprite_coord_enable != rctx->ps_shader->current->sprite_coord_enable ||
+		      rctx->rasterizer->flatshade != rctx->ps_shader->current->flatshade))) {
 
 		if (rctx->cb_misc_state.nr_ps_color_outputs != rctx->ps_shader->current->nr_ps_color_outputs) {
 			rctx->cb_misc_state.nr_ps_color_outputs = rctx->ps_shader->current->nr_ps_color_outputs;
@@ -1568,7 +1567,7 @@ static bool r600_update_derived_state(struct r600_context *rctx)
 			}
 		}
 
-		if (unlikely(!ps_dirty && rctx->ps_shader && rctx->rasterizer &&
+		if (unlikely(!ps_dirty && rctx->rasterizer &&
 				((rctx->rasterizer->sprite_coord_enable != rctx->ps_shader->current->sprite_coord_enable) ||
 						(rctx->rasterizer->flatshade != rctx->ps_shader->current->flatshade)))) {
 
@@ -1636,7 +1635,7 @@ static bool r600_update_derived_state(struct r600_context *rctx)
 		}
 	}
 
-	blend_disable = (rctx->dual_src_blend &&
+	blend_disable = (rctx->dual_src_blend && rctx->ps_shader &&
 			rctx->ps_shader->current->nr_ps_color_outputs < 2);
 
 	if (blend_disable != rctx->force_blend_disable) {
-- 
2.12.2



More information about the mesa-dev mailing list