On 07/25/2012 07:19 AM, Paul Berry wrote: > A lot of code was still differentiating between between winsys and > user fbos by testing the fbo's name against zero. This converts > everything in core mesa, the state tracker, and src/mesa/program over > to use _mesa_is_user_fbo() and _mesa_is_winsys_fbo(). > --- > src/mesa/main/context.c | 8 ++++---- > src/mesa/main/drawpix.c | 4 +++- > src/mesa/main/framebuffer.c | 6 +++--- > src/mesa/main/readpix.c | 4 +++- > src/mesa/program/prog_statevars.c | 3 ++- > src/mesa/state_tracker/st_cb_viewport.c | 3 ++- > src/mesa/state_tracker/st_context.h | 3 ++- > src/mesa/state_tracker/st_manager.c | 3 ++- > 8 files changed, 21 insertions(+), 13 deletions(-) > > diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c > index 41550f9..243053e 100644 > --- a/src/mesa/main/context.c > +++ b/src/mesa/main/context.c > @@ -1456,8 +1456,8 @@ _mesa_make_current( struct gl_context *newCtx, > _glapi_set_dispatch(newCtx->CurrentDispatch); > > if (drawBuffer && readBuffer) { > - ASSERT(drawBuffer->Name == 0); > - ASSERT(readBuffer->Name == 0); > + ASSERT(_mesa_is_winsys_fbo(drawBuffer)); > + ASSERT(_mesa_is_winsys_fbo(readBuffer)); > _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer); > _mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer); > > @@ -1465,7 +1465,7 @@ _mesa_make_current( struct gl_context *newCtx, > * Only set the context's Draw/ReadBuffer fields if they're NULL > * or not bound to a user-created FBO. > */ > - if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { > + if (!newCtx->DrawBuffer || _mesa_is_winsys_fbo(newCtx->DrawBuffer)) > { > _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); > /* Update the FBO's list of drawbuffers/renderbuffers. > * For winsys FBOs this comes from the GL state (which may have > @@ -1473,7 +1473,7 @@ _mesa_make_current( struct gl_context *newCtx, > */ > _mesa_update_draw_buffers(newCtx); > } > - if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { > + if (!newCtx->ReadBuffer || _mesa_is_winsys_fbo(newCtx->ReadBuffer)) > { > _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); > } > > diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c > index 49b0782..bd9837f 100644 > --- a/src/mesa/main/drawpix.c > +++ b/src/mesa/main/drawpix.c > @@ -36,6 +36,7 @@ > #include "state.h" > #include "dispatch.h" > #include "glformats.h" > +#include "fbobject.h" > > > #if FEATURE_drawpix > @@ -240,7 +241,8 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, > GLsizei height, > goto end; > } > > - if (ctx->ReadBuffer->Name != 0 && ctx->ReadBuffer->Visual.samples > 0) { > + if (_mesa_is_user_fbo(ctx->ReadBuffer) && > + ctx->ReadBuffer->Visual.samples > 0) { > _mesa_error(ctx, GL_INVALID_OPERATION, > "glCopyPixels(multisample FBO)"); > goto end; > diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c > index f45ece6..13887f8 100644 > --- a/src/mesa/main/framebuffer.c > +++ b/src/mesa/main/framebuffer.c > @@ -347,7 +347,7 @@ _mesa_resizebuffers( struct gl_context *ctx ) > GLuint newWidth, newHeight; > struct gl_framebuffer *buffer = ctx->WinSysDrawBuffer; > > - assert(buffer->Name == 0); > + assert(_mesa_is_winsys_fbo(buffer)); > > /* ask device driver for size of output buffer */ > ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); > @@ -364,7 +364,7 @@ _mesa_resizebuffers( struct gl_context *ctx ) > GLuint newWidth, newHeight; > struct gl_framebuffer *buffer = ctx->WinSysReadBuffer; > > - assert(buffer->Name == 0); > + assert(_mesa_is_winsys_fbo(buffer)); > > /* ask device driver for size of read buffer */ > ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight ); > @@ -444,7 +444,7 @@ _mesa_update_draw_buffer_bounds(struct gl_context *ctx) > if (!buffer) > return; > > - if (buffer->Name) { > + if (_mesa_is_user_fbo(buffer)) { > /* user-created framebuffer size depends on the renderbuffers */ > update_framebuffer_size(ctx, buffer); > } > diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c > index 82d99fd..7ac8774 100644 > --- a/src/mesa/main/readpix.c > +++ b/src/mesa/main/readpix.c > @@ -37,6 +37,7 @@ > #include "pbo.h" > #include "state.h" > #include "glformats.h" > +#include "fbobject.h" > > > /** > @@ -722,7 +723,8 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, > GLsizei height, > } > } > > - if (ctx->ReadBuffer->Name != 0 && ctx->ReadBuffer->Visual.samples > 0) { > + if (_mesa_is_user_fbo(ctx->ReadBuffer) && > + ctx->ReadBuffer->Visual.samples > 0) { > _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(multisample > FBO)"); > return; > } > diff --git a/src/mesa/program/prog_statevars.c > b/src/mesa/program/prog_statevars.c > index 98ab9d0..e881c09 100644 > --- a/src/mesa/program/prog_statevars.c > +++ b/src/mesa/program/prog_statevars.c > @@ -34,6 +34,7 @@ > #include "main/imports.h" > #include "main/macros.h" > #include "main/mtypes.h" > +#include "main/fbobject.h" > #include "prog_statevars.h" > #include "prog_parameter.h" > > @@ -574,7 +575,7 @@ _mesa_fetch_state(struct gl_context *ctx, const > gl_state_index state[], > case STATE_FB_WPOS_Y_TRANSFORM: > /* A driver may negate this conditional by using ZW swizzle > * instead of XY (based on e.g. some other state). */ > - if (ctx->DrawBuffer->Name != 0) { > + if (_mesa_is_user_fbo(ctx->DrawBuffer)) { > /* Identity (XY) followed by flipping Y upside down (ZW). */ > value[0] = 1.0F; > value[1] = 0.0F; > diff --git a/src/mesa/state_tracker/st_cb_viewport.c > b/src/mesa/state_tracker/st_cb_viewport.c > index d4742eb..e6f33d3 100644 > --- a/src/mesa/state_tracker/st_cb_viewport.c > +++ b/src/mesa/state_tracker/st_cb_viewport.c > @@ -43,7 +43,8 @@ static INLINE struct st_framebuffer * > st_ws_framebuffer(struct gl_framebuffer *fb) > { > /* FBO cannot be casted. See st_new_framebuffer */ > - return (struct st_framebuffer *) ((fb && !fb->Name) ? fb : NULL); > + return (struct st_framebuffer *) ((fb && _mesa_is_winsys_fbo(fb)) ? > + fb : NULL); > }
Now that these are spilling onto more than one line, I think it would be more readable as: if (fb && _mesa_is_winsys_fbo(fb)) return (struct st_framebuffer *) fb; return NULL; But I don't care too much either way. > > static void st_viewport(struct gl_context * ctx, GLint x, GLint y, > diff --git a/src/mesa/state_tracker/st_context.h > b/src/mesa/state_tracker/st_context.h > index be8fef1..cdac5a1 100644 > --- a/src/mesa/state_tracker/st_context.h > +++ b/src/mesa/state_tracker/st_context.h > @@ -31,6 +31,7 @@ > #include "main/mtypes.h" > #include "pipe/p_state.h" > #include "state_tracker/st_api.h" > +#include "main/fbobject.h" > > struct bitmap_cache; > struct blit_state; > @@ -238,7 +239,7 @@ void st_invalidate_state(struct gl_context * ctx, GLuint > new_state); > static INLINE GLuint > st_fb_orientation(const struct gl_framebuffer *fb) > { > - if (fb && fb->Name == 0) { > + if (fb && _mesa_is_winsys_fbo(fb)) { > /* Drawing into a window (on-screen buffer). > * > * Negate Y scale to flip image vertically. > diff --git a/src/mesa/state_tracker/st_manager.c > b/src/mesa/state_tracker/st_manager.c > index 748624f..1d65f0e 100644 > --- a/src/mesa/state_tracker/st_manager.c > +++ b/src/mesa/state_tracker/st_manager.c > @@ -64,7 +64,8 @@ static INLINE struct st_framebuffer * > st_ws_framebuffer(struct gl_framebuffer *fb) > { > /* FBO cannot be casted. See st_new_framebuffer */ > - return (struct st_framebuffer *) ((fb && !fb->Name) ? fb : NULL); > + return (struct st_framebuffer *) ((fb && _mesa_is_winsys_fbo(fb)) ? > + fb : NULL); > } > > /** Ditto. With or without the changes, Reviewed-by: Kenneth Graunke <kenn...@whitecape.org> _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev