aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/lima/ir
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/ir
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/ir')
-rw-r--r--src/gallium/drivers/lima/ir/lima_ir.h1
-rw-r--r--src/gallium/drivers/lima/ir/lima_nir_algebraic.py7
2 files changed, 8 insertions, 0 deletions
diff --git a/src/gallium/drivers/lima/ir/lima_ir.h b/src/gallium/drivers/lima/ir/lima_ir.h
index b160dc96738..8bd72c55abe 100644
--- a/src/gallium/drivers/lima/ir/lima_ir.h
+++ b/src/gallium/drivers/lima/ir/lima_ir.h
@@ -65,6 +65,7 @@ struct ra_regs *ppir_regalloc_init(void *mem_ctx);
void lima_nir_lower_uniform_to_scalar(nir_shader *shader);
bool lima_nir_scale_trig(nir_shader *shader);
+bool lima_nir_lower_ftrunc(nir_shader *shader);
bool lima_nir_split_load_input(nir_shader *shader);
#endif
diff --git a/src/gallium/drivers/lima/ir/lima_nir_algebraic.py b/src/gallium/drivers/lima/ir/lima_nir_algebraic.py
index 86f769587aa..db0ccc75bf5 100644
--- a/src/gallium/drivers/lima/ir/lima_nir_algebraic.py
+++ b/src/gallium/drivers/lima/ir/lima_nir_algebraic.py
@@ -32,6 +32,11 @@ scale_trig = [
(('fcos', 'a'), ('fcos', ('fmul', 'a', 1.0 / (2.0 * pi)))),
]
+# GP has fsign op, so we can use cheaper lowering than one in generic opt_algebraic
+lower_ftrunc = [
+ (('ftrunc', 'a'), ('fmul', ('fsign', 'a'), ('ffloor', ('fmax', 'a', ('fneg', 'a')))))
+]
+
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--import-path', required=True)
@@ -47,6 +52,8 @@ def run():
print(nir_algebraic.AlgebraicPass("lima_nir_scale_trig",
scale_trig).render())
+ print(nir_algebraic.AlgebraicPass("lima_nir_lower_ftrunc",
+ lower_ftrunc).render())
if __name__ == '__main__':
main()