radv: don't export cull distances if the shader culls against them

This increases primitive throughput for all hw with NGG if the shader
culls and the removal of cull distances reduces the number of position
exports.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35473>
This commit is contained in:
Marek Olšák
2025-07-06 21:31:25 -04:00
committed by Marge Bot
parent 0cce0505cc
commit bdcfe15457
2 changed files with 13 additions and 4 deletions
+10 -2
View File
@@ -156,8 +156,16 @@ lower_abi_instr(nir_builder *b, nir_intrinsic_instr *intrin, void *state)
*/
nir_def *small_workgroup = nir_ieq_imm(b, nir_iand_imm(b, gs_tg_info, BITFIELD_RANGE(22 + 4, 9 - 4)), 0);
/* If clip or cull distances are present, always cull against them if the workgroup is large enough. */
if (b->shader->info.clip_distance_array_size || b->shader->info.cull_distance_array_size) {
if (b->shader->info.cull_distance_array_size) {
/* If cull distances are present, always cull in the shader. We don't export them in order to increase
* primitive throughput.
*/
replacement = nir_imm_true(b);
break;
}
if (b->shader->info.clip_distance_array_size) {
/* If clip distances are present, cull in the shader only when the workgroup is large enough. */
replacement = nir_inot(b, small_workgroup);
break;
}