diff options
| author | Ryderadzeee <craftercrashonname@gmail.com> | 2026-11-22 23:57:08 +0400 |
|---|---|---|
| committer | Ryderadzeee <craftercrashonname@gmail.com> | 2026-11-22 23:57:08 +0400 |
| commit | bdf052a2d84aca38379cb3bd3a204485139008e7 (patch) | |
| tree | 95de083a66557b8a51695992aa1c04dae3eba1c9 /runtime/shims/dxgi_com.cpp | |
| parent | 162821017ea3c286c8bec860f3ff94f037912061 (diff) | |
DXGI: match native waitable swapchain frame latency limits
Diffstat (limited to 'runtime/shims/dxgi_com.cpp')
| -rw-r--r-- | runtime/shims/dxgi_com.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/runtime/shims/dxgi_com.cpp b/runtime/shims/dxgi_com.cpp index 47a53f7a2..4a41be1b9 100644 --- a/runtime/shims/dxgi_com.cpp +++ b/runtime/shims/dxgi_com.cpp | |||
| @@ -15,6 +15,9 @@ | |||
| 15 | namespace rt::dxgi { | 15 | namespace rt::dxgi { |
| 16 | namespace { | 16 | namespace { |
| 17 | 17 | ||
| 18 | // Native DXGI accepts up to 40 queued frames on a waitable swapchain. | ||
| 19 | constexpr UINT max_waitable_frame_latency = 40; | ||
| 20 | |||
| 18 | void stub(const char* method) { | 21 | void stub(const char* method) { |
| 19 | static std::mutex mutex; | 22 | static std::mutex mutex; |
| 20 | static std::set<std::string> seen; | 23 | static std::set<std::string> seen; |
| @@ -135,7 +138,7 @@ public: | |||
| 135 | if (flags_ & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT) { | 138 | if (flags_ & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT) { |
| 136 | // DXGI: waitable swapchains default to maximum frame latency 1. | 139 | // DXGI: waitable swapchains default to maximum frame latency 1. |
| 137 | max_frame_latency_.store(1, std::memory_order_relaxed); | 140 | max_frame_latency_.store(1, std::memory_order_relaxed); |
| 138 | waitable_ = CreateSemaphoreW(nullptr, 1, 16, nullptr); | 141 | waitable_ = CreateSemaphoreW(nullptr, 1, max_waitable_frame_latency, nullptr); |
| 139 | if (!waitable_) return false; | 142 | if (!waitable_) return false; |
| 140 | } | 143 | } |
| 141 | register_buffers(); | 144 | register_buffers(); |
| @@ -334,8 +337,8 @@ public: | |||
| 334 | return S_OK; | 337 | return S_OK; |
| 335 | } | 338 | } |
| 336 | HRESULT STDMETHODCALLTYPE SetMaximumFrameLatency(UINT max_latency) override { | 339 | HRESULT STDMETHODCALLTYPE SetMaximumFrameLatency(UINT max_latency) override { |
| 337 | if (!waitable_) return DXGI_ERROR_INVALID_CALL; | 340 | if (!waitable_ || max_latency == 0 || max_latency > max_waitable_frame_latency) |
| 338 | if (max_latency == 0 || max_latency > 16) return E_INVALIDARG; | 341 | return DXGI_ERROR_INVALID_CALL; |
| 339 | const UINT prev = max_frame_latency_.exchange(max_latency, std::memory_order_relaxed); | 342 | const UINT prev = max_frame_latency_.exchange(max_latency, std::memory_order_relaxed); |
| 340 | if (max_latency > prev) | 343 | if (max_latency > prev) |
| 341 | ReleaseSemaphore(waitable_, static_cast<LONG>(max_latency - prev), nullptr); | 344 | ReleaseSemaphore(waitable_, static_cast<LONG>(max_latency - prev), nullptr); |