Module: Mesa Branch: main Commit: ba7b08e324220e182afe19abdb548ae51616fb4b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ba7b08e324220e182afe19abdb548ae51616fb4b
Author: Konstantin Seurer <konstantin.seu...@gmail.com> Date: Mon Oct 30 20:16:56 2023 +0100 radv/rt: Repurpose radv_ray_tracing_stage_is_compiled Replace it with radv_ray_tracing_stage_is_always_inlined and use it inside radv_rt_compile_shaders. Reviewed-by: Friedrich Vock <friedrich.v...@gmx.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25224> --- src/amd/vulkan/radv_pipeline_rt.c | 12 +++++++++--- src/amd/vulkan/radv_private.h | 7 ------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index ddd0ff78205..0023527d0e0 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -479,6 +479,12 @@ radv_rt_can_inline_shader(nir_shader *nir) return true; } +static inline bool +radv_ray_tracing_stage_is_always_inlined(struct radv_ray_tracing_stage *stage) +{ + return stage->stage == MESA_SHADER_ANY_HIT || stage->stage == MESA_SHADER_INTERSECTION; +} + static VkResult radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *cache, const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, @@ -544,9 +550,9 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca * - non-recursive: Non-recursive shaders are inlined into the traversal shader. * - monolithic: Callable shaders (chit/miss) are inlined into the raygen shader. */ - bool compiled = radv_ray_tracing_stage_is_compiled(&rt_stages[idx]); + bool always_inlined = radv_ray_tracing_stage_is_always_inlined(&rt_stages[idx]); bool nir_needed = - (library && !has_callable) || !compiled || (monolithic && rt_stages[idx].stage != MESA_SHADER_RAYGEN); + (library && !has_callable) || always_inlined || (monolithic && rt_stages[idx].stage != MESA_SHADER_RAYGEN); nir_needed &= !rt_stages[idx].nir; if (nir_needed) { rt_stages[idx].stack_size = stage->nir->scratch_size; @@ -566,7 +572,7 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca * shaders since pipeline library shaders use separate compilation. * - separate: Compile any recursive stage if wasn't compiled yet. */ - bool shader_needed = radv_ray_tracing_stage_is_compiled(&rt_stages[idx]) && !rt_stages[idx].shader; + bool shader_needed = !radv_ray_tracing_stage_is_always_inlined(&rt_stages[idx]) && !rt_stages[idx].shader; if (rt_stages[idx].stage == MESA_SHADER_CLOSEST_HIT || rt_stages[idx].stage == MESA_SHADER_MISS) shader_needed &= !monolithic || raygen_imported; diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 99dbbbf941c..6a7babef601 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -2141,13 +2141,6 @@ struct radv_ray_tracing_stage { uint8_t sha1[SHA1_DIGEST_LENGTH]; }; -static inline bool -radv_ray_tracing_stage_is_compiled(struct radv_ray_tracing_stage *stage) -{ - return stage->stage == MESA_SHADER_RAYGEN || stage->stage == MESA_SHADER_CALLABLE || - stage->stage == MESA_SHADER_CLOSEST_HIT || stage->stage == MESA_SHADER_MISS; -} - struct radv_ray_tracing_pipeline { struct radv_compute_pipeline base;