TextureCache: Don't copy out-of-range rectangles when stitching textures
This can cause driver crashes or GPU hangs if we do.
This commit is contained in:
parent
2165523fdc
commit
933f3ba008
|
@ -384,6 +384,17 @@ TextureCacheBase::DoPartialTextureUpdates(TCacheEntry* entry_to_update, u8* pale
|
||||||
dst_y = 0;
|
dst_y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the source rectangle is outside of what we actually have in VRAM, skip the copy.
|
||||||
|
// The backend doesn't do any clamping, so if we don't, we'd pass out-of-range coordinates
|
||||||
|
// to the graphics driver, which can cause GPU resets.
|
||||||
|
if (static_cast<u32>(src_x) >= entry->native_width ||
|
||||||
|
static_cast<u32>(src_y) >= entry->native_height ||
|
||||||
|
static_cast<u32>(dst_x) >= entry_to_update->native_width ||
|
||||||
|
static_cast<u32>(dst_y) >= entry_to_update->native_height)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
u32 copy_width =
|
u32 copy_width =
|
||||||
std::min(entry->native_width - src_x, entry_to_update->native_width - dst_x);
|
std::min(entry->native_width - src_x, entry_to_update->native_width - dst_x);
|
||||||
u32 copy_height =
|
u32 copy_height =
|
||||||
|
@ -1453,6 +1464,17 @@ TextureCacheBase::GetTextureFromOverlappingTextures(const TextureLookupInformati
|
||||||
dst_y = 0;
|
dst_y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the source rectangle is outside of what we actually have in VRAM, skip the copy.
|
||||||
|
// The backend doesn't do any clamping, so if we don't, we'd pass out-of-range coordinates
|
||||||
|
// to the graphics driver, which can cause GPU resets.
|
||||||
|
if (static_cast<u32>(src_x) >= entry->native_width ||
|
||||||
|
static_cast<u32>(src_y) >= entry->native_height ||
|
||||||
|
static_cast<u32>(dst_x) >= stitched_entry->native_width ||
|
||||||
|
static_cast<u32>(dst_y) >= stitched_entry->native_height)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
u32 copy_width = std::min(entry->native_width - src_x, stitched_entry->native_width - dst_x);
|
u32 copy_width = std::min(entry->native_width - src_x, stitched_entry->native_width - dst_x);
|
||||||
u32 copy_height = std::min(entry->native_height - src_y, stitched_entry->native_height - dst_y);
|
u32 copy_height = std::min(entry->native_height - src_y, stitched_entry->native_height - dst_y);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue