[Mesa-dev] [PATCH 00/31] radeonsi: shader parts refactoring

Nicolai Hähnle nhaehnle at gmail.com
Mon Oct 31 22:10:47 UTC 2016

Hi all,

this series really does three things:

Patches 1-4: Link radeonsi against code in amd/common. I mainly did that
because I happened to need some radeon-specific code that interfaces
LLVM via C++, and ac_llvm_helper.cpp already existed. It would have been
trivial to add a C++ source file to radeonsi of course, but I hope that
this change nudges the radv contributors a bit in the direction of
following up with the code duplication reduction (*hint hint* ac_binary,
maybe others).

Patches 5-25: Simplify the way monolithic shaders are generated. Now, the
default is not to use monolithic shaders at all any more. But one can save
a few instructions and perhaps schedule instructions a bit better, so it
makes sense to keep monolithic shaders around for possible future async
compilation of specialized shaders.

The catch with the old way of generating monolithic shaders is that a lot
of logic was duplicated, e.g. there were two places that check for instance
divisors, two places for interpolation, and so on.

The new way always generates LLVM IR for prolog and epilog shaders. When
a monolithic shader is requested, all involved functions are created in
the same LLVM module, and inlining is used to create a single resulting
shader. The advantage is that while the size of the code stays roughly
the same (since more code is needed for building the wrapper function),
the complexity of the code is reduced and we're less likely to break
monolithic shaders in the future.

Patches 26-31: Add prologs to geometry shaders. This allows us to add a
workaround to the order of vertices in triangle strips with adjacency.

Please review!

 src/Makefile.am                              |    5 +-
 src/amd/common/Makefile.am                   |    6 +
 src/amd/common/Makefile.sources              |    4 +-
 src/amd/common/ac_llvm_helper.cpp            |   15 +-
 src/amd/common/ac_llvm_util.h                |   12 +
 src/amd/common/ac_nir_to_llvm.c              |    1 +
 src/amd/common/ac_nir_to_llvm.h              |    4 -
 src/gallium/drivers/radeonsi/Automake.inc    |    1 +
 src/gallium/drivers/radeonsi/si_pipe.c       |    1 +
 src/gallium/drivers/radeonsi/si_pipe.h       |    4 +-
 src/gallium/drivers/radeonsi/si_shader.c     | 1777 +++++++++-------
 src/gallium/drivers/radeonsi/si_shader.h     |   19 +-
 .../drivers/radeonsi/si_shader_internal.h    |    9 +-
 .../drivers/radeonsi/si_shader_tgsi_setup.c  |   13 +-
 src/gallium/drivers/radeonsi/si_state_draw.c |   18 +
 .../drivers/radeonsi/si_state_shaders.c      |   37 +-
 16 files changed, 1092 insertions(+), 834 deletions(-)

More information about the mesa-dev mailing list