From: Mathias Fröhlich Date: Fri, 21 Dec 2018 17:41:27 +0000 (+0100) Subject: mesa: Track buffer object use also for VAO usage. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e727f8c8b814b9c36d4a8b52829c2bf7281765be;p=mesa.git mesa: Track buffer object use also for VAO usage. We already track the usage history for buffer objects in a lot of aspects. Add GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER to gl_buffer_object::UsageHistory. Reviewed-by: Brian Paul Signed-off-by: Mathias Fröhlich --- diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index bfd6fce6798..68d30aa9b1f 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -1213,8 +1213,10 @@ vertex_array_element_buffer(struct gl_context *ctx, GLuint vaobj, GLuint buffer, bufObj = ctx->Shared->NullBufferObj; } - if (bufObj) + if (bufObj) { + bufObj->UsageHistory |= USAGE_ELEMENT_ARRAY_BUFFER; _mesa_reference_buffer_object(ctx, &vao->IndexBufferObj, bufObj); + } } diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index f9e52942d47..3caf363b37f 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -113,8 +113,13 @@ get_buffer_target(struct gl_context *ctx, GLenum target) switch (target) { case GL_ARRAY_BUFFER_ARB: + if (ctx->Array.ArrayBufferObj) + ctx->Array.ArrayBufferObj->UsageHistory |= USAGE_ARRAY_BUFFER; return &ctx->Array.ArrayBufferObj; case GL_ELEMENT_ARRAY_BUFFER_ARB: + if (ctx->Array.VAO->IndexBufferObj) + ctx->Array.VAO->IndexBufferObj->UsageHistory + |= USAGE_ELEMENT_ARRAY_BUFFER; return &ctx->Array.VAO->IndexBufferObj; case GL_PIXEL_PACK_BUFFER_EXT: return &ctx->Pack.BufferObj; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 9bca5c153ad..96f30d4a4d5 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1339,7 +1339,9 @@ typedef enum USAGE_SHADER_STORAGE_BUFFER = 0x8, USAGE_TRANSFORM_FEEDBACK_BUFFER = 0x10, USAGE_PIXEL_PACK_BUFFER = 0x20, - USAGE_DISABLE_MINMAX_CACHE = 0x40, + USAGE_ARRAY_BUFFER = 0x40, + USAGE_ELEMENT_ARRAY_BUFFER = 0x80, + USAGE_DISABLE_MINMAX_CACHE = 0x100, } gl_buffer_usage; diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 5af5a7f773f..e6057c7f881 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -209,10 +209,12 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx, binding->Offset = offset; binding->Stride = stride; - if (!_mesa_is_bufferobj(vbo)) + if (!_mesa_is_bufferobj(vbo)) { vao->VertexAttribBufferMask &= ~binding->_BoundArrays; - else + } else { vao->VertexAttribBufferMask |= binding->_BoundArrays; + vbo->UsageHistory |= USAGE_ARRAY_BUFFER; + } vao->NewArrays |= vao->Enabled & binding->_BoundArrays; if (vao == ctx->Array.VAO)