summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2014-01-15 08:07:27 -0500
committerRob Clark <[email protected]>2014-02-01 11:49:31 -0500
commit752475619997ce1d596dd0073d0fa5785d8f2646 (patch)
tree44fe4dde8a84c46d9aff363e92b4e41b714c169f /src/gallium
parentfafe16a8a00da3f0d48aba313685f673744d8909 (diff)
freedreno/a3xx/compiler: add CLAMP
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_compiler.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c b/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c
index 98624cb971a..862a91c4c75 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_compiler.c
@@ -573,19 +573,17 @@ create_mov(struct fd3_compile_context *ctx, struct tgsi_dst_register *dst,
}
static void
-create_clamp(struct fd3_compile_context *ctx, struct tgsi_dst_register *dst,
+create_clamp(struct fd3_compile_context *ctx,
+ struct tgsi_dst_register *dst, struct tgsi_src_register *val,
struct tgsi_src_register *minval, struct tgsi_src_register *maxval)
{
struct ir3_instruction *instr;
- struct tgsi_src_register src;
-
- src_from_dst(&src, dst);
instr = ir3_instr_create(ctx->ir, 2, OPC_MAX_F);
- vectorize(ctx, instr, dst, 2, &src, 0, minval, 0);
+ vectorize(ctx, instr, dst, 2, val, 0, minval, 0);
instr = ir3_instr_create(ctx->ir, 2, OPC_MIN_F);
- vectorize(ctx, instr, dst, 2, &src, 0, maxval, 0);
+ vectorize(ctx, instr, dst, 2, val, 0, maxval, 0);
}
static void
@@ -594,11 +592,14 @@ create_clamp_imm(struct fd3_compile_context *ctx,
uint32_t minval, uint32_t maxval)
{
struct tgsi_src_register minconst, maxconst;
+ struct tgsi_src_register src;
+
+ src_from_dst(&src, dst);
get_immediate(ctx, &minconst, minval);
get_immediate(ctx, &maxconst, maxval);
- create_clamp(ctx, dst, &minconst, &maxconst);
+ create_clamp(ctx, dst, &src, &minconst, &maxconst);
}
static struct tgsi_dst_register *
@@ -926,6 +927,21 @@ trans_dotp(const struct instr_translater *t,
create_mov(ctx, dst, tmp_src);
}
+static void
+trans_clamp(const struct instr_translater *t,
+ struct fd3_compile_context *ctx,
+ struct tgsi_full_instruction *inst)
+{
+ struct tgsi_dst_register *dst = get_dst(ctx, inst);
+ struct tgsi_src_register *src0 = &inst->Src[0].Register;
+ struct tgsi_src_register *src1 = &inst->Src[1].Register;
+ struct tgsi_src_register *src2 = &inst->Src[2].Register;
+
+ create_clamp(ctx, dst, src0, src1, src2);
+
+ put_dst(ctx, inst, dst);
+}
+
/* LRP(a,b,c) = (a * b) + ((1 - a) * c) */
static void
trans_lrp(const struct instr_translater *t,
@@ -1592,6 +1608,7 @@ static const struct instr_translater translaters[TGSI_OPCODE_LAST] = {
INSTR(TRUNC, instr_cat2, .opc = OPC_TRUNC_F),
INSTR(LRP, trans_lrp),
INSTR(FRC, trans_frac),
+ INSTR(CLAMP, trans_clamp),
INSTR(FLR, instr_cat2, .opc = OPC_FLOOR_F),
INSTR(ROUND, instr_cat2, .opc = OPC_RNDNE_F),
INSTR(ARL, trans_arl),