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).
This commit is contained in:
kokole 2021-06-23 16:34:37 +02:00 committed by Jim
parent 85891630b3
commit dd6dd4e104
5 changed files with 13 additions and 18 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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<IDXGISwapChain3 *>(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);
}
}

View File

@ -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();
}
}

View File

@ -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