[Mesa-dev] [PATCH 03/16] intel: Add singlesample fields to intel_mipmap_tree

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


Add the following fields:
    singlesamle_width0
    singlesample_height0
    singlesample_mt
    needs_downsample

These will all be used by later commits that implement MSAA for window
system buffers.

CC: Paul Berry <stereotype441 at gmail.com>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c |  8 ++++
 src/mesa/drivers/dri/intel/intel_mipmap_tree.h | 56 ++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 9f349d0..1f21d9c 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -334,6 +334,8 @@ intel_miptree_create_for_renderbuffer(struct intel_context *intel,
    struct intel_mipmap_tree *mt;
    uint32_t depth = 1;
    enum intel_msaa_layout msaa_layout = INTEL_MSAA_LAYOUT_NONE;
+   const uint32_t singlesample_width = width;
+   const uint32_t singlesample_height = height;
 
    if (num_samples > 1) {
       /* Adjust width/height/depth for MSAA */
@@ -397,6 +399,11 @@ intel_miptree_create_for_renderbuffer(struct intel_context *intel,
    mt = intel_miptree_create(intel, GL_TEXTURE_2D, format, 0, 0,
 			     width, height, depth, true, num_samples,
                              msaa_layout);
+   if (!mt)
+      return NULL;
+
+   mt->singlesample_width0 = singlesample_width;
+   mt->singlesample_height0 = singlesample_height;
 
    return mt;
 }
@@ -435,6 +442,7 @@ intel_miptree_release(struct intel_mipmap_tree **mt)
       intel_miptree_release(&(*mt)->stencil_mt);
       intel_miptree_release(&(*mt)->hiz_mt);
       intel_miptree_release(&(*mt)->mcs_mt);
+      intel_miptree_release(&(*mt)->singlesample_mt);
       intel_resolve_map_clear(&(*mt)->hiz_map);
 
       for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index bfeb69c..187e645 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -212,6 +212,18 @@ struct intel_mipmap_tree
    bool compressed;
 
    /**
+    * If num_samples > 0, then singlesample_width0 is the value that width0
+    * would have if instead a singlesample miptree were created. Note that,
+    * for non-interleaved msaa layouts, the two values are the same.
+    *
+    * If num_samples == 0, then singlesample_width0 is undefined.
+    */
+   uint32_t singlesample_width0;
+
+   /** \see singlesample_width0 */
+   uint32_t singlesample_height0;
+
+   /**
     * For 1D array, 2D array, cube, and 2D multisampled surfaces on Gen7: true
     * if the surface only contains LOD 0, and hence no space is for LOD's
     * other than 0 in between array slices.
@@ -248,6 +260,50 @@ struct intel_mipmap_tree
    uint32_t offset;
 
    /**
+    * \brief Singlesample miptree.
+    *
+    * This is used under two cases.
+    *
+    * --- Case 1: As persistent singlesample storage for multisample window
+    *  system front and back buffers ---
+    *
+    * Suppose that the window system FBO was created with a multisample
+    * config.  Let `back_irb` be the `intel_renderbuffer` for the FBO's back
+    * buffer. Then `back_irb` contains two miptrees: a parent multisample
+    * miptree (back_irb->mt) and a child singlesample miptree
+    * (back_irb->mt->singlesample_mt).  The DRM buffer shared with DRI2
+    * belongs to `back_irb->mt->singlesample_mt` and contains singlesample
+    * data.  The singlesample miptree is created at the same time as and
+    * persists for the lifetime of its parent multisample miptree.
+    *
+    * When access to the singlesample data is needed, such as at
+    * eglSwapBuffers and glReadPixels, an automatic downsample occurs from
+    * `back_rb->mt` to `back_rb->mt->singlesample_mt` when necessary.
+    *
+    * This description of the back buffer applies analogously to the front
+    * buffer.
+    *
+    *
+    * --- Case 2: As temporary singlesample storage for mapping multisample
+    *  miptrees ---
+    *
+    * Suppose the intel_miptree_map is called on a multisample miptree, `mt`,
+    * for which case 1 does not apply (that is, `mt` does not belong to
+    * a front or back buffer).  Then `mt->singlesample_mt` is null at the
+    * start of the call. intel_miptree_map will create a temporary
+    * singlesample miptree, store it at `mt->singlesample_mt`, downsample from
+    * `mt` to `mt->singlesample_mt` if necessary, then map
+    * `mt->singlesample_mt`. The temporary miptree is later deleted during
+    * intel_miptree_unmap.
+    */
+   struct intel_mipmap_tree *singlesample_mt;
+
+   /**
+    * \brief A downsample is needed from this miptree to singlesample_mt.
+    */
+   bool need_downsample;
+
+   /**
     * \brief HiZ miptree
     *
     * This is non-null only if HiZ is enabled for this miptree.
-- 
1.7.11.4



More information about the mesa-dev mailing list