[Mesa-dev] [PATCH 08/14] intel: Add hiz_region to intel_mipmap_tree
chad at chad-versace.us
chad at chad-versace.us
Wed May 4 13:33:52 PDT 2011
From: Chad Versace <chad.versace at intel.com>
When a depth texture is attached to an FBO, that texture's hiz surface
must be stored in the texture and not in the wrapping renderbuffer. If it
were stored in the renderbuffer, then inconsistent rendering would occur
when the depth texture was simultaneously attached to multiple FBO's.
Signed-off-by: Chad Versace <chad.versace at intel.com>
---
src/mesa/drivers/dri/intel/intel_fbo.c | 22 ++++++++++++++++++++++
src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 1 +
src/mesa/drivers/dri/intel/intel_mipmap_tree.h | 13 +++++++++++++
3 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index d20009e..42dcf7a 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -397,6 +397,7 @@ static GLboolean
intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb,
struct gl_texture_image *texImage)
{
+ struct intel_context *intel = intel_context(ctx);
struct intel_texture_image *intel_image = intel_texture_image(texImage);
if (!intel_span_supports_format(texImage->TexFormat)) {
@@ -423,6 +424,27 @@ intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb,
intel_region_reference(&irb->region, intel_image->mt->region);
}
+ /* Allocate the texture's hiz region if necessary. */
+ if (intel->vtbl.is_hiz_depth_format(intel, texImage->TexFormat)
+ && !intel_image->mt->hiz_region) {
+ intel_image->mt->hiz_region =
+ intel_region_alloc(intel->intelScreen,
+ I915_TILING_Y,
+ _mesa_get_format_bytes(texImage->TexFormat),
+ texImage->Width,
+ texImage->Height,
+ GL_TRUE);
+ if (!intel_image->mt->hiz_region)
+ return GL_FALSE;
+ assert(intel_image->mt->hiz_region->buffer);
+ }
+
+ /* Point the renderbuffer's hiz region to the texture's hiz region. */
+ if (irb->hiz_region != intel_image->mt->hiz_region) {
+ intel_region_release(&irb->hiz_region);
+ intel_region_reference(&irb->hiz_region, intel_image->mt->hiz_region);
+ }
+
return GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index a340927..e62905d 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -200,6 +200,7 @@ intel_miptree_release(struct intel_context *intel,
DBG("%s deleting %p\n", __FUNCTION__, *mt);
intel_region_release(&((*mt)->region));
+ intel_region_release(&((*mt)->hiz_region));
for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
free((*mt)->level[i].x_offset);
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index 760a8bc..5458adc 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -113,6 +113,19 @@ struct intel_mipmap_tree
*/
struct intel_region *region;
+ /**
+ * This points to an auxillary hiz region if
+ * 1. The texture has been attached to an FBO as a depthbuffer.
+ * 2. The texture format is hiz compatible.
+ * 3. The intel context supports hiz, of course.
+ *
+ * The hiz region is stored here instead of the wrapping intel_renderbuffer
+ * because a single texture may be attached to multiple FBO's.
+ *
+ * \see intel_fbo.c:intel_wrap_texture()
+ */
+ struct intel_region *hiz_region;
+
/* These are also refcounted:
*/
GLuint refcount;
--
1.7.5
More information about the mesa-dev
mailing list