mirror of https://git.suyu.dev/suyu/suyu
Address Feedback.
This commit is contained in:
parent
39e5b72948
commit
4e37f1b113
|
@ -153,8 +153,8 @@ public:
|
||||||
bool MustFlushRegion(VAddr addr, std::size_t size) {
|
bool MustFlushRegion(VAddr addr, std::size_t size) {
|
||||||
std::lock_guard lock{mutex};
|
std::lock_guard lock{mutex};
|
||||||
|
|
||||||
std::vector<MapInterval> objects = GetMapsInRange(addr, size);
|
const std::vector<MapInterval> objects = GetMapsInRange(addr, size);
|
||||||
return std::any_of(objects.begin(), objects.end(), [](const MapInterval& map) {
|
return std::any_of(objects.cbegin(), objects.cend(), [](const MapInterval& map) {
|
||||||
return map->IsModified() && map->IsRegistered();
|
return map->IsModified() && map->IsRegistered();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ public:
|
||||||
|
|
||||||
for (const auto& object : GetMapsInRange(addr, size)) {
|
for (const auto& object : GetMapsInRange(addr, size)) {
|
||||||
if (object->IsMemoryMarked() && object->IsRegistered()) {
|
if (object->IsMemoryMarked() && object->IsRegistered()) {
|
||||||
Unmark(object);
|
UnmarkMemory(object);
|
||||||
object->SetSyncPending(true);
|
object->SetSyncPending(true);
|
||||||
marked_for_unregister.emplace_back(object);
|
marked_for_unregister.emplace_back(object);
|
||||||
}
|
}
|
||||||
|
@ -217,10 +217,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShouldWaitAsyncFlushes() const {
|
bool ShouldWaitAsyncFlushes() const {
|
||||||
if (committed_flushes.empty()) {
|
return !committed_flushes.empty() && committed_flushes.front() != nullptr;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return committed_flushes.front() != nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasUncommittedFlushes() const {
|
bool HasUncommittedFlushes() const {
|
||||||
|
@ -294,7 +291,7 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unmark(const MapInterval& map) {
|
void UnmarkMemory(const MapInterval& map) {
|
||||||
if (!map->IsMemoryMarked()) {
|
if (!map->IsMemoryMarked()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -305,7 +302,7 @@ protected:
|
||||||
|
|
||||||
/// Unregisters an object from the cache
|
/// Unregisters an object from the cache
|
||||||
void Unregister(const MapInterval& map) {
|
void Unregister(const MapInterval& map) {
|
||||||
Unmark(map);
|
UnmarkMemory(map);
|
||||||
map->MarkAsRegistered(false);
|
map->MarkAsRegistered(false);
|
||||||
if (map->IsSyncPending()) {
|
if (map->IsSyncPending()) {
|
||||||
marked_for_unregister.remove(map);
|
marked_for_unregister.remove(map);
|
||||||
|
|
|
@ -54,7 +54,7 @@ class FenceManager {
|
||||||
public:
|
public:
|
||||||
void SignalSemaphore(GPUVAddr addr, u32 value) {
|
void SignalSemaphore(GPUVAddr addr, u32 value) {
|
||||||
TryReleasePendingFences();
|
TryReleasePendingFences();
|
||||||
bool should_flush = ShouldFlush();
|
const bool should_flush = ShouldFlush();
|
||||||
CommitAsyncFlushes();
|
CommitAsyncFlushes();
|
||||||
TFence new_fence = CreateFence(addr, value, !should_flush);
|
TFence new_fence = CreateFence(addr, value, !should_flush);
|
||||||
fences.push(new_fence);
|
fences.push(new_fence);
|
||||||
|
@ -67,7 +67,7 @@ public:
|
||||||
|
|
||||||
void SignalSyncPoint(u32 value) {
|
void SignalSyncPoint(u32 value) {
|
||||||
TryReleasePendingFences();
|
TryReleasePendingFences();
|
||||||
bool should_flush = ShouldFlush();
|
const bool should_flush = ShouldFlush();
|
||||||
CommitAsyncFlushes();
|
CommitAsyncFlushes();
|
||||||
TFence new_fence = CreateFence(value, !should_flush);
|
TFence new_fence = CreateFence(value, !should_flush);
|
||||||
fences.push(new_fence);
|
fences.push(new_fence);
|
||||||
|
@ -79,15 +79,15 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitPendingFences() {
|
void WaitPendingFences() {
|
||||||
|
auto& gpu{system.GPU()};
|
||||||
|
auto& memory_manager{gpu.MemoryManager()};
|
||||||
while (!fences.empty()) {
|
while (!fences.empty()) {
|
||||||
TFence& current_fence = fences.front();
|
TFence& current_fence = fences.front();
|
||||||
if (ShouldWait()) {
|
if (ShouldWait()) {
|
||||||
WaitFence(current_fence);
|
WaitFence(current_fence);
|
||||||
}
|
}
|
||||||
PopAsyncFlushes();
|
PopAsyncFlushes();
|
||||||
auto& gpu{system.GPU()};
|
|
||||||
if (current_fence->IsSemaphore()) {
|
if (current_fence->IsSemaphore()) {
|
||||||
auto& memory_manager{gpu.MemoryManager()};
|
|
||||||
memory_manager.Write<u32>(current_fence->GetAddress(), current_fence->GetPayload());
|
memory_manager.Write<u32>(current_fence->GetAddress(), current_fence->GetPayload());
|
||||||
} else {
|
} else {
|
||||||
gpu.IncrementSyncPoint(current_fence->GetPayload());
|
gpu.IncrementSyncPoint(current_fence->GetPayload());
|
||||||
|
@ -125,15 +125,15 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void TryReleasePendingFences() {
|
void TryReleasePendingFences() {
|
||||||
|
auto& gpu{system.GPU()};
|
||||||
|
auto& memory_manager{gpu.MemoryManager()};
|
||||||
while (!fences.empty()) {
|
while (!fences.empty()) {
|
||||||
TFence& current_fence = fences.front();
|
TFence& current_fence = fences.front();
|
||||||
if (ShouldWait() && !IsFenceSignaled(current_fence)) {
|
if (ShouldWait() && !IsFenceSignaled(current_fence)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PopAsyncFlushes();
|
PopAsyncFlushes();
|
||||||
auto& gpu{system.GPU()};
|
|
||||||
if (current_fence->IsSemaphore()) {
|
if (current_fence->IsSemaphore()) {
|
||||||
auto& memory_manager{gpu.MemoryManager()};
|
|
||||||
memory_manager.Write<u32>(current_fence->GetAddress(), current_fence->GetPayload());
|
memory_manager.Write<u32>(current_fence->GetAddress(), current_fence->GetPayload());
|
||||||
} else {
|
} else {
|
||||||
gpu.IncrementSyncPoint(current_fence->GetPayload());
|
gpu.IncrementSyncPoint(current_fence->GetPayload());
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
|
|
||||||
for (const auto& surface : GetSurfacesInRegion(addr, size)) {
|
for (const auto& surface : GetSurfacesInRegion(addr, size)) {
|
||||||
if (surface->IsMemoryMarked()) {
|
if (surface->IsMemoryMarked()) {
|
||||||
Unmark(surface);
|
UnmarkMemory(surface);
|
||||||
surface->SetSyncPending(true);
|
surface->SetSyncPending(true);
|
||||||
marked_for_unregister.emplace_back(surface);
|
marked_for_unregister.emplace_back(surface);
|
||||||
}
|
}
|
||||||
|
@ -119,8 +119,8 @@ public:
|
||||||
bool MustFlushRegion(VAddr addr, std::size_t size) {
|
bool MustFlushRegion(VAddr addr, std::size_t size) {
|
||||||
std::lock_guard lock{mutex};
|
std::lock_guard lock{mutex};
|
||||||
|
|
||||||
auto surfaces = GetSurfacesInRegion(addr, size);
|
const auto surfaces = GetSurfacesInRegion(addr, size);
|
||||||
return std::any_of(surfaces.begin(), surfaces.end(),
|
return std::any_of(surfaces.cbegin(), surfaces.cend(),
|
||||||
[](const TSurface& surface) { return surface->IsModified(); });
|
[](const TSurface& surface) { return surface->IsModified(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,10 +335,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShouldWaitAsyncFlushes() const {
|
bool ShouldWaitAsyncFlushes() const {
|
||||||
if (committed_flushes.empty()) {
|
return !committed_flushes.empty() && committed_flushes.front() != nullptr;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return committed_flushes.front() != nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopAsyncFlushes() {
|
void PopAsyncFlushes() {
|
||||||
|
@ -421,7 +418,7 @@ protected:
|
||||||
rasterizer.UpdatePagesCachedCount(*cpu_addr, size, 1);
|
rasterizer.UpdatePagesCachedCount(*cpu_addr, size, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unmark(TSurface surface) {
|
void UnmarkMemory(TSurface surface) {
|
||||||
if (!surface->IsMemoryMarked()) {
|
if (!surface->IsMemoryMarked()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -438,7 +435,7 @@ protected:
|
||||||
if (!guard_render_targets && surface->IsRenderTarget()) {
|
if (!guard_render_targets && surface->IsRenderTarget()) {
|
||||||
ManageRenderTargetUnregister(surface);
|
ManageRenderTargetUnregister(surface);
|
||||||
}
|
}
|
||||||
Unmark(surface);
|
UnmarkMemory(surface);
|
||||||
if (surface->IsSyncPending()) {
|
if (surface->IsSyncPending()) {
|
||||||
marked_for_unregister.remove(surface);
|
marked_for_unregister.remove(surface);
|
||||||
surface->SetSyncPending(false);
|
surface->SetSyncPending(false);
|
||||||
|
|
Loading…
Reference in New Issue