mesa: correctly allocate space for converted primtives
authorantonino <antonino.maniscalco@collabora.com>
Tue, 21 Mar 2023 14:35:59 +0000 (15:35 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 24 Mar 2023 13:11:12 +0000 (13:11 +0000)
Previosuly it was assumed that primitives where always converted to
triangles if the driver did not support all primitives, however that's
not true for a driver that supports quads but not quad strips.

Fixes piglit spec@!opengl 1.1@dlist-fdo3129-01 on Panfrost

Fixes: dcbf2423d28 ("vbo/dlist: add vertices to incomplete primitives")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21987>

src/mesa/vbo/vbo_save_api.c
src/panfrost/ci/panfrost-g52-fails.txt

index 111d7b3..a15c0d5 100644 (file)
@@ -625,6 +625,9 @@ compile_vertex_list(struct gl_context *ctx)
       GLubyte mode = original_prims[i].mode;
       bool converted_prim = false;
       unsigned index_size;
+      bool outputting_quads = !!(ctx->Const.DriverSupportedPrimMask &
+                                 (BITFIELD_MASK(PIPE_PRIM_QUADS) | BITFIELD_MASK(PIPE_PRIM_QUAD_STRIP)));
+      unsigned verts_per_primitive = outputting_quads ? 4 : 3;
 
       int vertex_count = original_prims[i].count;
       if (!vertex_count) {
@@ -632,8 +635,8 @@ compile_vertex_list(struct gl_context *ctx)
       }
 
       /* Increase indices storage if the original estimation was too small. */
-      if (idx + 3 * vertex_count > max_index_count) {
-         max_index_count = max_index_count + 3 * vertex_count;
+      if (idx + verts_per_primitive * vertex_count > max_index_count) {
+         max_index_count = max_index_count + verts_per_primitive * vertex_count;
          indices = (uint32_t*) realloc(indices, max_index_count * sizeof(uint32_t));
          tmp_indices = all_prims_supported ? NULL : realloc(tmp_indices, max_index_count * sizeof(uint32_t));
       }
index 2cad34a..d99994c 100644 (file)
@@ -498,7 +498,6 @@ spec@!opengl 1.0@gl-1.0-edgeflag-quads,Fail
 spec@!opengl 1.0@gl-1.0-no-op-paths,Fail
 spec@!opengl 1.0@gl-1.0-spot-light,Fail
 spec@!opengl 1.0@rasterpos,Crash
-spec@!opengl 1.1@dlist-fdo3129-01,Crash
 spec@!opengl 1.1@getteximage-formats,Fail
 spec@!opengl 1.1@linestipple@Factor 2x,Fail
 spec@!opengl 1.1@linestipple@Factor 3x,Fail