Blender V5.0
blender::gpu::Shader Class Referenceabstract

#include <gpu_shader_private.hh>

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

Public Member Functions

virtual void init (const shader::ShaderCreateInfo &info, bool is_batch_compilation)=0
virtual void vertex_shader_from_glsl (MutableSpan< StringRefNull > sources)=0
virtual void geometry_shader_from_glsl (MutableSpan< StringRefNull > sources)=0
virtual void fragment_shader_from_glsl (MutableSpan< StringRefNull > sources)=0
virtual void compute_shader_from_glsl (MutableSpan< StringRefNull > sources)=0
virtual bool finalize (const shader::ShaderCreateInfo *info=nullptr)=0
virtual void warm_cache (int limit)=0
virtual void bind (const shader::SpecializationConstants *constants_state)=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
StringRefNull 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 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)

Public Attributes

ShaderInterfaceinterface = nullptr
uint16_t fragment_output_bits = 0
std::unique_ptr< const shader::SpecializationConstantsconstants
bool is_polyline = false

Protected Member Functions

Debug functions
void print_log (Span< StringRefNull > 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 43 of file gpu_shader_private.hh.

Constructor & Destructor Documentation

◆ Shader()

Shader::Shader ( const char * name)

◆ ~Shader()

Shader::~Shader ( )
virtual

Definition at line 62 of file gpu_shader.cc.

References BLI_assert_msg, blender::gpu::Context::get(), interface, and ~Shader().

Referenced by ~Shader().

Member Function Documentation

◆ bind()

virtual void blender::gpu::Shader::bind ( const shader::SpecializationConstants * constants_state)
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< StringRefNull > sources)
pure virtual

◆ defines_declare()

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

Definition at line 35 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< StringRefNull > 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< StringRefNull > sources)
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 113 of file gpu_shader_private.hh.

References parent_shader_, and Shader().

◆ parent_set()

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

Definition at line 108 of file gpu_shader_private.hh.

References parent_shader_, and Shader().

Referenced by GPU_shader_set_parent().

◆ print_log()

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

◆ resources_declare()

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

◆ set_framebuffer_srgb_target()

◆ set_scene_linear_to_xyz_uniform()

◆ set_srgb_uniform()

◆ specialization_constants_init()

◆ 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< StringRefNull > sources)
pure virtual

◆ warm_cache()

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

Member Data Documentation

◆ constants

◆ fragment_output_bits

uint16_t blender::gpu::Shader::fragment_output_bits = 0

Bit-set indicating the frame-buffer color attachments that this shader writes to.

Definition at line 48 of file gpu_shader_private.hh.

Referenced by blender::gpu::Context::assert_framebuffer_shader_compatibility().

◆ interface

◆ is_polyline

bool blender::gpu::Shader::is_polyline = false

Definition at line 56 of file gpu_shader_private.hh.

Referenced by GPU_shader_get_builtin_shader_with_config().

◆ name

◆ parent_shader_

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

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