Use driRenderbuffer's offset, pitch fields in the span routines.
Remove the SetBuffer driver function.
Consolidate the code for setting CTX_RB3D_COLOROFFSET and CTX_RB3D_COLORPITCH
state in new radeonUpdateDrawBuffer() function.
Old code is surrounded by #if 000 / #endif, temporarily.
#define need_GL_NV_vertex_program
#include "extension_helper.h"
-#define DRIVER_DATE "20041207"
+#define DRIVER_DATE "20050831"
#include "vblank.h"
#include "utils.h"
struct r200_colorbuffer_state {
GLuint clear;
+#if 000
GLint drawOffset, drawPitch;
+#endif
int roundEnable;
};
GLfloat scale;
};
+#if 000
struct r200_pixel_state {
GLint readOffset, readPitch;
};
+#endif
struct r200_scissor_state {
drm_clip_rect_t rect;
*/
struct r200_colorbuffer_state color;
struct r200_depthbuffer_state depth;
+#if 00
struct r200_pixel_state pixel;
+#endif
struct r200_scissor_state scissor;
struct r200_stencilbuffer_state stencil;
struct r200_stipple_state stipple;
rmesa->swap_count++;
(void) (*dri_interface->getUST)( & rmesa->swap_ust );
+#if 000
if ( rmesa->sarea->pfCurrentPage == 1 ) {
rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset;
rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch;
if (rmesa->sarea->tiling_enabled) {
rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
}
+#else
+ r200UpdateDrawBuffer(rmesa->glCtx);
+#endif
}
#include "r200_tex.h"
#include "r200_state.h"
#include "r200_ioctl.h"
+#include "drirenderbuffer.h"
#if DEBUG_LOCKING
char *prevLockFile = NULL;
static void
r200UpdatePageFlipping( r200ContextPtr rmesa )
{
+#if 000
int use_back;
rmesa->doPageFlip = rmesa->sarea->pfState;
rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset
+ rmesa->r200Screen->fbLocation;
rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = rmesa->state.color.drawPitch;
+#else
+ if (rmesa->doPageFlip != rmesa->sarea->pfState
+ || rmesa->sarea->pfState) {
+ /* If page flipping is on, re we're turning it on/off now we need
+ * to update the flipped buffer info.
+ */
+ struct gl_framebuffer *fb = rmesa->glCtx->WinSysDrawBuffer;
+ driRenderbuffer *front_drb
+ = (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+ driRenderbuffer *back_drb
+ = (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+
+ if (rmesa->sarea->pfState && rmesa->sarea->pfCurrentPage == 1) {
+ /* flipped buffers */
+ front_drb->flippedOffset = back_drb->offset;
+ front_drb->flippedPitch = back_drb->pitch;
+ back_drb->flippedOffset = front_drb->offset;
+ back_drb->flippedPitch = front_drb->pitch;
+ }
+ else {
+ /* unflipped buffers */
+ front_drb->flippedOffset = front_drb->offset;
+ front_drb->flippedPitch = front_drb->pitch;
+ if (back_drb) {
+ /* back buffer is non-existant when single buffered */
+ back_drb->flippedOffset = back_drb->offset;
+ back_drb->flippedPitch = back_drb->pitch;
+ }
+ }
+
+ /* update local state */
+ rmesa->doPageFlip = rmesa->sarea->pfState;
+
+ /* set hw.ctx.cmd state here */
+ r200UpdateDrawBuffer(rmesa->glCtx);
+ }
+#endif
}
#include "r200_pixel.h"
#include "r200_swtcl.h"
+#include "drirenderbuffer.h"
static GLboolean
{
__DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ driRenderbuffer *drb = (driRenderbuffer *) ctx->ReadBuffer->_ColorReadBuffer;
int nbox = dPriv->numClipRects;
- int src_offset = rmesa->state.color.drawOffset
+ int src_offset = drb->offset
+ rmesa->r200Screen->fbLocation;
- int src_pitch = rmesa->state.color.drawPitch * rmesa->r200Screen->cpp;
+ int src_pitch = drb->pitch * drb->cpp;
int dst_offset = r200GartOffsetFromVirtual( rmesa, pixels );
int dst_pitch = pitch * rmesa->r200Screen->cpp;
drm_clip_rect_t *box = dPriv->pClipRects;
r200ContextPtr rmesa = R200_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
drm_clip_rect_t *box = dPriv->pClipRects;
+ struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorDrawBuffers[0][0];
+ driRenderbuffer *drb = (driRenderbuffer *) rb;
int nbox = dPriv->numClipRects;
int i;
int blit_format;
r200EmitBlit( rmesa,
blit_format,
src_pitch, src_offset,
- rmesa->state.color.drawPitch * rmesa->r200Screen->cpp,
- rmesa->state.color.drawOffset + rmesa->r200Screen->fbLocation,
+ drb->pitch * drb->cpp,
+ drb->offset + rmesa->r200Screen->fbLocation,
bx - x, by - y,
bx, by,
bw, bh );
if (R200_DEBUG & DEBUG_PIXEL)
fprintf(stderr, "%s\n", __FUNCTION__);
+ /* check that we're drawing to exactly one color buffer */
+ if (ctx->DrawBuffer->_NumColorDrawBuffers[0] != 1)
+ return GL_FALSE;
+
switch (format) {
case GL_RGB:
case GL_RGBA:
#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; \
(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; \
+ (void) p;
+#endif
#define LOCAL_DEPTH_VARS \
r200ContextPtr rmesa = R200_CONTEXT(ctx); \
- r200ScreenPtr r200Screen = rmesa->r200Screen; \
__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 + r200Screen->depthOffset); \
- (void) buf
+ char *buf = (char *)(sPriv->pFB + drb->offset);
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
#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)
#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)
#include "spantmp2.h"
*/
#define BIT(x,b) ((x & (1<<b))>>b)
-static GLuint r200_mba_z32( r200ContextPtr rmesa,
- GLint x, GLint y )
+
+static GLuint
+r200_mba_z32( driRenderbuffer *drb, GLint x, GLint y )
{
- GLuint pitch = rmesa->r200Screen->frontPitch;
- if (rmesa->r200Screen->depthHasSurface) {
- return 4*(x + y*pitch);
+ GLuint pitch = drb->pitch;
+ if (drb->depthHasSurface) {
+ return 4 * (x + y * pitch);
}
else {
GLuint b = ((y & 0x7FF) >> 4) * ((pitch & 0xFFF) >> 5) + ((x & 0x7FF) >> 5);
}
}
-static GLuint r200_mba_z16( r200ContextPtr rmesa, GLint x, GLint y )
+static GLuint
+r200_mba_z16( driRenderbuffer *drb, GLint x, GLint y )
{
- GLuint pitch = rmesa->r200Screen->frontPitch;
- if (rmesa->r200Screen->depthHasSurface) {
- return 2*(x + y*pitch);
+ GLuint pitch = drb->pitch;
+ if (drb->depthHasSurface) {
+ return 2 * (x + y * pitch);
}
else {
GLuint b = ((y & 0x7FF) >> 4) * ((pitch & 0xFFF) >> 6) + ((x & 0x7FF) >> 6);
*/
#define WRITE_DEPTH( _x, _y, d ) \
- *(GLushort *)(buf + r200_mba_z16( rmesa, _x + xo, _y + yo )) = d;
+ *(GLushort *)(buf + r200_mba_z16( drb, _x + xo, _y + yo )) = d;
#define READ_DEPTH( d, _x, _y ) \
- d = *(GLushort *)(buf + r200_mba_z16( rmesa, _x + xo, _y + yo ));
+ d = *(GLushort *)(buf + r200_mba_z16( drb, _x + xo, _y + yo ));
#define TAG(x) r200##x##_16
#include "depthtmp.h"
#define WRITE_DEPTH( _x, _y, d ) \
do { \
- GLuint offset = r200_mba_z32( rmesa, _x + xo, _y + yo ); \
+ GLuint offset = r200_mba_z32( drb, _x + xo, _y + yo ); \
GLuint tmp = *(GLuint *)(buf + offset); \
tmp &= 0xff000000; \
tmp |= ((d) & 0x00ffffff); \
} while (0)
#define READ_DEPTH( d, _x, _y ) \
- d = *(GLuint *)(buf + r200_mba_z32( rmesa, _x + xo, \
+ d = *(GLuint *)(buf + r200_mba_z32( drb, _x + xo, \
_y + yo )) & 0x00ffffff;
#define TAG(x) r200##x##_24_8
*/
#define WRITE_STENCIL( _x, _y, d ) \
do { \
- GLuint offset = r200_mba_z32( rmesa, _x + xo, _y + yo ); \
+ GLuint offset = r200_mba_z32( drb, _x + xo, _y + yo ); \
GLuint tmp = *(GLuint *)(buf + offset); \
tmp &= 0x00ffffff; \
tmp |= (((d) & 0xff) << 24); \
#define READ_STENCIL( d, _x, _y ) \
do { \
- GLuint offset = r200_mba_z32( rmesa, _x + xo, _y + yo ); \
+ GLuint offset = r200_mba_z32( drb, _x + xo, _y + yo ); \
GLuint tmp = *(GLuint *)(buf + offset); \
tmp &= 0xff000000; \
d = tmp >> 24; \
#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
break;
}
}
+#endif
/* Move locking out to get reasonable span performance (10x better
* than doing this in HW_LOCK above). WaitForIdle() is the main
*/
{
int p;
- volatile int *read_buf = (volatile int *)(rmesa->dri.screen->pFB +
- rmesa->state.pixel.readOffset);
+ driRenderbuffer *drb =
+ (driRenderbuffer *) ctx->WinSysDrawBuffer->_ColorDrawBuffers[0][0];
+ volatile int *read_buf =
+ (volatile int *)(rmesa->dri.screen->pFB + drb->offset);
p = *read_buf;
*read_buf = p;
}
{
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+#if 000
swdd->SetBuffer = r200SetBuffer;
+#endif
swdd->SpanRenderStart = r200SpanRenderStart;
swdd->SpanRenderFinish = r200SpanRenderFinish;
}
#include "tnl/t_pipeline.h"
#include "swrast_setup/swrast_setup.h"
-
#include "r200_context.h"
#include "r200_ioctl.h"
#include "r200_state.h"
#include "r200_swtcl.h"
#include "r200_vtxfmt.h"
+#include "drirenderbuffer.h"
+
/* =============================================================
* Alpha blending
R200_FIREVERTICES(rmesa); /* don't pipeline cliprect changes */
/*
- * _DrawDestMask is easier to cope with than <mode>.
+ * _ColorDrawBufferMask is easier to cope with than <mode>.
+ * Check for software fallback, update cliprects.
*/
switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
case BUFFER_BIT_FRONT_LEFT:
return;
}
+#if 000
/* We want to update the s/w rast state too so that r200SetBuffer()
* gets called.
*/
if (rmesa->sarea->tiling_enabled) {
rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
}
+#else
+ /* We'll set the drawing engine's offset/pitch parameters later
+ * when we update other state.
+ */
+#endif
}
+/**
+ * Tell the card where to render (offset, pitch).
+ * Effected by glDrawBuffer, etc
+ */
+void
+r200UpdateDrawBuffer(GLcontext *ctx)
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ driRenderbuffer *drb;
+
+ if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) {
+ /* draw to front */
+ drb = (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+ }
+ else if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) {
+ /* draw to back */
+ drb = (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+ }
+ else {
+ /* drawing to multiple buffers, or none */
+ return;
+ }
+
+ assert(drb);
+ assert(drb->flippedPitch);
+
+ R200_STATECHANGE( rmesa, ctx );
+
+ /* Note: we used the (possibly) page-flipped values */
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET]
+ = ((drb->flippedOffset + rmesa->r200Screen->fbLocation)
+ & R200_COLOROFFSET_MASK);
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = drb->flippedPitch;
+ if (rmesa->sarea->tiling_enabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
+ }
+}
+
+
+
void r200ValidateState( GLcontext *ctx )
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
GLuint new_state = rmesa->NewGLState;
+ if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
+ r200UpdateDrawBuffer(ctx);
+ }
+
if (new_state & _NEW_TEXTURE) {
r200UpdateTextureState( ctx );
new_state |= rmesa->NewGLState; /* may add TEXTURE_MATRIX */
extern void r200RecalcScissorRects( r200ContextPtr rmesa );
extern void r200UpdateViewportOffset( GLcontext *ctx );
extern void r200UpdateWindow( GLcontext *ctx );
+extern void r200UpdateDrawBuffer(GLcontext *ctx);
extern void r200ValidateState( GLcontext *ctx );
{
GLcontext *ctx = rmesa->glCtx;
GLuint color_fmt, depth_fmt, i;
+ GLint drawPitch, drawOffset;
switch ( rmesa->r200Screen->cpp ) {
case 2:
rmesa->Fallback = 0;
+ if ( ctx->Visual.doubleBufferMode && rmesa->sarea->pfCurrentPage == 0 ) {
+ drawOffset = rmesa->r200Screen->backOffset;
+ drawPitch = rmesa->r200Screen->backPitch;
+ } else {
+ drawOffset = rmesa->r200Screen->frontOffset;
+ drawPitch = rmesa->r200Screen->frontPitch;
+ }
+#if 000
if ( ctx->Visual.doubleBufferMode && rmesa->sarea->pfCurrentPage == 0 ) {
rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset;
rmesa->state.color.drawPitch = rmesa->r200Screen->backPitch;
rmesa->state.pixel.readOffset = rmesa->state.color.drawOffset;
rmesa->state.pixel.readPitch = rmesa->state.color.drawPitch;
+#endif
rmesa->hw.max_state_size = 0;
else
rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= rmesa->state.color.roundEnable;
+#if 000
rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = ((rmesa->state.color.drawOffset +
rmesa->r200Screen->fbLocation)
& R200_COLOROFFSET_MASK);
rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = ((rmesa->state.color.drawPitch &
R200_COLORPITCH_MASK) |
R200_COLOR_ENDIAN_NO_SWAP);
+#else
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = ((drawOffset +
+ rmesa->r200Screen->fbLocation)
+ & R200_COLOROFFSET_MASK);
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = ((drawPitch &
+ R200_COLORPITCH_MASK) |
+ R200_COLOR_ENDIAN_NO_SWAP);
+#endif
/* (fixed size) sarea is initialized to zero afaics so can omit version check. Phew! */
if (rmesa->sarea->tiling_enabled) {
rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;