Commit e1b08b55 authored by Samuel Pitoiset's avatar Samuel Pitoiset Committed by Marge Bot
Browse files

radv/sqtt: handle thread trace capture in sqtt_QueuePresentKHR()



To avoid wasting CPU cycles when thread trace is not enabled.
Signed-off-by: Samuel Pitoiset's avatarSamuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen's avatarBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tested-by: Marge Bot <mesa/mesa!4180>
Part-of: <mesa/mesa!4180>
parent 4061ac85
......@@ -571,6 +571,50 @@ radv_describe_layout_transition(struct radv_cmd_buffer *cmd_buffer,
cmd_buffer->state.num_layout_transitions++;
}
/* 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 sqtt_QueuePresentKHR(
VkQueue _queue,
const VkPresentInfoKHR* pPresentInfo)
{
VkResult result;
result = radv_QueuePresentKHR(_queue, pPresentInfo);
if (result != VK_SUCCESS)
return result;
radv_handle_thread_trace(_queue);
return VK_SUCCESS;
}
#define EVENT_MARKER(cmd_name, args...) \
RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer); \
radv_write_begin_general_api_marker(cmd_buffer, ApiCmd##cmd_name); \
......
......@@ -269,55 +269,16 @@ VkResult radv_AcquireNextImage2KHR(
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);
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;
return wsi_common_queue_present(&queue->device->physical_device->wsi_device,
radv_device_to_handle(queue->device),
_queue,
queue->queue_family_index,
pPresentInfo);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment