mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 10:08:08 +02:00
radeon/ac: use ds_swizzle for derivs on si/cik.
This looks like it's supported since llvm 3.9 at least,
so switch over radeonsi and radv to using it, -pro also
uses this. We can now drop creating lds for these operations
as the ds_swizzle operation doesn't actually write to lds at all.
Acked-by: Marek Olšák <marek.olsak@amd.com>
(stable requested due to fixing radv CIK conformance tests)
Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit cb6f16dce9)
[Emil Velikov: resolve trivial conflicts]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Conflicts:
src/amd/common/ac_nir_to_llvm.c
This commit is contained in:
parent
2dd6030fbb
commit
381ccaa1cb
4 changed files with 46 additions and 39 deletions
|
|
@ -795,21 +795,21 @@ ac_build_ddxy(struct ac_llvm_context *ctx,
|
|||
bool has_ds_bpermute,
|
||||
uint32_t mask,
|
||||
int idx,
|
||||
LLVMValueRef lds,
|
||||
LLVMValueRef val)
|
||||
{
|
||||
LLVMValueRef thread_id, tl, trbl, tl_tid, trbl_tid, args[2];
|
||||
LLVMValueRef tl, trbl, args[2];
|
||||
LLVMValueRef result;
|
||||
|
||||
thread_id = ac_get_thread_id(ctx);
|
||||
|
||||
tl_tid = LLVMBuildAnd(ctx->builder, thread_id,
|
||||
LLVMConstInt(ctx->i32, mask, false), "");
|
||||
|
||||
trbl_tid = LLVMBuildAdd(ctx->builder, tl_tid,
|
||||
LLVMConstInt(ctx->i32, idx, false), "");
|
||||
|
||||
if (has_ds_bpermute) {
|
||||
LLVMValueRef thread_id, tl_tid, trbl_tid;
|
||||
thread_id = ac_get_thread_id(ctx);
|
||||
|
||||
tl_tid = LLVMBuildAnd(ctx->builder, thread_id,
|
||||
LLVMConstInt(ctx->i32, mask, false), "");
|
||||
|
||||
trbl_tid = LLVMBuildAdd(ctx->builder, tl_tid,
|
||||
LLVMConstInt(ctx->i32, idx, false), "");
|
||||
|
||||
args[0] = LLVMBuildMul(ctx->builder, tl_tid,
|
||||
LLVMConstInt(ctx->i32, 4, false), "");
|
||||
args[1] = val;
|
||||
|
|
@ -827,15 +827,42 @@ ac_build_ddxy(struct ac_llvm_context *ctx,
|
|||
AC_FUNC_ATTR_READNONE |
|
||||
AC_FUNC_ATTR_CONVERGENT);
|
||||
} else {
|
||||
LLVMValueRef store_ptr, load_ptr0, load_ptr1;
|
||||
uint32_t masks[2];
|
||||
|
||||
store_ptr = ac_build_gep0(ctx, lds, thread_id);
|
||||
load_ptr0 = ac_build_gep0(ctx, lds, tl_tid);
|
||||
load_ptr1 = ac_build_gep0(ctx, lds, trbl_tid);
|
||||
switch (mask) {
|
||||
case AC_TID_MASK_TOP_LEFT:
|
||||
masks[0] = 0x8000;
|
||||
if (idx == 1)
|
||||
masks[1] = 0x8055;
|
||||
else
|
||||
masks[1] = 0x80aa;
|
||||
|
||||
LLVMBuildStore(ctx->builder, val, store_ptr);
|
||||
tl = LLVMBuildLoad(ctx->builder, load_ptr0, "");
|
||||
trbl = LLVMBuildLoad(ctx->builder, load_ptr1, "");
|
||||
break;
|
||||
case AC_TID_MASK_TOP:
|
||||
masks[0] = 0x8044;
|
||||
masks[1] = 0x80ee;
|
||||
break;
|
||||
case AC_TID_MASK_LEFT:
|
||||
masks[0] = 0x80a0;
|
||||
masks[1] = 0x80f5;
|
||||
break;
|
||||
}
|
||||
|
||||
args[0] = val;
|
||||
args[1] = LLVMConstInt(ctx->i32, masks[0], false);
|
||||
|
||||
tl = ac_build_intrinsic(ctx,
|
||||
"llvm.amdgcn.ds.swizzle", ctx->i32,
|
||||
args, 2,
|
||||
AC_FUNC_ATTR_READNONE |
|
||||
AC_FUNC_ATTR_CONVERGENT);
|
||||
|
||||
args[1] = LLVMConstInt(ctx->i32, masks[1], false);
|
||||
trbl = ac_build_intrinsic(ctx,
|
||||
"llvm.amdgcn.ds.swizzle", ctx->i32,
|
||||
args, 2,
|
||||
AC_FUNC_ATTR_READNONE |
|
||||
AC_FUNC_ATTR_CONVERGENT);
|
||||
}
|
||||
|
||||
tl = LLVMBuildBitCast(ctx->builder, tl, ctx->f32, "");
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ ac_build_ddxy(struct ac_llvm_context *ctx,
|
|||
bool has_ds_bpermute,
|
||||
uint32_t mask,
|
||||
int idx,
|
||||
LLVMValueRef lds,
|
||||
LLVMValueRef val);
|
||||
|
||||
#define AC_SENDMSG_GS 2
|
||||
|
|
|
|||
|
|
@ -1453,11 +1453,6 @@ static LLVMValueRef emit_ddxy(struct nir_to_llvm_context *ctx,
|
|||
int idx;
|
||||
LLVMValueRef result;
|
||||
|
||||
if (!ctx->lds && !ctx->has_ds_bpermute)
|
||||
ctx->lds = LLVMAddGlobalInAddressSpace(ctx->module,
|
||||
LLVMArrayType(ctx->i32, 64),
|
||||
"ddxy_lds", LOCAL_ADDR_SPACE);
|
||||
|
||||
if (op == nir_op_fddx_fine || op == nir_op_fddx)
|
||||
mask = AC_TID_MASK_LEFT;
|
||||
else if (op == nir_op_fddy_fine || op == nir_op_fddy)
|
||||
|
|
@ -1474,7 +1469,7 @@ static LLVMValueRef emit_ddxy(struct nir_to_llvm_context *ctx,
|
|||
idx = 2;
|
||||
|
||||
result = ac_build_ddxy(&ctx->ac, ctx->has_ds_bpermute,
|
||||
mask, idx, ctx->lds,
|
||||
mask, idx,
|
||||
src0);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3471,7 +3471,7 @@ static void si_llvm_emit_ddxy(
|
|||
|
||||
val = LLVMBuildBitCast(gallivm->builder, emit_data->args[0], ctx->i32, "");
|
||||
val = ac_build_ddxy(&ctx->ac, ctx->screen->has_ds_bpermute,
|
||||
mask, idx, ctx->lds, val);
|
||||
mask, idx, val);
|
||||
emit_data->output[emit_data->chan] = val;
|
||||
}
|
||||
|
||||
|
|
@ -4510,20 +4510,6 @@ static void create_function(struct si_shader_context *ctx)
|
|||
assert(shader->info.num_input_vgprs >= num_prolog_vgprs);
|
||||
shader->info.num_input_vgprs -= num_prolog_vgprs;
|
||||
|
||||
if (!ctx->screen->has_ds_bpermute &&
|
||||
bld_base->info &&
|
||||
(bld_base->info->opcode_count[TGSI_OPCODE_DDX] > 0 ||
|
||||
bld_base->info->opcode_count[TGSI_OPCODE_DDY] > 0 ||
|
||||
bld_base->info->opcode_count[TGSI_OPCODE_DDX_FINE] > 0 ||
|
||||
bld_base->info->opcode_count[TGSI_OPCODE_DDY_FINE] > 0 ||
|
||||
bld_base->info->opcode_count[TGSI_OPCODE_INTERP_OFFSET] > 0 ||
|
||||
bld_base->info->opcode_count[TGSI_OPCODE_INTERP_SAMPLE] > 0))
|
||||
ctx->lds =
|
||||
LLVMAddGlobalInAddressSpace(gallivm->module,
|
||||
LLVMArrayType(ctx->i32, 64),
|
||||
"ddxy_lds",
|
||||
LOCAL_ADDR_SPACE);
|
||||
|
||||
if (shader->key.as_ls ||
|
||||
ctx->type == PIPE_SHADER_TESS_CTRL ||
|
||||
/* GFX9 has the ESGS ring buffer in LDS. */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue