i965: Add program dumping for INTEL_DEBUG=gs.
[mesa.git] / src / mesa / drivers / dri / intel / intel_pixel_read.c
index a98e8e16c240cbc9a83c418064f8230624c7783e..21d2a7a93e2062ef03cdab7ec2595ca783ac7355 100644 (file)
@@ -80,7 +80,7 @@ do_blit_readpixels(GLcontext * ctx,
    GLint dst_x, dst_y;
 
    if (INTEL_DEBUG & DEBUG_PIXEL)
-      _mesa_printf("%s\n", __FUNCTION__);
+      printf("%s\n", __FUNCTION__);
 
    if (!src)
       return GL_FALSE;
@@ -89,7 +89,7 @@ do_blit_readpixels(GLcontext * ctx,
       /* PBO only for now:
        */
       if (INTEL_DEBUG & DEBUG_PIXEL)
-         _mesa_printf("%s - not PBO\n", __FUNCTION__);
+         printf("%s - not PBO\n", __FUNCTION__);
       return GL_FALSE;
    }
 
@@ -97,13 +97,13 @@ do_blit_readpixels(GLcontext * ctx,
    if (ctx->_ImageTransferState ||
        !intel_check_blit_format(src, format, type)) {
       if (INTEL_DEBUG & DEBUG_PIXEL)
-         _mesa_printf("%s - bad format for blit\n", __FUNCTION__);
+         printf("%s - bad format for blit\n", __FUNCTION__);
       return GL_FALSE;
    }
 
    if (pack->Alignment != 1 || pack->SwapBytes || pack->LsbFirst) {
       if (INTEL_DEBUG & DEBUG_PIXEL)
-         _mesa_printf("%s: bad packing params\n", __FUNCTION__);
+         printf("%s: bad packing params\n", __FUNCTION__);
       return GL_FALSE;
    }
 
@@ -114,7 +114,7 @@ do_blit_readpixels(GLcontext * ctx,
 
    if (pack->Invert) {
       if (INTEL_DEBUG & DEBUG_PIXEL)
-         _mesa_printf("%s: MESA_PACK_INVERT not done yet\n", __FUNCTION__);
+         printf("%s: MESA_PACK_INVERT not done yet\n", __FUNCTION__);
       return GL_FALSE;
    }
    else {
@@ -132,6 +132,8 @@ do_blit_readpixels(GLcontext * ctx,
       return GL_TRUE;
    }
 
+   intel_prepare_render(intel);
+
    all = (width * height * src->cpp == dst->Base.Size &&
          x == 0 && dst_offset == 0);
 
@@ -157,7 +159,7 @@ do_blit_readpixels(GLcontext * ctx,
    }
 
    if (INTEL_DEBUG & DEBUG_PIXEL)
-      _mesa_printf("%s - DONE\n", __FUNCTION__);
+      printf("%s - DONE\n", __FUNCTION__);
 
    return GL_TRUE;
 }
@@ -168,17 +170,26 @@ intelReadPixels(GLcontext * ctx,
                 GLenum format, GLenum type,
                 const struct gl_pixelstore_attrib *pack, GLvoid * pixels)
 {
+   struct intel_context *intel = intel_context(ctx);
+   GLboolean dirty;
+
    if (INTEL_DEBUG & DEBUG_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
-   intelFlush(ctx);
+   intel_flush(ctx);
+
+   /* glReadPixels() wont dirty the front buffer, so reset the dirty
+    * flag after calling intel_prepare_render(). */
+   dirty = intel->front_buffer_dirty;
+   intel_prepare_render(intel);
+   intel->front_buffer_dirty = dirty;
 
    if (do_blit_readpixels
        (ctx, x, y, width, height, format, type, pack, pixels))
       return;
 
    if (INTEL_DEBUG & DEBUG_PIXEL)
-      _mesa_printf("%s: fallback to swrast\n", __FUNCTION__);
+      printf("%s: fallback to swrast\n", __FUNCTION__);
 
    /* Update Mesa state before calling down into _swrast_ReadPixels, as
     * the spans code requires the computed buffer states to be up to date,
@@ -190,4 +201,7 @@ intelReadPixels(GLcontext * ctx,
       _mesa_update_state(ctx);
 
    _swrast_ReadPixels(ctx, x, y, width, height, format, type, pack, pixels);
+
+   /* There's an intel_prepare_render() call in intelSpanRenderStart(). */
+   intel->front_buffer_dirty = dirty;
 }