diff options
| author | 2021-12-23 01:40:45 +0100 | |
|---|---|---|
| committer | 2022-10-06 21:00:52 +0200 | |
| commit | 9cf4c8831d6a8b0d9c6e2a48e89b667fd73accee (patch) | |
| tree | b213e143366041f07ac9389e91801384f698b0d8 /src/video_core/control | |
| parent | Refactor VideoCore to use AS sepparate from Channel. (diff) | |
| download | yuzu-9cf4c8831d6a8b0d9c6e2a48e89b667fd73accee.tar.gz yuzu-9cf4c8831d6a8b0d9c6e2a48e89b667fd73accee.tar.xz yuzu-9cf4c8831d6a8b0d9c6e2a48e89b667fd73accee.zip | |
Texture cache: Fix dangling references on multichannel.
Diffstat (limited to 'src/video_core/control')
| -rw-r--r-- | src/video_core/control/channel_state_cache.h | 1 | ||||
| -rw-r--r-- | src/video_core/control/channel_state_cache.inc | 17 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/video_core/control/channel_state_cache.h b/src/video_core/control/channel_state_cache.h index c51040c83..9b1d7362b 100644 --- a/src/video_core/control/channel_state_cache.h +++ b/src/video_core/control/channel_state_cache.h | |||
| @@ -72,6 +72,7 @@ protected: | |||
| 72 | std::deque<P> channel_storage; | 72 | std::deque<P> channel_storage; |
| 73 | std::deque<size_t> free_channel_ids; | 73 | std::deque<size_t> free_channel_ids; |
| 74 | std::unordered_map<s32, size_t> channel_map; | 74 | std::unordered_map<s32, size_t> channel_map; |
| 75 | std::vector<size_t> active_channel_ids; | ||
| 75 | struct AddresSpaceRef { | 76 | struct AddresSpaceRef { |
| 76 | size_t ref_count; | 77 | size_t ref_count; |
| 77 | size_t storage_id; | 78 | size_t storage_id; |
diff --git a/src/video_core/control/channel_state_cache.inc b/src/video_core/control/channel_state_cache.inc index 185eabc35..d3ae758b2 100644 --- a/src/video_core/control/channel_state_cache.inc +++ b/src/video_core/control/channel_state_cache.inc | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | |||
| 2 | #include <algorithm> | ||
| 3 | |||
| 1 | #include "video_core/control/channel_state.h" | 4 | #include "video_core/control/channel_state.h" |
| 2 | #include "video_core/control/channel_state_cache.h" | 5 | #include "video_core/control/channel_state_cache.h" |
| 3 | #include "video_core/engines/kepler_compute.h" | 6 | #include "video_core/engines/kepler_compute.h" |
| @@ -27,15 +30,16 @@ void ChannelSetupCaches<P>::CreateChannel(struct Tegra::Control::ChannelState& c | |||
| 27 | if (current_channel_id != UNSET_CHANNEL) { | 30 | if (current_channel_id != UNSET_CHANNEL) { |
| 28 | channel_state = &channel_storage[current_channel_id]; | 31 | channel_state = &channel_storage[current_channel_id]; |
| 29 | } | 32 | } |
| 33 | active_channel_ids.push_back(new_id); | ||
| 30 | auto as_it = address_spaces.find(channel.memory_manager->GetID()); | 34 | auto as_it = address_spaces.find(channel.memory_manager->GetID()); |
| 31 | if (as_it != address_spaces.end()) { | 35 | if (as_it != address_spaces.end()) { |
| 32 | as_it->second.ref_count++; | 36 | as_it->second.ref_count++; |
| 33 | return; | 37 | return; |
| 34 | } | 38 | } |
| 35 | AddresSpaceRef new_gpu_mem_ref{ | 39 | AddresSpaceRef new_gpu_mem_ref{ |
| 36 | .ref_count = 1, | 40 | .ref_count = 1, |
| 37 | .storage_id = address_spaces.size(), | 41 | .storage_id = address_spaces.size(), |
| 38 | .gpu_memory = channel.memory_manager.get(), | 42 | .gpu_memory = channel.memory_manager.get(), |
| 39 | }; | 43 | }; |
| 40 | address_spaces.emplace(channel.memory_manager->GetID(), new_gpu_mem_ref); | 44 | address_spaces.emplace(channel.memory_manager->GetID(), new_gpu_mem_ref); |
| 41 | OnGPUASRegister(channel.memory_manager->GetID()); | 45 | OnGPUASRegister(channel.memory_manager->GetID()); |
| @@ -73,7 +77,8 @@ void ChannelSetupCaches<P>::EraseChannel(s32 id) { | |||
| 73 | } else if (current_channel_id != UNSET_CHANNEL) { | 77 | } else if (current_channel_id != UNSET_CHANNEL) { |
| 74 | channel_state = &channel_storage[current_channel_id]; | 78 | channel_state = &channel_storage[current_channel_id]; |
| 75 | } | 79 | } |
| 80 | active_channel_ids.erase( | ||
| 81 | std::find(active_channel_ids.begin(), active_channel_ids.end(), this_id)); | ||
| 76 | } | 82 | } |
| 77 | 83 | ||
| 78 | |||
| 79 | } // namespace VideoCommon | 84 | } // namespace VideoCommon |