|
Blender V5.3
|
#include <vk_shader_module.hh>
Public Member Functions | |
| ~VKShaderModule () | |
| void | finalize (StringRefNull name) |
| void | build_sources_hash (StringRef extra) |
Public Attributes | |
| std::string | original_sources |
| std::string | combined_sources |
| std::string | sources_hash |
| VkShaderModule | vk_shader_module = VK_NULL_HANDLE |
| shaderc::SpvCompilationResult | compilation_result |
| Vector< uint32_t > | spirv_binary |
| bool | is_ready = true |
Shader module.
A shader module contains shader code and can be used as a vertex/geometry/fragment/compute stage of a shader. The shader code in this sense doesn't need to be GLSL, but can also be SPIR-V binary.
For now this is just a data container so code can be reused when working with multiple shader stages.
Later we could load the SPIR-V binary directly from disk to skip front end compilation phase completely or skip shader module at all when the cache is already aware of this shader by using VK_EXT_shader_module_identifier.
Definition at line 34 of file vk_shader_module.hh.
| blender::gpu::VKShaderModule::~VKShaderModule | ( | ) |
Definition at line 17 of file vk_shader_module.cc.
References blender::gpu::VKDiscardPool::discard_pool_get(), blender::gpu::VKDiscardPool::discard_shader_module(), and vk_shader_module.
| void blender::gpu::VKShaderModule::build_sources_hash | ( | StringRef | extra | ) |
Build the sources hash from the combined_sources.
| extra | Additional data folded into the hash. This is used to distinguish cache entries with differing SPIR-V binary even though the sources are identical (e.g., the injected OpString shader name or potentially in the future whether debug information was generated). |
Definition at line 53 of file vk_shader_module.cc.
References blender::BLI_assert(), combined_sources, blender::blender::StringRefBase::data(), hash, blender::blender::StringRefBase::size(), and sources_hash.
Referenced by blender::gpu::read_spirv_from_disk().
| void blender::gpu::VKShaderModule::finalize | ( | StringRefNull | name | ) |
Finalize the shader module.
When compilation succeeded the VkShaderModule will be created and stored in vk_shader_module.
Definition at line 26 of file vk_shader_module.cc.
References blender::BLI_assert(), blender::StringRefNull::c_str(), compilation_result, lexit::Vector< T >::data(), blender::gpu::VKBackend::device, blender::gpu::VKDevice::functions, blender::gpu::VKBackend::get(), blender::gpu::debug::object_label(), lexit::Vector< T >::size(), spirv_binary, blender::gpu::VKDevice::vk_handle(), and vk_shader_module.
| std::string blender::gpu::VKShaderModule::combined_sources |
Single string containing GLSL source code after preprocessing.
Is cleared after compilation phase has completed. (VKShader::finalize_post).
Definition at line 48 of file vk_shader_module.hh.
Referenced by build_sources_hash(), and blender::gpu::compile_ex().
| shaderc::SpvCompilationResult blender::gpu::VKShaderModule::compilation_result |
Compilation result when compiling the shader module.
Is cleared after compilation phase has completed. (VKShader::finalize_post).
Definition at line 65 of file vk_shader_module.hh.
Referenced by blender::gpu::compile_ex(), and finalize().
| bool blender::gpu::VKShaderModule::is_ready = true |
Is compilation needed and is the compilation step done.
Is set to false when GLSL sources are loaded and will be set to true again after the compilation step. It will also be true when compilation has failed.
Definition at line 74 of file vk_shader_module.hh.
| std::string blender::gpu::VKShaderModule::original_sources |
Single string containing GLSL source code before preprocessing.
Is cleared after compilation phase has completed. (VKShader::finalize_post).
Definition at line 41 of file vk_shader_module.hh.
Referenced by blender::gpu::compile_ex().
| std::string blender::gpu::VKShaderModule::sources_hash |
Hash of the combined sources. Used to generate the name inside spirv cache.
Definition at line 53 of file vk_shader_module.hh.
Referenced by build_sources_hash(), blender::gpu::read_spirv_from_disk(), and blender::gpu::write_spirv_to_disk().
Definition at line 66 of file vk_shader_module.hh.
Referenced by blender::gpu::compile_ex(), finalize(), blender::gpu::read_spirv_from_disk(), and blender::gpu::write_spirv_to_disk().
| VkShaderModule blender::gpu::VKShaderModule::vk_shader_module = VK_NULL_HANDLE |
Vulkan handler of the shader module.
Definition at line 58 of file vk_shader_module.hh.
Referenced by blender::gpu::VKShader::ensure_and_get_compute_pipeline(), blender::gpu::VKShader::ensure_and_get_graphics_pipeline(), blender::gpu::VKShader::ensure_graphics_pipelines(), finalize(), and ~VKShaderModule().