Blender V5.0
blender::gpu::VKShader Class Reference

#include <vk_shader.hh>

Inherits blender::gpu::Shader.

Public Member Functions

 VKShader (const char *name)
virtual ~VKShader ()
void init (const shader::ShaderCreateInfo &info, bool is_batch_compilation) override
void vertex_shader_from_glsl (MutableSpan< StringRefNull > sources) override
void geometry_shader_from_glsl (MutableSpan< StringRefNull > sources) override
void fragment_shader_from_glsl (MutableSpan< StringRefNull > sources) override
void compute_shader_from_glsl (MutableSpan< StringRefNull > sources) override
bool finalize (const shader::ShaderCreateInfo *info=nullptr) override
bool finalize_post ()
bool is_ready () const
void warm_cache (int limit) override
void bind (const shader::SpecializationConstants *constants_state) override
void unbind () override
void uniform_float (int location, int comp_len, int array_size, const float *data) override
void uniform_int (int location, int comp_len, int array_size, const int *data) override
std::string resources_declare (const shader::ShaderCreateInfo &info) const override
std::string vertex_interface_declare (const shader::ShaderCreateInfo &info) const override
std::string fragment_interface_declare (const shader::ShaderCreateInfo &info) const override
std::string geometry_interface_declare (const shader::ShaderCreateInfo &info) const override
std::string geometry_layout_declare (const shader::ShaderCreateInfo &info) const override
std::string compute_layout_declare (const shader::ShaderCreateInfo &info) const override
VkPipeline ensure_and_get_compute_pipeline (const shader::SpecializationConstants &constants_state)
VkPipeline ensure_and_get_graphics_pipeline (GPUPrimType primitive, VKVertexAttributeObject &vao, VKStateManager &state_manager, VKFrameBuffer &framebuffer, shader::SpecializationConstants &constants_state)
const VKShaderInterfaceinterface_get () const
bool has_descriptor_set () const
VkDescriptorSetLayout vk_descriptor_set_layout_get () const
Public Member Functions inherited from blender::gpu::Shader
std::string defines_declare (const shader::ShaderCreateInfo &info) const
StringRefNull name_get () const
void parent_set (Shader *parent)
Shaderparent_get () const
 Shader (const char *name)
virtual ~Shader ()
void specialization_constants_init (const shader::ShaderCreateInfo &info)

Public Attributes

VKShaderModule vertex_module
VKShaderModule geometry_module
VKShaderModule fragment_module
VKShaderModule compute_module
bool compilation_finished = false
bool compilation_failed = false
VkPipelineLayout vk_pipeline_layout = VK_NULL_HANDLE
VKPushConstants push_constants
Public Attributes inherited from blender::gpu::Shader
ShaderInterfaceinterface = nullptr
uint16_t fragment_output_bits = 0
std::unique_ptr< const shader::SpecializationConstantsconstants
bool is_polyline = false

Additional Inherited Members

Static Public Member Functions inherited from blender::gpu::Shader
static void set_scene_linear_to_xyz_uniform (gpu::Shader *shader)
static void set_srgb_uniform (Context *ctx, gpu::Shader *shader)
static void set_framebuffer_srgb_target (int use_srgb_to_linear)
Protected Member Functions inherited from blender::gpu::Shader
void print_log (Span< StringRefNull > sources, const char *log, const char *stage, bool error, GPULogParser *parser)
Protected Attributes inherited from blender::gpu::Shader
char name [64]
Shaderparent_shader_ = nullptr

Detailed Description

Definition at line 25 of file vk_shader.hh.

Constructor & Destructor Documentation

◆ VKShader()

blender::gpu::VKShader::VKShader ( const char * name)

◆ ~VKShader()

Member Function Documentation

◆ bind()

void blender::gpu::VKShader::bind ( const shader::SpecializationConstants * constants_state)
overridevirtual

◆ compute_layout_declare()

◆ compute_shader_from_glsl()

void blender::gpu::VKShader::compute_shader_from_glsl ( MutableSpan< StringRefNull > sources)
overridevirtual

Implements blender::gpu::Shader.

Definition at line 569 of file vk_shader.cc.

References compute_module.

◆ ensure_and_get_compute_pipeline()

◆ ensure_and_get_graphics_pipeline()

VkPipeline blender::gpu::VKShader::ensure_and_get_graphics_pipeline ( GPUPrimType primitive,
VKVertexAttributeObject & vao,
VKStateManager & state_manager,
VKFrameBuffer & framebuffer,
shader::SpecializationConstants & constants_state )

Definition at line 1291 of file vk_shader.cc.

References blender::gpu::VKGraphicsInfo::VertexIn::attributes, blender::gpu::VKVertexAttributeObject::attributes, blender::gpu::VKGraphicsInfo::VertexIn::bindings, blender::gpu::VKVertexAttributeObject::bindings, BLI_assert, BLI_assert_msg, Vector< T, InlineBufferCapacity, Allocator >::clear(), blender::gpu::VKGraphicsInfo::FragmentOut::color_attachment_formats, blender::gpu::VKFrameBuffer::color_attachment_formats_get(), blender::gpu::VKFrameBuffer::color_attachment_size, blender::gpu::VKGraphicsInfo::FragmentOut::color_attachment_size, blender::gpu::VKGraphicsInfo::FragmentOut::depth_attachment_format, blender::gpu::VKFrameBuffer::depth_attachment_format_get(), ensure_and_get_graphics_pipeline(), blender::Vector< T, InlineBufferCapacity, Allocator >::extend(), Vector< T, InlineBufferCapacity, Allocator >::extend(), fragment_module, blender::gpu::VKGraphicsInfo::fragment_out, blender::gpu::VKGraphicsInfo::fragment_shader, geometry_module, blender::gpu::VKBackend::get(), blender::gpu::VKPipelinePool::get_or_create_graphics_pipeline(), GPU_PRIM_POINTS, interface_get, blender::gpu::StateManager::mutable_state, blender::gpu::VKGraphicsInfo::mutable_state, blender::gpu::Shader::name_get(), blender::gpu::debug::object_label(), blender::gpu::VKDevice::pipelines, blender::gpu::VKGraphicsInfo::pre_rasterization, blender::gpu::VKGraphicsInfo::FragmentShader::scissors, blender::gpu::VKGraphicsInfo::specialization_constants, blender::gpu::StateManager::state, blender::gpu::VKGraphicsInfo::state, blender::gpu::VKGraphicsInfo::FragmentOut::stencil_attachment_format, blender::gpu::VKFrameBuffer::stencil_attachment_format_get(), blender::gpu::to_vk_primitive_topology(), blender::gpu::shader::SpecializationConstants::values, blender::gpu::VKGraphicsInfo::vertex_in, vertex_module, blender::gpu::VKGraphicsInfo::FragmentShader::viewports, blender::gpu::VKGraphicsInfo::FragmentShader::vk_fragment_module, blender::gpu::VKGraphicsInfo::PreRasterization::vk_geometry_module, blender::gpu::VKGraphicsInfo::vk_pipeline_layout, vk_pipeline_layout, blender::gpu::VKFrameBuffer::vk_render_areas_append(), blender::gpu::VKGraphicsInfo::VertexIn::vk_topology, blender::gpu::VKGraphicsInfo::PreRasterization::vk_vertex_module, and blender::gpu::VKFrameBuffer::vk_viewports_append().

Referenced by ensure_and_get_graphics_pipeline(), and blender::gpu::VKContext::update_pipeline_data().

◆ finalize()

◆ finalize_post()

bool blender::gpu::VKShader::finalize_post ( )

◆ fragment_interface_declare()

std::string blender::gpu::VKShader::fragment_interface_declare ( const shader::ShaderCreateInfo & info) const
overridevirtual

◆ fragment_shader_from_glsl()

void blender::gpu::VKShader::fragment_shader_from_glsl ( MutableSpan< StringRefNull > sources)
overridevirtual

Implements blender::gpu::Shader.

Definition at line 564 of file vk_shader.cc.

References fragment_module.

◆ geometry_interface_declare()

◆ geometry_layout_declare()

◆ geometry_shader_from_glsl()

void blender::gpu::VKShader::geometry_shader_from_glsl ( MutableSpan< StringRefNull > sources)
overridevirtual

Implements blender::gpu::Shader.

Definition at line 559 of file vk_shader.cc.

References geometry_module.

Referenced by finalize().

◆ has_descriptor_set()

bool blender::gpu::VKShader::has_descriptor_set ( ) const
inline

Some shaders don't have a descriptor set and should not bind any descriptor set to the pipeline. This function can be used to determine if a descriptor set can be bound when this shader or one of its pipelines are active.

Definition at line 107 of file vk_shader.hh.

◆ init()

◆ interface_get()

const VKShaderInterface & blender::gpu::VKShader::interface_get ( ) const

◆ is_ready()

bool blender::gpu::VKShader::is_ready ( ) const

Check if needed compilation steps have been finished.

Returns true when all modules that needed compilation have finished their compilation steps. Compilations with errors are still considered finished. Returns false when compilation is still needed for one of the shader modules.

Definition at line 666 of file vk_shader.cc.

References compilation_finished.

◆ resources_declare()

std::string blender::gpu::VKShader::resources_declare ( const shader::ShaderCreateInfo & info) const
overridevirtual

Implements blender::gpu::Shader.

Definition at line 745 of file vk_shader.cc.

References ShaderCreateInfo::PushConst::array_size, blender::gpu::shader::ShaderCreateInfo::batch_resources_, BLI_assert_unreachable, blender::gpu::shader::bool_t, blender::gpu::shader::ShaderCreateInfo::compilation_constants_, blender::gpu::VKPushConstants::Layout::descriptor_set_location_get(), blender::gpu::shader::float_t, blender::gpu::shader::ShaderCreateInfo::geometry_resources_, blender::gpu::shader::SpecializationConstant::Value::i, blender::gpu::shader::int_t, interface_get(), blender::gpu::shader::SpecializationConstant::name, ShaderCreateInfo::PushConst::name, ShaderCreateInfo::SharedVariable::name, blender::gpu::VKPushConstants::NONE, blender::gpu::shader::ShaderCreateInfo::pass_resources_, blender::gpu::print_resource(), blender::gpu::VKPushConstants::PUSH_CONSTANTS, blender::gpu::shader::ShaderCreateInfo::push_constants_, blender::gpu::VKShaderInterface::push_constants_layout_get(), blender::gpu::shader::ShaderCreateInfo::shared_variables_, blender::gpu::shader::ShaderCreateInfo::specialization_constants_, blender::gpu::VKPushConstants::Layout::storage_type_get(), blender::gpu::to_string(), blender::gpu::shader::SpecializationConstant::type, ShaderCreateInfo::PushConst::type, ShaderCreateInfo::SharedVariable::type, blender::gpu::shader::SpecializationConstant::Value::u, blender::gpu::shader::uint_t, blender::gpu::VKPushConstants::UNIFORM_BUFFER, and blender::gpu::shader::SpecializationConstant::value.

◆ unbind()

void blender::gpu::VKShader::unbind ( )
overridevirtual

Implements blender::gpu::Shader.

Definition at line 733 of file vk_shader.cc.

◆ uniform_float()

void blender::gpu::VKShader::uniform_float ( int location,
int comp_len,
int array_size,
const float * data )
overridevirtual

Implements blender::gpu::Shader.

Definition at line 735 of file vk_shader.cc.

References data, and push_constants.

◆ uniform_int()

void blender::gpu::VKShader::uniform_int ( int location,
int comp_len,
int array_size,
const int * data )
overridevirtual

Implements blender::gpu::Shader.

Definition at line 740 of file vk_shader.cc.

References data, and push_constants.

◆ vertex_interface_declare()

◆ vertex_shader_from_glsl()

void blender::gpu::VKShader::vertex_shader_from_glsl ( MutableSpan< StringRefNull > sources)
overridevirtual

Implements blender::gpu::Shader.

Definition at line 554 of file vk_shader.cc.

References vertex_module.

◆ vk_descriptor_set_layout_get()

VkDescriptorSetLayout blender::gpu::VKShader::vk_descriptor_set_layout_get ( ) const
inline

Definition at line 112 of file vk_shader.hh.

◆ warm_cache()

void blender::gpu::VKShader::warm_cache ( int limit)
overridevirtual

Implements blender::gpu::Shader.

Definition at line 574 of file vk_shader.cc.

References NOT_YET_IMPLEMENTED.

Member Data Documentation

◆ compilation_failed

bool blender::gpu::VKShader::compilation_failed = false

Definition at line 52 of file vk_shader.hh.

Referenced by finalize().

◆ compilation_finished

bool blender::gpu::VKShader::compilation_finished = false

Definition at line 51 of file vk_shader.hh.

Referenced by finalize(), and is_ready().

◆ compute_module

VKShaderModule blender::gpu::VKShader::compute_module

◆ fragment_module

VKShaderModule blender::gpu::VKShader::fragment_module

◆ geometry_module

VKShaderModule blender::gpu::VKShader::geometry_module

◆ push_constants

VKPushConstants blender::gpu::VKShader::push_constants

Definition at line 55 of file vk_shader.hh.

Referenced by finalize(), uniform_float(), and uniform_int().

◆ vertex_module

VKShaderModule blender::gpu::VKShader::vertex_module

◆ vk_pipeline_layout

VkPipelineLayout blender::gpu::VKShader::vk_pipeline_layout = VK_NULL_HANDLE

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