Re: [igt-dev] [PATCH i-g-t 1/2] shaders: Add assembler instructions and update README for shaders

Arkadiusz Hiler
2018-10-03T11:05:17Z

On Tue, Oct 02, 2018 at 03:49:32PM +0200, Katarzyna Dec wrote:
> We're not planning to work on assembler in igt anymore, since we can
> reuse an existing project (IGA) that will do this work for us. The
> only extra thing we need to do is convert the result binary to C-array,
> simple python script.
>
> v2: Moved converter to single file. Fixed README for shaders.
>
> Signed-off-by: Katarzyna Dec <katarzyna.dec@intel.com>
> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> Cc: Petri Latvala <petri.latvala@intel.com>
> Cc: Kalamarz Lukasz <lukasz.kalamarz@intel.com>
> Cc: Antonio Argenziano <antonio.argenziano@intel.com>
> ---
> shaders/README | 19 +++++++++++++++++++
> shaders/converter.py | 24 ++++++++++++++++++++++++
> shaders/gpgpu/README | 11 +++++++++++
> shaders/gpgpu/gpgpu_fill_gen8.asm | 10 ++++++++++
> shaders/gpgpu/gpgpu_fill_gen9.asm | 10 ++++++++++
> shaders/media/README | 9 +++++++++
> shaders/media/media_fill_gen8.asm | 11 +++++++++++
> shaders/ps/README | 8 ++++++++
> shaders/ps/blit_gen8.asm | 7 +++++++
> shaders/ps/neg1_gen8.asm | 9 +++++++++
> 10 files changed, 118 insertions(+)
> create mode 100644 shaders/README
> create mode 100644 shaders/converter.py
> create mode 100644 shaders/gpgpu/gpgpu_fill_gen8.asm
> create mode 100644 shaders/gpgpu/gpgpu_fill_gen9.asm
> create mode 100644 shaders/media/media_fill_gen8.asm
> create mode 100644 shaders/ps/blit_gen8.asm
> create mode 100644 shaders/ps/neg1_gen8.asm
>
> diff --git a/shaders/README b/shaders/README
> new file mode 100644
> index 00000000..3365a209
> --- /dev/null
> +++ b/shaders/README
> @@ -0,0 +1,19 @@
> +This directory is for shaders used in media_fill, gpgpu_fill, rendercopy
> +and media_spin libraries.
> +
> +Till Gen8 shaders were generated using intel-gen4asm script (implementation in
> +assembler/ directory). From Gen8 it is possible to use Intel Graphics Assembler
> +to generate binary from asm instructions.
> +https://github.com/intel/intel-graphics-compiler
> + 1. Clone IGC project
> + 2. Go to igc/visa/iga
> + 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
> +
> +Instructions how to build media, gpgpu or ps shaders included in their
> +subdirectories.
> diff --git a/shaders/converter.py b/shaders/converter.py
> new file mode 100644
> index 00000000..a50ac96c
> --- /dev/null
> +++ b/shaders/converter.py
> @@ -0,0 +1,24 @@
> +#!/usr/bin/env python2
> +import struct
> +import sys
> +import argparse
> +
> +parser = argparse.ArgumentParser(description='Script for converting shaders in binary to hex.')
> +args = parser.parse_args()
> +
> +print "static const uint32_t kernel[][4] = {"
> +
> +with open(sys.argv[1], 'r') as f:
> + fmt = '<LLLL'
> + step = struct.calcsize(fmt)
> + while True:
> + buf = f.read(step)
> + if not buf:
> + break
> + elif len(buf) < step:
> + buf += '\x00' * (step - len(buf))
> +
> + val = struct.unpack('<LLLL', buf)
> + print "\t{{ 0x{:08x}, 0x{:08x}, 0x{:08x}, 0x{:08x} }},".format(*val)
> +
> +print "};"
> \ No newline at end of file
> diff --git a/shaders/gpgpu/README b/shaders/gpgpu/README
> index 3bf328ad..91aca7e8 100644
> --- a/shaders/gpgpu/README
> +++ b/shaders/gpgpu/README
> @@ -1,4 +1,15 @@
> +These files are here for reference only.
>
> Commands used to generate the shader on gen7
> $> m4 gpgpu_fill.gxa > gpgpu_fill.gxm
> $> intel-gen4asm -g 7 -o gpgpu_fill.gxm

Is there any point in having this README almost copy-and-pasted for each
shader directory, instead of having just a common one in shaders/
direcotry?

--
Cheers,
Arek