summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/egl
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2010-10-10 20:47:02 +0800
committerChia-I Wu <olv@lunarg.com>2010-11-03 17:50:25 +0800
commit3f7876d76f0dabfe0be7a7edb44946334a6fedc2 (patch)
tree34ea4eaaa839e67ba5d5e9a04874a13857890eff /src/gallium/state_trackers/egl
parentaf977b53826695afcdcfe900816a93671aec00f5 (diff)
st/egl: Use native_display_buffer for EGL_MESA_drm_image.
native_display_buffer is just a wrapper to resource_{from,get}_handle for drm backend.
Diffstat (limited to 'src/gallium/state_trackers/egl')
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.c3
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_image.c15
-rw-r--r--src/gallium/state_trackers/egl/drm/native_drm.c24
3 files changed, 32 insertions, 10 deletions
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c
index 3d0d13cfb1..a3750ac56f 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -553,7 +553,8 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy,
if (dpy->Platform == _EGL_PLATFORM_DRM) {
dpy->Extensions.MESA_drm_display = EGL_TRUE;
- dpy->Extensions.MESA_drm_image = EGL_TRUE;
+ if (gdpy->native->buffer)
+ dpy->Extensions.MESA_drm_image = EGL_TRUE;
}
if (egl_g3d_add_configs(drv, dpy, 1) == 1) {
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_image.c b/src/gallium/state_trackers/egl/common/egl_g3d_image.c
index 0c8ad339cc..6a1f8cc697 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_image.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_image.c
@@ -38,7 +38,7 @@
#include "egl_g3d_api.h"
#include "egl_g3d_image.h"
-/* move this to native display? */
+/* for struct winsys_handle */
#include "state_tracker/drm_driver.h"
/**
@@ -137,13 +137,11 @@ egl_g3d_reference_drm_buffer(_EGLDisplay *dpy, EGLint name,
_EGLImage *img, const EGLint *attribs)
{
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
- struct pipe_screen *screen = gdpy->native->screen;
struct pipe_resource templ;
struct winsys_handle wsh;
_EGLImageAttribs attrs;
EGLint format;
- /* winsys_handle is in theory platform-specific */
if (dpy->Platform != _EGL_PLATFORM_DRM)
return NULL;
@@ -181,7 +179,7 @@ egl_g3d_reference_drm_buffer(_EGLDisplay *dpy, EGLint name,
wsh.stride =
attrs.DRMBufferStrideMESA * util_format_get_blocksize(templ.format);
- return screen->resource_from_handle(screen, &templ, &wsh);
+ return gdpy->native->buffer->import_buffer(gdpy->native, &templ, &wsh);
}
#endif /* EGL_MESA_drm_image */
@@ -303,10 +301,8 @@ egl_g3d_export_drm_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img,
{
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
struct egl_g3d_image *gimg = egl_g3d_image(img);
- struct pipe_screen *screen = gdpy->native->screen;
struct winsys_handle wsh;
- /* winsys_handle is in theory platform-specific */
if (dpy->Platform != _EGL_PLATFORM_DRM)
return EGL_FALSE;
@@ -314,9 +310,9 @@ egl_g3d_export_drm_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img,
if (name) {
memset(&handle, 0, sizeof(handle));
wsh.type = DRM_API_HANDLE_TYPE_SHARED;
- if (!screen->resource_get_handle(screen, gimg->texture, &wsh)) {
+ if (!gdpy->native->buffer->export_buffer(gdpy->native,
+ gimg->texture, &wsh))
return EGL_FALSE;
- }
*name = wsh.handle;
}
@@ -325,7 +321,8 @@ egl_g3d_export_drm_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img,
if (handle || stride) {
memset(&wsh, 0, sizeof(wsh));
wsh.type = DRM_API_HANDLE_TYPE_KMS;
- if (!screen->resource_get_handle(screen, gimg->texture, &wsh))
+ if (!gdpy->native->buffer->export_buffer(gdpy->native,
+ gimg->texture, &wsh))
return EGL_FALSE;
if (handle)
diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c
index 21555dcd0e..3759c2a26d 100644
--- a/src/gallium/state_trackers/egl/drm/native_drm.c
+++ b/src/gallium/state_trackers/egl/drm/native_drm.c
@@ -185,6 +185,29 @@ drm_display_init_screen(struct native_display *ndpy)
return TRUE;
}
+static struct pipe_resource *
+drm_display_import_buffer(struct native_display *ndpy,
+ const struct pipe_resource *templ,
+ void *buf)
+{
+ return ndpy->screen->resource_from_handle(ndpy->screen,
+ templ, (struct winsys_handle *) buf);
+}
+
+static boolean
+drm_display_export_buffer(struct native_display *ndpy,
+ struct pipe_resource *res,
+ void *buf)
+{
+ return ndpy->screen->resource_get_handle(ndpy->screen,
+ res, (struct winsys_handle *) buf);
+}
+
+static struct native_display_buffer drm_display_buffer = {
+ drm_display_import_buffer,
+ drm_display_export_buffer
+};
+
static struct native_display *
drm_create_display(int fd, struct native_event_handler *event_handler,
void *user_data)
@@ -208,6 +231,7 @@ drm_create_display(int fd, struct native_event_handler *event_handler,
drmdpy->base.get_param = drm_display_get_param;
drmdpy->base.get_configs = drm_display_get_configs;
+ drmdpy->base.buffer = &drm_display_buffer;
drm_display_init_modeset(&drmdpy->base);
return &drmdpy->base;