Mesa (staging/19.2): broadcom/v3d: Allow importing linear BOs with arbitrary offset/stride.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Sep 5 22:17:26 UTC 2019
Module: Mesa
Branch: staging/19.2
Commit: 5e72987777ad4f451126a89715976b93bf6aaae2
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5e72987777ad4f451126a89715976b93bf6aaae2
Author: Dave Stevenson <dave.stevenson at raspberrypi.org>
Date: Wed May 22 17:12:56 2019 +0100
broadcom/v3d: Allow importing linear BOs with arbitrary offset/stride.
Equivalent of 0c1dd9dee "broadcom/vc4: Allow importing linear BOs with
arbitrary offset/stride." for v3d.
Allows YUV buffers with a single buffer and plane offsets to be
passed in.
Signed-off-by: Dave Stevenson <dave.stevenson at raspberrypi.org>
Reviewed-by: Eric Anholt <eric at anholt.net>
(cherry picked from commit 873b092e9110a0605293db7bc1c5bcb749cf9a28)
---
src/gallium/drivers/v3d/v3d_resource.c | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/src/gallium/drivers/v3d/v3d_resource.c b/src/gallium/drivers/v3d/v3d_resource.c
index 064709dff12..c2590fac1e5 100644
--- a/src/gallium/drivers/v3d/v3d_resource.c
+++ b/src/gallium/drivers/v3d/v3d_resource.c
@@ -842,13 +842,6 @@ v3d_resource_from_handle(struct pipe_screen *pscreen,
goto fail;
}
- if (whandle->offset != 0) {
- fprintf(stderr,
- "Attempt to import unsupported winsys offset %u\n",
- whandle->offset);
- goto fail;
- }
-
switch (whandle->type) {
case WINSYS_HANDLE_TYPE_SHARED:
rsc->bo = v3d_bo_open_name(screen, whandle->handle);
@@ -871,6 +864,26 @@ v3d_resource_from_handle(struct pipe_screen *pscreen,
v3d_setup_slices(rsc, whandle->stride, true);
v3d_debug_resource_layout(rsc, "import");
+ if (whandle->offset != 0) {
+ if (rsc->tiled) {
+ fprintf(stderr,
+ "Attempt to import unsupported winsys offset %u\n",
+ whandle->offset);
+ goto fail;
+ }
+ rsc->slices[0].offset += whandle->offset;
+
+ if (rsc->slices[0].offset + rsc->slices[0].size >
+ rsc->bo->size) {
+ fprintf(stderr, "Attempt to import "
+ "with overflowing offset (%d + %d > %d)\n",
+ whandle->offset,
+ rsc->slices[0].size,
+ rsc->bo->size);
+ goto fail;
+ }
+ }
+
if (screen->ro) {
/* Make sure that renderonly has a handle to our buffer in the
* display's fd, so that a later renderonly_get_handle()
@@ -886,7 +899,7 @@ v3d_resource_from_handle(struct pipe_screen *pscreen,
}
}
- if (whandle->stride != slice->stride) {
+ if (rsc->tiled && whandle->stride != slice->stride) {
static bool warned = false;
if (!warned) {
warned = true;
@@ -899,6 +912,8 @@ v3d_resource_from_handle(struct pipe_screen *pscreen,
slice->stride);
}
goto fail;
+ } else if (!rsc->tiled) {
+ slice->stride = whandle->stride;
}
return prsc;
More information about the mesa-commit
mailing list