Blender V5.3
blender::gpu::VKShaderModule Class Reference

#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

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~VKShaderModule()

blender::gpu::VKShaderModule::~VKShaderModule ( )

Member Function Documentation

◆ build_sources_hash()

void blender::gpu::VKShaderModule::build_sources_hash ( StringRef extra)

Build the sources hash from the combined_sources.

Parameters
extraAdditional 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().

◆ finalize()

Member Data Documentation

◆ combined_sources

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().

◆ compilation_result

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().

◆ is_ready

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.

◆ original_sources

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().

◆ sources_hash

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().

◆ spirv_binary

Vector<uint32_t> blender::gpu::VKShaderModule::spirv_binary

◆ vk_shader_module

VkShaderModule blender::gpu::VKShaderModule::vk_shader_module = VK_NULL_HANDLE

The documentation for this class was generated from the following files: