gbm: Implement dmabuf export for dumb buffers

Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
This commit is contained in:
stefan11111 2025-12-17 02:48:49 +02:00
parent d99a3d9b58
commit dbe71918aa

View file

@ -32,6 +32,7 @@
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h> /* for O_RDWR, which DRM_RDWR is defined as */
#include <limits.h>
#include <assert.h>
#include <sys/types.h>
@ -446,8 +447,19 @@ gbm_dri_bo_get_fd(struct gbm_bo *_bo)
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
int fd;
if (bo->image == NULL)
if (bo->image == NULL) {
#ifdef HAVE_LIBDRM
struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);
if (dri->has_dmabuf_export) {
int ret;
int prime_fd = -1;
ret = drmPrimeHandleToFD(dri->base.v0.fd, bo->handle, DRM_RDWR, &prime_fd);
if (!ret)
return prime_fd;
}
#endif
return -1;
}
if (!dri2_query_image(bo->image, __DRI_IMAGE_ATTRIB_FD, &fd))
return -1;