Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/doitsujin/dxvk.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard Yao <richard.yao@alumni.stonybrook.edu>2024-01-11 06:43:42 +0300
committerPhilip Rebohle <25567304+doitsujin@users.noreply.github.com>2024-01-15 14:42:19 +0300
commit14560600a9ad770a20c3e02e687fd6ff78d4f1b6 (patch)
tree78aceef9c6ce18cf81cb1244f83bc3d36daf4d04 /src
parent854e06d3f04e9d00df0a55a9fe4bbacf6a302189 (diff)
Micro-optimize locking in fences
When a fence has been missed, we can avoid locking *most* of the time via the double-checked locking pattern. We still lock before a second check in case the scheduler caused us to miss the fence. If the scheduler did cause us to miss the fence, we can drop the lock prior to executing the callback function, as a second micro-optimization. Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Diffstat (limited to 'src')
-rw-r--r--src/util/sync/sync_signal.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/util/sync/sync_signal.h b/src/util/sync/sync_signal.h
index cdbcae82..44f99eec 100644
--- a/src/util/sync/sync_signal.h
+++ b/src/util/sync/sync_signal.h
@@ -137,14 +137,22 @@ namespace dxvk::sync {
template<typename Fn>
void setCallback(uint64_t value, Fn&& proc) {
+ if (value <= this->value()) {
+ proc();
+ return;
+ }
+
std::unique_lock<dxvk::mutex> lock(m_mutex);
+ // Verify value is still in the future upon lock.
if (value > this->value())
m_callbacks.emplace_back(std::piecewise_construct,
std::make_tuple(value),
std::make_tuple(proc));
- else
+ else {
+ lock.unlock();
proc();
+ }
}
private: