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.souza@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26882>
This commit is contained in:
José Roberto de Souza 2024-01-03 10:57:37 -08:00 committed by Marge Bot
parent b8d48ebc93
commit d37414d8a4

View file

@ -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]);