diff options
Diffstat (limited to 'src/mesa')
34 files changed, 230 insertions, 216 deletions
diff --git a/src/mesa/drivers/dri/i810/i810context.c b/src/mesa/drivers/dri/i810/i810context.c index 3f7f2cc8a47..9e09bddea3d 100644 --- a/src/mesa/drivers/dri/i810/i810context.c +++ b/src/mesa/drivers/dri/i810/i810context.c @@ -424,11 +424,11 @@ void i810XMesaSetBackClipRects( i810ContextPtr imesa ) static void i810XMesaWindowMoved( i810ContextPtr imesa ) { /* Determine current color drawing buffer */ - switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) { - case BUFFER_BIT_FRONT_LEFT: + switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0]) { + case BUFFER_FRONT_LEFT: i810XMesaSetFrontClipRects( imesa ); break; - case BUFFER_BIT_BACK_LEFT: + case BUFFER_BACK_LEFT: i810XMesaSetBackClipRects( imesa ); break; default: @@ -486,11 +486,11 @@ i810UpdatePageFlipping( i810ContextPtr imesa ) int front = 0; /* Determine current color drawing buffer */ - switch (ctx->DrawBuffer->_ColorDrawBufferMask[0]) { - case BUFFER_BIT_FRONT_LEFT: + switch (ctx->DrawBuffer->_ColorDrawBufferIndexes[0]) { + case BUFFER_FRONT_LEFT: front = 1; break; - case BUFFER_BIT_BACK_LEFT: + case BUFFER_BACK_LEFT: front = 0; break; default: diff --git a/src/mesa/drivers/dri/i810/i810state.c b/src/mesa/drivers/dri/i810/i810state.c index e0d5b2b4876..185c098b5e1 100644 --- a/src/mesa/drivers/dri/i810/i810state.c +++ b/src/mesa/drivers/dri/i810/i810state.c @@ -292,18 +292,20 @@ void i810DrawBuffer(GLcontext *ctx, GLenum mode ) i810ContextPtr imesa = I810_CONTEXT(ctx); int front = 0; - /* - * _DrawDestMask is easier to cope with than <mode>. - */ - switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0]) { - case BUFFER_BIT_FRONT_LEFT: + if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { + /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ + FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_TRUE ); + return; + } + + switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0]) { + case BUFFER_FRONT_LEFT: front = 1; break; - case BUFFER_BIT_BACK_LEFT: + case BUFFER_BACK_LEFT: front = 0; break; default: - /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c index 99ea37d2275..2cb57f3a925 100644 --- a/src/mesa/drivers/dri/i915/intel_context.c +++ b/src/mesa/drivers/dri/i915/intel_context.c @@ -788,9 +788,7 @@ void LOCK_HARDWARE( struct intel_context *intel ) if (intel_fb) intel_rb = intel_get_renderbuffer(&intel_fb->Base, - intel_fb->Base._ColorDrawBufferMask[0] == - BUFFER_BIT_FRONT_LEFT ? BUFFER_FRONT_LEFT : - BUFFER_BACK_LEFT); + intel_fb->Base._ColorDrawBufferIndexes[0]); } if (intel_rb && dPriv->vblFlags && diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 5a6ef463ea0..a4645effd43 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -463,7 +463,9 @@ struct brw_context struct intel_region *saved_draw_region; struct intel_region *saved_depth_region; - GLuint restore_draw_mask; + GLuint restore_draw_buffers[MAX_DRAW_BUFFERS]; + GLuint restore_num_draw_buffers; + struct gl_fragment_program *restore_fp; GLboolean active; diff --git a/src/mesa/drivers/dri/i965/brw_metaops.c b/src/mesa/drivers/dri/i965/brw_metaops.c index 87da464f1ba..005489689f1 100644 --- a/src/mesa/drivers/dri/i965/brw_metaops.c +++ b/src/mesa/drivers/dri/i965/brw_metaops.c @@ -156,7 +156,7 @@ static const char *fp_tex_prog = * FragmentProgram->_Current * VertexProgram->_Enabled * brw->vertex_program - * DrawBuffer->_ColorDrawBufferMask[0] + * DrawBuffer->_ColorDrawBufferIndexes[0] * * * More if drawpixels-through-texture is added. @@ -481,6 +481,7 @@ static void install_meta_state( struct intel_context *intel ) { GLcontext *ctx = &intel->ctx; struct brw_context *brw = brw_context(ctx); + GLuint i; if (!brw->metaops.vbo) { init_metaops_state(brw); @@ -490,7 +491,12 @@ static void install_meta_state( struct intel_context *intel ) meta_no_texture(&brw->intel); meta_flat_shade(&brw->intel); - brw->metaops.restore_draw_mask = ctx->DrawBuffer->_ColorDrawBufferMask[0]; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + brw->metaops.restore_draw_buffers[i] + = ctx->DrawBuffer->_ColorDrawBufferIndexes[i]; + } + brw->metaops.restore_num_draw_buffers = ctx->DrawBuffer->_NumColorDrawBuffers; + brw->metaops.restore_fp = ctx->FragmentProgram.Current; /* This works without adjusting refcounts. Fix later? @@ -506,10 +512,16 @@ static void leave_meta_state( struct intel_context *intel ) { GLcontext *ctx = &intel->ctx; struct brw_context *brw = brw_context(ctx); + GLuint i; restore_attribs(brw); - ctx->DrawBuffer->_ColorDrawBufferMask[0] = brw->metaops.restore_draw_mask; + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + ctx->DrawBuffer->_ColorDrawBufferIndexes[i] + = brw->metaops.restore_draw_buffers[i]; + } + ctx->DrawBuffer->_NumColorDrawBuffers = brw->metaops.restore_num_draw_buffers; + ctx->FragmentProgram.Current = brw->metaops.restore_fp; brw->state.draw_region = brw->metaops.saved_draw_region; diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index 479c30669c3..72b17dd71f5 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -98,10 +98,10 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv, ASSERT(intel_fb); ASSERT(intel_fb->Base.Name == 0); /* Not a user-created FBO */ - ASSERT(frontRegion); - ASSERT(backRegion); - ASSERT(frontRegion->pitch == backRegion->pitch); - ASSERT(frontRegion->cpp == backRegion->cpp); + ASSERT(src); + ASSERT(dst); + ASSERT(src->pitch == dst->pitch); + ASSERT(src->cpp == dst->cpp); if (cpp == 2) { BR13 = (0xCC << 16) | (1 << 24); @@ -357,7 +357,7 @@ intelEmitCopyBlit(struct intel_context *intel, /** * Use blitting to clear the renderbuffers named by 'flags'. - * Note: we can't use the ctx->DrawBuffer->_ColorDrawBufferMask field + * Note: we can't use the ctx->DrawBuffer->_ColorDrawBufferIndexes field * since that might include software renderbuffers or renderbuffers * which we're clearing with triangles. * \param mask bitmask of BUFFER_BIT_* values indicating buffers to clear diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c index c654474200b..2ea8d683ebe 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.c +++ b/src/mesa/drivers/dri/intel/intel_buffers.c @@ -290,15 +290,14 @@ intelWindowMoved(struct intel_context *intel) } else { /* drawing to a window */ - switch (intel_fb->Base._ColorDrawBufferMask[0]) { - case BUFFER_BIT_FRONT_LEFT: + switch (intel_fb->Base._ColorDrawBufferIndexes[0]) { + case BUFFER_FRONT_LEFT: intelSetFrontClipRects(intel); break; - case BUFFER_BIT_BACK_LEFT: + case BUFFER_BACK_LEFT: intelSetBackClipRects(intel); break; default: - /* glDrawBuffer(GL_NONE or GL_FRONT_AND_BACK): software fallback */ intelSetFrontClipRects(intel); } } @@ -623,8 +622,8 @@ intel_wait_flips(struct intel_context *intel, GLuint batch_flags) (struct intel_framebuffer *) intel->ctx.DrawBuffer; struct intel_renderbuffer *intel_rb = intel_get_renderbuffer(&intel_fb->Base, - intel_fb->Base._ColorDrawBufferMask[0] == - BUFFER_BIT_FRONT_LEFT ? BUFFER_FRONT_LEFT : + intel_fb->Base._ColorDrawBufferIndexes[0] == + BUFFER_FRONT_LEFT ? BUFFER_FRONT_LEFT : BUFFER_BACK_LEFT); if (intel_fb->Base.Name == 0 && intel_rb && @@ -944,7 +943,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) /* draw to exactly one color buffer */ /*_mesa_debug(ctx, "Hardware rendering\n");*/ FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE); - if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) { + if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) { front = 1; } diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index 8d75c63cefa..84ac7889b2a 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -71,7 +71,10 @@ intel_renderbuffer(struct gl_renderbuffer *rb) struct intel_renderbuffer * intel_get_renderbuffer(struct gl_framebuffer *fb, GLuint attIndex) { - return intel_renderbuffer(fb->Attachment[attIndex].Renderbuffer); + if (attIndex >= 0) + return intel_renderbuffer(fb->Attachment[attIndex].Renderbuffer); + else + return NULL; } diff --git a/src/mesa/drivers/dri/mach64/mach64_lock.c b/src/mesa/drivers/dri/mach64/mach64_lock.c index b73e350111f..13e212b81de 100644 --- a/src/mesa/drivers/dri/mach64/mach64_lock.c +++ b/src/mesa/drivers/dri/mach64/mach64_lock.c @@ -70,7 +70,7 @@ void mach64GetLock( mach64ContextPtr mmesa, GLuint flags ) if ( mmesa->lastStamp != dPriv->lastStamp ) { mmesa->lastStamp = dPriv->lastStamp; - if (mmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) + if (mmesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) mach64SetCliprects( mmesa->glCtx, GL_BACK_LEFT ); else mach64SetCliprects( mmesa->glCtx, GL_FRONT_LEFT ); diff --git a/src/mesa/drivers/dri/mach64/mach64_state.c b/src/mesa/drivers/dri/mach64/mach64_state.c index 667a3945206..10a5b40ba16 100644 --- a/src/mesa/drivers/dri/mach64/mach64_state.c +++ b/src/mesa/drivers/dri/mach64/mach64_state.c @@ -726,24 +726,26 @@ static void mach64DDDrawBuffer( GLcontext *ctx, GLenum mode ) FLUSH_BATCH( mmesa ); - /* - * _DrawDestMask is easier to cope with than <mode>. - */ - switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { - case BUFFER_BIT_FRONT_LEFT: + if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { + /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ + FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_TRUE ); + return; + } + + switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { + case BUFFER_FRONT_LEFT: FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_FALSE ); mach64SetCliprects( ctx, GL_FRONT_LEFT ); if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) fprintf(stderr,"%s: BUFFER_BIT_FRONT_LEFT\n", __FUNCTION__); break; - case BUFFER_BIT_BACK_LEFT: + case BUFFER_BACK_LEFT: FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_FALSE ); mach64SetCliprects( ctx, GL_BACK_LEFT ); if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) fprintf(stderr,"%s: BUFFER_BIT_BACK_LEFT\n", __FUNCTION__); break; default: - /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_TRUE ); if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) fprintf(stderr,"%s: fallback (mode=%d)\n", __FUNCTION__, mode); diff --git a/src/mesa/drivers/dri/mga/mgastate.c b/src/mesa/drivers/dri/mga/mgastate.c index 88f2175cc3e..1d413d34734 100644 --- a/src/mesa/drivers/dri/mga/mgastate.c +++ b/src/mesa/drivers/dri/mga/mgastate.c @@ -799,20 +799,22 @@ static void mgaDDDrawBuffer(GLcontext *ctx, GLenum mode ) FLUSH_BATCH( mmesa ); - /* - * _DrawDestMask is easier to cope with than <mode>. - */ - switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { - case BUFFER_BIT_FRONT_LEFT: + if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { + /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ + FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE ); + return; + } + + switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { + case BUFFER_FRONT_LEFT: mmesa->setup.dstorg = mmesa->mgaScreen->frontOffset; mmesa->draw_buffer = MGA_FRONT; break; - case BUFFER_BIT_BACK_LEFT: + case BUFFER_BACK_LEFT: mmesa->setup.dstorg = mmesa->mgaScreen->backOffset; mmesa->draw_buffer = MGA_BACK; break; default: - /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 4f4128c875d..f18dd644905 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -328,7 +328,7 @@ nouveauDoSwapBuffers(nouveauContextPtr nmesa, __DRIdrawablePrivate *dPriv) int nbox, i; fb = (struct gl_framebuffer *)dPriv->driverPrivate; - if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) { + if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) { src = (nouveau_renderbuffer_t *) fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer; } else { diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c index 1135817fe9a..7bd42fdfe27 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_driver.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.c @@ -119,7 +119,7 @@ static void nouveauFlush( GLcontext *ctx ) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - if (ctx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) + if (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) nouveauDoSwapBuffers(nmesa, nmesa->driDrawable); FIRE_RING(); } diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c index f1e92d7a7a9..2abe59056e9 100644 --- a/src/mesa/drivers/dri/r128/r128_state.c +++ b/src/mesa/drivers/dri/r128/r128_state.c @@ -897,18 +897,22 @@ static void r128DDDrawBuffer( GLcontext *ctx, GLenum mode ) FLUSH_BATCH( rmesa ); - /* - * _ColorDrawBufferMask is easier to cope with than <mode>. - */ - switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { - case BUFFER_BIT_FRONT_LEFT: - case BUFFER_BIT_BACK_LEFT: - FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE ); - break; - default: + if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_TRUE ); - break; + return; + } + else { + switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { + case BUFFER_FRONT_LEFT: + case BUFFER_BACK_LEFT: + FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE ); + break; + default: + /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ + FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_TRUE ); + break; + } } rmesa->new_state |= R128_NEW_WINDOW; diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index 1d975ecd57d..cf375171c8a 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -1859,8 +1859,7 @@ void r200SetCliprects( r200ContextPtr rmesa ) GLframebuffer *const draw_fb = (GLframebuffer*) drawable->driverPrivate; GLframebuffer *const read_fb = (GLframebuffer*) readable->driverPrivate; - if (draw_fb->_ColorDrawBufferMask[0] - == BUFFER_BIT_BACK_LEFT) { + if (draw_fb->_ColorDrawBufferIndexes[0] == BUFFER_BIT_BACK_LEFT) { /* Can't ignore 2d windows if we are page flipping. */ if ( drawable->numBackClipRects == 0 || rmesa->doPageFlip ) { @@ -1910,17 +1909,18 @@ static void r200DrawBuffer( GLcontext *ctx, GLenum mode ) R200_FIREVERTICES(rmesa); /* don't pipeline cliprect changes */ - /* - * _ColorDrawBufferMask is easier to cope with than <mode>. - * Check for software fallback, update cliprects. - */ - switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { - case BUFFER_BIT_FRONT_LEFT: - case BUFFER_BIT_BACK_LEFT: + if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { + /* 0 (GL_NONE) buffers or multiple color drawing buffers */ + FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_TRUE ); + return; + } + + switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { + case BUFFER_FRONT_LEFT: + case BUFFER_BACK_LEFT: FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; default: - /* 0 (GL_NONE) buffers or multiple color drawing buffers */ FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } @@ -2445,11 +2445,11 @@ r200UpdateDrawBuffer(GLcontext *ctx) struct gl_framebuffer *fb = ctx->DrawBuffer; driRenderbuffer *drb; - if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) { + if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) { /* draw to front */ drb = (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer; } - else if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) { + else if (fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) { /* draw to back */ drb = (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer; } diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 9491f98b473..b90f42234a9 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1007,12 +1007,12 @@ void r300UpdateDrawBuffer(GLcontext * ctx) struct gl_framebuffer *fb = ctx->DrawBuffer; driRenderbuffer *drb; - if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) { + if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) { /* draw to front */ drb = (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT]. Renderbuffer; - } else if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) { + } else if (fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) { /* draw to back */ drb = (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT]. diff --git a/src/mesa/drivers/dri/r300/radeon_lock.c b/src/mesa/drivers/dri/r300/radeon_lock.c index bc3c2d6c6b3..d54a821c635 100644 --- a/src/mesa/drivers/dri/r300/radeon_lock.c +++ b/src/mesa/drivers/dri/r300/radeon_lock.c @@ -68,8 +68,8 @@ void radeonUpdatePageFlipping(radeonContextPtr rmesa) } use_back = rmesa->glCtx->DrawBuffer ? - (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == - BUFFER_BIT_BACK_LEFT) : 1; + (rmesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] == + BUFFER_BACK_LEFT) : 1; use_back ^= (rmesa->sarea->pfCurrentPage == 1); if (use_back) { diff --git a/src/mesa/drivers/dri/r300/radeon_state.c b/src/mesa/drivers/dri/r300/radeon_state.c index 82bfd951b92..af2c3bcacd3 100644 --- a/src/mesa/drivers/dri/r300/radeon_state.c +++ b/src/mesa/drivers/dri/r300/radeon_state.c @@ -152,7 +152,7 @@ void radeonSetCliprects(radeonContextPtr radeon) GLframebuffer *const draw_fb = (GLframebuffer*)drawable->driverPrivate; GLframebuffer *const read_fb = (GLframebuffer*)readable->driverPrivate; - if (draw_fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) { + if (draw_fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) { /* Can't ignore 2d windows if we are page flipping. */ if (drawable->numBackClipRects == 0 || radeon->doPageFlip || radeon->sarea->pfCurrentPage == 1) { diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c index 4de05c7697d..ae83c91d25f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state.c +++ b/src/mesa/drivers/dri/radeon/radeon_state.c @@ -1640,8 +1640,7 @@ void radeonSetCliprects( radeonContextPtr rmesa ) GLframebuffer *const draw_fb = (GLframebuffer*) drawable->driverPrivate; GLframebuffer *const read_fb = (GLframebuffer*) readable->driverPrivate; - if (draw_fb->_ColorDrawBufferMask[0] - == BUFFER_BIT_BACK_LEFT) { + if (draw_fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) { /* Can't ignore 2d windows if we are page flipping. */ if ( drawable->numBackClipRects == 0 || rmesa->doPageFlip ) { @@ -1693,17 +1692,18 @@ static void radeonDrawBuffer( GLcontext *ctx, GLenum mode ) RADEON_FIREVERTICES(rmesa); /* don't pipeline cliprect changes */ - /* - * _ColorDrawBufferMask is easier to cope with than <mode>. - * Check for software fallback, update cliprects. - */ - switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { - case BUFFER_BIT_FRONT_LEFT: - case BUFFER_BIT_BACK_LEFT: + if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { + /* 0 (GL_NONE) buffers or multiple color drawing buffers */ + FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_TRUE ); + return; + } + + switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { + case BUFFER_FRONT_LEFT: + case BUFFER_BACK_LEFT: FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; default: - /* 0 (GL_NONE) buffers or multiple color drawing buffers */ FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } @@ -2222,11 +2222,11 @@ radeonUpdateDrawBuffer(GLcontext *ctx) struct gl_framebuffer *fb = ctx->DrawBuffer; driRenderbuffer *drb; - if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) { + if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) { /* draw to front */ drb = (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer; } - else if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) { + else if (fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) { /* draw to back */ drb = (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer; } diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c index 013e88216fa..f23409fcbc9 100644 --- a/src/mesa/drivers/dri/savage/savage_xmesa.c +++ b/src/mesa/drivers/dri/savage/savage_xmesa.c @@ -730,7 +730,7 @@ void savageXMesaSetClipRects(savageContextPtr imesa) __DRIdrawablePrivate *dPriv = imesa->driDrawable; if ((dPriv->numBackClipRects == 0) - || (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT)) { + || (imesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)) { imesa->numClipRects = dPriv->numClipRects; imesa->pClipRects = dPriv->pClipRects; imesa->drawX = dPriv->x; diff --git a/src/mesa/drivers/dri/savage/savagestate.c b/src/mesa/drivers/dri/savage/savagestate.c index 741a9dda4f7..7c36b133a91 100644 --- a/src/mesa/drivers/dri/savage/savagestate.c +++ b/src/mesa/drivers/dri/savage/savagestate.c @@ -640,15 +640,17 @@ static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode ) savageContextPtr imesa = SAVAGE_CONTEXT(ctx); u_int32_t destCtrl = imesa->regs.s4.destCtrl.ui; - /* - * _DrawDestMask is easier to cope with than <mode>. - */ - switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { - case BUFFER_BIT_FRONT_LEFT: + if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { + FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_TRUE ); + return; + } + + switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { + case BUFFER_FRONT_LEFT: imesa->IsDouble = GL_FALSE; imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->frontOffset>>11; break; - case BUFFER_BIT_BACK_LEFT: + case BUFFER_BACK_LEFT: imesa->IsDouble = GL_TRUE; imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11; break; diff --git a/src/mesa/drivers/dri/sis/sis6326_state.c b/src/mesa/drivers/dri/sis/sis6326_state.c index 08402fb3e2a..e47e663c358 100644 --- a/src/mesa/drivers/dri/sis/sis6326_state.c +++ b/src/mesa/drivers/dri/sis/sis6326_state.c @@ -497,25 +497,27 @@ void sis6326DDDrawBuffer( GLcontext *ctx, GLenum mode ) __GLSiSHardware *current = &smesa->current; if(getenv("SIS_DRAW_FRONT")) - ctx->DrawBuffer->_ColorDrawBufferMask[0] = GL_FRONT_LEFT; + ctx->DrawBuffer->_ColorDrawBufferIndexes[0] = BUFFER_FRONT_LEFT; + + if (ctx->DrawBuffer->_NumColorDrawBuffers > 1) { + FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE ); + return; + } - /* - * _DrawDestMask is easier to cope with than <mode>. - */ current->hwDstSet &= ~MASK_DstBufferPitch; - switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { - case BUFFER_BIT_FRONT_LEFT: + + switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { + case BUFFER_FRONT_LEFT: current->hwOffsetDest = smesa->front.offset; current->hwDstSet |= smesa->front.pitch; FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; - case BUFFER_BIT_BACK_LEFT: + case BUFFER_BACK_LEFT: current->hwOffsetDest = smesa->back.offset; current->hwDstSet |= smesa->back.pitch; FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; default: - /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } diff --git a/src/mesa/drivers/dri/sis/sis_state.c b/src/mesa/drivers/dri/sis/sis_state.c index 33a2f089b82..b7454d4a078 100644 --- a/src/mesa/drivers/dri/sis/sis_state.c +++ b/src/mesa/drivers/dri/sis/sis_state.c @@ -547,23 +547,24 @@ void sisDDDrawBuffer( GLcontext *ctx, GLenum mode ) __GLSiSHardware *prev = &smesa->prev; __GLSiSHardware *current = &smesa->current; - /* - * _DrawDestMask is easier to cope with than <mode>. - */ + if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { + FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE ); + return; + } + current->hwDstSet &= ~MASK_DstBufferPitch; - switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { - case BUFFER_BIT_FRONT_LEFT: + switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { + case BUFFER_FRONT_LEFT: FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE ); current->hwOffsetDest = smesa->front.offset >> 1; current->hwDstSet |= smesa->front.pitch >> 2; break; - case BUFFER_BIT_BACK_LEFT: + case BUFFER_BACK_LEFT: FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE ); current->hwOffsetDest = smesa->back.offset >> 1; current->hwDstSet |= smesa->back.pitch >> 2; break; default: - /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } diff --git a/src/mesa/drivers/dri/sis/sis_tris.c b/src/mesa/drivers/dri/sis/sis_tris.c index a0e39dcd3c9..adbbb8ae137 100644 --- a/src/mesa/drivers/dri/sis/sis_tris.c +++ b/src/mesa/drivers/dri/sis/sis_tris.c @@ -848,7 +848,7 @@ static void sisRenderStart( GLcontext *ctx ) RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); - if (ctx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT && + if (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT && smesa->driDrawable->numClipRects != 0) { multipass_cliprect(ctx, 0); diff --git a/src/mesa/drivers/dri/tdfx/tdfx_render.c b/src/mesa/drivers/dri/tdfx/tdfx_render.c index f36c97bfebe..7b3ce36d1be 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_render.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_render.c @@ -275,7 +275,7 @@ static void tdfxClear( GLcontext *ctx, GLbitfield mask ) fxMesa->Color.ClearAlpha, fxMesa->Depth.Clear); FX_grColorMaskv_NoLock(ctx, true4); - if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT) + if (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); if (!ctx->Depth.Test || !ctx->Depth.Mask) fxMesa->Glide.grDepthMask(FXFALSE); @@ -295,7 +295,7 @@ static void tdfxClear( GLcontext *ctx, GLbitfield mask ) fxMesa->Glide.grDepthMask(FXTRUE); } FX_grColorMaskv_NoLock(ctx, true4); - if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT) + if (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER); } } diff --git a/src/mesa/drivers/dri/tdfx/tdfx_state.c b/src/mesa/drivers/dri/tdfx/tdfx_state.c index 42cb5dfaa38..e4d77e67420 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_state.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_state.c @@ -1033,21 +1033,23 @@ static void tdfxDDDrawBuffer( GLcontext *ctx, GLenum mode ) FLUSH_BATCH( fxMesa ); - /* - * _ColorDrawBufferMask is easier to cope with than <mode>. - */ - switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { - case BUFFER_BIT_FRONT_LEFT: + if (ctx->DrawBuffer->_NumColorDrawBuffers > 1) { + FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE ); + return; + } + + switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { + case BUFFER_FRONT_LEFT: fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER; fxMesa->new_state |= TDFX_NEW_RENDER; FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; - case BUFFER_BIT_BACK_LEFT: + case BUFFER_BACK_LEFT: fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER; fxMesa->new_state |= TDFX_NEW_RENDER; FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; - case 0: + case -1: FX_grColorMaskv( ctx, false4 ); FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c index 1551be5e751..a06b65224d1 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.c +++ b/src/mesa/drivers/dri/unichrome/via_context.c @@ -736,8 +736,8 @@ void viaXMesaWindowMoved(struct via_context *vmesa) draw_buffer = (struct via_renderbuffer *) drawable->driverPrivate; read_buffer = (struct via_renderbuffer *) readable->driverPrivate; - switch (vmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) { - case BUFFER_BIT_BACK_LEFT: + switch (vmesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0]) { + case BUFFER_BACK_LEFT: if (drawable->numBackClipRects == 0) { vmesa->numClipRects = drawable->numClipRects; vmesa->pClipRects = drawable->pClipRects; @@ -747,7 +747,7 @@ void viaXMesaWindowMoved(struct via_context *vmesa) vmesa->pClipRects = drawable->pBackClipRects; } break; - case BUFFER_BIT_FRONT_LEFT: + case BUFFER_FRONT_LEFT: vmesa->numClipRects = drawable->numClipRects; vmesa->pClipRects = drawable->pClipRects; break; diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c index bccdbe93264..d2c528923fd 100644 --- a/src/mesa/drivers/dri/unichrome/via_state.c +++ b/src/mesa/drivers/dri/unichrome/via_state.c @@ -656,13 +656,18 @@ static void viaDrawBuffer(GLcontext *ctx, GLenum mode) if (!ctx->DrawBuffer) return; - switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { - case BUFFER_BIT_FRONT_LEFT: + if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) { + FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_TRUE); + return; + } + + switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { + case BUFFER_FRONT_LEFT: VIA_FLUSH_DMA(vmesa); vmesa->drawBuffer = &vmesa->front; FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE); break; - case BUFFER_BIT_BACK_LEFT: + case BUFFER_BACK_LEFT: VIA_FLUSH_DMA(vmesa); vmesa->drawBuffer = &vmesa->back; FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE); diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 4e56f7bde50..c082fd827f2 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -1955,8 +1955,8 @@ fx_check_IsInHardware(GLcontext * ctx) return FX_FALLBACK_STENCIL; } - if (ctx->DrawBuffer->_ColorDrawBufferMask[0] != BUFFER_BIT_FRONT_LEFT && - ctx->DrawBuffer->_ColorDrawBufferMask[0] != BUFFER_BIT_BACK_LEFT) { + if ((ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_FRONT_LEFT) && + (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_BACK_LEFT)) { return FX_FALLBACK_DRAW_BUFFER; } diff --git a/src/mesa/drivers/x11/xm_line.c b/src/mesa/drivers/x11/xm_line.c index 7109c439157..9833b4c9f07 100644 --- a/src/mesa/drivers/x11/xm_line.c +++ b/src/mesa/drivers/x11/xm_line.c @@ -587,8 +587,8 @@ get_line_func(GLcontext *ctx) const int depth = GET_VISUAL_DEPTH(xmesa->xm_visual); const struct xmesa_renderbuffer *xrb; - if ((ctx->DrawBuffer->_ColorDrawBufferMask[0] - & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0) + if ((ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_FRONT_LEFT) && + (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_BACK_LEFT)) return (swrast_line_func) NULL; if (ctx->RenderMode != GL_RENDER) return (swrast_line_func) NULL; if (ctx->Line.SmoothFlag) return (swrast_line_func) NULL; @@ -662,7 +662,7 @@ get_line_func(GLcontext *ctx) #ifndef XFree86Server if (ctx->DrawBuffer->_NumColorDrawBuffers == 1 - && ctx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT + && ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT && swrast->_RasterMask == LOGIC_OP_BIT && ctx->Color.LogicOp == GL_XOR && !ctx->Line.StippleFlag diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c index a3978abdd07..c87a2937567 100644 --- a/src/mesa/drivers/x11/xm_tri.c +++ b/src/mesa/drivers/x11/xm_tri.c @@ -1462,8 +1462,8 @@ get_triangle_func(GLcontext *ctx) #endif /* trivial fallback tests */ - if ((ctx->DrawBuffer->_ColorDrawBufferMask[0] - & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0) + if ((ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_FRONT_LEFT) && + (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_BACK_LEFT)) return (swrast_tri_func) NULL; if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL; diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 2252bbd4c51..20999772919 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -159,7 +159,10 @@ _mesa_Clear( GLbitfield mask ) */ bufferMask = 0; if (mask & GL_COLOR_BUFFER_BIT) { - bufferMask |= ctx->DrawBuffer->_ColorDrawBufferMask[0]; + GLuint i; + for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) { + bufferMask |= (1 << ctx->DrawBuffer->_ColorDrawBufferIndexes[i]); + } } if ((mask & GL_DEPTH_BUFFER_BIT) @@ -487,41 +490,6 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) /** - * Set color output state. Traditionally, there was only one color - * output, but fragment programs can now have several distinct color - * outputs (see GL_ARB_draw_buffers). This function sets the state - * for one such color output. - * \param ctx current context - * \param output which fragment program output - * \param buffer buffer to write to (like GL_LEFT) - * \param destMask BUFFER_* bitmask - * (like BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT). - */ -static void -set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, - GLbitfield destMask) -{ - struct gl_framebuffer *fb = ctx->DrawBuffer; - - ASSERT(output < ctx->Const.MaxDrawBuffers); - - /* Set per-FBO state */ - fb->ColorDrawBuffer[output] = buffer; - fb->_ColorDrawBufferMask[output] = destMask; - - /* this will be computed later, but zero to be safe */ - fb->_NumColorDrawBuffers = 0; - - if (fb->Name == 0) { - /* Only set the per-context DrawBuffer state if we're currently - * drawing to a window system framebuffer. - */ - ctx->Color.DrawBuffer[output] = buffer; - } -} - - -/** * Helper function to set the GL_DRAW_BUFFER state in the context and * current FBO. * @@ -531,7 +499,7 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, * \param ctx current context * \param n number of color outputs to set * \param buffers array[n] of colorbuffer names, like GL_LEFT. - * \param destMask array[n] of BUFFER_* bitmasks which correspond to the + * \param destMask array[n] of BUFFER_BIT_* bitmasks which correspond to the * colorbuffer names. (i.e. GL_FRONT_AND_BACK => * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT). */ @@ -539,13 +507,13 @@ void _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, const GLbitfield *destMask) { + struct gl_framebuffer *fb = ctx->DrawBuffer; GLbitfield mask[MAX_DRAW_BUFFERS]; - GLuint output; if (!destMask) { /* compute destMask values now */ - const GLbitfield supportedMask - = supported_buffer_bitmask(ctx, ctx->DrawBuffer); + const GLbitfield supportedMask = supported_buffer_bitmask(ctx, fb); + GLuint output; for (output = 0; output < n; output++) { mask[output] = draw_buffer_enum_to_bitmask(buffers[output]); ASSERT(mask[output] != BAD_MASK); @@ -554,13 +522,44 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, destMask = mask; } - for (output = 0; output < n; output++) { - set_color_output(ctx, output, buffers[output], destMask[output]); + if (n == 1) { + GLuint buf, count = 0; + /* init to -1 to help catch errors */ + fb->_ColorDrawBufferIndexes[0] = -1; + for (buf = 0; buf < BUFFER_COUNT; buf++) { + if (destMask[0] & (1 << buf)) { + fb->_ColorDrawBufferIndexes[count] = buf; + count++; + } + } + fb->ColorDrawBuffer[0] = buffers[0]; + fb->_NumColorDrawBuffers = count; + } + else { + GLuint buf, count = 0; + for (buf = 0; buf < n; buf++ ) { + if (destMask[buf]) { + fb->_ColorDrawBufferIndexes[buf] = _mesa_ffs(destMask[buf]) - 1; + count = buf + 1; + } + else { + fb->_ColorDrawBufferIndexes[buf] = -1; + } + } + /* set remaining outputs to -1 (GL_NONE) */ + while (buf < ctx->Const.MaxDrawBuffers) { + fb->_ColorDrawBufferIndexes[buf] = -1; + buf++; + } + fb->_NumColorDrawBuffers = count; } - /* set remaining color outputs to NONE */ - for (output = n; output < ctx->Const.MaxDrawBuffers; output++) { - set_color_output(ctx, output, GL_NONE, 0x0); + if (fb->Name == 0) { + /* also set context drawbuffer state */ + GLuint buf; + for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) { + ctx->Color.DrawBuffer[buf] = fb->ColorDrawBuffer[buf]; + } } ctx->NewState |= _NEW_COLOR; diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 8f92fd3b42b..06a34574881 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -109,8 +109,9 @@ _mesa_new_framebuffer(GLcontext *ctx, GLuint name) if (fb) { fb->Name = name; fb->RefCount = 1; + fb->_NumColorDrawBuffers = 1; fb->ColorDrawBuffer[0] = GL_COLOR_ATTACHMENT0_EXT; - fb->_ColorDrawBufferMask[0] = BUFFER_BIT_COLOR0; + fb->_ColorDrawBufferIndexes[0] = BUFFER_COLOR0; fb->ColorReadBuffer = GL_COLOR_ATTACHMENT0_EXT; fb->_ColorReadBufferIndex = BUFFER_COLOR0; fb->Delete = _mesa_destroy_framebuffer; @@ -141,14 +142,16 @@ _mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual) /* Init read/draw renderbuffer state */ if (visual->doubleBufferMode) { + fb->_NumColorDrawBuffers = 1; fb->ColorDrawBuffer[0] = GL_BACK; - fb->_ColorDrawBufferMask[0] = BUFFER_BIT_BACK_LEFT; + fb->_ColorDrawBufferIndexes[0] = BUFFER_BACK_LEFT; fb->ColorReadBuffer = GL_BACK; fb->_ColorReadBufferIndex = BUFFER_BACK_LEFT; } else { + fb->_NumColorDrawBuffers = 1; fb->ColorDrawBuffer[0] = GL_FRONT; - fb->_ColorDrawBufferMask[0] = BUFFER_BIT_FRONT_LEFT; + fb->_ColorDrawBufferIndexes[0] = BUFFER_FRONT_LEFT; fb->ColorReadBuffer = GL_FRONT; fb->_ColorReadBufferIndex = BUFFER_FRONT_LEFT; } @@ -636,39 +639,17 @@ _mesa_update_stencil_buffer(GLcontext *ctx, static void update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb) { - GLuint output, count = 0; + GLuint output; - /* First, interpret _ColorDrawBufferMask[] in the manner that would be - * used if the fragment program/shader writes to gl_FragData[] - */ - for (output = 0; output < ctx->Const.MaxDrawBuffers; output++) { - GLuint buf = _mesa_ffs(fb->_ColorDrawBufferMask[output]); - if (buf) { - struct gl_renderbuffer *rb = fb->Attachment[buf - 1].Renderbuffer; - fb->_ColorDrawBuffers[output] = rb; /* may be NULL */ - if (rb) - count = output + 1; + for (output = 0; output < fb->_NumColorDrawBuffers; output++) { + GLint buf = fb->_ColorDrawBufferIndexes[output]; + if (buf >= 0) { + fb->_ColorDrawBuffers[output] = fb->Attachment[buf].Renderbuffer; } - } - - /* Second, handle the GL_FRONT_AND_BACK case, overwriting the above - * if needed. - */ - GLbitfield bufferMask = fb->_ColorDrawBufferMask[0]; - if (_mesa_bitcount(bufferMask) > 1) { - GLuint i; - count = 0; - for (i = 0; bufferMask && i < BUFFER_COUNT; i++) { - if (bufferMask & (1 << i)) { - struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; - fb->_ColorDrawBuffers[count] = rb; - count++; - } - bufferMask &= ~(1 << i); + else { + fb->_ColorDrawBuffers[output] = NULL; } } - - fb->_NumColorDrawBuffers = count; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 0e7364c08fa..c8718a7f636 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2395,12 +2395,10 @@ struct gl_framebuffer GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS]; GLenum ColorReadBuffer; - /* These are computed from ColorDrawBuffer and ColorReadBuffer */ - GLbitfield _ColorDrawBufferMask[MAX_DRAW_BUFFERS]; /* Mask of BUFFER_BIT_* flags */ - GLint _ColorReadBufferIndex; /* -1 = None */ - - /* These are computed from _ColorDrawBufferMask and _ColorReadBufferIndex */ + /** Computed from ColorDraw/ReadBuffer above */ GLuint _NumColorDrawBuffers; + GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */ + GLint _ColorReadBufferIndex; /* -1 = None */ struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS]; struct gl_renderbuffer *_ColorReadBuffer; |