[PR #2788] [MERGED] vk_rasterizer: Control mapped_ranges access with shared lock. #2980

Closed
opened 2026-02-27 22:01:59 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/2788
Author: @squidbus
Created: 4/15/2025
Status: Merged
Merged: 4/15/2025
Merged by: @squidbus

Base: mainHead: fix-mem-map


📝 Commits (1)

  • 929679c vk_rasterizer: Control mapped_ranges access with shared lock.

📊 Changes

2 files changed (+15 additions, -4 deletions)

View changed files

📝 src/video_core/renderer_vulkan/vk_rasterizer.cpp (+12 -4)
📝 src/video_core/renderer_vulkan/vk_rasterizer.h (+3 -0)

📄 Description

The GPU mapped memory ranges set may be modified by one thread at the same time as another thread checks it. Reading the set mid-write like this can produce an incorrect result, making it think that valid memory is not mapped.

To address this, add a shared lock to control access to mapped_ranges. Any number of readers can access the map at the same time, but when it is being written by a map/unmap operation, that is given exclusive access.

Also made the intervals and set contains check a bit more correct.

Fixes instances of incorrect Attempted to track non-GPU memory assert in games that map and unmap memory a lot beyond boot.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/2788 **Author:** [@squidbus](https://github.com/squidbus) **Created:** 4/15/2025 **Status:** ✅ Merged **Merged:** 4/15/2025 **Merged by:** [@squidbus](https://github.com/squidbus) **Base:** `main` ← **Head:** `fix-mem-map` --- ### 📝 Commits (1) - [`929679c`](https://github.com/shadps4-emu/shadPS4/commit/929679c13d474e63316a4400e752844d485b44bc) vk_rasterizer: Control mapped_ranges access with shared lock. ### 📊 Changes **2 files changed** (+15 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/video_core/renderer_vulkan/vk_rasterizer.cpp` (+12 -4) 📝 `src/video_core/renderer_vulkan/vk_rasterizer.h` (+3 -0) </details> ### 📄 Description The GPU mapped memory ranges set may be modified by one thread at the same time as another thread checks it. Reading the set mid-write like this can produce an incorrect result, making it think that valid memory is not mapped. To address this, add a shared lock to control access to `mapped_ranges`. Any number of readers can access the map at the same time, but when it is being written by a map/unmap operation, that is given exclusive access. Also made the intervals and set contains check a bit more correct. Fixes instances of incorrect `Attempted to track non-GPU memory` assert in games that map and unmap memory a lot beyond boot. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:01:59 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#2980
No description provided.