tc->base.resource_copy_region(&tc->base, resource, level, box->x, box->y, box->z, pres, 0, &src_box);
} else {
/* if stride doesn't match, inline util_copy_box on the GPU and assume the driver will optimize */
- unsigned src_offset = 0;
src_box.depth = 1;
- for (unsigned z = 0; z < box->depth; ++z) {
- unsigned dst_x = box->x, dst_y = box->y, width = box->width, height = box->height;
+ for (unsigned z = 0; z < box->depth; ++z, src_box.x = z * layer_stride) {
+ unsigned dst_x = box->x, dst_y = box->y, width = box->width, height = box->height, dst_z = box->z + z;
int blocksize = util_format_get_blocksize(format);
int blockwidth = util_format_get_blockwidth(format);
int blockheight = util_format_get_blockheight(format);
uint64_t size = (uint64_t)height * width;
assert(size <= SIZE_MAX);
- src_box.x = src_offset;
assert(dst_x + src_box.width < u_minify(pres->width0, level));
assert(dst_y + src_box.height < u_minify(pres->height0, level));
assert(pres->target != PIPE_TEXTURE_3D || z + src_box.depth < u_minify(pres->depth0, level));
- tc->base.resource_copy_region(&tc->base, resource, level, dst_x, dst_y, z, pres, 0, &src_box);
+ tc->base.resource_copy_region(&tc->base, resource, level, dst_x, dst_y, dst_z, pres, 0, &src_box);
} else {
src_box.height = 1;
- for (unsigned i = 0; i < height; i++, dst_y++) {
- src_box.x = src_offset;
- tc->base.resource_copy_region(&tc->base, resource, level, dst_x, dst_y, z, pres, 0, &src_box);
- src_offset += stride;
- }
+ for (unsigned i = 0; i < height; i++, dst_y++, src_box.x += stride)
+ tc->base.resource_copy_region(&tc->base, resource, level, dst_x, dst_y, dst_z, pres, 0, &src_box);
}
- src_offset += layer_stride;
}
}