intel: Remove now trivial intel_renderbuffer_set_{hiz_,}region().
authorEric Anholt <eric@anholt.net>
Wed, 29 Jun 2011 18:26:32 +0000 (11:26 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 7 Jul 2011 21:42:47 +0000 (14:42 -0700)
As a result of this cleanup, a bug in
intel_process_dri2_buffer_no_separate_stencil() became quite apparent.
We were associating the NULL pointer after an unreference with the
STENCIL attachment -- clarify the logic and attach the right region.

Reviewed-by: Chad Versace <chad@chad-versace.us>
src/mesa/drivers/dri/intel/intel_context.c
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_fbo.h

index 547d81b9351d27d7c4de9baf0d4efa2474814415..0402d83e9e3cd5b13f2320ba486e064583ce50f0 100644 (file)
@@ -1112,7 +1112,6 @@ intel_query_dri2_buffers_no_separate_stencil(struct intel_context *intel,
  *
  * \see intel_update_renderbuffers()
  * \see intel_region_alloc_for_handle()
- * \see intel_renderbuffer_set_region()
  */
 static void
 intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
@@ -1124,7 +1123,6 @@ intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
    assert(!intel->must_use_separate_stencil);
 
    struct gl_framebuffer *fb = drawable->driverPrivate;
-   struct intel_region *region = NULL;
    struct intel_renderbuffer *depth_rb = NULL;
 
    if (!rb)
@@ -1151,20 +1149,18 @@ intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
       if (unlikely(INTEL_DEBUG & DEBUG_DRI)) {
         fprintf(stderr, "(reusing depth buffer as stencil)\n");
       }
-      intel_region_reference(&region, depth_rb->region);
+      intel_region_reference(&rb->region, depth_rb->region);
    } else {
-      region = intel_region_alloc_for_handle(intel->intelScreen,
-                                            buffer->cpp,
-                                            drawable->w,
-                                            drawable->h,
-                                            buffer->pitch / buffer->cpp,
-                                            buffer->name,
-                                            buffer_name);
+      intel_region_release(&rb->region);
+      rb->region = intel_region_alloc_for_handle(intel->intelScreen,
+                                                buffer->cpp,
+                                                drawable->w,
+                                                drawable->h,
+                                                buffer->pitch / buffer->cpp,
+                                                buffer->name,
+                                                buffer_name);
    }
 
-   intel_renderbuffer_set_region(intel, rb, region);
-   intel_region_release(&region);
-
    if (buffer->attachment == __DRI_BUFFER_DEPTH_STENCIL) {
       struct intel_renderbuffer *stencil_rb =
         intel_get_renderbuffer(fb, BUFFER_STENCIL);
@@ -1172,10 +1168,10 @@ intel_process_dri2_buffer_no_separate_stencil(struct intel_context *intel,
       if (!stencil_rb)
         return;
 
-      if (stencil_rb->region && stencil_rb->region->name == buffer->name)
-        return;
-
-      intel_renderbuffer_set_region(intel, stencil_rb, region);
+      /* The rb passed in is the BUFFER_DEPTH attachment, and we need
+       * to associate this region to BUFFER_STENCIL as well.
+       */
+      intel_region_reference(&stencil_rb->region, rb->region);
    }
 }
 
@@ -1300,7 +1296,6 @@ intel_query_dri2_buffers_with_separate_stencil(struct intel_context *intel,
  *
  * \see intel_update_renderbuffers()
  * \see intel_region_alloc_for_handle()
- * \see intel_renderbuffer_set_region()
  * \see enum intel_dri2_has_hiz
  */
 static void
@@ -1360,9 +1355,9 @@ intel_process_dri2_buffer_with_separate_stencil(struct intel_context *intel,
                                    buffer_name);
 
    if (buffer->attachment == __DRI_BUFFER_HIZ) {
-      intel_renderbuffer_set_hiz_region(intel, rb, region);
+      intel_region_reference(&rb->hiz_region, region);
    } else {
-      intel_renderbuffer_set_region(intel, rb, region);
+      intel_region_reference(&rb->region, region);
    }
 
    intel_region_release(&region);
@@ -1511,12 +1506,10 @@ intel_verify_dri2_has_hiz(struct intel_context *intel,
                                             / depth_stencil_buffer->cpp,
                                          depth_stencil_buffer->name,
                                          "dri2 depth / stencil buffer");
-        intel_renderbuffer_set_region(intel,
-                                      intel_get_renderbuffer(fb, BUFFER_DEPTH),
-                                      region);
-        intel_renderbuffer_set_region(intel,
-                                      intel_get_renderbuffer(fb, BUFFER_STENCIL),
-                                      region);
+        intel_region_reference(&intel_get_renderbuffer(fb, BUFFER_DEPTH)->region,
+                               region);
+        intel_region_reference(&intel_get_renderbuffer(fb, BUFFER_STENCIL)->region,
+                               region);
         intel_region_release(&region);
       }
    }
index ee656edae5b84246145933cd60fae861c104253b..124600200904e8690130dd9b1aa74779e19fef1a 100644 (file)
@@ -343,25 +343,6 @@ intel_nop_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
    return GL_FALSE;
 }
 
-
-void
-intel_renderbuffer_set_region(struct intel_context *intel,
-                             struct intel_renderbuffer *rb,
-                             struct intel_region *region)
-{
-   intel_region_reference(&rb->region, region);
-}
-
-
-void
-intel_renderbuffer_set_hiz_region(struct intel_context *intel,
-                                 struct intel_renderbuffer *rb,
-                                 struct intel_region *region)
-{
-   intel_region_reference(&rb->hiz_region, region);
-}
-
-
 /**
  * Create a new intel_renderbuffer which corresponds to an on-screen window,
  * not a user-created renderbuffer.
index cbf29c8625742d07443347d9c774286d5a124f79..f7f99a4f00cbb2f68af889c99036b1b0c031f924 100644 (file)
@@ -155,18 +155,6 @@ intel_framebuffer_has_hiz(struct gl_framebuffer *fb)
    return intel_framebuffer_get_hiz_region(fb) != NULL;
 }
 
-
-extern void
-intel_renderbuffer_set_region(struct intel_context *intel,
-                             struct intel_renderbuffer *irb,
-                             struct intel_region *region);
-
-extern void
-intel_renderbuffer_set_hiz_region(struct intel_context *intel,
-                                 struct intel_renderbuffer *rb,
-                                 struct intel_region *region);
-
-
 extern struct intel_renderbuffer *
 intel_create_renderbuffer(gl_format format);