Module: Mesa
Branch: main
Commit: 334a20ae28a140c26887d65a1856b7b5916ae394
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=334a20ae28a140c26887d65a1856b7b5916ae394

Author: Konstantin Seurer <[email protected]>
Date:   Thu Jun  8 15:58:19 2023 +0200

radv: Implement executable properties for ray tracing stages

Reviewed-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Daniel Schürmann <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23524>

---

 src/amd/vulkan/radv_pipeline.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index eeef89a2228..80bfa330a83 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -693,10 +693,14 @@ radv_postprocess_nir(struct radv_device *device, const 
struct radv_pipeline_layo
 static uint32_t
 radv_get_executable_count(struct radv_pipeline *pipeline)
 {
-   if (pipeline->type == RADV_PIPELINE_RAY_TRACING)
-      return 1;
-
    uint32_t ret = 0;
+
+   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;
+   }
+
    for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; ++i) {
       if (!pipeline->shaders[i])
          continue;
@@ -714,8 +718,19 @@ static struct radv_shader *
 radv_get_shader_from_executable_index(struct radv_pipeline *pipeline, int 
index, gl_shader_stage *stage)
 {
    if (pipeline->type == RADV_PIPELINE_RAY_TRACING) {
-      *stage = MESA_SHADER_INTERSECTION;
-      return pipeline->shaders[*stage];
+      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))
+            continue;
+
+         if (!index) {
+            *stage = rt_stage->stage;
+            return container_of(rt_stage->shader, struct radv_shader, base);
+         }
+
+         index--;
+      }
    }
 
    for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; ++i) {

Reply via email to