All of lore.kernel.org
 help / color / mirror / Atom feed
* [OE-core][PATCH] mesa: Fix v3d & vc4 dmabuf import
@ 2021-07-27 17:24 Joshua Watt
  0 siblings, 0 replies; only message in thread
From: Joshua Watt @ 2021-07-27 17:24 UTC (permalink / raw)
  To: openembedded-core; +Cc: Joshua Watt

Mesa would unnecessarily fail in the v3d and vc4 driver if a dmabuf
could not imported for scanout. In particular, this meant the
weston-simple-dmabuf-egl test program would fail on a Raspberry Pi.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 ...mabuf-import-for-non-scanout-buffers.patch | 72 +++++++++++++++++++
 meta/recipes-graphics/mesa/mesa.inc           |  1 +
 2 files changed, 73 insertions(+)
 create mode 100644 meta/recipes-graphics/mesa/files/0001-v3d-vc4-Fix-dmabuf-import-for-non-scanout-buffers.patch

diff --git a/meta/recipes-graphics/mesa/files/0001-v3d-vc4-Fix-dmabuf-import-for-non-scanout-buffers.patch b/meta/recipes-graphics/mesa/files/0001-v3d-vc4-Fix-dmabuf-import-for-non-scanout-buffers.patch
new file mode 100644
index 0000000000..1a8771028b
--- /dev/null
+++ b/meta/recipes-graphics/mesa/files/0001-v3d-vc4-Fix-dmabuf-import-for-non-scanout-buffers.patch
@@ -0,0 +1,72 @@
+From 303c02a31df4e2b8f6090e75982922a9cba33e4c Mon Sep 17 00:00:00 2001
+From: Joshua Watt <JPEWhacker@gmail.com>
+Date: Tue, 27 Jul 2021 11:41:53 -0500
+Subject: [PATCH] v3d, vc4: Fix dmabuf import for non-scanout buffers
+
+Failure to create a buffer for scanout should not be fatal when
+importing a buffer. Buffers allocated from a render-only device may not
+be able to scanned out directly but can still be used for other
+rendering purposes (e.g. as a texture).
+
+Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
+Upstream-Status: Submitted [https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12081]
+---
+ src/gallium/drivers/v3d/v3d_resource.c | 13 +++++--------
+ src/gallium/drivers/vc4/vc4_resource.c |  3 ---
+ 2 files changed, 5 insertions(+), 11 deletions(-)
+
+diff --git a/src/gallium/drivers/v3d/v3d_resource.c b/src/gallium/drivers/v3d/v3d_resource.c
+index 602ba6d8447..02dc29ae6a0 100644
+--- a/src/gallium/drivers/v3d/v3d_resource.c
++++ b/src/gallium/drivers/v3d/v3d_resource.c
+@@ -433,10 +433,11 @@ v3d_resource_get_handle(struct pipe_screen *pscreen,
+                 return v3d_bo_flink(bo, &whandle->handle);
+         case WINSYS_HANDLE_TYPE_KMS:
+                 if (screen->ro) {
+-                        assert(rsc->scanout);
+-                        bool ok = renderonly_get_handle(rsc->scanout, whandle);
+-                        whandle->stride = rsc->slices[0].stride;
+-                        return ok;
++                        if (renderonly_get_handle(rsc->scanout, whandle)) {
++                                whandle->stride = rsc->slices[0].stride;
++                                return true;
++                        }
++                        return false;
+                 }
+                 whandle->handle = bo->handle;
+                 return true;
+@@ -929,10 +930,6 @@ v3d_resource_from_handle(struct pipe_screen *pscreen,
+                         renderonly_create_gpu_import_for_resource(prsc,
+                                                                   screen->ro,
+                                                                   NULL);
+-                if (!rsc->scanout) {
+-                        fprintf(stderr, "Failed to create scanout resource.\n");
+-                        goto fail;
+-                }
+         }
+ 
+         if (rsc->tiled && whandle->stride != slice->stride) {
+diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c
+index 61e5fd7e5a6..bf3f7656ff8 100644
+--- a/src/gallium/drivers/vc4/vc4_resource.c
++++ b/src/gallium/drivers/vc4/vc4_resource.c
+@@ -320,7 +320,6 @@ vc4_resource_get_handle(struct pipe_screen *pscreen,
+                 return vc4_bo_flink(rsc->bo, &whandle->handle);
+         case WINSYS_HANDLE_TYPE_KMS:
+                 if (screen->ro) {
+-                        assert(rsc->scanout);
+                         return renderonly_get_handle(rsc->scanout, whandle);
+                 }
+                 whandle->handle = rsc->bo->handle;
+@@ -689,8 +688,6 @@ vc4_resource_from_handle(struct pipe_screen *pscreen,
+                         renderonly_create_gpu_import_for_resource(prsc,
+                                                                   screen->ro,
+                                                                   NULL);
+-                if (!rsc->scanout)
+-                        goto fail;
+         }
+ 
+         if (rsc->tiled && whandle->stride != slice->stride) {
+-- 
+2.32.0
+
diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
index 6a0df4fa2e..85a352f736 100644
--- a/meta/recipes-graphics/mesa/mesa.inc
+++ b/meta/recipes-graphics/mesa/mesa.inc
@@ -19,6 +19,7 @@ SRC_URI = "https://mesa.freedesktop.org/archive/mesa-${PV}.tar.xz \
            file://0002-meson.build-make-TLS-ELF-optional.patch \
            file://0001-meson-misdetects-64bit-atomics-on-mips-clang.patch \
            file://0001-futex.h-Define-__NR_futex-if-it-does-not-exist.patch \
+           file://0001-v3d-vc4-Fix-dmabuf-import-for-non-scanout-buffers.patch \
            "
 
 SRC_URI[sha256sum] = "022c7293074aeeced2278c872db4fa693147c70f8595b076cf3f1ef81520766d"
-- 
2.32.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-27 17:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-27 17:24 [OE-core][PATCH] mesa: Fix v3d & vc4 dmabuf import Joshua Watt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.