radv_dump_enabled_options(device, stderr);
}
+ int radv_thread_trace = radv_get_int_debug_option("RADV_THREAD_TRACE", -1);
+ if (radv_thread_trace >= 0) {
+ fprintf(stderr, "*****************************************************************************\n");
+ fprintf(stderr, "* WARNING: Thread trace support is experimental and only supported on GFX9! *\n");
+ fprintf(stderr, "*****************************************************************************\n");
+
+ /* TODO: add support for more ASICs. */
+ assert(device->physical_device->rad_info.chip_class == GFX9);
+
+ /* Default buffer size set to 1MB per SE. */
+ device->thread_trace_buffer_size =
+ radv_get_int_debug_option("RADV_THREAD_TRACE_BUFFER_SIZE", 1024 * 1024);
+ device->thread_trace_start_frame = radv_thread_trace;
+
+ if (!radv_thread_trace_init(device))
+ goto fail;
+ }
+
/* Temporarily disable secure compile while we create meta shaders, etc */
uint8_t sc_threads = device->instance->num_sc_threads;
if (sc_threads)
fail:
radv_bo_list_finish(&device->bo_list);
+ radv_thread_trace_finish(device);
+
if (device->trace_bo)
device->ws->buffer_destroy(device->trace_bo);
pthread_cond_destroy(&device->timeline_cond);
radv_bo_list_finish(&device->bo_list);
+
+ radv_thread_trace_finish(device);
+
if (radv_device_use_secure_compile(device->instance)) {
for (unsigned i = 0; i < device->instance->num_sc_threads; i++ ) {
destroy_secure_compile_device(device, i);
return result;
}
+/* TODO: Improve the way to trigger capture (overlay, etc). */
+static void
+radv_handle_thread_trace(VkQueue _queue)
+{
+ RADV_FROM_HANDLE(radv_queue, queue, _queue);
+ static bool thread_trace_enabled = false;
+ static uint64_t num_frames = 0;
+
+ if (thread_trace_enabled) {
+ struct radv_thread_trace thread_trace = {};
+
+ radv_end_thread_trace(queue);
+ thread_trace_enabled = false;
+
+ /* TODO: Do something better than this whole sync. */
+ radv_QueueWaitIdle(_queue);
+
+ if (radv_get_thread_trace(queue, &thread_trace))
+ radv_dump_thread_trace(queue->device, &thread_trace);
+ } else {
+ if (num_frames == queue->device->thread_trace_start_frame) {
+ radv_begin_thread_trace(queue);
+ assert(!thread_trace_enabled);
+ thread_trace_enabled = true;
+ }
+ }
+ num_frames++;
+}
+
VkResult radv_QueuePresentKHR(
VkQueue _queue,
const VkPresentInfoKHR* pPresentInfo)
{
RADV_FROM_HANDLE(radv_queue, queue, _queue);
- return wsi_common_queue_present(&queue->device->physical_device->wsi_device,
- radv_device_to_handle(queue->device),
- _queue,
- queue->queue_family_index,
- pPresentInfo);
+ VkResult result;
+
+ result = wsi_common_queue_present(&queue->device->physical_device->wsi_device,
+ radv_device_to_handle(queue->device),
+ _queue,
+ queue->queue_family_index,
+ pPresentInfo);
+ if (result != VK_SUCCESS)
+ return result;
+
+ if (unlikely(queue->device->thread_trace_bo)) {
+ radv_handle_thread_trace(_queue);
+ }
+
+ return VK_SUCCESS;
}