mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-01-27 08:51:47 +00:00
texture_cache: Lock when updating image. (#2198)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
This commit is contained in:
parent
a3967ccdb4
commit
95a30b2b3e
|
@ -60,15 +60,13 @@ void TextureCache::MarkAsMaybeDirty(ImageId image_id, Image& image) {
|
|||
|
||||
void TextureCache::InvalidateMemory(VAddr addr, size_t size) {
|
||||
std::scoped_lock lock{mutex};
|
||||
const auto end = addr + size;
|
||||
const auto pages_start = PageManager::GetPageAddr(addr);
|
||||
const auto pages_end = PageManager::GetNextPageAddr(addr + size - 1);
|
||||
ForEachImageInRegion(pages_start, pages_end - pages_start, [&](ImageId image_id, Image& image) {
|
||||
const auto image_begin = image.info.guest_address;
|
||||
const auto image_end = image.info.guest_address + image.info.guest_size;
|
||||
if (image_begin < end && addr < image_end) {
|
||||
// Start or end of the modified region is in the image, or the image is entirely within
|
||||
// the modified region, so the image was definitely accessed by this page fault.
|
||||
if (image.Overlaps(addr, size)) {
|
||||
// Modified region overlaps image, so the image was definitely accessed by this fault.
|
||||
// Untrack the image, so that the range is unprotected and the guest can write freely.
|
||||
image.flags |= ImageFlagBits::CpuDirty;
|
||||
UntrackImage(image_id);
|
||||
|
|
|
@ -118,6 +118,7 @@ public:
|
|||
|
||||
/// Updates image contents if it was modified by CPU.
|
||||
void UpdateImage(ImageId image_id, Vulkan::Scheduler* custom_scheduler = nullptr) {
|
||||
std::scoped_lock lock{mutex};
|
||||
Image& image = slot_images[image_id];
|
||||
TrackImage(image_id);
|
||||
RefreshImage(image, custom_scheduler);
|
||||
|
|
Loading…
Reference in a new issue