diff options
author | Chia-I Wu <olvaffe@gmail.com> | 2010-01-12 18:08:02 +0800 |
---|---|---|
committer | Chia-I Wu <olvaffe@gmail.com> | 2010-01-14 17:25:19 +0800 |
commit | 6cb89b23eeac50cfb0c5fb8d77e19f869b524eac (patch) | |
tree | 1ce2fd6938d95521cc64e35cfb629d98da4b9260 /src/gallium/state_trackers/egl_g3d/x11/native_dri2.c | |
parent | 6a2936b87683d39beb81ccba831ae7de47063bc6 (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/x11/native_dri2.c')
-rw-r--r-- | src/gallium/state_trackers/egl_g3d/x11/native_dri2.c | 20 |
1 files changed, 17 insertions, 3 deletions
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 0dda786bbd..2192a1366d 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c @@ -64,6 +64,7 @@ struct dri2_surface { struct pipe_texture *pbuffer_textures[NUM_NATIVE_ATTACHMENTS]; boolean have_back, have_fake; int width, height; + unsigned int sequence_number; }; struct dri2_config { @@ -136,6 +137,7 @@ static boolean dri2_surface_validate(struct native_surface *nsurf, const enum native_attachment *natts, unsigned num_natts, + unsigned int *seq_num, struct pipe_texture **textures, int *width, int *height) { @@ -178,6 +180,8 @@ dri2_surface_validate(struct native_surface *nsurf, pipe_texture_reference(&textures[i], ptex); } + if (seq_num) + *seq_num = dri2surf->sequence_number; if (width) *width = dri2surf->width; if (height) @@ -219,15 +223,23 @@ dri2_surface_validate(struct native_surface *nsurf, dri2surf->have_back = FALSE; dri2surf->have_fake = FALSE; + /* remember old geometry */ + templ.width0 = dri2surf->width; + templ.height0 = dri2surf->height; + xbufs = x11_drawable_get_buffers(dri2dpy->xscr, dri2surf->drawable, &dri2surf->width, &dri2surf->height, dri2atts, FALSE, num_ins, &num_outs); if (!xbufs) return FALSE; - /* update width and height */ - templ.width0 = dri2surf->width; - templ.height0 = dri2surf->height; + if (templ.width0 != dri2surf->width || templ.height0 != dri2surf->height) { + /* are there cases where the buffers change and the geometry doesn't? */ + dri2surf->sequence_number++; + + templ.width0 = dri2surf->width; + templ.height0 = dri2surf->height; + } for (i = 0; i < num_outs; i++) { struct x11_drawable_buffer *xbuf = &xbufs[i]; @@ -279,6 +291,8 @@ dri2_surface_validate(struct native_surface *nsurf, free(xbufs); + if (seq_num) + *seq_num = dri2surf->sequence_number; if (width) *width = dri2surf->width; if (height) |