video_core: texture_cache: fix for page table corruption

This commit is contained in:
psucien 2024-05-31 12:32:46 +02:00
parent 92a8e18eab
commit 29f670cf9c
2 changed files with 3 additions and 0 deletions

View File

@ -101,6 +101,7 @@ TextureCache::~TextureCache() {
} }
void TextureCache::OnCpuWrite(VAddr address) { void TextureCache::OnCpuWrite(VAddr address) {
std::unique_lock lock{m_page_table};
ForEachImageInRegion(address, 1 << PageShift, [&](ImageId image_id, Image& image) { ForEachImageInRegion(address, 1 << PageShift, [&](ImageId image_id, Image& image) {
// Ensure image is reuploaded when accessed again. // Ensure image is reuploaded when accessed again.
image.flags |= ImageFlagBits::CpuModified; image.flags |= ImageFlagBits::CpuModified;
@ -110,6 +111,7 @@ void TextureCache::OnCpuWrite(VAddr address) {
} }
Image& TextureCache::FindImage(const ImageInfo& info, VAddr cpu_address) { Image& TextureCache::FindImage(const ImageInfo& info, VAddr cpu_address) {
std::unique_lock lock{m_page_table};
boost::container::small_vector<ImageId, 2> image_ids; boost::container::small_vector<ImageId, 2> image_ids;
ForEachImageInRegion(cpu_address, info.guest_size_bytes, [&](ImageId image_id, Image& image) { ForEachImageInRegion(cpu_address, info.guest_size_bytes, [&](ImageId image_id, Image& image) {
if (image.cpu_addr == cpu_address) { if (image.cpu_addr == cpu_address) {

View File

@ -136,6 +136,7 @@ private:
#ifdef _WIN64 #ifdef _WIN64
void* veh_handle{}; void* veh_handle{};
#endif #endif
std::mutex m_page_table;
}; };
} // namespace VideoCore } // namespace VideoCore