aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/auxiliary
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/gallium/auxiliary')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blit.c22
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.c22
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.h5
3 files changed, 35 insertions, 14 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_blit.c b/mesalib/src/gallium/auxiliary/util/u_blit.c
index a10fd17cb..127973388 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blit.c
+++ b/mesalib/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 &&
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c
index 48808ae08..5784a7ceb 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c
@@ -351,12 +351,12 @@ static void blitter_unset_running_flag(struct blitter_context_priv *ctx)
static void blitter_check_saved_vertex_states(struct blitter_context_priv *ctx)
{
- assert(ctx->base.saved_num_vertex_buffers != ~0 &&
- ctx->base.saved_velem_state != INVALID_PTR &&
- ctx->base.saved_vs != INVALID_PTR &&
- (!ctx->has_geometry_shader || ctx->base.saved_gs != INVALID_PTR) &&
- (!ctx->has_stream_out || ctx->base.saved_num_so_targets != ~0) &&
- ctx->base.saved_rs_state != INVALID_PTR);
+ assert(ctx->base.saved_num_vertex_buffers != ~0);
+ assert(ctx->base.saved_velem_state != INVALID_PTR);
+ assert(ctx->base.saved_vs != INVALID_PTR);
+ assert(!ctx->has_geometry_shader || ctx->base.saved_gs != INVALID_PTR);
+ assert(!ctx->has_stream_out || ctx->base.saved_num_so_targets != ~0);
+ assert(ctx->base.saved_rs_state != INVALID_PTR);
}
static void blitter_restore_vertex_states(struct blitter_context_priv *ctx)
@@ -410,9 +410,9 @@ static void blitter_restore_vertex_states(struct blitter_context_priv *ctx)
static void blitter_check_saved_fragment_states(struct blitter_context_priv *ctx)
{
- assert(ctx->base.saved_fs != INVALID_PTR &&
- ctx->base.saved_dsa_state != INVALID_PTR &&
- ctx->base.saved_blend_state != INVALID_PTR);
+ assert(ctx->base.saved_fs != INVALID_PTR);
+ assert(ctx->base.saved_dsa_state != INVALID_PTR);
+ assert(ctx->base.saved_blend_state != INVALID_PTR);
}
static void blitter_restore_fragment_states(struct blitter_context_priv *ctx)
@@ -453,8 +453,8 @@ static void blitter_restore_fb_state(struct blitter_context_priv *ctx)
static void blitter_check_saved_textures(struct blitter_context_priv *ctx)
{
- assert(ctx->base.saved_num_sampler_states != ~0 &&
- ctx->base.saved_num_sampler_views != ~0);
+ assert(ctx->base.saved_num_sampler_states != ~0);
+ assert(ctx->base.saved_num_sampler_views != ~0);
}
static void blitter_restore_textures(struct blitter_context_priv *ctx)
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h
index 874ea7eb1..b9ae7c190 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.h
+++ b/mesalib/src/gallium/auxiliary/util/u_format.h
@@ -578,8 +578,9 @@ boolean
util_format_is_pure_uint(enum pipe_format format);
/**
- * Whether the src format can be blitted to destation format with a simple
- * memcpy.
+ * Check if the src format can be blitted to the destination format with
+ * a simple memcpy. For example, blitting from RGBA to RGBx is OK, but not
+ * the reverse.
*/
boolean
util_is_format_compatible(const struct util_format_description *src_desc,