diff options
author | Dylan Baker <[email protected]> | 2017-09-19 11:46:16 -0700 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2017-09-27 09:07:28 -0700 |
commit | 848da662224326ccfbe6647bc82f4f89ca22c762 (patch) | |
tree | e5779521af3f18afb6fb639a42f5b8561e0aea64 /src/intel | |
parent | a65db0ad1c3ace58fbc81b6860e28c0a7645257c (diff) |
intel: use a flag instead of setting PYTHONPATH
Meson doesn't allow setting environment variables for custom targets, so
we either need to not pass this as an environment variable or use a
shell script to wrap the invocation. The chosen solution has the
advantage of working for both autotools and meson.
v2: - put rules back in top scope (Ken)
Reviewed-by: Kenneth Graunke <[email protected]>
Signed-off-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/Makefile.compiler.am | 2 | ||||
-rw-r--r-- | src/intel/compiler/brw_nir_trig_workarounds.py | 33 |
2 files changed, 26 insertions, 9 deletions
diff --git a/src/intel/Makefile.compiler.am b/src/intel/Makefile.compiler.am index 3ab550c96b1..45e7a6ccce8 100644 --- a/src/intel/Makefile.compiler.am +++ b/src/intel/Makefile.compiler.am @@ -35,7 +35,7 @@ BUILT_SOURCES += $(COMPILER_GENERATED_FILES) compiler/brw_nir_trig_workarounds.c: compiler/brw_nir_trig_workarounds.py \ $(top_srcdir)/src/compiler/nir/nir_algebraic.py $(MKDIR_GEN) - $(AM_V_GEN) PYTHONPATH=$(top_srcdir)/src/compiler/nir $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/compiler/brw_nir_trig_workarounds.py > $@ || ($(RM) $@; false) + $(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/compiler/brw_nir_trig_workarounds.py -p $(top_srcdir)/src/compiler/nir > $@ || ($(RM) $@; false) EXTRA_DIST += \ compiler/brw_nir_trig_workarounds.py diff --git a/src/intel/compiler/brw_nir_trig_workarounds.py b/src/intel/compiler/brw_nir_trig_workarounds.py index 6a77d64dbd4..3d08b9a41ea 100644 --- a/src/intel/compiler/brw_nir_trig_workarounds.py +++ b/src/intel/compiler/brw_nir_trig_workarounds.py @@ -20,8 +20,6 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. -import nir_algebraic - # Prior to Kaby Lake, The SIN and COS instructions on Intel hardware can # produce values slightly outside of the [-1.0, 1.0] range for a small set of # values. Obviously, this can break everyone's expectations about trig @@ -33,11 +31,30 @@ import nir_algebraic # amplitude slightly. Apparently this also minimizes the error function, # reducing the maximum error from 0.00006 to about 0.00003. -trig_workarounds = [ - (('fsin', 'x'), ('fmul', ('fsin', 'x'), 0.99997)), - (('fcos', 'x'), ('fmul', ('fcos', 'x'), 0.99997)), +import argparse +import sys + +TRIG_WORKAROUNDS = [ + (('fsin', 'x'), ('fmul', ('fsin', 'x'), 0.99997)), + (('fcos', 'x'), ('fmul', ('fcos', 'x'), 0.99997)), ] -print '#include "brw_nir.h"' -print nir_algebraic.AlgebraicPass("brw_nir_apply_trig_workarounds", - trig_workarounds).render() + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('-p', '--import-path', required=True) + args = parser.parse_args() + sys.path.insert(0, args.import_path) + run() + + +def run(): + import nir_algebraic # pylint: disable=import-error + + print '#include "brw_nir.h"' + print nir_algebraic.AlgebraicPass("brw_nir_apply_trig_workarounds", + TRIG_WORKAROUNDS).render() + + +if __name__ == '__main__': + main() |