radeonsi: stop using TGSI_OPCODE_CLAMP by moving it amd/common
Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
@@ -814,3 +814,17 @@ ac_emit_umsb(struct ac_llvm_context *ctx,
|
|||||||
LLVMConstInt(ctx->i32, 0, 0), ""),
|
LLVMConstInt(ctx->i32, 0, 0), ""),
|
||||||
LLVMConstInt(ctx->i32, -1, true), msb, "");
|
LLVMConstInt(ctx->i32, -1, true), msb, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LLVMValueRef ac_emit_clamp(struct ac_llvm_context *ctx, LLVMValueRef value)
|
||||||
|
{
|
||||||
|
const char *intr = HAVE_LLVM >= 0x0308 ? "llvm.AMDGPU.clamp." :
|
||||||
|
"llvm.AMDIL.clamp.";
|
||||||
|
LLVMValueRef args[3] = {
|
||||||
|
value,
|
||||||
|
LLVMConstReal(ctx->f32, 0),
|
||||||
|
LLVMConstReal(ctx->f32, 1),
|
||||||
|
};
|
||||||
|
|
||||||
|
return ac_emit_llvm_intrinsic(ctx, intr, ctx->f32, args, 3,
|
||||||
|
AC_FUNC_ATTR_READNONE);
|
||||||
|
}
|
||||||
|
@@ -190,6 +190,8 @@ LLVMValueRef ac_emit_umsb(struct ac_llvm_context *ctx,
|
|||||||
LLVMValueRef arg,
|
LLVMValueRef arg,
|
||||||
LLVMTypeRef dst_type);
|
LLVMTypeRef dst_type);
|
||||||
|
|
||||||
|
LLVMValueRef ac_emit_clamp(struct ac_llvm_context *ctx, LLVMValueRef value);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1018,7 +1018,7 @@ static void store_output_tcs(struct lp_build_tgsi_context *bld_base,
|
|||||||
LLVMValueRef value = dst[chan_index];
|
LLVMValueRef value = dst[chan_index];
|
||||||
|
|
||||||
if (inst->Instruction.Saturate)
|
if (inst->Instruction.Saturate)
|
||||||
value = si_llvm_saturate(bld_base, value);
|
value = ac_emit_clamp(&ctx->ac, value);
|
||||||
|
|
||||||
lds_store(bld_base, chan_index, dw_addr, value);
|
lds_store(bld_base, chan_index, dw_addr, value);
|
||||||
|
|
||||||
@@ -1810,7 +1810,7 @@ static void si_llvm_init_export_args(struct lp_build_tgsi_context *bld_base,
|
|||||||
|
|
||||||
case V_028714_SPI_SHADER_UNORM16_ABGR:
|
case V_028714_SPI_SHADER_UNORM16_ABGR:
|
||||||
for (chan = 0; chan < 4; chan++) {
|
for (chan = 0; chan < 4; chan++) {
|
||||||
val[chan] = si_llvm_saturate(bld_base, values[chan]);
|
val[chan] = ac_emit_clamp(&ctx->ac, values[chan]);
|
||||||
val[chan] = LLVMBuildFMul(builder, val[chan],
|
val[chan] = LLVMBuildFMul(builder, val[chan],
|
||||||
lp_build_const_float(gallivm, 65535), "");
|
lp_build_const_float(gallivm, 65535), "");
|
||||||
val[chan] = LLVMBuildFAdd(builder, val[chan],
|
val[chan] = LLVMBuildFAdd(builder, val[chan],
|
||||||
@@ -2688,7 +2688,7 @@ static void si_llvm_emit_vs_epilogue(struct lp_build_tgsi_context *bld_base)
|
|||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
addr = ctx->outputs[i][j];
|
addr = ctx->outputs[i][j];
|
||||||
val = LLVMBuildLoad(gallivm->builder, addr, "");
|
val = LLVMBuildLoad(gallivm->builder, addr, "");
|
||||||
val = si_llvm_saturate(bld_base, val);
|
val = ac_emit_clamp(&ctx->ac, val);
|
||||||
LLVMBuildStore(gallivm->builder, val, addr);
|
LLVMBuildStore(gallivm->builder, val, addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2834,7 +2834,7 @@ static void si_export_mrt_color(struct lp_build_tgsi_context *bld_base,
|
|||||||
/* Clamp color */
|
/* Clamp color */
|
||||||
if (ctx->shader->key.part.ps.epilog.clamp_color)
|
if (ctx->shader->key.part.ps.epilog.clamp_color)
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
color[i] = si_llvm_saturate(bld_base, color[i]);
|
color[i] = ac_emit_clamp(&ctx->ac, color[i]);
|
||||||
|
|
||||||
/* Alpha to one */
|
/* Alpha to one */
|
||||||
if (ctx->shader->key.part.ps.epilog.alpha_to_one)
|
if (ctx->shader->key.part.ps.epilog.alpha_to_one)
|
||||||
@@ -4357,7 +4357,7 @@ static void tex_fetch_args(
|
|||||||
* Z32_FLOAT, but we don't know that here.
|
* Z32_FLOAT, but we don't know that here.
|
||||||
*/
|
*/
|
||||||
if (ctx->screen->b.chip_class == VI)
|
if (ctx->screen->b.chip_class == VI)
|
||||||
z = si_llvm_saturate(bld_base, z);
|
z = ac_emit_clamp(&ctx->ac, z);
|
||||||
|
|
||||||
address[count++] = z;
|
address[count++] = z;
|
||||||
}
|
}
|
||||||
|
@@ -202,9 +202,6 @@ LLVMValueRef si_llvm_emit_fetch_64bit(struct lp_build_tgsi_context *bld_base,
|
|||||||
LLVMValueRef ptr,
|
LLVMValueRef ptr,
|
||||||
LLVMValueRef ptr2);
|
LLVMValueRef ptr2);
|
||||||
|
|
||||||
LLVMValueRef si_llvm_saturate(struct lp_build_tgsi_context *bld_base,
|
|
||||||
LLVMValueRef value);
|
|
||||||
|
|
||||||
LLVMValueRef si_llvm_emit_fetch(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,
|
const struct tgsi_full_src_register *reg,
|
||||||
enum tgsi_opcode_type type,
|
enum tgsi_opcode_type type,
|
||||||
|
@@ -952,21 +952,6 @@ static void emit_declaration(struct lp_build_tgsi_context *bld_base,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef si_llvm_saturate(struct lp_build_tgsi_context *bld_base,
|
|
||||||
LLVMValueRef value)
|
|
||||||
{
|
|
||||||
struct lp_build_emit_data clamp_emit_data;
|
|
||||||
|
|
||||||
memset(&clamp_emit_data, 0, sizeof(clamp_emit_data));
|
|
||||||
clamp_emit_data.arg_count = 3;
|
|
||||||
clamp_emit_data.args[0] = value;
|
|
||||||
clamp_emit_data.args[2] = bld_base->base.one;
|
|
||||||
clamp_emit_data.args[1] = bld_base->base.zero;
|
|
||||||
|
|
||||||
return lp_build_emit_llvm(bld_base, TGSI_OPCODE_CLAMP,
|
|
||||||
&clamp_emit_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void si_llvm_emit_store(struct lp_build_tgsi_context *bld_base,
|
void si_llvm_emit_store(struct lp_build_tgsi_context *bld_base,
|
||||||
const struct tgsi_full_instruction *inst,
|
const struct tgsi_full_instruction *inst,
|
||||||
const struct tgsi_opcode_info *info,
|
const struct tgsi_opcode_info *info,
|
||||||
@@ -1003,7 +988,7 @@ void si_llvm_emit_store(struct lp_build_tgsi_context *bld_base,
|
|||||||
if (tgsi_type_is_64bit(dtype) && (chan_index == 1 || chan_index == 3))
|
if (tgsi_type_is_64bit(dtype) && (chan_index == 1 || chan_index == 3))
|
||||||
continue;
|
continue;
|
||||||
if (inst->Instruction.Saturate)
|
if (inst->Instruction.Saturate)
|
||||||
value = si_llvm_saturate(bld_base, value);
|
value = ac_emit_clamp(&ctx->ac, value);
|
||||||
|
|
||||||
if (reg->Register.File == TGSI_FILE_ADDRESS) {
|
if (reg->Register.File == TGSI_FILE_ADDRESS) {
|
||||||
temp_ptr = ctx->addrs[reg->Register.Index][chan_index];
|
temp_ptr = ctx->addrs[reg->Register.Index][chan_index];
|
||||||
|
Reference in New Issue
Block a user