mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 00:20:09 +01:00
v3d: Enable Early-Z with discards when depth updates are disabled
The Early-Z optimization is disabled when there is a discard instruction in the shader used in the draw call. But if discard is the only reason to disable Early-Z, and at draw call time the updates in the draw call are disabled we can enable Early-Z using a shader variant. If there are occlussion queries active we also need to disable Early-z optimization. So this patch enables Early-Z in this scenario. The performance improvement is significant when running gfxbench benchmark showing an average improvement of 11.15% fps_avg helped: gl_gfxbench_aztec_high.trace: 3.13 -> 3.73 (19.13%) fps_avg helped: gl_gfxbench_aztec.trace: 4.82 -> 5.68 (17.88%) fps_avg helped: gl_gfxbench_manhattan31.trace: 5.10 -> 6.00 (17.59%) fps_avg helped: gl_gfxbench_manhattan.trace: 7.24 -> 8.36 (15.52%) fps_avg helped: gl_gfxbench_trex.trace: 19.25 -> 20.17 ( 4.81%) Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Cc: mesa-stable Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32028>
This commit is contained in:
parent
fef8490eb9
commit
5b951bcdd7
3 changed files with 9 additions and 2 deletions
|
|
@ -1973,11 +1973,12 @@ emit_frag_end(struct v3d_compile *c)
|
|||
*/
|
||||
if (c->output_position_index == -1 &&
|
||||
!(c->s->info.num_images || c->s->info.num_ssbos) &&
|
||||
!c->s->info.fs.uses_discard &&
|
||||
!c->fs_key->sample_alpha_to_coverage &&
|
||||
c->output_sample_mask_index == -1 &&
|
||||
has_any_tlb_color_write) {
|
||||
c->s->info.fs.early_fragment_tests = true;
|
||||
c->s->info.fs.early_fragment_tests =
|
||||
!c->s->info.fs.uses_discard ||
|
||||
c->fs_key->can_earlyz_with_discard;
|
||||
}
|
||||
|
||||
/* By default, Z buffer writes are implicit using the Z values produced
|
||||
|
|
|
|||
|
|
@ -426,6 +426,7 @@ struct v3d_fs_key {
|
|||
bool msaa;
|
||||
bool sample_alpha_to_coverage;
|
||||
bool sample_alpha_to_one;
|
||||
bool can_earlyz_with_discard;
|
||||
/* Mask of which color render targets are present. */
|
||||
uint8_t cbufs;
|
||||
uint8_t swap_color_rb;
|
||||
|
|
|
|||
|
|
@ -649,6 +649,7 @@ v3d_update_compiled_fs(struct v3d_context *v3d, uint8_t prim_mode)
|
|||
V3D_DIRTY_BLEND |
|
||||
V3D_DIRTY_FRAMEBUFFER |
|
||||
V3D_DIRTY_ZSA |
|
||||
V3D_DIRTY_OQ |
|
||||
V3D_DIRTY_RASTERIZER |
|
||||
V3D_DIRTY_SAMPLE_STATE |
|
||||
V3D_DIRTY_FRAGTEX |
|
||||
|
|
@ -677,6 +678,10 @@ v3d_update_compiled_fs(struct v3d_context *v3d, uint8_t prim_mode)
|
|||
}
|
||||
|
||||
key->swap_color_rb = v3d->swap_color_rb;
|
||||
key->can_earlyz_with_discard = s->info.fs.uses_discard &&
|
||||
(!v3d->zsa || !job->zsbuf || !v3d->zsa->base.depth_enabled ||
|
||||
!v3d->zsa->base.depth_writemask) &&
|
||||
!(v3d->active_queries && v3d->current_oq);
|
||||
|
||||
for (int i = 0; i < v3d->framebuffer.nr_cbufs; i++) {
|
||||
struct pipe_surface *cbuf = v3d->framebuffer.cbufs[i];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue