Blender  V3.3
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
blender::gpu::ShaderInterface Class Reference

#include <gpu_shader_interface.hh>

Inheritance diagram for blender::gpu::ShaderInterface:
blender::gpu::GLShaderInterface

Public Member Functions

 ShaderInterface ()
 
 ShaderInterface (const shader::ShaderCreateInfo &info)
 
virtual ~ShaderInterface ()
 
void debug_print ()
 
const ShaderInputattr_get (const char *name) const
 
const ShaderInputubo_get (const char *name) const
 
const ShaderInputubo_get (const int binding) const
 
const ShaderInputuniform_get (const char *name) const
 
const ShaderInputtexture_get (const int binding) const
 
const ShaderInputssbo_get (const char *name) const
 
const ShaderInputssbo_get (const int binding) const
 
const char * input_name_get (const ShaderInput *input) const
 
int32_t uniform_builtin (const GPUUniformBuiltin builtin) const
 
int32_t ubo_builtin (const GPUUniformBlockBuiltin builtin) const
 

Public Attributes

ShaderInputinputs_ = nullptr
 
char * name_buffer_ = nullptr
 
uint attr_len_ = 0
 
uint ubo_len_ = 0
 
uint uniform_len_ = 0
 
uint ssbo_len_ = 0
 
uint16_t enabled_attr_mask_ = 0
 
uint16_t enabled_ubo_mask_ = 0
 
uint8_t enabled_ima_mask_ = 0
 
uint64_t enabled_tex_mask_ = 0
 
uint16_t enabled_ssbo_mask_ = 0
 
int32_t builtins_ [GPU_NUM_UNIFORMS]
 
int32_t builtin_blocks_ [GPU_NUM_UNIFORM_BLOCKS]
 

Protected Member Functions

uint32_t set_input_name (ShaderInput *input, char *name, uint32_t name_len) const
 
void copy_input_name (ShaderInput *input, const StringRefNull &name, char *name_buffer, uint32_t &name_buffer_offset) const
 
void sort_inputs ()
 

Static Protected Member Functions

static const char * builtin_uniform_name (GPUUniformBuiltin u)
 
static const char * builtin_uniform_block_name (GPUUniformBlockBuiltin u)
 

Detailed Description

Implementation of Shader interface. Base class which is then specialized for each implementation (GL, VK, ...).

Definition at line 37 of file gpu_shader_interface.hh.

Constructor & Destructor Documentation

◆ ShaderInterface() [1/2]

blender::gpu::ShaderInterface::ShaderInterface ( )
default

◆ ShaderInterface() [2/2]

blender::gpu::ShaderInterface::ShaderInterface ( const shader::ShaderCreateInfo info)

◆ ~ShaderInterface()

blender::gpu::ShaderInterface::~ShaderInterface ( )
virtual

Definition at line 22 of file gpu_shader_interface.cc.

References inputs_, MEM_freeN, and name_buffer_.

Member Function Documentation

◆ attr_get()

const ShaderInput* blender::gpu::ShaderInterface::attr_get ( const char *  name) const
inline

Definition at line 67 of file gpu_shader_interface.hh.

References attr_len_, and inputs_.

Referenced by blender::gpu::vbo_bind().

◆ builtin_uniform_block_name()

const char * blender::gpu::ShaderInterface::builtin_uniform_block_name ( GPUUniformBlockBuiltin  u)
inlinestaticprotected

◆ builtin_uniform_name()

const char * blender::gpu::ShaderInterface::builtin_uniform_name ( GPUUniformBuiltin  u)
inlinestaticprotected

◆ copy_input_name()

void blender::gpu::ShaderInterface::copy_input_name ( ShaderInput input,
const StringRefNull name,
char *  name_buffer,
uint32_t name_buffer_offset 
) const
inlineprotected

◆ debug_print()

void blender::gpu::ShaderInterface::debug_print ( )

◆ input_name_get()

const char* blender::gpu::ShaderInterface::input_name_get ( const ShaderInput input) const
inline

Definition at line 100 of file gpu_shader_interface.hh.

References input, and name_buffer_.

◆ set_input_name()

uint32_t blender::gpu::ShaderInterface::set_input_name ( ShaderInput input,
char *  name,
uint32_t  name_len 
) const
inlineprotected

◆ sort_inputs()

void blender::gpu::ShaderInterface::sort_inputs ( )
protected

Finalize interface construction by sorting the #ShaderInputs for faster lookups.

Definition at line 52 of file gpu_shader_interface.cc.

References attr_len_, inputs_, blender::gpu::sort_input_list(), ssbo_len_, ubo_len_, and uniform_len_.

Referenced by blender::gpu::GLShaderInterface::GLShaderInterface().

◆ ssbo_get() [1/2]

const ShaderInput* blender::gpu::ShaderInterface::ssbo_get ( const char *  name) const
inline

Definition at line 91 of file gpu_shader_interface.hh.

References attr_len_, inputs_, ssbo_len_, ubo_len_, and uniform_len_.

◆ ssbo_get() [2/2]

const ShaderInput* blender::gpu::ShaderInterface::ssbo_get ( const int  binding) const
inline

Definition at line 95 of file gpu_shader_interface.hh.

References attr_len_, inputs_, ssbo_len_, ubo_len_, and uniform_len_.

◆ texture_get()

const ShaderInput* blender::gpu::ShaderInterface::texture_get ( const int  binding) const
inline

Definition at line 86 of file gpu_shader_interface.hh.

References attr_len_, inputs_, ubo_len_, and uniform_len_.

◆ ubo_builtin()

int32_t blender::gpu::ShaderInterface::ubo_builtin ( const GPUUniformBlockBuiltin  builtin) const
inline

◆ ubo_get() [1/2]

const ShaderInput* blender::gpu::ShaderInterface::ubo_get ( const char *  name) const
inline

Definition at line 72 of file gpu_shader_interface.hh.

References attr_len_, inputs_, and ubo_len_.

Referenced by blender::gpu::GLShaderInterface::GLShaderInterface().

◆ ubo_get() [2/2]

const ShaderInput* blender::gpu::ShaderInterface::ubo_get ( const int  binding) const
inline

Definition at line 76 of file gpu_shader_interface.hh.

References attr_len_, inputs_, and ubo_len_.

◆ uniform_builtin()

int32_t blender::gpu::ShaderInterface::uniform_builtin ( const GPUUniformBuiltin  builtin) const
inline

Definition at line 106 of file gpu_shader_interface.hh.

References BLI_assert, builtins_, and GPU_NUM_UNIFORMS.

Referenced by GPU_shader_get_builtin_uniform().

◆ uniform_get()

const ShaderInput* blender::gpu::ShaderInterface::uniform_get ( const char *  name) const
inline

Member Data Documentation

◆ attr_len_

uint blender::gpu::ShaderInterface::attr_len_ = 0

◆ builtin_blocks_

int32_t blender::gpu::ShaderInterface::builtin_blocks_[GPU_NUM_UNIFORM_BLOCKS]

◆ builtins_

int32_t blender::gpu::ShaderInterface::builtins_[GPU_NUM_UNIFORMS]

Location of builtin uniforms. Fast access, no lookup needed.

Definition at line 57 of file gpu_shader_interface.hh.

Referenced by blender::gpu::GLShaderInterface::GLShaderInterface(), and uniform_builtin().

◆ enabled_attr_mask_

uint16_t blender::gpu::ShaderInterface::enabled_attr_mask_ = 0

Enabled bind-points that needs to be fed with data.

Definition at line 51 of file gpu_shader_interface.hh.

Referenced by blender::gpu::GLShaderInterface::GLShaderInterface(), and blender::gpu::GLVertArray::update_bindings().

◆ enabled_ima_mask_

uint8_t blender::gpu::ShaderInterface::enabled_ima_mask_ = 0

◆ enabled_ssbo_mask_

uint16_t blender::gpu::ShaderInterface::enabled_ssbo_mask_ = 0

◆ enabled_tex_mask_

uint64_t blender::gpu::ShaderInterface::enabled_tex_mask_ = 0

◆ enabled_ubo_mask_

uint16_t blender::gpu::ShaderInterface::enabled_ubo_mask_ = 0

◆ inputs_

ShaderInput* blender::gpu::ShaderInterface::inputs_ = nullptr

Flat array. In this order: Attributes, Ubos, Uniforms.

Definition at line 42 of file gpu_shader_interface.hh.

Referenced by attr_get(), debug_print(), blender::gpu::GLShaderInterface::GLShaderInterface(), sort_inputs(), ssbo_get(), texture_get(), ubo_get(), uniform_get(), and ~ShaderInterface().

◆ name_buffer_

char* blender::gpu::ShaderInterface::name_buffer_ = nullptr

Buffer containing all inputs names separated by '\0'.

Definition at line 44 of file gpu_shader_interface.hh.

Referenced by debug_print(), blender::gpu::GLShaderInterface::GLShaderInterface(), input_name_get(), set_input_name(), and ~ShaderInterface().

◆ ssbo_len_

uint blender::gpu::ShaderInterface::ssbo_len_ = 0

◆ ubo_len_

uint blender::gpu::ShaderInterface::ubo_len_ = 0

◆ uniform_len_

uint blender::gpu::ShaderInterface::uniform_len_ = 0

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