From 11897376c775f9165b457acee2d7649f11c95b41 Mon Sep 17 00:00:00 2001 From: Konstantin Seurer Date: Wed, 6 Sep 2023 15:54:36 +0200 Subject: [PATCH] radv/rt: Skip null checks for small case counts The individual cases make sure the sbt_idx is not null implicitly because the handles are always != 0. Totals from 60 (22.56% of 266) affected shaders: Instrs: 47841 -> 47655 (-0.39%) CodeSize: 255028 -> 253460 (-0.61%) Latency: 1179658 -> 1225311 (+3.87%); split: -0.02%, +3.89% InvThroughput: 224122 -> 232851 (+3.89%); split: -0.02%, +3.92% Copies: 12049 -> 12043 (-0.05%); split: -0.37%, +0.32% Branches: 3312 -> 3290 (-0.66%) PreSGPRs: 3494 -> 3472 (-0.63%) Reviewed-by: Friedrich Vock Part-of: --- src/amd/vulkan/radv_rt_shader.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/amd/vulkan/radv_rt_shader.c b/src/amd/vulkan/radv_rt_shader.c index 0667aa896ad..fbc0dbc790f 100644 --- a/src/amd/vulkan/radv_rt_shader.c +++ b/src/amd/vulkan/radv_rt_shader.c @@ -38,6 +38,8 @@ * performance. */ #define MAX_STACK_ENTRY_COUNT 16 +#define RADV_RT_SWITCH_NULL_CHECK_THRESHOLD 3 + struct radv_rt_case_data { struct radv_device *device; struct radv_ray_tracing_pipeline *pipeline; @@ -83,6 +85,9 @@ radv_visit_inlined_shaders(nir_builder *b, nir_def *sbt_idx, bool can_have_null_ groups[case_count++] = group; } + /* Do not emit 'if (sbt_idx != 0) { ... }' is there are only a few cases. */ + can_have_null_shaders &= case_count >= RADV_RT_SWITCH_NULL_CHECK_THRESHOLD; + if (can_have_null_shaders) nir_push_if(b, nir_ine_imm(b, sbt_idx, 0));