Mesa (staging/21.3): llvmpipe: fix userptr for texture resources.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Oct 18 20:57:13 UTC 2021
Module: Mesa
Branch: staging/21.3
Commit: d92abcfdd29a10b0ecdbd66b86bd82f56278157c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d92abcfdd29a10b0ecdbd66b86bd82f56278157c
Author: Dave Airlie <airlied at gmail.com>
Date: Wed Oct 13 14:49:50 2021 +1000
llvmpipe: fix userptr for texture resources.
This is needed for CL image hostptr support, but it's possible
it could hit these paths from GL/Vulkan
Fixes: 9a57dceeb760 ("llvmpipe: add support for user memory pointers")
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13375>
(cherry picked from commit 17a565e0cfb79fb8078fcf7f7cc7b6be0ef887ba)
---
.pick_status.json | 2 +-
src/gallium/drivers/llvmpipe/lp_texture.c | 21 ++++++++++++++-------
src/gallium/drivers/llvmpipe/lp_texture.h | 2 +-
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 826aca6950a..add427b9333 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -373,7 +373,7 @@
"description": "llvmpipe: fix userptr for texture resources.",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": "9a57dceeb760a1d4f7d9d1666bec0844ee41852e"
},
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index d303e8abbd5..5bfc8dbc973 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -440,7 +440,7 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen,
struct llvmpipe_screen *screen = llvmpipe_screen(pscreen);
struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
- if (!lpr->backable) {
+ if (!lpr->backable && !lpr->user_ptr) {
if (lpr->dt) {
/* display target */
struct sw_winsys *winsys = screen->winsys;
@@ -454,11 +454,9 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen,
lpr->tex_data = NULL;
}
}
- else if (!lpr->userBuffer) {
- if (lpr->data) {
+ else if (lpr->data) {
if (!lpr->imported_memory)
align_free(lpr->data);
- }
}
}
#ifdef DEBUG
@@ -651,9 +649,18 @@ llvmpipe_resource_from_user_memory(struct pipe_screen *_screen,
pipe_reference_init(&lpr->base.reference, 1);
lpr->base.screen = _screen;
- lpr->data = user_memory;
- lpr->userBuffer = TRUE;
+ if (llvmpipe_resource_is_texture(&lpr->base)) {
+ if (!llvmpipe_texture_layout(screen, lpr, false))
+ goto fail;
+
+ lpr->tex_data = user_memory;
+ } else
+ lpr->data = user_memory;
+ lpr->user_ptr = true;
return &lpr->base;
+fail:
+ FREE(lpr);
+ return NULL;
}
void *
@@ -875,7 +882,7 @@ llvmpipe_user_buffer_create(struct pipe_screen *screen,
buffer->base.height0 = 1;
buffer->base.depth0 = 1;
buffer->base.array_size = 1;
- buffer->userBuffer = TRUE;
+ buffer->user_ptr = true;
buffer->data = ptr;
return &buffer->base;
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h
index eabfbeca8f0..c683cdd1e03 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.h
+++ b/src/gallium/drivers/llvmpipe/lp_texture.h
@@ -89,7 +89,7 @@ struct llvmpipe_resource
*/
void *data;
- boolean userBuffer; /** Is this a user-space buffer? */
+ bool user_ptr; /** Is this a user-space buffer? */
unsigned timestamp;
unsigned id; /**< temporary, for debugging */
More information about the mesa-commit
mailing list