mesa: Track buffer object use also for VAO usage.
authorMathias Fröhlich <mathias.froehlich@web.de>
Fri, 21 Dec 2018 17:41:27 +0000 (18:41 +0100)
committerMathias Fröhlich <Mathias.Froehlich@gmx.net>
Mon, 4 Mar 2019 16:03:06 +0000 (17:03 +0100)
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 <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
src/mesa/main/arrayobj.c
src/mesa/main/bufferobj.c
src/mesa/main/mtypes.h
src/mesa/main/varray.c

index bfd6fce6798fe3def88b03a627ce57608887e2f4..68d30aa9b1f204af5f2180b23922770ac1207a22 100644 (file)
@@ -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);
+   }
 }
 
 
index f9e52942d47564c87677f2c0d23369e66b205d1e..3caf363b37fbb2c197da0d7995eafc0055406402 100644 (file)
@@ -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;
index 9bca5c153adcdf800149eb3cf418ecb5e537b227..96f30d4a4d52415fb80b9846fb00a718adc43428 100644 (file)
@@ -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;
 
 
index 5af5a7f773f5ed07b81ed9b6ba2922e71da39d86..e6057c7f88153f89bef530010a40e825d5794cb2 100644 (file)
@@ -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)