Module: Mesa Branch: main Commit: d37414d8a4d9648eb182c44269636b95ffbdcea2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d37414d8a4d9648eb182c44269636b95ffbdcea2
Author: José Roberto de Souza <jose.so...@intel.com> Date: Wed Jan 3 10:57:37 2024 -0800 anv: Fix anv_measure_start/stop_snapshot() over copy or video engine Those engines don't have PIPE_CONTROL so we can't do ANV_TIMESTAMP_CAPTURE_AT_CS_STALL but we can support measurement by changing the capture type to ANV_TIMESTAMP_CAPTURE_TOP/END_OF_PIPE Right now this issue is only reproduced in Xe KMD without setting any special parameters(other than INTEL_MEASURE) because Xe KMD allows the usage of copy engine while i915 can't due TRTT restrictions. Signed-off-by: José Roberto de Souza <jose.so...@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwer...@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26882> --- src/intel/vulkan/anv_measure.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/intel/vulkan/anv_measure.c b/src/intel/vulkan/anv_measure.c index 8c6a241151b..9223ca158fe 100644 --- a/src/intel/vulkan/anv_measure.c +++ b/src/intel/vulkan/anv_measure.c @@ -112,8 +112,9 @@ anv_measure_start_snapshot(struct anv_cmd_buffer *cmd_buffer, 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); - + enum anv_timestamp_capture_type capture_type; unsigned index = measure->base.index++; + if (event_name == NULL) event_name = intel_measure_snapshot_string(type); @@ -128,11 +129,18 @@ anv_measure_start_snapshot(struct anv_cmd_buffer *cmd_buffer, return; } + + if ((batch->engine_class == INTEL_ENGINE_CLASS_COPY) || + (batch->engine_class == INTEL_ENGINE_CLASS_VIDEO)) + capture_type = ANV_TIMESTAMP_CAPTURE_TOP_OF_PIPE; + else + capture_type = ANV_TIMESTAMP_CAPTURE_AT_CS_STALL; + (*device->cmd_emit_timestamp)(batch, cmd_buffer->device, (struct anv_address) { .bo = measure->bo, .offset = index * sizeof(uint64_t) }, - ANV_TIMESTAMP_CAPTURE_AT_CS_STALL, + capture_type, NULL); struct intel_measure_snapshot *snapshot = &(measure->base.snapshots[index]); @@ -169,17 +177,24 @@ anv_measure_end_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_config *config = config_from_command_buffer(cmd_buffer); - + enum anv_timestamp_capture_type capture_type; unsigned index = measure->base.index++; assert(index % 2 == 1); + if (config->cpu_measure) return; + if ((batch->engine_class == INTEL_ENGINE_CLASS_COPY) || + (batch->engine_class == INTEL_ENGINE_CLASS_VIDEO)) + capture_type = ANV_TIMESTAMP_CAPTURE_END_OF_PIPE; + else + capture_type = ANV_TIMESTAMP_CAPTURE_AT_CS_STALL; + (*device->cmd_emit_timestamp)(batch, cmd_buffer->device, (struct anv_address) { .bo = measure->bo, .offset = index * sizeof(uint64_t) }, - ANV_TIMESTAMP_CAPTURE_AT_CS_STALL, + capture_type, NULL); struct intel_measure_snapshot *snapshot = &(measure->base.snapshots[index]);