Skip to content

Commit

Permalink
vkd3d: Skip redundant wait for fences in queue workers.
Browse files Browse the repository at this point in the history
Avoids an apparent NV performance bug on CPU.

Signed-off-by: Hans-Kristian Arntzen <[email protected]>
  • Loading branch information
HansKristian-Work committed Jan 6, 2025
1 parent b121e6d commit 9efbd38
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions libs/vkd3d/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -18007,13 +18007,20 @@ static void d3d12_command_queue_push_fence_waits_to_worker(struct d3d12_command_
cookie = vkd3d_queue_timeline_trace_register_wait(&worker->device->queue_timeline_trace,
&fence_wait->fence->ID3D12Fence_iface, fence_wait->virtual_value);

memset(&fence_info, 0, sizeof(fence_info));
fence_info.fence = &command_queue->wait_fences[i].fence->ID3D12Fence_iface;
fence_info.vk_semaphore = fence_wait->vk_semaphore;
fence_info.vk_semaphore_value = fence_wait->vk_semaphore_value;
/* Only wait for fence completion if we're interested in it for profiling purposes.
* Otherwise, there is no point in waiting on it since we resolved the wait to a vkd3d_queue internal timeline.
* This also functions as a performance workaround for NV since NV seems to dislike when the same timeline is
* waited on by multiple threads, which could happen in this code path. See issue 2256 for more details. */
if (vkd3d_queue_timeline_trace_cookie_is_valid(cookie))
{
memset(&fence_info, 0, sizeof(fence_info));
fence_info.fence = &fence_wait->fence->ID3D12Fence_iface;
fence_info.vk_semaphore = fence_wait->vk_semaphore;
fence_info.vk_semaphore_value = fence_wait->vk_semaphore_value;

if (FAILED(hr = vkd3d_enqueue_timeline_semaphore(worker, &fence_info, &cookie)))
ERR("Failed to enqueue timeline semaphore, hr %#x.\n", hr);
if (FAILED(hr = vkd3d_enqueue_timeline_semaphore(worker, &fence_info, &cookie)))
ERR("Failed to enqueue timeline semaphore, hr %#x.\n", hr);
}
}
}

Expand Down

0 comments on commit 9efbd38

Please sign in to comment.