Mesa (master): intel: Fix intel_draw_buffer() to accomodate hiz and separate stencil

Chad Versace chadversary at kemper.freedesktop.org
Wed May 25 14:44:45 UTC 2011


Module: Mesa
Branch: master
Commit: ce8fdf666fc14aa5b9672be1711dfc1c0039efd0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ce8fdf666fc14aa5b9672be1711dfc1c0039efd0

Author: Chad Versace <chad at chad-versace.us>
Date:   Mon May 23 13:47:42 2011 -0700

intel: Fix intel_draw_buffer() to accomodate hiz and separate stencil

The logic of intel_draw_buffers() expected that stencil buffers were
always combined depth/stencil.

Reviewed-by: Eric Anholt <eric at anholt.net>
Signed-off-by: Chad Versace <chad at chad-versace.us>

---

 src/mesa/drivers/dri/intel/intel_buffers.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c
index ee551ef..a0fa091 100644
--- a/src/mesa/drivers/dri/intel/intel_buffers.c
+++ b/src/mesa/drivers/dri/intel/intel_buffers.c
@@ -93,6 +93,7 @@ intel_draw_buffer(struct gl_context * ctx, struct gl_framebuffer *fb)
    struct intel_context *intel = intel_context(ctx);
    struct intel_region *colorRegions[MAX_DRAW_BUFFERS], *depthRegion = NULL;
    struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL;
+   bool fb_has_hiz = intel_framebuffer_has_hiz(fb);
 
    if (!fb) {
       /* this can happen during the initial context initialization */
@@ -166,11 +167,11 @@ intel_draw_buffer(struct gl_context * ctx, struct gl_framebuffer *fb)
 
    /***
     *** Get depth buffer region and check if we need a software fallback.
-    *** Note that the depth buffer is usually a DEPTH_STENCIL buffer.
     ***/
    if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped) {
       irbDepth = intel_renderbuffer(fb->_DepthBuffer->Wrapped);
       if (irbDepth && irbDepth->region) {
+	 assert(!fb_has_hiz || irbDepth->Base.Format != MESA_FORMAT_S8_Z24);
          FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
          depthRegion = irbDepth->region;
       }
@@ -187,13 +188,16 @@ intel_draw_buffer(struct gl_context * ctx, struct gl_framebuffer *fb)
 
    /***
     *** Stencil buffer
-    *** This can only be hardware accelerated if we're using a
-    *** combined DEPTH_STENCIL buffer.
     ***/
    if (fb->_StencilBuffer && fb->_StencilBuffer->Wrapped) {
       irbStencil = intel_renderbuffer(fb->_StencilBuffer->Wrapped);
       if (irbStencil && irbStencil->region) {
-         ASSERT(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
+	 if (!intel->has_separate_stencil)
+	    assert(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
+	 if (fb_has_hiz || intel->must_use_separate_stencil)
+	    assert(irbStencil->Base.Format == MESA_FORMAT_S8);
+	 if (irbStencil->Base.Format == MESA_FORMAT_S8)
+	    assert(intel->has_separate_stencil);
          FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
       }
       else {
@@ -208,8 +212,10 @@ intel_draw_buffer(struct gl_context * ctx, struct gl_framebuffer *fb)
    /* If we have a (packed) stencil buffer attached but no depth buffer,
     * we still need to set up the shared depth/stencil state so we can use it.
     */
-   if (depthRegion == NULL && irbStencil && irbStencil->region)
+   if (depthRegion == NULL && irbStencil && irbStencil->region
+       && irbStencil->Base.Format == MESA_FORMAT_S8_Z24) {
       depthRegion = irbStencil->region;
+   }
 
    /*
     * Update depth and stencil test state




More information about the mesa-commit mailing list