gbm: add gbm_{bo,surface}_create_with_modifiers2
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>
This commit is contained in:
parent
76d64d2a3e
commit
268e12c605
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -496,6 +496,18 @@ gbm_bo_create_with_modifiers(struct gbm_device *gbm,
|
|||
uint32_t format,
|
||||
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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -630,13 +647,30 @@ gbm_surface_create_with_modifiers(struct gbm_device *gbm,
|
|||
uint32_t format,
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue