[Mesa-dev] [PATCH 6/7] radeonsi: properly unbind shader states

Marek Olšák maraeo at gmail.com
Thu Oct 22 16:12:18 PDT 2015


From: Marek Olšák <marek.olsak at amd.com>

Any context can release a shader now, so we can't rely on unbinding
in delete_shader_selector.
---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 34 +++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 4a3a04c..478b851 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -798,10 +798,24 @@ static void si_bind_vs_shader(struct pipe_context *ctx, void *state)
 {
 	struct si_context *sctx = (struct si_context *)ctx;
 	struct si_shader_selector *sel = state;
+	struct si_shader *old = sctx->vs_shader.current;
 
 	if (sctx->vs_shader.cso == sel)
 		return;
 
+	if (old) {
+		if (old->key.vs.as_es) {
+			sctx->queued.named.es = NULL;
+			sctx->emitted.named.es = NULL;
+		} else if (old->key.vs.as_ls) {
+			sctx->queued.named.ls = NULL;
+			sctx->emitted.named.ls = NULL;
+		} else {
+			sctx->queued.named.vs = NULL;
+			sctx->emitted.named.vs = NULL;
+		}
+	}
+
 	sctx->vs_shader.cso = sel;
 	sctx->vs_shader.current = sel ? sel->first_variant : NULL;
 	si_mark_atom_dirty(sctx, &sctx->clip_regs);
@@ -817,6 +831,9 @@ static void si_bind_gs_shader(struct pipe_context *ctx, void *state)
 	if (sctx->gs_shader.cso == sel)
 		return;
 
+	sctx->queued.named.gs = NULL;
+	sctx->emitted.named.gs = NULL;
+
 	sctx->gs_shader.cso = sel;
 	sctx->gs_shader.current = sel ? sel->first_variant : NULL;
 	si_mark_atom_dirty(sctx, &sctx->clip_regs);
@@ -836,6 +853,9 @@ static void si_bind_tcs_shader(struct pipe_context *ctx, void *state)
 	if (sctx->tcs_shader.cso == sel)
 		return;
 
+	sctx->queued.named.hs = NULL;
+	sctx->emitted.named.hs = NULL;
+
 	sctx->tcs_shader.cso = sel;
 	sctx->tcs_shader.current = sel ? sel->first_variant : NULL;
 
@@ -848,10 +868,21 @@ static void si_bind_tes_shader(struct pipe_context *ctx, void *state)
 	struct si_context *sctx = (struct si_context *)ctx;
 	struct si_shader_selector *sel = state;
 	bool enable_changed = !!sctx->tes_shader.cso != !!sel;
+	struct si_shader *old = sctx->vs_shader.current;
 
 	if (sctx->tes_shader.cso == sel)
 		return;
 
+	if (old) {
+		if (old->key.tes.as_es) {
+			sctx->queued.named.es = NULL;
+			sctx->emitted.named.es = NULL;
+		} else {
+			sctx->queued.named.vs = NULL;
+			sctx->emitted.named.vs = NULL;
+		}
+	}
+
 	sctx->tes_shader.cso = sel;
 	sctx->tes_shader.current = sel ? sel->first_variant : NULL;
 	si_mark_atom_dirty(sctx, &sctx->clip_regs);
@@ -873,6 +904,9 @@ static void si_bind_ps_shader(struct pipe_context *ctx, void *state)
 	if (sctx->ps_shader.cso == sel)
 		return;
 
+	sctx->queued.named.ps = NULL;
+	sctx->emitted.named.ps = NULL;
+
 	sctx->ps_shader.cso = sel;
 	sctx->ps_shader.current = sel ? sel->first_variant : NULL;
 	si_mark_atom_dirty(sctx, &sctx->cb_target_mask);
-- 
2.1.4



More information about the mesa-dev mailing list