gpu: bound overlapping image copies by both native backings

This commit is contained in:
Pixeluted
2026-10-19 04:12:25 +02:00
committed by nmzik
parent 05d25ef28c
commit 440245f616
2 changed files with 51 additions and 2 deletions
@@ -353,8 +353,12 @@ void Image::CopyImage(Image& source) {
std::vector<vk::ImageCopy> copies;
copies.reserve(levels);
for (uint32_t level = 0; level < levels; level++) {
const auto width = std::max(source.backing.extent.width >> level, 1u);
const auto height = std::max(source.backing.extent.height >> level, 1u);
// Overlapping cache images can differ in size; copying the source extent into a smaller
// destination writes out of bounds and loses the device.
const auto width = std::min(std::max(source.backing.extent.width >> level, 1u),
std::max(backing.extent.width >> level, 1u));
const auto height = std::min(std::max(source.backing.extent.height >> level, 1u),
std::max(backing.extent.height >> level, 1u));
const auto depth = std::max(base_depth >> level, 1u);
const auto [source_layers, destination_layers] = SanitizeCopyLayers(source, *this, depth);
vk::ImageCopy copy {};