vk_rmv_log_misc_token(&device->vk, VK_RMV_MISC_EVENT_TYPE_PRESENT);
- simple_mtx_lock(&device->vk.memory_trace_data.token_mtx);
- radv_rmv_collect_trace_events(device);
- vk_rmv_handle_present_locked(&device->vk);
- simple_mtx_unlock(&device->vk.memory_trace_data.token_mtx);
-
return VK_SUCCESS;
}
add_entrypoints(&b, &rra_device_entrypoints, RADV_RRA_DISPATCH_TABLE);
#ifndef _WIN32
- if (vk_memory_trace_enabled())
+ if (physical_device->instance->vk.trace_mode & VK_TRACE_MODE_RMV)
add_entrypoints(&b, &rmv_device_entrypoints, RADV_RMV_DISPATCH_TABLE);
#endif
}
}
+ if (queue->device->vk.memory_trace_data.is_enabled) {
+ simple_mtx_lock(&queue->device->vk.memory_trace_data.token_mtx);
+ radv_rmv_collect_trace_events(queue->device);
+ vk_dump_rmv_capture(&queue->device->vk.memory_trace_data);
+ simple_mtx_unlock(&queue->device->vk.memory_trace_data.token_mtx);
+ }
+
if (queue->device->instance->vk.trace_mode & RADV_TRACE_MODE_RGP)
queue->device->sqtt_triggered = true;
}
#ifndef _WIN32
- if (vk_memory_trace_enabled()) {
+ if (physical_device->instance->vk.trace_mode & VK_TRACE_MODE_RMV) {
struct vk_rmv_device_info info;
memset(&info, 0, sizeof(struct vk_rmv_device_info));
radv_rmv_fill_device_info(physical_device, &info);
tool_count++;
/* RMV */
- rmv_enabled = vk_memory_trace_enabled();
+ rmv_enabled = pdevice->instance->vk.trace_mode & VK_TRACE_MODE_RMV;
if (rmv_enabled)
tool_count++;
util_dynarray_init(&device->memory_trace_data.tokens, NULL);
simple_mtx_init(&device->memory_trace_data.token_mtx, mtx_plain);
- device->memory_trace_data.trace_frame_idx = vk_memory_trace_frame();
- device->memory_trace_data.trigger_file_name = vk_memory_trace_trigger_file();
-
- device->memory_trace_data.cur_frame_idx = 0;
device->memory_trace_data.next_resource_id = 1;
device->memory_trace_data.handle_table = _mesa_hash_table_u64_create(NULL);
}
}
void
-vk_rmv_handle_present_locked(struct vk_device *device)
-{
- struct vk_memory_trace_data *trace_data = &device->memory_trace_data;
-
- if (!trace_data->is_enabled)
- return;
- bool frame_trigger = false;
- bool file_trigger = false;
-
-#ifndef _WIN32
- if (trace_data->trigger_file_name && access(trace_data->trigger_file_name, W_OK) == 0) {
- if (unlink(trace_data->trigger_file_name) == 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, "mesa: could not remove memory trace trigger "
- "file, ignoring\n");
- }
-#endif
-
- frame_trigger = trace_data->cur_frame_idx == trace_data->trace_frame_idx;
- if (trace_data->cur_frame_idx <= trace_data->trace_frame_idx)
- trace_data->cur_frame_idx++;
-
- if (file_trigger || frame_trigger)
- vk_dump_rmv_capture(trace_data);
-}
-
-void
vk_rmv_emit_token(struct vk_memory_trace_data *data, enum vk_rmv_token_type type, void *token_data)
{
struct vk_rmv_token token;
struct util_dynarray tokens;
simple_mtx_t token_mtx;
- int32_t cur_frame_idx;
- int32_t trace_frame_idx;
- const char *trigger_file_name;
-
bool is_enabled;
struct vk_rmv_device_info device_info;
struct vk_device;
-static inline int
-vk_memory_trace_frame()
-{
- return (int)debug_get_num_option("MESA_VK_MEMORY_TRACE", -1);
-}
-
-static inline const char *
-vk_memory_trace_trigger_file()
-{
- return getenv("MESA_VK_MEMORY_TRACE_TRIGGER");
-}
-
-static inline bool
-vk_memory_trace_enabled()
-{
- return vk_memory_trace_frame() != -1 || vk_memory_trace_trigger_file();
-}
-
void vk_memory_trace_init(struct vk_device *device, const struct vk_rmv_device_info *device_info);
void vk_memory_trace_finish(struct vk_device *device);
-/* The memory trace mutex should be locked when entering this function. */
-void vk_rmv_handle_present_locked(struct vk_device *device);
-
int vk_dump_rmv_capture(struct vk_memory_trace_data *data);
void vk_rmv_emit_token(struct vk_memory_trace_data *data, enum vk_rmv_token_type type,
(VK_API_VERSION_MAJOR(version) == 1 && VK_API_VERSION_MINOR(version) == 0)
static const struct debug_control trace_options[] = {
+ {"rmv", VK_TRACE_MODE_RMV},
{NULL, 0},
};
struct vk_physical_device;
enum vk_trace_mode {
+ /** Radeon Memory Visualizer */
+ VK_TRACE_MODE_RMV = 1 << 0,
+
/** Number of common trace modes. */
- VK_TRACE_MODE_COUNT = 0,
+ VK_TRACE_MODE_COUNT = 1,
};
/** Base struct for all `VkInstance` implementations