The V3D engine provides several perf counters.
Implement ->get_driver_query_[group_]info() so that these counters are
exposed through the GL_AMD_performance_monitor extension.
Signed-off-by: Boris Brezillon
---
Changes in v2 (all reported by Eric):
- Add missing "TLB-quads-passing-z-and-stencil-test" perf counter
- Make sure we wait for the results to be available before returning
true in vc4_get_query_result()
- Flush pending jobs in vc4_begin_query() and vc4_end_query() so that
perf counters are not polluted by unrelated jobs
- Reset the counters in vc4_begin_query()
- Initialize ->group_id in vc4_get_driver_query_info()
---
src/gallium/drivers/vc4/vc4_context.h | 18 +++
src/gallium/drivers/vc4/vc4_job.c | 7 ++
src/gallium/drivers/vc4/vc4_query.c | 228 --
src/gallium/drivers/vc4/vc4_screen.c | 7 ++
src/gallium/drivers/vc4/vc4_screen.h | 1 +
5 files changed, 249 insertions(+), 12 deletions(-)
diff --git a/src/gallium/drivers/vc4/vc4_context.h
b/src/gallium/drivers/vc4/vc4_context.h
index 4a1e4093f1a0..41241d36a4bc 100644
--- a/src/gallium/drivers/vc4/vc4_context.h
+++ b/src/gallium/drivers/vc4/vc4_context.h
@@ -219,6 +219,13 @@ struct vc4_job_key {
struct pipe_surface *zsbuf;
};
+struct vc4_hwperfmon {
+uint32_t id;
+uint64_t last_seqno;
+uint8_t events[DRM_VC4_MAX_PERF_COUNTERS];
+uint64_t counters[DRM_VC4_MAX_PERF_COUNTERS];
+};
+
/**
* A complete bin/render job.
*
@@ -306,6 +313,9 @@ struct vc4_job {
/** Any flags to be passed in drm_vc4_submit_cl.flags. */
uint32_t flags;
+ /* Performance monitor attached to this job. */
+ struct vc4_hwperfmon *perfmon;
+
struct vc4_job_key key;
};
@@ -387,6 +397,8 @@ struct vc4_context {
struct pipe_viewport_state viewport;
struct vc4_constbuf_stateobj constbuf[PIPE_SHADER_TYPES];
struct vc4_vertexbuf_stateobj vertexbuf;
+
+struct vc4_hwperfmon *perfmon;
/** @} */
};
@@ -444,6 +456,12 @@ vc4_sampler_state(struct pipe_sampler_state *psampler)
return (struct vc4_sampler_state *)psampler;
}
+int vc4_get_driver_query_group_info(struct pipe_screen *pscreen,
+unsigned index,
+struct pipe_driver_query_group_info *info);
+int vc4_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
+ struct pipe_driver_query_info *info);
+
struct pipe_context *vc4_context_create(struct pipe_screen *pscreen,
void *priv, unsigned flags);
void vc4_draw_init(struct pipe_context *pctx);
diff --git a/src/gallium/drivers/vc4/vc4_job.c
b/src/gallium/drivers/vc4/vc4_job.c
index 7fe20c16bad9..f0a59781b298 100644
--- a/src/gallium/drivers/vc4/vc4_job.c
+++ b/src/gallium/drivers/vc4/vc4_job.c
@@ -90,6 +90,9 @@ vc4_job_create(struct vc4_context *vc4)
job->draw_max_x = 0;
job->draw_max_y = 0;
+if (vc4->perfmon)
+job->perfmon = vc4->perfmon;
+
return job;
}
@@ -453,6 +456,8 @@ vc4_job_submit(struct vc4_context *vc4, struct vc4_job *job)
submit.shader_rec_count = job->shader_rec_count;
submit.uniforms = (uintptr_t)job->uniforms.base;
submit.uniforms_size = cl_offset(&job->uniforms);
+ if (job->perfmon)
+ submit.perfmonid = job->perfmon->id;
assert(job->draw_min_x != ~0 && job->draw_min_y != ~0);
submit.min_x_tile = job->draw_min_x / job->tile_width;
@@ -485,6 +490,8 @@ vc4_job_submit(struct vc4_context *vc4, struct vc4_job *job)
warned = true;
} else if (!ret) {
vc4->last_emit_seqno = submit.seqno;
+if (job->perfmon)
+job->perfmon->last_seqno = submit.seqno;
}
}
diff --git a/src/gallium/drivers/vc4/vc4_query.c
b/src/gallium/drivers/vc4/vc4_query.c
index ddf8f8fb0c2c..6e4681e93ccb 100644
--- a/src/gallium/drivers/vc4/vc4_query.c
+++ b/src/gallium/drivers/vc4/vc4_query.c
@@ -22,8 +22,9 @@
*/
/**
- * Stub support for occlusion queries.
+ * Expose V3D HW perf counters.
*
+ * We also have code to fake support for occlusion queries.
* Since we expose support for GL 2.0, we have to expose occlusion queries,
* but the spec allows you to expose 0 query counter bits, so we just return 0
* as the result of all our queries.
@@ -32,49 +33,252 @@
struct vc4_query
{
-uint8_t pad;
+unsigned num_queries;
+struct vc4_hwperfmon *hwperfmon;
};
+static const char *v3d_counter_names[] = {
+"FEP-valid-primitives-no-rendered-pixels",
+"FEP-valid-primitives-rendered-pixels",
+"FEP-clipped-quads",
+"FEP-valid-quads",
+"TLB-quads-not-passing-stencil-test",
+"TLB-quads-not-passing-z-and-stencil-test",
+