[g3dvl] move z-coord generation for multiple render targets into vertex shader
[mesa.git] / src / mesa / drivers / dri / intel / intel_pixel_read.c
index a98e8e16c240cbc9a83c418064f8230624c7783e..54da29236d252cec46dd7780231c4afd10b3d5b6 100644 (file)
@@ -42,6 +42,8 @@
 #include "intel_pixel.h"
 #include "intel_buffer_objects.h"
 
+#define FILE_DEBUG_FLAG DEBUG_PIXEL
+
 /* For many applications, the new ability to pull the source buffers
  * back out of the GTT and then do the packing/conversion operations
  * in software will be as much of an improvement as trying to get the
@@ -65,7 +67,7 @@
  */
 
 static GLboolean
-do_blit_readpixels(GLcontext * ctx,
+do_blit_readpixels(struct gl_context * ctx,
                    GLint x, GLint y, GLsizei width, GLsizei height,
                    GLenum format, GLenum type,
                    const struct gl_pixelstore_attrib *pack, GLvoid * pixels)
@@ -79,8 +81,7 @@ do_blit_readpixels(GLcontext * ctx,
    GLboolean all;
    GLint dst_x, dst_y;
 
-   if (INTEL_DEBUG & DEBUG_PIXEL)
-      _mesa_printf("%s\n", __FUNCTION__);
+   DBG("%s\n", __FUNCTION__);
 
    if (!src)
       return GL_FALSE;
@@ -88,22 +89,19 @@ do_blit_readpixels(GLcontext * ctx,
    if (!_mesa_is_bufferobj(pack->BufferObj)) {
       /* PBO only for now:
        */
-      if (INTEL_DEBUG & DEBUG_PIXEL)
-         _mesa_printf("%s - not PBO\n", __FUNCTION__);
+      DBG("%s - not PBO\n", __FUNCTION__);
       return GL_FALSE;
    }
 
 
    if (ctx->_ImageTransferState ||
        !intel_check_blit_format(src, format, type)) {
-      if (INTEL_DEBUG & DEBUG_PIXEL)
-         _mesa_printf("%s - bad format for blit\n", __FUNCTION__);
+      DBG("%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__);
+      DBG("%s: bad packing params\n", __FUNCTION__);
       return GL_FALSE;
    }
 
@@ -113,8 +111,7 @@ do_blit_readpixels(GLcontext * ctx,
       rowLength = width;
 
    if (pack->Invert) {
-      if (INTEL_DEBUG & DEBUG_PIXEL)
-         _mesa_printf("%s: MESA_PACK_INVERT not done yet\n", __FUNCTION__);
+      DBG("%s: MESA_PACK_INVERT not done yet\n", __FUNCTION__);
       return GL_FALSE;
    }
    else {
@@ -132,6 +129,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);
 
@@ -156,29 +155,35 @@ do_blit_readpixels(GLcontext * ctx,
       return GL_FALSE;
    }
 
-   if (INTEL_DEBUG & DEBUG_PIXEL)
-      _mesa_printf("%s - DONE\n", __FUNCTION__);
+   DBG("%s - DONE\n", __FUNCTION__);
 
    return GL_TRUE;
 }
 
 void
-intelReadPixels(GLcontext * ctx,
+intelReadPixels(struct gl_context * ctx,
                 GLint x, GLint y, GLsizei width, GLsizei height,
                 GLenum format, GLenum type,
                 const struct gl_pixelstore_attrib *pack, GLvoid * pixels)
 {
-   if (INTEL_DEBUG & DEBUG_PIXEL)
-      fprintf(stderr, "%s\n", __FUNCTION__);
+   struct intel_context *intel = intel_context(ctx);
+   GLboolean dirty;
 
-   intelFlush(ctx);
+   DBG("%s\n", __FUNCTION__);
+
+   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__);
+   fallback_debug("%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 +195,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;
 }