gallium/draw: initial code to properly support llvm in the draw module
[mesa.git] / src / mesa / drivers / dri / r200 / r200_pixel.c
index eefa2a1e11aef11c6574cf4f9cb36870265dd29e..bfb7e2a2ed3f8370c3ed357fb691e080e456c56c 100644 (file)
@@ -53,27 +53,27 @@ check_color( const GLcontext *ctx, GLenum type, GLenum format,
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    GLuint cpp = rmesa->radeon.radeonScreen->cpp;
 
-   if (R200_DEBUG & DEBUG_PIXEL)
+   if (R200_DEBUG & RADEON_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
    if (        (pitch & 63) ||
        ctx->_ImageTransferState ||
        packing->SwapBytes ||
        packing->LsbFirst) {
-      if (R200_DEBUG & DEBUG_PIXEL)
+      if (R200_DEBUG & RADEON_PIXEL)
         fprintf(stderr, "%s: failed 1\n", __FUNCTION__);
       return GL_FALSE;
    }
 
-   if ( type == GL_UNSIGNED_INT_8_8_8_8_REV && 
-       cpp == 4 && 
+   if ( type == GL_UNSIGNED_INT_8_8_8_8_REV &&
+       cpp == 4 &&
        format == GL_BGRA ) {
-      if (R200_DEBUG & DEBUG_PIXEL)
+      if (R200_DEBUG & RADEON_PIXEL)
         fprintf(stderr, "%s: passed 2\n", __FUNCTION__);
       return GL_TRUE;
    }
 
-   if (R200_DEBUG & DEBUG_PIXEL)
+   if (R200_DEBUG & RADEON_PIXEL)
       fprintf(stderr, "%s: failed\n", __FUNCTION__);
 
    return GL_FALSE;
@@ -83,25 +83,25 @@ static GLboolean
 check_color_per_fragment_ops( const GLcontext *ctx )
 {
    int result;
-   result = (!(     ctx->Color.AlphaEnabled || 
+   result = (!(     ctx->Color.AlphaEnabled ||
                    ctx->Depth.Test ||
                    ctx->Fog.Enabled ||
                    ctx->Scissor.Enabled ||
-                   ctx->Stencil.Enabled ||
-                   !ctx->Color.ColorMask[0] ||
-                   !ctx->Color.ColorMask[1] ||
-                   !ctx->Color.ColorMask[2] ||
-                   !ctx->Color.ColorMask[3] ||
+                   ctx->Stencil._Enabled ||
+                   !ctx->Color.ColorMask[0][0] ||
+                   !ctx->Color.ColorMask[0][1] ||
+                   !ctx->Color.ColorMask[0][2] ||
+                   !ctx->Color.ColorMask[0][3] ||
                    ctx->Color.ColorLogicOpEnabled ||
                    ctx->Texture._EnabledUnits
            ) &&
           ctx->Current.RasterPosValid);
-   
+
    return result;
 }
 
 
-
+#if 0
 static GLboolean
 clip_pixelrect( const GLcontext *ctx,
                const GLframebuffer *buffer,
@@ -142,6 +142,7 @@ clip_pixelrect( const GLcontext *ctx,
 
    return GL_TRUE;
 }
+#endif
 
 static GLboolean
 r200TryReadPixels( GLcontext *ctx,
@@ -150,22 +151,22 @@ r200TryReadPixels( GLcontext *ctx,
                  const struct gl_pixelstore_attrib *pack,
                  GLvoid *pixels )
 {
+   return GL_FALSE;
+#if 0
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    GLint pitch = pack->RowLength ? pack->RowLength : width;
    GLint blit_format;
    GLuint cpp = rmesa->radeon.radeonScreen->cpp;
    GLint size = width * height * cpp;
 
-   return GL_FALSE;
-#if 0
-   if (R200_DEBUG & DEBUG_PIXEL)
+   if (R200_DEBUG & RADEON_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
    /* Only accelerate reading to GART buffers.
     */
-   if ( !r200IsGartMemory(rmesa, pixels, 
+   if ( !r200IsGartMemory(rmesa, pixels,
                         pitch * height * rmesa->radeon.radeonScreen->cpp ) ) {
-      if (R200_DEBUG & DEBUG_PIXEL)
+      if (R200_DEBUG & RADEON_PIXEL)
         fprintf(stderr, "%s: dest not GART\n", __FUNCTION__);
    }
 
@@ -173,7 +174,7 @@ r200TryReadPixels( GLcontext *ctx,
     * blitter:
     */
    if (!pack->Invert) {
-      if (R200_DEBUG & DEBUG_PIXEL)
+      if (R200_DEBUG & RADEON_PIXEL)
         fprintf(stderr, "%s: MESA_PACK_INVERT not set\n", __FUNCTION__);
       return GL_FALSE;
    }
@@ -206,14 +207,14 @@ r200TryReadPixels( GLcontext *ctx,
    if (!clip_pixelrect(ctx, ctx->ReadBuffer, &x, &y, &width, &height,
                       &size)) {
       UNLOCK_HARDWARE( &rmesa->radeon );
-      if (R200_DEBUG & DEBUG_PIXEL)
+      if (R200_DEBUG & RADEON_PIXEL)
         fprintf(stderr, "%s totally clipped -- nothing to do\n",
                 __FUNCTION__);
       return GL_TRUE;
    }
 
    {
-      __DRIdrawablePrivate *dPriv = rmesa->radeon.dri.drawable;
+      __DRIdrawable *dPriv = rmesa->radeon.dri.drawable;
       driRenderbuffer *drb = (driRenderbuffer *) ctx->ReadBuffer->_ColorReadBuffer;
       int nbox = dPriv->numClipRects;
       int src_offset = drb->offset
@@ -224,14 +225,14 @@ r200TryReadPixels( GLcontext *ctx,
       drm_clip_rect_t *box = dPriv->pClipRects;
       int i;
 
-      r200EmitWait( rmesa, RADEON_WAIT_3D ); 
+      r200EmitWait( rmesa, RADEON_WAIT_3D );
 
       y = dPriv->h - y - height;
       x += dPriv->x;
       y += dPriv->y;
 
 
-      if (R200_DEBUG & DEBUG_PIXEL)
+      if (R200_DEBUG & RADEON_PIXEL)
         fprintf(stderr, "readpixel blit src_pitch %d dst_pitch %d\n",
                 src_pitch, dst_pitch);
 
@@ -241,7 +242,7 @@ r200TryReadPixels( GLcontext *ctx,
         GLint by = box[i].y1;
         GLint bw = box[i].x2 - bx;
         GLint bh = box[i].y2 - by;
-        
+
         if (bx < x) bw -= x - bx, bx = x;
         if (by < y) bh -= y - by, by = y;
         if (bx + bw > x + width) bw = x + width - bx;
@@ -262,7 +263,7 @@ r200TryReadPixels( GLcontext *ctx,
    }
    UNLOCK_HARDWARE( &rmesa->radeon );
 
-   r200Finish( ctx ); /* required by GL */
+   radeonFinish( ctx ); /* required by GL */
 #endif
    return GL_TRUE;
 }
@@ -274,12 +275,12 @@ r200ReadPixels( GLcontext *ctx,
                 const struct gl_pixelstore_attrib *pack,
                 GLvoid *pixels )
 {
-   if (R200_DEBUG & DEBUG_PIXEL)
+   if (R200_DEBUG & RADEON_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
-   if (!r200TryReadPixels( ctx, x, y, width, height, format, type, pack, 
+   if (!r200TryReadPixels( ctx, x, y, width, height, format, type, pack,
                           pixels))
-      _swrast_ReadPixels( ctx, x, y, width, height, format, type, pack, 
+      _swrast_ReadPixels( ctx, x, y, width, height, format, type, pack,
                          pixels);
 }
 
@@ -292,8 +293,12 @@ static void do_draw_pix( GLcontext *ctx,
                         const void *pixels,
                         GLuint planemask)
 {
+   if (R200_DEBUG & RADEON_PIXEL)
+      fprintf(stderr, "%s\n", __FUNCTION__);
+
+#if 0
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   __DRIdrawablePrivate *dPriv = rmesa->radeon.dri.drawable;
+   __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon);
    drm_clip_rect_t *box = dPriv->pClipRects;
    struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorDrawBuffers[0];
    driRenderbuffer *drb = (driRenderbuffer *) rb;
@@ -304,9 +309,6 @@ static void do_draw_pix( GLcontext *ctx,
    int src_offset = r200GartOffsetFromVirtual( rmesa, pixels );
    int src_pitch = pitch * rmesa->radeon.radeonScreen->cpp;
 
-   if (R200_DEBUG & DEBUG_PIXEL)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-#if 0
    switch ( rmesa->radeon.radeonScreen->cpp ) {
    case 2:
       blit_format = R200_CP_COLOR_FORMAT_RGB565;
@@ -325,7 +327,7 @@ static void do_draw_pix( GLcontext *ctx,
       rcommonFlushCmdBufLocked( &rmesa->radeon, __FUNCTION__ );
 
    y -= height;                        /* cope with pixel zoom */
-   
+
    if (!clip_pixelrect(ctx, ctx->DrawBuffer,
                       &x, &y, &width, &height,
                       &size)) {
@@ -386,7 +388,7 @@ r200TryDrawPixels( GLcontext *ctx,
    GLuint cpp = rmesa->radeon.radeonScreen->cpp;
    GLint size = height * pitch * cpp;
 
-   if (R200_DEBUG & DEBUG_PIXEL)
+   if (R200_DEBUG & RADEON_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
    /* check that we're drawing to exactly one color buffer */
@@ -398,10 +400,10 @@ r200TryDrawPixels( GLcontext *ctx,
    case GL_RGBA:
    case GL_BGRA:
       planemask = radeonPackColor(cpp,
-                               ctx->Color.ColorMask[RCOMP],
-                               ctx->Color.ColorMask[GCOMP],
-                               ctx->Color.ColorMask[BCOMP],
-                               ctx->Color.ColorMask[ACOMP]);
+                               ctx->Color.ColorMask[0][RCOMP],
+                               ctx->Color.ColorMask[0][GCOMP],
+                               ctx->Color.ColorMask[0][BCOMP],
+                               ctx->Color.ColorMask[0][ACOMP]);
 
       if (cpp == 2)
         planemask |= planemask << 16;
@@ -409,10 +411,10 @@ r200TryDrawPixels( GLcontext *ctx,
       if (planemask != ~0)
         return GL_FALSE;       /* fix me -- should be possible */
 
-      /* Can't do conversions on GART reads/draws. 
+      /* Can't do conversions on GART reads/draws.
        */
       if ( !r200IsGartMemory( rmesa, pixels, size ) ) {
-        if (R200_DEBUG & DEBUG_PIXEL)
+        if (R200_DEBUG & RADEON_PIXEL)
            fprintf(stderr, "%s: not GART memory\n", __FUNCTION__);
         return GL_FALSE;
       }
@@ -455,7 +457,7 @@ r200DrawPixels( GLcontext *ctx,
                 const struct gl_pixelstore_attrib *unpack,
                 const GLvoid *pixels )
 {
-   if (R200_DEBUG & DEBUG_PIXEL)
+   if (R200_DEBUG & RADEON_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
    if (!r200TryDrawPixels( ctx, x, y, width, height, format, type,
@@ -484,9 +486,9 @@ r200Bitmap( GLcontext *ctx, GLint px, GLint py,
 void r200InitPixelFuncs( GLcontext *ctx )
 {
    if (!getenv("R200_NO_BLITS")) {
-      ctx->Driver.ReadPixels = r200ReadPixels;  
-      ctx->Driver.DrawPixels = r200DrawPixels; 
-      if (getenv("R200_HW_BITMAP")) 
+      ctx->Driver.ReadPixels = r200ReadPixels;
+      ctx->Driver.DrawPixels = r200DrawPixels;
+      if (getenv("R200_HW_BITMAP"))
         ctx->Driver.Bitmap = r200Bitmap;
    }
 }