summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2010-01-12 18:08:02 +0800
committerChia-I Wu <olvaffe@gmail.com>2010-01-14 17:25:19 +0800
commit6cb89b23eeac50cfb0c5fb8d77e19f869b524eac (patch)
tree1ce2fd6938d95521cc64e35cfb629d98da4b9260 /src/gallium/state_trackers/egl_g3d/common/egl_g3d.c
parent6a2936b87683d39beb81ccba831ae7de47063bc6 (diff)
st/egl_g3d: Use a sequence number to decide if validation is required.
It is not safe to assume that the native surface has not changed since the last validation by checking the geometry alone. Add a sequence number to "validate" callback for that purpose. This is inspired by Luca Barbieri's work.
Diffstat (limited to 'src/gallium/state_trackers/egl_g3d/common/egl_g3d.c')
-rw-r--r--src/gallium/state_trackers/egl_g3d/common/egl_g3d.c35
1 files changed, 23 insertions, 12 deletions
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 741e5b4659..9d5734d46f 100644
--- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c
@@ -63,22 +63,19 @@ egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx)
}
if (!gctx->force_validate) {
- EGLint cur_w, cur_h;
+ unsigned int seq_num;
- cur_w = gsurf->base.Width;
- cur_h = gsurf->base.Height;
gsurf->native->validate(gsurf->native,
gbuf->native_atts, gbuf->num_atts,
- NULL,
- &gsurf->base.Width, &gsurf->base.Height);
- /* validate only when the geometry changed */
- if (gsurf->base.Width == cur_w && gsurf->base.Height == cur_h)
+ &seq_num, NULL, NULL, NULL);
+ /* skip validation */
+ if (gsurf->sequence_number == seq_num)
continue;
}
gsurf->native->validate(gsurf->native,
gbuf->native_atts, gbuf->num_atts,
- (struct pipe_texture **) textures,
+ &gsurf->sequence_number, textures,
&gsurf->base.Width, &gsurf->base.Height);
for (i = 0; i < gbuf->num_atts; i++) {
struct pipe_texture *pt = textures[i];
@@ -599,6 +596,16 @@ egl_g3d_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
return EGL_TRUE;
}
+static EGLBoolean
+init_surface_geometry(_EGLSurface *surf)
+{
+ struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+
+ return gsurf->native->validate(gsurf->native, NULL, 0,
+ &gsurf->sequence_number, NULL,
+ &gsurf->base.Width, &gsurf->base.Height);
+}
+
static _EGLSurface *
egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLConfig *conf, EGLNativeWindowType win,
@@ -626,8 +633,7 @@ egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy,
return NULL;
}
- if (!gsurf->native->validate(gsurf->native, NULL, 0, NULL,
- &gsurf->base.Width, &gsurf->base.Height)) {
+ if (!init_surface_geometry(&gsurf->base)) {
gsurf->native->destroy(gsurf->native);
free(gsurf);
return NULL;
@@ -667,8 +673,7 @@ egl_g3d_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy,
return NULL;
}
- if (!gsurf->native->validate(gsurf->native, NULL, 0, NULL,
- &gsurf->base.Width, &gsurf->base.Height)) {
+ if (!init_surface_geometry(&gsurf->base)) {
gsurf->native->destroy(gsurf->native);
free(gsurf);
return NULL;
@@ -706,6 +711,12 @@ egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy,
return NULL;
}
+ if (!init_surface_geometry(&gsurf->base)) {
+ gsurf->native->destroy(gsurf->native);
+ free(gsurf);
+ return NULL;
+ }
+
gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ?
NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT;