[Mesa-dev] [PATCH 20/25] egl/dri2: Dispatch eglCreateImageKHR by display, not driver
Chad Versace
chad.versace at linux.intel.com
Sun Feb 9 13:37:56 PST 2014
Add dri2_egl_display_vtbl::create_image, set it for each platform, and
let egl_dri2 dispatch eglCreateImageKHR to that.
To remove ambiguity, rename egl_dri2.c:dri2_create_image() to
dri2_create_image_from_dri().
This prepares for the EGL platform extensions.
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
src/egl/drivers/dri2/egl_dri2.c | 22 ++++++++++++++++------
src/egl/drivers/dri2/egl_dri2.h | 5 +++++
src/egl/drivers/dri2/platform_android.c | 9 +--------
src/egl/drivers/dri2/platform_drm.c | 3 +--
src/egl/drivers/dri2/platform_wayland.c | 1 +
src/egl/drivers/dri2/platform_x11.c | 13 +++++++++++--
6 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index e0d4b6c..fcf4acf 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1219,8 +1219,18 @@ dri2_release_tex_image(_EGLDriver *drv,
return EGL_TRUE;
}
+static _EGLImage*
+dri2_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
+ EGLenum target, EGLClientBuffer buffer,
+ const EGLint *attr_list)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+ return dri2_dpy->vtbl->create_image(drv, dpy, ctx, target, buffer,
+ attr_list);
+}
+
static _EGLImage *
-dri2_create_image(_EGLDisplay *disp, __DRIimage *dri_image)
+dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image)
{
struct dri2_egl_image *dri2_img;
@@ -1264,7 +1274,7 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx,
dri2_dpy->image->createImageFromRenderbuffer(dri2_ctx->dri_context,
renderbuffer, NULL);
- return dri2_create_image(disp, dri_image);
+ return dri2_create_image_from_dri(disp, dri_image);
}
#ifdef HAVE_DRM_PLATFORM
@@ -1310,7 +1320,7 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx,
pitch,
NULL);
- return dri2_create_image(disp, dri_image);
+ return dri2_create_image_from_dri(disp, dri_image);
}
#endif
@@ -1373,7 +1383,7 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx,
return NULL;
}
- return dri2_create_image(disp, dri_image);
+ return dri2_create_image_from_dri(disp, dri_image);
}
#endif
@@ -1743,7 +1753,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
if (!dri_image)
return EGL_NO_IMAGE_KHR;
- res = dri2_create_image(disp, dri_image);
+ res = dri2_create_image_from_dri(disp, dri_image);
if (res)
dri2_take_dma_buf_ownership(fds, num_fds);
@@ -2156,7 +2166,7 @@ _eglBuiltInDriverDRI2(const char *args)
dri2_drv->base.API.PostSubBufferNV = dri2_post_sub_buffer;
dri2_drv->base.API.CopyBuffers = dri2_copy_buffers,
dri2_drv->base.API.QueryBufferAge = dri2_query_buffer_age;
- dri2_drv->base.API.CreateImageKHR = dri2_create_image_khr;
+ dri2_drv->base.API.CreateImageKHR = dri2_create_image;
dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
dri2_drv->base.API.CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image;
#ifdef HAVE_DRM_PLATFORM
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 8f3ed9d..35115bc 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -107,6 +107,11 @@ struct dri2_egl_display_vtbl {
EGLBoolean
(*destroy_surface)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface);
+ _EGLImage*
+ (*create_image)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
+ EGLenum target, EGLClientBuffer buffer,
+ const EGLint *attr_list);
+
EGLBoolean
(*swap_interval)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
EGLint interval);
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 0aa0fa4..3020af7 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -421,12 +421,6 @@ droid_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
}
static void
-droid_init_driver_functions(_EGLDriver *drv)
-{
- drv->API.CreateImageKHR = droid_create_image_khr;
-}
-
-static void
droid_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate)
{
}
@@ -645,6 +639,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
.create_pixmap_surface = dri2_fallback_pixmap_surface,
.create_pbuffer_surface = droid_create_pbuffer_surface,
.destroy_surface = droid_destroy_surface,
+ .create_image = droid_create_image_khr,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = droid_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
@@ -717,8 +712,6 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
dpy->VersionMajor = 1;
dpy->VersionMinor = 4;
- droid_init_driver_functions(drv);
-
/* Fill vtbl last to prevent accidentally calling virtual function during
* initialization.
*/
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 89222bf..a05074d 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -447,6 +447,7 @@ static struct dri2_egl_display_vtbl dri2_drm_display_vtbl = {
.create_pixmap_surface = dri2_fallback_create_pixmap_surface,
.create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
.destroy_surface = dri2_drm_destroy_surface,
+ .create_image = dri2_drm_create_image_khr,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = dri2_drm_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
@@ -549,8 +550,6 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
i + 1, EGL_WINDOW_BIT, attr_list, NULL);
}
- drv->API.CreateImageKHR = dri2_drm_create_image_khr;
-
disp->Extensions.EXT_buffer_age = EGL_TRUE;
#ifdef HAVE_WAYLAND_PLATFORM
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index a875656..1b5577a 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -937,6 +937,7 @@ static struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
.create_pixmap_surface = dri2_fallback_create_pixmap_surface,
.create_pbuffer_surface = dri2_fallback_create_pbuffer_surface,
.destroy_surface = dri2_wl_destroy_surface,
+ .create_image = dri2_create_image_khr,
.swap_interval = dri2_wl_swap_interval,
.swap_buffers = dri2_wl_swap_buffers,
.swap_buffers_with_damage = dri2_wl_swap_buffers_with_damage,
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 3c97a95..82f3ce9 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -993,12 +993,22 @@ dri2_x11_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
}
}
+static _EGLImage*
+dri2_x11_swrast_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
+ _EGLContext *ctx, EGLenum target,
+ EGLClientBuffer buffer,
+ const EGLint *attr_list)
+{
+ return NULL;
+}
+
static struct dri2_egl_display_vtbl dri2_x11_swrast_display_vtbl = {
.authenticate = NULL,
.create_window_surface = dri2_x11_create_window_surface,
.create_pixmap_surface = dri2_x11_create_pixmap_surface,
.create_pbuffer_surface = dri2_x11_create_pbuffer_surface,
.destroy_surface = dri2_x11_destroy_surface,
+ .create_image = dri2_x11_swrast_create_image_khr,
.swap_interval = dri2_fallback_swap_interval,
.swap_buffers = dri2_x11_swap_buffers,
.swap_buffers_region = dri2_fallback_swap_buffers_region,
@@ -1014,6 +1024,7 @@ static struct dri2_egl_display_vtbl dri2_x11_display_vtbl = {
.create_pixmap_surface = dri2_x11_create_pixmap_surface,
.create_pbuffer_surface = dri2_x11_create_pbuffer_surface,
.destroy_surface = dri2_x11_destroy_surface,
+ .create_image = dri2_x11_create_image_khr,
.swap_interval = dri2_x11_swap_interval,
.swap_buffers = dri2_x11_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
@@ -1143,8 +1154,6 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, _EGLDisplay *disp)
{
struct dri2_egl_display *dri2_dpy;
- drv->API.CreateImageKHR = dri2_x11_create_image_khr;
-
dri2_dpy = calloc(1, sizeof *dri2_dpy);
if (!dri2_dpy)
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
--
1.8.5.3
More information about the mesa-dev
mailing list