diff options
author | Eric Anholt <[email protected]> | 2015-01-11 15:22:22 +1300 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2015-01-11 17:17:20 +1300 |
commit | 1519a1928a6009904359d2de188c65632385f401 (patch) | |
tree | c440a92efa4babefe9ce2c71c9c98c6c05d0849a /src/gallium/drivers/vc4/vc4_program.c | |
parent | 1a328120d334ae09fa6a1ce8b599174f730a9753 (diff) |
vc4: Add a little helper for clamping to [0,1].
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_program.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 2ab7da90dd7..2b546eeb433 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -315,6 +315,14 @@ get_swizzled_channel(struct vc4_compile *c, } } +static inline struct qreg +qir_SAT(struct vc4_compile *c, struct qreg val) +{ + return qir_FMAX(c, + qir_FMIN(c, val, qir_uniform_f(c, 1.0)), + qir_uniform_f(c, 0.0)); +} + static struct qreg tgsi_to_qir_alu(struct vc4_compile *c, struct tgsi_full_instruction *tgsi_inst, @@ -686,13 +694,11 @@ tgsi_to_qir_tex(struct vc4_compile *c, } if (c->key->tex[unit].wrap_s == PIPE_TEX_WRAP_CLAMP) { - s = qir_FMIN(c, qir_FMAX(c, s, qir_uniform_f(c, 0.0)), - qir_uniform_f(c, 1.0)); + s = qir_SAT(c, s); } if (c->key->tex[unit].wrap_t == PIPE_TEX_WRAP_CLAMP) { - t = qir_FMIN(c, qir_FMAX(c, t, qir_uniform_f(c, 0.0)), - qir_uniform_f(c, 1.0)); + t = qir_SAT(c, t); } qir_TEX_T(c, t, texture_u[next_texture_u++]); |