mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-10-18 10:47:55 +00:00
[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>
This commit is contained in:
parent
0102f548d0
commit
dbbe5b3328
29 changed files with 112 additions and 23 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue