+/**
+ * Are the given pipe formats compatible, in terms of vgpu10's
+ * PredCopyRegion() command?
+ */
+static bool
+formats_compatible(const struct svga_screen *ss,
+ enum pipe_format src_fmt,
+ enum pipe_format dst_fmt)
+{
+ SVGA3dSurfaceFormat src_svga_fmt, dst_svga_fmt;
+
+ src_svga_fmt = svga_translate_format(ss, src_fmt, PIPE_BIND_SAMPLER_VIEW);
+ dst_svga_fmt = svga_translate_format(ss, dst_fmt, PIPE_BIND_SAMPLER_VIEW);
+
+ src_svga_fmt = svga_typeless_format(src_svga_fmt);
+ dst_svga_fmt = svga_typeless_format(dst_svga_fmt);
+
+ return src_svga_fmt == dst_svga_fmt;
+}
+
+
+/**
+ * The state tracker implements some resource copies with blits (for
+ * GL_ARB_copy_image). This function checks if we should really do the blit
+ * with a VGPU10 CopyRegion command or software fallback (for incompatible
+ * src/dst formats).
+ */
+static bool
+can_blit_via_copy_region_vgpu10(struct svga_context *svga,
+ const struct pipe_blit_info *blit_info)
+{
+ struct svga_texture *dtex, *stex;
+
+ if (!svga_have_vgpu10(svga))
+ return false;
+
+ stex = svga_texture(blit_info->src.resource);
+ dtex = svga_texture(blit_info->dst.resource);
+
+ // can't copy within one resource
+ if (stex->handle == dtex->handle)
+ return false;
+
+ /* can't copy between different resource types */
+ if (svga_resource_type(blit_info->src.resource->target) !=
+ svga_resource_type(blit_info->dst.resource->target))
+ return false;
+
+ /* check that the blit src/dst regions are same size, no flipping, etc. */
+ if (blit_info->src.box.width != blit_info->dst.box.width ||
+ blit_info->src.box.height != blit_info->dst.box.height)
+ return false;
+
+ /* For depth+stencil formats, copy with maks != PIPE_MASK_ZS is not
+ * supported */
+ if (util_format_is_depth_and_stencil(blit_info->src.format) &&
+ blit_info->mask != (PIPE_MASK_ZS))
+ return false;
+
+ if (blit_info->alpha_blend ||
+ (svga->render_condition && blit_info->render_condition_enable) ||
+ blit_info->scissor_enable)
+ return false;
+
+ return formats_compatible(svga_screen(svga->pipe.screen),
+ blit_info->src.resource->format,
+ blit_info->dst.resource->format);
+}
+
+