graphics-hook: Avoid conflict between Vulkan and DXGI Present

master
Eric Laberge 2022-07-10 20:13:44 -03:00 committed by Jim
parent 7bfc7e65f4
commit dfb9bb74f7
3 changed files with 38 additions and 1 deletions

View File

@ -198,6 +198,13 @@ static void update_mismatch_count(bool match)
static HRESULT STDMETHODCALLTYPE hook_present(IDXGISwapChain *swap,
UINT sync_interval, UINT flags)
{
if (should_passthrough()) {
dxgi_presenting = true;
const HRESULT hr = RealPresent(swap, sync_interval, flags);
dxgi_presenting = false;
return hr;
}
const bool capture_overlay = global_hook_info->capture_overlay;
const bool test_draw = (flags & DXGI_PRESENT_TEST) != 0;
@ -255,6 +262,14 @@ static HRESULT STDMETHODCALLTYPE
hook_present1(IDXGISwapChain1 *swap, UINT sync_interval, UINT flags,
const DXGI_PRESENT_PARAMETERS *params)
{
if (should_passthrough()) {
dxgi_presenting = true;
const HRESULT hr =
RealPresent1(swap, sync_interval, flags, params);
dxgi_presenting = false;
return hr;
}
const bool capture_overlay = global_hook_info->capture_overlay;
const bool test_draw = (flags & DXGI_PRESENT_TEST) != 0;

View File

@ -248,6 +248,19 @@ static inline bool capture_should_init(void)
return should_init;
}
#if COMPILE_VULKAN_HOOK
extern __declspec(thread) int vk_presenting;
#endif
static inline bool should_passthrough()
{
#if COMPILE_VULKAN_HOOK
return vk_presenting > 0;
#else
return false;
#endif
}
#ifdef __cplusplus
}
#endif

View File

@ -115,6 +115,8 @@ struct vk_data {
ID3D11DeviceContext *d3d11_context;
};
__declspec(thread) int vk_presenting = 0;
/* ------------------------------------------------------------------------- */
static void *vk_alloc(const VkAllocationCallbacks *ac, size_t size,
@ -1216,7 +1218,14 @@ static VkResult VKAPI_CALL OBS_QueuePresentKHR(VkQueue queue,
vk_capture(data, queue, info);
}
return funcs->QueuePresentKHR(queue, info);
if (vk_presenting != 0) {
flog("non-zero vk_presenting: %d", vk_presenting);
}
vk_presenting++;
VkResult res = funcs->QueuePresentKHR(queue, info);
vk_presenting--;
return res;
}
/* ======================================================================== */