Module: Mesa
Branch: 9.1
Commit: 5265c42e52b304d3d63dc2a8fbb5d835ad79a7ac
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5265c42e52b304d3d63dc2a8fbb5d835ad79a7ac

Author: Kenneth Graunke <[email protected]>
Date:   Mon Jan 28 22:26:31 2013 -0800

i965/blorp: Support blits between ARGB and XRGB formats.

Now that we have support for overriding alpha to 1.0, we can handle
blitting between these formats in either direction.

For now, we only support two XRGB formats: MESA_FORMAT_XRGB8888 and
MESA_FORMAT_RGBX8888_REV.  Most places only appear to worry about the
former, so ignore the latter for now.  We can always add it later.

Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Tested-by: Martin Steigerwald <[email protected]>
(cherry picked from commit 7d467f3c1583c94daffb58610d12eece1fddd9c2)

---

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

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp 
b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index f45bbbf..3615b09 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -184,10 +184,19 @@ formats_match(GLbitfield buffer_bit, struct 
intel_renderbuffer *src_irb,
    gl_format src_format = find_miptree(buffer_bit, src_irb)->format;
    gl_format dst_format = find_miptree(buffer_bit, dst_irb)->format;
 
-   return _mesa_get_srgb_format_linear(src_format) ==
-          _mesa_get_srgb_format_linear(dst_format);
-}
+   gl_format linear_src_format = _mesa_get_srgb_format_linear(src_format);
+   gl_format linear_dst_format = _mesa_get_srgb_format_linear(dst_format);
 
+   /* Normally, we require the formats to be equal.  However, we also support
+    * blitting from ARGB to XRGB (discarding alpha), and from XRGB to ARGB
+    * (overriding alpha to 1.0 via blending).
+    */
+   return linear_src_format == linear_dst_format ||
+          (linear_src_format == MESA_FORMAT_XRGB8888 &&
+           linear_dst_format == MESA_FORMAT_ARGB8888) ||
+          (linear_src_format == MESA_FORMAT_ARGB8888 &&
+           linear_dst_format == MESA_FORMAT_XRGB8888);
+}
 
 static bool
 try_blorp_blit(struct intel_context *intel,
@@ -1730,17 +1739,6 @@ brw_blorp_blit_params::brw_blorp_blit_params(struct 
brw_context *brw,
    src.set(brw, src_mt, src_level, src_layer);
    dst.set(brw, dst_mt, dst_level, dst_layer);
 
-   /* If we are blitting from sRGB to linear or vice versa, we still want the
-    * blit to be a direct copy, so we need source and destination to use the
-    * same format.  However, we want the destination sRGB/linear state to be
-    * correct (so that sRGB blending is used when doing an MSAA resolve to an
-    * sRGB surface, and linear blending is used when doing an MSAA resolve to
-    * a linear surface).  Since blorp blits don't support any format
-    * conversion (except between sRGB and linear), we can accomplish this by
-    * simply setting up the source to use the same format as the destination.
-    */
-   assert(_mesa_get_srgb_format_linear(src_mt->format) ==
-          _mesa_get_srgb_format_linear(dst_mt->format));
    src.brw_surfaceformat = dst.brw_surfaceformat;
 
    use_wm_prog = true;

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to