summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-02-28 07:48:34 -0700
committerBrian Paul <[email protected]>2012-02-29 08:40:37 -0700
commit7f9692b97dab498ad47f82394892455d43dcd08b (patch)
tree590d34fc9b85cb70c1cc53d1c90bbe2520eeca0d /src/gallium
parentce671c7aceca33a2f29dddfaa555a25218524146 (diff)
util: replace format equality test with compatibility test in blit code
This lets us use the resource_copy_region() path when blitting from R8G8B8A8 to R8G8B8x8, for example. v2: be smarter when src_format==dst_format Reviewed-by: Alex Deucher <[email protected]> Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/util/u_blit.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index a10fd17cbff..1279733881a 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -321,6 +321,26 @@ regions_overlap(int srcX0, int srcY0,
/**
+ * Can we blit from src format to dest format with a simple copy?
+ */
+static boolean
+formats_compatible(enum pipe_format src_format,
+ enum pipe_format dst_format)
+{
+ if (src_format == dst_format) {
+ return TRUE;
+ }
+ else {
+ const struct util_format_description *src_desc =
+ util_format_description(src_format);
+ const struct util_format_description *dst_desc =
+ util_format_description(dst_format);
+ return util_is_format_compatible(src_desc, dst_desc);
+ }
+}
+
+
+/**
* Copy pixel block from src surface to dst surface.
* Overlapping regions are acceptable.
* Flipping and stretching are supported.
@@ -377,7 +397,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
* no overlapping.
* Filter mode should not matter since there's no stretching.
*/
- if (dst_format == src_format &&
+ if (formats_compatible(src_format, dst_format) &&
srcX0 < srcX1 &&
dstX0 < dstX1 &&
srcY0 < srcY1 &&