-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c,v 1.10 2002/12/16 16:18:53 dawes Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
#include "r128_context.h"
#include "r128_state.h"
#include "r128_ioctl.h"
-#include "imports.h"
-#include "macros.h"
+#include "main/imports.h"
+#include "main/macros.h"
#include "swrast/swrast.h"
#include "vblank.h"
+#include "mmio.h"
+#include "drirenderbuffer.h"
#define R128_TIMEOUT 2048
#define R128_IDLE_RETRY 32
int wait = 0;
while ( 1 ) {
- uint32_t frame = LE32_TO_CPU(*(volatile uint32_t *)(R128MMIO + R128_LAST_FRAME_REG));
+ uint32_t frame = read_MMIO_LE32( R128MMIO, R128_LAST_FRAME_REG );
if ( rmesa->sarea->last_frame - frame <= R128_MAX_OUTSTANDING ) {
break;
/* Copy the back color buffer to the front color buffer.
*/
-void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
+void r128CopyBuffer( __DRIdrawable *dPriv )
{
r128ContextPtr rmesa;
GLint nbox, i, ret;
}
UNLOCK_HARDWARE( rmesa );
- driWaitForVBlank( dPriv, &rmesa->vbl_seq, rmesa->vblank_flags, &missed_target );
+ driWaitForVBlank( dPriv, &missed_target );
LOCK_HARDWARE( rmesa );
nbox = dPriv->numClipRects; /* must be in locked region */
#endif
}
-void r128PageFlip( const __DRIdrawablePrivate *dPriv )
+void r128PageFlip( __DRIdrawable *dPriv )
{
r128ContextPtr rmesa;
GLint ret;
}
UNLOCK_HARDWARE( rmesa );
- driWaitForVBlank( dPriv, &rmesa->vbl_seq, rmesa->vblank_flags, &missed_target );
+ driWaitForVBlank( dPriv, &missed_target );
LOCK_HARDWARE( rmesa );
/* The kernel will have been initialized to perform page flipping
exit( 1 );
}
- if ( rmesa->sarea->pfCurrentPage == 1 ) {
- rmesa->drawOffset = rmesa->r128Screen->frontOffset;
- rmesa->drawPitch = rmesa->r128Screen->frontPitch;
- } else {
- rmesa->drawOffset = rmesa->r128Screen->backOffset;
- rmesa->drawPitch = rmesa->r128Screen->backPitch;
- }
+ /* Get ready for drawing next frame. Update the renderbuffers'
+ * flippedOffset/Pitch fields so we draw into the right place.
+ */
+ driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
+ rmesa->sarea->pfCurrentPage);
- rmesa->setup.dst_pitch_offset_c = (((rmesa->drawPitch/8) << 21) |
- (rmesa->drawOffset >> 5));
rmesa->new_state |= R128_NEW_WINDOW;
/* FIXME: Do we need this anymore? */
* Buffer clear
*/
-static void r128Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint cx, GLint cy, GLint cw, GLint ch )
+static void r128Clear( GLcontext *ctx, GLbitfield mask )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
- __DRIdrawablePrivate *dPriv = rmesa->driDrawable;
+ __DRIdrawable *dPriv = rmesa->driDrawable;
drm_r128_clear_t clear;
GLuint flags = 0;
GLint i;
GLint ret;
+ GLuint depthmask = 0;
+ GLint cx, cy, cw, ch;
if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
fprintf( stderr, "%s:\n", __FUNCTION__ );
rmesa->new_state = save_state & ~R128_NEW_MASKS;
}
- if ( mask & DD_FRONT_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
flags |= R128_FRONT;
- mask &= ~DD_FRONT_LEFT_BIT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
}
- if ( mask & DD_BACK_LEFT_BIT ) {
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
flags |= R128_BACK;
- mask &= ~DD_BACK_LEFT_BIT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
}
- if ( ( mask & DD_DEPTH_BIT ) && ctx->Depth.Mask ) {
+ if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) {
flags |= R128_DEPTH;
- mask &= ~DD_DEPTH_BIT;
+ /* if we're at 16 bits, extra plane mask won't hurt */
+ depthmask |= 0x00ffffff;
+ mask &= ~BUFFER_BIT_DEPTH;
}
-#if 0
- /* FIXME: Add stencil support */
- if ( mask & DD_STENCIL_BIT ) {
- flags |= DRM_R128_DEPTH_BUFFER;
- mask &= ~DD_STENCIL_BIT;
+
+ if ( mask & BUFFER_BIT_STENCIL &&
+ (ctx->Visual.stencilBits > 0 && ctx->Visual.depthBits == 24) ) {
+ flags |= R128_DEPTH;
+ depthmask |= ctx->Stencil.WriteMask[0] << 24;
+ mask &= ~BUFFER_BIT_STENCIL;
}
-#endif
if ( flags ) {
+ LOCK_HARDWARE( rmesa );
+
+ /* compute region after locking: */
+ cx = ctx->DrawBuffer->_Xmin;
+ cy = ctx->DrawBuffer->_Ymin;
+ cw = ctx->DrawBuffer->_Xmax - cx;
+ ch = ctx->DrawBuffer->_Ymax - cy;
+
/* Flip top to bottom */
cx += dPriv->x;
cy = dPriv->y + dPriv->h - cy - ch;
- LOCK_HARDWARE( rmesa );
-
/* FIXME: Do we actually need this?
*/
if ( rmesa->dirty & ~R128_UPLOAD_CLIPRECTS ) {
drm_clip_rect_t *b = rmesa->sarea->boxes;
GLint n = 0;
- if ( !all ) {
+ if (cw != dPriv->w || ch != dPriv->h) {
+ /* clear subregion */
for ( ; i < nr ; i++ ) {
GLint x = box[i].x1;
GLint y = box[i].y1;
n++;
}
} else {
+ /* clear whole window */
for ( ; i < nr ; i++ ) {
*b++ = box[i];
n++;
clear.clear_color = rmesa->ClearColor;
clear.clear_depth = rmesa->ClearDepth;
clear.color_mask = rmesa->setup.plane_3d_mask_c;
- clear.depth_mask = ~0;
+ clear.depth_mask = depthmask;
ret = drmCommandWrite( rmesa->driFd, DRM_R128_CLEAR,
&clear, sizeof(clear) );
}
if ( mask )
- _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+ _swrast_Clear( ctx, mask );
}
void r128WriteDepthSpanLocked( r128ContextPtr rmesa,
GLuint n, GLint x, GLint y,
- const GLdepth depth[],
+ const GLuint depth[],
const GLubyte mask[] )
{
drm_clip_rect_t *pbox = rmesa->pClipRects;
void r128WriteDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
const GLint x[], const GLint y[],
- const GLdepth depth[],
+ const GLuint depth[],
const GLubyte mask[] )
{
drm_clip_rect_t *pbox = rmesa->pClipRects;