From 48645f21b5222f383681810a04b97d3f50ae427e Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 17 Apr 2026 10:54:04 +0100 Subject: [PATCH] radv: initialize nir_shader_compiler_options directly in compiler info Signed-off-by: Rhys Perry Reviewed-by: Konstantin Seurer Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/meta/radv_meta.c | 2 +- src/amd/vulkan/radv_device.c | 3 +-- src/amd/vulkan/radv_physical_device.c | 2 -- src/amd/vulkan/radv_physical_device.h | 2 -- src/amd/vulkan/radv_pipeline_graphics.c | 3 +-- src/amd/vulkan/radv_pipeline_rt.c | 2 +- src/amd/vulkan/radv_shader.c | 17 +++++++++-------- src/amd/vulkan/radv_shader.h | 2 +- 8 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/amd/vulkan/meta/radv_meta.c b/src/amd/vulkan/meta/radv_meta.c index eb3cba511f4..c37c1fbb133 100644 --- a/src/amd/vulkan/meta/radv_meta.c +++ b/src/amd/vulkan/meta/radv_meta.c @@ -347,7 +347,7 @@ radv_device_init_meta(struct radv_device *device) if (pdev->emulate_etc2) { device->meta_state.etc_decode.allocator = &device->meta_state.alloc; - device->meta_state.etc_decode.nir_options = &pdev->nir_options[MESA_SHADER_COMPUTE]; + device->meta_state.etc_decode.nir_options = &device->compiler_info.nir_options[MESA_SHADER_COMPUTE]; device->meta_state.etc_decode.pipeline_cache = device->meta_state.cache; vk_texcompress_etc2_init(&device->vk, &device->meta_state.etc_decode); diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index a284f4f6275..a191396ae63 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -1221,8 +1221,7 @@ radv_device_init_compiler_info(struct radv_device *device) .spirv_caps = vk_physical_device_get_spirv_capabilities(device->vk.physical), }; - for (uint32_t s = 0; s < MESA_VULKAN_SHADER_STAGES; s++) - info.nir_options[s] = pdev->nir_options[s]; + radv_get_nir_options(&info); device->compiler_info = info; } diff --git a/src/amd/vulkan/radv_physical_device.c b/src/amd/vulkan/radv_physical_device.c index 5e4222c0ff1..5d4979de98c 100644 --- a/src/amd/vulkan/radv_physical_device.c +++ b/src/amd/vulkan/radv_physical_device.c @@ -2688,8 +2688,6 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm radv_physical_device_init_cache_key(pdev); - radv_get_nir_options(pdev); - if (radv_device_get_cache_uuid(pdev, pdev->cache_uuid)) { result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, "cannot generate UUID"); goto fail_wsi; diff --git a/src/amd/vulkan/radv_physical_device.h b/src/amd/vulkan/radv_physical_device.h index a81bbbabe16..75b5f0ab681 100644 --- a/src/amd/vulkan/radv_physical_device.h +++ b/src/amd/vulkan/radv_physical_device.h @@ -178,8 +178,6 @@ struct radv_physical_device { dev_t render_devid; #endif - nir_shader_compiler_options nir_options[MESA_VULKAN_SHADER_STAGES]; - enum radv_queue_family vk_queue_to_radv[RADV_MAX_QUEUE_FAMILIES]; uint32_t num_queues; diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index a707af40ae7..b611369fe50 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -2225,7 +2225,6 @@ static void radv_pipeline_import_retained_shaders(const struct radv_device *device, struct radv_graphics_lib_pipeline *lib, struct radv_shader_stage *stages) { - const struct radv_physical_device *pdev = radv_device_physical(device); struct radv_retained_shaders *retained_shaders = &lib->retained_shaders; /* Import the stages (SPIR-V only in case of cache hits). */ @@ -2244,7 +2243,7 @@ radv_pipeline_import_retained_shaders(const struct radv_device *device, struct r int64_t stage_start = os_time_get_nano(); /* Deserialize the NIR shader. */ - const struct nir_shader_compiler_options *options = &pdev->nir_options[s]; + const struct nir_shader_compiler_options *options = &device->compiler_info.nir_options[s]; struct blob_reader blob_reader; blob_reader_init(&blob_reader, retained_shaders->stages[s].serialized_nir, retained_shaders->stages[s].serialized_nir_size); diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index 4214d39c917..d85ea40217e 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -1051,7 +1051,7 @@ compile_rt_prolog(struct radv_device *device, struct radv_ray_tracing_pipeline * struct radv_shader_stage prolog_stage = {0}; struct radv_shader_debug_info debug = {0}; radv_build_rt_prolog(&device->compiler_info, &prolog_stage, uses_descriptor_heap, &debug); - prolog_stage.nir->options = &pdev->nir_options[MESA_SHADER_COMPUTE]; + prolog_stage.nir->options = &device->compiler_info.nir_options[MESA_SHADER_COMPUTE]; radv_optimize_nir(prolog_stage.nir, false); radv_postprocess_nir(&device->compiler_info, NULL, &prolog_stage); diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index c0922b45c85..818451fc60a 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -53,15 +53,16 @@ #endif static void -get_nir_options_for_stage(struct radv_physical_device *pdev, mesa_shader_stage stage) +get_nir_options_for_stage(struct radv_compiler_info *compiler_info, mesa_shader_stage stage) { - nir_shader_compiler_options *options = &pdev->nir_options[stage]; - const bool split_fma = (stage <= MESA_SHADER_GEOMETRY || stage == MESA_SHADER_MESH) && pdev->cache_key.split_fma; + nir_shader_compiler_options *options = &compiler_info->nir_options[stage]; + const bool split_fma = + (stage <= MESA_SHADER_GEOMETRY || stage == MESA_SHADER_MESH) && compiler_info->cache_key->split_fma; - ac_nir_set_options(&pdev->info.compiler_info, pdev->use_llvm, options); + ac_nir_set_options(compiler_info->ac, compiler_info->debug.use_llvm, options); - options->lower_ffma16 = split_fma || pdev->info.gfx_level < GFX9; - options->lower_ffma32 = split_fma || pdev->info.gfx_level < GFX10_3; + options->lower_ffma16 = split_fma || compiler_info->ac->gfx_level < GFX9; + options->lower_ffma32 = split_fma || compiler_info->ac->gfx_level < GFX10_3; options->lower_ffma64 = split_fma; options->max_unroll_iterations = 32; options->max_unroll_iterations_aggressive = 128; @@ -71,10 +72,10 @@ get_nir_options_for_stage(struct radv_physical_device *pdev, mesa_shader_stage s } void -radv_get_nir_options(struct radv_physical_device *pdev) +radv_get_nir_options(struct radv_compiler_info *compiler_info) { for (mesa_shader_stage stage = MESA_SHADER_VERTEX; stage < MESA_VULKAN_SHADER_STAGES; stage++) - get_nir_options_for_stage(pdev, stage); + get_nir_options_for_stage(compiler_info, stage); } static uint8_t diff --git a/src/amd/vulkan/radv_shader.h b/src/amd/vulkan/radv_shader.h index a0dd8ffe20d..532471616f4 100644 --- a/src/amd/vulkan/radv_shader.h +++ b/src/amd/vulkan/radv_shader.h @@ -758,7 +758,7 @@ bool radv_consider_culling(const struct radv_compiler_info *compiler_info, struc uint64_t ps_inputs_read, unsigned num_vertices_per_primitive, const struct radv_shader_info *info); -void radv_get_nir_options(struct radv_physical_device *pdev); +void radv_get_nir_options(struct radv_compiler_info *compiler_info); enum radv_rt_lowering_mode { RADV_RT_LOWERING_MODE_MONOLITHIC,