Blender V5.3
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_codegen_only)=0
virtual const shader::ShaderCreateInfo & patch_create_info (const shader::ShaderCreateInfo &original_info)=0
virtual void vertex_shader_from_glsl (const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources)=0
virtual void geometry_shader_from_glsl (const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources)=0
virtual void fragment_shader_from_glsl (const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources)=0
virtual void compute_shader_from_glsl (const shader::ShaderCreateInfo &info, 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
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)
Shader * parent_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

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)
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)
Interface.
static std::string run_preprocessor (StringRef source, bool no_dead_code_elimination)

Public Attributes

ShaderInterface * interface = nullptr
uint16_t fragment_output_bits = 0
std::unique_ptr< const shader::SpecializationConstants > constants
bool is_polyline = false
bool skip_preprocessor = 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]
Shader * parent_shader_ = nullptr
std::unique_ptr< PatchedShaderCreateInfo > patched_info_

Detailed Description

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

Definition at line 52 of file gpu_shader_private.hh.

Constructor & Destructor Documentation

◆ Shader()

Shader::Shader ( const char * name)

◆ ~Shader()

Shader::~Shader ( )
virtual

Definition at line 127 of file gpu_shader.cc.

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

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 ( const shader::ShaderCreateInfo & info,
MutableSpan< StringRefNull > sources )
pure virtual

◆ defines_declare()

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

Definition at line 91 of file gpu_shader.cc.

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

Referenced by uniform_int().

◆ dump_source_to_disk()

◆ 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 ( const shader::ShaderCreateInfo & info,
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 ( const shader::ShaderCreateInfo & info,
MutableSpan< StringRefNull > sources )
pure virtual

◆ init()

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

◆ name_get()

◆ parent_get()

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

Definition at line 138 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 133 of file gpu_shader_private.hh.

References parent_shader_, and Shader().

Referenced by blender::GPU_shader_set_parent().

◆ patch_create_info()

virtual const shader::ShaderCreateInfo & blender::gpu::Shader::patch_create_info ( const shader::ShaderCreateInfo & original_info)
pure virtual

◆ print_log()

◆ resources_declare()

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

◆ run_preprocessor()

◆ 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 ( const shader::ShaderCreateInfo & info,
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 57 of file gpu_shader_private.hh.

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

◆ interface

◆ is_polyline

◆ name

◆ parent_shader_

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

◆ patched_info_

std::unique_ptr<PatchedShaderCreateInfo> blender::gpu::Shader::patched_info_
protected

Definition at line 84 of file gpu_shader_private.hh.

Referenced by blender::gpu::MTLShader::patch_create_info().

◆ skip_preprocessor

bool blender::gpu::Shader::skip_preprocessor = false

Definition at line 70 of file gpu_shader_private.hh.


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