v3d: enable early Z/S clears

This performance optimization can be enabled if we are clearing Z/S
buffer, and not storing or loading it.

v2:
 - Add assertion on depth/stencil job loads (Iago)

Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16166>
This commit is contained in:
Juan A. Suarez Romero
2022-04-19 16:52:44 +02:00
committed by Marge Bot
parent 4dec4ba87d
commit 07cfa2bd96
2 changed files with 15 additions and 4 deletions

View File

@@ -470,6 +470,11 @@ struct v3d_job {
*/
enum v3d_ez_state first_ez_state;
/**
* If this job has been configured to use early Z/S clear.
*/
bool early_zs_clear;
/**
* Number of draw calls (not counting full buffer clears) queued in
* the current job.

View File

@@ -245,6 +245,7 @@ v3d_rcl_emit_loads(struct v3d_job *job, struct v3d_cl *cl, int layer)
if ((loads_pending & PIPE_CLEAR_DEPTHSTENCIL) &&
(V3D_VERSION >= 40 ||
(job->zsbuf && job->zsbuf->texture->nr_samples > 1))) {
assert(!job->early_zs_clear);
struct pipe_surface *src = job->bbuf ? job->bbuf : job->zsbuf;
struct v3d_resource *rsc = v3d_resource(src->texture);
@@ -345,6 +346,7 @@ v3d_rcl_emit_stores(struct v3d_job *job, struct v3d_cl *cl, int layer)
if (job->store & PIPE_CLEAR_DEPTHSTENCIL && job->zsbuf &&
!(V3D_VERSION < 40 && job->zsbuf->texture->nr_samples <= 1)) {
assert(!job->early_zs_clear);
struct v3d_resource *rsc = v3d_resource(job->zsbuf->texture);
if (rsc->separate_stencil) {
if (job->store & PIPE_CLEAR_DEPTH) {
@@ -418,7 +420,7 @@ v3d_rcl_emit_stores(struct v3d_job *job, struct v3d_cl *cl, int layer)
*/
if (job->clear) {
cl_emit(cl, CLEAR_TILE_BUFFERS, clear) {
clear.clear_z_stencil_buffer = true;
clear.clear_z_stencil_buffer = !job->early_zs_clear;
clear.clear_all_render_targets = true;
}
}
@@ -657,7 +659,7 @@ emit_render_layer(struct v3d_job *job, uint32_t layer)
}
if (i == 0 || do_double_initial_tile_clear(job)) {
cl_emit(&job->rcl, CLEAR_TILE_BUFFERS, clear) {
clear.clear_z_stencil_buffer = true;
clear.clear_z_stencil_buffer = !job->early_zs_clear;
clear.clear_all_render_targets = true;
}
}
@@ -724,9 +726,13 @@ v3dX(emit_rcl)(struct v3d_job *job)
struct v3d_surface *surf = v3d_surface(job->zsbuf);
config.internal_depth_type = surf->internal_type;
}
#endif /* V3D_VERSION >= 40 */
/* XXX: Early D/S clear */
job->early_zs_clear = (job->clear & PIPE_CLEAR_DEPTHSTENCIL) &&
!(job->load & PIPE_CLEAR_DEPTHSTENCIL) &&
!(job->store & PIPE_CLEAR_DEPTHSTENCIL);
config.early_depth_stencil_clear = job->early_zs_clear;
#endif /* V3D_VERSION >= 40 */
switch (job->first_ez_state) {
case V3D_EZ_UNDECIDED: