From ea14579f3dc3144541c6e5944d14e0e257115b15 Mon Sep 17 00:00:00 2001 From: antonino Date: Mon, 13 Feb 2023 12:57:38 +0100 Subject: [PATCH] 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 Reviewed-by: Erik Faye-Lund Part-of: --- src/compiler/nir/nir_passthrough_gs.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 */