i965: Add support for non-color render target write data to new FS backend.
[mesa.git] / src / mesa / drivers / dri / mga / mgapixel.c
index df6489ccb98b1e248663ba140a45beff8eb85201..9cbdbe02c942941f2c35a417ee398c354714096a 100644 (file)
  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file mgapixel.c
+ * Implement framebuffer pixel operations for MGA.
  *
- * Authors:
- *    Keith Whitwell <keith@tungstengraphics.com>
- *    Gareth Hughes <gareth@valinux.com>
+ * \todo
+ * Someday the accelerated \c glReadPixels and \c glDrawPixels paths need to
+ * be resurrected.  They are currently ifdef'ed out because they don't seem
+ * to work and they only get activated some very rare circumstances.
+ *
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ * \author Gareth Hughes <gareth@valinux.com>
  */
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgapixel.c,v 1.9 2002/11/05 17:46:08 tsi Exp $ */
 
-#include "enums.h"
-#include "mtypes.h"
-#include "macros.h"
-#include "texutil.h"
+#include "main/mtypes.h"
+#include "main/macros.h"
 #include "mgadd.h"
 #include "mgacontext.h"
 #include "mgaioctl.h"
@@ -38,8 +44,9 @@
 #include "mgastate.h"
 
 #include "swrast/swrast.h"
-#include "imports.h"
+#include "main/imports.h"
 
+#if 0
 #define IS_AGP_MEM( mmesa, p )                                           \
    ((unsigned long)mmesa->mgaScreen->buffers.map <= ((unsigned long)p) && \
     (unsigned long)mmesa->mgaScreen->buffers.map +                       \
@@ -48,7 +55,6 @@
      (((unsigned long)p) - (unsigned long)mmesa->mgaScreen->buffers.map)
 
 
-#if defined(MESA_packed_depth_stencil)
 static GLboolean
 check_depth_stencil_24_8( const GLcontext *ctx, GLenum type,
                          const struct gl_pixelstore_attrib *packing,
@@ -57,7 +63,7 @@ check_depth_stencil_24_8( const GLcontext *ctx, GLenum type,
 {
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);
 
-   return ( type == GL_UNSIGNED_INT_24_8_MESA &&
+   return ( type == GL_UNSIGNED_INT_24_8 &&
            ctx->Visual->DepthBits == 24 &&
            ctx->Visual->StencilBits == 8 &&
            mmesa->mgaScreen->cpp == 4 &&
@@ -71,7 +77,6 @@ check_depth_stencil_24_8( const GLcontext *ctx, GLenum type,
            pitch % 32 == 0 &&
            pitch < 4096 );
 }
-#endif
 
 
 static GLboolean
@@ -126,14 +131,13 @@ check_color_per_fragment_ops( const GLcontext *ctx )
                    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->Depth.OcclusionTest
+                   ctx->Texture._EnabledUnits
            ) &&
           ctx->Current.RasterPosValid &&
           ctx->Pixel.ZoomX == 1.0F &&
@@ -144,10 +148,10 @@ static GLboolean
 check_depth_per_fragment_ops( const GLcontext *ctx )
 {
    return ( ctx->Current.RasterPosValid &&
-           ctx->Color.ColorMask[RCOMP] == 0 &&
-           ctx->Color.ColorMask[BCOMP] == 0 &&
-           ctx->Color.ColorMask[GCOMP] == 0 &&
-           ctx->Color.ColorMask[ACOMP] == 0 &&
+           ctx->Color.ColorMask[0][RCOMP] == 0 &&
+           ctx->Color.ColorMask[0][BCOMP] == 0 &&
+           ctx->Color.ColorMask[0][GCOMP] == 0 &&
+           ctx->Color.ColorMask[0][ACOMP] == 0 &&
            ctx->Pixel.ZoomX == 1.0F &&
            ( ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F ) );
 }
@@ -246,13 +250,11 @@ mgaTryReadPixels( GLcontext *ctx,
       return GL_FALSE;
 
    switch (format) {
-#if defined(MESA_packed_depth_stencil)
-   case GL_DEPTH_STENCIL_MESA:
+   case GL_DEPTH_STENCIL:
       ok = check_depth_stencil_24_8(ctx, type, pack, pixels, size, pitch);
       planemask = ~0;
       source = mmesa->mgaScreen->depthOffset;
       break;
-#endif
 
    case GL_DEPTH_COMPONENT:
       ok = check_depth(ctx, type, pack, pixels, size, pitch);
@@ -293,7 +295,7 @@ mgaTryReadPixels( GLcontext *ctx,
 
 #if 0
    {
-      __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+      __DRIdrawable *dPriv = mmesa->driDrawable;
       int nbox, retcode, i;
 
       UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT );
@@ -326,7 +328,7 @@ mgaTryReadPixels( GLcontext *ctx,
       for (i = 0 ; i < nbox ; )
       {
         int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
-        XF86DRIClipRectRec *box = dPriv->pClipRects;
+        drm_clip_rect_t *box = dPriv->pClipRects;
         drm_clip_rect_t *b = mmesa->sarea->boxes;
         int n = 0;
 
@@ -393,8 +395,8 @@ static void do_draw_pix( GLcontext *ctx,
 #if 0
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);
    drmMGABlit blit;
-   __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
-   XF86DRIClipRectPtr pbox = dPriv->pClipRects;
+   __DRIdrawable *dPriv = mmesa->driDrawable;
+   drm_clip_rect_t pbox = dPriv->pClipRects;
    int nbox = dPriv->numClipRects;
    int retcode, i;
 
@@ -427,7 +429,7 @@ static void do_draw_pix( GLcontext *ctx,
    for (i = 0 ; i < nbox ; )
    {
       int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
-      XF86DRIClipRectRec *box = mmesa->pClipRects;
+      drm_clip_rect_t *box = mmesa->pClipRects;
       drm_clip_rect_t *b = mmesa->sarea->boxes;
       int n = 0;
 
@@ -488,8 +490,7 @@ mgaTryDrawPixels( GLcontext *ctx,
 
 
    switch (format) {
-#if defined(MESA_packed_depth_stencil)
-   case GL_DEPTH_STENCIL_MESA:
+   case GL_DEPTH_STENCIL:
       dest = mmesa->mgaScreen->depthOffset;
       planemask = ~0;
       if (!check_depth_stencil_24_8(ctx, type, unpack, pixels, size, pitch) ||
@@ -497,7 +498,6 @@ mgaTryDrawPixels( GLcontext *ctx,
          !check_stencil_per_fragment_ops(ctx))
         return GL_FALSE;
       break;
-#endif
 
    case GL_DEPTH_COMPONENT:
       dest = mmesa->mgaScreen->depthOffset;
@@ -519,10 +519,10 @@ mgaTryDrawPixels( GLcontext *ctx,
              mmesa->mgaScreen->backOffset);
 
       planemask = mgaPackColor(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;
@@ -594,7 +594,7 @@ mgaTryDrawPixels( GLcontext *ctx,
            }
         }
 #else
-        MEMCPY( address, pixels, rows*bufferpitch );
+        memcpy( address, pixels, rows*bufferpitch );
 #endif
 
         do_draw_pix( ctx, x, y, width, rows,
@@ -630,7 +630,7 @@ mgaDDDrawPixels( GLcontext *ctx,
       _swrast_DrawPixels( ctx, x, y, width, height, format, type,
                          unpack, pixels );
 }
-
+#endif
 
 
 /* Stub functions - not a real allocator, always returns pointer to
@@ -639,16 +639,11 @@ mgaDDDrawPixels( GLcontext *ctx,
  */
 void mgaDDInitPixelFuncs( GLcontext *ctx )
 {
-   /* Pixel path fallbacks.
-    */
-   ctx->Driver.Accum = _swrast_Accum;
-   ctx->Driver.Bitmap = _swrast_Bitmap;
-   ctx->Driver.CopyPixels = _swrast_CopyPixels;
-   ctx->Driver.DrawPixels = _swrast_DrawPixels;
-   ctx->Driver.ReadPixels = _swrast_ReadPixels;
-
+#if 0
+   /* evidently, these functions don't always work */
    if (getenv("MGA_BLIT_PIXELS")) {
       ctx->Driver.ReadPixels = mgaDDReadPixels; /* requires agp dest */
       ctx->Driver.DrawPixels = mgaDDDrawPixels; /* works with agp/normal mem */
    }
+#endif
 }