From 0597906adae811f00d78891f861075eb08287ac9 Mon Sep 17 00:00:00 2001 From: Konstantin Seurer Date: Sun, 14 Jan 2024 14:08:18 +0100 Subject: [PATCH] radv/rt: Add radv_ray_tracing_stage_info Useful for gathering more information about used args and traces. Reviewed-by: Friedrich Vock Part-of: --- src/amd/vulkan/radv_pipeline_rt.c | 33 +++++++++++++++++++------------ src/amd/vulkan/radv_private.h | 6 +++++- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index fc7d8c83e92..ca8c4c988e1 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -274,6 +274,7 @@ radv_rt_fill_stage_info(const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, st stages[idx].stage = library_pipeline->stages[j].stage; stages[idx].stack_size = library_pipeline->stages[j].stack_size; + stages[idx].info = library_pipeline->stages[j].info; memcpy(stages[idx].sha1, library_pipeline->stages[j].sha1, SHA1_DIGEST_LENGTH); idx++; } @@ -471,15 +472,12 @@ radv_rt_nir_to_asm(struct radv_device *device, struct vk_pipeline_cache *cache, return shader ? VK_SUCCESS : VK_ERROR_OUT_OF_HOST_MEMORY; } -static bool -radv_rt_can_inline_shader(nir_shader *nir) +static struct radv_ray_tracing_stage_info +radv_gather_ray_tracing_stage_info(nir_shader *nir) { - if (nir->info.stage == MESA_SHADER_RAYGEN || nir->info.stage == MESA_SHADER_ANY_HIT || - nir->info.stage == MESA_SHADER_INTERSECTION) - return true; - - if (nir->info.stage == MESA_SHADER_CALLABLE) - return false; + struct radv_ray_tracing_stage_info info = { + .can_inline = true, + }; nir_function_impl *impl = nir_shader_get_entrypoint(nir); nir_foreach_block (block, impl) { @@ -487,12 +485,21 @@ radv_rt_can_inline_shader(nir_shader *nir) if (instr->type != nir_instr_type_intrinsic) continue; - if (nir_instr_as_intrinsic(instr)->intrinsic == nir_intrinsic_trace_ray) - return false; + nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); + if (intr->intrinsic != nir_intrinsic_trace_ray) + continue; + + info.can_inline = false; } } - return true; + if (nir->info.stage == MESA_SHADER_RAYGEN || nir->info.stage == MESA_SHADER_ANY_HIT || + nir->info.stage == MESA_SHADER_INTERSECTION) + info.can_inline = true; + else if (nir->info.stage == MESA_SHADER_CALLABLE) + info.can_inline = false; + + return info; } static inline bool @@ -538,7 +545,7 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca NIR_PASS(_, stage->nir, radv_nir_lower_hit_attrib_derefs); - rt_stages[i].can_inline = radv_rt_can_inline_shader(stage->nir); + rt_stages[i].info = radv_gather_ray_tracing_stage_info(stage->nir); stage->feedback.duration = os_time_get_nano() - stage_start; } @@ -548,7 +555,7 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca bool raygen_imported = false; for (uint32_t i = 0; i < pipeline->stage_count; i++) { has_callable |= rt_stages[i].stage == MESA_SHADER_CALLABLE; - monolithic &= rt_stages[i].can_inline; + monolithic &= rt_stages[i].info.can_inline; if (i > pCreateInfo->stageCount) raygen_imported |= rt_stages[i].stage == MESA_SHADER_RAYGEN; diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 242dddc6e36..fa392be65a0 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -2364,13 +2364,17 @@ struct radv_ray_tracing_group { struct radv_pipeline_group_handle handle; }; +struct radv_ray_tracing_stage_info { + bool can_inline; +}; + struct radv_ray_tracing_stage { struct vk_pipeline_cache_object *nir; struct radv_shader *shader; gl_shader_stage stage; uint32_t stack_size; - bool can_inline; + struct radv_ray_tracing_stage_info info; uint8_t sha1[SHA1_DIGEST_LENGTH]; };