From f4b9c5b1d0ca7b9f9aae2319eda2b46e6f57efa9 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 7 Aug 2023 09:40:01 +0200 Subject: [PATCH] radv: store pipeline create flags to radv_pipeline::create_flags This is a common practice in vulkan/runtime and this will be easier to use extended pipeline create flags. Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_pipeline_cache.c | 2 +- src/amd/vulkan/radv_pipeline_compute.c | 18 +++++----- src/amd/vulkan/radv_pipeline_graphics.c | 47 ++++++++++++++------------ src/amd/vulkan/radv_pipeline_rt.c | 60 +++++++++++++++++++-------------- src/amd/vulkan/radv_private.h | 2 ++ src/amd/vulkan/radv_rt_shader.c | 7 ++-- 6 files changed, 77 insertions(+), 59 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c index b051964..25317be 100644 --- a/src/amd/vulkan/radv_pipeline_cache.c +++ b/src/amd/vulkan/radv_pipeline_cache.c @@ -473,7 +473,7 @@ radv_ray_tracing_pipeline_cache_search(struct radv_device *device, struct vk_pip struct radv_pipeline_cache_object *pipeline_obj = container_of(object, struct radv_pipeline_cache_object, base); - bool is_library = pCreateInfo->flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR; + bool is_library = pipeline->base.base.create_flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR; bool complete = true; unsigned idx = 0; diff --git a/src/amd/vulkan/radv_pipeline_compute.c b/src/amd/vulkan/radv_pipeline_compute.c index bee7591..12adf0f 100644 --- a/src/amd/vulkan/radv_pipeline_compute.c +++ b/src/amd/vulkan/radv_pipeline_compute.c @@ -106,9 +106,10 @@ radv_compute_generate_pm4(const struct radv_device *device, struct radv_compute_ } static struct radv_pipeline_key -radv_generate_compute_pipeline_key(const struct radv_device *device, const VkComputePipelineCreateInfo *pCreateInfo) +radv_generate_compute_pipeline_key(const struct radv_device *device, const struct radv_compute_pipeline *pipeline, + const VkComputePipelineCreateInfo *pCreateInfo) { - return radv_generate_pipeline_key(device, &pCreateInfo->stage, 1, pCreateInfo->flags, pCreateInfo->pNext); + return radv_generate_pipeline_key(device, &pCreateInfo->stage, 1, pipeline->base.create_flags, pCreateInfo->pNext); } void @@ -181,13 +182,13 @@ static VkResult radv_compute_pipeline_compile(struct radv_compute_pipeline *pipeline, struct radv_pipeline_layout *pipeline_layout, struct radv_device *device, struct vk_pipeline_cache *cache, const struct radv_pipeline_key *pipeline_key, - const VkPipelineShaderStageCreateInfo *pStage, const VkPipelineCreateFlags flags, + const VkPipelineShaderStageCreateInfo *pStage, const VkPipelineCreationFeedbackCreateInfo *creation_feedback) { struct radv_shader_binary *cs_binary = NULL; unsigned char hash[20]; - bool keep_executable_info = radv_pipeline_capture_shaders(device, flags); - bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, flags); + bool keep_executable_info = radv_pipeline_capture_shaders(device, pipeline->base.create_flags); + bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pipeline->base.create_flags); struct radv_shader_stage cs_stage = {0}; VkPipelineCreationFeedback pipeline_feedback = { .flags = VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT, @@ -212,7 +213,7 @@ radv_compute_pipeline_compile(struct radv_compute_pipeline *pipeline, struct rad goto done; } - if (flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT) + if (pipeline->base.create_flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT) return VK_PIPELINE_COMPILE_REQUIRED; int64_t stage_start = os_time_get_nano(); @@ -265,15 +266,16 @@ radv_compute_pipeline_create(VkDevice _device, VkPipelineCache _cache, const VkC } radv_pipeline_init(device, &pipeline->base, RADV_PIPELINE_COMPUTE); + pipeline->base.create_flags = pCreateInfo->flags; pipeline->base.is_internal = _cache == device->meta_state.cache; const VkPipelineCreationFeedbackCreateInfo *creation_feedback = vk_find_struct_const(pCreateInfo->pNext, PIPELINE_CREATION_FEEDBACK_CREATE_INFO); - struct radv_pipeline_key key = radv_generate_compute_pipeline_key(device, pCreateInfo); + struct radv_pipeline_key key = radv_generate_compute_pipeline_key(device, pipeline, pCreateInfo); result = radv_compute_pipeline_compile(pipeline, pipeline_layout, device, cache, &key, &pCreateInfo->stage, - pCreateInfo->flags, creation_feedback); + creation_feedback); if (result != VK_SUCCESS) { radv_pipeline_destroy(device, &pipeline->base, pAllocator); return result; diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index 1f07725..8626dc7 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -293,7 +293,7 @@ radv_pipeline_init_blend_state(struct radv_graphics_pipeline *pipeline, const st } static bool -radv_pipeline_uses_vrs_attachment(const VkGraphicsPipelineCreateInfo *pCreateInfo, +radv_pipeline_uses_vrs_attachment(const struct radv_graphics_pipeline *pipeline, const struct vk_graphics_pipeline_state *state) { VK_FROM_HANDLE(vk_render_pass, render_pass, state->rp->render_pass); @@ -305,7 +305,7 @@ radv_pipeline_uses_vrs_attachment(const VkGraphicsPipelineCreateInfo *pCreateInf return !!subpass->fragment_shading_rate_attachment; } - return (pCreateInfo->flags & VK_PIPELINE_CREATE_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR) != 0; + return (pipeline->base.create_flags & VK_PIPELINE_CREATE_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR) != 0; } static void @@ -736,7 +736,7 @@ radv_pipeline_import_graphics_info(struct radv_device *device, struct radv_graph * * In that case discard whatever was imported before. */ - if (pCreateInfo->flags & VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT && + if (pipeline->base.create_flags & VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT && !pipeline_layout->independent_sets) { radv_pipeline_layout_finish(device, layout); radv_pipeline_layout_init(device, layout, false /* independent_sets */); @@ -824,7 +824,7 @@ radv_pipeline_init_input_assembly_state(const struct radv_device *device, struct } static bool -radv_pipeline_uses_ds_feedback_loop(const VkGraphicsPipelineCreateInfo *pCreateInfo, +radv_pipeline_uses_ds_feedback_loop(const struct radv_graphics_pipeline *pipeline, const struct vk_graphics_pipeline_state *state) { VK_FROM_HANDLE(vk_render_pass, render_pass, state->rp->render_pass); @@ -841,7 +841,7 @@ radv_pipeline_uses_ds_feedback_loop(const VkGraphicsPipelineCreateInfo *pCreateI } } - return (pCreateInfo->flags & VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT) != 0; + return (pipeline->base.create_flags & VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT) != 0; } static void @@ -1135,7 +1135,7 @@ radv_pipeline_init_dynamic_state(const struct radv_device *device, struct radv_g } if (states & RADV_DYNAMIC_ATTACHMENT_FEEDBACK_LOOP_ENABLE) { - bool uses_ds_feedback_loop = radv_pipeline_uses_ds_feedback_loop(pCreateInfo, state); + bool uses_ds_feedback_loop = radv_pipeline_uses_ds_feedback_loop(pipeline, state); dynamic->feedback_loop_aspects = uses_ds_feedback_loop ? (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT) : VK_IMAGE_ASPECT_NONE; @@ -1816,7 +1816,7 @@ radv_generate_graphics_pipeline_key(const struct radv_device *device, const stru { const struct radv_physical_device *pdevice = device->physical_device; struct radv_pipeline_key key = radv_generate_pipeline_key(device, pCreateInfo->pStages, pCreateInfo->stageCount, - pCreateInfo->flags, pCreateInfo->pNext); + pipeline->base.create_flags, pCreateInfo->pNext); key.lib_flags = lib_flags; key.has_multiview_view_index = state->rp ? !!state->rp->view_mask : 0; @@ -2371,7 +2371,7 @@ radv_pipeline_load_retained_shaders(const struct radv_device *device, struct rad { const VkPipelineLibraryCreateInfoKHR *libs_info = vk_find_struct_const(pCreateInfo->pNext, PIPELINE_LIBRARY_CREATE_INFO_KHR); - const bool link_optimize = (pCreateInfo->flags & VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT) != 0; + const bool link_optimize = (pipeline->base.create_flags & VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT) != 0; /* Nothing to load if no libs are imported. */ if (!libs_info) @@ -2633,8 +2633,8 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk struct radv_shader_binary *gs_copy_binary = NULL; struct radv_shader_part_binary *ps_epilog_binary = NULL; unsigned char hash[20]; - bool keep_executable_info = radv_pipeline_capture_shaders(device, pCreateInfo->flags); - bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pCreateInfo->flags); + bool keep_executable_info = radv_pipeline_capture_shaders(device, pipeline->base.create_flags); + bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pipeline->base.create_flags); struct radv_shader_stage stages[MESA_VULKAN_SHADER_STAGES]; const VkPipelineCreationFeedbackCreateInfo *creation_feedback = vk_find_struct_const(pCreateInfo->pNext, PIPELINE_CREATION_FEEDBACK_CREATE_INFO); @@ -2643,7 +2643,8 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk }; bool skip_shaders_cache = false; VkResult result = VK_SUCCESS; - const bool retain_shaders = !!(pCreateInfo->flags & VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT); + const bool retain_shaders = + !!(pipeline->base.create_flags & VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT); struct radv_retained_shaders *retained_shaders = NULL; int64_t pipeline_start = os_time_get_nano(); @@ -2682,7 +2683,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk */ if (fast_linking_enabled || keep_executable_info) { skip_shaders_cache = true; - } else if ((pCreateInfo->flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) && retain_shaders) { + } else if ((pipeline->base.create_flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) && retain_shaders) { for (uint32_t i = 0; i < MESA_VULKAN_SHADER_STAGES; i++) { if (stages[i].entrypoint && !stages[i].spirv.size) { skip_shaders_cache = true; @@ -2716,7 +2717,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk goto done; } - if (pCreateInfo->flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT) + if (pipeline->base.create_flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT) return VK_PIPELINE_COMPILE_REQUIRED; if (retain_shaders) { @@ -3841,7 +3842,8 @@ radv_pipeline_init_extra(struct radv_graphics_pipeline *pipeline, } static bool -radv_is_fast_linking_enabled(const VkGraphicsPipelineCreateInfo *pCreateInfo) +radv_is_fast_linking_enabled(const struct radv_graphics_pipeline *pipeline, + const VkGraphicsPipelineCreateInfo *pCreateInfo) { const VkPipelineLibraryCreateInfoKHR *libs_info = vk_find_struct_const(pCreateInfo->pNext, PIPELINE_LIBRARY_CREATE_INFO_KHR); @@ -3849,7 +3851,7 @@ radv_is_fast_linking_enabled(const VkGraphicsPipelineCreateInfo *pCreateInfo) if (!libs_info) return false; - return !(pCreateInfo->flags & VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT); + return !(pipeline->base.create_flags & VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT); } bool @@ -3892,7 +3894,7 @@ radv_graphics_pipeline_init(struct radv_graphics_pipeline *pipeline, struct radv const struct radv_graphics_pipeline_create_info *extra) { VkGraphicsPipelineLibraryFlagBitsEXT needed_lib_flags = ALL_GRAPHICS_LIB_FLAGS; - bool fast_linking_enabled = radv_is_fast_linking_enabled(pCreateInfo); + bool fast_linking_enabled = radv_is_fast_linking_enabled(pipeline, pCreateInfo); struct radv_pipeline_layout pipeline_layout; struct vk_graphics_pipeline_state state = {0}; VkResult result = VK_SUCCESS; @@ -3906,7 +3908,7 @@ radv_graphics_pipeline_init(struct radv_graphics_pipeline *pipeline, struct radv /* If we have libraries, import them first. */ if (libs_info) { - const bool link_optimize = (pCreateInfo->flags & VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT) != 0; + const bool link_optimize = (pipeline->base.create_flags & VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT) != 0; for (uint32_t i = 0; i < libs_info->libraryCount; i++) { RADV_FROM_HANDLE(radv_pipeline, pipeline_lib, libs_info->pLibraries[i]); @@ -3994,7 +3996,7 @@ radv_graphics_pipeline_init(struct radv_graphics_pipeline *pipeline, struct radv pipeline->force_vrs_per_vertex = pipeline->base.shaders[pipeline->last_vgt_api_stage]->info.force_vrs_per_vertex; pipeline->rast_prim = vgt_gs_out_prim_type; pipeline->uses_out_of_order_rast = state.rs->rasterization_order_amd == VK_RASTERIZATION_ORDER_RELAXED_AMD; - pipeline->uses_vrs_attachment = radv_pipeline_uses_vrs_attachment(pCreateInfo, &state); + pipeline->uses_vrs_attachment = radv_pipeline_uses_vrs_attachment(pipeline, &state); pipeline->base.push_constant_size = pipeline_layout.push_constant_size; pipeline->base.dynamic_offset_count = pipeline_layout.dynamic_offset_count; @@ -4036,6 +4038,7 @@ radv_graphics_pipeline_create(VkDevice _device, VkPipelineCache _cache, const Vk return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); radv_pipeline_init(device, &pipeline->base, RADV_PIPELINE_GRAPHICS); + pipeline->base.create_flags = pCreateInfo->flags; pipeline->base.is_internal = _cache == device->meta_state.cache; result = radv_graphics_pipeline_init(pipeline, device, cache, pCreateInfo, extra); @@ -4076,21 +4079,22 @@ radv_graphics_lib_pipeline_init(struct radv_graphics_lib_pipeline *pipeline, str VkGraphicsPipelineLibraryFlagBitsEXT needed_lib_flags = lib_info ? lib_info->flags : 0; const VkPipelineLibraryCreateInfoKHR *libs_info = vk_find_struct_const(pCreateInfo->pNext, PIPELINE_LIBRARY_CREATE_INFO_KHR); - bool fast_linking_enabled = radv_is_fast_linking_enabled(pCreateInfo); + bool fast_linking_enabled = radv_is_fast_linking_enabled(&pipeline->base, pCreateInfo); struct vk_graphics_pipeline_state *state = &pipeline->graphics_state; struct radv_pipeline_layout *pipeline_layout = &pipeline->layout; pipeline->base.last_vgt_api_stage = MESA_SHADER_NONE; pipeline->base.retain_shaders = - (pCreateInfo->flags & VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT) != 0; + (pipeline->base.base.create_flags & VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT) != 0; pipeline->lib_flags = needed_lib_flags; radv_pipeline_layout_init(device, pipeline_layout, false); /* If we have libraries, import them first. */ if (libs_info) { - const bool link_optimize = (pCreateInfo->flags & VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT) != 0; + const bool link_optimize = + (pipeline->base.base.create_flags & VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT) != 0; for (uint32_t i = 0; i < libs_info->libraryCount; i++) { RADV_FROM_HANDLE(radv_pipeline, pipeline_lib, libs_info->pLibraries[i]); @@ -4135,6 +4139,7 @@ radv_graphics_lib_pipeline_create(VkDevice _device, VkPipelineCache _cache, return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); radv_pipeline_init(device, &pipeline->base.base, RADV_PIPELINE_GRAPHICS_LIB); + pipeline->base.base.create_flags = pCreateInfo->flags; pipeline->mem_ctx = ralloc_context(NULL); diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index b65f98d..e1a1a60 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -83,15 +83,16 @@ handle_from_stages(struct radv_device *device, struct radv_ray_tracing_stage *st } static struct radv_pipeline_key -radv_generate_rt_pipeline_key(const struct radv_device *device, const VkRayTracingPipelineCreateInfoKHR *pCreateInfo) +radv_generate_rt_pipeline_key(const struct radv_device *device, const struct radv_ray_tracing_pipeline *pipeline, + const VkRayTracingPipelineCreateInfoKHR *pCreateInfo) { struct radv_pipeline_key key = radv_generate_pipeline_key(device, pCreateInfo->pStages, pCreateInfo->stageCount, - pCreateInfo->flags, pCreateInfo->pNext); + pipeline->base.base.create_flags, pCreateInfo->pNext); if (pCreateInfo->pLibraryInfo) { for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) { - RADV_FROM_HANDLE(radv_pipeline, pipeline, pCreateInfo->pLibraryInfo->pLibraries[i]); - struct radv_ray_tracing_pipeline *library_pipeline = radv_pipeline_to_ray_tracing(pipeline); + RADV_FROM_HANDLE(radv_pipeline, pipeline_lib, pCreateInfo->pLibraryInfo->pLibraries[i]); + struct radv_ray_tracing_pipeline *library_pipeline = radv_pipeline_to_ray_tracing(pipeline_lib); /* apply shader robustness from merged shaders */ if (library_pipeline->traversal_storage_robustness2) key.stage_info[MESA_SHADER_INTERSECTION].storage_robustness2 = true; @@ -105,10 +106,12 @@ radv_generate_rt_pipeline_key(const struct radv_device *device, const VkRayTraci } static VkResult -radv_create_group_handles(struct radv_device *device, const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, - struct radv_ray_tracing_stage *stages, struct radv_ray_tracing_group *groups) +radv_create_group_handles(struct radv_device *device, const struct radv_ray_tracing_pipeline *pipeline, + const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, struct radv_ray_tracing_stage *stages, + struct radv_ray_tracing_group *groups) { - bool capture_replay = pCreateInfo->flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR; + bool capture_replay = + pipeline->base.base.create_flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR; for (unsigned i = 0; i < pCreateInfo->groupCount; ++i) { const VkRayTracingShaderGroupCreateInfoKHR *group_info = &pCreateInfo->pGroups[i]; switch (group_info->type) { @@ -161,12 +164,12 @@ radv_create_group_handles(struct radv_device *device, const VkRayTracingPipeline } static VkResult -radv_rt_fill_group_info(struct radv_device *device, const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, - struct radv_ray_tracing_stage *stages, +radv_rt_fill_group_info(struct radv_device *device, const struct radv_ray_tracing_pipeline *pipeline, + const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, struct radv_ray_tracing_stage *stages, struct radv_serialized_shader_arena_block *capture_replay_blocks, struct radv_ray_tracing_group *groups) { - VkResult result = radv_create_group_handles(device, pCreateInfo, stages, groups); + VkResult result = radv_create_group_handles(device, pipeline, pCreateInfo, stages, groups); uint32_t idx; for (idx = 0; idx < pCreateInfo->groupCount; idx++) { @@ -224,8 +227,8 @@ radv_rt_fill_group_info(struct radv_device *device, const VkRayTracingPipelineCr if (pCreateInfo->pLibraryInfo) { unsigned stage_count = pCreateInfo->stageCount; for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) { - RADV_FROM_HANDLE(radv_pipeline, pipeline, pCreateInfo->pLibraryInfo->pLibraries[i]); - struct radv_ray_tracing_pipeline *library_pipeline = radv_pipeline_to_ray_tracing(pipeline); + RADV_FROM_HANDLE(radv_pipeline, pipeline_lib, pCreateInfo->pLibraryInfo->pLibraries[i]); + struct radv_ray_tracing_pipeline *library_pipeline = radv_pipeline_to_ray_tracing(pipeline_lib); for (unsigned j = 0; j < library_pipeline->group_count; ++j) { struct radv_ray_tracing_group *dst = &groups[idx + j]; @@ -342,13 +345,14 @@ move_rt_instructions(nir_shader *shader) static VkResult radv_rt_nir_to_asm(struct radv_device *device, struct vk_pipeline_cache *cache, const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, const struct radv_pipeline_key *pipeline_key, - struct radv_shader_stage *stage, uint32_t *stack_size, - struct radv_serialized_shader_arena_block *replay_block, struct radv_shader **out_shader) + const struct radv_ray_tracing_pipeline *pipeline, struct radv_shader_stage *stage, + uint32_t *stack_size, struct radv_serialized_shader_arena_block *replay_block, + struct radv_shader **out_shader) { struct radv_shader_binary *binary; RADV_FROM_HANDLE(radv_pipeline_layout, pipeline_layout, pCreateInfo->layout); - bool keep_executable_info = radv_pipeline_capture_shaders(device, pCreateInfo->flags); - bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pCreateInfo->flags); + bool keep_executable_info = radv_pipeline_capture_shaders(device, pipeline->base.base.create_flags); + bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pipeline->base.base.create_flags); /* Gather shader info. */ nir_shader_gather_info(stage->nir, nir_shader_get_entrypoint(stage->nir)); @@ -398,7 +402,8 @@ radv_rt_nir_to_asm(struct radv_device *device, struct vk_pipeline_cache *cache, } bool dump_shader = radv_can_dump_shader(device, shaders[0], false); - bool replayable = pCreateInfo->flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR; + bool replayable = + pipeline->base.base.create_flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR; /* Compile NIR shader to AMD assembly. */ binary = radv_shader_nir_to_asm(device, stage, shaders, num_shaders, pipeline_key, keep_executable_info, @@ -436,7 +441,7 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca const struct radv_pipeline_key *key, struct radv_ray_tracing_pipeline *pipeline, struct radv_serialized_shader_arena_block *capture_replay_handles) { - if (pCreateInfo->flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT) + if (pipeline->base.base.create_flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT) return VK_PIPELINE_COMPILE_REQUIRED; VkResult result = VK_SUCCESS; @@ -460,7 +465,8 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca capture_replay_handles[idx].arena_va ? &capture_replay_handles[idx] : NULL; struct radv_shader *shader; - result = radv_rt_nir_to_asm(device, cache, pCreateInfo, key, &stage, &stack_size, replay_block, &shader); + result = + radv_rt_nir_to_asm(device, cache, pCreateInfo, key, pipeline, &stage, &stack_size, replay_block, &shader); stages[idx].stack_size = stack_size; stages[idx].shader = shader ? &shader->base : NULL; } else { @@ -481,7 +487,7 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca } } - if (pCreateInfo->flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) + if (pipeline->base.base.create_flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) return VK_SUCCESS; /* create traversal shader */ @@ -500,7 +506,7 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca .nir = traversal_module.nir, }; vk_pipeline_hash_shader_stage(&pStage, NULL, traversal_stage.shader_sha1); - result = radv_rt_nir_to_asm(device, cache, pCreateInfo, key, &traversal_stage, NULL, NULL, + result = radv_rt_nir_to_asm(device, cache, pCreateInfo, key, pipeline, &traversal_stage, NULL, NULL, &pipeline->base.base.shaders[MESA_SHADER_INTERSECTION]); return result; @@ -614,8 +620,6 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache, const VkRayTra VK_FROM_HANDLE(vk_pipeline_cache, cache, _cache); RADV_FROM_HANDLE(radv_pipeline_layout, pipeline_layout, pCreateInfo->layout); VkResult result; - bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pCreateInfo->flags); - bool keep_executable_info = radv_pipeline_capture_shaders(device, pCreateInfo->flags); const VkPipelineCreationFeedbackCreateInfo *creation_feedback = vk_find_struct_const(pCreateInfo->pNext, PIPELINE_CREATION_FEEDBACK_CREATE_INFO); if (creation_feedback) @@ -634,12 +638,13 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache, const VkRayTra return VK_ERROR_OUT_OF_HOST_MEMORY; radv_pipeline_init(device, &pipeline->base.base, RADV_PIPELINE_RAY_TRACING); + pipeline->base.base.create_flags = pCreateInfo->flags; pipeline->stage_count = local_create_info.stageCount; pipeline->group_count = local_create_info.groupCount; pipeline->stages = stages; pipeline->groups = groups; - struct radv_pipeline_key key = radv_generate_rt_pipeline_key(device, pCreateInfo); + struct radv_pipeline_key key = radv_generate_rt_pipeline_key(device, pipeline, pCreateInfo); /* cache robustness state for making merged shaders */ if (key.stage_info[MESA_SHADER_INTERSECTION].storage_robustness2) @@ -649,10 +654,13 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache, const VkRayTra pipeline->traversal_uniform_robustness2 = true; radv_rt_fill_stage_info(device, pCreateInfo, stages, &key); - result = radv_rt_fill_group_info(device, pCreateInfo, stages, capture_replay_blocks, pipeline->groups); + result = radv_rt_fill_group_info(device, pipeline, pCreateInfo, stages, capture_replay_blocks, pipeline->groups); if (result != VK_SUCCESS) goto fail; + bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pipeline->base.base.create_flags); + bool keep_executable_info = radv_pipeline_capture_shaders(device, pipeline->base.base.create_flags); + radv_hash_rt_shaders(pipeline->sha1, pCreateInfo, &key, pipeline->groups, radv_get_hash_flags(device, keep_statistic_info)); pipeline->base.base.pipeline_hash = *(uint64_t *)pipeline->sha1; @@ -669,7 +677,7 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache, const VkRayTra goto fail; } - if (!(pCreateInfo->flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR)) { + if (!(pipeline->base.base.create_flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR)) { compute_rt_stack_size(pCreateInfo, pipeline); compile_rt_prolog(device, pipeline); diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 359744d..5a07c36 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -2225,6 +2225,8 @@ struct radv_pipeline { struct vk_object_base base; enum radv_pipeline_type type; + VkPipelineCreateFlags create_flags; + struct vk_pipeline_cache_object *cache_object; bool is_internal; diff --git a/src/amd/vulkan/radv_rt_shader.c b/src/amd/vulkan/radv_rt_shader.c index c5c8297..8ce2463 100644 --- a/src/amd/vulkan/radv_rt_shader.c +++ b/src/amd/vulkan/radv_rt_shader.c @@ -1444,9 +1444,10 @@ radv_build_traversal_shader(struct radv_device *device, struct radv_ray_tracing_ .stack_base = 0, .stack_store_cb = store_stack_entry, .stack_load_cb = load_stack_entry, - .aabb_cb = - (pCreateInfo->flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) ? NULL : handle_candidate_aabb, - .triangle_cb = (pCreateInfo->flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) + .aabb_cb = (pipeline->base.base.create_flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) + ? NULL + : handle_candidate_aabb, + .triangle_cb = (pipeline->base.base.create_flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) ? NULL : handle_candidate_triangle, .data = &data, -- 2.7.4