mesa: allocate the attribute stack on demand
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6946>
This commit is contained in:
@@ -78,7 +78,15 @@ _mesa_PushAttrib(GLbitfield mask)
|
||||
return;
|
||||
}
|
||||
|
||||
head = &ctx->AttribStack[ctx->AttribStackDepth];
|
||||
head = ctx->AttribStack[ctx->AttribStackDepth];
|
||||
if (unlikely(!head)) {
|
||||
head = CALLOC_STRUCT(gl_attrib_node);
|
||||
if (unlikely(!head)) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib");
|
||||
return;
|
||||
}
|
||||
ctx->AttribStack[ctx->AttribStackDepth] = head;
|
||||
}
|
||||
head->Mask = mask;
|
||||
|
||||
if (mask & GL_ACCUM_BUFFER_BIT)
|
||||
@@ -650,7 +658,7 @@ _mesa_PopAttrib(void)
|
||||
}
|
||||
|
||||
ctx->AttribStackDepth--;
|
||||
attr = &ctx->AttribStack[ctx->AttribStackDepth];
|
||||
attr = ctx->AttribStack[ctx->AttribStackDepth];
|
||||
|
||||
unsigned mask = attr->Mask;
|
||||
|
||||
@@ -1471,11 +1479,14 @@ _mesa_free_attrib_data(struct gl_context *ctx)
|
||||
struct gl_attrib_node *attr;
|
||||
|
||||
ctx->AttribStackDepth--;
|
||||
attr = &ctx->AttribStack[ctx->AttribStackDepth];
|
||||
attr = ctx->AttribStack[ctx->AttribStackDepth];
|
||||
|
||||
if (attr->Mask & GL_TEXTURE_BIT)
|
||||
_mesa_reference_shared_state(ctx, &attr->Texture.SharedRef, NULL);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(ctx->AttribStack); i++)
|
||||
free(ctx->AttribStack[i]);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -5195,7 +5195,7 @@ struct gl_context
|
||||
/** \name State attribute stack (for glPush/PopAttrib) */
|
||||
/*@{*/
|
||||
GLuint AttribStackDepth;
|
||||
struct gl_attrib_node AttribStack[MAX_ATTRIB_STACK_DEPTH];
|
||||
struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
|
||||
/*@}*/
|
||||
|
||||
/** \name Renderer attribute groups
|
||||
|
Reference in New Issue
Block a user