Mesa (main): mesa: move setting USAGE_PIXEL_PACK_BUFFER out of BindBuffer to reduce overhead

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Oct 25 20:19:54 UTC 2021


Module: Mesa
Branch: main
Commit: 2f059b861e0d0f3e44d9f97d5f08fbb9ba19dc26
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f059b861e0d0f3e44d9f97d5f08fbb9ba19dc26

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Tue Oct 19 23:48:51 2021 -0400

mesa: move setting USAGE_PIXEL_PACK_BUFFER out of BindBuffer to reduce overhead

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13513>

---

 src/mesa/main/bufferobj.c   | 4 ----
 src/mesa/main/pixel.c       | 9 +++++++++
 src/mesa/main/polygon.c     | 3 +++
 src/mesa/main/readpix.c     | 3 +++
 src/mesa/main/texgetimage.c | 6 ++++++
 5 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 7dcf38a3075..4af6e1d3f1a 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1127,10 +1127,6 @@ bind_buffer_object(struct gl_context *ctx,
       if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
                                         &newBufObj, "glBindBuffer"))
          return;
-
-      /* record usage history */
-      if (bindTarget == &ctx->Pack.BufferObj)
-         newBufObj->UsageHistory |= USAGE_PIXEL_PACK_BUFFER;
    }
 
    /* bind new buffer */
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index ffa362f297d..9553b44e447 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -343,6 +343,9 @@ _mesa_GetnPixelMapfvARB( GLenum map, GLsizei bufSize, GLfloat *values )
       return;
    }
 
+   if (ctx->Pack.BufferObj)
+      ctx->Pack.BufferObj->UsageHistory |= USAGE_PIXEL_PACK_BUFFER;
+
    values = (GLfloat *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values);
    if (!values) {
       if (ctx->Pack.BufferObj) {
@@ -392,6 +395,9 @@ _mesa_GetnPixelMapuivARB( GLenum map, GLsizei bufSize, GLuint *values )
       return;
    }
 
+   if (ctx->Pack.BufferObj)
+      ctx->Pack.BufferObj->UsageHistory |= USAGE_PIXEL_PACK_BUFFER;
+
    values = (GLuint *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values);
    if (!values) {
       if (ctx->Pack.BufferObj) {
@@ -441,6 +447,9 @@ _mesa_GetnPixelMapusvARB( GLenum map, GLsizei bufSize, GLushort *values )
       return;
    }
 
+   if (ctx->Pack.BufferObj)
+      ctx->Pack.BufferObj->UsageHistory |= USAGE_PIXEL_PACK_BUFFER;
+
    values = (GLushort *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values);
    if (!values) {
       if (ctx->Pack.BufferObj) {
diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c
index bbba607ebe4..d961e7a2c72 100644
--- a/src/mesa/main/polygon.c
+++ b/src/mesa/main/polygon.c
@@ -294,6 +294,9 @@ _mesa_GetnPolygonStippleARB( GLsizei bufSize, GLubyte *dest )
    if (MESA_VERBOSE&VERBOSE_API)
       _mesa_debug(ctx, "glGetPolygonStipple\n");
 
+   if (ctx->Pack.BufferObj)
+      ctx->Pack.BufferObj->UsageHistory |= USAGE_PIXEL_PACK_BUFFER;
+
    dest = _mesa_map_validate_pbo_dest(ctx, 2,
                                       &ctx->Pack, 32, 32, 1,
                                       GL_COLOR_INDEX, GL_BITMAP,
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index f52474ca1af..4852cc0b2b4 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -1170,6 +1170,9 @@ read_pixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
       }
    }
 
+   if (ctx->Pack.BufferObj)
+      ctx->Pack.BufferObj->UsageHistory |= USAGE_PIXEL_PACK_BUFFER;
+
    ctx->Driver.ReadPixels(ctx, x, y, width, height,
                           format, type, &clippedPacking, pixels);
 }
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 0b8a031fbf0..de6caaed5a1 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -1428,6 +1428,9 @@ get_texture_image(struct gl_context *ctx,
       numFaces = 1;
    }
 
+   if (ctx->Pack.BufferObj)
+      ctx->Pack.BufferObj->UsageHistory |= USAGE_PIXEL_PACK_BUFFER;
+
    _mesa_lock_texture(ctx, texObj);
 
    for (i = 0; i < numFaces; i++) {
@@ -1804,6 +1807,9 @@ get_compressed_texture_image(struct gl_context *ctx,
       numFaces = 1;
    }
 
+   if (ctx->Pack.BufferObj)
+      ctx->Pack.BufferObj->UsageHistory |= USAGE_PIXEL_PACK_BUFFER;
+
    _mesa_lock_texture(ctx, texObj);
 
    for (i = 0; i < numFaces; i++) {



More information about the mesa-commit mailing list