+ /* Sanity checks. */
+ if (dst == src) {
+ assert(!is_overlap(srcbox->x, srcbox->x + width, srcbox->y, srcbox->y + height,
+ dstx, dstx + width, dsty, dsty + height));
+ }
+ assert(src->target < PIPE_MAX_TEXTURE_TYPES);
+ /* XXX should handle 3d regions */
+ assert(srcbox->depth == 1);
+
+ /* Is this a ZS format? */
+ is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
+ is_stencil = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 1) != 0;
+
+ if (is_depth || is_stencil)
+ bind = PIPE_BIND_DEPTH_STENCIL;
+ else
+ bind = PIPE_BIND_RENDER_TARGET;
+
+ /* Check if we can sample from and render to the surfaces. */
+ /* (assuming copying a stencil buffer is not possible) */
+ if ((!ignore_stencil && is_stencil) ||
+ !screen->is_format_supported(screen, dst->format, dst->target,
+ dst->nr_samples, bind, 0) ||
+ !screen->is_format_supported(screen, src->format, src->target,
+ src->nr_samples, PIPE_BIND_SAMPLER_VIEW, 0)) {
+ util_resource_copy_region(pipe, dst, dstlevel, dstx, dsty, dstz,
+ src, srclevel, srcbox);
+ return;
+ }
+
+ /* Get surface. */
+ memset(&surf_templ, 0, sizeof(surf_templ));
+ u_surface_default_template(&surf_templ, dst, bind);
+ surf_templ.u.tex.level = dstlevel;
+ surf_templ.u.tex.first_layer = dstz;
+ surf_templ.u.tex.last_layer = dstz;
+ dstsurf = pipe->create_surface(pipe, dst, &surf_templ);
+
+ /* Check whether the states are properly saved. */
+ blitter_check_saved_CSOs(ctx);