From: Nicolai Hähnle <nicolai.haeh...@amd.com> --- src/amd/common/ac_nir_to_llvm.c | 3 +++ src/amd/common/ac_shader_abi.h | 2 ++ src/gallium/drivers/radeonsi/si_shader.c | 14 ++++++++++++++ 3 files changed, 19 insertions(+)
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index d4b52b4..9e7f51a 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -2392,20 +2392,23 @@ static LLVMValueRef visit_load_buffer(struct nir_to_llvm_context *ctx, } static LLVMValueRef visit_load_ubo_buffer(struct ac_nir_context *ctx, const nir_intrinsic_instr *instr) { LLVMValueRef results[8], ret; LLVMValueRef rsrc = get_src(ctx, instr->src[0]); LLVMValueRef offset = get_src(ctx, instr->src[1]); int num_components = instr->num_components; + if (ctx->abi->load_ubo) + rsrc = ctx->abi->load_ubo(ctx->abi, rsrc); + rsrc = LLVMBuildBitCast(ctx->ac.builder, rsrc, LLVMVectorType(ctx->ac.i8, 16), ""); if (instr->dest.ssa.bit_size == 64) num_components *= 2; for (unsigned i = 0; i < num_components; ++i) { LLVMValueRef params[] = { rsrc, LLVMBuildAdd(ctx->ac.builder, LLVMConstInt(ctx->ac.i32, 4 * i, 0), offset, "") diff --git a/src/amd/common/ac_shader_abi.h b/src/amd/common/ac_shader_abi.h index 0d91dd2..30dc5d4 100644 --- a/src/amd/common/ac_shader_abi.h +++ b/src/amd/common/ac_shader_abi.h @@ -37,13 +37,15 @@ struct ac_shader_abi { /* For VS and PS: pre-loaded shader inputs. * * Currently only used for NIR shaders; indexed by variables' * driver_location. */ LLVMValueRef *inputs; void (*emit_outputs)(struct ac_shader_abi *abi, unsigned max_outputs, LLVMValueRef *addrs); + + LLVMValueRef (*load_ubo)(struct ac_shader_abi *abi, LLVMValueRef index); }; #endif /* AC_SHADER_ABI_H */ diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index c3ea666..e97e0ee 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -1720,20 +1720,32 @@ static void declare_compute_memory(struct si_shader_context *ctx, static LLVMValueRef load_const_buffer_desc(struct si_shader_context *ctx, int i) { LLVMValueRef list_ptr = LLVMGetParam(ctx->main_fn, ctx->param_const_and_shader_buffers); return ac_build_indexed_load_const(&ctx->ac, list_ptr, LLVMConstInt(ctx->i32, si_get_constbuf_slot(i), 0)); } +static LLVMValueRef load_ubo(struct ac_shader_abi *abi, LLVMValueRef index) +{ + struct si_shader_context *ctx = si_shader_context_from_abi(abi); + LLVMValueRef ptr = LLVMGetParam(ctx->main_fn, ctx->param_const_and_shader_buffers); + + index = si_llvm_bound_index(ctx, index, ctx->num_const_buffers); + index = LLVMBuildAdd(ctx->gallivm.builder, index, + LLVMConstInt(ctx->i32, SI_NUM_SHADER_BUFFERS, 0), ""); + + return ac_build_indexed_load_const(&ctx->ac, ptr, index); +} + static LLVMValueRef fetch_constant( struct lp_build_tgsi_context *bld_base, const struct tgsi_full_src_register *reg, enum tgsi_opcode_type type, unsigned swizzle) { struct si_shader_context *ctx = si_shader_context(bld_base); struct lp_build_context *base = &bld_base->base; const struct tgsi_ind_register *ireg = ®->Indirect; unsigned buf, idx; @@ -5539,20 +5551,22 @@ static bool si_compile_tgsi_main(struct si_shader_context *ctx, bld_base->emit_epilogue = si_llvm_return_fs_outputs; break; case PIPE_SHADER_COMPUTE: ctx->declare_memory_region = declare_compute_memory; break; default: assert(!"Unsupported shader type"); return false; } + ctx->abi.load_ubo = load_ubo; + create_function(ctx); preload_ring_buffers(ctx); /* For GFX9 merged shaders: * - Set EXEC. If the prolog is present, set EXEC there instead. * - Add a barrier before the second shader. * * The same thing for monolithic shaders is done in * si_build_wrapper_function. */ -- 2.9.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev