upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/dxgi_com.cpp
diff options
context:
space:
mode:
authorbobcatchris <83428450+bobcatchris@users.noreply.github.com>2026-11-22 06:33:56 -0600
committerbobcatchris <83428450+bobcatchris@users.noreply.github.com>2026-11-22 06:33:56 -0600
commitc083d09f193412c49efc97aa8623296698cf48d5 (patch)
tree0313a7bee02c696be2c9624252267f64efbecb6c /runtime/shims/dxgi_com.cpp
parent99f99890c5ebe186ef2f9fe8ff6d675745d9e621 (diff)
dxgi: report swapchain frame statistics from the presenter
GetFrameStatistics returned E_NOTIMPL even though the swapchain already tracks successful presents. Record the QPC at each successful present and fill PresentCount, PresentRefreshCount, SyncRefreshCount and SyncQPCTime; failed and test presents still change nothing. The test checks the values and the null-argument error. Verified on Windows 11 with an RX 7900 XTX: dxgi_swapchain passed with and without LEONIDA_VK_VALIDATION=1. No game files. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Diffstat (limited to 'runtime/shims/dxgi_com.cpp')
-rw-r--r--runtime/shims/dxgi_com.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/runtime/shims/dxgi_com.cpp b/runtime/shims/dxgi_com.cpp
index 3c8102b99..9ae843ba0 100644
--- a/runtime/shims/dxgi_com.cpp
+++ b/runtime/shims/dxgi_com.cpp
@@ -188,6 +188,8 @@ public:
188 const std::uint32_t cur = swapchain_.current_back_buffer_index(); 188 const std::uint32_t cur = swapchain_.current_back_buffer_index();
189 if (!swapchain_.present(cur)) return E_FAIL; 189 if (!swapchain_.present(cur)) return E_FAIL;
190 ++present_count_; 190 ++present_count_;
191 LARGE_INTEGER qpc{};
192 if (QueryPerformanceCounter(&qpc)) last_present_qpc_.store(qpc.QuadPart, std::memory_order_relaxed);
191 std::uint32_t next = 0; 193 std::uint32_t next = 0;
192 if (!swapchain_.acquire_next_image(next)) return E_FAIL; 194 if (!swapchain_.acquire_next_image(next)) return E_FAIL;
193 if (waitable_) ReleaseSemaphore(waitable_, 1, nullptr); 195 if (waitable_) ReleaseSemaphore(waitable_, 1, nullptr);
@@ -249,7 +251,16 @@ public:
249 251
250 HRESULT STDMETHODCALLTYPE ResizeTarget(const DXGI_MODE_DESC*) override { return S_OK; } 252 HRESULT STDMETHODCALLTYPE ResizeTarget(const DXGI_MODE_DESC*) override { return S_OK; }
251 HRESULT STDMETHODCALLTYPE GetContainingOutput(IDXGIOutput**) override { return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE; } 253 HRESULT STDMETHODCALLTYPE GetContainingOutput(IDXGIOutput**) override { return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE; }
252 HRESULT STDMETHODCALLTYPE GetFrameStatistics(DXGI_FRAME_STATISTICS*) override { return E_NOTIMPL; } 254 HRESULT STDMETHODCALLTYPE GetFrameStatistics(DXGI_FRAME_STATISTICS* stats) override {
255 if (!stats) return E_INVALIDARG;
256 std::memset(stats, 0, sizeof(*stats));
257 const UINT count = present_count_.load(std::memory_order_relaxed);
258 stats->PresentCount = count;
259 stats->PresentRefreshCount = count;
260 stats->SyncRefreshCount = count;
261 stats->SyncQPCTime.QuadPart = last_present_qpc_.load(std::memory_order_relaxed);
262 return S_OK;
263 }
253 HRESULT STDMETHODCALLTYPE GetLastPresentCount(UINT* p) override { 264 HRESULT STDMETHODCALLTYPE GetLastPresentCount(UINT* p) override {
254 if (!p) return E_INVALIDARG; 265 if (!p) return E_INVALIDARG;
255 *p = present_count_.load(std::memory_order_relaxed); 266 *p = present_count_.load(std::memory_order_relaxed);
@@ -381,6 +392,7 @@ private:
381 HANDLE waitable_ = nullptr; 392 HANDLE waitable_ = nullptr;
382 std::vector<BackBufferResource*> buffers_; 393 std::vector<BackBufferResource*> buffers_;
383 std::atomic<UINT> present_count_{0}; 394 std::atomic<UINT> present_count_{0};
395 std::atomic<LONGLONG> last_present_qpc_{0};
384 std::atomic<UINT> max_frame_latency_{2}; 396 std::atomic<UINT> max_frame_latency_{2};
385}; 397};
386 398