[Mesa-dev] [PATCH 3/5] i965: Make a helper function for the renderbuffer temporary mt workaround.

Eric Anholt eric at anholt.net
Fri Oct 12 15:30:36 PDT 2012


We now have a case of wanting to do that on gen6+ as well, so make this logic
usable elsewhere.
---
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |   23 +------------------
 src/mesa/drivers/dri/intel/intel_fbo.c           |   26 ++++++++++++++++++++++
 src/mesa/drivers/dri/intel/intel_fbo.h           |    3 +++
 3 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index abdcb84..25ee557 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -1136,28 +1136,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
 	  * select the image.  So, instead, we just make a new single-level
 	  * miptree and render into that.
 	  */
-	 struct intel_context *intel = intel_context(ctx);
-	 struct intel_texture_image *intel_image =
-	    intel_texture_image(irb->tex_image);
-	 struct intel_mipmap_tree *new_mt;
-	 int width, height, depth;
-
-	 intel_miptree_get_dimensions_for_image(irb->tex_image, &width, &height, &depth);
-
-	 new_mt = intel_miptree_create(intel, irb->tex_image->TexObject->Target,
-				       intel_image->base.Base.TexFormat,
-				       intel_image->base.Base.Level,
-				       intel_image->base.Base.Level,
-				       width, height, depth,
-				       true,
-                                       0 /* num_samples */,
-                                       INTEL_MSAA_LAYOUT_NONE);
-
-	 intel_miptree_copy_teximage(intel, intel_image, new_mt);
-	 intel_miptree_reference(&irb->mt, intel_image->mt);
-	 intel_renderbuffer_set_draw_offset(irb);
-	 intel_miptree_release(&new_mt);
-
+	 intel_renderbuffer_move_to_temp(intel, irb);
 	 mt = irb->mt;
       }
    }
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index feac702..10a8c7f 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -936,6 +936,32 @@ intel_renderbuffer_resolve_depth(struct intel_context *intel,
    return false;
 }
 
+void
+intel_renderbuffer_move_to_temp(struct intel_context *intel,
+                                struct intel_renderbuffer *irb)
+{
+   struct intel_texture_image *intel_image =
+      intel_texture_image(irb->tex_image);
+   struct intel_mipmap_tree *new_mt;
+   int width, height, depth;
+
+   intel_miptree_get_dimensions_for_image(irb->tex_image, &width, &height, &depth);
+
+   new_mt = intel_miptree_create(intel, irb->tex_image->TexObject->Target,
+                                 intel_image->base.Base.TexFormat,
+                                 intel_image->base.Base.Level,
+                                 intel_image->base.Base.Level,
+                                 width, height, depth,
+                                 true,
+                                 irb->mt->num_samples,
+                                 irb->mt->msaa_layout);
+
+   intel_miptree_copy_teximage(intel, intel_image, new_mt);
+   intel_miptree_reference(&irb->mt, intel_image->mt);
+   intel_renderbuffer_set_draw_offset(irb);
+   intel_miptree_release(&new_mt);
+}
+
 /**
  * Do one-time context initializations related to GL_EXT_framebuffer_object.
  * Hook in device driver functions.
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.h b/src/mesa/drivers/dri/intel/intel_fbo.h
index 3db80de..9ae961e 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.h
+++ b/src/mesa/drivers/dri/intel/intel_fbo.h
@@ -197,6 +197,9 @@ bool
 intel_renderbuffer_resolve_depth(struct intel_context *intel,
 				 struct intel_renderbuffer *irb);
 
+void intel_renderbuffer_move_to_temp(struct intel_context *intel,
+                                     struct intel_renderbuffer *irb);
+
 unsigned
 intel_quantize_num_samples(struct intel_screen *intel, unsigned num_samples);
 
-- 
1.7.10.4



More information about the mesa-dev mailing list