[Mesa-dev] [PATCH 04/16] intel: Refactor creation of hiz and mcs miptrees

Chad Versace chad.versace at linux.intel.com
Thu Aug 2 18:39:47 PDT 2012


Move the logic for creating the ancillary hiz and mcs miptress for winsys
and non-texture renderbuffers from intel_alloc_renderbuffer_storage to
intel_miptree_create_for_renderbuffer. Let's try to isolate complex
miptree logic to intel_mipmap_tree.c.

Without this refactor, code duplication would be required along the
intel_process_dri2_buffer codepath in order to create the mcs miptree.

Reviewed-by: Paul Berry <stereotype441 at gmail.com>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 src/mesa/drivers/dri/intel/intel_fbo.c         | 16 ----------------
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 19 ++++++++++++++++++-
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index cea57e6..e6e6408 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -274,22 +274,6 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
    if (!irb->mt)
       return false;
 
-   if (intel->vtbl.is_hiz_depth_format(intel, rb->Format)) {
-      bool ok = intel_miptree_alloc_hiz(intel, irb->mt, rb->NumSamples);
-      if (!ok) {
-	 intel_miptree_release(&irb->mt);
-	 return false;
-      }
-   }
-
-   if (irb->mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS) {
-      bool ok = intel_miptree_alloc_mcs(intel, irb->mt, rb->NumSamples);
-      if (!ok) {
-         intel_miptree_release(&irb->mt);
-         return false;
-      }
-   }
-
    return true;
 }
 
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 1f21d9c..3767c9d 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -336,6 +336,7 @@ intel_miptree_create_for_renderbuffer(struct intel_context *intel,
    enum intel_msaa_layout msaa_layout = INTEL_MSAA_LAYOUT_NONE;
    const uint32_t singlesample_width = width;
    const uint32_t singlesample_height = height;
+   bool ok;
 
    if (num_samples > 1) {
       /* Adjust width/height/depth for MSAA */
@@ -400,12 +401,28 @@ intel_miptree_create_for_renderbuffer(struct intel_context *intel,
 			     width, height, depth, true, num_samples,
                              msaa_layout);
    if (!mt)
-      return NULL;
+       goto fail;
 
    mt->singlesample_width0 = singlesample_width;
    mt->singlesample_height0 = singlesample_height;
 
+   if (intel->vtbl.is_hiz_depth_format(intel, format)) {
+      ok = intel_miptree_alloc_hiz(intel, mt, num_samples);
+      if (!ok)
+         goto fail;
+   }
+
+   if (mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS) {
+      ok = intel_miptree_alloc_mcs(intel, mt, num_samples);
+      if (!ok)
+         goto fail;
+   }
+
    return mt;
+
+fail:
+   intel_miptree_release(&mt);
+   return NULL;
 }
 
 void
-- 
1.7.11.4



More information about the mesa-dev mailing list