[Mesa-dev] [PATCH 09/11] radeonsi/gfx9: fix LS scratch buffer support without TCS for GFX9

Marek Olšák maraeo at gmail.com
Thu Jun 1 18:18:27 UTC 2017


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

LS is merged into TCS. If there is no TCS, LS is merged into fixed-func
TCS. The problem is the fixed-func TCS was ignored by scratch update
functions, so LS didn't have the scratch buffer set up.

Note that Mesa 17.1 doesn't have merged shaders.
---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 5cbb91b..631272e 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -2704,58 +2704,73 @@ static int si_update_scratch_buffer(struct si_context *sctx,
 static unsigned si_get_current_scratch_buffer_size(struct si_context *sctx)
 {
 	return sctx->scratch_buffer ? sctx->scratch_buffer->b.b.width0 : 0;
 }
 
 static unsigned si_get_scratch_buffer_bytes_per_wave(struct si_shader *shader)
 {
 	return shader ? shader->config.scratch_bytes_per_wave : 0;
 }
 
+static struct si_shader *si_get_tcs_current(struct si_context *sctx)
+{
+	if (!sctx->tes_shader.cso)
+		return NULL; /* tessellation disabled */
+
+	return sctx->tcs_shader.cso ? sctx->tcs_shader.current :
+				      sctx->fixed_func_tcs_shader.current;
+}
+
 static unsigned si_get_max_scratch_bytes_per_wave(struct si_context *sctx)
 {
 	unsigned bytes = 0;
 
 	bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->ps_shader.current));
 	bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->gs_shader.current));
 	bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->vs_shader.current));
-	bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->tcs_shader.current));
 	bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(sctx->tes_shader.current));
+
+	if (sctx->tes_shader.cso) {
+		struct si_shader *tcs = si_get_tcs_current(sctx);
+
+		bytes = MAX2(bytes, si_get_scratch_buffer_bytes_per_wave(tcs));
+	}
 	return bytes;
 }
 
 static bool si_update_scratch_relocs(struct si_context *sctx)
 {
+	struct si_shader *tcs = si_get_tcs_current(sctx);
 	int r;
 
 	/* Update the shaders, so that they are using the latest scratch.
 	 * The scratch buffer may have been changed since these shaders were
 	 * last used, so we still need to try to update them, even if they
 	 * require scratch buffers smaller than the current size.
 	 */
 	r = si_update_scratch_buffer(sctx, sctx->ps_shader.current);
 	if (r < 0)
 		return false;
 	if (r == 1)
 		si_pm4_bind_state(sctx, ps, sctx->ps_shader.current->pm4);
 
 	r = si_update_scratch_buffer(sctx, sctx->gs_shader.current);
 	if (r < 0)
 		return false;
 	if (r == 1)
 		si_pm4_bind_state(sctx, gs, sctx->gs_shader.current->pm4);
 
-	r = si_update_scratch_buffer(sctx, sctx->tcs_shader.current);
+	r = si_update_scratch_buffer(sctx, tcs);
 	if (r < 0)
 		return false;
 	if (r == 1)
-		si_pm4_bind_state(sctx, hs, sctx->tcs_shader.current->pm4);
+		si_pm4_bind_state(sctx, hs, tcs->pm4);
 
 	/* VS can be bound as LS, ES, or VS. */
 	r = si_update_scratch_buffer(sctx, sctx->vs_shader.current);
 	if (r < 0)
 		return false;
 	if (r == 1) {
 		if (sctx->tes_shader.current)
 			si_pm4_bind_state(sctx, ls, sctx->vs_shader.current->pm4);
 		else if (sctx->gs_shader.current)
 			si_pm4_bind_state(sctx, es, sctx->vs_shader.current->pm4);
-- 
2.7.4



More information about the mesa-dev mailing list