From 4ce4823f4e69d6226ae1b8dc2bc6763c9be56174 Mon Sep 17 00:00:00 2001 From: antonino Date: Fri, 14 Apr 2023 12:47:17 +0200 Subject: [PATCH] zink: use correct primitives for passthrough gs with tess When tessellation is used the geometry shader needs to take the tessellator output primitive as input. Reviewed-by: Mike Blumenkrantz Fixes: 90a8525d703 ("zink: handle edgeflags") Part-of: (cherry picked from commit c84989c4cf3d95871047cb2e2bb87e41663b13dc) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_program.c | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 39302bf7d10..14d4cc504ed 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -445,7 +445,7 @@ "description": "zink: use correct primitives for passthrough gs with tess", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "90a8525d703330b9d198ddf9579c560d0e5cadaa" }, diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index a703c5b5581..b631d150f79 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -2222,6 +2222,24 @@ zink_rast_prim_for_pipe(enum pipe_prim_type prim) } } +static enum pipe_prim_type +zink_tess_prim_type(struct zink_shader *tess) +{ + if (tess->info.tess.point_mode) + return PIPE_PRIM_POINTS; + else { + switch (tess->info.tess._primitive_mode) { + case TESS_PRIMITIVE_ISOLINES: + return PIPE_PRIM_LINES; + case TESS_PRIMITIVE_TRIANGLES: + case TESS_PRIMITIVE_QUADS: + return PIPE_PRIM_TRIANGLES; + default: + return PIPE_PRIM_MAX; + } + } +} + static inline void zink_add_inline_uniform(nir_shader *shader, int offset) { @@ -2320,10 +2338,13 @@ zink_set_primitive_emulation_keys(struct zink_context *ctx) prev_stage, ZINK_INLINE_VAL_PV_LAST_VERT * 4); } else { + enum pipe_prim_type prim = ctx->gfx_pipeline_state.gfx_prim_mode; + if (prev_vertex_stage == MESA_SHADER_TESS_EVAL) + prim = zink_tess_prim_type(ctx->gfx_stages[MESA_SHADER_TESS_EVAL]); nir = nir_create_passthrough_gs( &screen->nir_options, prev_stage, - ctx->gfx_pipeline_state.gfx_prim_mode, + prim, ZINK_INLINE_VAL_FLAT_MASK * sizeof(uint32_t), ZINK_INLINE_VAL_PV_LAST_VERT * sizeof(uint32_t), lower_edge_flags,