From dd6dd4e1045a9671c4f9b7908ad5fc55588050b2 Mon Sep 17 00:00:00 2001 From: kokole <3148715+kokole@users.noreply.github.com> Date: Wed, 23 Jun 2021 16:34:37 +0200 Subject: [PATCH] win-capture: Fix D3D12 third party overlay capture Doesn't make sense to grab the oldest frame when not capturing overlays, because the overlay was already rendered in it. This will grab the latest frame (before the overlay is rendered). --- plugins/win-capture/graphics-hook/d3d10-capture.cpp | 2 +- plugins/win-capture/graphics-hook/d3d11-capture.cpp | 2 +- plugins/win-capture/graphics-hook/d3d12-capture.cpp | 11 +++-------- plugins/win-capture/graphics-hook/dxgi-capture.cpp | 10 +++++----- plugins/win-capture/graphics-hook/graphics-hook.h | 6 +++--- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/plugins/win-capture/graphics-hook/d3d10-capture.cpp b/plugins/win-capture/graphics-hook/d3d10-capture.cpp index cec722cde..e627d43ea 100644 --- a/plugins/win-capture/graphics-hook/d3d10-capture.cpp +++ b/plugins/win-capture/graphics-hook/d3d10-capture.cpp @@ -330,7 +330,7 @@ static inline void d3d10_shmem_capture(ID3D10Resource *backbuffer) data.cur_tex = next_tex; } -void d3d10_capture(void *swap_ptr, void *backbuffer_ptr, bool) +void d3d10_capture(void *swap_ptr, void *backbuffer_ptr) { IDXGIResource *dxgi_backbuffer = (IDXGIResource *)backbuffer_ptr; IDXGISwapChain *swap = (IDXGISwapChain *)swap_ptr; diff --git a/plugins/win-capture/graphics-hook/d3d11-capture.cpp b/plugins/win-capture/graphics-hook/d3d11-capture.cpp index 168afed66..a71517096 100644 --- a/plugins/win-capture/graphics-hook/d3d11-capture.cpp +++ b/plugins/win-capture/graphics-hook/d3d11-capture.cpp @@ -337,7 +337,7 @@ static inline void d3d11_shmem_capture(ID3D11Resource *backbuffer) data.cur_tex = next_tex; } -void d3d11_capture(void *swap_ptr, void *backbuffer_ptr, bool) +void d3d11_capture(void *swap_ptr, void *backbuffer_ptr) { IDXGIResource *dxgi_backbuffer = (IDXGIResource *)backbuffer_ptr; IDXGISwapChain *swap = (IDXGISwapChain *)swap_ptr; diff --git a/plugins/win-capture/graphics-hook/d3d12-capture.cpp b/plugins/win-capture/graphics-hook/d3d12-capture.cpp index d9ec7d0d9..839d9dfa8 100644 --- a/plugins/win-capture/graphics-hook/d3d12-capture.cpp +++ b/plugins/win-capture/graphics-hook/d3d12-capture.cpp @@ -313,8 +313,7 @@ static inline void d3d12_copy_texture(ID3D11Resource *dst, ID3D11Resource *src) } } -static inline void d3d12_shtex_capture(IDXGISwapChain *swap, - bool capture_overlay) +static inline void d3d12_shtex_capture(IDXGISwapChain *swap) { bool dxgi_1_4 = data.dxgi_1_4; UINT cur_idx; @@ -323,10 +322,6 @@ static inline void d3d12_shtex_capture(IDXGISwapChain *swap, IDXGISwapChain3 *swap3 = reinterpret_cast(swap); cur_idx = swap3->GetCurrentBackBufferIndex(); - if (!capture_overlay) { - if (++cur_idx >= data.backbuffer_count) - cur_idx = 0; - } } else { cur_idx = data.cur_backbuffer; } @@ -344,7 +339,7 @@ static inline void d3d12_shtex_capture(IDXGISwapChain *swap, } } -void d3d12_capture(void *swap_ptr, void *, bool capture_overlay) +void d3d12_capture(void *swap_ptr, void *) { IDXGISwapChain *swap = (IDXGISwapChain *)swap_ptr; @@ -355,7 +350,7 @@ void d3d12_capture(void *swap_ptr, void *, bool capture_overlay) d3d12_init(swap); } if (capture_ready()) { - d3d12_shtex_capture(swap, capture_overlay); + d3d12_shtex_capture(swap); } } diff --git a/plugins/win-capture/graphics-hook/dxgi-capture.cpp b/plugins/win-capture/graphics-hook/dxgi-capture.cpp index 20d740080..5e031529d 100644 --- a/plugins/win-capture/graphics-hook/dxgi-capture.cpp +++ b/plugins/win-capture/graphics-hook/dxgi-capture.cpp @@ -31,7 +31,7 @@ bool dxgi_present_attempted = false; struct dxgi_swap_data { IDXGISwapChain *swap; - void (*capture)(void *, void *, bool); + void (*capture)(void *, void *); void (*free)(void); }; @@ -223,7 +223,7 @@ static HRESULT STDMETHODCALLTYPE hook_present(IDXGISwapChain *swap, IUnknown *backbuffer = get_dxgi_backbuffer(swap); if (backbuffer) { - data.capture(swap, backbuffer, capture_overlay); + data.capture(swap, backbuffer); backbuffer->Release(); } } @@ -250,7 +250,7 @@ static HRESULT STDMETHODCALLTYPE hook_present(IDXGISwapChain *swap, IUnknown *backbuffer = get_dxgi_backbuffer(swap); if (backbuffer) { - data.capture(swap, backbuffer, capture_overlay); + data.capture(swap, backbuffer); backbuffer->Release(); } } @@ -285,7 +285,7 @@ hook_present1(IDXGISwapChain1 *swap, UINT sync_interval, UINT flags, if (backbuffer) { DXGI_SWAP_CHAIN_DESC1 desc; swap->GetDesc1(&desc); - data.capture(swap, backbuffer, capture_overlay); + data.capture(swap, backbuffer); backbuffer->Release(); } } @@ -305,7 +305,7 @@ hook_present1(IDXGISwapChain1 *swap, UINT sync_interval, UINT flags, IUnknown *backbuffer = get_dxgi_backbuffer(swap); if (backbuffer) { - data.capture(swap, backbuffer, capture_overlay); + data.capture(swap, backbuffer); backbuffer->Release(); } } diff --git a/plugins/win-capture/graphics-hook/graphics-hook.h b/plugins/win-capture/graphics-hook/graphics-hook.h index 5c4c24eb0..db341a92e 100644 --- a/plugins/win-capture/graphics-hook/graphics-hook.h +++ b/plugins/win-capture/graphics-hook/graphics-hook.h @@ -57,13 +57,13 @@ extern bool hook_gl(void); extern bool hook_vulkan(void); #endif -extern void d3d10_capture(void *swap, void *backbuffer, bool capture_overlay); +extern void d3d10_capture(void *swap, void *backbuffer); extern void d3d10_free(void); -extern void d3d11_capture(void *swap, void *backbuffer, bool capture_overlay); +extern void d3d11_capture(void *swap, void *backbuffer); extern void d3d11_free(void); #if COMPILE_D3D12_HOOK -extern void d3d12_capture(void *swap, void *backbuffer, bool capture_overlay); +extern void d3d12_capture(void *swap, void *backbuffer); extern void d3d12_free(void); #endif