From: Brian Paul Date: Thu, 29 Jan 2009 23:05:39 +0000 (-0700) Subject: swrast: replace RENDER_START/FINISH macros with inline functions X-Git-Tag: 062012170305~17671^2~111 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d5b86be25a7ccb729e746aa5e1bdd537d76df68;p=profile%2Fivi%2Fmesa.git swrast: replace RENDER_START/FINISH macros with inline functions --- diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index ff74177..c6c7dbf 100644 --- a/src/mesa/swrast/s_accum.c +++ b/src/mesa/swrast/s_accum.c @@ -550,7 +550,7 @@ _swrast_Accum(GLcontext *ctx, GLenum op, GLfloat value) SWcontext *swrast = SWRAST_CONTEXT(ctx); GLint xpos, ypos, width, height; - if (SWRAST_CONTEXT(ctx)->NewState) + if (swrast->NewState) _swrast_validate_derived( ctx ); if (!ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer) { @@ -558,9 +558,9 @@ _swrast_Accum(GLcontext *ctx, GLenum op, GLfloat value) return; } - RENDER_START(swrast, ctx); + swrast_render_start(ctx); - /* Compute region after calling RENDER_START so that we know the + /* Compute region after calling swrast_render_start() so that we know the * drawbuffer's size/bounds are up to date. */ xpos = ctx->DrawBuffer->_Xmin; @@ -595,5 +595,5 @@ _swrast_Accum(GLcontext *ctx, GLenum op, GLfloat value) break; } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); } diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c index 35b34e6..5e7822c 100644 --- a/src/mesa/swrast/s_bitmap.c +++ b/src/mesa/swrast/s_bitmap.c @@ -50,7 +50,6 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap ) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLint row, col; GLuint count = 0; SWspan span; @@ -61,7 +60,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, if (!bitmap) return; - RENDER_START(swrast,ctx); + swrast_render_start(ctx); if (SWRAST_CONTEXT(ctx)->NewState) _swrast_validate_derived( ctx ); @@ -132,7 +131,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, } } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); _mesa_unmap_bitmap_pbo(ctx, unpack); } @@ -157,7 +156,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, ASSERT(ctx->RenderMode == GL_RENDER); ASSERT(bitmap); - RENDER_START(swrast,ctx); + swrast_render_start(ctx); if (SWRAST_CONTEXT(ctx)->NewState) _swrast_validate_derived( ctx ); @@ -224,6 +223,6 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, } } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); } #endif diff --git a/src/mesa/swrast/s_blit.c b/src/mesa/swrast/s_blit.c index bc4b2ac..0e32cb8 100644 --- a/src/mesa/swrast/s_blit.c +++ b/src/mesa/swrast/s_blit.c @@ -737,7 +737,6 @@ _swrast_BlitFramebuffer(GLcontext *ctx, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); static const GLint buffers[3] = { GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, @@ -753,7 +752,7 @@ _swrast_BlitFramebuffer(GLcontext *ctx, return; } - RENDER_START(swrast, ctx); + swrast_render_start(ctx); if (srcX1 - srcX0 == dstX1 - dstX0 && srcY1 - srcY0 == dstY1 - dstY0 && @@ -789,5 +788,5 @@ _swrast_BlitFramebuffer(GLcontext *ctx, } } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); } diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c index 9e87d6d..af475ad 100644 --- a/src/mesa/swrast/s_buffers.c +++ b/src/mesa/swrast/s_buffers.c @@ -307,8 +307,6 @@ clear_color_buffers(GLcontext *ctx) void _swrast_Clear(GLcontext *ctx, GLbitfield buffers) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); - #ifdef DEBUG_FOO { const GLbitfield legalBits = @@ -327,7 +325,7 @@ _swrast_Clear(GLcontext *ctx, GLbitfield buffers) } #endif - RENDER_START(swrast,ctx); + swrast_render_start(ctx); /* do software clearing here */ if (buffers) { @@ -347,5 +345,5 @@ _swrast_Clear(GLcontext *ctx, GLbitfield buffers) } } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); } diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index 46a5fa2..cdd6fa5 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -253,19 +253,28 @@ CONST_SWRAST_CONTEXT(const GLcontext *ctx) } -#define RENDER_START(SWctx, GLctx) \ - do { \ - if ((SWctx)->Driver.SpanRenderStart) { \ - (*(SWctx)->Driver.SpanRenderStart)(GLctx); \ - } \ - } while (0) - -#define RENDER_FINISH(SWctx, GLctx) \ - do { \ - if ((SWctx)->Driver.SpanRenderFinish) { \ - (*(SWctx)->Driver.SpanRenderFinish)(GLctx); \ - } \ - } while (0) +/** + * Called prior to framebuffer reading/writing. + * For drivers that rely on swrast for fallback rendering, this is the + * driver's opportunity to map renderbuffers and textures. + */ +static INLINE void +swrast_render_start(GLcontext *ctx) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + if (swrast->Driver.SpanRenderStart) + swrast->Driver.SpanRenderStart(ctx); +} + + +/** Called after framebuffer reading/writing */ +static INLINE void +swrast_render_finish(GLcontext *ctx) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + if (swrast->Driver.SpanRenderFinish) + swrast->Driver.SpanRenderFinish(ctx); +} diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index fc5990b..5ecfb1e 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -899,7 +899,7 @@ _swrast_CopyPixels( GLcontext *ctx, GLint destx, GLint desty, GLenum type ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - RENDER_START(swrast,ctx); + swrast_render_start(ctx); if (swrast->NewState) _swrast_validate_derived( ctx ); @@ -928,5 +928,5 @@ _swrast_CopyPixels( GLcontext *ctx, } } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); } diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 7af3e3d..2fc9fd0 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -830,7 +830,7 @@ _swrast_DrawPixels( GLcontext *ctx, { SWcontext *swrast = SWRAST_CONTEXT(ctx); - RENDER_START(swrast,ctx); + swrast_render_start(ctx); if (ctx->NewState) _mesa_update_state(ctx); @@ -840,7 +840,7 @@ _swrast_DrawPixels( GLcontext *ctx, pixels = _mesa_map_drawpix_pbo(ctx, unpack, pixels); if (!pixels) { - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); return; } @@ -879,7 +879,7 @@ _swrast_DrawPixels( GLcontext *ctx, /* don't return yet, clean-up */ } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); _mesa_unmap_drapix_pbo(ctx, unpack); } @@ -904,7 +904,7 @@ _swrast_DrawDepthPixelsMESA( GLcontext *ctx, if (swrast->NewState) _swrast_validate_derived( ctx ); - RENDER_START(swrast,ctx); + swrast_render_start(ctx); switch (colorFormat) { case GL_COLOR_INDEX: @@ -933,6 +933,6 @@ _swrast_DrawDepthPixelsMESA( GLcontext *ctx, _mesa_problem(ctx, "unexpected format in glDrawDepthPixelsMESA"); } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); } #endif diff --git a/src/mesa/swrast/s_imaging.c b/src/mesa/swrast/s_imaging.c index 591857c..d6be3aa 100644 --- a/src/mesa/swrast/s_imaging.c +++ b/src/mesa/swrast/s_imaging.c @@ -39,7 +39,6 @@ _swrast_CopyColorTable( GLcontext *ctx, GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLchan data[MAX_WIDTH][4]; struct gl_buffer_object *bufferSave; @@ -51,13 +50,13 @@ _swrast_CopyColorTable( GLcontext *ctx, if (width > MAX_WIDTH) width = MAX_WIDTH; - RENDER_START( swrast, ctx ); + swrast_render_start(ctx); /* read the data from framebuffer */ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, width, x, y, CHAN_TYPE, data ); - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); /* save PBO binding */ bufferSave = ctx->Unpack.BufferObj; @@ -74,7 +73,6 @@ void _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start, GLint x, GLint y, GLsizei width) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLchan data[MAX_WIDTH][4]; struct gl_buffer_object *bufferSave; @@ -86,13 +84,13 @@ _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start, if (width > MAX_WIDTH) width = MAX_WIDTH; - RENDER_START( swrast, ctx ); + swrast_render_start(ctx); /* read the data from framebuffer */ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, width, x, y, CHAN_TYPE, data ); - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); /* save PBO binding */ bufferSave = ctx->Unpack.BufferObj; @@ -110,7 +108,6 @@ _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLchan rgba[MAX_CONVOLUTION_WIDTH][4]; struct gl_buffer_object *bufferSave; @@ -119,13 +116,13 @@ _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, return; } - RENDER_START( swrast, ctx ); + swrast_render_start(ctx); /* read the data from framebuffer */ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, width, x, y, CHAN_TYPE, rgba ); - RENDER_FINISH( swrast, ctx ); + swrast_render_finish(ctx); /* save PBO binding */ bufferSave = ctx->Unpack.BufferObj; @@ -145,7 +142,6 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); struct gl_pixelstore_attrib packSave; GLchan rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4]; GLint i; @@ -156,7 +152,7 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, return; } - RENDER_START(swrast,ctx); + swrast_render_start(ctx); /* read pixels from framebuffer */ for (i = 0; i < height; i++) { @@ -164,7 +160,7 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, width, x, y + i, CHAN_TYPE, rgba[i] ); } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); /* * HACK: save & restore context state so we can store this as a diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index f263045..e901fc6 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -555,11 +555,11 @@ _swrast_ReadPixels( GLcontext *ctx, SWcontext *swrast = SWRAST_CONTEXT(ctx); struct gl_pixelstore_attrib clippedPacking = *packing; - /* Need to do RENDER_START before clipping or anything else since this - * is where a driver may grab the hw lock and get an updated window - * size. + /* Need to do swrast_render_start() before clipping or anything else + * since this is where a driver may grab the hw lock and get an updated + * window size. */ - RENDER_START(swrast, ctx); + swrast_render_start(ctx); if (ctx->NewState) _mesa_update_state(ctx); @@ -570,7 +570,7 @@ _swrast_ReadPixels( GLcontext *ctx, /* Do all needed clipping here, so that we can forget about it later */ if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) { /* The ReadPixels region is totally outside the window bounds */ - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); return; } @@ -614,7 +614,7 @@ _swrast_ReadPixels( GLcontext *ctx, /* don't return yet, clean-up */ } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); _mesa_unmap_readpix_pbo(ctx, &clippedPacking); } diff --git a/src/mesa/swrast/s_texstore.c b/src/mesa/swrast/s_texstore.c index 16b00b9..f9ff9ad 100644 --- a/src/mesa/swrast/s_texstore.c +++ b/src/mesa/swrast/s_texstore.c @@ -67,7 +67,6 @@ static GLvoid * read_color_image( GLcontext *ctx, GLint x, GLint y, GLenum type, GLsizei width, GLsizei height ) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; const GLint pixelSize = _mesa_bytes_per_pixel(GL_RGBA, type); const GLint stride = width * pixelSize; @@ -78,7 +77,7 @@ read_color_image( GLcontext *ctx, GLint x, GLint y, GLenum type, if (!image) return NULL; - RENDER_START(swrast, ctx); + swrast_render_start(ctx); dst = image; for (row = 0; row < height; row++) { @@ -86,7 +85,7 @@ read_color_image( GLcontext *ctx, GLint x, GLint y, GLenum type, dst += stride; } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); return image; } @@ -101,7 +100,6 @@ read_depth_image( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height ) { struct gl_renderbuffer *rb = ctx->ReadBuffer->_DepthBuffer; - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLuint *image, *dst; GLint i; @@ -109,7 +107,7 @@ read_depth_image( GLcontext *ctx, GLint x, GLint y, if (!image) return NULL; - RENDER_START(swrast, ctx); + swrast_render_start(ctx); dst = image; for (i = 0; i < height; i++) { @@ -117,7 +115,7 @@ read_depth_image( GLcontext *ctx, GLint x, GLint y, dst += width; } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); return image; } @@ -132,7 +130,6 @@ read_depth_stencil_image(GLcontext *ctx, GLint x, GLint y, { struct gl_renderbuffer *depthRb = ctx->ReadBuffer->_DepthBuffer; struct gl_renderbuffer *stencilRb = ctx->ReadBuffer->_StencilBuffer; - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLuint *image, *dst; GLint i; @@ -143,7 +140,7 @@ read_depth_stencil_image(GLcontext *ctx, GLint x, GLint y, if (!image) return NULL; - RENDER_START(swrast, ctx); + swrast_render_start(ctx); /* read from depth buffer */ dst = image; @@ -205,7 +202,7 @@ read_depth_stencil_image(GLcontext *ctx, GLint x, GLint y, dst += width; } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); return image; }