#include "vk_common_entrypoints.h"
#include "wsi_common_entrypoints.h"
-static void
-radv_rra_handle_trace(VkQueue _queue)
-{
- RADV_FROM_HANDLE(radv_queue, queue, _queue);
-
- simple_mtx_lock(&queue->device->rra_trace.data_mtx);
- /*
- * TODO: This code is shared with RGP tracing and could be merged in a common helper.
- */
- bool frame_trigger = queue->device->rra_trace.elapsed_frames == queue->device->rra_trace.trace_frame;
- if (queue->device->rra_trace.elapsed_frames <= queue->device->rra_trace.trace_frame)
- ++queue->device->rra_trace.elapsed_frames;
-
- bool file_trigger = false;
-#ifndef _WIN32
- if (queue->device->rra_trace.trigger_file && access(queue->device->rra_trace.trigger_file, W_OK) == 0) {
- if (unlink(queue->device->rra_trace.trigger_file) == 0) {
- file_trigger = true;
- } else {
- /* Do not enable tracing if we cannot remove the file,
- * because by then we'll trace every frame ... */
- fprintf(stderr, "radv: could not remove RRA trace trigger file, ignoring\n");
- }
- }
-#endif
-
- if (!frame_trigger && !file_trigger) {
- simple_mtx_unlock(&queue->device->rra_trace.data_mtx);
- return;
- }
-
- if (_mesa_hash_table_num_entries(queue->device->rra_trace.accel_structs) == 0) {
- fprintf(stderr, "radv: No acceleration structures captured, not saving RRA trace.\n");
- simple_mtx_unlock(&queue->device->rra_trace.data_mtx);
- return;
- }
-
- char filename[2048];
- struct tm now;
- time_t t;
-
- t = time(NULL);
- now = *localtime(&t);
-
- snprintf(filename, sizeof(filename), "/tmp/%s_%04d.%02d.%02d_%02d.%02d.%02d.rra", util_get_process_name(),
- 1900 + now.tm_year, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec);
-
- VkResult result = radv_rra_dump_trace(_queue, filename);
-
- if (result == VK_SUCCESS)
- fprintf(stderr, "radv: RRA capture saved to '%s'\n", filename);
- else
- fprintf(stderr, "radv: Failed to save RRA capture!\n");
-
- simple_mtx_unlock(&queue->device->rra_trace.data_mtx);
-}
-
VKAPI_ATTR VkResult VKAPI_CALL
rra_QueuePresentKHR(VkQueue _queue, const VkPresentInfoKHR *pPresentInfo)
{
if (result != VK_SUCCESS)
return result;
- radv_rra_handle_trace(_queue);
-
if (!queue->device->rra_trace.copy_after_build)
return VK_SUCCESS;
#include "util/os_time.h"
#include "util/timespec.h"
#include "util/u_atomic.h"
+#include "util/u_process.h"
#include "vulkan/vk_icd.h"
#include "winsys/null/radv_null_winsys_public.h"
#include "git_sha1.h"
if (radv_sqtt_enabled())
add_entrypoints(&b, &sqtt_device_entrypoints, RADV_RGP_DISPATCH_TABLE);
- if (radv_rra_trace_enabled() && radv_enable_rt(physical_device, false))
+ if ((physical_device->instance->vk.trace_mode & RADV_TRACE_MODE_RRA) && radv_enable_rt(physical_device, false))
add_entrypoints(&b, &rra_device_entrypoints, RADV_RRA_DISPATCH_TABLE);
#ifndef _WIN32
return VK_SUCCESS;
}
+static VkResult
+capture_trace(VkQueue _queue)
+{
+ RADV_FROM_HANDLE(radv_queue, queue, _queue);
+
+ VkResult result = VK_SUCCESS;
+
+ char filename[2048];
+ struct tm now;
+ time_t t;
+
+ t = time(NULL);
+ now = *localtime(&t);
+
+ if (queue->device->instance->vk.trace_mode & RADV_TRACE_MODE_RRA) {
+ if (_mesa_hash_table_num_entries(queue->device->rra_trace.accel_structs) == 0) {
+ fprintf(stderr, "radv: No acceleration structures captured, not saving RRA trace.\n");
+ } else {
+ snprintf(filename, sizeof(filename), "/tmp/%s_%04d.%02d.%02d_%02d.%02d.%02d.rra", util_get_process_name(),
+ 1900 + now.tm_year, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec);
+
+ result = radv_rra_dump_trace(_queue, filename);
+
+ if (result == VK_SUCCESS)
+ fprintf(stderr, "radv: RRA capture saved to '%s'\n", filename);
+ else
+ fprintf(stderr, "radv: Failed to save RRA capture!\n");
+ }
+ }
+
+ return result;
+}
+
VKAPI_ATTR VkResult VKAPI_CALL
radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice)
init_dispatch_tables(device, physical_device);
+ device->vk.capture_trace = capture_trace;
+
device->vk.command_buffer_ops = &radv_cmd_buffer_ops;
device->vk.check_status = radv_check_status;
}
}
- if (radv_rra_trace_enabled() && radv_enable_rt(physical_device, false)) {
+ if ((device->instance->vk.trace_mode & RADV_TRACE_MODE_RRA) && radv_enable_rt(physical_device, false)) {
radv_rra_trace_init(device);
}
radv_GetPhysicalDeviceToolProperties(VkPhysicalDevice physicalDevice, uint32_t *pToolCount,
VkPhysicalDeviceToolProperties *pToolProperties)
{
+ VK_FROM_HANDLE(radv_physical_device, pdevice, physicalDevice);
+
VK_OUTARRAY_MAKE_TYPED(VkPhysicalDeviceToolProperties, out, pToolProperties, pToolCount);
bool rgp_enabled, rmv_enabled, rra_enabled;
uint32_t tool_count = 0;
tool_count++;
/* RRA */
- rra_enabled = radv_rra_trace_enabled();
+ rra_enabled = pdevice->instance->vk.trace_mode & RADV_TRACE_MODE_RRA;
if (rra_enabled)
tool_count++;
void radv_destroy_rra_accel_struct_data(VkDevice device, struct radv_rra_accel_struct_data *data);
struct radv_rra_trace_data {
- int elapsed_frames;
- int trace_frame;
- char *trigger_file;
struct hash_table *accel_structs;
struct hash_table_u64 *accel_struct_vas;
simple_mtx_t data_mtx;
void radv_emit_inhibit_clockgating(const struct radv_device *device, struct radeon_cmdbuf *cs, bool inhibit);
void radv_emit_spi_config_cntl(const struct radv_device *device, struct radeon_cmdbuf *cs, bool enable);
-int radv_rra_trace_frame(void);
-char *radv_rra_trace_trigger_file(void);
-bool radv_rra_trace_enabled(void);
-
void radv_rra_trace_init(struct radv_device *device);
VkResult radv_rra_dump_trace(VkQueue vk_queue, char *filename);
return result;
}
-int
-radv_rra_trace_frame()
-{
- return (int)debug_get_num_option("RADV_RRA_TRACE", -1);
-}
-
-char *
-radv_rra_trace_trigger_file()
-{
- return getenv("RADV_RRA_TRACE_TRIGGER");
-}
-
-bool
-radv_rra_trace_enabled()
-{
- return radv_rra_trace_frame() != -1 || radv_rra_trace_trigger_file();
-}
-
void
radv_rra_trace_init(struct radv_device *device)
{
- device->rra_trace.trace_frame = radv_rra_trace_frame();
- device->rra_trace.elapsed_frames = 0;
- device->rra_trace.trigger_file = radv_rra_trace_trigger_file();
device->rra_trace.validate_as = debug_get_bool_option("RADV_RRA_TRACE_VALIDATE", false);
device->rra_trace.copy_after_build = debug_get_bool_option("RADV_RRA_TRACE_COPY_AFTER_BUILD", false);
device->rra_trace.accel_structs = _mesa_pointer_hash_table_create(NULL);