From: Nicolai Hähnle <nicolai.haeh...@amd.com> --- src/gallium/drivers/radeonsi/si_shader.c | 15 +++++---------- src/gallium/drivers/radeonsi/si_shader_internal.h | 7 +++++++ 2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 837cc1c..39ce080 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -3400,26 +3400,21 @@ static void emit_optimization_barrier(struct si_shader_context *ctx, vgpr = LLVMBuildBitCast(builder, vgpr, LLVMVectorType(ctx->i32, vgpr_size / 4), ""); vgpr0 = LLVMBuildExtractElement(builder, vgpr, ctx->i32_0, ""); vgpr0 = LLVMBuildCall(builder, inlineasm, &vgpr0, 1, ""); vgpr = LLVMBuildInsertElement(builder, vgpr, vgpr0, ctx->i32_0, ""); vgpr = LLVMBuildBitCast(builder, vgpr, vgpr_type, ""); *pvgpr = vgpr; } } -/* Combine these with & instead of |. */ -#define NOOP_WAITCNT 0xf7f -#define LGKM_CNT 0x07f -#define VM_CNT 0xf70 - -static void emit_waitcnt(struct si_shader_context *ctx, unsigned simm16) +void si_emit_waitcnt(struct si_shader_context *ctx, unsigned simm16) { struct gallivm_state *gallivm = &ctx->gallivm; LLVMBuilderRef builder = gallivm->builder; LLVMValueRef args[1] = { LLVMConstInt(ctx->i32, simm16, 0) }; lp_build_intrinsic(builder, "llvm.amdgcn.s.waitcnt", ctx->voidt, args, 1, 0); } @@ -3438,21 +3433,21 @@ static void membar_emit( if (flags & (TGSI_MEMBAR_ATOMIC_BUFFER | TGSI_MEMBAR_SHADER_BUFFER | TGSI_MEMBAR_SHADER_IMAGE)) waitcnt &= VM_CNT; if (flags & TGSI_MEMBAR_SHARED) waitcnt &= LGKM_CNT; if (waitcnt != NOOP_WAITCNT) - emit_waitcnt(ctx, waitcnt); + si_emit_waitcnt(ctx, waitcnt); } static void clock_emit( const struct lp_build_tgsi_action *action, struct lp_build_tgsi_context *bld_base, struct lp_build_emit_data *emit_data) { struct si_shader_context *ctx = si_shader_context(bld_base); struct gallivm_state *gallivm = &ctx->gallivm; LLVMValueRef tmp; @@ -3948,21 +3943,21 @@ static void load_emit( const struct tgsi_shader_info *info = &ctx->shader->selector->info; char intrinsic_name[64]; bool readonly_memory = false; if (inst->Src[0].Register.File == TGSI_FILE_MEMORY) { load_emit_memory(ctx, emit_data); return; } if (inst->Memory.Qualifier & TGSI_MEMORY_VOLATILE) - emit_waitcnt(ctx, VM_CNT); + si_emit_waitcnt(ctx, VM_CNT); readonly_memory = !(inst->Memory.Qualifier & TGSI_MEMORY_VOLATILE) && is_oneway_access_only(inst, info, info->shader_buffers_store | info->shader_buffers_atomic, info->images_store | info->images_atomic); if (inst->Src[0].Register.File == TGSI_FILE_BUFFER) { load_emit_buffer(ctx, emit_data, readonly_memory); @@ -4165,21 +4160,21 @@ static void store_emit( unsigned target = inst->Memory.Texture; char intrinsic_name[64]; bool writeonly_memory = false; if (inst->Dst[0].Register.File == TGSI_FILE_MEMORY) { store_emit_memory(ctx, emit_data); return; } if (inst->Memory.Qualifier & TGSI_MEMORY_VOLATILE) - emit_waitcnt(ctx, VM_CNT); + si_emit_waitcnt(ctx, VM_CNT); writeonly_memory = is_oneway_access_only(inst, info, info->shader_buffers_load | info->shader_buffers_atomic, info->images_load | info->images_atomic); if (inst->Dst[0].Register.File == TGSI_FILE_BUFFER) { store_emit_buffer(ctx, emit_data, writeonly_memory); return; @@ -5682,21 +5677,21 @@ static void si_llvm_emit_barrier(const struct lp_build_tgsi_action *action, { struct si_shader_context *ctx = si_shader_context(bld_base); struct gallivm_state *gallivm = &ctx->gallivm; /* SI only (thanks to a hw bug workaround): * The real barrier instruction isn’t needed, because an entire patch * always fits into a single wave. */ if (ctx->screen->b.chip_class == SI && ctx->type == PIPE_SHADER_TESS_CTRL) { - emit_waitcnt(ctx, LGKM_CNT & VM_CNT); + si_emit_waitcnt(ctx, LGKM_CNT & VM_CNT); return; } lp_build_intrinsic(gallivm->builder, "llvm.amdgcn.s.barrier", ctx->voidt, NULL, 0, LP_FUNC_ATTR_CONVERGENT); } static const struct lp_build_tgsi_action tex_action = { .fetch_args = tex_fetch_args, diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h b/src/gallium/drivers/radeonsi/si_shader_internal.h index 35315ca..c3913de 100644 --- a/src/gallium/drivers/radeonsi/si_shader_internal.h +++ b/src/gallium/drivers/radeonsi/si_shader_internal.h @@ -280,13 +280,20 @@ LLVMValueRef si_llvm_emit_fetch_64bit(struct lp_build_tgsi_context *bld_base, LLVMValueRef si_llvm_emit_fetch(struct lp_build_tgsi_context *bld_base, const struct tgsi_full_src_register *reg, enum tgsi_opcode_type type, unsigned swizzle); void si_llvm_emit_store(struct lp_build_tgsi_context *bld_base, const struct tgsi_full_instruction *inst, const struct tgsi_opcode_info *info, LLVMValueRef dst[4]); +/* Combine these with & instead of |. */ +#define NOOP_WAITCNT 0xf7f +#define LGKM_CNT 0x07f +#define VM_CNT 0xf70 + +void si_emit_waitcnt(struct si_shader_context *ctx, unsigned simm16); + void si_shader_context_init_alu(struct lp_build_tgsi_context *bld_base); #endif -- 2.9.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev