mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 04:46:27 -05:00
Vulkan: Fix the master Semaphore
This commit is contained in:
parent
35f46fc079
commit
7f4de3466a
1 changed files with 12 additions and 4 deletions
|
@ -21,12 +21,12 @@ public:
|
|||
|
||||
/// Returns the current logical tick.
|
||||
[[nodiscard]] u64 CurrentTick() const noexcept {
|
||||
return current_tick.load(std::memory_order_relaxed);
|
||||
return current_tick.load(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
/// Returns the last known GPU tick.
|
||||
[[nodiscard]] u64 KnownGpuTick() const noexcept {
|
||||
return gpu_tick.load(std::memory_order_relaxed);
|
||||
return gpu_tick.load(std::memory_order_acquire);
|
||||
}
|
||||
|
||||
/// Returns the timeline semaphore handle.
|
||||
|
@ -41,12 +41,20 @@ public:
|
|||
|
||||
/// Advance to the logical tick and return the old one
|
||||
[[nodiscard]] u64 NextTick() noexcept {
|
||||
return current_tick.fetch_add(1, std::memory_order::relaxed);
|
||||
return current_tick.fetch_add(1, std::memory_order_release);
|
||||
}
|
||||
|
||||
/// Refresh the known GPU tick
|
||||
void Refresh() {
|
||||
gpu_tick.store(semaphore.GetCounter(), std::memory_order_relaxed);
|
||||
auto this_tick = gpu_tick.load(std::memory_order_acquire);
|
||||
u64 counter{};
|
||||
do {
|
||||
counter = semaphore.GetCounter();
|
||||
if (counter < this_tick) {
|
||||
return;
|
||||
}
|
||||
} while (!gpu_tick.compare_exchange_weak(this_tick, counter, std::memory_order_release,
|
||||
std::memory_order_relaxed));
|
||||
}
|
||||
|
||||
/// Waits for a tick to be hit on the GPU
|
||||
|
|
Loading…
Reference in a new issue