提交 4c505e70 编写于 作者: P Palana 提交者: jp9000

win-capture: Track gl "swap" invocations to prevent duplicate work

Tested using FTL (steam): SwapBuffers ultimately calls wgl_swap_buffers
causing an additional copy which just isn't necessary

This also causes game capture to sometimes capture overlays even when
not intended
上级 f8fcba2f
......@@ -30,6 +30,7 @@ static struct func_hook wgl_delete_context;
static bool darkest_dungeon_fix = false;
struct gl_data {
int swap_recurse;
HDC hdc;
uint32_t base_cx;
uint32_t base_cy;
......@@ -773,20 +774,36 @@ static void gl_capture(HDC hdc)
}
}
static BOOL WINAPI hook_swap_buffers(HDC hdc)
static inline void gl_swap_begin(HDC hdc)
{
BOOL ret;
if (data.swap_recurse++)
return;
if (!global_hook_info->capture_overlay)
gl_capture(hdc);
}
static inline void gl_swap_end(HDC hdc)
{
if (--data.swap_recurse)
return;
if (global_hook_info->capture_overlay)
gl_capture(hdc);
}
static BOOL WINAPI hook_swap_buffers(HDC hdc)
{
BOOL ret;
gl_swap_begin(hdc);
unhook(&swap_buffers);
BOOL (WINAPI *call)(HDC) = swap_buffers.call_addr;
ret = call(hdc);
rehook(&swap_buffers);
if (global_hook_info->capture_overlay)
gl_capture(hdc);
gl_swap_end(hdc);
return ret;
}
......@@ -795,16 +812,15 @@ static BOOL WINAPI hook_wgl_swap_buffers(HDC hdc)
{
BOOL ret;
if (!global_hook_info->capture_overlay)
gl_capture(hdc);
gl_swap_begin(hdc);
unhook(&wgl_swap_buffers);
BOOL (WINAPI *call)(HDC) = wgl_swap_buffers.call_addr;
ret = call(hdc);
rehook(&wgl_swap_buffers);
if (global_hook_info->capture_overlay)
gl_capture(hdc);
gl_swap_end(hdc);
return ret;
}
......@@ -813,16 +829,15 @@ static BOOL WINAPI hook_wgl_swap_layer_buffers(HDC hdc, UINT planes)
{
BOOL ret;
if (!global_hook_info->capture_overlay)
gl_capture(hdc);
gl_swap_begin(hdc);
unhook(&wgl_swap_layer_buffers);
BOOL (WINAPI *call)(HDC, UINT) = wgl_swap_layer_buffers.call_addr;
ret = call(hdc, planes);
rehook(&wgl_swap_layer_buffers);
if (global_hook_info->capture_overlay)
gl_capture(hdc);
gl_swap_end(hdc);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册