Module: Mesa Branch: staging/23.0 Commit: a0224f1b3a62084aeaeb9775c6770a33c12043eb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0224f1b3a62084aeaeb9775c6770a33c12043eb
Author: antonino <[email protected]> Date: Mon Feb 13 12:57:38 2023 +0100 nir: handle primitives with adjacency `nir_create_passthrough_gs` can now handle primitives with adjacency where some vertices need to be skipped. Fixes: d0342e28b32 ("nir: Add helper to create passthrough GS shader") Acked-by: Mike Blumenkrantz <[email protected]> Reviewed-by: Erik Faye-Lund <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21238> (cherry picked from commit ea14579f3dc3144541c6e5944d14e0e257115b15) --- .pick_status.json | 2 +- src/compiler/nir/nir_passthrough_gs.c | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index bc50d3ed27a..ecdc0883d11 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2740,7 +2740,7 @@ "description": "nir: handle primitives with adjacency", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "d0342e28b32d7aa4b25cf045ac9933348ec053a9" }, diff --git a/src/compiler/nir/nir_passthrough_gs.c b/src/compiler/nir/nir_passthrough_gs.c index b13b8909484..4ba4f2c8380 100644 --- a/src/compiler/nir/nir_passthrough_gs.c +++ b/src/compiler/nir/nir_passthrough_gs.c @@ -89,7 +89,25 @@ nir_create_passthrough_gs(const nir_shader_compiler_options *options, out_vars[num_vars++] = out; } - for (unsigned i = 0; i < vertices; ++i) { + unsigned int start_vert = 0; + unsigned int end_vert = vertices; + unsigned int vert_step = 1; + switch (primitive_type) { + case PIPE_PRIM_LINES_ADJACENCY: + case PIPE_PRIM_LINE_STRIP_ADJACENCY: + start_vert = 1; + end_vert += 1; + break; + case PIPE_PRIM_TRIANGLES_ADJACENCY: + case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY: + end_vert = 5; + vert_step = 2; + break; + default: + break; + } + + for (unsigned i = start_vert; i < end_vert; i += vert_step) { /* Copy inputs to outputs. */ for (unsigned j = 0; j < num_vars; ++j) { /* no need to use copy_var to save a lower pass */
