[igt-dev] [PATCH i-g-t] lib/i915/shaders: Tweak converter.py
Michał Winiarski
michal.winiarski at intel.com
Thu Jan 10 14:23:53 UTC 2019
The converter contains #!python3, but is written in python2.
Let's fix that, and while I'm here let's also tweak the README.
Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>
Cc: Katarzyna Dec <katarzyna.dec at intel.com>
Cc: Kalamarz Lukasz <lukasz.kalamarz at intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
lib/i915/shaders/README | 12 +++++++-----
lib/i915/shaders/converter.py | 20 +++++++++++---------
2 files changed, 18 insertions(+), 14 deletions(-)
mode change 100644 => 100755 lib/i915/shaders/converter.py
diff --git a/lib/i915/shaders/README b/lib/i915/shaders/README
index 06b9883c..9b7beb96 100644
--- a/lib/i915/shaders/README
+++ b/lib/i915/shaders/README
@@ -10,11 +10,6 @@ https://github.com/intel/intel-graphics-compiler
3. Build iga
cmake . && make
-For maintaining compatibility with our tests there is a bin to hex converter
-written in python:
- $>converter.py input_file > output_file
-e.g.$>python converter.py gen9_iga_output > gen9_hex_array
-
Commands used to generate the shader on gen7
$> m4 gpgpu_fill.gxa > gpgpu_fill.gxm
$> intel-gen4asm -g 7 -o <output> gpgpu_fill.gxm
@@ -23,3 +18,10 @@ Commands used to generate the shader on gen8
$> m4 media_fill.gxa > media_fill.gxm
$> intel-gen4asm -g 8 -o <output> media_fill.gxm
+Commands used to generate the shader using IGA on gen9
+$> iga64 -p=9 -a -o <output> gpgpu_fill_gen9.asm
+
+For maintaining compatibility with our tests there is a bin to hex converter
+written in python
+$> converter.py input_file > output_file
+$> converter.py gen9_iga_output > gen9_hex_array
diff --git a/lib/i915/shaders/converter.py b/lib/i915/shaders/converter.py
old mode 100644
new mode 100755
index 25a79a94..9dea0b75
--- a/lib/i915/shaders/converter.py
+++ b/lib/i915/shaders/converter.py
@@ -1,16 +1,18 @@
#!/usr/bin/env python3
+
import struct
import sys
import argparse
-parser=argparse.ArgumentParser(
- description='''Script for converting shaders from binary to hex ''' )
-parser = argparse.ArgumentParser(prog='converter.py', usage='%(prog)s binary_file')
+parser = argparse.ArgumentParser(
+ prog='converter.py',
+ description='Script for converting shaders from binary to hex',
+ usage='%(prog)s binary_file')
parser.add_argument('binary', nargs=1, help='binary_file')
-args=parser.parse_args()
+args = parser.parse_args()
-print "static const uint32_t kernel[][4] = {"
-with open(sys.argv[1], 'r') as f:
+print("static const uint32_t kernel[][4] = {")
+with open(sys.argv[1], 'rb') as f:
fmt = '<LLLL'
step = struct.calcsize(fmt)
while True:
@@ -18,9 +20,9 @@ with open(sys.argv[1], 'r') as f:
if not buf:
break
elif len(buf) < step:
- buf += '\x00' * (step - len(buf))
+ buf += b'\x00' * (step - len(buf))
val = struct.unpack('<LLLL', buf)
- print "\t{{ 0x{:08x}, 0x{:08x}, 0x{:08x}, 0x{:08x} }},".format(*val)
+ print("\t{{ 0x{:08x}, 0x{:08x}, 0x{:08x}, 0x{:08x} }},".format(*val))
-print "};"
+print("};")
--
2.19.2
More information about the igt-dev
mailing list