[Mesa-dev] [PATCH 17/22] swrast: move swrast_render_start/finish() call in drawpixels code

Brian Paul brianp at vmware.com
Sun Dec 18 19:08:22 PST 2011


We don't want to call these functions if where we'll be using
Map/UnmapRenderbuffer().  So push them further down in the drawpixels
cases so that we can switch over to Map/UnmapRenderbuffer() step by step.
---
 src/mesa/swrast/s_drawpix.c |   34 ++++++++++++++++++++++++----------
 1 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index 19b43f6..b4d91c0 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -111,6 +111,7 @@ fast_draw_rgba_pixels(struct gl_context *ctx, GLint x, GLint y,
    /*
     * Ready to draw!
     */
+   swrast_render_start(ctx);
 
    if (format == GL_RGBA && type == rbType) {
       const GLubyte *src
@@ -139,7 +140,7 @@ fast_draw_rgba_pixels(struct gl_context *ctx, GLint x, GLint y,
          }
          span.array->ChanType = CHAN_TYPE;
       }
-      return GL_TRUE;
+      goto end;
    }
 
    if (format == GL_RGB && type == rbType) {
@@ -170,12 +171,14 @@ fast_draw_rgba_pixels(struct gl_context *ctx, GLint x, GLint y,
          }
          span.array->ChanType = CHAN_TYPE;
       }
-      return GL_TRUE;
+      goto end;
    }
 
    /* Remaining cases haven't been tested with alignment != 1 */
-   if (userUnpack->Alignment != 1)
+   if (userUnpack->Alignment != 1) {
+      swrast_render_finish(ctx);
       return GL_FALSE;
+   }
 
    if (format == GL_LUMINANCE && type == CHAN_TYPE && rbType == CHAN_TYPE) {
       const GLchan *src = (const GLchan *) pixels
@@ -217,7 +220,7 @@ fast_draw_rgba_pixels(struct gl_context *ctx, GLint x, GLint y,
             destY++;
          }
       }
-      return GL_TRUE;
+      goto end;
    }
 
    if (format == GL_LUMINANCE_ALPHA && type == CHAN_TYPE && rbType == CHAN_TYPE) {
@@ -263,7 +266,7 @@ fast_draw_rgba_pixels(struct gl_context *ctx, GLint x, GLint y,
             destY++;
          }
       }
-      return GL_TRUE;
+      goto end;
    }
 
    if (format == GL_COLOR_INDEX && type == GL_UNSIGNED_BYTE) {
@@ -299,12 +302,17 @@ fast_draw_rgba_pixels(struct gl_context *ctx, GLint x, GLint y,
                destY++;
             }
          }
-         return GL_TRUE;
+         goto end;
       }
    }
 
    /* can't handle this pixel format and/or data type */
    return GL_FALSE;
+
+end:
+   /* success, unmap render buffers */
+   swrast_render_finish(ctx);
+   return GL_TRUE;
 }
 
 
@@ -480,6 +488,8 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
       return;
    }
 
+   swrast_render_start(ctx);
+
    INIT_SPAN(span, GL_BITMAP);
    _swrast_span_default_attribs(ctx, &span);
    span.arrayMask = SPAN_RGBA;
@@ -547,6 +557,8 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
    if (convImage) {
       free(convImage);
    }
+
+   swrast_render_finish(ctx);
 }
 
 
@@ -747,8 +759,6 @@ _swrast_DrawPixels( struct gl_context *ctx,
     */
    _mesa_set_vp_override(ctx, GL_TRUE);
 
-   swrast_render_start(ctx);
-
    if (ctx->NewState)
       _mesa_update_state(ctx);
 
@@ -757,7 +767,6 @@ _swrast_DrawPixels( struct gl_context *ctx,
 
    pixels = _mesa_map_pbo_source(ctx, unpack, pixels);
    if (!pixels) {
-      swrast_render_finish(ctx);
       _mesa_set_vp_override(ctx, save_vp_override);
       return;
    }
@@ -767,20 +776,25 @@ _swrast_DrawPixels( struct gl_context *ctx,
     */
    switch (format) {
    case GL_STENCIL_INDEX:
+      swrast_render_start(ctx);
       draw_stencil_pixels( ctx, x, y, width, height, type, unpack, pixels );
+      swrast_render_finish(ctx);
       break;
    case GL_DEPTH_COMPONENT:
+      swrast_render_start(ctx);
       draw_depth_pixels( ctx, x, y, width, height, type, unpack, pixels );
+      swrast_render_finish(ctx);
       break;
    case GL_DEPTH_STENCIL_EXT:
+      swrast_render_start(ctx);
       draw_depth_stencil_pixels(ctx, x, y, width, height, type, unpack, pixels);
+      swrast_render_finish(ctx);
       break;
    default:
       /* all other formats should be color formats */
       draw_rgba_pixels(ctx, x, y, width, height, format, type, unpack, pixels);
    }
 
-   swrast_render_finish(ctx);
    _mesa_set_vp_override(ctx, save_vp_override);
 
    _mesa_unmap_pbo_source(ctx, unpack);
-- 
1.7.3.4



More information about the mesa-dev mailing list