[Mesa-dev] [PATCH] radeonsi: Set declared tessellation LDS size to hardware size.

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Sun May 8 11:00:24 UTC 2016


The calculated limit gave problems on SI as it was > 32 KiB
and the hardware LDS size on SI is only 32 KiB. It isn't
correct anyway when processing multiple patches in a threadgroup.

As we potentially have any number of patches such that the
used LDS is at most the hardware LDS size, and exact size
per patch is not known at compile time, this seems like
the only valid bound.

Signed-off-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
---

I had this in my offchip tessellation series and it seems a bit less temporary.
Not tested on SI though.

 src/gallium/drivers/radeonsi/si_shader.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 532a77a..73e4286 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -5032,19 +5032,13 @@ static void declare_tess_lds(struct si_shader_context *ctx)
 {
 	struct gallivm_state *gallivm = &ctx->radeon_bld.gallivm;
 	LLVMTypeRef i32 = ctx->radeon_bld.soa.bld_base.uint_bld.elem_type;
-
-	/* This is the upper bound, maximum is 32 inputs times 32 vertices */
-	unsigned vertex_data_dw_size = 32*32*4;
-	unsigned patch_data_dw_size = 32*4;
-	/* The formula is: TCS inputs + TCS outputs + TCS patch outputs. */
-	unsigned patch_dw_size = vertex_data_dw_size*2 + patch_data_dw_size;
-	unsigned lds_dwords = patch_dw_size;
+	unsigned lds_size = ctx->screen->b.chip_class >= CIK ? 65536 : 32768;
 
 	/* The actual size is computed outside of the shader to reduce
 	 * the number of shader variants. */
 	ctx->lds =
 		LLVMAddGlobalInAddressSpace(gallivm->module,
-					    LLVMArrayType(i32, lds_dwords),
+					    LLVMArrayType(i32, lds_size / 4),
 					    "tess_lds",
 					    LOCAL_ADDR_SPACE);
 }
-- 
2.8.2



More information about the mesa-dev mailing list