gbm: assume USE_SCANOUT in create_with_modifiers
authorSimon Ser <contact@emersion.fr>
Fri, 27 Aug 2021 13:03:39 +0000 (15:03 +0200)
committerSimon Ser <contact@emersion.fr>
Thu, 30 Sep 2021 22:02:36 +0000 (00:02 +0200)
gbm_{bo,surface}_create_with_modifiers doesn't allow callers to
pass usage flags. Assume USE_SCANOUT since this is what most
callers want.

Bump the GBM ABI version so that other backends can discover when
the usage flags can be used.

Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: James Jones <jajones@nvidia.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3197>

src/gbm/main/gbm.c
src/gbm/main/gbm_abi_check.c
src/gbm/main/gbm_backend_abi.h

index 5c722ad..2d646e0 100644 (file)
@@ -498,7 +498,7 @@ gbm_bo_create_with_modifiers(struct gbm_device *gbm,
                              const unsigned int count)
 {
    return gbm_bo_create_with_modifiers2(gbm, width, height, format, modifiers,
-                                        count, 0);
+                                        count, GBM_BO_USE_SCANOUT);
 }
 
 GBM_EXPORT struct gbm_bo *
@@ -649,7 +649,8 @@ gbm_surface_create_with_modifiers(struct gbm_device *gbm,
                                   const unsigned int count)
 {
    return gbm_surface_create_with_modifiers2(gbm, width, height, format,
-                                             modifiers, count, 0);
+                                             modifiers, count,
+                                             GBM_BO_USE_SCANOUT);
 }
 
 GBM_EXPORT struct gbm_surface *
index f1137be..feca099 100644 (file)
  * -Add a new block of checks in main()
  */
 
-/* From: 49a7331cb02 - James Jones - gbm: Version the backend interface */
-#define GBM_BACKEND_ABI_VERSION_abi0 0
+/*
+ * From: Simon Ser - "gbm: assume USE_SCANOUT in create_with_modifiers"
+ *
+ * Note: ABI 1 is identical to ABI 0, except gbm_device_v0.bo_create can
+ * provide both modifiers and usage.
+ */
+#define GBM_BACKEND_ABI_VERSION_abi0 1
 struct gbm_device_v0_abi0 {
    const struct gbm_backend_desc *backend_desc;
    uint32_t backend_version;
index 962ee74..222ce34 100644 (file)
@@ -72,7 +72,7 @@ struct gbm_backend_desc;
  * Core ABI version: 4
  * ABI version of a buffer object created by a device from the backend: 4
  */
-#define GBM_BACKEND_ABI_VERSION 0
+#define GBM_BACKEND_ABI_VERSION 1
 
 /**
  * GBM device interface corresponding to GBM_BACKEND_ABI_VERSION = 0
@@ -113,6 +113,10 @@ struct gbm_device_v0 {
                                           uint32_t format,
                                           uint64_t modifier);
 
+   /**
+    * Since version 1, usage is properly populated when modifiers are
+    * supplied. Version 0 always set usage to 0 in this case.
+    */
    struct gbm_bo *(*bo_create)(struct gbm_device *gbm,
                                uint32_t width, uint32_t height,
                                uint32_t format,
@@ -137,6 +141,10 @@ struct gbm_device_v0 {
    uint64_t (*bo_get_modifier)(struct gbm_bo *bo);
    void (*bo_destroy)(struct gbm_bo *bo);
 
+   /**
+    * Since version 1, flags are properly populated when modifiers are
+    * supplied. Version 0 always set flags to 0 in this case.
+    */
    struct gbm_surface *(*surface_create)(struct gbm_device *gbm,
                                          uint32_t width, uint32_t height,
                                          uint32_t format, uint32_t flags,