if(dst->memory_property_flags & vk::MemoryPropertyFlagBits::eHostVisible) {
GGML_ASSERT(dst->memory_property_flags & vk::MemoryPropertyFlagBits::eHostCoherent);
- for (size_t i = 0; i < height; i++) {
- memcpy((uint8_t *)dst->ptr + offset + i * dpitch, (const uint8_t *) src + i * spitch, width);
+ if (width == spitch && width == dpitch) {
+ memcpy((uint8_t *)dst->ptr + offset, src, width * height);
+ } else {
+ for (size_t i = 0; i < height; i++) {
+ memcpy((uint8_t *)dst->ptr + offset + i * dpitch, (const uint8_t *) src + i * spitch, width);
+ }
}
} else {
std::lock_guard<std::recursive_mutex> guard(dst->device->mutex);
if(src->memory_property_flags & vk::MemoryPropertyFlagBits::eHostVisible && src->device->uma) {
GGML_ASSERT(src->memory_property_flags & vk::MemoryPropertyFlagBits::eHostCoherent);
- for (size_t i = 0; i < height; i++) {
- memcpy((uint8_t *) dst + i * dpitch, (const uint8_t *) src->ptr + offset + i * spitch, width);
+ if (width == spitch && width == dpitch) {
+ memcpy(dst, (const uint8_t *) src->ptr + offset, width * height);
+ } else {
+ for (size_t i = 0; i < height; i++) {
+ memcpy((uint8_t *) dst + i * dpitch, (const uint8_t *) src->ptr + offset + i * spitch, width);
+ }
}
} else {
std::lock_guard<std::recursive_mutex> guard(src->device->mutex);