Mesa (master): intel: Add fields to intel_texture for faking s8z24 with separate stencil

Chad Versace chadversary at kemper.freedesktop.org
Fri Jun 24 21:48:49 UTC 2011


Module: Mesa
Branch: master
Commit: 1a062dfc6f6e872e18f048bb5a61709c36f22870
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1a062dfc6f6e872e18f048bb5a61709c36f22870

Author: Chad Versace <chad at chad-versace.us>
Date:   Tue Jun 21 13:44:57 2011 -0700

intel: Add fields to intel_texture for faking s8z24 with separate stencil

Add the fields depth_rb and stencil_rb, and put hooks in place to
release the renderbuffers in intelFreeTextureImageData and
intelTexImage.

Signed-off-by: Chad Versace <chad at chad-versace.us>

---

 src/mesa/drivers/dri/intel/intel_tex.c       |    9 +++++++
 src/mesa/drivers/dri/intel/intel_tex_image.c |   13 +----------
 src/mesa/drivers/dri/intel/intel_tex_obj.h   |   30 ++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c
index 32e1fb7..21c4a1d 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.c
+++ b/src/mesa/drivers/dri/intel/intel_tex.c
@@ -1,4 +1,5 @@
 #include "swrast/swrast.h"
+#include "main/renderbuffer.h"
 #include "main/texobj.h"
 #include "main/teximage.h"
 #include "main/mipmap.h"
@@ -59,6 +60,14 @@ intelFreeTextureImageData(struct gl_context * ctx, struct gl_texture_image *texI
       _mesa_free_texmemory(texImage->Data);
       texImage->Data = NULL;
    }
+
+   if (intelImage->depth_rb) {
+      _mesa_reference_renderbuffer(&intelImage->depth_rb, NULL);
+   }
+
+   if (intelImage->stencil_rb) {
+      _mesa_reference_renderbuffer(&intelImage->stencil_rb, NULL);
+   }
 }
 
 /**
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 90d4117..472a8e1 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -314,18 +314,7 @@ intelTexImage(struct gl_context * ctx,
       }
    }
 
-   /* Release the reference to a potentially orphaned buffer.   
-    * Release any old malloced memory.
-    */
-   if (intelImage->mt) {
-      intel_miptree_release(intel, &intelImage->mt);
-      assert(!texImage->Data);
-   }
-   else if (texImage->Data) {
-      _mesa_free_texmemory(texImage->Data);
-      texImage->Data = NULL;
-   }
-
+   ctx->Driver.FreeTexImageData(ctx, texImage);
    assert(!intelImage->mt);
 
    if (intelObj->mt &&
diff --git a/src/mesa/drivers/dri/intel/intel_tex_obj.h b/src/mesa/drivers/dri/intel/intel_tex_obj.h
index e93ef4a..a9ae2ec 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_obj.h
+++ b/src/mesa/drivers/dri/intel/intel_tex_obj.h
@@ -63,6 +63,36 @@ struct intel_texture_image
     */
    struct intel_mipmap_tree *mt;
    GLboolean used_as_render_target;
+
+   /**
+    * \name Renderbuffers for faking packed depth/stencil
+    *
+    * These renderbuffers are non-null only if the intel_context is using
+    * separate stencil and this texture has a packed depth/stencil format. When
+    * glFramebufferTexture is called on this image, the resultant renderbuffer
+    * wrapper reuses these renderbuffers as its own.
+    *
+    * \see intel_wrap_texture
+    * \see intel_tex_image_s8z24_create_renderbuffers
+    * \see intel_tex_image_s8z24_scatter
+    * \see intel_tex_image_s8z24_gather
+    *
+    * \{
+    */
+
+   /**
+    * The depth buffer has format X8_Z24. The x8 bits are undefined unless
+    * intel_tex_image_s8z24_gather has been immediately called. The depth buffer
+    * resuses the image miptree's region and hiz_region as its own.
+    */
+   struct gl_renderbuffer *depth_rb;
+
+   /**
+    * The stencil buffer has format S8 and keeps its data in its own region.
+    */
+   struct gl_renderbuffer *stencil_rb;
+
+   /** \} */
 };
 
 static INLINE struct intel_texture_object *




More information about the mesa-commit mailing list