summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-04-22 11:14:40 -0400
committerGravatar Fernando Sahmkow2020-04-22 11:36:27 -0400
commit4e37f1b1130b083b42f21029155e5a2e4e9a9eb3 (patch)
tree751ecd6d575de14bb9b7bf5a9bc0e2e28c9fa1e3
parentAsync GPU: Correct flushing behavior to be similar to old async GPU behavior. (diff)
downloadyuzu-4e37f1b1130b083b42f21029155e5a2e4e9a9eb3.tar.gz
yuzu-4e37f1b1130b083b42f21029155e5a2e4e9a9eb3.tar.xz
yuzu-4e37f1b1130b083b42f21029155e5a2e4e9a9eb3.zip
Address Feedback.
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h15
-rw-r--r--src/video_core/fence_manager.h12
-rw-r--r--src/video_core/texture_cache/texture_cache.h15
3 files changed, 18 insertions, 24 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index f3aa35295..510f11089 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -153,8 +153,8 @@ public:
153 bool MustFlushRegion(VAddr addr, std::size_t size) { 153 bool MustFlushRegion(VAddr addr, std::size_t size) {
154 std::lock_guard lock{mutex}; 154 std::lock_guard lock{mutex};
155 155
156 std::vector<MapInterval> objects = GetMapsInRange(addr, size); 156 const std::vector<MapInterval> objects = GetMapsInRange(addr, size);
157 return std::any_of(objects.begin(), objects.end(), [](const MapInterval& map) { 157 return std::any_of(objects.cbegin(), objects.cend(), [](const MapInterval& map) {
158 return map->IsModified() && map->IsRegistered(); 158 return map->IsModified() && map->IsRegistered();
159 }); 159 });
160 } 160 }
@@ -176,7 +176,7 @@ public:
176 176
177 for (const auto& object : GetMapsInRange(addr, size)) { 177 for (const auto& object : GetMapsInRange(addr, size)) {
178 if (object->IsMemoryMarked() && object->IsRegistered()) { 178 if (object->IsMemoryMarked() && object->IsRegistered()) {
179 Unmark(object); 179 UnmarkMemory(object);
180 object->SetSyncPending(true); 180 object->SetSyncPending(true);
181 marked_for_unregister.emplace_back(object); 181 marked_for_unregister.emplace_back(object);
182 } 182 }
@@ -217,10 +217,7 @@ public:
217 } 217 }
218 218
219 bool ShouldWaitAsyncFlushes() const { 219 bool ShouldWaitAsyncFlushes() const {
220 if (committed_flushes.empty()) { 220 return !committed_flushes.empty() && committed_flushes.front() != nullptr;
221 return false;
222 }
223 return committed_flushes.front() != nullptr;
224 } 221 }
225 222
226 bool HasUncommittedFlushes() const { 223 bool HasUncommittedFlushes() const {
@@ -294,7 +291,7 @@ protected:
294 } 291 }
295 } 292 }
296 293
297 void Unmark(const MapInterval& map) { 294 void UnmarkMemory(const MapInterval& map) {
298 if (!map->IsMemoryMarked()) { 295 if (!map->IsMemoryMarked()) {
299 return; 296 return;
300 } 297 }
@@ -305,7 +302,7 @@ protected:
305 302
306 /// Unregisters an object from the cache 303 /// Unregisters an object from the cache
307 void Unregister(const MapInterval& map) { 304 void Unregister(const MapInterval& map) {
308 Unmark(map); 305 UnmarkMemory(map);
309 map->MarkAsRegistered(false); 306 map->MarkAsRegistered(false);
310 if (map->IsSyncPending()) { 307 if (map->IsSyncPending()) {
311 marked_for_unregister.remove(map); 308 marked_for_unregister.remove(map);
diff --git a/src/video_core/fence_manager.h b/src/video_core/fence_manager.h
index 9fe9c1bf2..dabd1588c 100644
--- a/src/video_core/fence_manager.h
+++ b/src/video_core/fence_manager.h
@@ -54,7 +54,7 @@ class FenceManager {
54public: 54public:
55 void SignalSemaphore(GPUVAddr addr, u32 value) { 55 void SignalSemaphore(GPUVAddr addr, u32 value) {
56 TryReleasePendingFences(); 56 TryReleasePendingFences();
57 bool should_flush = ShouldFlush(); 57 const bool should_flush = ShouldFlush();
58 CommitAsyncFlushes(); 58 CommitAsyncFlushes();
59 TFence new_fence = CreateFence(addr, value, !should_flush); 59 TFence new_fence = CreateFence(addr, value, !should_flush);
60 fences.push(new_fence); 60 fences.push(new_fence);
@@ -67,7 +67,7 @@ public:
67 67
68 void SignalSyncPoint(u32 value) { 68 void SignalSyncPoint(u32 value) {
69 TryReleasePendingFences(); 69 TryReleasePendingFences();
70 bool should_flush = ShouldFlush(); 70 const bool should_flush = ShouldFlush();
71 CommitAsyncFlushes(); 71 CommitAsyncFlushes();
72 TFence new_fence = CreateFence(value, !should_flush); 72 TFence new_fence = CreateFence(value, !should_flush);
73 fences.push(new_fence); 73 fences.push(new_fence);
@@ -79,15 +79,15 @@ public:
79 } 79 }
80 80
81 void WaitPendingFences() { 81 void WaitPendingFences() {
82 auto& gpu{system.GPU()};
83 auto& memory_manager{gpu.MemoryManager()};
82 while (!fences.empty()) { 84 while (!fences.empty()) {
83 TFence& current_fence = fences.front(); 85 TFence& current_fence = fences.front();
84 if (ShouldWait()) { 86 if (ShouldWait()) {
85 WaitFence(current_fence); 87 WaitFence(current_fence);
86 } 88 }
87 PopAsyncFlushes(); 89 PopAsyncFlushes();
88 auto& gpu{system.GPU()};
89 if (current_fence->IsSemaphore()) { 90 if (current_fence->IsSemaphore()) {
90 auto& memory_manager{gpu.MemoryManager()};
91 memory_manager.Write<u32>(current_fence->GetAddress(), current_fence->GetPayload()); 91 memory_manager.Write<u32>(current_fence->GetAddress(), current_fence->GetPayload());
92 } else { 92 } else {
93 gpu.IncrementSyncPoint(current_fence->GetPayload()); 93 gpu.IncrementSyncPoint(current_fence->GetPayload());
@@ -125,15 +125,15 @@ protected:
125 125
126private: 126private:
127 void TryReleasePendingFences() { 127 void TryReleasePendingFences() {
128 auto& gpu{system.GPU()};
129 auto& memory_manager{gpu.MemoryManager()};
128 while (!fences.empty()) { 130 while (!fences.empty()) {
129 TFence& current_fence = fences.front(); 131 TFence& current_fence = fences.front();
130 if (ShouldWait() && !IsFenceSignaled(current_fence)) { 132 if (ShouldWait() && !IsFenceSignaled(current_fence)) {
131 return; 133 return;
132 } 134 }
133 PopAsyncFlushes(); 135 PopAsyncFlushes();
134 auto& gpu{system.GPU()};
135 if (current_fence->IsSemaphore()) { 136 if (current_fence->IsSemaphore()) {
136 auto& memory_manager{gpu.MemoryManager()};
137 memory_manager.Write<u32>(current_fence->GetAddress(), current_fence->GetPayload()); 137 memory_manager.Write<u32>(current_fence->GetAddress(), current_fence->GetPayload());
138 } else { 138 } else {
139 gpu.IncrementSyncPoint(current_fence->GetPayload()); 139 gpu.IncrementSyncPoint(current_fence->GetPayload());
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 1148c3a34..cf6bd005a 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -68,7 +68,7 @@ public:
68 68
69 for (const auto& surface : GetSurfacesInRegion(addr, size)) { 69 for (const auto& surface : GetSurfacesInRegion(addr, size)) {
70 if (surface->IsMemoryMarked()) { 70 if (surface->IsMemoryMarked()) {
71 Unmark(surface); 71 UnmarkMemory(surface);
72 surface->SetSyncPending(true); 72 surface->SetSyncPending(true);
73 marked_for_unregister.emplace_back(surface); 73 marked_for_unregister.emplace_back(surface);
74 } 74 }
@@ -119,8 +119,8 @@ public:
119 bool MustFlushRegion(VAddr addr, std::size_t size) { 119 bool MustFlushRegion(VAddr addr, std::size_t size) {
120 std::lock_guard lock{mutex}; 120 std::lock_guard lock{mutex};
121 121
122 auto surfaces = GetSurfacesInRegion(addr, size); 122 const auto surfaces = GetSurfacesInRegion(addr, size);
123 return std::any_of(surfaces.begin(), surfaces.end(), 123 return std::any_of(surfaces.cbegin(), surfaces.cend(),
124 [](const TSurface& surface) { return surface->IsModified(); }); 124 [](const TSurface& surface) { return surface->IsModified(); });
125 } 125 }
126 126
@@ -335,10 +335,7 @@ public:
335 } 335 }
336 336
337 bool ShouldWaitAsyncFlushes() const { 337 bool ShouldWaitAsyncFlushes() const {
338 if (committed_flushes.empty()) { 338 return !committed_flushes.empty() && committed_flushes.front() != nullptr;
339 return false;
340 }
341 return committed_flushes.front() != nullptr;
342 } 339 }
343 340
344 void PopAsyncFlushes() { 341 void PopAsyncFlushes() {
@@ -421,7 +418,7 @@ protected:
421 rasterizer.UpdatePagesCachedCount(*cpu_addr, size, 1); 418 rasterizer.UpdatePagesCachedCount(*cpu_addr, size, 1);
422 } 419 }
423 420
424 void Unmark(TSurface surface) { 421 void UnmarkMemory(TSurface surface) {
425 if (!surface->IsMemoryMarked()) { 422 if (!surface->IsMemoryMarked()) {
426 return; 423 return;
427 } 424 }
@@ -438,7 +435,7 @@ protected:
438 if (!guard_render_targets && surface->IsRenderTarget()) { 435 if (!guard_render_targets && surface->IsRenderTarget()) {
439 ManageRenderTargetUnregister(surface); 436 ManageRenderTargetUnregister(surface);
440 } 437 }
441 Unmark(surface); 438 UnmarkMemory(surface);
442 if (surface->IsSyncPending()) { 439 if (surface->IsSyncPending()) {
443 marked_for_unregister.remove(surface); 440 marked_for_unregister.remove(surface);
444 surface->SetSyncPending(false); 441 surface->SetSyncPending(false);