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@lists.freedesktop.org

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11974>
This commit is contained in:
Marek Olšák
2021-07-20 05:23:25 -04:00
committed by Marge Bot
parent 5bfd1a7e19
commit 54e1ec017d

View File

@@ -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. */