#define DBG 0
-#define GET_PTR(X,Y) (sPriv->pFB + drb->flippedOffset \
- + ((dPriv->y + (Y)) * drb->flippedPitch + (dPriv->x + (X))) * drb->cpp)
-
-#if 000
-#define LOCAL_VARS \
- r200ContextPtr rmesa = R200_CONTEXT(ctx); \
- r200ScreenPtr r200Screen = rmesa->r200Screen; \
- __DRIscreenPrivate *sPriv = rmesa->dri.screen; \
- __DRIdrawablePrivate *dPriv = rmesa->dri.drawable; \
- GLuint pitch = r200Screen->frontPitch * r200Screen->cpp; \
- GLuint height = dPriv->h; \
- char *buf = (char *)(sPriv->pFB + \
- rmesa->state.color.drawOffset + \
- (dPriv->x * r200Screen->cpp) + \
- (dPriv->y * pitch)); \
- char *read_buf = (char *)(sPriv->pFB + \
- rmesa->state.pixel.readOffset + \
- (dPriv->x * r200Screen->cpp) + \
- (dPriv->y * pitch)); \
- GLuint p; \
- (void) read_buf; (void) buf; (void) p
-#else
-#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;
-#endif
-#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()
#define TAG(x) r200##x##_RGB565
#define TAG2(x,y) r200##x##_RGB565##y
-#define GET_SRC_PTR(X,Y) GET_PTR(X,Y)
-#define GET_DST_PTR(X,Y) GET_PTR(X,Y)
+#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 2)
#include "spantmp2.h"
/* 32 bit, ARGB8888 color spanline and pixel functions
#define TAG(x) r200##x##_ARGB8888
#define TAG2(x,y) r200##x##_ARGB8888##y
-#define GET_SRC_PTR(X,Y) GET_PTR(X,Y)
-#define GET_DST_PTR(X,Y) GET_PTR(X,Y)
+#define GET_PTR(X,Y) (buf + ((Y) * drb->flippedPitch + (X)) * 4)
#include "spantmp2.h"
* are set up correctly. It is not quite enough to get it working with hyperz too...
*/
+/* extract bit 'b' of x, result is zero or one */
#define BIT(x,b) ((x & (1<<b))>>b)
static GLuint
#define READ_DEPTH( d, _x, _y ) \
d = *(GLushort *)(buf + r200_mba_z16( drb, _x + xo, _y + yo ));
-#define TAG(x) r200##x##_16
+#define TAG(x) r200##x##_z16
#include "depthtmp.h"
d = *(GLuint *)(buf + r200_mba_z32( drb, _x + xo, \
_y + yo )) & 0x00ffffff;
-#define TAG(x) r200##x##_24_8
+#define TAG(x) r200##x##_z24_s8
#include "depthtmp.h"
d = tmp >> 24; \
} while (0)
-#define TAG(x) r200##x##_24_8
+#define TAG(x) r200##x##_z24_s8
#include "stenciltmp.h"
-#if 000
-/*
- * This function is called to specify which buffer to read and write
- * for software rasterization (swrast) fallbacks. This doesn't necessarily
- * correspond to glDrawBuffer() or glReadBuffer() calls.
- */
-static void r200SetBuffer( GLcontext *ctx,
- GLframebuffer *colorBuffer,
- GLuint bufferBit )
-{
- r200ContextPtr rmesa = R200_CONTEXT(ctx);
-
- switch ( bufferBit ) {
- case BUFFER_BIT_FRONT_LEFT:
- if ( rmesa->doPageFlip && rmesa->sarea->pfCurrentPage == 1 ) {
- rmesa->state.pixel.readOffset = rmesa->r200Screen->backOffset;
- rmesa->state.pixel.readPitch = rmesa->r200Screen->backPitch;
- rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset;
- rmesa->state.color.drawPitch = rmesa->r200Screen->backPitch;
- } else {
- rmesa->state.pixel.readOffset = rmesa->r200Screen->frontOffset;
- rmesa->state.pixel.readPitch = rmesa->r200Screen->frontPitch;
- rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset;
- rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch;
- }
- break;
- case BUFFER_BIT_BACK_LEFT:
- if ( rmesa->doPageFlip && rmesa->sarea->pfCurrentPage == 1 ) {
- rmesa->state.pixel.readOffset = rmesa->r200Screen->frontOffset;
- rmesa->state.pixel.readPitch = rmesa->r200Screen->frontPitch;
- rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset;
- rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch;
- } else {
- rmesa->state.pixel.readOffset = rmesa->r200Screen->backOffset;
- rmesa->state.pixel.readPitch = rmesa->r200Screen->backPitch;
- rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset;
- rmesa->state.color.drawPitch = rmesa->r200Screen->backPitch;
- }
- break;
- default:
- _mesa_problem(ctx, "Bad bufferBit in %s", __FUNCTION__);
- break;
- }
-}
-#endif
-
/* Move locking out to get reasonable span performance (10x better
* than doing this in HW_LOCK above). WaitForIdle() is the main
* culprit.
int p;
driRenderbuffer *drb =
(driRenderbuffer *) ctx->WinSysDrawBuffer->_ColorDrawBuffers[0][0];
- volatile int *read_buf =
+ volatile int *buf =
(volatile int *)(rmesa->dri.screen->pFB + drb->offset);
- p = *read_buf;
- *read_buf = p;
+ p = *buf;
+ *buf = p;
}
}
void r200InitSpanFuncs( GLcontext *ctx )
{
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-
-#if 000
- swdd->SetBuffer = r200SetBuffer;
-#endif
swdd->SpanRenderStart = r200SpanRenderStart;
swdd->SpanRenderFinish = r200SpanRenderFinish;
}
}
}
else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
- drb->Base.GetRow = r200ReadDepthSpan_16;
- drb->Base.GetValues = r200ReadDepthPixels_16;
- drb->Base.PutRow = r200WriteDepthSpan_16;
- drb->Base.PutMonoRow = r200WriteMonoDepthSpan_16;
- drb->Base.PutValues = r200WriteDepthPixels_16;
- drb->Base.PutMonoValues = NULL;
+ r200InitDepthPointers_z16(&drb->Base);
}
else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
- drb->Base.GetRow = r200ReadDepthSpan_24_8;
- drb->Base.GetValues = r200ReadDepthPixels_24_8;
- drb->Base.PutRow = r200WriteDepthSpan_24_8;
- drb->Base.PutMonoRow = r200WriteMonoDepthSpan_24_8;
- drb->Base.PutValues = r200WriteDepthPixels_24_8;
- drb->Base.PutMonoValues = NULL;
+ r200InitDepthPointers_z24_s8(&drb->Base);
}
else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
- drb->Base.GetRow = r200ReadStencilSpan_24_8;
- drb->Base.GetValues = r200ReadStencilPixels_24_8;
- drb->Base.PutRow = r200WriteStencilSpan_24_8;
- drb->Base.PutMonoRow = r200WriteMonoStencilSpan_24_8;
- drb->Base.PutValues = r200WriteStencilPixels_24_8;
- drb->Base.PutMonoValues = NULL;
+ r200InitStencilPointers_z24_s8(&drb->Base);
}
}