radv_emit_sqtt_userdata(cmd_buffer, &marker, sizeof(marker) / 4);
}
-/* TODO: Improve the way to trigger capture (overlay, etc). */
static void
radv_handle_sqtt(VkQueue _queue)
{
RADV_FROM_HANDLE(radv_queue, queue, _queue);
- static bool sqtt_enabled = false;
- static uint64_t num_frames = 0;
- bool resize_trigger = false;
- if (sqtt_enabled) {
+ bool trigger = queue->device->sqtt_triggered;
+ queue->device->sqtt_triggered = false;
+
+ if (queue->device->sqtt_enabled) {
struct ac_sqtt_trace sqtt_trace = {0};
radv_end_sqtt(queue);
- sqtt_enabled = false;
+ queue->device->sqtt_enabled = false;
/* TODO: Do something better than this whole sync. */
queue->device->vk.dispatch_table.QueueWaitIdle(_queue);
/* Trigger a new capture if the driver failed to get
* the trace because the buffer was too small.
*/
- resize_trigger = true;
+ trigger = true;
}
/* Clear resources used for this capture. */
radv_reset_sqtt_trace(queue->device);
}
- if (!sqtt_enabled) {
- bool frame_trigger = num_frames == queue->device->sqtt.start_frame;
- bool file_trigger = false;
-#ifndef _WIN32
- if (queue->device->sqtt.trigger_file && access(queue->device->sqtt.trigger_file, W_OK) == 0) {
- if (unlink(queue->device->sqtt.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 thread trace trigger file, ignoring\n");
- }
+ if (trigger) {
+ if (ac_check_profile_state(&queue->device->physical_device->rad_info)) {
+ fprintf(stderr, "radv: Canceling RGP trace request as a hang condition has been "
+ "detected. Force the GPU into a profiling mode with e.g. "
+ "\"echo profile_peak > "
+ "/sys/class/drm/card0/device/power_dpm_force_performance_level\"\n");
+ return;
}
-#endif
-
- if (frame_trigger || file_trigger || resize_trigger) {
- if (ac_check_profile_state(&queue->device->physical_device->rad_info)) {
- fprintf(stderr, "radv: Canceling RGP trace request as a hang condition has been "
- "detected. Force the GPU into a profiling mode with e.g. "
- "\"echo profile_peak > "
- "/sys/class/drm/card0/device/power_dpm_force_performance_level\"\n");
- return;
- }
- /* Sample CPU/GPU clocks before starting the trace. */
- if (!radv_sqtt_sample_clocks(queue->device)) {
- fprintf(stderr, "radv: Failed to sample clocks\n");
- }
-
- radv_begin_sqtt(queue);
- assert(!sqtt_enabled);
- sqtt_enabled = true;
- }
+ radv_begin_sqtt(queue);
+ assert(!queue->device->sqtt_enabled);
+ queue->device->sqtt_enabled = true;
}
- num_frames++;
}
VKAPI_ATTR VkResult VKAPI_CALL
#endif
static bool
-radv_spm_trace_enabled()
+radv_spm_trace_enabled(struct radv_instance *instance)
{
- return radv_sqtt_enabled() && debug_get_bool_option("RADV_THREAD_TRACE_CACHE_COUNTERS", true);
+ return (instance->vk.trace_mode == RADV_TRACE_MODE_RGP) &&
+ debug_get_bool_option("RADV_THREAD_TRACE_CACHE_COUNTERS", true);
}
VKAPI_ATTR VkResult VKAPI_CALL
add_entrypoints(&b, &rage2_device_entrypoints, RADV_APP_DISPATCH_TABLE);
}
- if (radv_sqtt_enabled())
+ if (physical_device->instance->vk.trace_mode & RADV_TRACE_MODE_RGP)
add_entrypoints(&b, &sqtt_device_entrypoints, RADV_RGP_DISPATCH_TABLE);
if ((physical_device->instance->vk.trace_mode & RADV_TRACE_MODE_RRA) && radv_enable_rt(physical_device, false))
}
}
+ if (queue->device->instance->vk.trace_mode & RADV_TRACE_MODE_RGP)
+ queue->device->sqtt_triggered = true;
+
return result;
}
radv_dump_enabled_options(device, stderr);
}
- if (radv_sqtt_enabled()) {
+ if (device->instance->vk.trace_mode & RADV_TRACE_MODE_RGP) {
if (device->physical_device->rad_info.gfx_level < GFX8 || device->physical_device->rad_info.gfx_level > GFX11) {
fprintf(stderr, "GPU hardware not supported: refer to "
"the RGP documentation for the list of "
"radv: Thread trace support is enabled (initial buffer size: %u MiB, "
"instruction timing: %s, cache counters: %s).\n",
device->sqtt.buffer_size / (1024 * 1024), radv_is_instruction_timing_enabled() ? "enabled" : "disabled",
- radv_spm_trace_enabled() ? "enabled" : "disabled");
+ radv_spm_trace_enabled(device->instance) ? "enabled" : "disabled");
- if (radv_spm_trace_enabled()) {
+ if (radv_spm_trace_enabled(device->instance)) {
/* TODO: add SPM counters for GFX11. */
if (device->physical_device->rad_info.gfx_level == GFX10 ||
device->physical_device->rad_info.gfx_level == GFX10_3) {
#endif
};
+static void
+radv_handle_legacy_sqtt_trigger(struct vk_instance *instance)
+{
+ char *trigger_file = getenv("RADV_THREAD_TRACE_TRIGGER");
+ if (trigger_file) {
+ instance->trace_trigger_file = trigger_file;
+ instance->trace_mode |= RADV_TRACE_MODE_RGP;
+ fprintf(stderr, "WARNING: RADV_THREAD_TRACE_TRIGGER is deprecated, please use MESA_VK_TRACE_TRIGGER instead.\n");
+ }
+}
+
VKAPI_ATTR VkResult VKAPI_CALL
radv_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
VkInstance *pInstance)
}
vk_instance_add_driver_trace_modes(&instance->vk, trace_options);
+ radv_handle_legacy_sqtt_trigger(&instance->vk);
instance->debug_flags = parse_debug_string(getenv("RADV_DEBUG"), radv_debug_options);
instance->perftest_flags = parse_debug_string(getenv("RADV_PERFTEST"), radv_perftest_options);
#include "ac_llvm_util.h"
#endif
-bool
-radv_sqtt_enabled(void)
-{
- return debug_get_num_option("RADV_THREAD_TRACE", -1) >= 0 || getenv("RADV_THREAD_TRACE_TRIGGER");
-}
-
static bool
radv_perf_query_supported(const struct radv_physical_device *pdev)
{
/* SQTT / SPM interfere with the register states for perf counters, and
* the code has only been tested on GFX10.3 */
- return pdev->rad_info.gfx_level == GFX10_3 && !radv_sqtt_enabled();
+ return pdev->rad_info.gfx_level == GFX10_3 && !(pdev->instance->vk.trace_mode & RADV_TRACE_MODE_RGP);
}
static bool
.EXT_conditional_rendering = true,
.EXT_conservative_rasterization = device->rad_info.gfx_level >= GFX9,
.EXT_custom_border_color = true,
- .EXT_debug_marker = radv_sqtt_enabled(),
+ .EXT_debug_marker = device->instance->vk.trace_mode & RADV_TRACE_MODE_RGP,
.EXT_depth_bias_control = true,
.EXT_depth_clip_control = true,
.EXT_depth_clip_enable = true,
device->ws = radv_null_winsys_create();
#else
if (drm_device) {
- bool reserve_vmid = radv_sqtt_enabled();
+ bool reserve_vmid = instance->vk.trace_mode & RADV_TRACE_MODE_RGP;
device->ws = radv_amdgpu_winsys_create(fd, instance->debug_flags, instance->perftest_flags, reserve_vmid);
} else {
uint32_t tool_count = 0;
/* RGP */
- rgp_enabled = radv_sqtt_enabled();
+ rgp_enabled = pdevice->instance->vk.trace_mode & RADV_TRACE_MODE_RGP;
if (rgp_enabled)
tool_count++;
void radv_physical_device_destroy(struct vk_physical_device *vk_device);
-bool radv_sqtt_enabled(void);
-
enum radv_trace_mode {
/** Radeon GPU Profiler */
RADV_TRACE_MODE_RGP = 1 << VK_TRACE_MODE_COUNT,
/* Thread trace. */
struct ac_sqtt sqtt;
+ bool sqtt_enabled;
+ bool sqtt_triggered;
/* Memory trace. */
struct radv_memory_trace_data memory_trace;
/* Default buffer size set to 32MB per SE. */
device->sqtt.buffer_size = (uint32_t)debug_get_num_option("RADV_THREAD_TRACE_BUFFER_SIZE", 32 * 1024 * 1024);
- device->sqtt.start_frame = (int)debug_get_num_option("RADV_THREAD_TRACE", -1);
-
- const char *trigger_file = getenv("RADV_THREAD_TRACE_TRIGGER");
- if (trigger_file)
- device->sqtt.trigger_file = strdup(trigger_file);
if (!radv_sqtt_init_bo(device))
return false;
struct ac_sqtt *sqtt = &device->sqtt;
struct radeon_winsys *ws = device->ws;
- free(device->sqtt.trigger_file);
-
radv_sqtt_finish_bo(device);
for (unsigned i = 0; i < 2; i++) {