fix up radeon span functions using latest r200 code from Brian,
[mesa.git] / src / mesa / drivers / dri / r200 / r200_pixel.c
index 806484404d67c57c75e5f5b3d5b11524c21ddb80..c3489b6c621a20afa523757b63a041c8eaa4fa87 100644 (file)
@@ -36,7 +36,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "enums.h"
 #include "mtypes.h"
 #include "macros.h"
-#include "texutil.h"
 #include "swrast/swrast.h"
 
 #include "r200_context.h"
@@ -44,6 +43,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_pixel.h"
 #include "r200_swtcl.h"
 
+#include "drirenderbuffer.h"
 
 
 static GLboolean
@@ -94,8 +94,7 @@ check_color_per_fragment_ops( const GLcontext *ctx )
                    !ctx->Color.ColorMask[2] ||
                    !ctx->Color.ColorMask[3] ||
                    ctx->Color.ColorLogicOpEnabled ||
-                   ctx->Texture._EnabledUnits ||
-                   ctx->Depth.OcclusionTest
+                   ctx->Texture._EnabledUnits
            ) &&
           ctx->Current.RasterPosValid);
    
@@ -153,9 +152,10 @@ r200TryReadPixels( GLcontext *ctx,
                  GLvoid *pixels )
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   GLint size;
    GLint pitch = pack->RowLength ? pack->RowLength : width;
    GLint blit_format;
+   GLuint cpp = rmesa->r200Screen->cpp;
+   GLint size = width * height * cpp;
 
    if (R200_DEBUG & DEBUG_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
@@ -214,13 +214,14 @@ r200TryReadPixels( GLcontext *ctx,
 
    {
       __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+      driRenderbuffer *drb = (driRenderbuffer *) ctx->ReadBuffer->_ColorReadBuffer;
       int nbox = dPriv->numClipRects;
-      int src_offset = rmesa->state.color.drawOffset
+      int src_offset = drb->offset
                     + rmesa->r200Screen->fbLocation;
-      int src_pitch = rmesa->state.color.drawPitch * rmesa->r200Screen->cpp;
+      int src_pitch = drb->pitch * drb->cpp;
       int dst_offset = r200GartOffsetFromVirtual( rmesa, pixels );
       int dst_pitch = pitch * rmesa->r200Screen->cpp;
-      XF86DRIClipRectRec *box = dPriv->pClipRects;
+      drm_clip_rect_t *box = dPriv->pClipRects;
       int i;
 
       r200EmitWait( rmesa, RADEON_WAIT_3D ); 
@@ -293,7 +294,9 @@ static void do_draw_pix( GLcontext *ctx,
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
-   XF86DRIClipRectPtr box = dPriv->pClipRects;
+   drm_clip_rect_t *box = dPriv->pClipRects;
+   struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorDrawBuffers[0][0];
+   driRenderbuffer *drb = (driRenderbuffer *) rb;
    int nbox = dPriv->numClipRects;
    int i;
    int blit_format;
@@ -354,8 +357,8 @@ static void do_draw_pix( GLcontext *ctx,
       r200EmitBlit( rmesa,
                    blit_format,
                    src_pitch, src_offset,
-                   rmesa->state.color.drawPitch * rmesa->r200Screen->cpp,
-                   rmesa->state.color.drawOffset + rmesa->r200Screen->fbLocation,
+                   drb->pitch * drb->cpp,
+                   drb->offset + rmesa->r200Screen->fbLocation,
                    bx - x, by - y,
                    bx, by,
                    bw, bh );
@@ -385,6 +388,10 @@ r200TryDrawPixels( GLcontext *ctx,
    if (R200_DEBUG & DEBUG_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
+   /* check that we're drawing to exactly one color buffer */
+   if (ctx->DrawBuffer->_NumColorDrawBuffers[0] != 1)
+     return GL_FALSE;
+
    switch (format) {
    case GL_RGB:
    case GL_RGBA: