Fix image extent in buffer copy to image

This commit is contained in:
Marcin Mikołajczyk 2025-05-20 18:26:10 +01:00
parent 034ae8cffa
commit 039ee99b11

View File

@ -538,10 +538,16 @@ void TextureCache::RefreshImage(Image& image, Vulkan::Scheduler* custom_schedule
image.mip_hashes[m] = hash;
}
auto mip_pitch = static_cast<u32>(mip.pitch);
auto mip_height = static_cast<u32>(mip.height);
auto image_extent_width = mip_pitch ? std::min(mip_pitch, width) : width;
auto image_extent_height = mip_height ? std::min(mip_height, height) : height;
image_copy.push_back({
.bufferOffset = mip.offset,
.bufferRowLength = static_cast<u32>(mip.pitch),
.bufferImageHeight = static_cast<u32>(mip.height),
.bufferRowLength = mip_pitch,
.bufferImageHeight = mip_height,
.imageSubresource{
.aspectMask = image.aspect_mask & ~vk::ImageAspectFlagBits::eStencil,
.mipLevel = m,
@ -549,7 +555,7 @@ void TextureCache::RefreshImage(Image& image, Vulkan::Scheduler* custom_schedule
.layerCount = num_layers,
},
.imageOffset = {0, 0, 0},
.imageExtent = {width, height, depth},
.imageExtent = {image_extent_width, image_extent_height, depth},
});
}