diff options
author | Christian König <[email protected]> | 2013-02-28 14:50:07 +0100 |
---|---|---|
committer | Christian König <[email protected]> | 2013-03-19 15:16:18 +0100 |
commit | f5298b0a65bbbd9a0eba703dd39b121a74dc200c (patch) | |
tree | da90b3bd9d9a6991539e030101e64e815bee3450 /src/gallium/drivers/radeonsi/radeonsi_shader.c | |
parent | c05483fc00a0630aba86ad9de68d949bbb68f8c9 (diff) |
radeonsi: switch to using resource destribtors for constants v2
v2: remove superfluous mask, use buffer_size instead of constant
Signed-off-by: Christian König <[email protected]>
Reviewed-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi/radeonsi_shader.c')
-rw-r--r-- | src/gallium/drivers/radeonsi/radeonsi_shader.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c index 95ccd1ef17e..c40795349c7 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_shader.c +++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c @@ -354,11 +354,10 @@ static LLVMValueRef fetch_constant( { struct si_shader_context *si_shader_ctx = si_shader_context(bld_base); struct lp_build_context * base = &bld_base->base; - unsigned idx; - LLVMValueRef const_ptr; - LLVMValueRef offset; - LLVMValueRef load; + LLVMValueRef ptr; + LLVMValueRef args[2]; + LLVMValueRef result; if (swizzle == LP_CHAN_ALL) { unsigned chan; @@ -369,23 +368,22 @@ static LLVMValueRef fetch_constant( return lp_build_gather_values(bld_base->base.gallivm, values, 4); } + /* Load the resource descriptor */ + ptr = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn, SI_PARAM_CONST); + args[0] = build_indexed_load(base->gallivm, ptr, bld_base->uint_bld.zero); + /* currently not supported */ if (reg->Register.Indirect) { assert(0); - load = lp_build_const_int32(base->gallivm, 0); - return bitcast(bld_base, type, load); - } - - const_ptr = LLVMGetParam(si_shader_ctx->radeon_bld.main_fn, SI_PARAM_CONST); + result = lp_build_const_int32(base->gallivm, 0); + return bitcast(bld_base, type, result); + } else + args[1] = lp_build_const_int32(base->gallivm, (reg->Register.Index * 4 + swizzle) * 4); - /* XXX: This assumes that the constant buffer is not packed, so - * CONST[0].x will have an offset of 0 and CONST[1].x will have an - * offset of 4. */ - idx = (reg->Register.Index * 4) + swizzle; - offset = lp_build_const_int32(base->gallivm, idx); + result = build_intrinsic(base->gallivm->builder, "llvm.SI.load.const", base->elem_type, + args, 2, LLVMReadOnlyAttribute | LLVMNoUnwindAttribute); - load = build_indexed_load(base->gallivm, const_ptr, offset); - return bitcast(bld_base, type, load); + return bitcast(bld_base, type, result); } /* Initialize arguments for the shader export intrinsic */ @@ -931,8 +929,8 @@ static void create_function(struct si_shader_context *si_shader_ctx) v2i32 = LLVMVectorType(i32, 2); v3i32 = LLVMVectorType(i32, 3); - params[SI_PARAM_CONST] = LLVMPointerType(f32, CONST_ADDR_SPACE); - params[SI_PARAM_SAMPLER] = LLVMPointerType(LLVMVectorType(i8, 16), CONST_ADDR_SPACE); + params[SI_PARAM_CONST] = LLVMPointerType(LLVMVectorType(i8, 16), CONST_ADDR_SPACE); + params[SI_PARAM_SAMPLER] = params[SI_PARAM_CONST]; params[SI_PARAM_RESOURCE] = LLVMPointerType(LLVMVectorType(i8, 32), CONST_ADDR_SPACE); if (si_shader_ctx->type == TGSI_PROCESSOR_VERTEX) { |