Mesa (master): i965/blorp: Implement source clipping.

Paul Berry stereotype441 at kemper.freedesktop.org
Fri Jun 15 16:12:39 UTC 2012


Module: Mesa
Branch: master
Commit: 75f409d75cacf90df2d6f1d718251a5d5cd92f7f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=75f409d75cacf90df2d6f1d718251a5d5cd92f7f

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Tue Jun 12 10:44:10 2012 -0700

i965/blorp: Implement source clipping.

This patch modifies blorp blits (which are used for MSAA) to properly
account for clipping of source coordinates.  Previously, if we
detected the possibility of source clipping, we would fall back to the
blit meta-op, which doesn't support MSAA and is very slow for depth
and stencil buffers.

Fixes piglit tests
"EXT_framebuffer_multisample/clip-and-scissor-blit" on i965/Gen6+.

Also substantially speeds up the Humble Bundle V game "Psychonauts" on
Gen6+ (without this patch, the game's depth buffer blits use the slow
blit meta-op).

Reviewed-by: Carl Worth <cworth at cworth.org>

---

 src/mesa/drivers/dri/i965/brw_blorp_blit.cpp |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index 4de2d7a..0bed768 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -60,6 +60,9 @@ fixup_mirroring(bool &mirror, GLint &coord0, GLint &coord1)
  * For clarity, the nomenclature of this function assumes we are clipping and
  * scissoring the X coordinate; the exact same logic applies for Y
  * coordinates.
+ *
+ * Note: this function may also be used to account for clipping of source
+ * coordinates, by swapping the roles of src and dst.
  */
 static inline bool
 clip_or_scissor(bool mirror, GLint &src_x0, GLint &src_x1, GLint &dst_x0,
@@ -203,9 +206,14 @@ try_blorp_blit(struct intel_context *intel,
       return true;
    }
 
-   /* TODO: Clipping the source rectangle is not yet implemented. */
-   if (srcX0 < 0 || (GLuint) srcX1 > read_fb->Width) return false;
-   if (srcY0 < 0 || (GLuint) srcY1 > read_fb->Height) return false;
+   /* If the source rectangle needs to be clipped or scissored, do so. */
+   if (!(clip_or_scissor(mirror_x, dstX0, dstX1, srcX0, srcX1,
+                         0, read_fb->Width) &&
+         clip_or_scissor(mirror_y, dstY0, dstY1, srcY0, srcY1,
+                         0, read_fb->Height))) {
+      /* Everything got clipped/scissored away, so the blit was successful. */
+      return true;
+   }
 
    /* Get ready to blit.  This includes depth resolving the src and dst
     * buffers if necessary.




More information about the mesa-commit mailing list