i965/meta: Stencil blit for miptree updownsampling
authorTopi Pohjolainen <topi.pohjolainen@intel.com>
Mon, 12 May 2014 09:35:40 +0000 (12:35 +0300)
committerTopi Pohjolainen <topi.pohjolainen@intel.com>
Thu, 15 May 2014 18:39:33 +0000 (21:39 +0300)
Cc: "10.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c

index d6b7f16ee40b613381271375723a08fb9dac2bdd..a9adbf2cecc72054a48b11d2ecb0f7322b7bd9e9 100644 (file)
@@ -1488,6 +1488,10 @@ void brw_meta_fbo_stencil_blit(struct brw_context *brw,
                                GLfloat srcX1, GLfloat srcY1,
                                GLfloat dstX0, GLfloat dstY0,
                                GLfloat dstX1, GLfloat dstY1);
+
+void brw_meta_stencil_updownsample(struct brw_context *brw,
+                                   struct intel_mipmap_tree *src,
+                                   struct intel_mipmap_tree *dst);
 /*======================================================================
  * brw_misc_state.c
  */
index b47f49da5ac66be4ce8bdf72c9bc531d35510cb2..e36900154e54df7cc24c19e38c9576f561dde8ed 100644 (file)
@@ -488,3 +488,37 @@ brw_meta_fbo_stencil_blit(struct brw_context *brw,
                          dst_mt, dst_irb->mt_level, dst_irb->mt_layer, &dims);
    intel_batchbuffer_emit_mi_flush(brw);
 }
+
+void
+brw_meta_stencil_updownsample(struct brw_context *brw,
+                              struct intel_mipmap_tree *src,
+                              struct intel_mipmap_tree *dst)
+{
+   struct gl_context *ctx = &brw->ctx;
+   struct blit_dims dims = {
+      .src_x0 = 0, .src_y0 = 0,
+      .src_x1 = src->logical_width0, .src_y1 = src->logical_height0,
+      .dst_x0 = 0, .dst_y0 = 0,
+      .dst_x1 = dst->logical_width0, .dst_y1 = dst->logical_height0,
+      .mirror_x = 0, .mirror_y = 0 };
+   GLuint fbo, rbo;
+
+   if (dst->stencil_mt)
+      dst = dst->stencil_mt;
+
+   intel_batchbuffer_emit_mi_flush(brw);
+   _mesa_meta_begin(ctx, MESA_META_ALL);
+
+   _mesa_GenFramebuffers(1, &fbo);
+   rbo = brw_get_rb_for_slice(brw, src, 0, 0, false);
+
+   _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
+   _mesa_FramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
+                                 GL_RENDERBUFFER, rbo);
+
+   brw_meta_stencil_blit(brw, dst, 0, 0, &dims);
+   intel_batchbuffer_emit_mi_flush(brw);
+
+   _mesa_DeleteRenderbuffers(1, &rbo);
+   _mesa_DeleteFramebuffers(1, &fbo);
+}