[PATCH 00/21] Towards NIR support for etnaviv

Christian Gmeiner christian.gmeiner at gmail.com
Tue Jun 5 15:43:46 UTC 2018


Am Di., 5. Juni 2018 um 16:40 Uhr schrieb Philipp Zabel
<p.zabel at pengutronix.de>:
>
> Hi!
>
> we have been interested in NIR support for etnaviv for a while, for the
> obvious reasons: gaining access to common optimizations, better support
> for non-trivial code transformations, better register allocation, and
> the promise of OpenCL and SPIR-V support in the future.
>
> Michael and I have used our annual exploratory "tech week" last year
> and last week to get acquainted with NIR and the Vivante GPUs a bit and
> to get started compiling NIR shaders from the GLSL compiler to Vivante
> machine code.
>
> The following patches are still very much work in progress. Until now,
> this has only been tested with kmscube, weston, and glmark2 (and some
> benchmarks are not working yet, missing instruction implementations).
> We haven't even dared to run piglit yet. At this point we'd very much
> like some feedback on where we are on the right path, and where things
> could be done in a better way.
> The NIR compiler is placed next to the current TGSI translation layer,
> and still uses the same backend for code emission. NIR support is
> disabled by default, and can be enabled using the etnaviv environment
> option: ETNA_MESA_DEBUG="nir", so this could be merged without side
> effects, once it is deemed acceptable, to support further development
> in-tree.
>
> Due to the shared global register file, reducing the amount of temporary
> registers used by a shader is important for parallelism. We have added
> added a layer of virtual registers with less than four components over
> each vec4 base register using the register allocator utility, and use
> source swizzles and destination write masks to reuse the free components
> of partially occupied registers if possible.
> We use the NIR global registers, indexed to represent the registers in
> the global temporary register file, which allows us to do register
> assignment in NIR and then reuse the current code emitter without
> introducing another intermediate representation.
>
> There are already a few Vivante specific lowering passes, but we
> notably are still missing support for loops, and for lowering sin,
> cos and log functions to the Vivante specific hardware instructions
> that need prescaling and post-multiplication of the results' x and
> y components (or to replace them with approximations where the
> instructions are not supported).
>

Thanks for this nice patch series. I have been working for too long on
the nir topic
for etnaviv and never pushed any patches (which is quite sad). I have taken
another route to tackle it. I have started with a low level library to
generate valid
Vivante binaries and to be able to disassemble them. On top of this, I
have an eir
library which is a simple block based ir which makes use of the low-level lib.
And the last thing is the actual compiler which is nir based. All life outside
of the gallium driver and have some gtest based unit tests. My main goal was to
start from a green field without looking at the current tgsi based compiler.

I will have a deeper look at your patches and review them. I am quite
unsure what I
will do with my current code. I think the best would be to clean it up
and push it.

Hopefully, we can incorporate each work into a really nice new compiler.

> The patches can also be found at:
>
>   git://git.pengutronix.de/pza/mesa.git etnaviv-nir
>
> regards
> Philipp
>
> Michael Tretter (10):
>   etnaviv: extract get_mystery_meat_load_balancing
>   etnaviv: compiler: extract compile shader from tgsi
>   etnaviv: compiler: setup registers from nir
>   etnaviv: compiler: avoid using tgsi_shader_info
>   etnaviv: compiler: add code emitter for alu operations
>   etnaviv: compiler: generate instructions for log2
>   etnaviv: nir: remove undefined variables
>   etnaviv: compiler: ignore nir_instr_type_ssa_undef
>   etnaviv: nir: add extra mov for uniforms used as output
>   etnaviv: nir: avoid multiple uniform src for alu ops
>
> Philipp Zabel (11):
>   etnaviv: prefix COMPARE_FUNC enum values in rnndb
>   etnaviv: add debug option to report NIR as supported and preferred
>     shader IR
>   etnaviv: generate and optimize NIR
>   etnaviv: nir: hardwire position location
>   etnaviv: nir: merge mov of result into alu op
>   etnaviv: nir: add virtual register classes
>   etnaviv: nir: add a nop intrinsic to empty shaders
>   etnaviv: compiler: generate texture loads
>   etnaviv: nir: add texture fixup path before register assignment
>   etnaviv: nir: implement conditionals
>   etnaviv: nir: globalize local registers
>
>  src/gallium/drivers/etnaviv/Makefile.am       |    5 +-
>  src/gallium/drivers/etnaviv/Makefile.sources  |    2 +
>  .../drivers/etnaviv/etnaviv_compiler.c        |  816 +++++++++++-
>  src/gallium/drivers/etnaviv/etnaviv_debug.h   |    3 +
>  src/gallium/drivers/etnaviv/etnaviv_nir.c     | 1108 +++++++++++++++++
>  src/gallium/drivers/etnaviv/etnaviv_nir.h     |   39 +
>  src/gallium/drivers/etnaviv/etnaviv_screen.c  |   23 +-
>  src/gallium/drivers/etnaviv/etnaviv_shader.c  |   10 +
>  src/gallium/drivers/etnaviv/etnaviv_shader.h  |    3 +
>  src/gallium/drivers/etnaviv/hw/state_3d.xml.h |   16 +-
>  10 files changed, 1956 insertions(+), 69 deletions(-)
>  create mode 100644 src/gallium/drivers/etnaviv/etnaviv_nir.c
>  create mode 100644 src/gallium/drivers/etnaviv/etnaviv_nir.h
>
> --
> 2.17.1
>
> _______________________________________________
> etnaviv mailing list
> etnaviv at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



--
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info


More information about the etnaviv mailing list