swrast: move resampleRow setup code in blit_nearest()
authorBrian Paul <brianp@vmware.com>
Mon, 21 Jan 2013 15:59:25 +0000 (08:59 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 22 Jan 2013 21:53:58 +0000 (14:53 -0700)
The resampleRow setup depends on pixelSize.  For color buffers,
we don't know the pixelSize until we're in the buffer loop.  Move
that code inside the loop.

Fixes: http://bugs.freedesktop.org/show_bug.cgi?id=59541
Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/mesa/swrast/s_blit.c

index 3a4e7eec001001dc1e5b408dca35f4ddf0bc3868..605c80ade140061706bb283977699899b34d8990 100644 (file)
@@ -188,29 +188,6 @@ blit_nearest(struct gl_context *ctx,
       return;
    }
 
-   /* choose row resampler */
-   switch (pixelSize) {
-   case 1:
-      resampleRow = resample_row_1;
-      break;
-   case 2:
-      resampleRow = resample_row_2;
-      break;
-   case 4:
-      resampleRow = resample_row_4;
-      break;
-   case 8:
-      resampleRow = resample_row_8;
-      break;
-   case 16:
-      resampleRow = resample_row_16;
-      break;
-   default:
-      _mesa_problem(ctx, "unexpected pixel size (%d) in blit_nearest",
-                    pixelSize);
-      return;
-   }
-
    /* Blit to all the draw buffers */
    for (i = 0; i < numDrawBuffers; i++) {
       if (buffer == GL_COLOR_BUFFER_BIT) {
@@ -232,6 +209,29 @@ blit_nearest(struct gl_context *ctx,
          }
       }
 
+      /* choose row resampler */
+      switch (pixelSize) {
+      case 1:
+         resampleRow = resample_row_1;
+         break;
+      case 2:
+         resampleRow = resample_row_2;
+         break;
+      case 4:
+         resampleRow = resample_row_4;
+         break;
+      case 8:
+         resampleRow = resample_row_8;
+         break;
+      case 16:
+         resampleRow = resample_row_16;
+         break;
+      default:
+         _mesa_problem(ctx, "unexpected pixel size (%d) in blit_nearest",
+                       pixelSize);
+         return;
+      }
+
       if ((readRb == drawRb) ||
           (readAtt->Texture && drawAtt->Texture &&
            (readAtt->Texture == drawAtt->Texture))) {