Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement an adaptive internal latency handle. #1961

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions libs/vkd3d/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,22 @@ static void vkd3d_queue_push_waiters_to_worker_locked(struct vkd3d_queue *vkd3d_
}
}

static void vkd3d_queue_check_idle_state_locked(struct vkd3d_queue *vkd3d_queue, struct d3d12_device *device)
{
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
uint64_t counter = 0;

/* If there are no pending submissions, waits, or signals on this queue, we consider it to have gone idle.
* This is mostly interesting for the DIRECT queue since it is part of the heuristics for swapchain pacing. */
if (!vkd3d_queue->queue_has_been_idle && vkd3d_queue->submission_timeline_count)
{
vkd3d_queue->queue_has_been_idle =
VK_CALL(vkGetSemaphoreCounterValue(device->vk_device,
vkd3d_queue->submission_timeline, &counter)) == VK_SUCCESS &&
counter == vkd3d_queue->submission_timeline_count;
}
}

static void vkd3d_queue_flush_waiters(struct vkd3d_queue *vkd3d_queue,
struct vkd3d_fence_worker *worker,
const struct vkd3d_vk_device_procs *vk_procs)
Expand Down Expand Up @@ -413,6 +429,9 @@ static void vkd3d_queue_flush_waiters(struct vkd3d_queue *vkd3d_queue,
return;
}

if (worker)
vkd3d_queue_check_idle_state_locked(vkd3d_queue, worker->device);

signal_semaphore.sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO;
signal_semaphore.semaphore = vkd3d_queue->submission_timeline;
signal_semaphore.value = ++vkd3d_queue->submission_timeline_count;
Expand Down Expand Up @@ -17562,6 +17581,8 @@ static void d3d12_command_queue_signal_shared(struct d3d12_command_queue *comman
return;
}

vkd3d_queue_check_idle_state_locked(vkd3d_queue, device);

memset(&signal_semaphore_info, 0, sizeof(signal_semaphore_info));
signal_semaphore_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO;
signal_semaphore_info.semaphore = fence->timeline_semaphore;
Expand Down Expand Up @@ -17940,6 +17961,8 @@ static void d3d12_command_queue_execute(struct d3d12_command_queue *command_queu
return;
}

vkd3d_queue_check_idle_state_locked(vkd3d_queue, command_queue->device);

memset(&signal_semaphore_info, 0, sizeof(signal_semaphore_info));
signal_semaphore_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO;
signal_semaphore_info.semaphore = vkd3d_queue->submission_timeline;
Expand Down
Loading
Loading