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: dcbf2423d2 ("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>
This commit is contained in:
antonino 2023-03-21 15:35:59 +01:00 committed by Marge Bot
parent d9e68f4e40
commit d4a6c97779
2 changed files with 5 additions and 3 deletions

View 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));
}

View 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