Further clean-up and simplification of the span-related functions.
authorBrian Paul <brian.paul@tungstengraphics.com>
Sun, 4 Sep 2005 22:16:08 +0000 (22:16 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Sun, 4 Sep 2005 22:16:08 +0000 (22:16 +0000)
src/mesa/drivers/dri/r200/r200_span.c
src/mesa/drivers/dri/radeon/radeon_span.c

index 7cfed947716596c9ffbcd91cb4441ef5591c1b31..487da280be0fdc033d891ba900b8c40ace51c955 100644 (file)
@@ -46,28 +46,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 +89,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 +99,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"
 
 
index 05c478193681023f2e8884356dd46d76d28beb4b..c49f5870c63ca0ddeb77d6186cf76ce43b1e7a62 100644 (file)
@@ -52,34 +52,30 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
 /*
- * Eventually, try to remove all references to ctx/rmesa here.
- * The renderbuffer parameter to the span functions should provide all
- * the info needed to read/write the pixels.
- * We'll be a step closer to supporting Pbuffer and framebuffer objects then.
+ * 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                                                     \
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);                       \
-   __DRIscreenPrivate *sPriv = rmesa->dri.screen;                      \
-   __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;                  \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;                      \
-   GLuint height = dPriv->h;                                           \
-   GLuint p;                                                           \
+#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                                               \
-   radeonContextPtr rmesa = RADEON_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()
 
@@ -98,8 +94,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define TAG(x)    radeon##x##_RGB565
 #define TAG2(x,y) radeon##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"
 
 
@@ -110,8 +105,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define TAG(x)    radeon##x##_ARGB8888
 #define TAG2(x,y) radeon##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"