Blender V4.3
blender::gpu::Shader Class Referenceabstract

#include <gpu_shader_private.hh>

Inherited by blender::gpu::GLShader, blender::gpu::MTLShader, and blender::gpu::VKShader.

Classes

struct  Constants
 

Public Member Functions

virtual void init (const shader::ShaderCreateInfo &info, bool is_batch_compilation)=0
 
virtual void vertex_shader_from_glsl (MutableSpan< const char * > sources)=0
 
virtual void geometry_shader_from_glsl (MutableSpan< const char * > sources)=0
 
virtual void fragment_shader_from_glsl (MutableSpan< const char * > sources)=0
 
virtual void compute_shader_from_glsl (MutableSpan< const char * > sources)=0
 
virtual bool finalize (const shader::ShaderCreateInfo *info=nullptr)=0
 
virtual void warm_cache (int limit)=0
 
virtual void transform_feedback_names_set (Span< const char * > name_list, eGPUShaderTFBType geom_type)=0
 
virtual bool transform_feedback_enable (VertBuf *)=0
 
virtual void transform_feedback_disable ()=0
 
virtual void bind ()=0
 
virtual void unbind ()=0
 
virtual void uniform_float (int location, int comp_len, int array_size, const float *data)=0
 
virtual void uniform_int (int location, int comp_len, int array_size, const int *data)=0
 
std::string defines_declare (const shader::ShaderCreateInfo &info) const
 
virtual std::string resources_declare (const shader::ShaderCreateInfo &info) const =0
 
virtual std::string vertex_interface_declare (const shader::ShaderCreateInfo &info) const =0
 
virtual std::string fragment_interface_declare (const shader::ShaderCreateInfo &info) const =0
 
virtual std::string geometry_interface_declare (const shader::ShaderCreateInfo &info) const =0
 
virtual std::string geometry_layout_declare (const shader::ShaderCreateInfo &info) const =0
 
virtual std::string compute_layout_declare (const shader::ShaderCreateInfo &info) const =0
 
virtual int program_handle_get () const =0
 
virtual bool get_uses_ssbo_vertex_fetch () const =0
 
virtual int get_ssbo_vertex_fetch_output_num_verts () const =0
 
const char *const name_get () const
 
void parent_set (Shader *parent)
 
Shaderparent_get () const
 
Creation / Destruction
 Shader (const char *name)
 
virtual ~Shader ()
 
Assign specialization constants.
void specialization_constants_init (const shader::ShaderCreateInfo &info)
 

Static Public Member Functions

sRGB Rendering Workaround

The viewport overlay frame-buffer is sRGB and will expect shaders to output display referred Linear colors. But other frame-buffers (i.e: the area frame-buffers) are not sRGB and require the shader output color to be in sRGB space (assumed display encoded color-space as the time of writing). For this reason we have a uniform to switch the transform on and off depending on the current frame-buffer color-space.

static bool srgb_uniform_dirty_get ()
 
static void set_srgb_uniform (GPUShader *shader)
 
static void set_framebuffer_srgb_target (int use_srgb_to_linear)
 

Public Attributes

ShaderInterfaceinterface = nullptr
 
struct blender::gpu::Shader::Constants constants
 

Protected Member Functions

Debug functions
void print_log (Span< const char * > sources, const char *log, const char *stage, bool error, GPULogParser *parser)
 

Protected Attributes

char name [64]
 
Shaderparent_shader_ = nullptr
 

Detailed Description

Implementation of shader compilation and uniforms handling. Base class which is then specialized for each implementation (GL, VK, ...).

Definition at line 44 of file gpu_shader_private.hh.

Constructor & Destructor Documentation

◆ Shader()

Shader::Shader ( const char * name)

Definition at line 55 of file gpu_shader.cc.

References STRNCPY.

◆ ~Shader()

Shader::~Shader ( )
virtual

Definition at line 60 of file gpu_shader.cc.

Member Function Documentation

◆ bind()

virtual void blender::gpu::Shader::bind ( )
pure virtual

◆ compute_layout_declare()

virtual std::string blender::gpu::Shader::compute_layout_declare ( const shader::ShaderCreateInfo & info) const
pure virtual

◆ compute_shader_from_glsl()

virtual void blender::gpu::Shader::compute_shader_from_glsl ( MutableSpan< const char * > sources)
pure virtual

◆ defines_declare()

std::string Shader::defines_declare ( const shader::ShaderCreateInfo & info) const

Definition at line 33 of file gpu_shader.cc.

References blender::gpu::shader::ShaderCreateInfo::defines_.

◆ finalize()

virtual bool blender::gpu::Shader::finalize ( const shader::ShaderCreateInfo * info = nullptr)
pure virtual

◆ fragment_interface_declare()

virtual std::string blender::gpu::Shader::fragment_interface_declare ( const shader::ShaderCreateInfo & info) const
pure virtual

◆ fragment_shader_from_glsl()

virtual void blender::gpu::Shader::fragment_shader_from_glsl ( MutableSpan< const char * > sources)
pure virtual

◆ geometry_interface_declare()

virtual std::string blender::gpu::Shader::geometry_interface_declare ( const shader::ShaderCreateInfo & info) const
pure virtual

◆ geometry_layout_declare()

virtual std::string blender::gpu::Shader::geometry_layout_declare ( const shader::ShaderCreateInfo & info) const
pure virtual

◆ geometry_shader_from_glsl()

virtual void blender::gpu::Shader::geometry_shader_from_glsl ( MutableSpan< const char * > sources)
pure virtual

◆ get_ssbo_vertex_fetch_output_num_verts()

virtual int blender::gpu::Shader::get_ssbo_vertex_fetch_output_num_verts ( ) const
pure virtual

◆ get_uses_ssbo_vertex_fetch()

virtual bool blender::gpu::Shader::get_uses_ssbo_vertex_fetch ( ) const
pure virtual

◆ init()

virtual void blender::gpu::Shader::init ( const shader::ShaderCreateInfo & info,
bool is_batch_compilation )
pure virtual

◆ name_get()

◆ parent_get()

Shader * blender::gpu::Shader::parent_get ( ) const
inline

Definition at line 136 of file gpu_shader_private.hh.

References parent_shader_.

◆ parent_set()

void blender::gpu::Shader::parent_set ( Shader * parent)
inline

Definition at line 131 of file gpu_shader_private.hh.

References parent_shader_.

Referenced by GPU_shader_set_parent().

◆ print_log()

void Shader::print_log ( Span< const char * > sources,
const char * log,
const char * stage,
bool error,
GPULogParser * parser )
protected

◆ program_handle_get()

virtual int blender::gpu::Shader::program_handle_get ( ) const
pure virtual

◆ resources_declare()

virtual std::string blender::gpu::Shader::resources_declare ( const shader::ShaderCreateInfo & info) const
pure virtual

◆ set_framebuffer_srgb_target()

void Shader::set_framebuffer_srgb_target ( int use_srgb_to_linear)
static

◆ set_srgb_uniform()

◆ specialization_constants_init()

void Shader::specialization_constants_init ( const shader::ShaderCreateInfo & info)

◆ srgb_uniform_dirty_get()

bool Shader::srgb_uniform_dirty_get ( )
static

Definition at line 782 of file gpu_shader.cc.

References blender::gpu::g_shader_builtin_srgb_is_dirty.

◆ transform_feedback_disable()

virtual void blender::gpu::Shader::transform_feedback_disable ( )
pure virtual

◆ transform_feedback_enable()

virtual bool blender::gpu::Shader::transform_feedback_enable ( VertBuf * )
pure virtual

◆ transform_feedback_names_set()

virtual void blender::gpu::Shader::transform_feedback_names_set ( Span< const char * > name_list,
eGPUShaderTFBType geom_type )
pure virtual

◆ unbind()

virtual void blender::gpu::Shader::unbind ( )
pure virtual

◆ uniform_float()

virtual void blender::gpu::Shader::uniform_float ( int location,
int comp_len,
int array_size,
const float * data )
pure virtual

◆ uniform_int()

virtual void blender::gpu::Shader::uniform_int ( int location,
int comp_len,
int array_size,
const int * data )
pure virtual

◆ vertex_interface_declare()

virtual std::string blender::gpu::Shader::vertex_interface_declare ( const shader::ShaderCreateInfo & info) const
pure virtual

◆ vertex_shader_from_glsl()

virtual void blender::gpu::Shader::vertex_shader_from_glsl ( MutableSpan< const char * > sources)
pure virtual

◆ warm_cache()

virtual void blender::gpu::Shader::warm_cache ( int limit)
pure virtual

Member Data Documentation

◆ constants

◆ interface

◆ name

char blender::gpu::Shader::name[64]
protected

◆ parent_shader_

Shader* blender::gpu::Shader::parent_shader_ = nullptr
protected

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