From d4a6c97779b851aac66da4369500ca53d4cf056d Mon Sep 17 00:00:00 2001 From: antonino Date: Tue, 21 Mar 2023 15:35:59 +0100 Subject: [PATCH] mesa: correctly allocate space for converted primtives 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 Part-of: --- src/mesa/vbo/vbo_save_api.c | 7 +++++-- src/panfrost/ci/panfrost-g52-fails.txt | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 111d7b3a8cb..a15c0d5c075 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -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)); } diff --git a/src/panfrost/ci/panfrost-g52-fails.txt b/src/panfrost/ci/panfrost-g52-fails.txt index 2cad34a0363..d99994c2a83 100644 --- a/src/panfrost/ci/panfrost-g52-fails.txt +++ b/src/panfrost/ci/panfrost-g52-fails.txt @@ -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