gallium: Fix u_stream_outputs_for_vertices with QUADS
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 18 Mar 2023 02:59:05 +0000 (22:59 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 21 Mar 2023 18:33:42 +0000 (18:33 +0000)
Per the spec. This helper is only used in nv50 and panfrost, the latter is known
to have a completely broken transform feedback implementation and I'd be
unsurprised if the same is true for nv50. So unsurprising that compatibility
profile interaction was missed.

This is part of the Piglit ext_transform_feedback-tessellation quads puzzle.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22013>

src/gallium/auxiliary/util/u_prim.h

index f4807f0..4c7214b 100644 (file)
@@ -371,6 +371,21 @@ u_stream_outputs_for_vertices(enum pipe_prim_type primitive, unsigned nr)
 
    /* One output per vertex after decomposition */
    enum pipe_prim_type base = u_base_prim_type(primitive);
+
+   /* The GL 4.6 compatibility spec says
+    *
+    *    When quads and polygons are provided to transform feedback with a
+    *    primitive mode of TRIANGLES, they will be tessellated and recorded as
+    *    triangles (the order of tessellation within a primitive is undefined)
+    *
+    * Further, quads and polygons are always provided as TRIANGLES. So
+    * tessellate quads into triangles.
+    */
+   if (base == PIPE_PRIM_QUADS) {
+      base = PIPE_PRIM_TRIANGLES;
+      prims *= 2;
+   }
+
    return u_vertices_for_prims(base, prims);
 }