Browse Source

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.
tags/7.8-rc1
Chia-I Wu 15 years ago
parent
commit
51b00574a2

+ 6
- 4
src/gallium/state_trackers/egl_g3d/common/egl_g3d.c View File

@@ -24,6 +24,7 @@

#include <assert.h>
#include <string.h>
#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) {

+ 7
- 10
src/gallium/state_trackers/egl_g3d/common/native.h View File

@@ -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_ */

+ 3
- 19
src/gallium/state_trackers/egl_g3d/kms/native_kms.c View File

@@ -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;
}

+ 1
- 18
src/gallium/state_trackers/egl_g3d/x11/native_dri2.c View File

@@ -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;

+ 3
- 4
src/gallium/state_trackers/egl_g3d/x11/native_x11.c View File

@@ -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;

+ 2
- 6
src/gallium/state_trackers/egl_g3d/x11/native_x11.h View File

@@ -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_ */

+ 1
- 17
src/gallium/state_trackers/egl_g3d/x11/native_ximage.c View File

@@ -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;

Loading…
Cancel
Save