Module: Mesa Branch: main Commit: 8198805e1f2469dfb877dc3212bc4e9780ec96a3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8198805e1f2469dfb877dc3212bc4e9780ec96a3
Author: Konstantin Seurer <konstantin.seu...@gmail.com> Date: Tue Sep 12 17:26:47 2023 +0200 radv: Skip compiling chit and miss shaders Reviewed-by: Friedrich Vock <friedrich.v...@gmx.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25224> --- src/amd/vulkan/layers/radv_sqtt_layer.c | 4 ++++ src/amd/vulkan/radv_cmd_buffer.c | 2 +- src/amd/vulkan/radv_debug.c | 4 ++-- src/amd/vulkan/radv_pipeline.c | 4 ++-- src/amd/vulkan/radv_pipeline_rt.c | 14 +++++++++----- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/amd/vulkan/layers/radv_sqtt_layer.c b/src/amd/vulkan/layers/radv_sqtt_layer.c index 35626c4f184..4dc070eeecd 100644 --- a/src/amd/vulkan/layers/radv_sqtt_layer.c +++ b/src/amd/vulkan/layers/radv_sqtt_layer.c @@ -1571,6 +1571,10 @@ radv_register_rt_pipeline(struct radv_device *device, struct radv_ray_tracing_pi unreachable("invalid non-compiled stage"); continue; } + + if (!pipeline->stages[i].shader) + continue; + struct radv_shader *shader = container_of(pipeline->stages[i].shader, struct radv_shader, base); result = radv_register_rt_stage(device, pipeline, i, stage->stack_size, shader); if (result != VK_SUCCESS) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 38257ad1a00..5d2fd79610b 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -6266,7 +6266,7 @@ radv_emit_compute_pipeline(struct radv_cmd_buffer *cmd_buffer, struct radv_compu struct radv_ray_tracing_pipeline *rt_pipeline = radv_pipeline_to_ray_tracing(&pipeline->base); for (unsigned i = 0; i < rt_pipeline->stage_count; ++i) { - if (!radv_ray_tracing_stage_is_compiled(&rt_pipeline->stages[i])) + if (!rt_pipeline->stages[i].shader) continue; struct radv_shader *shader = container_of(rt_pipeline->stages[i].shader, struct radv_shader, base); diff --git a/src/amd/vulkan/radv_debug.c b/src/amd/vulkan/radv_debug.c index 6cdc1b79500..a012cda42dd 100644 --- a/src/amd/vulkan/radv_debug.c +++ b/src/amd/vulkan/radv_debug.c @@ -487,7 +487,7 @@ radv_dump_queue_state(struct radv_queue *queue, const char *dump_dir, FILE *f) } else if (pipeline->type == RADV_PIPELINE_RAY_TRACING) { struct radv_ray_tracing_pipeline *rt_pipeline = radv_pipeline_to_ray_tracing(pipeline); for (unsigned i = 0; i < rt_pipeline->stage_count; i++) { - if (radv_ray_tracing_stage_is_compiled(&rt_pipeline->stages[i])) { + if (rt_pipeline->stages[i].shader) { struct radv_shader *shader = container_of(rt_pipeline->stages[i].shader, struct radv_shader, base); radv_dump_shader(device, pipeline, shader, shader->info.stage, dump_dir, f); } @@ -521,7 +521,7 @@ radv_dump_queue_state(struct radv_queue *queue, const char *dump_dir, FILE *f) } else if (pipeline->type == RADV_PIPELINE_RAY_TRACING) { struct radv_ray_tracing_pipeline *rt_pipeline = radv_pipeline_to_ray_tracing(pipeline); for (unsigned i = 0; i < rt_pipeline->stage_count; i++) { - if (radv_ray_tracing_stage_is_compiled(&rt_pipeline->stages[i])) { + if (rt_pipeline->stages[i].shader) { struct radv_shader *shader = container_of(rt_pipeline->stages[i].shader, struct radv_shader, base); radv_dump_annotated_shader(shader, shader->info.stage, waves, num_waves, f); } diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index a807cbdbab6..f428ce11063 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -807,7 +807,7 @@ radv_get_executable_count(struct radv_pipeline *pipeline) if (pipeline->type == RADV_PIPELINE_RAY_TRACING) { struct radv_ray_tracing_pipeline *rt_pipeline = radv_pipeline_to_ray_tracing(pipeline); for (uint32_t i = 0; i < rt_pipeline->stage_count; i++) - ret += radv_ray_tracing_stage_is_compiled(&rt_pipeline->stages[i]) ? 1 : 0; + ret += rt_pipeline->stages[i].shader ? 1 : 0; } for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; ++i) { @@ -830,7 +830,7 @@ radv_get_shader_from_executable_index(struct radv_pipeline *pipeline, int index, struct radv_ray_tracing_pipeline *rt_pipeline = radv_pipeline_to_ray_tracing(pipeline); for (uint32_t i = 0; i < rt_pipeline->stage_count; i++) { struct radv_ray_tracing_stage *rt_stage = &rt_pipeline->stages[i]; - if (!radv_ray_tracing_stage_is_compiled(rt_stage)) + if (!rt_stage->shader) continue; if (!index) { diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index f2ec9a1a1ea..32ec0d1f1fa 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -567,9 +567,11 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca * TODO: - monolithic: Extend the loop to cover imported stages and force compilation of imported raygen * shaders since pipeline library shaders use separate compilation. * - separate: Compile any recursive stage if wasn't compiled yet. - * TODO: Skip chit and miss shaders in the monolithic case. */ bool shader_needed = radv_ray_tracing_stage_is_compiled(&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; + if (shader_needed) { uint32_t stack_size = 0; struct radv_serialized_shader_arena_block *replay_block = @@ -721,7 +723,7 @@ compile_rt_prolog(struct radv_device *device, struct radv_ray_tracing_pipeline * /* create combined config */ struct ac_shader_config *config = &pipeline->prolog->config; for (unsigned i = 0; i < pipeline->stage_count; i++) { - if (radv_ray_tracing_stage_is_compiled(&pipeline->stages[i])) { + if (pipeline->stages[i].shader) { struct radv_shader *shader = container_of(pipeline->stages[i].shader, struct radv_shader, base); combine_config(config, &shader->config); } @@ -814,9 +816,11 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache, const VkRayTra /* write shader VAs into group handles */ for (unsigned i = 0; i < pipeline->group_count; i++) { if (pipeline->groups[i].recursive_shader != VK_SHADER_UNUSED_KHR) { - struct radv_shader *shader = - container_of(pipeline->stages[pipeline->groups[i].recursive_shader].shader, struct radv_shader, base); - pipeline->groups[i].handle.recursive_shader_ptr = shader->va | radv_get_rt_priority(shader->info.stage); + if (pipeline->stages[pipeline->groups[i].recursive_shader].shader) { + struct radv_shader *shader = + container_of(pipeline->stages[pipeline->groups[i].recursive_shader].shader, struct radv_shader, base); + pipeline->groups[i].handle.recursive_shader_ptr = shader->va | radv_get_rt_priority(shader->info.stage); + } } }