From 51b00574a2ef81629548b079ef70c016bdd4251d Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 15 Jan 2010 17:39:49 +0800 Subject: st/egl_g3d: Always override flush_frontbuffer. Instead of letting the native displays install their own version of flush_frontbuffer, always override the callback with a version that calls the flush_frontbuffer of the native surface. --- .../state_trackers/egl_g3d/common/egl_g3d.c | 10 ++++++---- src/gallium/state_trackers/egl_g3d/common/native.h | 17 +++++++---------- .../state_trackers/egl_g3d/kms/native_kms.c | 22 +++------------------- .../state_trackers/egl_g3d/x11/native_dri2.c | 19 +------------------ .../state_trackers/egl_g3d/x11/native_x11.c | 7 +++---- .../state_trackers/egl_g3d/x11/native_x11.h | 8 ++------ .../state_trackers/egl_g3d/x11/native_ximage.c | 18 +----------------- 7 files changed, 23 insertions(+), 78 deletions(-) (limited to 'src/gallium/state_trackers') diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c index 8b69a8c..7da9300 100644 --- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c @@ -24,6 +24,7 @@ #include #include +#include "pipe/p_screen.h" #include "util/u_memory.h" #include "egldriver.h" #include "eglcurrent.h" @@ -456,8 +457,8 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) * Flush the front buffer of the context's draw surface. */ static void -egl_g3d_flush_frontbuffer(void *dummy, struct pipe_surface *surf, - void *context_private) +egl_g3d_flush_frontbuffer(struct pipe_screen *screen, + struct pipe_surface *surf, void *context_private) { struct egl_g3d_context *gctx = egl_g3d_context(context_private); struct egl_g3d_surface *gsurf = egl_g3d_surface(gctx->base.DrawSurface); @@ -509,13 +510,14 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, } dpy->DriverData = gdpy; - gdpy->native = - native_create_display(dpy->NativeDisplay, egl_g3d_flush_frontbuffer); + gdpy->native = native_create_display(dpy->NativeDisplay); if (!gdpy->native) { _eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)"); goto fail; } + gdpy->native->screen->flush_frontbuffer = egl_g3d_flush_frontbuffer; + dpy->ClientAPIsMask = gdrv->api_mask; if (egl_g3d_add_configs(drv, dpy, 1) == 1) { diff --git a/src/gallium/state_trackers/egl_g3d/common/native.h b/src/gallium/state_trackers/egl_g3d/common/native.h index 4714e24..1c3b016 100644 --- a/src/gallium/state_trackers/egl_g3d/common/native.h +++ b/src/gallium/state_trackers/egl_g3d/common/native.h @@ -114,7 +114,13 @@ struct native_display_modeset; * the native display server. */ struct native_display { + /** + * The pipe screen of the native display. + * + * Note that the "flush_frontbuffer" callback will be overridden. + */ struct pipe_screen *screen; + void (*destroy)(struct native_display *ndpy); /** @@ -204,19 +210,10 @@ struct native_display_modeset { const struct native_mode *nmode); }; -/** - * This function is called when the native display wants to display the front - * buffer of the draw surface of the given context. - */ -typedef void (*native_flush_frontbuffer)(void *dummy, - struct pipe_surface *surf, - void *context_private); - const char * native_get_name(void); struct native_display * -native_create_display(EGLNativeDisplayType dpy, - native_flush_frontbuffer flush_frontbuffer); +native_create_display(EGLNativeDisplayType dpy); #endif /* _NATIVE_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c b/src/gallium/state_trackers/egl_g3d/kms/native_kms.c index a44b9b9..65829fc 100644 --- a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c +++ b/src/gallium/state_trackers/egl_g3d/kms/native_kms.c @@ -769,8 +769,7 @@ static struct native_display_modeset kms_display_modeset = { }; static struct native_display * -kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api, - native_flush_frontbuffer flush_frontbuffer) +kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api) { struct kms_display *kdpy; @@ -812,10 +811,6 @@ kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api, return NULL; } - kdpy->base.screen->flush_frontbuffer = - (void (*)(struct pipe_screen *, struct pipe_surface *, void *)) - flush_frontbuffer; - kdpy->base.destroy = kms_display_destroy; kdpy->base.get_configs = kms_display_get_configs; kdpy->base.create_context = kms_display_create_context; @@ -826,13 +821,6 @@ kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api, return &kdpy->base; } -static void -dummy_flush_frontbuffer(void *dummy, struct pipe_surface *surf, - void *context_private) -{ - _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied"); -} - /* the api is destroyed with the native display */ static struct drm_api *drm_api; @@ -853,19 +841,15 @@ native_get_name(void) } struct native_display * -native_create_display(EGLNativeDisplayType dpy, - native_flush_frontbuffer flush_frontbuffer) +native_create_display(EGLNativeDisplayType dpy) { struct native_display *ndpy = NULL; if (!drm_api) drm_api = drm_api_create(); - if (!flush_frontbuffer) - flush_frontbuffer = dummy_flush_frontbuffer; - if (drm_api) - ndpy = kms_create_display(dpy, drm_api, flush_frontbuffer); + ndpy = kms_create_display(dpy, drm_api); return ndpy; } diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c index 2192a13..f497d8c 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c @@ -641,18 +641,8 @@ dri2_display_init_screen(struct native_display *ndpy) return TRUE; } -static void -dri2_display_flush_frontbuffer(void *dummy, struct pipe_surface *surf, - void *context_private) -{ - /* TODO get native surface from context private, and remove the callback */ - _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied"); -} - struct native_display * -x11_create_dri2_display(EGLNativeDisplayType dpy, - struct drm_api *api, - native_flush_frontbuffer flush_frontbuffer) +x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api) { struct dri2_display *dri2dpy; @@ -689,13 +679,6 @@ x11_create_dri2_display(EGLNativeDisplayType dpy, return NULL; } - if (!flush_frontbuffer) - flush_frontbuffer = dri2_display_flush_frontbuffer; - - dri2dpy->base.screen->flush_frontbuffer = - (void (*)(struct pipe_screen *, struct pipe_surface *, void *)) - flush_frontbuffer; - dri2dpy->base.destroy = dri2_display_destroy; dri2dpy->base.get_configs = dri2_display_get_configs; dri2dpy->base.create_context = dri2_display_create_context; diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_x11.c b/src/gallium/state_trackers/egl_g3d/x11/native_x11.c index a4f36e9..583ce3d 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/native_x11.c +++ b/src/gallium/state_trackers/egl_g3d/x11/native_x11.c @@ -48,8 +48,7 @@ native_get_name(void) } struct native_display * -native_create_display(EGLNativeDisplayType dpy, - native_flush_frontbuffer flush_frontbuffer) +native_create_display(EGLNativeDisplayType dpy) { struct native_display *ndpy = NULL; boolean force_sw; @@ -59,14 +58,14 @@ native_create_display(EGLNativeDisplayType dpy, force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE); if (api && !force_sw) { - ndpy = x11_create_dri2_display(dpy, api, flush_frontbuffer); + ndpy = x11_create_dri2_display(dpy, api); } if (!ndpy) { EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING; _eglLog(level, "use software fallback"); - ndpy = x11_create_ximage_display(dpy, TRUE, flush_frontbuffer); + ndpy = x11_create_ximage_display(dpy, TRUE); } return ndpy; diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_x11.h b/src/gallium/state_trackers/egl_g3d/x11/native_x11.h index 9217eb6..622ddac 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/native_x11.h +++ b/src/gallium/state_trackers/egl_g3d/x11/native_x11.h @@ -29,13 +29,9 @@ #include "common/native.h" struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy, - boolean use_xshm, - native_flush_frontbuffer flush_frontbuffer); +x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm); struct native_display * -x11_create_dri2_display(EGLNativeDisplayType dpy, - struct drm_api *api, - native_flush_frontbuffer flush_frontbuffer); +x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api); #endif /* _NATIVE_X11_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c index 1a1844e..24a50df 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c @@ -632,18 +632,8 @@ ximage_display_destroy(struct native_display *ndpy) free(xdpy); } -static void -ximage_display_flush_frontbuffer(void *dummy, struct pipe_surface *surf, - void *context_private) -{ - /* TODO get native surface from context private, and remove the callback */ - _eglLog(_EGL_WARNING, "flush_frontbuffer is not supplied"); -} - struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy, - boolean use_xshm, - native_flush_frontbuffer flush_frontbuffer) +x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm) { struct ximage_display *xdpy; @@ -672,12 +662,6 @@ x11_create_ximage_display(EGLNativeDisplayType dpy, (use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM)); xdpy->winsys = create_sw_winsys(); - if (!flush_frontbuffer) - flush_frontbuffer = ximage_display_flush_frontbuffer; - xdpy->winsys->flush_frontbuffer = - (void (*)(struct pipe_winsys *, struct pipe_surface *, void *)) - flush_frontbuffer; - xdpy->base.screen = softpipe_create_screen(xdpy->winsys); xdpy->base.destroy = ximage_display_destroy; -- cgit v1.1