gbm: add gbm_{bo,surface}_create_with_modifiers2
authorSimon Ser <contact@emersion.fr>
Sun, 22 Dec 2019 20:46:57 +0000 (21:46 +0100)
committerSimon Ser <contact@emersion.fr>
Thu, 30 Sep 2021 22:02:32 +0000 (00:02 +0200)
gbm_{bo,surface}_create_with_modifiers is missing the usage flags. Add a new
function which lets library users specify it.

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/backends/dri/gbm_dri.c
src/gbm/gbm-symbols.txt
src/gbm/main/gbm.c
src/gbm/main/gbm.h

index 1c2b989..d4eee4d 100644 (file)
@@ -1185,11 +1185,6 @@ gbm_dri_bo_create(struct gbm_device *gbm,
    int dri_format;
    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.
-    */
-   assert(!(usage && count));
-
    format = gbm_core.v0.format_canonicalize(format);
 
    if (usage & GBM_BO_USE_WRITE || dri->image == NULL)
index 8cdbc21..d3c99b0 100644 (file)
@@ -1,5 +1,6 @@
 gbm_bo_create
 gbm_bo_create_with_modifiers
+gbm_bo_create_with_modifiers2
 gbm_bo_destroy
 gbm_bo_get_bpp
 gbm_bo_get_device
@@ -30,6 +31,7 @@ gbm_device_is_format_supported
 gbm_format_get_name
 gbm_surface_create
 gbm_surface_create_with_modifiers
+gbm_surface_create_with_modifiers2
 gbm_surface_destroy
 gbm_surface_has_free_buffers
 gbm_surface_lock_front_buffer
index ffe8335..5c722ad 100644 (file)
@@ -497,6 +497,18 @@ gbm_bo_create_with_modifiers(struct gbm_device *gbm,
                              const uint64_t *modifiers,
                              const unsigned int count)
 {
+   return gbm_bo_create_with_modifiers2(gbm, width, height, format, modifiers,
+                                        count, 0);
+}
+
+GBM_EXPORT struct gbm_bo *
+gbm_bo_create_with_modifiers2(struct gbm_device *gbm,
+                              uint32_t width, uint32_t height,
+                              uint32_t format,
+                              const uint64_t *modifiers,
+                              const unsigned int count,
+                              uint32_t flags)
+{
    if (width == 0 || height == 0) {
       errno = EINVAL;
       return NULL;
@@ -507,7 +519,12 @@ gbm_bo_create_with_modifiers(struct gbm_device *gbm,
       return NULL;
    }
 
-   return gbm->v0.bo_create(gbm, width, height, format, 0, modifiers, count);
+   if (modifiers && (flags & GBM_BO_USE_LINEAR)) {
+      errno = EINVAL;
+      return NULL;
+   }
+
+   return gbm->v0.bo_create(gbm, width, height, format, flags, modifiers, count);
 }
 
 /**
@@ -631,12 +648,29 @@ gbm_surface_create_with_modifiers(struct gbm_device *gbm,
                                   const uint64_t *modifiers,
                                   const unsigned int count)
 {
+   return gbm_surface_create_with_modifiers2(gbm, width, height, format,
+                                             modifiers, count, 0);
+}
+
+GBM_EXPORT struct gbm_surface *
+gbm_surface_create_with_modifiers2(struct gbm_device *gbm,
+                                   uint32_t width, uint32_t height,
+                                   uint32_t format,
+                                   const uint64_t *modifiers,
+                                   const unsigned int count,
+                                   uint32_t flags)
+{
    if ((count && !modifiers) || (modifiers && !count)) {
       errno = EINVAL;
       return NULL;
    }
 
-   return gbm->v0.surface_create(gbm, width, height, format, 0,
+   if (modifiers && (flags & GBM_BO_USE_LINEAR)) {
+      errno = EINVAL;
+      return NULL;
+   }
+
+   return gbm->v0.surface_create(gbm, width, height, format, flags,
                                  modifiers, count);
 }
 
index 6117b35..a963ed7 100644 (file)
@@ -281,6 +281,15 @@ gbm_bo_create_with_modifiers(struct gbm_device *gbm,
                              uint32_t format,
                              const uint64_t *modifiers,
                              const unsigned int count);
+
+struct gbm_bo *
+gbm_bo_create_with_modifiers2(struct gbm_device *gbm,
+                              uint32_t width, uint32_t height,
+                              uint32_t format,
+                              const uint64_t *modifiers,
+                              const unsigned int count,
+                              uint32_t flags);
+
 #define GBM_BO_IMPORT_WL_BUFFER         0x5501
 #define GBM_BO_IMPORT_EGL_IMAGE         0x5502
 #define GBM_BO_IMPORT_FD                0x5503
@@ -413,6 +422,14 @@ gbm_surface_create_with_modifiers(struct gbm_device *gbm,
                                   const uint64_t *modifiers,
                                   const unsigned int count);
 
+struct gbm_surface *
+gbm_surface_create_with_modifiers2(struct gbm_device *gbm,
+                                   uint32_t width, uint32_t height,
+                                   uint32_t format,
+                                   const uint64_t *modifiers,
+                                   const unsigned int count,
+                                   uint32_t flags);
+
 struct gbm_bo *
 gbm_surface_lock_front_buffer(struct gbm_surface *surface);