Blender V5.3
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_codegen_only) override
const shader::ShaderCreateInfo & patch_create_info (const shader::ShaderCreateInfo &original_info) override
void vertex_shader_from_glsl (const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override
void geometry_shader_from_glsl (const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override
void fragment_shader_from_glsl (const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override
void compute_shader_from_glsl (const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override
bool finalize (const shader::ShaderCreateInfo *info=nullptr) override
bool finalize_post (Span< shader::PipelineState > pipeline_states)
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)
bool ensure_graphics_pipelines (Span< shader::PipelineState > pipeline_states)
VkPipeline ensure_and_get_graphics_pipeline (GPUPrimType primitive, VKVertexInputDescriptionPool::Key vertex_input_description_key, VKStateManager &state_manager, const VKFrameBuffer &framebuffer, shader::SpecializationConstants &constants_state)
const VKShaderInterface & interface_get () const
bool has_descriptor_set () const
VkDescriptorSetLayout vk_descriptor_set_layout_get () const
bool use_ray_query_get () const
Public Member Functions inherited from blender::gpu::Shader
StringRefNull name_get () const
void parent_set (Shader *parent)
Shader * parent_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
VkPipelineLayout vk_pipeline_layout = VK_NULL_HANDLE
VKPushConstants push_constants
Public Attributes inherited from blender::gpu::Shader
ShaderInterface * interface = nullptr
uint16_t fragment_output_bits = 0
std::unique_ptr< const shader::SpecializationConstants > constants
bool is_polyline = false
bool skip_preprocessor = false

Additional Inherited Members

Static Public Member Functions inherited from blender::gpu::Shader
static std::string defines_declare (const shader::ShaderCreateInfo &info)
static void dump_source_to_disk (StringRef shader_name, StringRef shader_name_with_stage_name, StringRef extension, StringRef source)
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)
static std::string run_preprocessor (StringRef source, bool no_dead_code_elimination)
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]
Shader * parent_shader_ = nullptr
std::unique_ptr< PatchedShaderCreateInfo > patched_info_

Detailed Description

Definition at line 26 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

Implements blender::gpu::Shader.

Definition at line 730 of file vk_shader.cc.

References blender::gpu::VKContext::get().

◆ compute_layout_declare()

◆ compute_shader_from_glsl()

void blender::gpu::VKShader::compute_shader_from_glsl ( const shader::ShaderCreateInfo & info,
MutableSpan< StringRefNull > sources )
overridevirtual

Implements blender::gpu::Shader.

Definition at line 588 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,
VKVertexInputDescriptionPool::Key vertex_input_description_key,
VKStateManager & state_manager,
const VKFrameBuffer & framebuffer,
shader::SpecializationConstants & constants_state )

Definition at line 1433 of file vk_shader.cc.

References blender::BLI_assert(), BLI_assert_msg, CLOG_DEBUG, CLOG_INFO, blender::gpu::VKGraphicsInfo::Shaders::color_attachment_count, blender::gpu::VKGraphicsInfo::FragmentOut::color_attachment_formats, blender::gpu::VKFrameBuffer::color_attachment_formats_get(), blender::gpu::VKGraphicsInfo::FragmentOut::depth_attachment_format, blender::gpu::VKFrameBuffer::depth_attachment_format_get(), blender::gpu::VKBackend::device, blender::gpu::VKExtensions::extended_dynamic_state, blender::gpu::VKDevice::extensions_get(), fragment_module, blender::gpu::VKGraphicsInfo::fragment_out, blender::G, blender::G_DEBUG_GPU, geometry_module, blender::gpu::VKBackend::get(), blender::gpu::VKContext::get(), blender::gpu::VKPipelinePool::get_or_create_graphics_pipeline(), blender::GPU_PRIM_POINTS, blender::GPU_STENCIL_NONE, blender::GPU_STENCIL_OP_NONE, blender::gpu::VKGraphicsInfo::Shaders::has_depth, blender::gpu::VKGraphicsInfo::Shaders::has_stencil, interface_get(), blender::gpu::VKVertexInputDescriptionPool::invalid_key, blender::LOG, blender::gpu::VKGraphicsInfo::Shaders::max_input_attachment_index, blender::gpu::Shader::name_get(), blender::gpu::VKGraphicsInfo::pipeline_info_source(), blender::gpu::VKDevice::pipelines, blender::gpu::VKGraphicsInfo::Shaders::scissors, blender::gpu::VKGraphicsInfo::shaders, lexit::Vector< T >::size(), blender::gpu::VKGraphicsInfo::Shaders::specialization_constants, blender::gpu::StateManager::state, blender::gpu::VKGraphicsInfo::FragmentOut::state, blender::gpu::VKGraphicsInfo::Shaders::state, blender::gpu::VKWorkarounds::static_viewport_scissor, blender::gpu::VKGraphicsInfo::FragmentOut::stencil_attachment_format, blender::gpu::VKFrameBuffer::stencil_attachment_format_get(), blender::gpu::to_vk_primitive_topology(), UNUSED_VARS_NDEBUG, blender::gpu::shader::SpecializationConstants::values, blender::gpu::VKGraphicsInfo::vertex_in, blender::gpu::VKExtensions::vertex_input_dynamic_state, blender::gpu::VKGraphicsInfo::VertexIn::vertex_input_key, vertex_module, blender::gpu::VKGraphicsInfo::Shaders::viewport_count, blender::gpu::VKFrameBuffer::viewport_size(), blender::gpu::VKGraphicsInfo::Shaders::viewports, blender::gpu::VKGraphicsInfo::Shaders::vk_fragment_module, blender::gpu::VKGraphicsInfo::Shaders::vk_geometry_module, blender::gpu::VKGraphicsInfo::Shaders::vk_pipeline_layout, vk_pipeline_layout, blender::gpu::VKFrameBuffer::vk_render_areas_append(), blender::gpu::VKShaderModule::vk_shader_module, blender::gpu::VKGraphicsInfo::Shaders::vk_topology, blender::gpu::VKGraphicsInfo::VertexIn::vk_topology, blender::gpu::VKGraphicsInfo::Shaders::vk_vertex_module, blender::gpu::VKFrameBuffer::vk_viewports_append(), and blender::gpu::VKDevice::workarounds_get().

Referenced by blender::gpu::VKContext::update_pipeline_data().

◆ ensure_graphics_pipelines()

bool blender::gpu::VKShader::ensure_graphics_pipelines ( Span< shader::PipelineState > pipeline_states)

Definition at line 1362 of file vk_shader.cc.

References blender::BLI_assert(), blender::gpu::VKGraphicsInfo::Shaders::color_attachment_count, blender::gpu::VKGraphicsInfo::FragmentOut::color_attachment_formats, blender::gpu::VKGraphicsInfo::FragmentOut::depth_attachment_format, blender::gpu::VKBackend::device, blender::gpu::VKExtensions::extended_dynamic_state, blender::gpu::VKDevice::extensions_get(), fragment_module, blender::gpu::VKGraphicsInfo::fragment_out, geometry_module, blender::gpu::VKBackend::get(), blender::gpu::VKPipelinePool::get_or_create_graphics_pipeline(), blender::gpu::VKGraphicsInfo::Shaders::has_depth, blender::gpu::VKGraphicsInfo::Shaders::has_stencil, blender::gpu::Invalid, blender::gpu::VKVertexInputDescriptionPool::invalid_key, blender::gpu::VKGraphicsInfo::Shaders::max_input_attachment_index, blender::gpu::Shader::name_get(), blender::gpu::VKDevice::pipelines, blender::gpu::VKGraphicsInfo::shaders, lexit::Vector< T >::size(), blender::gpu::VKGraphicsInfo::Shaders::specialization_constants, blender::gpu::VKGraphicsInfo::FragmentOut::state, blender::gpu::VKGraphicsInfo::Shaders::state, blender::gpu::VKWorkarounds::static_viewport_scissor, blender::gpu::VKGraphicsInfo::FragmentOut::stencil_attachment_format, blender::gpu::to_vk_format(), blender::gpu::to_vk_primitive_topology(), UNUSED_VARS_NDEBUG, blender::gpu::VKGraphicsInfo::vertex_in, blender::gpu::VKExtensions::vertex_input_dynamic_state, blender::gpu::VKGraphicsInfo::VertexIn::vertex_input_key, vertex_module, blender::gpu::VKGraphicsInfo::Shaders::viewport_count, blender::gpu::VKGraphicsInfo::Shaders::vk_fragment_module, blender::gpu::VKGraphicsInfo::Shaders::vk_geometry_module, blender::gpu::VKGraphicsInfo::Shaders::vk_pipeline_layout, vk_pipeline_layout, blender::gpu::VKShaderModule::vk_shader_module, blender::gpu::VKGraphicsInfo::Shaders::vk_topology, blender::gpu::VKGraphicsInfo::VertexIn::vk_topology, blender::gpu::VKGraphicsInfo::Shaders::vk_vertex_module, and blender::gpu::VKDevice::workarounds_get().

Referenced by finalize_post().

◆ finalize()

◆ finalize_post()

bool blender::gpu::VKShader::finalize_post ( Span< shader::PipelineState > pipeline_states)

◆ fragment_interface_declare()

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

Implements blender::gpu::Shader.

Definition at line 973 of file vk_shader.cc.

References blender::gpu::shader::BARYCENTRIC_COORD, blender::gpu::shader::ShaderCreateInfo::builtins_combined(), blender::gpu::shader::CLIP_DISTANCES, blender::gpu::shader::ShaderCreateInfo::depth_write_, blender::gpu::VKBackend::device, blender::gpu::VKExtensions::dynamic_rendering_local_read, blender::gpu::shader::ShaderCreateInfo::early_fragment_test_, ELEM, blender::gpu::VKDevice::extensions_get(), blender::blender::StringRefBase::find(), blender::gpu::shader::ShaderCreateInfo::fragment_outputs_, blender::gpu::VKExtensions::fragment_shader_barycentric, blender::gpu::shader::ShaderCreateInfo::fragment_source_, blender::gpu::shader::ShaderCreateInfo::geometry_out_interfaces_, blender::gpu::shader::ShaderCreateInfo::geometry_source_, blender::gpu::VKBackend::get(), blender::ShaderCreateInfo::SubpassIn::img_type, blender::ShaderCreateInfo::SubpassIn::index, blender::gpu::shader::int_t, blender::gpu::Shader::interface, interface_get(), blender::blender::StringRefBase::is_empty(), blender::gpu::shader::LAYER, blender::ShaderCreateInfo::SubpassIn::name, output, blender::gpu::print_interface(), blender::gpu::print_resource(), blender::gpu::VKExtensions::shader_clip_distance, blender::gpu::shader::ShaderCreateInfo::subpass_inputs_, blender::gpu::shader::to_component_count(), blender::gpu::to_component_type(), blender::gpu::to_string(), blender::ShaderCreateInfo::SubpassIn::type, blender::gpu::shader::uint_t, blender::gpu::shader::UNCHANGED, blender::gpu::shader::ShaderCreateInfo::vertex_out_interfaces_, and blender::gpu::shader::VIEWPORT_INDEX.

◆ fragment_shader_from_glsl()

void blender::gpu::VKShader::fragment_shader_from_glsl ( const shader::ShaderCreateInfo & info,
MutableSpan< StringRefNull > sources )
overridevirtual

Implements blender::gpu::Shader.

Definition at line 582 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 ( const shader::ShaderCreateInfo & info,
MutableSpan< StringRefNull > sources )
overridevirtual

Implements blender::gpu::Shader.

Definition at line 576 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 126 of file vk_shader.hh.

◆ init()

◆ interface_get()

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

◆ patch_create_info()

const shader::ShaderCreateInfo & blender::gpu::VKShader::patch_create_info ( const shader::ShaderCreateInfo & original_info)
inlineoverridevirtual

Implements blender::gpu::Shader.

Definition at line 77 of file vk_shader.hh.

◆ resources_declare()

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

◆ unbind()

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

Implements blender::gpu::Shader.

Definition at line 740 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

◆ uniform_int()

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

◆ use_ray_query_get()

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

Definition at line 136 of file vk_shader.hh.

◆ vertex_interface_declare()

◆ vertex_shader_from_glsl()

void blender::gpu::VKShader::vertex_shader_from_glsl ( const shader::ShaderCreateInfo & info,
MutableSpan< StringRefNull > sources )
overridevirtual

Implements blender::gpu::Shader.

Definition at line 570 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 131 of file vk_shader.hh.

◆ warm_cache()

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

Implements blender::gpu::Shader.

Definition at line 594 of file vk_shader.cc.

References NOT_YET_IMPLEMENTED.

Member Data Documentation

◆ 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 70 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: