summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/egl/common
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2010-04-09 17:27:06 +0800
committerChia-I Wu <olv@lunarg.com>2010-04-09 17:52:37 +0800
commitf69b35fa15f43747dde29addaeec845604d7e127 (patch)
treec3806d31c350a7fa461b29ea47eca7a758d989ca /src/gallium/state_trackers/egl/common
parent08100aa44449e9f43d7b3b7b195d68185c109703 (diff)
st/egl: Remove pbuffer from the native interface.
A pbuffer is an EGL resource. It does not need a native display to create.
Diffstat (limited to 'src/gallium/state_trackers/egl/common')
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.c41
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.h2
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_st.c57
-rw-r--r--src/gallium/state_trackers/egl/common/native.h8
4 files changed, 84 insertions, 24 deletions
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c
index 5eabe10558..21fa6c8d4f 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -524,9 +524,6 @@ egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
case EGL_PIXMAP_BIT:
err = "eglCreatePixmapSurface";
break;
- case EGL_PBUFFER_BIT:
- err = "eglCreatePBufferSurface";
- break;
#ifdef EGL_MESA_screen_surface
case EGL_SCREEN_BIT_MESA:
err = "eglCreateScreenSurface";
@@ -558,10 +555,6 @@ egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
nsurf = gdpy->native->create_pixmap_surface(gdpy->native,
arg->u.pix, gconf->native);
break;
- case EGL_PBUFFER_BIT:
- nsurf = gdpy->native->create_pbuffer_surface(gdpy->native,
- gconf->native, gsurf->base.Width, gsurf->base.Height);
- break;
#ifdef EGL_MESA_screen_surface
case EGL_SCREEN_BIT_MESA:
/* prefer back buffer (move to _eglInitSurface?) */
@@ -593,7 +586,7 @@ egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
gsurf->stfbi = egl_g3d_create_st_framebuffer(&gsurf->base);
if (!gsurf->stfbi) {
- gsurf->native->destroy(gsurf->native);
+ nsurf->destroy(nsurf);
free(gsurf);
return NULL;
}
@@ -636,12 +629,29 @@ static _EGLSurface *
egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLConfig *conf, const EGLint *attribs)
{
- struct egl_g3d_create_surface_arg arg;
+ struct egl_g3d_config *gconf = egl_g3d_config(conf);
+ struct egl_g3d_surface *gsurf;
- memset(&arg, 0, sizeof(arg));
- arg.type = EGL_PBUFFER_BIT;
+ gsurf = CALLOC_STRUCT(egl_g3d_surface);
+ if (!gsurf) {
+ _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface");
+ return NULL;
+ }
- return egl_g3d_create_surface(drv, dpy, conf, &arg, attribs);
+ if (!_eglInitSurface(&gsurf->base, dpy, EGL_PBUFFER_BIT, conf, attribs)) {
+ free(gsurf);
+ return NULL;
+ }
+
+ gsurf->stvis = gconf->stvis;
+
+ gsurf->stfbi = egl_g3d_create_st_framebuffer(&gsurf->base);
+ if (!gsurf->stfbi) {
+ free(gsurf);
+ return NULL;
+ }
+
+ return &gsurf->base;
}
/**
@@ -658,7 +668,8 @@ destroy_surface(_EGLDisplay *dpy, _EGLSurface *surf)
pipe_texture_reference(&gsurf->render_texture, NULL);
egl_g3d_destroy_st_framebuffer(gsurf->stfbi);
- gsurf->native->destroy(gsurf->native);
+ if (gsurf->native)
+ gsurf->native->destroy(gsurf->native);
free(gsurf);
}
@@ -879,7 +890,9 @@ egl_g3d_wait_native(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine)
if (ctx && ctx->DrawSurface) {
struct egl_g3d_surface *gsurf = egl_g3d_surface(ctx->DrawSurface);
- gsurf->native->wait(gsurf->native);
+
+ if (gsurf->native)
+ gsurf->native->wait(gsurf->native);
}
return EGL_TRUE;
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.h b/src/gallium/state_trackers/egl/common/egl_g3d.h
index 2788f1bf4a..ad1c2859aa 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.h
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.h
@@ -70,8 +70,10 @@ struct egl_g3d_surface {
struct st_visual stvis;
struct st_framebuffer_iface *stfbi;
+ /* the native surface; NULL for pbuffers */
struct native_surface *native;
struct pipe_texture *render_texture;
+
unsigned int sequence_number;
};
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
index 9573ba09d1..f4934982ed 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
@@ -141,6 +141,53 @@ egl_g3d_destroy_st_manager(struct st_manager *smapi)
}
static boolean
+egl_g3d_st_framebuffer_flush_front_pbuffer(struct st_framebuffer_iface *stfbi,
+ enum st_attachment_type statt)
+{
+ return TRUE;
+}
+
+static boolean
+egl_g3d_st_framebuffer_validate_pbuffer(struct st_framebuffer_iface *stfbi,
+ const enum st_attachment_type *statts,
+ unsigned count,
+ struct pipe_texture **out)
+{
+ _EGLSurface *surf = (_EGLSurface *) stfbi->st_manager_private;
+ struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+ struct pipe_texture templ;
+ unsigned i;
+
+ for (i = 0; i < count; i++) {
+ out[i] = NULL;
+
+ if (gsurf->stvis.render_buffer != statts[i])
+ continue;
+
+ if (!gsurf->render_texture) {
+ struct egl_g3d_display *gdpy =
+ egl_g3d_display(gsurf->base.Resource.Display);
+ struct pipe_screen *screen = gdpy->native->screen;
+
+ memset(&templ, 0, sizeof(templ));
+ templ.target = PIPE_TEXTURE_2D;
+ templ.last_level = 0;
+ templ.width0 = gsurf->base.Width;
+ templ.height0 = gsurf->base.Height;
+ templ.depth0 = 1;
+ templ.format = gsurf->stvis.color_format;
+ templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+
+ gsurf->render_texture = screen->texture_create(screen, &templ);
+ }
+
+ pipe_texture_reference(&out[i], gsurf->render_texture);
+ }
+
+ return TRUE;
+}
+
+static boolean
egl_g3d_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi,
enum st_attachment_type statt)
{
@@ -246,8 +293,14 @@ egl_g3d_create_st_framebuffer(_EGLSurface *surf)
return NULL;
stfbi->visual = &gsurf->stvis;
- stfbi->flush_front = egl_g3d_st_framebuffer_flush_front;
- stfbi->validate = egl_g3d_st_framebuffer_validate;
+ if (gsurf->base.Type != EGL_PBUFFER_BIT) {
+ stfbi->flush_front = egl_g3d_st_framebuffer_flush_front;
+ stfbi->validate = egl_g3d_st_framebuffer_validate;
+ }
+ else {
+ stfbi->flush_front = egl_g3d_st_framebuffer_flush_front_pbuffer;
+ stfbi->validate = egl_g3d_st_framebuffer_validate_pbuffer;
+ }
stfbi->st_manager_private = (void *) &gsurf->base;
return stfbi;
diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h
index 93c81b26e1..5062ea1076 100644
--- a/src/gallium/state_trackers/egl/common/native.h
+++ b/src/gallium/state_trackers/egl/common/native.h
@@ -197,14 +197,6 @@ struct native_display {
EGLNativePixmapType pix,
const struct native_config *nconf);
- /**
- * Create a pbuffer surface. Required unless no config has GLX_PBUFFER_BIT
- * set.
- */
- struct native_surface *(*create_pbuffer_surface)(struct native_display *ndpy,
- const struct native_config *nconf,
- uint width, uint height);
-
const struct native_display_modeset *modeset;
};