Skip to content

Commit

Permalink
vkd3d: Add implementation of a queue timeline.
Browse files Browse the repository at this point in the history
The purpose of this is to get a high-level glance of:

- CPU / GPU overlap
- Latency
- Being able to correlate performance against events which may lead to
  stutter such as resource allocations, etc.

The format is the trivial JSON format supported by Chromium
chrome://tracing.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
  • Loading branch information
HansKristian-Work committed Nov 18, 2023
1 parent 3c79b87 commit 38bea1c
Show file tree
Hide file tree
Showing 9 changed files with 864 additions and 42 deletions.
142 changes: 110 additions & 32 deletions libs/vkd3d/command.c

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions libs/vkd3d/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -3278,6 +3278,7 @@ static void d3d12_device_destroy(struct d3d12_device *device)

vkd3d_cleanup_format_info(device);
vkd3d_memory_info_cleanup(&device->memory_info, device);
vkd3d_queue_timeline_trace_cleanup(&device->queue_timeline_trace);
vkd3d_shader_debug_ring_cleanup(&device->debug_ring, device);
#ifdef VKD3D_ENABLE_BREADCRUMBS
vkd3d_breadcrumb_tracer_cleanup_barrier_hashes(&device->breadcrumb_tracer);
Expand Down Expand Up @@ -8296,13 +8297,16 @@ static HRESULT d3d12_device_init(struct d3d12_device *device,
if (FAILED(hr = vkd3d_shader_debug_ring_init(&device->debug_ring, device)))
goto out_cleanup_meta_ops;

if (FAILED(hr = vkd3d_queue_timeline_trace_init(&device->queue_timeline_trace)))
goto out_cleanup_debug_ring;

vkd3d_scratch_pool_init(device);

#ifdef VKD3D_ENABLE_BREADCRUMBS
vkd3d_breadcrumb_tracer_init_barrier_hashes(&device->breadcrumb_tracer);
if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_BREADCRUMBS)
if (FAILED(hr = vkd3d_breadcrumb_tracer_init(&device->breadcrumb_tracer, device)))
goto out_cleanup_debug_ring;
goto out_cleanup_queue_timeline_trace;
#endif

if (vkd3d_descriptor_debug_active_qa_checks())
Expand Down Expand Up @@ -8349,9 +8353,11 @@ static HRESULT d3d12_device_init(struct d3d12_device *device,
#ifdef VKD3D_ENABLE_BREADCRUMBS
if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_BREADCRUMBS)
vkd3d_breadcrumb_tracer_cleanup(&device->breadcrumb_tracer, device);
out_cleanup_debug_ring:
out_cleanup_queue_timeline_trace:
vkd3d_breadcrumb_tracer_cleanup_barrier_hashes(&device->breadcrumb_tracer);
vkd3d_queue_timeline_trace_cleanup(&device->queue_timeline_trace);
#endif
out_cleanup_debug_ring:
vkd3d_shader_debug_ring_cleanup(&device->debug_ring, device);
out_cleanup_meta_ops:
vkd3d_meta_ops_cleanup(&device->meta_ops, device);
Expand Down
3 changes: 3 additions & 0 deletions libs/vkd3d/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ static HRESULT d3d12_heap_init(struct d3d12_heap *heap, struct d3d12_device *dev
heap->allocation.chunk == NULL /* not suballocated */ &&
(device->memory_properties.memoryTypes[heap->allocation.device_allocation.vk_memory_type].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);

vkd3d_queue_timeline_trace_register_instantaneous(&device->queue_timeline_trace,
VKD3D_QUEUE_TIMELINE_TRACE_STATE_TYPE_HEAP_ALLOCATION, desc->SizeInBytes);

d3d12_device_add_ref(heap->device);
return S_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion libs/vkd3d/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ static HRESULT vkd3d_memory_transfer_queue_flush_locked(struct vkd3d_memory_tran
vkd3d_queue_add_wait(queue_family->queues[i],
NULL,
queue->vk_semaphore,
queue->next_signal_value);
queue->next_signal_value, 0);
}
}

Expand Down
3 changes: 2 additions & 1 deletion libs/vkd3d/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ vkd3d_src = [
'vkd3d_main.c',
'raytracing_pipeline.c',
'acceleration_structure.c',
'swapchain.c'
'swapchain.c',
'queue_timeline.c'
]

if enable_renderdoc
Expand Down
Loading

0 comments on commit 38bea1c

Please sign in to comment.