For more code isolation.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22707>
static_assert(sizeof(struct sqtt_file_chunk_spm_db) == 32,
"sqtt_file_chunk_spm_db doesn't match RGP spec");
-static void ac_sqtt_fill_spm_db(const struct ac_spm_trace_data *spm_trace,
+static void ac_sqtt_fill_spm_db(const struct ac_spm_trace *spm_trace,
struct sqtt_file_chunk_spm_db *chunk,
uint32_t num_samples,
uint32_t chunk_size)
chunk->sample_interval = spm_trace->sample_interval;
}
-static void ac_sqtt_dump_spm(const struct ac_spm_trace_data *spm_trace,
+static void ac_sqtt_dump_spm(const struct ac_spm_trace *spm_trace,
size_t file_offset,
FILE *output)
{
- uint32_t sample_size_in_bytes = ac_spm_get_sample_size(spm_trace);
- uint32_t num_samples = ac_spm_get_num_samples(spm_trace);
+ uint32_t sample_size_in_bytes = spm_trace->sample_size_in_bytes;
+ uint32_t num_samples = spm_trace->num_samples;
uint8_t *spm_data_ptr = (uint8_t *)spm_trace->ptr;
struct sqtt_file_chunk_spm_db spm_db;
size_t file_spm_db_offset = file_offset;
#if defined(USE_LIBELF)
static void ac_sqtt_dump_data(struct radeon_info *rad_info,
struct ac_thread_trace *thread_trace,
- const struct ac_spm_trace_data *spm_trace,
+ const struct ac_spm_trace *spm_trace,
FILE *output)
{
struct ac_thread_trace_data *thread_trace_data = thread_trace->data;
int ac_dump_rgp_capture(struct radeon_info *info,
struct ac_thread_trace *thread_trace,
- const struct ac_spm_trace_data *spm_trace)
+ const struct ac_spm_trace *spm_trace)
{
#if !defined(USE_LIBELF)
return -1;
struct radeon_info;
struct ac_thread_trace;
struct ac_thread_trace_data;
-struct ac_spm_trace_data;
+struct ac_spm_trace;
enum rgp_hardware_stages {
RGP_HW_STAGE_VS = 0,
int
ac_dump_rgp_capture(struct radeon_info *info,
struct ac_thread_trace *thread_trace,
- const struct ac_spm_trace_data *spm_trace);
+ const struct ac_spm_trace *spm_trace);
void
ac_rgp_file_write_elf_object(FILE *output, size_t file_elf_start,
FREE(spm_trace->counters);
}
-uint32_t ac_spm_get_sample_size(const struct ac_spm_trace_data *spm_trace)
+static uint32_t ac_spm_get_sample_size(const struct ac_spm_trace_data *spm_trace)
{
uint32_t sample_size = 0; /* in bytes */
return sample_size;
}
-uint32_t ac_spm_get_num_samples(const struct ac_spm_trace_data *spm_trace)
+static uint32_t ac_spm_get_num_samples(const struct ac_spm_trace_data *spm_trace)
{
uint32_t sample_size = ac_spm_get_sample_size(spm_trace);
uint32_t *ptr = (uint32_t *)spm_trace->ptr;
return num_samples;
}
+
+void ac_spm_get_trace(const struct ac_spm_trace_data *spm,
+ struct ac_spm_trace *trace)
+{
+ memset(trace, 0, sizeof(*trace));
+
+ trace->ptr = spm->ptr;
+ trace->sample_interval = spm->sample_interval;
+ trace->num_counters = spm->num_counters;
+ trace->counters = spm->counters;
+ trace->sample_size_in_bytes = ac_spm_get_sample_size(spm);
+ trace->num_samples = ac_spm_get_num_samples(spm);
+}
struct ac_spm_muxsel_line *muxsel_lines[AC_SPM_SEGMENT_TYPE_COUNT];
};
+struct ac_spm_trace {
+ void *ptr;
+ uint16_t sample_interval;
+ unsigned num_counters;
+ struct ac_spm_counter_info *counters;
+ uint32_t sample_size_in_bytes;
+ uint32_t num_samples;
+};
+
bool ac_init_spm(const struct radeon_info *info,
const struct ac_perfcounters *pc,
unsigned num_counters,
struct ac_spm_trace_data *spm_trace);
void ac_destroy_spm(struct ac_spm_trace_data *spm_trace);
-uint32_t ac_spm_get_sample_size(const struct ac_spm_trace_data *spm_trace);
-uint32_t ac_spm_get_num_samples(const struct ac_spm_trace_data *spm_trace);
+void ac_spm_get_trace(const struct ac_spm_trace_data *spm,
+ struct ac_spm_trace *trace);
#endif
queue->device->vk.dispatch_table.QueueWaitIdle(_queue);
if (radv_get_thread_trace(queue, &thread_trace)) {
- struct ac_spm_trace_data *spm_trace = NULL;
+ struct ac_spm_trace spm_trace;
if (queue->device->spm_trace.bo)
- spm_trace = &queue->device->spm_trace;
+ ac_spm_get_trace(&queue->device->spm_trace, &spm_trace);
- ac_dump_rgp_capture(&queue->device->physical_device->rad_info, &thread_trace, spm_trace);
+ ac_dump_rgp_capture(&queue->device->physical_device->rad_info, &thread_trace,
+ queue->device->spm_trace.bo ? &spm_trace : NULL);
} else {
/* Trigger a new capture if the driver failed to get
* the trace because the buffer was too small.
/* Wait for SQTT to finish and read back the bo */
if (sctx->ws->fence_wait(sctx->ws, sctx->last_sqtt_fence, PIPE_TIMEOUT_INFINITE) &&
si_get_thread_trace(sctx, &thread_trace)) {
+ struct ac_spm_trace spm_trace;
+
/* Map the SPM counter buffer */
- if (sctx->spm_trace.bo)
+ if (sctx->spm_trace.bo) {
sctx->spm_trace.ptr = sctx->ws->buffer_map(sctx->ws, sctx->spm_trace.bo,
NULL, PIPE_MAP_READ | RADEON_MAP_TEMPORARY);
+ ac_spm_get_trace(&sctx->spm_trace, &spm_trace);
+ }
- ac_dump_rgp_capture(&sctx->screen->info, &thread_trace, sctx->spm_trace.bo ? &sctx->spm_trace : NULL);
+ ac_dump_rgp_capture(&sctx->screen->info, &thread_trace, sctx->spm_trace.bo ? &spm_trace : NULL);
if (sctx->spm_trace.ptr)
sctx->ws->buffer_unmap(sctx->ws, sctx->spm_trace.bo);