From 3f52a853f795d7432b181de81da6f0c4cf1cc202 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 1 May 2009 12:48:46 -0600 Subject: st: when creating an on-demand front color buffer, init to back buffer image When we create a new front color buffer (user called glDrawBuffer(GL_FRONT)) initialize it to the contents of the back buffer. Any previous call to SwapBuffers() would have done that in effect, so make it reality. --- src/mesa/state_tracker/st_cb_fbo.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index fe9befaa2c..9ae4208a18 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -454,6 +454,31 @@ st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) } +/** + * Copy back color buffer to front color buffer. + */ +static void +copy_back_to_front(struct st_context *st, + struct gl_framebuffer *fb, + gl_buffer_index frontIndex, + gl_buffer_index backIndex) + +{ + struct st_framebuffer *stfb = (struct st_framebuffer *) fb; + struct pipe_surface *surf_front, *surf_back; + + (void) st_get_framebuffer_surface(stfb, frontIndex, &surf_front); + (void) st_get_framebuffer_surface(stfb, backIndex, &surf_back); + + if (surf_front && surf_back) { + st->pipe->surface_copy(st->pipe, + surf_front, 0, 0, /* dest */ + surf_back, 0, 0, /* src */ + fb->Width, fb->Height); + } +} + + /** * Check if we're drawing into, or read from, a front color buffer. If the * front buffer is missing, create it now. @@ -493,7 +518,7 @@ check_create_front_buffer(GLcontext *ctx, struct gl_framebuffer *fb, uint samples; if (0) - _mesa_debug(ctx, "Allocate new front buffer"); + _mesa_debug(ctx, "Allocate new front buffer\n"); /* get back renderbuffer info */ back = st_renderbuffer(fb->Attachment[backIndex].Renderbuffer); @@ -507,6 +532,11 @@ check_create_front_buffer(GLcontext *ctx, struct gl_framebuffer *fb, /* alloc texture/surface for new front buffer */ front->AllocStorage(ctx, front, front->InternalFormat, fb->Width, fb->Height); + + /* initialize the front color buffer contents by copying + * the back buffer. + */ + copy_back_to_front(ctx->st, fb, frontIndex, backIndex); } } } -- cgit v1.2.3