From 11f41ba2f9c37d172fda3c2af3a2e68c9511d7da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 25 May 2021 17:26:23 -0400 Subject: [PATCH] mesa: optimize unreferencing VBOs in glPopClientAttrib Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/attrib.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index e46d29889e9..b8bb8a153b4 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1525,7 +1525,17 @@ _mesa_PopClientAttrib(void) if (head->Mask & GL_CLIENT_VERTEX_ARRAY_BIT) { restore_array_attrib(ctx, &ctx->Array, &head->Array); - _mesa_unbind_array_object_vbos(ctx, &head->VAO); + + /* _mesa_unbind_array_object_vbos can't use NonDefaultStateMask because + * it's used by internal VAOs which don't always update the mask, so do + * it manually here. + */ + GLbitfield mask = head->VAO.NonDefaultStateMask; + while (mask) { + unsigned i = u_bit_scan(&mask); + _mesa_reference_buffer_object(ctx, &head->VAO.BufferBinding[i].BufferObj, NULL); + } + _mesa_reference_buffer_object(ctx, &head->VAO.IndexBufferObj, NULL); _mesa_reference_buffer_object(ctx, &head->Array.ArrayBufferObj, NULL); }