[Mesa-dev] [PATCH 10/15] gbm: Create a DRI image for dumb buffers, too.
Christopher James Halse Rogers
christopher.halse.rogers at canonical.com
Sat Jul 20 04:40:42 PDT 2013
We want this so we can hand out CPU-mappable buffers to clients, but still
use EGL in the server to composite said buffers.
---
src/gbm/backends/dri/gbm_dri.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 8b71cca..8ca7b54 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -318,9 +318,9 @@ gbm_dri_bo_destroy(struct gbm_bo *_bo)
struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
struct drm_mode_destroy_dumb arg;
- if (bo->image != NULL) {
+ if (bo->image)
dri->image->destroyImage(bo->image);
- } else {
+ if (bo->map) {
munmap(bo->map, bo->size);
memset(&arg, 0, sizeof(arg));
arg.handle = bo->handle;
@@ -532,6 +532,25 @@ create_dumb(struct gbm_device *gbm,
if (bo->map == MAP_FAILED)
goto destroy_dumb;
+ if (usage & GBM_BO_USE_RENDERING)
+ {
+ struct drm_gem_flink flink_arg;
+ memset(&flink_arg, 0, sizeof(flink_arg));
+ flink_arg.handle = bo->handle;
+ ret = drmIoctl(dri->base.base.fd, DRM_IOCTL_GEM_FLINK, &flink_arg);
+ if (ret)
+ goto destroy_dumb;
+
+ bo->image = dri->image->createImageFromName(dri->screen,
+ width, height,
+ gbm_to_dri_format(format),
+ flink_arg.name,
+ bo->base.base.stride / 4,
+ bo);
+
+ if (!bo->image)
+ goto destroy_dumb;
+ }
return &bo->base.base;
destroy_dumb:
--
1.8.3.2
More information about the mesa-dev
mailing list