summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-04-07 13:50:02 -0600
committerBrian Paul <[email protected]>2008-04-07 13:50:02 -0600
commit2b2d0e05842691e715782a64845aeca12a428427 (patch)
treee721945176fbc6e3e57bac83111760441c562469 /src
parent42a9218daa8f564ea1b992a48cc3c375fd1b815e (diff)
gallium: clean-up in st_renderbuffer_alloc_storage()
Diffstat (limited to 'src')
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index ec7788923a3..e55281a4308 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -80,6 +80,8 @@ init_renderbuffer_bits(struct st_renderbuffer *strb,
/**
* gl_renderbuffer::AllocStorage()
+ * This is called to allocate the original drawing surface, and
+ * during window resize.
*/
static GLboolean
st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
@@ -90,8 +92,10 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
struct st_renderbuffer *strb = st_renderbuffer(rb);
enum pipe_format pipeFormat;
GLbitfield flags = 0x0; /* XXX needed? */
+ int ret;
if (!strb->surface) {
+ /* first time surface creation */
strb->surface = pipe->winsys->surface_alloc(pipe->winsys);
assert(strb->surface);
assert(strb->surface->refcount);
@@ -99,10 +103,10 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
if (!strb->surface)
return GL_FALSE;
}
-
- if (strb->surface->buffer)
- pipe_buffer_reference(pipe->winsys, &strb->surface->buffer,
- NULL);
+ else if (strb->surface->buffer) {
+ /* release/discard the old surface buffer */
+ pipe_buffer_reference(pipe->winsys, &strb->surface->buffer, NULL);
+ }
/* Determine surface format here */
if (strb->format != PIPE_FORMAT_NONE) {
@@ -116,14 +120,15 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
init_renderbuffer_bits(strb, pipeFormat);
- pipe->winsys->surface_alloc_storage(pipe->winsys,
- strb->surface,
- width,
- height,
- pipeFormat,
- flags);
- if (!strb->surface->buffer)
+ ret = pipe->winsys->surface_alloc_storage(pipe->winsys,
+ strb->surface,
+ width,
+ height,
+ pipeFormat,
+ flags);
+ if (ret || !strb->surface->buffer) {
return GL_FALSE; /* out of memory, try s/w buffer? */
+ }
ASSERT(strb->surface->buffer);
ASSERT(strb->surface->format);