anv: Enable INTEL_MEASURE=cpu

Reviewed-by: Mark Janes <markjanes@swizzler.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21505>
This commit is contained in:
Felix DeGrood
2023-02-22 19:29:28 +00:00
committed by Marge Bot
parent 55ba4575be
commit 0417cfd7a0
+25 -6
View File
@@ -104,6 +104,10 @@ anv_measure_init(struct anv_cmd_buffer *cmd_buffer)
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
memset(measure, 0, batch_bytes);
cmd_buffer->measure = measure;
if(config->cpu_measure)
return;
ASSERTED VkResult result =
anv_device_alloc_bo(device, "measure data",
config->batch_size * sizeof(uint64_t),
@@ -112,8 +116,6 @@ anv_measure_init(struct anv_cmd_buffer *cmd_buffer)
(struct anv_bo**)&measure->bo);
measure->base.timestamps = measure->bo->map;
assert(result == VK_SUCCESS);
cmd_buffer->measure = measure;
}
static void
@@ -126,6 +128,7 @@ anv_measure_start_snapshot(struct anv_cmd_buffer *cmd_buffer,
struct anv_measure_batch *measure = cmd_buffer->measure;
struct anv_physical_device *device = cmd_buffer->device->physical;
struct intel_measure_device *measure_device = &device->measure_device;
struct intel_measure_config *config = config_from_command_buffer(cmd_buffer);
const unsigned device_frame = measure_device->frame;
@@ -148,6 +151,18 @@ anv_measure_start_snapshot(struct anv_cmd_buffer *cmd_buffer,
// framebuffer == 0 ); /* compute has no framebuffer */
unsigned index = measure->base.index++;
if (event_name == NULL)
event_name = intel_measure_snapshot_string(type);
if (config->cpu_measure) {
intel_measure_print_cpu_result(measure->base.frame,
measure->base.batch_count,
index/2,
measure->base.event_count,
count,
event_name);
return;
}
(*device->cmd_emit_timestamp)(batch, cmd_buffer->device,
(struct anv_address) {
@@ -155,9 +170,6 @@ anv_measure_start_snapshot(struct anv_cmd_buffer *cmd_buffer,
.offset = index * sizeof(uint64_t) },
ANV_TIMESTAMP_CAPTURE_AT_CS_STALL);
if (event_name == NULL)
event_name = intel_measure_snapshot_string(type);
struct intel_measure_snapshot *snapshot = &(measure->base.snapshots[index]);
memset(snapshot, 0, sizeof(*snapshot));
snapshot->type = type;
@@ -188,9 +200,12 @@ anv_measure_end_snapshot(struct anv_cmd_buffer *cmd_buffer,
struct anv_batch *batch = &cmd_buffer->batch;
struct anv_measure_batch *measure = cmd_buffer->measure;
struct anv_physical_device *device = cmd_buffer->device->physical;
struct intel_measure_config *config = config_from_command_buffer(cmd_buffer);
unsigned index = measure->base.index++;
assert(index % 2 == 1);
if (config->cpu_measure)
return;
(*device->cmd_emit_timestamp)(batch, cmd_buffer->device,
(struct anv_address) {
@@ -347,7 +362,8 @@ anv_measure_destroy(struct anv_cmd_buffer *cmd_buffer)
*/
intel_measure_gather(&physical->measure_device, &physical->info);
anv_device_release_bo(device, measure->bo);
if (measure->bo != NULL)
anv_device_release_bo(device, measure->bo);
vk_free(&cmd_buffer->vk.pool->alloc, measure);
cmd_buffer->measure = NULL;
}
@@ -402,6 +418,9 @@ _anv_measure_submit(struct anv_cmd_buffer *cmd_buffer)
base->event_count = 0;
}
if (config->cpu_measure)
return;
/* Mark the final timestamp as 'not completed'. This marker will be used
* to verify that rendering is complete.
*/