summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2017-01-10 15:46:17 +0100
committerNicolai Hähnle <nicolai.haehnle@amd.com>2017-01-10 17:29:58 +0100
commit64fc65193024c12f6f740f01d02c1221f2f633c6 (patch)
tree49b043a7aa70bb5ad4d7e283356024e7703dbe59
parent5064b4e72555062d0aa2e052520c1047f5689a9e (diff)
ac/nir: use ac_emit_fdiv throughoutcubemaps
... and eliminate emit_fdiv and nir_to_llvm_context::fpmath_md_*, which are now unused.
-rw-r--r--src/amd/common/ac_nir_to_llvm.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 5fe9e8ce58..269c4bc81a 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -113,10 +113,8 @@ struct nir_to_llvm_context {
unsigned range_md_kind;
unsigned uniform_md_kind;
- unsigned fpmath_md_kind;
unsigned invariant_load_md_kind;
LLVMValueRef empty_md;
- LLVMValueRef fpmath_md_2p5_ulp;
gl_shader_stage stage;
LLVMValueRef lds;
@@ -583,10 +581,7 @@ static void setup_types(struct nir_to_llvm_context *ctx)
LLVMGetMDKindIDInContext(ctx->context, "amdgpu.uniform", 14);
ctx->empty_md = LLVMMDNodeInContext(ctx->context, NULL, 0);
- ctx->fpmath_md_kind = LLVMGetMDKindIDInContext(ctx->context, "fpmath", 6);
-
args[0] = LLVMConstReal(ctx->f32, 2.5);
- ctx->fpmath_md_2p5_ulp = LLVMMDNodeInContext(ctx->context, args, 1);
}
static int get_llvm_num_components(LLVMValueRef value)
@@ -1193,17 +1188,6 @@ static LLVMValueRef emit_ddxy_interp(
return ac_build_gather_values(&ctx->ac, result, 4);
}
-static LLVMValueRef emit_fdiv(struct nir_to_llvm_context *ctx,
- LLVMValueRef num,
- LLVMValueRef den)
-{
- LLVMValueRef ret = LLVMBuildFDiv(ctx->builder, num, den, "");
-
- if (!LLVMIsConstant(ret))
- LLVMSetMetadata(ret, ctx->fpmath_md_kind, ctx->fpmath_md_2p5_ulp);
- return ret;
-}
-
static void visit_alu(struct nir_to_llvm_context *ctx, nir_alu_instr *instr)
{
LLVMValueRef src[4], result = NULL;
@@ -1273,7 +1257,7 @@ static void visit_alu(struct nir_to_llvm_context *ctx, nir_alu_instr *instr)
case nir_op_fmod:
src[0] = to_float(ctx, src[0]);
src[1] = to_float(ctx, src[1]);
- result = emit_fdiv(ctx, src[0], src[1]);
+ result = ac_emit_fdiv(&ctx->ac, src[0], src[1]);
result = emit_intrin_1f_param(ctx, "llvm.floor.f32", result);
result = LLVMBuildFMul(ctx->builder, src[1] , result, "");
result = LLVMBuildFSub(ctx->builder, src[0], result, "");
@@ -1297,11 +1281,11 @@ static void visit_alu(struct nir_to_llvm_context *ctx, nir_alu_instr *instr)
case nir_op_fdiv:
src[0] = to_float(ctx, src[0]);
src[1] = to_float(ctx, src[1]);
- result = emit_fdiv(ctx, src[0], src[1]);
+ result = ac_emit_fdiv(&ctx->ac, src[0], src[1]);
break;
case nir_op_frcp:
src[0] = to_float(ctx, src[0]);
- result = emit_fdiv(ctx, ctx->f32one, src[0]);
+ result = ac_emit_fdiv(&ctx->ac, ctx->f32one, src[0]);
break;
case nir_op_iand:
result = LLVMBuildAnd(ctx->builder, src[0], src[1], "");
@@ -1408,7 +1392,7 @@ static void visit_alu(struct nir_to_llvm_context *ctx, nir_alu_instr *instr)
break;
case nir_op_frsq:
result = emit_intrin_1f_param(ctx, "llvm.sqrt.f32", src[0]);
- result = emit_fdiv(ctx, ctx->f32one, result);
+ result = ac_emit_fdiv(&ctx->ac, ctx->f32one, result);
break;
case nir_op_fpow:
result = emit_intrin_2f_param(ctx, "llvm.pow.f32", src[0], src[1]);
@@ -1637,7 +1621,7 @@ static LLVMValueRef radv_lower_gather4_integer(struct nir_to_llvm_context *ctx,
half_texel[c] = LLVMBuildExtractElement(ctx->builder, size,
LLVMConstInt(ctx->i32, c, false), "");
half_texel[c] = LLVMBuildUIToFP(ctx->builder, half_texel[c], ctx->f32, "");
- half_texel[c] = emit_fdiv(ctx, ctx->f32one, half_texel[c]);
+ half_texel[c] = ac_emit_fdiv(&ctx->ac, ctx->f32one, half_texel[c]);
half_texel[c] = LLVMBuildFMul(ctx->builder, half_texel[c],
LLVMConstReal(ctx->f32, -0.5), "");
}
@@ -3822,7 +3806,7 @@ handle_fs_inputs_pre(struct nir_to_llvm_context *ctx,
for(int i = 0; i < 3; ++i)
inputs[i] = ctx->frag_pos[i];
- inputs[3] = emit_fdiv(ctx, ctx->f32one, ctx->frag_pos[3]);
+ inputs[3] = ac_emit_fdiv(&ctx->ac, ctx->f32one, ctx->frag_pos[3]);
}
}
ctx->shader_info->fs.num_interp = index;