summaryrefslogtreecommitdiff
path: root/src/gbm/backends/dri/gbm_dri.c
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2023-07-27 01:48:14 +0100
committerMarge Bot <emma+marge@anholt.net>2023-07-28 12:25:19 +0000
commitf4d24ca4142af15d31e19cba229ee3c2a7332d20 (patch)
treea8ec0b168dc874272f5e1b696595c3d340a2fec4 /src/gbm/backends/dri/gbm_dri.c
parent3d59f4cfcbc9d955a37f98e7bd378abd32c5ac86 (diff)
egl/drm: Assume modern DRI interface versions
We know we always have modern versions of DRI_IMAGE and DRI_FLUSH as we're version-locked to our same Mesa version. Signed-off-by: Daniel Stone <daniels@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24347>
Diffstat (limited to 'src/gbm/backends/dri/gbm_dri.c')
-rw-r--r--src/gbm/backends/dri/gbm_dri.c54
1 files changed, 9 insertions, 45 deletions
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 03d3f0054ea..dd38f8f6435 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -521,7 +521,7 @@ gbm_dri_is_format_supported(struct gbm_device *gbm,
/* If there is no query, fall back to the small table which was originally
* here. */
- if (dri->image->base.version <= 15 || !dri->image->queryDmaBufModifiers) {
+ if (!dri->image->queryDmaBufModifiers) {
switch (format) {
case GBM_FORMAT_XRGB8888:
case GBM_FORMAT_ARGB8888:
@@ -548,8 +548,7 @@ gbm_dri_get_format_modifier_plane_count(struct gbm_device *gbm,
struct gbm_dri_device *dri = gbm_dri_device(gbm);
uint64_t plane_count;
- if (dri->image->base.version < 16 ||
- !dri->image->queryDmaBufFormatModifierAttribs)
+ if (!dri->image->queryDmaBufFormatModifierAttribs)
return -1;
format = gbm_core.v0.format_canonicalize(format);
@@ -629,17 +628,6 @@ gbm_dri_bo_get_handle_for_plane(struct gbm_bo *_bo, int plane)
union gbm_bo_handle ret;
ret.s32 = -1;
- if (!dri->image || dri->image->base.version < 13 || !dri->image->fromPlanar) {
- /* Preserve legacy behavior if plane is 0 */
- if (plane == 0) {
- /* NOTE: return _bo->handle, *NOT* bo->handle which is invalid at this point */
- return _bo->v0.handle;
- }
-
- errno = ENOSYS;
- return ret;
- }
-
if (plane >= get_number_planes(dri, bo->image)) {
errno = EINVAL;
return ret;
@@ -671,7 +659,7 @@ gbm_dri_bo_get_plane_fd(struct gbm_bo *_bo, int plane)
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
int fd = -1;
- if (!dri->image || dri->image->base.version < 13 || !dri->image->fromPlanar) {
+ if (!dri->image || !dri->image->fromPlanar) {
/* Preserve legacy behavior if plane is 0 */
if (plane == 0)
return gbm_dri_bo_get_fd(_bo);
@@ -711,7 +699,7 @@ gbm_dri_bo_get_stride(struct gbm_bo *_bo, int plane)
__DRIimage *image;
int stride = 0;
- if (!dri->image || dri->image->base.version < 11 || !dri->image->fromPlanar) {
+ if (!dri->image || !dri->image->fromPlanar) {
/* Preserve legacy behavior if plane is 0 */
if (plane == 0)
return _bo->v0.stride;
@@ -749,14 +737,6 @@ gbm_dri_bo_get_offset(struct gbm_bo *_bo, int plane)
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
int offset = 0;
- /* These error cases do not actually return an error code, as the user
- * will also fail to obtain the handle/FD from the BO. In that case, the
- * offset is irrelevant, as they have no buffer to offset into, so
- * returning 0 is harmless.
- */
- if (!dri->image || dri->image->base.version < 13 || !dri->image->fromPlanar)
- return 0;
-
if (plane >= get_number_planes(dri, bo->image))
return 0;
@@ -784,11 +764,6 @@ gbm_dri_bo_get_modifier(struct gbm_bo *_bo)
struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
- if (!dri->image || dri->image->base.version < 14) {
- errno = ENOSYS;
- return DRM_FORMAT_MOD_INVALID;
- }
-
/* Dumb buffers have no modifiers */
if (!bo->image)
return DRM_FORMAT_MOD_LINEAR;
@@ -923,8 +898,7 @@ gbm_dri_bo_import(struct gbm_device *gbm,
int fourcc;
/* Import with modifier requires createImageFromDmaBufs2 */
- if (dri->image == NULL || dri->image->base.version < 15 ||
- dri->image->createImageFromDmaBufs2 == NULL) {
+ if (dri->image->createImageFromDmaBufs2 == NULL) {
errno = ENOSYS;
return NULL;
}
@@ -1096,8 +1070,7 @@ 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 && (dri->image->base.version < 14 ||
- !dri->image->createImageWithModifiers)) {
+ if (modifiers && !dri->image->createImageWithModifiers) {
errno = ENOSYS;
goto failed;
}
@@ -1139,11 +1112,6 @@ gbm_dri_bo_map(struct gbm_bo *_bo,
return *map_data;
}
- if (!dri->image || dri->image->base.version < 12 || !dri->image->mapImage) {
- errno = ENOSYS;
- return NULL;
- }
-
mtx_lock(&dri->mutex);
if (!dri->context) {
unsigned error;
@@ -1176,8 +1144,7 @@ gbm_dri_bo_unmap(struct gbm_bo *_bo, void *map_data)
return;
}
- if (!dri->context || !dri->image ||
- dri->image->base.version < 12 || !dri->image->unmapImage)
+ if (!dri->context || !dri->image->unmapImage)
return;
dri->image->unmapImage(dri->context, bo->image, map_data);
@@ -1187,8 +1154,7 @@ gbm_dri_bo_unmap(struct gbm_bo *_bo, void *map_data)
* on the mapping context. Since there is no explicit gbm flush
* mechanism, we need to flush here.
*/
- if (dri->flush->base.version >= 4)
- dri->flush->flush_with_flags(dri->context, NULL, __DRI2_FLUSH_CONTEXT, 0);
+ dri->flush->flush_with_flags(dri->context, NULL, __DRI2_FLUSH_CONTEXT, 0);
}
@@ -1201,9 +1167,7 @@ gbm_dri_surface_create(struct gbm_device *gbm,
struct gbm_dri_device *dri = gbm_dri_device(gbm);
struct gbm_dri_surface *surf;
- if (modifiers &&
- (!dri->image || dri->image->base.version < 14 ||
- !dri->image->createImageWithModifiers)) {
+ if (modifiers && !dri->image->createImageWithModifiers) {
errno = ENOSYS;
return NULL;
}