|
Blender V5.3
|
#include <vk_pipeline_pool.hh>
Inherits blender::blender::NonCopyable.
Public Member Functions | |
| void | init () |
| void | discard (VKDiscardPool &discard_pool, VkPipelineLayout vk_pipeline_layout) |
| void | free_data (const VKDevice &device) |
Compute pipelines | |
| VkPipeline | get_or_create_compute_pipeline (const VKComputeInfo &compute_info, bool is_static_shader, VkPipeline vk_pipeline_base, StringRefNull name) |
Graphics pipelines | |
| VkPipeline | get_or_create_graphics_pipeline (const VKGraphicsInfo &graphics_info, bool is_static_shader, VkPipeline vk_pipeline_base, StringRefNull name, bool &r_created) |
Vertex input library | |
| VkPipeline | get_or_create_vertex_input_lib (const VKGraphicsInfo::VertexIn &vertex_input_info) |
Shaders library | |
| VkPipeline | get_or_create_shaders_lib (const VKGraphicsInfo::Shaders &shaders_info) |
Fragment output library | |
| VkPipeline | get_or_create_fragment_output_lib (const VKGraphicsInfo::FragmentOut &fragment_output_info) |
Persistent cache | |
| void | read_from_disk () |
| void | write_to_disk () |
| Public Member Functions inherited from blender::blender::NonCopyable | |
| NonCopyable (const NonCopyable &other)=delete | |
| NonCopyable & | operator= (const NonCopyable &other)=delete |
| NonCopyable ()=default | |
| NonCopyable (NonCopyable &&other)=default | |
| NonCopyable & | operator= (NonCopyable &&other)=default |
Friends | |
| class | VKDevice |
Pipelines are lazy initialized and same pipelines should share their handle.
A requirement of our render graph implementation is that changes of the pipeline can be detected based on the VkPipeline handle. We only want to rebind the pipeline handle when the handle actually changes. This improves performance (especially on NVIDIA) devices where pipeline binds are known to be costly.
Especially for graphics pipelines many parameters are needed to compile a graphics pipeline. Some of the information would be boiler plating; or at least from Blender point of view. To improve lookup performance we use a slimmed down version of the pipeline create info structs. The idea is that we can limit the required data because we control which data we actually use, removing the boiler plating and improve hashing performance better than the VkPipelineCache can give us.
TODO: Extensions like VK_EXT_graphics_pipeline_library should fit in this class and ease the development for graphics pipelines. Geometry in and frame-buffer out could be cached separately to reduce pipeline creation times. Most likely we will add support when we work on graphic pipelines. Recent drivers all support this extension, but the full coverage is still <20%. A fallback should made available for older drivers is required.
TODO: Creation of shader modules needs to be revisited. VK_EXT_graphics_pipeline_library deprecates the use of shader modules and use the spriv bin directly. In this extension the pipeline and shader module are the same. The current approach should also be revisited as the latest drivers all implement pipeline libraries, but there are some platforms where the driver isn't been updated and doesn't implement this extension. In that case shader modules should still be used.
Definition at line 380 of file vk_pipeline_pool.hh.
| void blender::gpu::VKPipelinePool::discard | ( | VKDiscardPool & | discard_pool, |
| VkPipelineLayout | vk_pipeline_layout ) |
Discard all pipelines that uses the given pipeline_layout.
Definition at line 606 of file vk_pipeline_pool.cc.
Referenced by VKDevice, and blender::gpu::VKShader::~VKShader().
| void blender::gpu::VKPipelinePool::free_data | ( | const VKDevice & | device | ) |
Destroy all created pipelines.
Function is called just before the device is removed. This cannot be done in the destructor as that would be called after the device is removed.
Definition at line 614 of file vk_pipeline_pool.cc.
References blender::gpu::VKDevice::functions, blender::gpu::VKDevice::vk_handle(), and VKDevice.
Referenced by blender::gpu::VKDevice::deinit(), and VKDevice.
| VkPipeline blender::gpu::VKPipelinePool::get_or_create_compute_pipeline | ( | const VKComputeInfo & | compute_info, |
| bool | is_static_shader, | ||
| VkPipeline | vk_pipeline_base, | ||
| StringRefNull | name ) |
Get an existing or create a new compute pipeline based on the provided ComputeInfo.
When vk_pipeline_base is a valid pipeline handle, the pipeline base will be used to speed up pipeline creation process.
| compute_info | Description of the pipeline to compile. |
| is_static_shader | Pipelines from static shaders are cached between Blender sessions. Pipelines from dynamic shaders are only cached for the duration of a single Blender session. |
| vk_pipeline_base | An already existing pipeline that can be used as a base when compiling the pipeline. |
| name | Name to give as a debug label when creating a pipeline. |
Definition at line 50 of file vk_pipeline_pool.cc.
Referenced by blender::gpu::VKShader::ensure_and_get_compute_pipeline(), and VKDevice.
| VkPipeline blender::gpu::VKPipelinePool::get_or_create_fragment_output_lib | ( | const VKGraphicsInfo::FragmentOut & | fragment_output_info | ) |
Get an existing or create a new fragment output library pipeline based on the provided info.
| fragment_output_info | Description of the pipeline to compile. |
Definition at line 570 of file vk_pipeline_pool.cc.
Referenced by blender::gpu::create_graphics_pipeline_libs(), and VKDevice.
| VkPipeline blender::gpu::VKPipelinePool::get_or_create_graphics_pipeline | ( | const VKGraphicsInfo & | graphics_info, |
| bool | is_static_shader, | ||
| VkPipeline | vk_pipeline_base, | ||
| StringRefNull | name, | ||
| bool & | r_created ) |
Get an existing or create a new graphics pipeline based on the provided GraphicsInfo.
When vk_pipeline_base is a valid pipeline handle, the pipeline base will be used to speed up pipeline creation process.
| graphics_info | Description of the pipeline to compile. |
| is_static_shader | Pipelines from static shaders are cached between Blender sessions. Pipelines from dynamic shaders are only cached for the duration of a single Blender session. |
| vk_pipeline_base | An already existing pipeline that can be used as a base when compiling the pipeline. |
| name | Name to give as a debug label when creating a pipeline. |
| r_created | Is set to true when this call has compiled a new pipeline. Otherwise it is set to false. |
Definition at line 128 of file vk_pipeline_pool.cc.
References BLI_assert_msg, blender::gpu::VKGraphicsInfo::fragment_out, blender::gpu::VKGraphicsInfo::shaders, blender::gpu::VKGraphicsInfo::FragmentOut::state, and blender::gpu::VKGraphicsInfo::Shaders::state.
Referenced by blender::gpu::VKShader::ensure_and_get_graphics_pipeline(), blender::gpu::VKShader::ensure_graphics_pipelines(), and VKDevice.
| VkPipeline blender::gpu::VKPipelinePool::get_or_create_shaders_lib | ( | const VKGraphicsInfo::Shaders & | shaders_info | ) |
Get an existing or create a new shaders library pipeline based on the provided info.
| shaders_info | Description of the pipeline to compile. |
Definition at line 529 of file vk_pipeline_pool.cc.
Referenced by blender::gpu::create_graphics_pipeline_libs(), and VKDevice.
| VkPipeline blender::gpu::VKPipelinePool::get_or_create_vertex_input_lib | ( | const VKGraphicsInfo::VertexIn & | vertex_input_info | ) |
Get an existing or create a new vertex input library pipeline based on the provided info.
| vertex_input_info | Description of the pipeline to compile. |
Definition at line 489 of file vk_pipeline_pool.cc.
Referenced by blender::gpu::create_graphics_pipeline_libs(), and VKDevice.
| void blender::gpu::VKPipelinePool::init | ( | ) |
Definition at line 33 of file vk_pipeline_pool.cc.
References blender::gpu::VKBackend::device, blender::gpu::VKDevice::functions, blender::gpu::VKBackend::get(), blender::gpu::debug::object_label(), blender::gpu::VKDevice::vk_handle(), and VKDevice.
Referenced by blender::gpu::VKDevice::init(), and VKDevice.
| void blender::gpu::VKPipelinePool::read_from_disk | ( | ) |
Read the static pipeline cache from cache file.
Pipeline caches requires blender to be build with WITH_BUILDINFO enabled . Between commits shader modules can change and shader module identifiers cannot be used. We use the build info to check if the identifiers can be reused.
Previous stored pipeline cache will not be read when G_DEBUG_GPU is enabled. In this case the shader modules will be compiled with other settings and any cached pipeline will not be used during this session.
NOTE: When developing shaders we assume that WITH_BUILDINFO is turned off or G_DEBUG_GPU flag is set.
Definition at line 673 of file vk_pipeline_pool.cc.
References blender::BLI_exists(), blender::BLI_file_touch(), CLOG_INFO, lexit::Vector< T >::data(), blender::gpu::VKBackend::device, blender::gpu::VKDevice::functions, blender::G, blender::G_DEBUG_GPU, blender::gpu::VKBackend::get(), blender::LOG, blender::gpu::VKDevice::vk_handle(), and VKDevice.
Referenced by blender::gpu::VKDevice::init(), and VKDevice.
| void blender::gpu::VKPipelinePool::write_to_disk | ( | ) |
Store the static pipeline cache to disk.
Pipeline caches requires blender to be build with WITH_BUILDINFO enabled . Between commits shader modules can change and shader module identifiers cannot be used. We use the build info to check if the identifiers can be reused.
The cache will not be written when G_DEBUG_GPU is active. In this case the shader modules will been generated with debug information and other compiler settings are used. This will clutter the pipeline cache.
NOTE: When developing shaders we assume that WITH_BUILDINFO is turned off or G_DEBUG_GPU flag is set.
Definition at line 729 of file vk_pipeline_pool.cc.
References CLOG_INFO, lexit::Vector< T >::data(), blender::gpu::VKBackend::device, blender::gpu::VKDevice::functions, blender::G, blender::G_DEBUG_GPU, blender::gpu::VKBackend::get(), blender::LOG, blender::gpu::VKDevice::vk_handle(), and VKDevice.
Referenced by blender::gpu::VKDevice::deinit(), and VKDevice.
|
friend |
Definition at line 381 of file vk_pipeline_pool.hh.
References discard(), free_data(), get_or_create_compute_pipeline(), get_or_create_fragment_output_lib(), get_or_create_graphics_pipeline(), get_or_create_shaders_lib(), get_or_create_vertex_input_lib(), init(), read_from_disk(), VKDevice, and write_to_disk().
Referenced by free_data(), init(), read_from_disk(), VKDevice, and write_to_disk().