Mesa (staging/21.3): gbm: Don't pass default usage flags on ABIs < 1
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Dec 12 22:36:42 UTC 2021
Module: Mesa
Branch: staging/21.3
Commit: 24d48c58402431d1cd6f47035979845ae537769f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=24d48c58402431d1cd6f47035979845ae537769f
Author: James Jones <jajones at nvidia.com>
Date: Fri Nov 19 11:50:18 2021 -0800
gbm: Don't pass default usage flags on ABIs < 1
Older drivers will not expect any flags from the
GBM front-end when modifiers are in use, and will
likely fail the allocation or handle them
incorrectly as a result. Only specify usage flags
when allocating from a backend with an ABI >= 1,
as that's the ABI version that added support for
specifying usage flags along with modifiers.
Fixes: ad50b47a14e9 ("gbm: assume USE_SCANOUT in create_with_modifiers")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5709
Signed-off-by: James Jones <jajones at nvidia.com>
Reviewed-by: Simon Ser <contact at emersion.fr>
Tested-by: Olivier Fourdan <ofourdan at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14049>
(cherry picked from commit c2550d1b7ca8146283265ce6f4267fa2b3591946)
---
.pick_status.json | 2 +-
src/gbm/main/gbm.c | 32 ++++++++++++++++++++++++++++++--
2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 966c95f2797..3cc7c4e59bb 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -967,7 +967,7 @@
"description": "gbm: Don't pass default usage flags on ABIs < 1",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": "ad50b47a14e94751cd59ad5892ad795d508557f0"
},
diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c
index 2d646e0e515..f0e650efe39 100644
--- a/src/gbm/main/gbm.c
+++ b/src/gbm/main/gbm.c
@@ -497,8 +497,22 @@ gbm_bo_create_with_modifiers(struct gbm_device *gbm,
const uint64_t *modifiers,
const unsigned int count)
{
+ uint32_t flags = 0;
+
+ /*
+ * ABI version 1 added the modifiers+flags capability. Backends from
+ * prior versions may fail if "unknown" flags are provided along with
+ * modifiers, but assume scanout is required when modifiers are used.
+ * Newer backends expect scanout to be explicitly requested if required,
+ * but applications using this older interface rely on the older implied
+ * requirement, so that behavior must be preserved.
+ */
+ if (gbm->v0.backend_version >= 1) {
+ flags |= GBM_BO_USE_SCANOUT;
+ }
+
return gbm_bo_create_with_modifiers2(gbm, width, height, format, modifiers,
- count, GBM_BO_USE_SCANOUT);
+ count, flags);
}
GBM_EXPORT struct gbm_bo *
@@ -648,9 +662,23 @@ gbm_surface_create_with_modifiers(struct gbm_device *gbm,
const uint64_t *modifiers,
const unsigned int count)
{
+ uint32_t flags = 0;
+
+ /*
+ * ABI version 1 added the modifiers+flags capability. Backends from
+ * prior versions may fail if "unknown" flags are provided along with
+ * modifiers, but assume scanout is required when modifiers are used.
+ * Newer backends expect scanout to be explicitly requested if required,
+ * but applications using this older interface rely on the older implied
+ * requirement, so that behavior must be preserved.
+ */
+ if (gbm->v0.backend_version >= 1) {
+ flags |= GBM_BO_USE_SCANOUT;
+ }
+
return gbm_surface_create_with_modifiers2(gbm, width, height, format,
modifiers, count,
- GBM_BO_USE_SCANOUT);
+ flags);
}
GBM_EXPORT struct gbm_surface *
More information about the mesa-commit
mailing list