[Mesa-dev] [PATCH 18/28] intel/nir: call nir_opt_constant_folding before brw_nir_apply_trig_workarounds

Samuel Iglesias Gonsálvez siglesias at igalia.com
Wed Dec 5 15:55:33 UTC 2018


If we have fsin or fcos trigonometric operations with constant values as inputs,
we will multiply the result by 0.99997 in brw_nir_apply_trig_workarounds,
making the result wrong. Running nir_opt_constant_folding before, we will
calculate correctly the result for these trignometric ops.

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
 src/intel/compiler/brw_nir.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index 600f7a97df9..41e27054595 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -664,8 +664,10 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir)
 
    /* See also brw_nir_trig_workarounds.py */
    if (compiler->precise_trig &&
-       !(devinfo->gen >= 10 || devinfo->is_kabylake))
+       !(devinfo->gen >= 10 || devinfo->is_kabylake)) {
+      OPT(nir_opt_constant_folding);
       OPT(brw_nir_apply_trig_workarounds);
+   }
 
    static const nir_lower_tex_options tex_options = {
       .lower_txp = ~0,
-- 
2.19.1



More information about the mesa-dev mailing list