Mesa (master): i965/blorp: Allow format conversions for CopyTexSubImage.

Kenneth Graunke kwg at kemper.freedesktop.org
Wed Oct 9 23:36:31 UTC 2013


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Sun Sep 29 22:22:52 2013 -0700

i965/blorp: Allow format conversions for CopyTexSubImage.

BLORP performs blits by drawing a rectangle with a shader that samples
from the source texture, and writes color data to the destination.

The sampler always returns 32-bit RGBA float data, regardless of the
source format's component ordering or data type.  Likewise, the render
target write message takes 32-bit RGBA float data, and converts it
appropriately.  So the bulk of the work is already taken care of for us.

This greatly accelerates a lot of CopyTexSubImage calls, and makes
Legends of Aethereus playable on Ivybridge.  At the default settings,
LOA continually blits between SRGBA8888 (the window format) and
RGBA16_FLOAT.  Since neither BLORP nor our BLT paths supported this,
it fell back to meta, spending 33% of the CPU in floorf() converting
between floats and half-floats.

v2: Use != instead of ^ (suggested by Ian).  Note that only
    CopyTexSubImage is affected by this patch (caught by Eric).

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Chad Versace <chad.versace at linux.intel.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>

---

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

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index 999a317..2b94e2d 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -353,10 +353,23 @@ brw_blorp_copytexsubimage(struct brw_context *brw,
    if (brw->gen < 6)
       return false;
 
-   if (!color_formats_match(src_mt->format, dst_mt->format)) {
+   if (_mesa_get_format_base_format(src_mt->format) !=
+       _mesa_get_format_base_format(dst_mt->format)) {
       return false;
    }
 
+   /* We can't handle format conversions between Z24 and other formats since
+    * we have to lie about the surface format.  See the comments in
+    * brw_blorp_surface_info::set().
+    */
+   if ((src_mt->format == MESA_FORMAT_X8_Z24) !=
+       (dst_mt->format == MESA_FORMAT_X8_Z24)) {
+      return false;
+   }
+
+   if (!brw->format_supported_as_render_target[dst_mt->format])
+      return false;
+
    /* Source clipping shouldn't be necessary, since copytexsubimage (in
     * src/mesa/main/teximage.c) calls _mesa_clip_copytexsubimage() which
     * takes care of it.




More information about the mesa-commit mailing list