[Mesa-dev] [PATCH 08/12] intel: Track miptrees for fake packed depth/stencil renderbuffers.
Eric Anholt
eric at anholt.net
Mon Dec 5 11:42:32 PST 2011
Right now the fake packed d/s RBs are creating two sub-renderbuffers
with their own storage, and the hardware setup and the mapping code
have been explicitly referencing them. By setting miptrees on them,
we'll be able to make our renderbuffer code for fake packed
depth/stencil more consistent with all our other renderbuffers.
The interesting new behavior here is that there is now a mt with a
non-depthstencil format (X8Z24) that has a stencil_mt field
associated. This looks like it should be safe, and we'll need to be
able to do this for floating point depth/stencil as well.
---
src/mesa/drivers/dri/intel/intel_fbo.c | 10 ++++++++++
src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 5 +++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index de4abab..8b72eb7 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -591,6 +591,7 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
bool ok = true;
struct gl_renderbuffer *depth_rb;
struct gl_renderbuffer *stencil_rb;
+ struct intel_renderbuffer *depth_irb, *stencil_irb;
depth_rb = intel_create_wrapped_renderbuffer(ctx, width, height,
MESA_FORMAT_X8_Z24);
@@ -614,6 +615,12 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
return false;
}
+ depth_irb = intel_renderbuffer(depth_rb);
+ stencil_irb = intel_renderbuffer(stencil_rb);
+
+ intel_miptree_reference(&depth_irb->mt->stencil_mt, stencil_irb->mt);
+ intel_miptree_reference(&irb->mt, depth_irb->mt);
+
depth_rb->Wrapped = rb;
stencil_rb->Wrapped = rb;
_mesa_reference_renderbuffer(&irb->wrapped_depth, depth_rb);
@@ -953,6 +960,9 @@ intel_renderbuffer_update_wrapper(struct intel_context *intel,
if (!ok)
return false;
}
+
+ intel_miptree_reference(&depth_irb->mt->stencil_mt, stencil_irb->mt);
+ intel_miptree_reference(&irb->mt, depth_irb->mt);
} else {
intel_miptree_reference(&irb->mt, mt);
intel_renderbuffer_set_draw_offset(irb);
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 2be02d0..c1805fc 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -808,8 +808,9 @@ intel_miptree_map_depthstencil(struct intel_context *intel,
ptrdiff_t s_offset = intel_offset_S8(s_mt->region->pitch,
x + s_image_x + map->x,
y + s_image_y + map->y);
- ptrdiff_t z_offset = ((y + z_image_y) * z_mt->region->pitch +
- (x + z_image_x));
+ ptrdiff_t z_offset = (((y + map->y + z_image_y) *
+ z_mt->region->pitch) +
+ (x + map->x + z_image_x));
uint8_t s = s_map[s_offset];
uint32_t z = z_map[z_offset];
--
1.7.7.3
More information about the mesa-dev
mailing list