aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/fence_manager.h
diff options
context:
space:
mode:
authorcrueter <crueter@eden-emu.dev>2025-08-05 23:16:57 +0200
committercrueter <crueter@eden-emu.dev>2025-08-05 23:16:57 +0200
commitdbbe5b3328ac23c0729ca1b91854d21f769f7a5d (patch)
treeccc1efe0a660a35131f6c20c8bfe5ac1392cdddf /src/video_core/fence_manager.h
parent0102f548d043315123e94bbeca674dcbeb84e0dd (diff)
[android] Early Release Fences, v2 (#190)
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/190 Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev>
Diffstat (limited to 'src/video_core/fence_manager.h')
-rw-r--r--src/video_core/fence_manager.h69
1 files changed, 46 insertions, 23 deletions
diff --git a/src/video_core/fence_manager.h b/src/video_core/fence_manager.h
index 19f7aa7881..0f927159ba 100644
--- a/src/video_core/fence_manager.h
+++ b/src/video_core/fence_manager.h
@@ -11,14 +11,11 @@
#include <cstring>
#include <deque>
#include <functional>
-#include <memory>
#include <mutex>
#include <thread>
#include <queue>
#include "common/common_types.h"
-#include "common/microprofile.h"
-#include "common/scope_exit.h"
#include "common/settings.h"
#include "common/thread.h"
#include "video_core/delayed_destruction_ring.h"
@@ -75,32 +72,66 @@ public:
}
void SignalFence(std::function<void()>&& func) {
- bool delay_fence = Settings::IsGPULevelHigh();
- if constexpr (!can_async_check) {
- TryReleasePendingFences<false>();
- }
+ const bool delay_fence = Settings::IsGPULevelHigh();
+
+ #ifdef __ANDROID__
+ const bool use_optimized = Settings::values.early_release_fences.GetValue();
+ #else
+ constexpr bool use_optimized = false;
+ #endif
+
const bool should_flush = ShouldFlush();
CommitAsyncFlushes();
TFence new_fence = CreateFence(!should_flush);
- if constexpr (can_async_check) {
- guard.lock();
- }
- if (delay_fence) {
- uncommitted_operations.emplace_back(std::move(func));
+
+ if (use_optimized) {
+ if (!delay_fence) {
+ TryReleasePendingFences<false>();
+ }
+
+ if (delay_fence) {
+ guard.lock();
+ uncommitted_operations.emplace_back(std::move(func));
+ }
+ } else {
+ if constexpr (!can_async_check) {
+ TryReleasePendingFences<false>();
+ }
+
+ if constexpr (can_async_check) {
+ guard.lock();
+ }
+
+ if (delay_fence) {
+ uncommitted_operations.emplace_back(std::move(func));
+ }
}
+
pending_operations.emplace_back(std::move(uncommitted_operations));
QueueFence(new_fence);
+
if (!delay_fence) {
func();
}
+
fences.push(std::move(new_fence));
+
if (should_flush) {
rasterizer.FlushCommands();
}
- if constexpr (can_async_check) {
- guard.unlock();
- cv.notify_all();
+
+ if (use_optimized) {
+ if (delay_fence) {
+ guard.unlock();
+ cv.notify_all();
+ }
+ } else {
+ if constexpr (can_async_check) {
+ guard.unlock();
+ cv.notify_all();
+ }
}
+
rasterizer.InvalidateGPUCache();
}
@@ -197,14 +228,6 @@ private:
void ReleaseThreadFunc(std::stop_token stop_token) {
std::string name = "GPUFencingThread";
- MicroProfileOnThreadCreate(name.c_str());
-
- // Cleanup
-#if MICROPROFILE_ENABLED
- SCOPE_EXIT {
- MicroProfileOnThreadExit();
- };
-#endif
Common::SetCurrentThreadName(name.c_str());
Common::SetCurrentThreadPriority(Common::ThreadPriority::High);