Hi all, A few weeks ago I mentioned that I was looking into support of GL_ARB_gl_spirv. Based on that feedback, I continued an approach where Mesa translates SPIR-V to NIR during shader specialization, and hands off the lowered NIR to the driver. This makes it easier for a lot of the program resource machinery to work without having a separate SPIR-V path, in particular around glUniform*() and friends.
I got the first very simple VS-PS pipelines working using SPIR-V over the weekend, so it's time to start upstreaming the underlying work in radeonsi. The status of the code: Enabling it is optional using R600_DEBUG=nir. It only supports VS-PS pipelines (and hence OpenGL 3.1), and has plenty of regressions especially surrounding compatibility features. Those are explicitly removed in GL_ARB_gl_spirv, so I didn't put an emphasis on those. Still, a lot of compatibility profile programs do work, which helps increase coverage. It also works with some games. The series ended up pretty long, but most of the changes are conceptually quite simple. Patches 1-8 add some glsl & NIR pieces that are useful later on because we'd like the lowered NIR code to look a bit different from what freedreno and vc4 expect. Patches 9-13 fix and refactor some Gallium bits, especially to allow us to do TGSI <-> Mesa mappings in radeonsi. For example, radeonsi wants to map VARYING_SLOTs to TGSI_SEMANTICs for settings up interstage state. Patches 14-22 fix some NIR bugs in st/mesa and allow the driver greater control over how NIR is lowered. Patch 23 is a build system adjustment. Patches 24-92 are the bulk of the work in ac/nir and radeonsi, plus some minor radv changes around the edges. Most of the changes in ac/nir are about disentangling nir_to_llvm_context from a new ac_nir_context structure. The idea here is that ac_nir_context is used for translating NIR code itself to LLVM, while nir_to_llvm_context is used for the radv-specific shader ABI lowering. There is also a new ac_shader_abi, which is used to describe the ABI differences between radeonsi and radv as far as they're relevant for the NIR code translation. Ultimately, I'd like to split ac_nir_to_llvm.c into radv- and generic parts. But that's something to be done after all shader stages and features have been implemented. One slightly awkward design issue that would be nice to straighten out eventually is the proliferation of shader_info structures. There's tgsi_shader_info, ac_shader_info, (compiler) shader_info, and the radv shader variant info thing. But that's something to keep in mind for later. The whole series is also at https://cgit.freedesktop.org/~nh/mesa/log/?h=nir Please review! Thanks, Nicolai -- src/amd/common/ac_llvm_build.c | 24 +- src/amd/common/ac_llvm_build.h | 14 +- src/amd/common/ac_nir_to_llvm.c | 1827 +++++++++------- src/amd/common/ac_nir_to_llvm.h | 9 +- src/amd/common/ac_shader_abi.h | 93 + src/amd/common/ac_shader_info.c | 9 + src/amd/common/ac_shader_info.h | 10 +- src/amd/vulkan/radv_cmd_buffer.c | 2 +- src/amd/vulkan/radv_pipeline.c | 2 +- src/compiler/Makefile.sources | 2 + src/compiler/glsl/glsl_to_nir.cpp | 1 + src/compiler/glsl_types.h | 11 + src/compiler/nir/nir.c | 13 + src/compiler/nir/nir.h | 24 + .../nir/nir_lower_samplers_as_deref.c | 243 ++ src/compiler/nir/nir_lower_system_values.c | 36 +- src/compiler/nir/nir_lower_uniforms_to_ubo.c | 140 ++ src/compiler/nir/nir_lower_wpos_ytransform.c | 6 +- src/compiler/nir_types.cpp | 7 + src/compiler/nir_types.h | 2 + src/gallium/auxiliary/Makefile.sources | 2 + src/gallium/auxiliary/tgsi/tgsi_from_mesa.c | 185 ++ src/gallium/auxiliary/tgsi/tgsi_from_mesa.h | 71 + src/gallium/docs/source/screen.rst | 27 + src/gallium/drivers/ddebug/dd_context.c | 6 +- src/gallium/drivers/ddebug/dd_draw.c | 9 +- src/gallium/drivers/ddebug/dd_screen.c | 21 + src/gallium/drivers/etnaviv/etnaviv_screen.c | 2 + .../drivers/freedreno/freedreno_screen.c | 16 + src/gallium/drivers/i915/i915_screen.c | 2 + src/gallium/drivers/llvmpipe/lp_screen.c | 2 + .../drivers/nouveau/nv30/nv30_screen.c | 2 + .../drivers/nouveau/nv50/nv50_screen.c | 2 + .../drivers/nouveau/nvc0/nvc0_screen.c | 2 + src/gallium/drivers/r300/r300_screen.c | 2 + src/gallium/drivers/r600/r600_pipe.c | 2 + .../drivers/radeon/r600_pipe_common.c | 1 + .../drivers/radeon/r600_pipe_common.h | 2 +- src/gallium/drivers/radeonsi/Automake.inc | 3 + src/gallium/drivers/radeonsi/Makefile.am | 1 + .../drivers/radeonsi/Makefile.sources | 1 + src/gallium/drivers/radeonsi/si_pipe.c | 59 + src/gallium/drivers/radeonsi/si_shader.c | 228 +- src/gallium/drivers/radeonsi/si_shader.h | 8 + .../drivers/radeonsi/si_shader_internal.h | 36 +- src/gallium/drivers/radeonsi/si_shader_nir.c | 493 +++++ .../drivers/radeonsi/si_shader_tgsi_mem.c | 63 +- .../drivers/radeonsi/si_state_shaders.c | 46 +- src/gallium/drivers/softpipe/sp_screen.c | 2 + src/gallium/drivers/svga/svga_screen.c | 2 + src/gallium/drivers/swr/swr_screen.cpp | 2 + src/gallium/drivers/vc4/vc4_screen.c | 17 + src/gallium/drivers/virgl/virgl_screen.c | 2 + src/gallium/include/pipe/p_defines.h | 8 + src/gallium/include/pipe/p_screen.h | 11 + src/gallium/targets/d3dadapter9/Makefile.am | 1 + src/gallium/targets/omx/Makefile.am | 1 + src/gallium/targets/va/Makefile.am | 1 + src/gallium/targets/vdpau/Makefile.am | 1 + src/gallium/targets/xvmc/Makefile.am | 1 + src/mesa/state_tracker/st_glsl_to_nir.cpp | 23 +- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 23 +- src/mesa/state_tracker/st_program.c | 103 +- src/mesa/state_tracker/st_program.h | 21 +- 64 files changed, 2912 insertions(+), 1076 deletions(-) _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev