anv: Emit CS stall on INTEL_MEASURE timestamp

For INTEL_MEASURE, ensure all prior instructions completed before
timestamp taken. Continue to support no CS flush case for Perfetto.
CS stall was dropped from pipecontrol when adding u_trace support.

Fixes: cc5843a573 ("anv: implement u_trace support")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20502>
(cherry picked from commit 7f6beb8537)
This commit is contained in:
Felix DeGrood 2023-01-03 19:22:30 +00:00 committed by Eric Engestrom
parent 052a2a47b3
commit 6893f2b5b4
6 changed files with 38 additions and 12 deletions

View file

@ -2605,7 +2605,7 @@
"description": "anv: Emit CS stall on INTEL_MEASURE timestamp",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "cc5843a573bd0412c547b4f2af3cce18263ecfd4"
},

View file

@ -150,7 +150,7 @@ void genX(blorp_exec)(struct blorp_batch *batch,
void genX(cmd_emit_timestamp)(struct anv_batch *batch,
struct anv_device *device,
struct anv_address addr,
bool end_of_pipe);
enum anv_timestamp_capture_type);
void genX(batch_emit_dummy_post_sync_op)(struct anv_batch *batch,
struct anv_device *device,

View file

@ -153,7 +153,7 @@ anv_measure_start_snapshot(struct anv_cmd_buffer *cmd_buffer,
(struct anv_address) {
.bo = measure->bo,
.offset = index * sizeof(uint64_t) },
true /* end_of_pipe */);
ANV_TIMESTAMP_CAPTURE_AT_CS_STALL);
if (event_name == NULL)
event_name = intel_measure_snapshot_string(type);
@ -196,7 +196,7 @@ anv_measure_end_snapshot(struct anv_cmd_buffer *cmd_buffer,
(struct anv_address) {
.bo = measure->bo,
.offset = index * sizeof(uint64_t) },
true /* end_of_pipe */);
ANV_TIMESTAMP_CAPTURE_AT_CS_STALL);
struct intel_measure_snapshot *snapshot = &(measure->base.snapshots[index]);
memset(snapshot, 0, sizeof(*snapshot));

View file

@ -953,6 +953,12 @@ struct anv_memregion {
uint64_t available;
};
enum anv_timestamp_capture_type {
ANV_TIMESTAMP_CAPTURE_TOP_OF_PIPE,
ANV_TIMESTAMP_CAPTURE_END_OF_PIPE,
ANV_TIMESTAMP_CAPTURE_AT_CS_STALL,
};
struct anv_physical_device {
struct vk_physical_device vk;
@ -1052,7 +1058,7 @@ struct anv_physical_device {
int64_t master_minor;
struct intel_query_engine_info * engine_info;
void (*cmd_emit_timestamp)(struct anv_batch *, struct anv_device *, struct anv_address, bool);
void (*cmd_emit_timestamp)(struct anv_batch *, struct anv_device *, struct anv_address, enum anv_timestamp_capture_type);
struct intel_measure_device measure_device;
};

View file

@ -227,11 +227,14 @@ anv_utrace_record_ts(struct u_trace *ut, void *cs,
struct anv_device *device = cmd_buffer->device;
struct anv_bo *bo = timestamps;
enum anv_timestamp_capture_type capture_type =
(end_of_pipe) ? ANV_TIMESTAMP_CAPTURE_END_OF_PIPE
: ANV_TIMESTAMP_CAPTURE_TOP_OF_PIPE;
device->physical->cmd_emit_timestamp(&cmd_buffer->batch, device,
(struct anv_address) {
.bo = bo,
.offset = idx * sizeof(uint64_t) },
end_of_pipe);
capture_type);
}
static uint64_t

View file

@ -7461,17 +7461,34 @@ VkResult genX(CmdSetPerformanceStreamMarkerINTEL)(
void genX(cmd_emit_timestamp)(struct anv_batch *batch,
struct anv_device *device,
struct anv_address addr,
bool end_of_pipe) {
if (end_of_pipe) {
enum anv_timestamp_capture_type type) {
switch (type) {
case ANV_TIMESTAMP_CAPTURE_TOP_OF_PIPE: {
struct mi_builder b;
mi_builder_init(&b, device->info, batch);
mi_store(&b, mi_mem64(addr), mi_reg64(TIMESTAMP));
break;
}
case ANV_TIMESTAMP_CAPTURE_END_OF_PIPE:
anv_batch_emit(batch, GENX(PIPE_CONTROL), pc) {
pc.PostSyncOperation = WriteTimestamp;
pc.Address = addr;
anv_debug_dump_pc(pc);
}
} else {
struct mi_builder b;
mi_builder_init(&b, device->info, batch);
mi_store(&b, mi_mem64(addr), mi_reg64(TIMESTAMP));
break;
case ANV_TIMESTAMP_CAPTURE_AT_CS_STALL:
anv_batch_emit(batch, GENX(PIPE_CONTROL), pc) {
pc.CommandStreamerStallEnable = true;
pc.PostSyncOperation = WriteTimestamp;
pc.Address = addr;
anv_debug_dump_pc(pc);
}
break;
default:
unreachable("invalid");
}
}