[Mesa-dev] [PATCH 5/6] gallium: gbm/egl: support GBM surface extensions on DRM
Lucas Stach
l.stach at pengutronix.de
Wed Nov 6 08:22:55 PST 2013
Let's applications like Weston create EGL onscreen-surfaces
on bare DRM devices.
Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
---
src/gallium/state_trackers/egl/drm/native_drm.c | 11 ++++++
src/gallium/state_trackers/gbm/gbm_drm.c | 44 ++++++++++++++++++++++
.../state_trackers/gbm/gbm_gallium_drmint.h | 12 ++++++
3 files changed, 67 insertions(+)
diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c
index c82bbe4d7417..10a77603d2aa 100644
--- a/src/gallium/state_trackers/egl/drm/native_drm.c
+++ b/src/gallium/state_trackers/egl/drm/native_drm.c
@@ -83,6 +83,7 @@ drm_display_get_configs(struct native_display *ndpy, int *num_configs)
}
nconf->color_format = format;
+ nconf->window_bit = TRUE;
/* support KMS */
if (drmdpy->resources)
@@ -211,6 +212,15 @@ drm_create_pixmap_surface(struct native_display *ndpy,
return drm_display_create_surface_from_resource(ndpy, bo->resource);
}
+static struct native_surface *
+drm_create_window_surface(struct native_display *ndpy,
+ EGLNativeWindowType win,
+ const struct native_config *nconf)
+{
+ struct gbm_gallium_drm_surface *surf = (void *) win;
+ return drm_display_create_surface_from_resource(ndpy, surf->bo->resource);
+}
+
static boolean
drm_display_init_screen(struct native_display *ndpy)
{
@@ -246,6 +256,7 @@ drm_create_display(struct gbm_gallium_drm_device *gbmdrm, int own_gbm,
drmdpy->base.get_configs = drm_display_get_configs;
drmdpy->base.create_pixmap_surface = drm_create_pixmap_surface;
+ drmdpy->base.create_window_surface = drm_create_window_surface;
drmdpy->base.buffer = &drm_display_buffer;
#ifdef HAVE_WAYLAND_BACKEND
diff --git a/src/gallium/state_trackers/gbm/gbm_drm.c b/src/gallium/state_trackers/gbm/gbm_drm.c
index 725f12f6dad5..ad1c4a5c5639 100644
--- a/src/gallium/state_trackers/gbm/gbm_drm.c
+++ b/src/gallium/state_trackers/gbm/gbm_drm.c
@@ -218,6 +218,47 @@ gbm_gallium_drm_bo_create(struct gbm_device *gbm,
return &bo->base.base;
}
+static struct gbm_surface *
+gbm_gallium_drm_surface_create(struct gbm_device *gbm,
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t flags)
+{
+ struct gbm_gallium_drm_surface *surf;
+
+ surf = calloc(1, sizeof *surf);
+ if (surf == NULL)
+ return NULL;
+
+ surf->base.gbm = gbm;
+ surf->base.width = width;
+ surf->base.height = height;
+ surf->base.format = format;
+ surf->base.flags = flags;
+
+ surf->bo = gbm_gallium_drm_bo_create(gbm, width, height, format,
+ GBM_BO_USE_RENDERING);
+
+ return &surf->base;
+}
+
+static void
+gbm_gallium_drm_surface_destroy(struct gbm_surface *_surf)
+{
+ struct gbm_gallium_drm_surface *surf = gbm_gallium_drm_surface(_surf);
+
+ gbm_gallium_drm_bo_destroy(&surf->bo->base.base);
+
+ free(surf);
+}
+
+static struct gbm_bo *
+gbm_gallium_drm_lock_front_buffer(struct gbm_surface *_surf)
+{
+ struct gbm_gallium_drm_surface *surf = gbm_gallium_drm_surface(_surf);
+
+ return surf->bo;
+}
+
static void
gbm_gallium_drm_destroy(struct gbm_device *gbm)
{
@@ -240,6 +281,9 @@ gbm_gallium_drm_device_create(int fd)
gdrm->base.base.bo_import = gbm_gallium_drm_bo_import;
gdrm->base.base.bo_destroy = gbm_gallium_drm_bo_destroy;
gdrm->base.base.is_format_supported = gbm_gallium_drm_is_format_supported;
+ gdrm->base.base.surface_create = gbm_gallium_drm_surface_create;
+ gdrm->base.base.surface_destroy = gbm_gallium_drm_surface_destroy;
+ gdrm->base.base.surface_lock_front_buffer = gbm_gallium_drm_lock_front_buffer;
gdrm->base.base.destroy = gbm_gallium_drm_destroy;
gdrm->base.type = GBM_DRM_DRIVER_TYPE_GALLIUM;
diff --git a/src/gallium/state_trackers/gbm/gbm_gallium_drmint.h b/src/gallium/state_trackers/gbm/gbm_gallium_drmint.h
index a5d6d834737b..e873e9174d45 100644
--- a/src/gallium/state_trackers/gbm/gbm_gallium_drmint.h
+++ b/src/gallium/state_trackers/gbm/gbm_gallium_drmint.h
@@ -53,6 +53,12 @@ struct gbm_gallium_drm_bo {
struct pipe_resource *resource;
};
+struct gbm_gallium_drm_surface {
+ struct gbm_surface base;
+
+ struct gbm_gallium_drm_bo *bo;
+};
+
static inline struct gbm_gallium_drm_device *
gbm_gallium_drm_device(struct gbm_device *gbm)
{
@@ -65,6 +71,12 @@ gbm_gallium_drm_bo(struct gbm_bo *bo)
return (struct gbm_gallium_drm_bo *) bo;
}
+static inline struct gbm_gallium_drm_surface *
+gbm_gallium_drm_surface(struct gbm_surface *surface)
+{
+ return (struct gbm_gallium_drm_surface *) surface;
+}
+
struct gbm_device *
gbm_gallium_drm_device_create(int fd);
--
1.8.4.rc3
More information about the mesa-dev
mailing list