[Mesa-dev] [PATCH 05/14] i965/blorp: Add plumbing for glsl-based color blits

Topi Pohjolainen topi.pohjolainen at intel.com
Thu Apr 23 11:18:19 PDT 2015


Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_blorp.h        | 27 +++++++++
 src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 90 ++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp.h b/src/mesa/drivers/dri/i965/brw_blorp.h
index 9fd4193..253d6e6 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.h
+++ b/src/mesa/drivers/dri/i965/brw_blorp.h
@@ -430,6 +430,33 @@ private:
                                     uint32_t wm_prog_offset);
 };
 
+class brw_meta_blit_params : public brw_meta_fs_params
+{
+public:
+   brw_meta_blit_params(struct brw_context *brw,
+                        const struct gl_fragment_program *fp,
+                        uint32_t wm_prog_offset,
+                        const struct brw_wm_prog_data *wm_prog_data,
+                        const struct gl_framebuffer *read_fb,
+                        const struct gl_framebuffer *draw_fb,
+                        struct intel_mipmap_tree *src_mt,
+                        unsigned src_level, unsigned src_layer,
+                        mesa_format src_format,
+                        float src_x0, float src_y0,
+                        float src_x1, float src_y1,
+                        float dst_x0, float dst_y0,
+                        float dst_x1, float dst_y1,
+                        GLenum filter, GLenum target,
+                        bool mirror_x, bool mirror_y);
+
+private:
+   const float src_x0, src_y0, src_x1, src_y1;
+   const struct gl_framebuffer * const read_fb;
+   const struct gl_framebuffer * const draw_fb;
+   const GLenum filter;
+   const GLenum target;
+};
+
 /**
  * \name BLORP internals
  * \{
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index 947f3b0..17b884f 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -345,6 +345,63 @@ brw_blorp_framebuffer(struct brw_context *brw,
    return mask;
 }
 
+bool
+brw_meta_fbo_color_blit(struct brw_context *brw,
+                        struct gl_framebuffer *read_fb,
+                        struct gl_framebuffer *draw_fb,
+                        float src_x0, float src_y0,
+                        float src_x1, float src_y1,
+                        float dst_x0, float dst_y0,
+                        float dst_x1, float dst_y1,
+                        GLenum filter)
+{
+   /* Sync up the state of window system buffers.  We need to do this before
+    * we go looking for the buffers.
+    */
+   intel_prepare_render(brw);
+
+   bool mirror_x, mirror_y;
+   if (brw_meta_mirror_clip_and_scissor(&brw->ctx, read_fb, draw_fb,
+                                        &src_x0, &src_y0, &src_x1, &src_y1,
+                                        &dst_x0, &dst_y0, &dst_x1, &dst_y1,
+                                        &mirror_x, &mirror_y))
+      return true;
+
+   GLenum target;
+   const struct gl_fragment_program *fp;
+   uint32_t wm_prog_offset;
+   const struct brw_wm_prog_data *wm_prog_data;
+
+   if (!brw_meta_choose_blit_shader(brw, GL_COLOR_BUFFER_BIT, filter, &target,
+                                    &fp, &wm_prog_offset, &wm_prog_data))
+      return false;
+
+   struct intel_renderbuffer *src_irb =
+      intel_renderbuffer(read_fb->_ColorReadBuffer);
+   struct intel_mipmap_tree *src_mt =
+      find_miptree(GL_COLOR_BUFFER_BIT, src_irb);
+
+   intel_miptree_resolve_color(brw, src_mt);
+   brw_meta_blit_params params(brw, fp, wm_prog_offset, wm_prog_data,
+                               read_fb, draw_fb, src_mt,
+                               src_irb->mt_level, src_irb->mt_layer,
+                               src_irb->Base.Base.Format,
+                               src_x0, src_y0,
+                               src_x1, src_y1,
+                               dst_x0, dst_y0,
+                               dst_x1, dst_y1,
+                               filter, target, mirror_x, mirror_y);
+
+   /* Manually store and disable current srgb setting. */
+   bool srgb_save = brw->ctx.Color.sRGBEnabled;
+   brw->ctx.Color.sRGBEnabled = false;
+
+   brw_blorp_exec(brw, &params);
+
+   brw->ctx.Color.sRGBEnabled = srgb_save;
+
+   return true;
+}
 
 /**
  * Enum to specify the order of arguments in a sampler message
@@ -2136,3 +2193,36 @@ brw_blorp_blit_params::set_wm_prog(struct brw_context *brw)
                        &prog_offset, &prog_data);
    }
 }
+
+brw_meta_blit_params::brw_meta_blit_params(
+                         struct brw_context *brw,
+                         const struct gl_fragment_program *fp,
+                         uint32_t wm_prog_offset,
+                         const struct brw_wm_prog_data *wm_prog_data,
+                         const struct gl_framebuffer *read_fb,
+                         const struct gl_framebuffer *draw_fb,
+                         struct intel_mipmap_tree *src_mt,
+                         unsigned src_level,
+                         unsigned src_layer,
+                         mesa_format src_format,
+                         float src_x0, float src_y0,
+                         float src_x1, float src_y1,
+                         float dst_x0, float dst_y0,
+                         float dst_x1, float dst_y1,
+                         GLenum filter, GLenum target,
+                         bool mirror_x, bool mirror_y) :
+   brw_meta_fs_params(draw_fb->Visual.samples, draw_fb->_NumColorDrawBuffers,
+                      1 /* single layer */,
+                      fp, wm_prog_offset, wm_prog_data,
+                      0 /* no-op clear */),
+   src_x0(src_x0), src_y0(src_y0), src_x1(src_x1), src_y1(src_y1),
+   read_fb(read_fb), draw_fb(draw_fb), filter(filter), target(target)
+{
+   use_wm_prog = true;
+   x0 = mirror_x ? dst_x1 : dst_x0;
+   y0 = mirror_y ? dst_y1 : dst_y0;
+   x1 = mirror_x ? dst_x0 : dst_x1;
+   y1 = mirror_y ? dst_y0 : dst_y1;
+
+   src.set(brw, src_mt, src_level, src_layer, src_format, false);
+}
-- 
1.9.3



More information about the mesa-dev mailing list