From a1185d09f0691365d56ff1e509ed711167d1f164 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 10 Feb 2021 14:18:11 +0100 Subject: [PATCH] radv: add support for resizing the SQTT buffer automatically The buffer is resized when too small, the 150% limit is arbitrary and works in most cases. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_sqtt.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/amd/vulkan/radv_sqtt.c b/src/amd/vulkan/radv_sqtt.c index 0947f27e31d..0099688c6d6 100644 --- a/src/amd/vulkan/radv_sqtt.c +++ b/src/amd/vulkan/radv_sqtt.c @@ -550,6 +550,25 @@ radv_thread_trace_finish(struct radv_device *device) } } +static bool +radv_thread_trace_resize_bo(struct radv_device *device, uint32_t expected_size) +{ + /* Resize the trace buffer BO by 150% of the expected size to be sure + * it will be enough. + */ + device->thread_trace.buffer_size = expected_size * 1.50; + + /* Cleanup and re-initialize thread trace. */ + radv_thread_trace_finish(device); + if (!radv_thread_trace_init(device)) + return false; + + fprintf(stderr, "The thread trace buffer has been resized to %d KB " + "per SE ! Please try again.\n", + device->thread_trace.buffer_size / 1024); + return true; +} + bool radv_begin_thread_trace(struct radv_queue *queue) { @@ -597,8 +616,11 @@ radv_get_thread_trace(struct radv_queue *queue, "hardware needs %d KB per SE but the " "buffer size is %d KB.\n", expected_size, available_size); - fprintf(stderr, "Please update the buffer size with " - "RADV_THREAD_TRACE_BUFFER_SIZE=\n"); + if (!radv_thread_trace_resize_bo(device, expected_size * 1024)) { + fprintf(stderr, "Failed to resize the thread " + "trace buffer.\n"); + abort(); + } return false; }