Don't use the x/y/width/height params passed to Clear(). Get them

after locking.  Next: remove the params altogether.
This commit is contained in:
Brian Paul
2006-11-01 18:51:43 +00:00
parent 26b5904d70
commit 9669804fe4
6 changed files with 80 additions and 60 deletions

View File

@@ -395,13 +395,15 @@ static void draw_poly(i830ContextPtr i830,
void void
i830ClearWithTris(intelContextPtr intel, GLbitfield mask, i830ClearWithTris(intelContextPtr intel, GLbitfield mask,
GLboolean all, GLboolean allFoo,
GLint cx, GLint cy, GLint cw, GLint ch) GLint cxFoo, GLint cyFoo, GLint cwFoo, GLint chFoo)
{ {
i830ContextPtr i830 = I830_CONTEXT( intel ); i830ContextPtr i830 = I830_CONTEXT( intel );
__DRIdrawablePrivate *dPriv = intel->driDrawable; __DRIdrawablePrivate *dPriv = intel->driDrawable;
intelScreenPrivate *screen = intel->intelScreen; intelScreenPrivate *screen = intel->intelScreen;
int x0, y0, x1, y1; int x0, y0, x1, y1;
GLint cx, cy, cw, ch;
GLboolean all;
INTEL_FIREVERTICES(intel); INTEL_FIREVERTICES(intel);
SET_STATE( i830, meta ); SET_STATE( i830, meta );
@@ -411,6 +413,14 @@ i830ClearWithTris(intelContextPtr intel, GLbitfield mask,
LOCK_HARDWARE(intel); LOCK_HARDWARE(intel);
/* get clear bounds after locking */
cx = intel->ctx.DrawBuffer->_Xmin;
cy = intel->ctx.DrawBuffer->_Ymin;
cw = intel->ctx.DrawBuffer->_Xmax - cx;
ch = intel->ctx.DrawBuffer->_Ymax - cy;
all = (cw == intel->ctx.DrawBuffer->Width &&
ch == intel->ctx.DrawBuffer->Height);
if(!all) { if(!all) {
x0 = cx; x0 = cx;
y0 = cy; y0 = cy;

View File

@@ -493,14 +493,16 @@ static void draw_poly(i915ContextPtr i915,
void void
i915ClearWithTris(intelContextPtr intel, GLbitfield mask, i915ClearWithTris(intelContextPtr intel, GLbitfield buffers,
GLboolean all, GLboolean allFoo,
GLint cx, GLint cy, GLint cw, GLint ch) GLint cxFoo, GLint cyFoo, GLint cwFoo, GLint chFoo)
{ {
i915ContextPtr i915 = I915_CONTEXT( intel ); i915ContextPtr i915 = I915_CONTEXT( intel );
__DRIdrawablePrivate *dPriv = intel->driDrawable; __DRIdrawablePrivate *dPriv = intel->driDrawable;
intelScreenPrivate *screen = intel->intelScreen; intelScreenPrivate *screen = intel->intelScreen;
int x0, y0, x1, y1; int x0, y0, x1, y1;
GLint cx, cy, cw, ch;
GLboolean all;
SET_STATE( i915, meta ); SET_STATE( i915, meta );
set_initial_state( i915 ); set_initial_state( i915 );
@@ -509,6 +511,14 @@ i915ClearWithTris(intelContextPtr intel, GLbitfield mask,
LOCK_HARDWARE(intel); LOCK_HARDWARE(intel);
/* get clear bounds after locking */
cx = intel->ctx.DrawBuffer->_Xmin;
cy = intel->ctx.DrawBuffer->_Ymin;
cw = intel->ctx.DrawBuffer->_Xmax - cx;
ch = intel->ctx.DrawBuffer->_Ymax - cy;
all = (cw == intel->ctx.DrawBuffer->Width &&
ch == intel->ctx.DrawBuffer->Height);
if (!all) { if (!all) {
x0 = cx; x0 = cx;
y0 = cy; y0 = cy;
@@ -525,7 +535,7 @@ i915ClearWithTris(intelContextPtr intel, GLbitfield mask,
* The active cliprects will be applied as for any other geometry. * The active cliprects will be applied as for any other geometry.
*/ */
if (mask & BUFFER_BIT_FRONT_LEFT) { if (buffers & BUFFER_BIT_FRONT_LEFT) {
set_no_depth_stencil_write( i915 ); set_no_depth_stencil_write( i915 );
set_color_mask( i915, GL_TRUE ); set_color_mask( i915, GL_TRUE );
set_draw_region( i915, &screen->front ); set_draw_region( i915, &screen->front );
@@ -536,7 +546,7 @@ i915ClearWithTris(intelContextPtr intel, GLbitfield mask,
0, 0, 0, 0); 0, 0, 0, 0);
} }
if (mask & BUFFER_BIT_BACK_LEFT) { if (buffers & BUFFER_BIT_BACK_LEFT) {
set_no_depth_stencil_write( i915 ); set_no_depth_stencil_write( i915 );
set_color_mask( i915, GL_TRUE ); set_color_mask( i915, GL_TRUE );
set_draw_region( i915, &screen->back ); set_draw_region( i915, &screen->back );
@@ -547,7 +557,7 @@ i915ClearWithTris(intelContextPtr intel, GLbitfield mask,
0, 0, 0, 0); 0, 0, 0, 0);
} }
if (mask & BUFFER_BIT_STENCIL) { if (buffers & BUFFER_BIT_STENCIL) {
set_stencil_replace( i915, set_stencil_replace( i915,
intel->ctx.Stencil.WriteMask[0], intel->ctx.Stencil.WriteMask[0],
intel->ctx.Stencil.Clear); intel->ctx.Stencil.Clear);

View File

@@ -621,13 +621,14 @@ void intelEmitCopyBlitLocked( intelContextPtr intel,
void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all, void intelClearWithBlit(GLcontext *ctx, GLbitfield buffers, GLboolean allFoo,
GLint cx1, GLint cy1, GLint cw, GLint ch) GLint cx1Foo, GLint cy1Foo, GLint cwFoo, GLint chFoo)
{ {
intelContextPtr intel = INTEL_CONTEXT( ctx ); intelContextPtr intel = INTEL_CONTEXT( ctx );
intelScreenPrivate *intelScreen = intel->intelScreen; intelScreenPrivate *intelScreen = intel->intelScreen;
GLuint clear_depth, clear_color; GLuint clear_depth, clear_color;
GLint cx, cy; GLint cx, cy, cw, ch;
GLboolean all;
GLint pitch; GLint pitch;
GLint cpp = intelScreen->cpp; GLint cpp = intelScreen->cpp;
GLint i; GLint i;
@@ -637,16 +638,24 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
intelFlush( &intel->ctx ); intelFlush( &intel->ctx );
LOCK_HARDWARE( intel ); LOCK_HARDWARE( intel );
/* get clear bounds after locking */
cx = intel->ctx.DrawBuffer->_Xmin;
cy = intel->ctx.DrawBuffer->_Ymin;
cw = intel->ctx.DrawBuffer->_Xmax - cx;
ch = intel->ctx.DrawBuffer->_Ymax - cy;
all = (cw == intel->ctx.DrawBuffer->Width &&
ch == intel->ctx.DrawBuffer->Height);
pitch = intelScreen->front.pitch; pitch = intelScreen->front.pitch;
clear_color = intel->ClearColor; clear_color = intel->ClearColor;
clear_depth = 0; clear_depth = 0;
if (flags & BUFFER_BIT_DEPTH) { if (buffers & BUFFER_BIT_DEPTH) {
clear_depth = (GLuint)(ctx->Depth.Clear * intel->ClearDepth); clear_depth = (GLuint)(ctx->Depth.Clear * intel->ClearDepth);
} }
if (flags & BUFFER_BIT_STENCIL) { if (buffers & BUFFER_BIT_STENCIL) {
clear_depth |= (ctx->Stencil.Clear & 0xff) << 24; clear_depth |= (ctx->Stencil.Clear & 0xff) << 24;
} }
@@ -661,8 +670,8 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
XY_COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_ALPHA |
XY_COLOR_BLT_WRITE_RGB); XY_COLOR_BLT_WRITE_RGB);
D_CMD = XY_COLOR_BLT_CMD; D_CMD = XY_COLOR_BLT_CMD;
if (flags & BUFFER_BIT_DEPTH) D_CMD |= XY_COLOR_BLT_WRITE_RGB; if (buffers & BUFFER_BIT_DEPTH) D_CMD |= XY_COLOR_BLT_WRITE_RGB;
if (flags & BUFFER_BIT_STENCIL) D_CMD |= XY_COLOR_BLT_WRITE_ALPHA; if (buffers & BUFFER_BIT_STENCIL) D_CMD |= XY_COLOR_BLT_WRITE_ALPHA;
break; break;
default: default:
BR13 = (0xF0 << 16) | (pitch) | (1<<24); BR13 = (0xF0 << 16) | (pitch) | (1<<24);
@@ -672,17 +681,17 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
{ {
/* flip top to bottom */ /* flip top to bottom */
cy = intel->driDrawable->h-cy1-ch; cy = intel->driDrawable->h - cy - ch;
cx = cx1 + intel->drawX; cx = cx + intel->drawX;
cy += intel->drawY; cy += intel->drawY;
/* adjust for page flipping */ /* adjust for page flipping */
if ( intel->sarea->pf_current_page == 1 ) { if ( intel->sarea->pf_current_page == 1 ) {
GLuint tmp = flags; GLuint tmp = buffers;
flags &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT); buffers &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
if ( tmp & BUFFER_BIT_FRONT_LEFT ) flags |= BUFFER_BIT_BACK_LEFT; if ( tmp & BUFFER_BIT_FRONT_LEFT ) buffers |= BUFFER_BIT_BACK_LEFT;
if ( tmp & BUFFER_BIT_BACK_LEFT ) flags |= BUFFER_BIT_FRONT_LEFT; if ( tmp & BUFFER_BIT_BACK_LEFT ) buffers |= BUFFER_BIT_FRONT_LEFT;
} }
for (i = 0 ; i < intel->numClipRects ; i++) for (i = 0 ; i < intel->numClipRects ; i++)
@@ -718,7 +727,7 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
b.y2 > intelScreen->height) b.y2 > intelScreen->height)
continue; continue;
if ( flags & BUFFER_BIT_FRONT_LEFT ) { if ( buffers & BUFFER_BIT_FRONT_LEFT ) {
BEGIN_BATCH( 6); BEGIN_BATCH( 6);
OUT_BATCH( CMD ); OUT_BATCH( CMD );
OUT_BATCH( BR13 ); OUT_BATCH( BR13 );
@@ -729,7 +738,7 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
ADVANCE_BATCH(); ADVANCE_BATCH();
} }
if ( flags & BUFFER_BIT_BACK_LEFT ) { if ( buffers & BUFFER_BIT_BACK_LEFT ) {
BEGIN_BATCH( 6); BEGIN_BATCH( 6);
OUT_BATCH( CMD ); OUT_BATCH( CMD );
OUT_BATCH( BR13 ); OUT_BATCH( BR13 );
@@ -740,7 +749,7 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
ADVANCE_BATCH(); ADVANCE_BATCH();
} }
if ( flags & (BUFFER_BIT_STENCIL | BUFFER_BIT_DEPTH) ) { if ( buffers & (BUFFER_BIT_STENCIL | BUFFER_BIT_DEPTH) ) {
BEGIN_BATCH( 6); BEGIN_BATCH( 6);
OUT_BATCH( D_CMD ); OUT_BATCH( D_CMD );
OUT_BATCH( BR13 ); OUT_BATCH( BR13 );

View File

@@ -375,8 +375,8 @@ void intelFinish( GLcontext *ctx )
} }
void intelClear(GLcontext *ctx, GLbitfield mask, GLboolean all, void intelClear(GLcontext *ctx, GLbitfield mask, GLboolean allFoo,
GLint cx, GLint cy, GLint cw, GLint ch) GLint cxFoo, GLint cyFoo, GLint cwFoo, GLint chFoo)
{ {
intelContextPtr intel = INTEL_CONTEXT( ctx ); intelContextPtr intel = INTEL_CONTEXT( ctx );
const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask); const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
@@ -429,13 +429,13 @@ void intelClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
swrast_mask |= (mask & BUFFER_BIT_ACCUM); swrast_mask |= (mask & BUFFER_BIT_ACCUM);
if (blit_mask) if (blit_mask)
intelClearWithBlit( ctx, blit_mask, all, cx, cy, cw, ch ); intelClearWithBlit( ctx, blit_mask, 0, 0, 0, 0, 0);
if (tri_mask) if (tri_mask)
intel->vtbl.clear_with_tris( intel, tri_mask, all, cx, cy, cw, ch); intel->vtbl.clear_with_tris( intel, tri_mask, 0, 0, 0, 0, 0);
if (swrast_mask) if (swrast_mask)
_swrast_Clear( ctx, swrast_mask, all, cx, cy, cw, ch ); _swrast_Clear( ctx, swrast_mask, 0, 0, 0, 0, 0);
} }

View File

@@ -376,8 +376,8 @@ intelEmitCopyBlit(struct intel_context *intel,
* \param mask bitmask of BUFFER_BIT_* values indicating buffers to clear * \param mask bitmask of BUFFER_BIT_* values indicating buffers to clear
*/ */
void void
intelClearWithBlit(GLcontext * ctx, GLbitfield mask, GLboolean all, intelClearWithBlit(GLcontext * ctx, GLbitfield mask, GLboolean allFoo,
GLint cx, GLint cy, GLint cw, GLint ch) GLint cxFoo, GLint cyFoo, GLint cwFoo, GLint chFoo)
{ {
struct intel_context *intel = intel_context(ctx); struct intel_context *intel = intel_context(ctx);
GLuint clear_depth; GLuint clear_depth;
@@ -409,20 +409,15 @@ intelClearWithBlit(GLcontext * ctx, GLbitfield mask, GLboolean all,
LOCK_HARDWARE(intel); LOCK_HARDWARE(intel);
if (intel->numClipRects) { if (intel->numClipRects) {
GLint cx, cy, cw, ch;
drm_clip_rect_t clear; drm_clip_rect_t clear;
int i; int i;
/* Refresh the cx/y/w/h values as they may have been invalidated /* Get clear bounds after locking */
* by a new window position or size picked up when we did cx = ctx->DrawBuffer->_Xmin;
* LOCK_HARDWARE above. The values passed by mesa are not cy = ctx->DrawBuffer->_Ymin;
* reliable. cw = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
*/ ch = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
{
cx = ctx->DrawBuffer->_Xmin;
cy = ctx->DrawBuffer->_Ymin;
ch = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
cw = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
}
if (intel->ctx.DrawBuffer->Name == 0) { if (intel->ctx.DrawBuffer->Name == 0) {
/* clearing a window */ /* clearing a window */
@@ -458,7 +453,9 @@ intelClearWithBlit(GLcontext * ctx, GLbitfield mask, GLboolean all,
const drm_clip_rect_t *box = &intel->pClipRects[i]; const drm_clip_rect_t *box = &intel->pClipRects[i];
drm_clip_rect_t b; drm_clip_rect_t b;
GLuint buf; GLuint buf;
GLuint clearMask = mask; /* use copy, since we modify it below */ GLuint clearMask = mask; /* use copy, since we modify it below */
GLboolean all = (cw == ctx->DrawBuffer->Width &&
ch == ctx->DrawBuffer->Height);
if (!all) { if (!all) {
intel_intersect_cliprects(&b, &clear, box); intel_intersect_cliprects(&b, &clear, box);

View File

@@ -281,7 +281,7 @@ intelWindowMoved(struct intel_context *intel)
static void static void
intelClearWithTris(struct intel_context *intel, intelClearWithTris(struct intel_context *intel,
GLbitfield mask, GLbitfield mask,
GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch) GLboolean allFoo, GLint cxFoo, GLint cyFoo, GLint cwFoo, GLint chFoo)
{ {
GLcontext *ctx = &intel->ctx; GLcontext *ctx = &intel->ctx;
drm_clip_rect_t clear; drm_clip_rect_t clear;
@@ -293,22 +293,16 @@ intelClearWithTris(struct intel_context *intel,
/* XXX FBO: was: intel->driDrawable->numClipRects */ /* XXX FBO: was: intel->driDrawable->numClipRects */
if (intel->numClipRects) { if (intel->numClipRects) {
GLint cx, cy, cw, ch;
GLuint buf; GLuint buf;
intel->vtbl.install_meta_state(intel); intel->vtbl.install_meta_state(intel);
/* Get clear bounds after locking */
/* Refresh the cx/y/w/h values as they may have been invalidated cx = ctx->DrawBuffer->_Xmin;
* by a new window position or size picked up when we did cy = ctx->DrawBuffer->_Ymin;
* LOCK_HARDWARE above. The values passed by mesa are not ch = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
* reliable. cw = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
*/
{
cx = ctx->DrawBuffer->_Xmin;
cy = ctx->DrawBuffer->_Ymin;
ch = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
cw = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
}
/* note: regardless of 'all', cx, cy, cw, ch are now correct */ /* note: regardless of 'all', cx, cy, cw, ch are now correct */
clear.x1 = cx; clear.x1 = cx;
@@ -542,7 +536,7 @@ intelRotateWindow(struct intel_context *intel,
static void static void
intelClear(GLcontext * ctx, intelClear(GLcontext * ctx,
GLbitfield mask, GLbitfield mask,
GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch) GLboolean allFoo, GLint cxFoo, GLint cyFoo, GLint cwFoo, GLint chFoo)
{ {
struct intel_context *intel = intel_context(ctx); struct intel_context *intel = intel_context(ctx);
const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask); const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask);
@@ -609,13 +603,13 @@ intelClear(GLcontext * ctx,
intelFlush(ctx); /* XXX intelClearWithBlit also does this */ intelFlush(ctx); /* XXX intelClearWithBlit also does this */
if (blit_mask) if (blit_mask)
intelClearWithBlit(ctx, blit_mask, all, cx, cy, cw, ch); intelClearWithBlit(ctx, blit_mask, 0, 0, 0, 0, 0);
if (tri_mask) if (tri_mask)
intelClearWithTris(intel, tri_mask, all, cx, cy, cw, ch); intelClearWithTris(intel, tri_mask, 0, 0, 0, 0, 0);
if (swrast_mask) if (swrast_mask)
_swrast_Clear(ctx, swrast_mask, all, cx, cy, cw, ch); _swrast_Clear(ctx, swrast_mask, 0, 0, 0, 0, 0);
} }