Rendering to FBO w/ stencil but w/out depth works now.

Assorted clean-ups and fixes.
This commit is contained in:
Brian Paul 2006-03-22 23:05:25 +00:00
parent d689cd0715
commit 08f0579176
4 changed files with 42 additions and 51 deletions

View file

@ -534,8 +534,6 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
_mesa_update_framebuffer(ctx);
/* this updates the DrawBuffer's Width/Height if it's a FBO */
_mesa_update_draw_buffer_bounds(ctx);
intel_validate_depth_stencil(ctx, fb);
}
if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
@ -546,6 +544,8 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
return;
}
intel_validate_paired_depth_stencil(ctx, fb);
/*
* How many color buffers are we drawing into?
*/
@ -570,7 +570,7 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
}
/*
* Get the intel_renderbuffer we're drawing into.
* Get the intel_renderbuffer for the colorbuffer we're drawing into.
* And set up cliprects.
*/
if (fb->Name == 0) {
@ -597,26 +597,12 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
ASSERT(irb);
}
/*
* Unbind old color region, bind new region
*/
if (intel->draw_region != colorRegion) {
intel_region_release(intel, &intel->draw_region);
intel_region_reference(&intel->draw_region, colorRegion);
}
/***
*** Get depth buffer region and check if we need a software fallback.
*** Note the BUFFER_DEPTH attachment is usually a DEPTH_STENCIL buffer.
*** Note that the depth buffer is usually a DEPTH_STENCIL buffer.
***/
#if 0
irbDepth = intel_get_renderbuffer(fb, BUFFER_DEPTH);
if (irbDepth) {
#else
if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped) {
irbDepth = intel_renderbuffer(fb->_DepthBuffer->Wrapped);
#endif
if (irbDepth->region) {
FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
depthRegion = irbDepth->region;
@ -632,33 +618,20 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
depthRegion = NULL;
}
/*
* Unbind old depth region, bind new region
*/
if (intel->depth_region != depthRegion) {
intel_region_release(intel, &intel->depth_region);
intel_region_reference(&intel->depth_region, depthRegion);
}
/***
*** Stencil buffer
*** This can only be hardware accelerated if we're using a
*** combined DEPTH_STENCIL buffer (for now anyway).
***/
#if 0
irbStencil = intel_get_renderbuffer(fb, BUFFER_STENCIL);
if (irbStencil) {
#else
if (fb->_StencilBuffer && fb->_StencilBuffer->Wrapped) {
irbStencil = intel_renderbuffer(fb->_StencilBuffer->Wrapped);
#endif
if ((irbStencil == irbDepth && irbStencil->region) /***||
(irbStencil->PairedDepth == irbDepth->Base.Name)**/) {
if (irbStencil && irbStencil->region) {
ASSERT(irbStencil->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT);
FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
/* need to re-compute stencil hw state */
ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
if (!depthRegion)
depthRegion = irbStencil->region;
}
else {
FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_TRUE);
@ -670,9 +643,19 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
/* need to re-compute stencil hw state */
ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
}
/*
_mesa_debug(ctx, "STENCIL FALLBACK: 0x%x\n", intel->Fallback );
*/
/**
** Release old regions, reference new regions
**/
if (intel->draw_region != colorRegion) {
intel_region_release(intel, &intel->draw_region);
intel_region_reference(&intel->draw_region, colorRegion);
}
if (intel->depth_region != depthRegion) {
intel_region_release(intel, &intel->depth_region);
intel_region_reference(&intel->depth_region, depthRegion);
}
intel->vtbl.set_draw_region( intel, colorRegion, depthRegion );

View file

@ -131,8 +131,7 @@ unmap_regions(GLcontext *ctx,
* driRb should be a depth/stencil or stencil renderbuffer.
*/
void
intel_undo_depth_stencil_pairing(GLcontext *ctx,
struct intel_renderbuffer *irb)
intel_unpair_depth_stencil(GLcontext *ctx, struct intel_renderbuffer *irb)
{
if (irb->PairedStencil) {
/* irb is a depth/stencil buffer */
@ -183,10 +182,16 @@ intel_undo_depth_stencil_pairing(GLcontext *ctx,
/**
* Must be called if NewState & _NEW_BUFFER
* Examine the depth and stencil renderbuffers which are attached to the
* framebuffer. If both depth and stencil are attached, make sure that the
* renderbuffers are 'paired' (combined). If only depth or only stencil is
* attached, undo any previous pairing.
*
* Must be called if NewState & _NEW_BUFFER (when renderbuffer attachments
* change, for example).
*/
void
intel_validate_depth_stencil(GLcontext *ctx, struct gl_framebuffer *fb)
intel_validate_paired_depth_stencil(GLcontext *ctx, struct gl_framebuffer *fb)
{
struct intel_renderbuffer *depthRb, *stencilRb;
@ -213,10 +218,10 @@ intel_validate_depth_stencil(GLcontext *ctx, struct gl_framebuffer *fb)
else {
/* need to setup pairing/interleaving */
if (depthRb->PairedStencil) {
intel_undo_depth_stencil_pairing(ctx, depthRb);
intel_unpair_depth_stencil(ctx, depthRb);
}
if (stencilRb->PairedDepth) {
intel_undo_depth_stencil_pairing(ctx, stencilRb);
intel_unpair_depth_stencil(ctx, stencilRb);
}
ASSERT(depthRb->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT);
@ -242,7 +247,7 @@ intel_validate_depth_stencil(GLcontext *ctx, struct gl_framebuffer *fb)
*/
/* intel_undo any previous pairing */
if (depthRb->PairedStencil) {
intel_undo_depth_stencil_pairing(ctx, depthRb);
intel_unpair_depth_stencil(ctx, depthRb);
}
}
else if (stencilRb) {
@ -252,17 +257,21 @@ intel_validate_depth_stencil(GLcontext *ctx, struct gl_framebuffer *fb)
*/
/* undo any previous pairing */
if (stencilRb->PairedDepth) {
intel_undo_depth_stencil_pairing(ctx, stencilRb);
intel_unpair_depth_stencil(ctx, stencilRb);
}
if (stencilRb->Base._ActualFormat == GL_STENCIL_INDEX8_EXT) {
/* promote buffer to GL_DEPTH24_STENCIL8 */
/* promote buffer to GL_DEPTH24_STENCIL8 for hw rendering */
_mesa_promote_stencil(ctx, &stencilRb->Base);
ASSERT(stencilRb->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT);
}
}
_mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH);
_mesa_update_stencil_buffer(ctx, fb, BUFFER_DEPTH); /* Yes, not STENCIL */
if (depthRb)
_mesa_update_stencil_buffer(ctx, fb, BUFFER_DEPTH);
else
_mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL);
/* The hardware should use fb->Attachment[BUFFER_DEPTH].Renderbuffer
* first, if present, then fb->Attachment[BUFFER_STENCIL].Renderbuffer

View file

@ -4,11 +4,10 @@
extern void
intel_undo_depth_stencil_pairing(GLcontext *ctx,
struct intel_renderbuffer *driRb);
intel_unpair_depth_stencil(GLcontext *ctx, struct intel_renderbuffer *irb);
extern void
intel_validate_depth_stencil(GLcontext *ctx, struct gl_framebuffer *fb);
intel_validate_paired_depth_stencil(GLcontext *ctx, struct gl_framebuffer *fb);
#endif /* INTEL_DEPTH_STENCIL_H */

View file

@ -105,7 +105,7 @@ intel_delete_renderbuffer(struct gl_renderbuffer *rb)
ASSERT(irb);
if (irb->PairedStencil || irb->PairedDepth) {
intel_undo_depth_stencil_pairing(ctx, irb);
intel_unpair_depth_stencil(ctx, irb);
}
if (intel && irb->region) {