[Mesa-dev] [PATCH 12/12] i965: Update cached stencil region pointer when updating draw buffers

chad at chad-versace.us chad at chad-versace.us
Fri Apr 29 18:05:02 PDT 2011


From: Chad Versace <chad.versace at intel.com>

That is, update brw_context.state.stencil_region and set the dirty bit
BRW_NEW_STENCIL_BUFFER.

Signed-off-by: Chad Versace <chad.versace at intel.com>
---
 src/mesa/drivers/dri/i965/brw_vtbl.c       |    8 +++++++-
 src/mesa/drivers/dri/intel/intel_buffers.c |   13 +++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c
index a35ea99..411ba67 100644
--- a/src/mesa/drivers/dri/i965/brw_vtbl.c
+++ b/src/mesa/drivers/dri/i965/brw_vtbl.c
@@ -101,13 +101,19 @@ static void brw_set_draw_region( struct intel_context *intel,
 {
    struct brw_context *brw = brw_context(&intel->ctx);
 
-   assert(!stencil_region);
+   assert(stencil_region == NULL || intel->use_hiz);
 
    if (brw->state.depth_region != depth_region) {
       brw->state.dirty.brw |= BRW_NEW_DEPTH_BUFFER;
       intel_region_release(&brw->state.depth_region);
       intel_region_reference(&brw->state.depth_region, depth_region);
    }
+
+   if (brw->state.stencil_region != stencil_region) {
+      brw->state.dirty.brw |= BRW_NEW_STENCIL_BUFFER;
+      intel_region_release(&brw->state.stencil_region);
+      intel_region_reference(&brw->state.stencil_region, stencil_region);
+   }
 }
 
 
diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c
index 83f63b4..173a0ea 100644
--- a/src/mesa/drivers/dri/intel/intel_buffers.c
+++ b/src/mesa/drivers/dri/intel/intel_buffers.c
@@ -91,7 +91,9 @@ void
 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_region *colorRegions[MAX_DRAW_BUFFERS];
+   struct intel_region *depthRegion = NULL;
+   struct intel_region *stencilRegion = NULL;
    struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL;
 
    if (!fb) {
@@ -191,6 +193,7 @@ intel_draw_buffer(struct gl_context * ctx, struct gl_framebuffer *fb)
    if (fb->_StencilBuffer && fb->_StencilBuffer->Wrapped) {
       irbStencil = intel_renderbuffer(fb->_StencilBuffer->Wrapped);
       if (irbStencil && irbStencil->region) {
+         stencilRegion = irbStencil->region;
          if (intel->use_hiz)
             assert(irbStencil->Base.Format == MESA_FORMAT_S8);
          else
@@ -209,8 +212,8 @@ 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 (!intel->use_hiz && !depthRegion && irbStencil && irbStencil->region)
-      depthRegion = irbStencil->region;
+   if (!intel->use_hiz && !depthRegion && stencilRegion)
+      depthRegion = stencilRegion;
 
    /*
     * Update depth and stencil test state
@@ -230,7 +233,9 @@ intel_draw_buffer(struct gl_context * ctx, struct gl_framebuffer *fb)
       intel->NewGLState |= (_NEW_DEPTH | _NEW_STENCIL);
    }
 
-   intel->vtbl.set_draw_region(intel, colorRegions, depthRegion, NULL,
+   intel->vtbl.set_draw_region(intel, colorRegions, depthRegion,
+                               depthRegion == stencilRegion ? NULL :
+                                                              stencilRegion,
                                fb->_NumColorDrawBuffers);
    intel->NewGLState |= _NEW_BUFFERS;
 
-- 
1.7.4.2



More information about the mesa-dev mailing list