ac/nir/cull: Change if condition for bounding box culling.

The previous code checked all_w_positive in the if condition.
Instead, always execute the bbox culling code and include
all_w_positive at the end.

We assume checking in the if is not beneficial because it's
very unlikely that there is no primitive in a wave whose W are
not all positive.

This allows moving other things to the condition
in the next commit.

Fossil DB stats on Navi 21:

Totals from 60918 (45.16% of 134906) affected shaders:
CodeSize: 160574204 -> 160330564 (-0.15%); split: -0.15%, +0.00%
Instrs: 30538297 -> 30477385 (-0.20%); split: -0.20%, +0.00%
Latency: 139810902 -> 139802763 (-0.01%); split: -0.01%, +0.00%
InvThroughput: 21198449 -> 21198444 (-0.00%); split: -0.00%, +0.00%
SClause: 749810 -> 749811 (+0.00%)
Copies: 2701474 -> 2701482 (+0.00%); split: -0.00%, +0.00%

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17870>
This commit is contained in:
Timur Kristóf
2022-08-03 11:40:12 +02:00
committed by Marge Bot
parent fb4e68b724
commit 0d527bb1aa
+3 -4
View File
@@ -155,9 +155,8 @@ ac_nir_cull_triangle(nir_builder *b,
accepted = nir_iand(b, accepted, cull_face(b, pos, &w_info));
nir_ssa_def *bbox_accepted = NULL;
nir_ssa_def *try_cull_bbox = nir_iand(b, accepted, w_info.all_w_positive);
nir_if *if_cull_bbox = nir_push_if(b, try_cull_bbox);
nir_if *if_accepted = nir_push_if(b, accepted);
{
nir_ssa_def *bbox_min[3] = {0}, *bbox_max[3] = {0};
calc_bbox(b, pos, bbox_min, bbox_max);
@@ -166,9 +165,9 @@ ac_nir_cull_triangle(nir_builder *b,
nir_ssa_def *prim_is_small = cull_small_primitive(b, bbox_min, bbox_max);
nir_ssa_def *prim_invisible = nir_ior(b, prim_outside_view, prim_is_small);
bbox_accepted = nir_inot(b, prim_invisible);
bbox_accepted = nir_iand(b, nir_inot(b, prim_invisible), w_info.all_w_positive);
}
nir_pop_if(b, if_cull_bbox);
nir_pop_if(b, if_accepted);
accepted = nir_iand(b, accepted, nir_if_phi(b, bbox_accepted, accepted));
return accepted;