Mesa (main): st/mesa: always use PIPE_USAGE_STAGING for GL_MAP_READ_BIT usage

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 20 10:14:09 UTC 2021


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Tue Jul 20 05:23:25 2021 -0400

st/mesa: always use PIPE_USAGE_STAGING for GL_MAP_READ_BIT usage

This fixes CPU read performance.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5091
Cc: mesa-stable at lists.freedesktop.org

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

---

 src/mesa/state_tracker/st_cb_bufferobjects.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 2fd5aeef152..fdb1ec69a67 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -250,16 +250,20 @@ static enum pipe_resource_usage
 buffer_usage(GLenum target, GLboolean immutable,
              GLbitfield storageFlags, GLenum usage)
 {
+   /* "immutable" means that "storageFlags" was set by the user and "usage"
+    * was guessed by Mesa. Otherwise, "usage" was set by the user and
+    * storageFlags was guessed by Mesa.
+    *
+    * Therefore, use storageFlags with immutable, else use "usage".
+    */
    if (immutable) {
       /* BufferStorage */
-      if (storageFlags & GL_CLIENT_STORAGE_BIT) {
-         if (storageFlags & GL_MAP_READ_BIT)
-            return PIPE_USAGE_STAGING;
-         else
-            return PIPE_USAGE_STREAM;
-      } else {
+      if (storageFlags & GL_MAP_READ_BIT)
+         return PIPE_USAGE_STAGING;
+      else if (storageFlags & GL_CLIENT_STORAGE_BIT)
+         return PIPE_USAGE_STREAM;
+      else
          return PIPE_USAGE_DEFAULT;
-      }
    }
    else {
       /* These are often read by the CPU, so enable CPU caches. */



More information about the mesa-commit mailing list