From dfe432d829257dd01070ae1dcd4b663a0e96641f Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Fri, 17 Sep 2021 15:37:49 +0200 Subject: [PATCH] ir3: Make trig replacement expression exact This prevents other optimizations from associating the inner multiply, which can add inaccuracies that can lead to discontinuities around the boundary of the ffract. We should use exactly the sequence that the blob uses to avoid problems. Since fadd + fmul cannot be combined to ffma when exact is specified, we have to use ffma ourselves. Fixes artifacts in PixMark Volplosion with !7458. Part-of: --- src/freedreno/ci/traces-freedreno.yml | 8 ++++---- src/freedreno/ir3/ir3_nir_trig.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/freedreno/ci/traces-freedreno.yml b/src/freedreno/ci/traces-freedreno.yml index 0f1f5eadc84..49a39a515e6 100644 --- a/src/freedreno/ci/traces-freedreno.yml +++ b/src/freedreno/ci/traces-freedreno.yml @@ -413,14 +413,14 @@ traces: # - device: freedreno-a306 # checksum: 751e0e784ba2f003cfc456fe8699f1fa - device: freedreno-a530 - checksum: a8580a2a85f37600c15fb897cd874432 + checksum: ba53d1ffbe911171546a93259fb2e57c - device: freedreno-a630 - checksum: 66d7cfb1aedfe40048fe2cdf8032071c + checksum: 313ef615f0f5a11eeaf95a2a87769a32 # Note: Requires GL3.3 - path: gputest/gimark.trace expectations: - device: freedreno-a630 - checksum: 286cab0d6d6562d5dcc969d778cfa666 + checksum: e58167bd8eeb8952facbc00ff0449135 - path: gputest/pixmark-julia-fp32.trace expectations: - device: freedreno-a630 @@ -459,7 +459,7 @@ traces: - path: gputest/tessmark.trace expectations: - device: freedreno-a630 - checksum: 93d7cb8c775a7b60c499695045edc07f + checksum: af356a98c4d55fb10613a11fbe687adb - path: gputest/triangle.trace expectations: - device: freedreno-a306 diff --git a/src/freedreno/ir3/ir3_nir_trig.py b/src/freedreno/ir3/ir3_nir_trig.py index 6a88420e1e5..657dbb25ea4 100644 --- a/src/freedreno/ir3/ir3_nir_trig.py +++ b/src/freedreno/ir3/ir3_nir_trig.py @@ -24,8 +24,8 @@ import argparse import sys trig_workarounds = [ - (('fsin', 'x@32'), ('fsin', ('fsub', ('fmul', 6.2831853, ('ffract', ('fadd', ('fmul', 0.15915494, 'x'), 0.5))), 3.14159265))), - (('fcos', 'x@32'), ('fcos', ('fsub', ('fmul', 6.2831853, ('ffract', ('fadd', ('fmul', 0.15915494, 'x'), 0.5))), 3.14159265))), + (('fsin', 'x@32'), ('fsin', ('!ffma', 6.2831853, ('ffract', ('!ffma', 0.15915494, 'x', 0.5)), -3.14159265))), + (('fcos', 'x@32'), ('fcos', ('!ffma', 6.2831853, ('ffract', ('!ffma', 0.15915494, 'x', 0.5)), -3.14159265))), ]