radv: initialize stage/next_stage earlier
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 24 Jul 2023 13:41:56 +0000 (15:41 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 26 Jul 2023 07:44:49 +0000 (07:44 +0000)
This will allow more refactoring.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24313>

src/amd/vulkan/radv_pipeline_compute.c
src/amd/vulkan/radv_pipeline_graphics.c
src/amd/vulkan/radv_pipeline_rt.c
src/amd/vulkan/radv_private.h
src/amd/vulkan/radv_shader_info.c

index 19a3f05..56e793b 100644 (file)
@@ -150,9 +150,9 @@ radv_compile_cs(struct radv_device *device, struct vk_pipeline_cache *cache, str
    nir_shader_gather_info(cs_stage->nir, nir_shader_get_entrypoint(cs_stage->nir));
 
    /* Run the shader info pass. */
-   radv_nir_shader_info_init(&cs_stage->info);
-   radv_nir_shader_info_pass(device, cs_stage->nir, MESA_SHADER_NONE, pipeline_layout, pipeline_key,
-                             RADV_PIPELINE_COMPUTE, false, &cs_stage->info);
+   radv_nir_shader_info_init(cs_stage->stage, MESA_SHADER_NONE, &cs_stage->info);
+   radv_nir_shader_info_pass(device, cs_stage->nir, pipeline_layout, pipeline_key, RADV_PIPELINE_COMPUTE, false,
+                             &cs_stage->info);
 
    radv_declare_shader_args(device, pipeline_key, &cs_stage->info, MESA_SHADER_COMPUTE, MESA_SHADER_NONE,
                             &cs_stage->args);
index 0690146..c8c48f0 100644 (file)
@@ -2116,9 +2116,7 @@ radv_fill_shader_info(struct radv_device *device, struct radv_graphics_pipeline
 
    radv_foreach_stage(i, active_nir_stages)
    {
-      gl_shader_stage next_stage = radv_get_next_stage(i, active_nir_stages);
-
-      radv_nir_shader_info_pass(device, stages[i].nir, next_stage, pipeline_layout, pipeline_key, pipeline->base.type,
+      radv_nir_shader_info_pass(device, stages[i].nir, pipeline_layout, pipeline_key, pipeline->base.type,
                                 i == pipeline->last_vgt_api_stage && consider_force_vrs, &stages[i].info);
    }
 
@@ -2192,9 +2190,9 @@ radv_create_gs_copy_shader(struct radv_device *device, struct vk_pipeline_cache
       .stage = MESA_SHADER_VERTEX,
       .shader_sha1 = {0},
    };
-   radv_nir_shader_info_init(&gs_copy_stage.info);
-   radv_nir_shader_info_pass(device, nir, MESA_SHADER_FRAGMENT, pipeline_layout, pipeline_key, RADV_PIPELINE_GRAPHICS,
-                             false, &gs_copy_stage.info);
+   radv_nir_shader_info_init(gs_copy_stage.stage, MESA_SHADER_FRAGMENT, &gs_copy_stage.info);
+   radv_nir_shader_info_pass(device, nir, pipeline_layout, pipeline_key, RADV_PIPELINE_GRAPHICS, false,
+                             &gs_copy_stage.info);
    gs_copy_stage.info.wave_size = 64;      /* Wave32 not supported. */
    gs_copy_stage.info.workgroup_size = 64; /* HW VS: separate waves, no workgroups */
    gs_copy_stage.info.so = gs_info->so;
@@ -2603,7 +2601,9 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk
 
    radv_foreach_stage(i, active_nir_stages)
    {
-      radv_nir_shader_info_init(&stages[i].info);
+      gl_shader_stage next_stage = radv_get_next_stage(i, active_nir_stages);
+
+      radv_nir_shader_info_init(i, next_stage, &stages[i].info);
    }
 
    /* Determine if shaders uses NGG before linking because it's needed for some NIR pass. */
index 0d5f6ad..82d1a95 100644 (file)
@@ -352,9 +352,9 @@ radv_rt_nir_to_asm(struct radv_device *device, struct vk_pipeline_cache *cache,
 
    /* Gather shader info. */
    nir_shader_gather_info(stage->nir, nir_shader_get_entrypoint(stage->nir));
-   radv_nir_shader_info_init(&stage->info);
-   radv_nir_shader_info_pass(device, stage->nir, MESA_SHADER_NONE, pipeline_layout, pipeline_key,
-                             RADV_PIPELINE_RAY_TRACING, false, &stage->info);
+   radv_nir_shader_info_init(stage->stage, MESA_SHADER_NONE, &stage->info);
+   radv_nir_shader_info_pass(device, stage->nir, pipeline_layout, pipeline_key, RADV_PIPELINE_RAY_TRACING, false,
+                             &stage->info);
 
    /* Declare shader arguments. */
    radv_declare_shader_args(device, pipeline_key, &stage->info, stage->stage, MESA_SHADER_NONE, &stage->args);
index 4a3ed05..f818890 100644 (file)
@@ -3028,12 +3028,12 @@ void llvm_compile_shader(const struct radv_nir_compiler_options *options, const
 /* radv_shader_info.h */
 struct radv_shader_info;
 
-void radv_nir_shader_info_pass(struct radv_device *device, const struct nir_shader *nir, gl_shader_stage next_stage,
+void radv_nir_shader_info_pass(struct radv_device *device, const struct nir_shader *nir,
                                const struct radv_pipeline_layout *layout, const struct radv_pipeline_key *pipeline_key,
                                const enum radv_pipeline_type pipeline_type, bool consider_force_vrs,
                                struct radv_shader_info *info);
 
-void radv_nir_shader_info_init(struct radv_shader_info *info);
+void radv_nir_shader_info_init(gl_shader_stage stage, gl_shader_stage next_stage, struct radv_shader_info *info);
 
 void radv_nir_shader_info_link(struct radv_device *device, const struct radv_pipeline_key *pipeline_key,
                                struct radv_pipeline_stage *stages);
index e443cae..986d087 100644 (file)
@@ -847,23 +847,23 @@ radv_get_user_data_0(const struct radv_device *device, struct radv_shader_info *
 }
 
 void
-radv_nir_shader_info_init(struct radv_shader_info *info)
+radv_nir_shader_info_init(gl_shader_stage stage, gl_shader_stage next_stage, struct radv_shader_info *info)
 {
    memset(info, 0, sizeof(*info));
 
    /* Assume that shaders can inline all push constants by default. */
    info->can_inline_all_push_constants = true;
+
+   info->stage = stage;
+   info->next_stage = next_stage;
 }
 
 void
-radv_nir_shader_info_pass(struct radv_device *device, const struct nir_shader *nir, gl_shader_stage next_stage,
+radv_nir_shader_info_pass(struct radv_device *device, const struct nir_shader *nir,
                           const struct radv_pipeline_layout *layout, const struct radv_pipeline_key *pipeline_key,
                           const enum radv_pipeline_type pipeline_type, bool consider_force_vrs,
                           struct radv_shader_info *info)
 {
-   info->stage = nir->info.stage;
-   info->next_stage = next_stage;
-
    struct nir_function *func = (struct nir_function *)exec_list_get_head_const(&nir->functions);
 
    if (layout && layout->dynamic_offset_count &&