[Mesa-dev] [PATCH 01/22] i965/meta: Add means for signaling meta blit surface overrides

Topi Pohjolainen topi.pohjolainen at intel.com
Mon Jun 9 00:45:35 PDT 2014


On hardware older than gen8 there will be limited stencil texturing
support, enough to support meta blits but not to turn on the
extension itself. Hence surface setup needs to be told through the
context to use stencil indexing.

Additionally there is now signaling for source layer. Stencil blits
using blorp honor the renderbuffer settings. These are no piglit tests
relying on this.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_context.c           | 10 ++++++++++
 src/mesa/drivers/dri/i965/brw_context.h           | 15 +++++++++++++++
 src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c | 11 +++++++++--
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 39dd582..c1116ad 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -784,10 +784,20 @@ brwCreateContext(gl_api api,
    vbo_use_buffer_objects(ctx);
    vbo_always_unmap_buffers(ctx);
 
+   brw_meta_blit_reset(brw);
+
    return true;
 }
 
 void
+brw_meta_blit_reset(struct brw_context *brw)
+{
+   brw->meta_blit.is_active = false;
+   brw->meta_blit.use_stencil_index_mode = false;
+   brw->meta_blit.src_layer = 0;
+}
+
+void
 intelDestroyContext(__DRIcontext * driContextPriv)
 {
    struct brw_context *brw =
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 283c576..b2e5416 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -955,6 +955,17 @@ struct brw_stage_state
    uint32_t sdc_offset[BRW_MAX_TEX_UNIT];
 };
 
+struct brw_meta_blit
+{
+   /* Tells if a meta blit is currently active and surface setup should
+    * use the overrides set here.
+    */
+   bool is_active;
+
+   /* Parameters for texture surface configuration. */
+   bool use_stencil_index_mode; /* Used for gen6 and gen7 */
+   unsigned src_layer; /* Used for >= gen6 */
+};
 
 /**
  * brw_context is derived from gl_context.
@@ -1431,6 +1442,8 @@ struct brw_context
 
    __DRIcontext *driContext;
    struct intel_screen *intelScreen;
+
+   struct brw_meta_blit meta_blit;
 };
 
 /*======================================================================
@@ -1492,6 +1505,8 @@ void brw_meta_fbo_stencil_blit(struct brw_context *brw,
 void brw_meta_stencil_updownsample(struct brw_context *brw,
                                    struct intel_mipmap_tree *src,
                                    struct intel_mipmap_tree *dst);
+
+void brw_meta_blit_reset(struct brw_context *brw);
 /*======================================================================
  * brw_misc_state.c
  */
diff --git a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
index 5d132b7..cc7fdbe 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
@@ -370,12 +370,14 @@ prepare_vertex_data(void)
 }
 
 static void
-set_read_rb_tex_image(struct gl_context *ctx, struct fb_tex_blit_state *blit,
+set_read_rb_tex_image(struct brw_context *brw, struct fb_tex_blit_state *blit,
                       GLenum *target)
 {
+   struct gl_context *ctx = &brw->ctx;
    const struct gl_renderbuffer_attachment *att =
       &ctx->ReadBuffer->Attachment[BUFFER_STENCIL];
    struct gl_renderbuffer *rb = att->Renderbuffer;
+   const struct intel_renderbuffer *irb = intel_renderbuffer(rb);
    struct gl_texture_object *tex_obj;
    unsigned level = 0;
 
@@ -394,6 +396,10 @@ set_read_rb_tex_image(struct gl_context *ctx, struct fb_tex_blit_state *blit,
    blit->stencilSamplingSave = tex_obj->StencilSampling;
    blit->sampler = _mesa_meta_setup_sampler(ctx, tex_obj, *target,
                                             GL_NEAREST, level);
+
+   brw->meta_blit.is_active = true;
+   brw->meta_blit.use_stencil_index_mode = true;
+   brw->meta_blit.src_layer = irb->mt_layer;
 }
 
 static void
@@ -422,7 +428,7 @@ brw_meta_stencil_blit(struct brw_context *brw,
    _mesa_DrawBuffer(GL_COLOR_ATTACHMENT0);
    ctx->DrawBuffer->_Status = GL_FRAMEBUFFER_COMPLETE;
 
-   set_read_rb_tex_image(ctx, &blit, &target);
+   set_read_rb_tex_image(brw, &blit, &target);
 
    _mesa_TexParameteri(target, GL_DEPTH_STENCIL_TEXTURE_MODE,
                        GL_STENCIL_INDEX);
@@ -445,6 +451,7 @@ brw_meta_stencil_blit(struct brw_context *brw,
 
    _mesa_meta_fb_tex_blit_end(ctx, target, &blit);
    _mesa_meta_end(ctx);
+   brw_meta_blit_reset(brw);
 
    _mesa_DeleteRenderbuffers(1, &rbo);
    _mesa_DeleteFramebuffers(1, &fbo);
-- 
1.8.3.1



More information about the mesa-dev mailing list