mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 11:18:08 +02:00
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 <samuel.pitoiset@gmail.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4180> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4180>
This commit is contained in:
parent
4061ac859d
commit
e1b08b55ff
2 changed files with 49 additions and 44 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue