mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
v3d: attach performance monitor to jobs
When a performance monitor is enabled in the context, all the jobs submitted to the kernel will have attached this monitor ID, so the kernel will measuring the performance counters selected in the monitor when these jobs are executed by the GPU (accumulating the results). v2 (Iago): - Update comment - Assert fence is not NULL - Assert has_perfmon when using perfmon - Rewrite conditional - Implement performance counters in CSD v4 (Juan): - Track previous perfmon and sync BCL if required (Juan). - Track if a job with perfmon was submitted (Juan) v7 (Iago) - No braces for single-line body conditionals Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10666>
This commit is contained in:
parent
6b9fcb0193
commit
9969703547
4 changed files with 56 additions and 0 deletions
|
|
@ -304,6 +304,19 @@ struct v3d_shaderimg_stateobj {
|
|||
uint32_t enabled_mask;
|
||||
};
|
||||
|
||||
struct v3d_perfmon_state {
|
||||
/* The kernel perfmon id */
|
||||
uint32_t kperfmon_id;
|
||||
/* True if at least one job was submitted with this perfmon. */
|
||||
bool job_submitted;
|
||||
/* Fence to be signaled when the last job submitted with this perfmon
|
||||
* is executed by the GPU.
|
||||
*/
|
||||
struct v3d_fence *last_job_fence;
|
||||
uint8_t counters[DRM_V3D_MAX_PERF_COUNTERS];
|
||||
uint64_t values[DRM_V3D_MAX_PERF_COUNTERS];
|
||||
};
|
||||
|
||||
/**
|
||||
* A complete bin/render job.
|
||||
*
|
||||
|
|
@ -576,6 +589,8 @@ struct v3d_context {
|
|||
struct pipe_resource *prim_counts;
|
||||
uint32_t prim_counts_offset;
|
||||
struct pipe_debug_callback debug;
|
||||
struct v3d_perfmon_state *active_perfmon;
|
||||
struct v3d_perfmon_state *last_perfmon;
|
||||
/** @} */
|
||||
};
|
||||
|
||||
|
|
@ -730,6 +745,9 @@ bool v3d_generate_mipmap(struct pipe_context *pctx,
|
|||
unsigned int first_layer,
|
||||
unsigned int last_layer);
|
||||
|
||||
void
|
||||
v3d_fence_unreference(struct v3d_fence **fence);
|
||||
|
||||
struct v3d_fence *v3d_fence_create(struct v3d_context *v3d);
|
||||
|
||||
void v3d_update_primitive_counters(struct v3d_context *v3d);
|
||||
|
|
|
|||
|
|
@ -61,6 +61,17 @@ v3d_fence_reference(struct pipe_screen *pscreen,
|
|||
*p = f;
|
||||
}
|
||||
|
||||
void
|
||||
v3d_fence_unreference(struct v3d_fence **fence)
|
||||
{
|
||||
assert(fence);
|
||||
|
||||
if (!*fence)
|
||||
return;
|
||||
|
||||
v3d_fence_reference(NULL, (struct pipe_fence_handle **)fence, NULL);
|
||||
}
|
||||
|
||||
static bool
|
||||
v3d_fence_finish(struct pipe_screen *pscreen,
|
||||
struct pipe_context *ctx,
|
||||
|
|
|
|||
|
|
@ -502,6 +502,20 @@ v3d_job_submit(struct v3d_context *v3d, struct v3d_job *job)
|
|||
job->submit.bcl_end = job->bcl.bo->offset + cl_offset(&job->bcl);
|
||||
job->submit.rcl_end = job->rcl.bo->offset + cl_offset(&job->rcl);
|
||||
|
||||
if (v3d->active_perfmon) {
|
||||
assert(screen->has_perfmon);
|
||||
job->submit.perfmon_id = v3d->active_perfmon->kperfmon_id;
|
||||
}
|
||||
|
||||
/* If we are submitting a job with a different perfmon, we need to
|
||||
* ensure the previous one fully finishes before starting this;
|
||||
* otherwise it would wrongly mix counter results.
|
||||
*/
|
||||
if (v3d->active_perfmon != v3d->last_perfmon) {
|
||||
v3d->last_perfmon = v3d->active_perfmon;
|
||||
job->submit.in_sync_bcl = v3d->out_sync;
|
||||
}
|
||||
|
||||
job->submit.flags = 0;
|
||||
if (job->tmu_dirty_rcl && screen->has_cache_flush)
|
||||
job->submit.flags |= DRM_V3D_SUBMIT_CL_FLUSH_CACHE;
|
||||
|
|
@ -529,6 +543,9 @@ v3d_job_submit(struct v3d_context *v3d, struct v3d_job *job)
|
|||
fprintf(stderr, "Draw call returned %s. "
|
||||
"Expect corruption.\n", strerror(errno));
|
||||
warned = true;
|
||||
} else if (!ret) {
|
||||
if (v3d->active_perfmon)
|
||||
v3d->active_perfmon->job_submitted = true;
|
||||
}
|
||||
|
||||
/* If we are submitting a job in the middle of transform
|
||||
|
|
|
|||
|
|
@ -1448,6 +1448,13 @@ v3d_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
|
|||
submit.in_sync = v3d->out_sync;
|
||||
submit.out_sync = v3d->out_sync;
|
||||
|
||||
if (v3d->active_perfmon) {
|
||||
assert(screen->has_perfmon);
|
||||
submit.perfmon_id = v3d->active_perfmon->kperfmon_id;
|
||||
}
|
||||
|
||||
v3d->last_perfmon = v3d->active_perfmon;
|
||||
|
||||
if (!(V3D_DEBUG & V3D_DEBUG_NORAST)) {
|
||||
int ret = v3d_ioctl(screen->fd, DRM_IOCTL_V3D_SUBMIT_CSD,
|
||||
&submit);
|
||||
|
|
@ -1456,6 +1463,9 @@ v3d_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
|
|||
fprintf(stderr, "CSD submit call returned %s. "
|
||||
"Expect corruption.\n", strerror(errno));
|
||||
warned = true;
|
||||
} else if (!ret) {
|
||||
if (v3d->active_perfmon)
|
||||
v3d->active_perfmon->job_submitted = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue