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

Samuel Iglesias Gonsálvez siglesias at igalia.com
Tue Dec 18 10:34:13 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 3b4d25213f5..2debce72db2 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -665,8 +665,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