2
* Copyright © 2020 Intel Corporation
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* on the rights to use, copy, modify, merge, publish, distribute, sub
8
* license, and/or sell copies of the Software, and to permit persons to whom
9
* the Software is furnished to do so, subject to the following conditions:
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21
* USE OR OTHER DEALINGS IN THE SOFTWARE.
24
#ifndef INTEL_MEASURE_H
25
#define INTEL_MEASURE_H
32
#include "util/list.h"
34
enum intel_measure_snapshot_type {
35
INTEL_SNAPSHOT_UNDEFINED,
37
INTEL_SNAPSHOT_CCS_AMBIGUATE,
38
INTEL_SNAPSHOT_CCS_COLOR_CLEAR,
39
INTEL_SNAPSHOT_CCS_PARTIAL_RESOLVE,
40
INTEL_SNAPSHOT_CCS_RESOLVE,
41
INTEL_SNAPSHOT_COMPUTE,
44
INTEL_SNAPSHOT_HIZ_AMBIGUATE,
45
INTEL_SNAPSHOT_HIZ_CLEAR,
46
INTEL_SNAPSHOT_HIZ_RESOLVE,
47
INTEL_SNAPSHOT_MCS_COLOR_CLEAR,
48
INTEL_SNAPSHOT_MCS_PARTIAL_RESOLVE,
49
INTEL_SNAPSHOT_SLOW_COLOR_CLEAR,
50
INTEL_SNAPSHOT_SLOW_DEPTH_CLEAR,
51
INTEL_SNAPSHOT_SECONDARY_BATCH,
55
enum intel_measure_events {
56
INTEL_MEASURE_DRAW = (1 << 0),
57
INTEL_MEASURE_RENDERPASS = (1 << 1),
58
INTEL_MEASURE_SHADER = (1 << 2),
59
INTEL_MEASURE_BATCH = (1 << 3),
60
INTEL_MEASURE_FRAME = (1 << 4),
63
struct intel_measure_config {
65
/* Stderr, or optionally set with INTEL_MEASURE=file={path{ */
68
/* Events that will be measured. Set only one flag, with
69
* INTEL_MEASURE=[draw,rt,shader,batch,frame] */
70
enum intel_measure_events flags;
72
/* Optionally set with INTEL_MEASURE=start={num} */
75
/* Optionally calculated with INTEL_MEASURE=count={num} based on
80
/* Number of events to combine per line of output. Optionally set with
81
* INTEL_MEASURE=interval={num}
83
unsigned event_interval;
85
/* Max snapshots per batch. Set with
86
* INTEL_MEASURE=batch_size={num}. Additional snapshots will be dropped.
90
/* Max number of batch measurements that can be buffered, for combining
91
* snapshots into frame or interval data.
95
/* Fifo which will be read to enable measurements at run-time. Set with
96
* INTEL_MEASURE=control={path}. `echo {num} > {path}` will collect num
97
* frames of measurements, beginning with the next frame boundary.
101
/* true when snapshots are currently being collected */
105
struct intel_measure_batch;
107
struct intel_measure_snapshot {
108
enum intel_measure_snapshot_type type;
109
unsigned count, event_count;
110
const char* event_name;
111
uintptr_t framebuffer, vs, tcs, tes, gs, fs, cs;
112
/* for vulkan secondary command buffers */
113
struct intel_measure_batch *secondary;
116
struct intel_measure_buffered_result {
117
struct intel_measure_snapshot snapshot;
118
uint64_t start_ts, end_ts, idle_duration;
119
unsigned frame, batch_count, event_index;
122
struct intel_measure_ringbuffer {
124
struct intel_measure_buffered_result results[0];
127
struct intel_measure_device {
128
struct intel_measure_config *config;
131
/* Holds the list of (iris/anv)_measure_batch snapshots that have been
132
* submitted for rendering, but have not completed.
134
pthread_mutex_t mutex;
135
struct list_head queued_snapshots;
137
/* Holds completed snapshots that may need to be combined before being
140
struct intel_measure_ringbuffer *ringbuffer;
143
struct intel_measure_batch {
144
struct list_head link;
146
unsigned frame, batch_count, event_count;
147
uintptr_t framebuffer;
148
uint64_t *timestamps;
149
struct intel_measure_snapshot snapshots[0];
152
void intel_measure_init(struct intel_measure_device *device);
153
const char * intel_measure_snapshot_string(enum intel_measure_snapshot_type type);
154
bool intel_measure_state_changed(const struct intel_measure_batch *batch,
155
uintptr_t vs, uintptr_t tcs, uintptr_t tes,
156
uintptr_t gs, uintptr_t fs, uintptr_t cs);
157
void intel_measure_frame_transition(unsigned frame);
159
bool intel_measure_ready(struct intel_measure_batch *batch);
161
struct intel_device_info;
162
void intel_measure_gather(struct intel_measure_device *device,
163
struct intel_device_info *info);
165
#endif /* INTEL_MEASURE_H */