aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/lima/lima_program.c
diff options
context:
space:
mode:
authorVasily Khoruzhick <[email protected]>2020-03-10 01:30:14 -0700
committerVasily Khoruzhick <[email protected]>2020-03-16 16:28:33 -0700
commit2756b629171f61ca8e162be7b332e91a62c5c978 (patch)
tree052810b07014c013f15891064401bc0925f3ffe5 /src/gallium/drivers/lima/lima_program.c
parentb7d89476f1e7d0f3b9e751887f42b750a5ec216e (diff)
lima/gpir: add better lowering for ftrunc
GP doesn't support ftrunc natively and unfortunately one in generic opt_algebraic is not GP-friendly either. Introduce our own lowering that utilizes fsign() that GP supports: ftrunc(a) = fmul(fsign(a), ffloor(fmax(a, -a))) Tested-by: Andreas Baierl <[email protected]> Reviewed-by: Andreas Baierl <[email protected]> Signed-off-by: Vasily Khoruzhick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4126>
Diffstat (limited to 'src/gallium/drivers/lima/lima_program.c')
-rw-r--r--src/gallium/drivers/lima/lima_program.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/gallium/drivers/lima/lima_program.c b/src/gallium/drivers/lima/lima_program.c
index 6440a8826fc..33a695557a6 100644
--- a/src/gallium/drivers/lima/lima_program.c
+++ b/src/gallium/drivers/lima/lima_program.c
@@ -49,7 +49,6 @@ static const nir_shader_compiler_options vs_nir_options = {
.lower_sub = true,
.lower_flrp32 = true,
.lower_flrp64 = true,
- .lower_ftrunc = true,
/* could be implemented by clamp */
.lower_fsat = true,
.lower_bitops = true,
@@ -123,6 +122,7 @@ lima_program_optimize_vs_nir(struct nir_shader *s)
NIR_PASS(progress, s, nir_opt_cse);
NIR_PASS(progress, s, nir_opt_peephole_select, 8, true, true);
NIR_PASS(progress, s, nir_opt_algebraic);
+ NIR_PASS(progress, s, lima_nir_lower_ftrunc);
NIR_PASS(progress, s, nir_opt_constant_folding);
NIR_PASS(progress, s, nir_opt_undef);
NIR_PASS(progress, s, nir_opt_loop_unroll,
@@ -132,14 +132,8 @@ lima_program_optimize_vs_nir(struct nir_shader *s)
} while (progress);
NIR_PASS_V(s, nir_lower_int_to_float);
- /* Run opt_algebraic between int_to_float and bool_to_float because
- * int_to_float emits ftrunc, and ftrunc lowering generates bool ops
- */
- do {
- progress = false;
- NIR_PASS(progress, s, nir_opt_algebraic);
- } while (progress);
-
+ /* int_to_float pass generates ftrunc, so lower it */
+ NIR_PASS(progress, s, lima_nir_lower_ftrunc);
NIR_PASS_V(s, nir_lower_bool_to_float);
NIR_PASS_V(s, nir_copy_prop);