+++ /dev/null
-From afd8b2f498a417de6ecdbd13045d97c9ecf4391b Mon Sep 17 00:00:00 2001
-From: Simon Ser <contact@emersion.fr>
-Date: Mon, 14 Dec 2020 18:32:47 +0100
-Subject: [PATCH] dri: add createImageWithModifiers2 interface
-
-With the addition of createImageWithModifiers usage flags were
-dropped, as it was believed at the time that modifers will be a
-full replacement for the usage flags. This has turned out to be
-untrue, as modifiers are not able to describe buffer placement.
-
-Add a new version of the interface, that allows to specifiy
-use flags in addition to the modifier.
-
-Signed-off-by: Simon Ser <contact@emersion.fr>
-Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-Reviewed-by: Daniel Stone <daniels@collabora.com>
-Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8106>
-Upstream-Status: Applied [https://gitlab.freedesktop.org/mesa/mesa/-/commit/afd8b2f498a417de6ecdbd13045d97c9ecf4391b]
----
- include/GL/internal/dri_interface.h | 24 +++++++++++++++++++++++-
- 1 file changed, 23 insertions(+), 1 deletion(-)
-
-diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
-index 9b85e67ce49..a7d9903f94e 100644
---- a/include/GL/internal/dri_interface.h
-+++ b/include/GL/internal/dri_interface.h
-@@ -1328,7 +1328,7 @@ struct __DRIdri2ExtensionRec {
- * extensions.
- */
- #define __DRI_IMAGE "DRI_IMAGE"
--#define __DRI_IMAGE_VERSION 18
-+#define __DRI_IMAGE_VERSION 19
-
- /**
- * These formats correspond to the similarly named MESA_FORMAT_*
-@@ -1803,6 +1803,28 @@ struct __DRIimageExtensionRec {
- uint32_t flags,
- unsigned *error,
- void *loaderPrivate);
-+
-+ /**
-+ * Creates an image with implementation's favorite modifiers and the
-+ * provided usage flags.
-+ *
-+ * This acts like createImageWithModifiers except usage is also specified.
-+ *
-+ * The created image should be destroyed with destroyImage().
-+ *
-+ * Returns the new DRIimage. The chosen modifier can be obtained later on
-+ * and passed back to things like the kernel's AddFB2 interface.
-+ *
-+ * \sa __DRIimageRec::createImage
-+ *
-+ * \since 19
-+ */
-+ __DRIimage *(*createImageWithModifiers2)(__DRIscreen *screen,
-+ int width, int height, int format,
-+ const uint64_t *modifiers,
-+ const unsigned int modifier_count,
-+ unsigned int use,
-+ void *loaderPrivate);
- };
-
-
---
-2.31.1
-
+++ /dev/null
-From cb9ae4273d680ab34fc2ca933c4f960e7f086275 Mon Sep 17 00:00:00 2001
-From: Lucas Stach <l.stach@pengutronix.de>
-Date: Tue, 15 Dec 2020 14:39:32 +0100
-Subject: [PATCH] dri: add loader_dri_create_image helper
-
-The DRI image extension already has two different ways to allocate an
-image (with and without a modifier) and will soon grow a third one.
-Add a helper, which handles calling the appropriate implementation to
-get rid of code duplication in the winsys.
-
-This convert the two obvious call sites (GBM dri and EGL wayland)
-that profit from the code dedup.
-
-Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-Reviewed-by: Daniel Stone <daniels@collabora.com>
-Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8106>
-Upstream-Status: Applied [https://gitlab.freedesktop.org/mesa/mesa/-/commit/cb9ae4273d680ab34fc2ca933c4f960e7f086275]
----
- src/egl/drivers/dri2/platform_wayland.c | 60 +++++++---------------
- src/gbm/backends/dri/gbm_dri.c | 53 +++++--------------
- src/loader/Makefile.sources | 2 +
- src/loader/loader_dri_helper.c | 68 +++++++++++++++++++++++++
- src/loader/loader_dri_helper.h | 33 ++++++++++++
- src/loader/meson.build | 2 +-
- 6 files changed, 134 insertions(+), 84 deletions(-)
- create mode 100644 src/loader/loader_dri_helper.c
- create mode 100644 src/loader/loader_dri_helper.h
-
-diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
-index 26b6711952c..180380b4c4c 100644
---- a/src/egl/drivers/dri2/platform_wayland.c
-+++ b/src/egl/drivers/dri2/platform_wayland.c
-@@ -40,6 +40,7 @@
- #include <sys/mman.h>
-
- #include "egl_dri2.h"
-+#include "loader_dri_helper.h"
- #include "loader.h"
- #include "util/u_vector.h"
- #include "util/anon_file.h"
-@@ -578,28 +579,16 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
- dri2_surf->back->linear_copy == NULL) {
- /* The LINEAR modifier should be a perfect alias of the LINEAR use
- * flag; try the new interface first before the old, then fall back. */
-- if (dri2_dpy->image->base.version >= 15 &&
-- dri2_dpy->image->createImageWithModifiers) {
-- uint64_t linear_mod = DRM_FORMAT_MOD_LINEAR;
--
-- dri2_surf->back->linear_copy =
-- dri2_dpy->image->createImageWithModifiers(dri2_dpy->dri_screen,
-- dri2_surf->base.Width,
-- dri2_surf->base.Height,
-- linear_dri_image_format,
-- &linear_mod,
-- 1,
-- NULL);
-- } else {
-- dri2_surf->back->linear_copy =
-- dri2_dpy->image->createImage(dri2_dpy->dri_screen,
-- dri2_surf->base.Width,
-- dri2_surf->base.Height,
-- linear_dri_image_format,
-- use_flags |
-- __DRI_IMAGE_USE_LINEAR,
-- NULL);
-- }
-+ uint64_t linear_mod = DRM_FORMAT_MOD_LINEAR;
-+
-+ dri2_surf->back->linear_copy =
-+ loader_dri_create_image(dri2_dpy->dri_screen, dri2_dpy->image,
-+ dri2_surf->base.Width,
-+ dri2_surf->base.Height,
-+ linear_dri_image_format,
-+ use_flags | __DRI_IMAGE_USE_LINEAR,
-+ &linear_mod, 1, NULL);
-+
- if (dri2_surf->back->linear_copy == NULL)
- return -1;
- }
-@@ -609,26 +598,13 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
- * createImageWithModifiers, then fall back to the old createImage,
- * and hope it allocates an image which is acceptable to the winsys.
- */
-- if (num_modifiers && dri2_dpy->image->base.version >= 15 &&
-- dri2_dpy->image->createImageWithModifiers) {
-- dri2_surf->back->dri_image =
-- dri2_dpy->image->createImageWithModifiers(dri2_dpy->dri_screen,
-- dri2_surf->base.Width,
-- dri2_surf->base.Height,
-- dri_image_format,
-- modifiers,
-- num_modifiers,
-- NULL);
-- } else {
-- dri2_surf->back->dri_image =
-- dri2_dpy->image->createImage(dri2_dpy->dri_screen,
-- dri2_surf->base.Width,
-- dri2_surf->base.Height,
-- dri_image_format,
-- dri2_dpy->is_different_gpu ?
-- 0 : use_flags,
-- NULL);
-- }
-+ dri2_surf->back->dri_image =
-+ loader_dri_create_image(dri2_dpy->dri_screen, dri2_dpy->image,
-+ dri2_surf->base.Width,
-+ dri2_surf->base.Height,
-+ dri_image_format,
-+ dri2_dpy->is_different_gpu ? 0 : use_flags,
-+ modifiers, num_modifiers, NULL);
-
- dri2_surf->back->age = 0;
- }
-diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
-index 751b2e56497..dff0b3c7ecf 100644
---- a/src/gbm/backends/dri/gbm_dri.c
-+++ b/src/gbm/backends/dri/gbm_dri.c
-@@ -47,6 +47,7 @@
- #include "gbm_driint.h"
-
- #include "gbmint.h"
-+#include "loader_dri_helper.h"
- #include "loader.h"
- #include "util/debug.h"
- #include "util/macros.h"
-@@ -1151,8 +1152,7 @@ gbm_dri_bo_create(struct gbm_device *gbm,
- struct gbm_dri_device *dri = gbm_dri_device(gbm);
- struct gbm_dri_bo *bo;
- int dri_format;
-- unsigned dri_use = 0, i;
-- bool has_valid_modifier;
-+ unsigned dri_use = 0;
-
- /* Callers of this may specify a modifier, or a dri usage, but not both. The
- * newer modifier interface deprecates the older usage flags.
-@@ -1191,50 +1191,21 @@ gbm_dri_bo_create(struct gbm_device *gbm,
- /* Gallium drivers requires shared in order to get the handle/stride */
- dri_use |= __DRI_IMAGE_USE_SHARE;
-
-- if (modifiers) {
-- if (!dri->image || dri->image->base.version < 14 ||
-- !dri->image->createImageWithModifiers) {
-- errno = ENOSYS;
-- goto failed;
-- }
--
-- /* It's acceptable to create an image with INVALID modifier in the list,
-- * but it cannot be on the only modifier (since it will certainly fail
-- * later). While we could easily catch this after modifier creation, doing
-- * the check here is a convenient debug check likely pointing at whatever
-- * interface the client is using to build its modifier list.
-- */
-- has_valid_modifier = false;
-- for (i = 0; i < count; i++) {
-- if (modifiers[i] != DRM_FORMAT_MOD_INVALID) {
-- has_valid_modifier = true;
-- break;
-- }
-- }
-- if (!has_valid_modifier) {
-- errno = EINVAL;
-- goto failed;
-- }
--
-- bo->image =
-- dri->image->createImageWithModifiers(dri->screen,
-- width, height,
-- dri_format,
-- modifiers, count,
-- bo);
--
-- if (bo->image) {
-- /* The client passed in a list of invalid modifiers */
-- assert(gbm_dri_bo_get_modifier(&bo->base) != DRM_FORMAT_MOD_INVALID);
-- }
-- } else {
-- bo->image = dri->image->createImage(dri->screen, width, height,
-- dri_format, dri_use, bo);
-+ if (modifiers && (dri->image->base.version < 14 ||
-+ !dri->image->createImageWithModifiers)) {
-+ errno = ENOSYS;
-+ return NULL;
- }
-
-+ bo->image = loader_dri_create_image(dri->screen, dri->image, width, height,
-+ dri_format, dri_use, modifiers, count,
-+ bo);
- if (bo->image == NULL)
- goto failed;
-
-+ if (modifiers)
-+ assert(gbm_dri_bo_get_modifier(&bo->base) != DRM_FORMAT_MOD_INVALID);
-+
- dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_HANDLE,
- &bo->base.handle.s32);
- dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE,
-diff --git a/src/loader/Makefile.sources b/src/loader/Makefile.sources
-index b61ef1cd943..6627222ac30 100644
---- a/src/loader/Makefile.sources
-+++ b/src/loader/Makefile.sources
-@@ -1,4 +1,6 @@
- LOADER_C_FILES := \
-+ loader_dri_helper.c \
-+ loader_dri_helper.h \
- loader.c \
- loader.h \
- pci_id_driver_map.c \
-diff --git a/src/loader/loader_dri_helper.c b/src/loader/loader_dri_helper.c
-new file mode 100644
-index 00000000000..21419f087d6
---- /dev/null
-+++ b/src/loader/loader_dri_helper.c
-@@ -0,0 +1,68 @@
-+/*
-+ * Permission to use, copy, modify, distribute, and sell this software and its
-+ * documentation for any purpose is hereby granted without fee, provided that
-+ * the above copyright notice appear in all copies and that both that copyright
-+ * notice and this permission notice appear in supporting documentation, and
-+ * that the name of the copyright holders not be used in advertising or
-+ * publicity pertaining to distribution of the software without specific,
-+ * written prior permission. The copyright holders make no representations
-+ * about the suitability of this software for any purpose. It is provided "as
-+ * is" without express or implied warranty.
-+ *
-+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
-+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
-+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
-+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
-+ * OF THIS SOFTWARE.
-+ */
-+
-+#include <errno.h>
-+#include <stdbool.h>
-+#include <stdio.h>
-+#include <sys/types.h>
-+
-+#include <GL/gl.h> /* dri_interface needs GL types */
-+#include <GL/internal/dri_interface.h>
-+
-+#include "drm-uapi/drm_fourcc.h"
-+#include "loader_dri_helper.h"
-+
-+__DRIimage *loader_dri_create_image(__DRIscreen *screen,
-+ const __DRIimageExtension *image,
-+ uint32_t width, uint32_t height,
-+ uint32_t dri_format, uint32_t dri_usage,
-+ const uint64_t *modifiers,
-+ unsigned int modifiers_count,
-+ void *loaderPrivate)
-+{
-+ if (modifiers &&
-+ image->base.version > 14 && image->createImageWithModifiers) {
-+ bool has_valid_modifier = false;
-+ int i;
-+
-+ /* It's acceptable to create an image with INVALID modifier in the list,
-+ * but it cannot be on the only modifier (since it will certainly fail
-+ * later). While we could easily catch this after modifier creation, doing
-+ * the check here is a convenient debug check likely pointing at whatever
-+ * interface the client is using to build its modifier list.
-+ */
-+ for (i = 0; i < modifiers_count; i++) {
-+ if (modifiers[i] != DRM_FORMAT_MOD_INVALID) {
-+ has_valid_modifier = true;
-+ break;
-+ }
-+ }
-+ if (!has_valid_modifier)
-+ return NULL;
-+
-+ return image->createImageWithModifiers(screen, width, height,
-+ dri_format, modifiers,
-+ modifiers_count, loaderPrivate);
-+ }
-+
-+ /* No modifier given or fallback to the legacy createImage allowed */
-+ return image->createImage(screen, width, height, dri_format, dri_usage,
-+ loaderPrivate);
-+}
-diff --git a/src/loader/loader_dri_helper.h b/src/loader/loader_dri_helper.h
-new file mode 100644
-index 00000000000..e0aae69477b
---- /dev/null
-+++ b/src/loader/loader_dri_helper.h
-@@ -0,0 +1,33 @@
-+/*
-+ * Permission to use, copy, modify, distribute, and sell this software and its
-+ * documentation for any purpose is hereby granted without fee, provided that
-+ * the above copyright notice appear in all copies and that both that copyright
-+ * notice and this permission notice appear in supporting documentation, and
-+ * that the name of the copyright holders not be used in advertising or
-+ * publicity pertaining to distribution of the software without specific,
-+ * written prior permission. The copyright holders make no representations
-+ * about the suitability of this software for any purpose. It is provided "as
-+ * is" without express or implied warranty.
-+ *
-+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
-+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
-+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
-+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
-+ * OF THIS SOFTWARE.
-+ */
-+
-+#include <stdbool.h>
-+#include <sys/types.h>
-+
-+#include <GL/gl.h> /* dri_interface needs GL types */
-+#include <GL/internal/dri_interface.h>
-+
-+__DRIimage *loader_dri_create_image(__DRIscreen *screen,
-+ const __DRIimageExtension *image,
-+ uint32_t width, uint32_t height,
-+ uint32_t dri_format, uint32_t dri_usage,
-+ const uint64_t *modifiers,
-+ unsigned int modifiers_count,
-+ void *loaderPrivate);
-diff --git a/src/loader/meson.build b/src/loader/meson.build
-index 34a43e33f09..57a93c3aa17 100644
---- a/src/loader/meson.build
-+++ b/src/loader/meson.build
-@@ -47,7 +47,7 @@ endif
-
- libloader = static_library(
- 'loader',
-- ['loader.c', 'pci_id_driver_map.c'],
-+ ['loader_dri_helper.c', 'loader.c', 'pci_id_driver_map.c'],
- c_args : loader_c_args,
- gnu_symbol_visibility : 'hidden',
- include_directories : [inc_include, inc_src, inc_util],
---
-2.31.1
-
+++ /dev/null
-From 8fd5b16efc60ad666b05ec745109d0a482b6157b Mon Sep 17 00:00:00 2001
-From: Lucas Stach <l.stach@pengutronix.de>
-Date: Tue, 15 Dec 2020 14:52:28 +0100
-Subject: [PATCH] loader/dri3: convert to loader_dri_create_image
-
-Get rid of the code duplication and makes it easier to hook in a
-new createImageWithModifiers2, but obscures the code flow a bit.
-
-Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-Reviewed-by: Daniel Stone <daniels@collabora.com>
-Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8106>
-Upstream-Status: Applied [https://gitlab.freedesktop.org/mesa/mesa/-/commit/8fd5b16efc60ad666b05ec745109d0a482b6157b]
----
- src/loader/loader_dri3_helper.c | 40 ++++++++++-----------------------
- 1 file changed, 12 insertions(+), 28 deletions(-)
-
-diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
-index 6c4b704ae5b..c5e340e6942 100644
---- a/src/loader/loader_dri3_helper.c
-+++ b/src/loader/loader_dri3_helper.c
-@@ -34,6 +34,7 @@
-
- #include <X11/Xlib-xcb.h>
-
-+#include "loader_dri_helper.h"
- #include "loader_dri3_helper.h"
- #include "util/macros.h"
- #include "drm-uapi/drm_fourcc.h"
-@@ -1314,6 +1315,8 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format,
- struct xshmfence *shm_fence;
- int buffer_fds[4], fence_fd;
- int num_planes = 0;
-+ uint64_t *modifiers = NULL;
-+ uint32_t count = 0;
- int i, mod;
- int ret;
-
-@@ -1348,8 +1351,6 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format,
- xcb_dri3_get_supported_modifiers_cookie_t mod_cookie;
- xcb_dri3_get_supported_modifiers_reply_t *mod_reply;
- xcb_generic_error_t *error = NULL;
-- uint64_t *modifiers = NULL;
-- uint32_t count = 0;
-
- mod_cookie = xcb_dri3_get_supported_modifiers(draw->conn,
- draw->window,
-@@ -1395,34 +1396,17 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format,
- }
-
- free(mod_reply);
--
-- /* don't use createImageWithModifiers() if we have no
-- * modifiers, other things depend on the use flags when
-- * there are no modifiers to know that a buffer can be
-- * shared.
-- */
-- if (modifiers) {
-- buffer->image = draw->ext->image->createImageWithModifiers(draw->dri_screen,
-- width, height,
-- format,
-- modifiers,
-- count,
-- buffer);
-- }
--
-- free(modifiers);
- }
- #endif
-- if (!buffer->image)
-- buffer->image = draw->ext->image->createImage(draw->dri_screen,
-- width, height,
-- format,
-- __DRI_IMAGE_USE_SHARE |
-- __DRI_IMAGE_USE_SCANOUT |
-- __DRI_IMAGE_USE_BACKBUFFER |
-- (draw->is_protected_content ?
-- __DRI_IMAGE_USE_PROTECTED : 0),
-- buffer);
-+ buffer->image = loader_dri_create_image(draw->dri_screen, draw->ext->image,
-+ width, height, format,
-+ __DRI_IMAGE_USE_SHARE |
-+ __DRI_IMAGE_USE_SCANOUT |
-+ __DRI_IMAGE_USE_BACKBUFFER |
-+ (draw->is_protected_content ?
-+ __DRI_IMAGE_USE_PROTECTED : 0),
-+ modifiers, count, buffer);
-+ free(modifiers);
-
- pixmap_buffer = buffer->image;
-
---
-2.31.1
-
+++ /dev/null
-From c03e79d7831f253b16d6f52f2fb959eb02257a8b Mon Sep 17 00:00:00 2001
-From: Lucas Stach <l.stach@pengutronix.de>
-Date: Tue, 15 Dec 2020 14:59:21 +0100
-Subject: [PATCH] loader/dri: hook up createImageWithModifiers2
-
-Call into the new modifiers with usage createImage variant when available
-to provide the DRI implementation with more context about the allocation.
-
-Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-Reviewed-by: Daniel Stone <daniels@collabora.com>
-Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8106>
-Upstream-Status: Applied [https://gitlab.freedesktop.org/mesa/mesa/-/commit/c03e79d7831f253b16d6f52f2fb959eb02257a8b]
----
- src/loader/loader_dri_helper.c | 12 +++++++++---
- 1 file changed, 9 insertions(+), 3 deletions(-)
-
-diff --git a/src/loader/loader_dri_helper.c b/src/loader/loader_dri_helper.c
-index 21419f087d6..972ca2da26a 100644
---- a/src/loader/loader_dri_helper.c
-+++ b/src/loader/loader_dri_helper.c
-@@ -57,9 +57,15 @@ __DRIimage *loader_dri_create_image(__DRIscreen *screen,
- if (!has_valid_modifier)
- return NULL;
-
-- return image->createImageWithModifiers(screen, width, height,
-- dri_format, modifiers,
-- modifiers_count, loaderPrivate);
-+ if (image->base.version >= 19 && image->createImageWithModifiers2)
-+ return image->createImageWithModifiers2(screen, width, height,
-+ dri_format, modifiers,
-+ modifiers_count, dri_usage,
-+ loaderPrivate);
-+ else
-+ return image->createImageWithModifiers(screen, width, height,
-+ dri_format, modifiers,
-+ modifiers_count, loaderPrivate);
- }
-
- /* No modifier given or fallback to the legacy createImage allowed */
---
-2.31.1
-
+++ /dev/null
-From 3701cb9439058e71c1981bd80c5a9e1383815b08 Mon Sep 17 00:00:00 2001
-From: Lucas Stach <l.stach@pengutronix.de>
-Date: Fri, 13 Nov 2020 14:26:23 +0100
-Subject: [PATCH] gallium/dri: copy image use in dup_image
-
-Don't lose the use flags when dup'ing an image.
-
-Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-Reviewed-by: Daniel Stone <daniels@collabora.com>
-Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8106>
-Upstream-Status: Applied [https://gitlab.freedesktop.org/mesa/mesa/-/commit/3701cb9439058e71c1981bd80c5a9e1383815b08]
----
- src/gallium/frontends/dri/dri2.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c
-index 9999b31b022..08a9ed9693c 100644
---- a/src/gallium/frontends/dri/dri2.c
-+++ b/src/gallium/frontends/dri/dri2.c
-@@ -1326,6 +1326,7 @@ dri2_dup_image(__DRIimage *image, void *loaderPrivate)
- img->dri_format = image->dri_format;
- /* This should be 0 for sub images, but dup is also used for base images. */
- img->dri_components = image->dri_components;
-+ img->use = image->use;
- img->loader_private = loaderPrivate;
- img->sPriv = image->sPriv;
-
---
-2.31.1
-
+++ /dev/null
-From 77fcf700826d6637e4e407c73c209f3b1718a26e Mon Sep 17 00:00:00 2001
-From: Lucas Stach <l.stach@pengutronix.de>
-Date: Thu, 20 May 2021 18:07:12 +0200
-Subject: [PATCH] dri: don't call modifier interfaces when modifiers_count is 0
-
-The wayland EGL platform sets the modifier count to 0 in some cases
-to signal that modifiers should not be used, even if a list of modifiers
-is present. The loader_dri_create_image helper didn't handle this case
-properly and called the modifierful driver interface with a 0 modifier
-count, leading to the obvious outcome of the driver being unable to
-allocate an image.
-
-Fixes: cb9ae4273d68 ("dri: add loader_dri_create_image helper")
-Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10903>
-Upstream-Status: Applied [https://gitlab.freedesktop.org/mesa/mesa/-/commit/77fcf700826d6637e4e407c73c209f3b1718a26e]
----
- src/loader/loader_dri_helper.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/loader/loader_dri_helper.c b/src/loader/loader_dri_helper.c
-index 972ca2da26a..ff6ce35953f 100644
---- a/src/loader/loader_dri_helper.c
-+++ b/src/loader/loader_dri_helper.c
-@@ -37,7 +37,7 @@ __DRIimage *loader_dri_create_image(__DRIscreen *screen,
- unsigned int modifiers_count,
- void *loaderPrivate)
- {
-- if (modifiers &&
-+ if (modifiers && modifiers_count > 0 &&
- image->base.version > 14 && image->createImageWithModifiers) {
- bool has_valid_modifier = false;
- int i;
---
-2.31.1
-
+++ /dev/null
-From 3824429da0e0e68b78534b1e0ab7e386bcb2b2e2 Mon Sep 17 00:00:00 2001
-From: Lucas Stach <l.stach@pengutronix.de>
-Date: Fri, 13 Nov 2020 14:59:52 +0100
-Subject: [PATCH] frontend/dri: add EXPLICIT_FLUSH hint in
- dri2_resource_get_param
-
-dri2_resource_get_param() is called from two different places right now.
-Only one of them adds the EXPLICIT_FLUSH hint to the handle usage, which
-may disable the optimizations provided by this hint without a reason.
-
-Make sure to always add this hint when appropriate.
-
-Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7603>
-Upstream-Status: Applied [https://gitlab.freedesktop.org/mesa/mesa/-/commit/3824429da0e0e68b78534b1e0ab7e386bcb2b2e2]
----
- src/gallium/frontends/dri/dri2.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c
-index 0220513368e..8ed47c25825 100644
---- a/src/gallium/frontends/dri/dri2.c
-+++ b/src/gallium/frontends/dri/dri2.c
-@@ -1252,6 +1252,9 @@ dri2_resource_get_param(__DRIimage *image, enum pipe_resource_param param,
- if (!pscreen->resource_get_param)
- return false;
-
-+ if (image->use & __DRI_IMAGE_USE_BACKBUFFER)
-+ handle_usage |= PIPE_HANDLE_USAGE_EXPLICIT_FLUSH;
-+
- return pscreen->resource_get_param(pscreen, NULL, image->texture,
- image->plane, 0, 0, param, handle_usage,
- value);
-@@ -1296,9 +1299,6 @@ dri2_query_image_by_resource_param(__DRIimage *image, int attrib, int *value)
-
- handle_usage = PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE;
-
-- if (image->use & __DRI_IMAGE_USE_BACKBUFFER)
-- handle_usage |= PIPE_HANDLE_USAGE_EXPLICIT_FLUSH;
--
- if (!dri2_resource_get_param(image, param, handle_usage, &res_param))
- return false;
-
---
-2.31.1
-
+++ /dev/null
-From 1c539bbb06f318d2bd0f93701b532f77894e391d Mon Sep 17 00:00:00 2001
-From: Lucas Stach <l.stach@pengutronix.de>
-Date: Fri, 13 Nov 2020 15:03:37 +0100
-Subject: [PATCH] etnaviv: remove double assigment of surface->texture
-
-surf->base.texture is already assigned earlier via a proper
-pipe_resource_reference call. Remove the superfluous assignement.
-
-Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
-Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7603>
-Upstream-Status: Applied [https://gitlab.freedesktop.org/mesa/mesa/-/commit/1c539bbb06f318d2bd0f93701b532f77894e391d]
----
- src/gallium/drivers/etnaviv/etnaviv_surface.c | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/src/gallium/drivers/etnaviv/etnaviv_surface.c b/src/gallium/drivers/etnaviv/etnaviv_surface.c
-index c78973bdb09..52a937652d2 100644
---- a/src/gallium/drivers/etnaviv/etnaviv_surface.c
-+++ b/src/gallium/drivers/etnaviv/etnaviv_surface.c
-@@ -112,7 +112,6 @@ etna_create_surface(struct pipe_context *pctx, struct pipe_resource *prsc,
- etna_screen_resource_alloc_ts(pctx->screen, rsc);
- }
-
-- surf->base.texture = &rsc->base;
- surf->base.format = templat->format;
- surf->base.width = rsc->levels[level].width;
- surf->base.height = rsc->levels[level].height;
---
-2.31.1
-
+++ /dev/null
-From 7b9d8d1936d72af6fd1bfd30afed354bb76b4c0c Mon Sep 17 00:00:00 2001
-From: Lucas Stach <l.stach@pengutronix.de>
-Date: Fri, 13 Nov 2020 15:05:55 +0100
-Subject: [PATCH] etnaviv: flush used render buffers on context flush when
- neccessary
-
-Some resources like backbuffers are explicitly flushed by the frontend
-at the appropriate time, others however won't get flushed explicitly.
-Remember those resources when they get emitted as a render buffer and
-flush them on a context flush to make their content visible to other
-entities sharing the buffer.
-
-We still keep the optimized path for most resources where the frontend
-promises to do the flushing for us and only enable implicit flushing
-when a buffer handle is exported/imported without the
-PIPE_HANDLE_USAGE_EXPLICIT_FLUSH flag set.
-
-Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
-Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
-Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7603>
-Upstream-Status: Applied [https://gitlab.freedesktop.org/mesa/mesa/-/commit/7b9d8d1936d72af6fd1bfd30afed354bb76b4c0c]
----
- src/gallium/drivers/etnaviv/etnaviv_context.c | 16 ++++++++++++++++
- src/gallium/drivers/etnaviv/etnaviv_context.h | 3 +++
- src/gallium/drivers/etnaviv/etnaviv_resource.c | 7 +++++++
- src/gallium/drivers/etnaviv/etnaviv_resource.h | 2 ++
- src/gallium/drivers/etnaviv/etnaviv_state.c | 18 ++++++++++++++++++
- 5 files changed, 46 insertions(+)
-
-diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c
-index 4dd9e427ea1..581edc78d2f 100644
---- a/src/gallium/drivers/etnaviv/etnaviv_context.c
-+++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
-@@ -129,6 +129,9 @@ etna_context_destroy(struct pipe_context *pctx)
- _mesa_set_destroy(ctx->used_resources_write, NULL);
-
- }
-+ if (ctx->flush_resources)
-+ _mesa_set_destroy(ctx->flush_resources, NULL);
-+
- mtx_unlock(&ctx->lock);
-
- if (ctx->dummy_desc_bo)
-@@ -490,6 +493,14 @@ etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence,
- list_for_each_entry(struct etna_acc_query, aq, &ctx->active_acc_queries, node)
- etna_acc_query_suspend(aq, ctx);
-
-+ /* flush all resources that need an implicit flush */
-+ set_foreach(ctx->flush_resources, entry) {
-+ struct pipe_resource *prsc = (struct pipe_resource *)entry->key;
-+
-+ pctx->flush_resource(pctx, prsc);
-+ }
-+ _mesa_set_clear(ctx->flush_resources, NULL);
-+
- etna_cmd_stream_flush(ctx->stream, ctx->in_fence_fd,
- (flags & PIPE_FLUSH_FENCE_FD) ? &out_fence_fd : NULL);
-
-@@ -596,6 +607,11 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
- if (!ctx->used_resources_write)
- goto fail;
-
-+ ctx->flush_resources = _mesa_set_create(NULL, _mesa_hash_pointer,
-+ _mesa_key_pointer_equal);
-+ if (!ctx->flush_resources)
-+ goto fail;
-+
- mtx_init(&ctx->lock, mtx_recursive);
-
- /* context ctxate setup */
-diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h b/src/gallium/drivers/etnaviv/etnaviv_context.h
-index 72000f2122b..21e4d3f33ca 100644
---- a/src/gallium/drivers/etnaviv/etnaviv_context.h
-+++ b/src/gallium/drivers/etnaviv/etnaviv_context.h
-@@ -206,6 +206,9 @@ struct etna_context {
- struct set *used_resources_read;
- struct set *used_resources_write;
-
-+ /* resources that must be flushed implicitly at the context flush time */
-+ struct set *flush_resources;
-+
- mtx_t lock;
- };
-
-diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c
-index ae4f24b9b44..0c8c28e66aa 100644
---- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
-+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
-@@ -265,6 +265,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout,
- rsc->base.nr_samples = nr_samples;
- rsc->layout = layout;
- rsc->halign = halign;
-+ rsc->explicit_flush = true;
-
- pipe_reference_init(&rsc->base.reference, 1);
- util_range_init(&rsc->valid_buffer_range);
-@@ -519,6 +520,9 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
- rsc->layout = modifier_to_layout(handle->modifier);
- rsc->halign = TEXTURE_HALIGN_FOUR;
-
-+ if (usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH)
-+ rsc->explicit_flush = true;
-+
- level->width = tmpl->width0;
- level->height = tmpl->height0;
- level->depth = tmpl->depth0;
-@@ -584,6 +588,9 @@ etna_resource_get_handle(struct pipe_screen *pscreen,
- handle->offset = rsc->levels[0].offset;
- handle->modifier = layout_to_modifier(rsc->layout);
-
-+ if (!(usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH))
-+ rsc->explicit_flush = false;
-+
- if (handle->type == WINSYS_HANDLE_TYPE_SHARED) {
- return etna_bo_get_name(rsc->bo, &handle->handle) == 0;
- } else if (handle->type == WINSYS_HANDLE_TYPE_KMS) {
-diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.h b/src/gallium/drivers/etnaviv/etnaviv_resource.h
-index cb83e891d34..167cf4ed069 100644
---- a/src/gallium/drivers/etnaviv/etnaviv_resource.h
-+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.h
-@@ -93,6 +93,8 @@ struct etna_resource {
- struct pipe_resource *texture;
- /* for when PE doesn't support the base layout */
- struct pipe_resource *render;
-+ /* frontend flushes resource via an explicit call to flush_resource */
-+ bool explicit_flush;
-
- enum etna_resource_status status;
-
-diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c b/src/gallium/drivers/etnaviv/etnaviv_state.c
-index 44b1c4f8fab..1ad839799f2 100644
---- a/src/gallium/drivers/etnaviv/etnaviv_state.c
-+++ b/src/gallium/drivers/etnaviv/etnaviv_state.c
-@@ -753,6 +753,21 @@ etna_update_zsa(struct etna_context *ctx)
- return true;
- }
-
-+static bool
-+etna_record_flush_resources(struct etna_context *ctx)
-+{
-+ struct pipe_framebuffer_state *fb = &ctx->framebuffer_s;
-+
-+ if (fb->nr_cbufs > 0) {
-+ struct etna_surface *surf = etna_surface(fb->cbufs[0]);
-+
-+ if (!etna_resource(surf->prsc)->explicit_flush)
-+ _mesa_set_add(ctx->flush_resources, surf->prsc);
-+ }
-+
-+ return true;
-+}
-+
- struct etna_state_updater {
- bool (*update)(struct etna_context *ctx);
- uint32_t dirty;
-@@ -780,6 +795,9 @@ static const struct etna_state_updater etna_state_updates[] = {
- },
- {
- etna_update_zsa, ETNA_DIRTY_ZSA | ETNA_DIRTY_SHADER,
-+ },
-+ {
-+ etna_record_flush_resources, ETNA_DIRTY_FRAMEBUFFER,
- }
- };
-
---
-2.31.1
-
-FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:"
-SRC_URI:append:use-mainline-bsp = " \
- file://0001-dri-add-createImageWithModifiers2-interface.patch \
- file://0002-dri-add-loader_dri_create_image-helper.patch \
- file://0003-loader-dri3-convert-to-loader_dri_create_image.patch \
- file://0004-loader-dri-hook-up-createImageWithModifiers2.patch \
- file://0005-gallium-dri-copy-image-use-in-dup_image.patch \
- file://0006-dri-don-t-call-modifier-interfaces-when-modifiers_co.patch \
- file://0007-frontend-dri-add-EXPLICIT_FLUSH-hint-in-dri2_resourc.patch \
- file://0008-etnaviv-remove-double-assigment-of-surface-texture.patch \
- file://0009-etnaviv-flush-used-render-buffers-on-context-flush-w.patch \
-"
-
PROVIDES:remove:imxgpu = "virtual/egl"
PROVIDES:remove:imxgpu3d = "virtual/libgl virtual/libgles1 virtual/libgles2"