Merge branch 'mesa_7_5_branch'
[mesa.git] / src / mesa / drivers / dri / r200 / r200_span.c
index 7cfed947716596c9ffbcd91cb4441ef5591c1b31..9783678028a879fd09e4addf7ef02c785df625ce 100644 (file)
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_span.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
 /*
 Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
 
@@ -33,10 +32,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *   Keith Whitwell <keith@tungstengraphics.com>
  */
 
-#include "glheader.h"
-#include "imports.h"
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/colormac.h"
 #include "swrast/swrast.h"
-#include "colormac.h"
 
 #include "r200_context.h"
 #include "r200_ioctl.h"
@@ -46,28 +45,31 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define DBG 0
 
-#define LOCAL_VARS                                                     \
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);                           \
-   __DRIscreenPrivate *sPriv = rmesa->dri.screen;                      \
-   __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;                  \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
-   GLuint height = dPriv->h;                                           \
-   GLuint p;                                                           \
+/*
+ * Note that all information needed to access pixels in a renderbuffer
+ * should be obtained through the gl_renderbuffer parameter, not per-context
+ * information.
+ */
+#define LOCAL_VARS                                             \
+   driRenderbuffer *drb = (driRenderbuffer *) rb;              \
+   const __DRIdrawablePrivate *dPriv = drb->dPriv;             \
+   const GLuint bottom = dPriv->h - 1;                         \
+   GLubyte *buf = (GLubyte *) drb->flippedData                 \
+      + (dPriv->y * drb->flippedPitch + dPriv->x) * drb->cpp;  \
+   GLuint p;                                                   \
    (void) p;
 
-#define LOCAL_DEPTH_VARS                                               \
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);                           \
-   __DRIscreenPrivate *sPriv = rmesa->dri.screen;                      \
-   __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;                  \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
-   GLuint height = dPriv->h;                                           \
-   GLuint xo = dPriv->x;                                               \
-   GLuint yo = dPriv->y;                                               \
-   char *buf = (char *)(sPriv->pFB + drb->offset);
+#define LOCAL_DEPTH_VARS                               \
+   driRenderbuffer *drb = (driRenderbuffer *) rb;      \
+   const __DRIdrawablePrivate *dPriv = drb->dPriv;     \
+   const GLuint bottom = dPriv->h - 1;                 \
+   GLuint xo = dPriv->x;                               \
+   GLuint yo = dPriv->y;                               \
+   GLubyte *buf = (GLubyte *) drb->Base.Data;
 
-#define LOCAL_STENCIL_VARS     LOCAL_DEPTH_VARS
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
 
-#define Y_FLIP( _y )           (height - _y - 1)
+#define Y_FLIP(Y) (bottom - (Y))
 
 #define HW_LOCK() 
 
@@ -86,8 +88,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define TAG(x)    r200##x##_RGB565
 #define TAG2(x,y) r200##x##_RGB565##y
-#define GET_PTR(X,Y) (sPriv->pFB + drb->flippedOffset          \
-     + ((dPriv->y + (Y)) * drb->flippedPitch + (dPriv->x + (X))) * drb->cpp)
+#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 2)
 #include "spantmp2.h"
 
 /* 32 bit, ARGB8888 color spanline and pixel functions
@@ -97,8 +98,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define TAG(x)    r200##x##_ARGB8888
 #define TAG2(x,y) r200##x##_ARGB8888##y
-#define GET_PTR(X,Y) (sPriv->pFB + drb->flippedOffset          \
-     + ((dPriv->y + (Y)) * drb->flippedPitch + (dPriv->x + (X))) * drb->cpp)
+#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 4)
 #include "spantmp2.h"
 
 
@@ -172,6 +172,7 @@ r200_mba_z16( driRenderbuffer *drb, GLint x, GLint y )
 
 /* 16-bit depth buffer functions
  */
+#define VALUE_TYPE GLushort
 
 #define WRITE_DEPTH( _x, _y, d )                                       \
    *(GLushort *)(buf + r200_mba_z16( drb, _x + xo, _y + yo )) = d;
@@ -185,6 +186,7 @@ r200_mba_z16( driRenderbuffer *drb, GLint x, GLint y )
 
 /* 24 bit depth, 8 bit stencil depthbuffer functions
  */
+#define VALUE_TYPE GLuint
 
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
@@ -255,7 +257,7 @@ static void r200SpanRenderStart( GLcontext *ctx )
    {
       int p;
       driRenderbuffer *drb =
-        (driRenderbuffer *) ctx->WinSysDrawBuffer->_ColorDrawBuffers[0][0];
+        (driRenderbuffer *) ctx->WinSysDrawBuffer->_ColorDrawBuffers[0];
       volatile int *buf =
         (volatile int *)(rmesa->dri.screen->pFB + drb->offset);
       p = *buf;
@@ -283,7 +285,7 @@ void r200InitSpanFuncs( GLcontext *ctx )
  * Plug in the Get/Put routines for the given driRenderbuffer.
  */
 void
-r200SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+radeonSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
 {
    if (drb->Base.InternalFormat == GL_RGBA) {
       if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {