radv: improve skipping of creation of NIR for cached rt pipeline libraries

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38263>
This commit is contained in:
Rhys Perry 2026-01-27 10:54:42 +00:00 committed by Marge Bot
parent 89eefdcadb
commit 3fed41eade
3 changed files with 11 additions and 5 deletions

View file

@ -441,8 +441,9 @@ struct radv_ray_tracing_group_cache_data {
};
struct radv_ray_tracing_stage_cache_data {
uint32_t stack_size : 31;
uint32_t stack_size : 30;
uint32_t has_shader : 1;
uint32_t needs_nir : 1;
uint8_t sha1[SHA1_DIGEST_LENGTH];
struct radv_ray_tracing_stage_info info;
};
@ -482,11 +483,12 @@ radv_ray_tracing_pipeline_cache_search(struct radv_device *device, struct vk_pip
pipeline->stages[i].stack_size = data->stages[i].stack_size;
pipeline->stages[i].info = data->stages[i].info;
memcpy(pipeline->stages[i].sha1, data->stages[i].sha1, sizeof(pipeline->stages[i].sha1));
pipeline->stages[i].needs_nir = data->stages[i].needs_nir;
if (data->stages[i].has_shader)
pipeline->stages[i].shader = radv_shader_ref(pipeline_obj->shaders[idx++]);
if (data->is_library) {
if (pipeline->stages[i].needs_nir) {
pipeline->stages[i].nir = radv_pipeline_cache_lookup_nir_handle(device, cache, pipeline->stages[i].sha1);
complete &= pipeline->stages[i].nir != NULL;
}
@ -552,6 +554,7 @@ radv_ray_tracing_pipeline_cache_insert(struct radv_device *device, struct vk_pip
data->stages[i].stack_size = pipeline->stages[i].stack_size;
data->stages[i].info = pipeline->stages[i].info;
data->stages[i].has_shader = !!pipeline->stages[i].shader;
data->stages[i].needs_nir = data->is_library && pipeline->stages[i].nir;
memcpy(data->stages[i].sha1, pipeline->stages[i].sha1, sizeof(pipeline->stages[i].sha1));
if (pipeline->stages[i].shader)

View file

@ -268,8 +268,10 @@ static void
radv_rt_fill_stage_info(const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, struct radv_ray_tracing_stage *stages)
{
uint32_t idx;
for (idx = 0; idx < pCreateInfo->stageCount; idx++)
for (idx = 0; idx < pCreateInfo->stageCount; idx++) {
stages[idx].stage = vk_to_mesa_shader_stage(pCreateInfo->pStages[idx].stage);
stages[idx].needs_nir = true;
}
if (pCreateInfo->pLibraryInfo) {
for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
@ -674,7 +676,7 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca
bool can_use_monolithic = !library && pipeline->stage_count < 50;
for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) {
if (rt_stages[i].nir)
if (rt_stages[i].nir || !rt_stages[i].needs_nir)
continue;
int64_t stage_start = os_time_get_nano();
@ -749,7 +751,7 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca
inline_any_hit_shaders |= raygen_lowering_mode == RADV_RT_LOWERING_MODE_MONOLITHIC && !raygen_imported;
for (uint32_t idx = 0; idx < pCreateInfo->stageCount; idx++) {
if (rt_stages[idx].nir)
if (rt_stages[idx].nir || !rt_stages[idx].needs_nir)
continue;
int64_t stage_start = os_time_get_nano();

View file

@ -100,6 +100,7 @@ struct radv_ray_tracing_stage {
struct radv_shader *shader;
mesa_shader_stage stage;
uint32_t stack_size;
bool needs_nir;
struct radv_ray_tracing_stage_info info;