i965: Add layer_count to intel_renderbuffer
authorChris Forbes <chrisf@ijw.co.nz>
Tue, 21 Jan 2014 08:45:28 +0000 (21:45 +1300)
committerChris Forbes <chrisf@ijw.co.nz>
Thu, 10 Apr 2014 06:27:41 +0000 (18:27 +1200)
This is the effective layer count, for clears etc. This differs from the
depth of the miptree level when views are involved.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/intel_fbo.c
src/mesa/drivers/dri/i965/intel_fbo.h

index 5ade9e6168a80ff3f5ff7a4d0fd1761262705b5d..c70b1bf36b2806854673c57b874598a86a9012c7 100644 (file)
@@ -319,6 +319,8 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
    if (!irb->mt)
       return false;
 
+   irb->layer_count = 1;
+
    return true;
 }
 
@@ -383,6 +385,7 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
    rb->Format = image->format;
    rb->_BaseFormat = _mesa_base_fbo_format(ctx, image->internal_format);
    rb->NeedsFinishRenderTexture = true;
+   irb->layer_count = 1;
 }
 
 /**
@@ -435,6 +438,7 @@ intel_create_renderbuffer(mesa_format format, unsigned num_samples)
    }
 
    rb = &irb->Base.Base;
+   irb->layer_count = 1;
 
    _mesa_init_renderbuffer(rb, 0);
    rb->ClassID = INTEL_RB_CLASS;
@@ -532,6 +536,12 @@ intel_renderbuffer_update_wrapper(struct brw_context *brw,
 
    irb->mt_layer = layer_multiplier * layer;
 
+   if (layered) {
+      irb->layer_count = image->TexObject->NumLayers ?: mt->level[level].depth / layer_multiplier;
+   } else {
+      irb->layer_count = 1;
+   }
+
    intel_miptree_reference(&irb->mt, mt);
 
    intel_renderbuffer_set_draw_offset(irb);
index fa457e29d09524d615216b4b7fe959ce0d9b2fec..c7cc57073c1b9320905bf5a1d21a940e4264b175 100644 (file)
@@ -90,6 +90,9 @@ struct intel_renderbuffer
     */
    unsigned int mt_level;
    unsigned int mt_layer;
+
+   /* The number of attached logical layers. */
+   unsigned int layer_count;
    /** \} */
 
    GLuint draw_x, draw_y; /**< Offset of drawing within the region */