zink: use correct primitives for passthrough gs with tess
authorantonino <antonino.maniscalco@collabora.com>
Fri, 14 Apr 2023 10:47:17 +0000 (12:47 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 14 Apr 2023 19:22:48 +0000 (19:22 +0000)
When tessellation is used the geometry shader needs to take the
tessellator output primitive as input.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fixes: 90a8525d703 ("zink: handle edgeflags")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22498>

src/gallium/drivers/zink/zink_program.c

index 35aea2f..21f8b06 100644 (file)
@@ -2236,6 +2236,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)
 {
@@ -2334,10 +2352,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,