v3d: add initial compiler plumbing for geometry shaders

Graphics / Mesa 3D Graphics Library / Mesa - Iago Toral Quiroga [igalia.com] - 16 December 2019 07:42 EST

Most of the relevant work happens in the v3d_nir_lower_io. Since geometry shaders can write any number of output vertices, this pass injects a few variables into the shader code to keep track of things like the number of vertices emitted or the offsets into the VPM of the current vertex output, etc. This is also where we handle EmitVertex() and EmitPrimitive() intrinsics.

The geometry shader VPM output layout has a specific structure with a 32-bit general header, then another 32-bit header slot for each output vertex, and finally the actual vertex data.

When vertex shaders are paired with geometry shaders we also need to consider the following:
- Only geometry shaders emit fixed function outputs.- The coordinate shader used for the vertex stage during binning must not drop varyings other than those used by transform feedback, since these may be read by the binning GS.

- Use MAX3 instead of a chain of MAX2 (Alejandro).- Make all loop variables unsigned in ntq_setup_gs_inputs (Alejandro)- Update comment in IO owering so it includes the GS stage (Alejandro)

5d578c27cec v3d: add initial compiler plumbing for geometry shaders
src/broadcom/common/v3d_limits.h | 5 +-
src/broadcom/compiler/nir_to_vir.c | 175 ++++++++++++---
src/broadcom/compiler/v3d_compiler.h | 33 +++
src/broadcom/compiler/v3d_nir_lower_io.c | 357 +++++++++++++++++++++++++++----
src/broadcom/compiler/vir.c | 119 +++++++++--
src/gallium/drivers/v3d/v3d_context.h | 30 +--
src/gallium/drivers/v3d/v3d_program.c | 169 +++++++++++++--
7 files changed, 778 insertions(+), 110 deletions(-)

Upstream: cgit.freedesktop.org

  • Share