graphics-hook: Track DXGI status with counter

Previous approach could mark Present exit too early.
This commit is contained in:
jpark37 2022-07-29 21:04:15 -07:00 committed by Jim
parent dfb9bb74f7
commit 4c7c1854bd
2 changed files with 7 additions and 7 deletions

View File

@ -45,7 +45,7 @@ struct d3d12_data {
static struct d3d12_data data = {}; static struct d3d12_data data = {};
extern thread_local bool dxgi_presenting; extern thread_local int dxgi_presenting;
extern ID3D12CommandQueue *dxgi_possible_swap_queues[8]; extern ID3D12CommandQueue *dxgi_possible_swap_queues[8];
extern size_t dxgi_possible_swap_queue_count; extern size_t dxgi_possible_swap_queue_count;
extern bool dxgi_present_attempted; extern bool dxgi_present_attempted;
@ -375,7 +375,7 @@ hook_execute_command_lists(ID3D12CommandQueue *queue, UINT NumCommandLists,
if (dxgi_possible_swap_queue_count < if (dxgi_possible_swap_queue_count <
_countof(dxgi_possible_swap_queues)) { _countof(dxgi_possible_swap_queues)) {
if (dxgi_presenting && if ((dxgi_presenting > 0) &&
(queue->GetDesc().Type == D3D12_COMMAND_LIST_TYPE_DIRECT)) { (queue->GetDesc().Type == D3D12_COMMAND_LIST_TYPE_DIRECT)) {
if (try_append_queue_if_unique(queue)) { if (try_append_queue_if_unique(queue)) {
hlog("Remembering D3D12 queue from present: queue=0x%" PRIX64, hlog("Remembering D3D12 queue from present: queue=0x%" PRIX64,

View File

@ -25,7 +25,7 @@ resize_buffers_t RealResizeBuffers = nullptr;
present_t RealPresent = nullptr; present_t RealPresent = nullptr;
present1_t RealPresent1 = nullptr; present1_t RealPresent1 = nullptr;
thread_local bool dxgi_presenting = false; thread_local int dxgi_presenting = 0;
struct ID3D12CommandQueue *dxgi_possible_swap_queues[8]{}; struct ID3D12CommandQueue *dxgi_possible_swap_queues[8]{};
size_t dxgi_possible_swap_queue_count; size_t dxgi_possible_swap_queue_count;
bool dxgi_present_attempted = false; bool dxgi_present_attempted = false;
@ -230,9 +230,9 @@ static HRESULT STDMETHODCALLTYPE hook_present(IDXGISwapChain *swap,
} }
} }
dxgi_presenting = true; ++dxgi_presenting;
const HRESULT hr = RealPresent(swap, sync_interval, flags); const HRESULT hr = RealPresent(swap, sync_interval, flags);
dxgi_presenting = false; --dxgi_presenting;
dxgi_present_attempted = true; dxgi_present_attempted = true;
if (capture && capture_overlay) { if (capture && capture_overlay) {
@ -297,9 +297,9 @@ hook_present1(IDXGISwapChain1 *swap, UINT sync_interval, UINT flags,
} }
} }
dxgi_presenting = true; ++dxgi_presenting;
const HRESULT hr = RealPresent1(swap, sync_interval, flags, params); const HRESULT hr = RealPresent1(swap, sync_interval, flags, params);
dxgi_presenting = false; --dxgi_presenting;
dxgi_present_attempted = true; dxgi_present_attempted = true;
if (capture && capture_overlay) { if (capture && capture_overlay) {