[Mesa-dev] [PATCH v2 12/12] radeonsi: add an assertion that only two-dimensional constant references are used

Nicolai Hähnle nhaehnle at gmail.com
Mon Aug 28 08:58:20 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

v2: remove some redundant checks

Acked-by: Roland Scheidegger <sroland at vmware.com> (v1)
Tested-by: Dieter Nützel <Dieter at nuetzel-hh.de> (v1)
---
 src/gallium/drivers/radeonsi/si_shader.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index f02fc9e9ba2..81b00246559 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1844,24 +1844,25 @@ static LLVMValueRef fetch_constant(
 
 	if (swizzle == LP_CHAN_ALL) {
 		unsigned chan;
 		LLVMValueRef values[4];
 		for (chan = 0; chan < TGSI_NUM_CHANNELS; ++chan)
 			values[chan] = fetch_constant(bld_base, reg, type, chan);
 
 		return lp_build_gather_values(&ctx->gallivm, values, 4);
 	}
 
-	buf = reg->Register.Dimension ? reg->Dimension.Index : 0;
+	assert(reg->Register.Dimension);
+	buf = reg->Dimension.Index;
 	idx = reg->Register.Index * 4 + swizzle;
 
-	if (reg->Register.Dimension && reg->Dimension.Indirect) {
+	if (reg->Dimension.Indirect) {
 		LLVMValueRef ptr = LLVMGetParam(ctx->main_fn, ctx->param_const_and_shader_buffers);
 		LLVMValueRef index;
 		index = si_get_bounded_indirect_index(ctx, &reg->DimIndirect,
 						      reg->Dimension.Index,
 						      ctx->num_const_buffers);
 		index = LLVMBuildAdd(ctx->gallivm.builder, index,
 				     LLVMConstInt(ctx->i32, SI_NUM_SHADER_BUFFERS, 0), "");
 		bufp = ac_build_indexed_load_const(&ctx->ac, ptr, index);
 	} else
 		bufp = load_const_buffer_desc(ctx, buf);
-- 
2.11.0



More information about the mesa-dev mailing list