Blender V4.3
blender::gpu::MTLShaderInterface Class Reference

#include <mtl_shader_interface.hh>

Inherits blender::gpu::ShaderInterface.

Public Member Functions

 MTLShaderInterface (const char *name)
 
 ~MTLShaderInterface ()
 
void init ()
 
void add_input_attribute (uint32_t name_offset, uint32_t attribute_location, MTLVertexFormat format, uint32_t buffer_index, uint32_t size, uint32_t offset, int matrix_element_count=1)
 
uint32_t add_uniform_block (uint32_t name_offset, uint32_t buffer_index, uint32_t location, uint32_t size, ShaderStage stage_mask=ShaderStage::ANY)
 
uint32_t add_storage_block (uint32_t name_offset, uint32_t buffer_index, uint32_t location, uint32_t size, ShaderStage stage_mask=ShaderStage::ANY)
 
void add_uniform (uint32_t name_offset, eMTLDataType type, int array_len=1)
 
void add_texture (uint32_t name_offset, uint32_t texture_slot, uint32_t location, eGPUTextureType tex_binding_type, eGPUSamplerFormat sampler_format, bool is_texture_sampler, ShaderStage stage_mask=ShaderStage::FRAGMENT, int tex_buffer_ssbo_location=-1)
 
void add_push_constant_block (uint32_t name_offset)
 
void add_constant (uint32_t name_offset)
 
void map_builtins ()
 
void set_sampler_properties (bool use_argument_buffer, uint32_t argument_buffer_bind_index_vert, uint32_t argument_buffer_bind_index_frag, uint32_t argument_buffer_bind_index_compute)
 
void prepare_common_shader_inputs (const shader::ShaderCreateInfo *info=nullptr)
 
const MTLShaderUniformget_uniform (uint index) const
 
uint32_t get_total_uniforms () const
 
uint32_t get_total_constants () const
 
const MTLShaderBufferBlockget_uniform_block (uint index) const
 
uint32_t get_total_uniform_blocks () const
 
bool has_uniform_block (uint32_t block_index) const
 
uint32_t get_uniform_block_size (uint32_t block_index) const
 
const MTLShaderBufferBlockget_storage_block (uint index) const
 
uint32_t get_total_storage_blocks () const
 
bool has_storage_block (uint32_t block_index) const
 
uint32_t get_storage_block_size (uint32_t block_index) const
 
const MTLShaderBufferBlockget_push_constant_block () const
 
uint32_t get_max_buffer_index () const
 
const MTLShaderTextureget_texture (uint index) const
 
uint32_t get_total_textures () const
 
uint32_t get_max_texture_index () const
 
bool uses_argument_buffer_for_samplers () const
 
int get_argument_buffer_bind_index (ShaderStage stage) const
 
const MTLShaderInputAttributeget_attribute (uint index) const
 
uint32_t get_total_attributes () const
 
uint32_t get_total_vertex_stride () const
 
uint32_t get_enabled_attribute_mask () const
 
const char * get_name_at_offset (uint32_t offset) const
 
const char * get_name () const
 
id< MTLArgumentEncoder > find_argument_encoder (int buffer_index) const
 
void insert_argument_encoder (int buffer_index, id encoder)
 
 MEM_CXX_CLASS_ALLOC_FUNCS ("MTLShaderInterface")
 
- Public Member Functions inherited from blender::gpu::ShaderInterface
 ShaderInterface ()
 
virtual ~ShaderInterface ()
 
void debug_print () const
 
const ShaderInputattr_get (const char *name) const
 
const ShaderInputattr_get (const int binding) 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 ShaderInputconstant_get (const char *name) 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
 

Additional Inherited Members

- Public Attributes inherited from blender::gpu::ShaderInterface
ShaderInputinputs_ = nullptr
 
char * name_buffer_ = nullptr
 
uint attr_len_ = 0
 
uint ubo_len_ = 0
 
uint uniform_len_ = 0
 
uint ssbo_len_ = 0
 
uint constant_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
 
uint16_t ssbo_attr_mask_ = 0
 
int32_t builtins_ [GPU_NUM_UNIFORMS]
 
int32_t builtin_blocks_ [GPU_NUM_UNIFORM_BLOCKS]
 
uint8_t attr_types_ [GPU_VERT_ATTR_MAX_LEN]
 
- Protected Member Functions inherited from blender::gpu::ShaderInterface
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 inherited from blender::gpu::ShaderInterface
static const char * builtin_uniform_name (GPUUniformBuiltin u)
 
static const char * builtin_uniform_block_name (GPUUniformBlockBuiltin u)
 

Detailed Description

Implementation of Shader interface for Metal Back-end.

Definition at line 167 of file mtl_shader_interface.hh.

Constructor & Destructor Documentation

◆ MTLShaderInterface()

blender::gpu::MTLShaderInterface::MTLShaderInterface ( const char * name)

Definition at line 27 of file mtl_shader_interface.mm.

References init(), blender::gpu::ShaderInterface::inputs_, and STRNCPY.

◆ ~MTLShaderInterface()

blender::gpu::MTLShaderInterface::~MTLShaderInterface ( )

Definition at line 41 of file mtl_shader_interface.mm.

Member Function Documentation

◆ add_constant()

void blender::gpu::MTLShaderInterface::add_constant ( uint32_t name_offset)

◆ add_input_attribute()

◆ add_push_constant_block()

◆ add_storage_block()

◆ add_texture()

void blender::gpu::MTLShaderInterface::add_texture ( uint32_t name_offset,
uint32_t texture_slot,
uint32_t location,
eGPUTextureType tex_binding_type,
eGPUSamplerFormat sampler_format,
bool is_texture_sampler,
ShaderStage stage_mask = ShaderStage::FRAGMENT,
int tex_buffer_ssbo_location = -1 )

◆ add_uniform()

◆ add_uniform_block()

◆ find_argument_encoder()

id< MTLArgumentEncoder > blender::gpu::MTLShaderInterface::find_argument_encoder ( int buffer_index) const

◆ get_argument_buffer_bind_index()

int blender::gpu::MTLShaderInterface::get_argument_buffer_bind_index ( ShaderStage stage) const

◆ get_attribute()

◆ get_enabled_attribute_mask()

uint32_t blender::gpu::MTLShaderInterface::get_enabled_attribute_mask ( ) const

Definition at line 505 of file mtl_shader_interface.mm.

◆ get_max_buffer_index()

uint32_t blender::gpu::MTLShaderInterface::get_max_buffer_index ( ) const

◆ get_max_texture_index()

uint32_t blender::gpu::MTLShaderInterface::get_max_texture_index ( ) const

◆ get_name()

◆ get_name_at_offset()

◆ get_push_constant_block()

const MTLShaderBufferBlock & blender::gpu::MTLShaderInterface::get_push_constant_block ( ) const

◆ get_storage_block()

const MTLShaderBufferBlock & blender::gpu::MTLShaderInterface::get_storage_block ( uint index) const

◆ get_storage_block_size()

uint32_t blender::gpu::MTLShaderInterface::get_storage_block_size ( uint32_t block_index) const

Definition at line 569 of file mtl_shader_interface.mm.

References blender::gpu::MTLShaderBufferBlock::size.

◆ get_texture()

const MTLShaderTexture & blender::gpu::MTLShaderInterface::get_texture ( uint index) const

◆ get_total_attributes()

◆ get_total_constants()

uint32_t blender::gpu::MTLShaderInterface::get_total_constants ( ) const

Definition at line 495 of file mtl_shader_interface.mm.

Referenced by prepare_common_shader_inputs().

◆ get_total_storage_blocks()

◆ get_total_textures()

◆ get_total_uniform_blocks()

◆ get_total_uniforms()

uint32_t blender::gpu::MTLShaderInterface::get_total_uniforms ( ) const

◆ get_total_vertex_stride()

uint32_t blender::gpu::MTLShaderInterface::get_total_vertex_stride ( ) const

Definition at line 500 of file mtl_shader_interface.mm.

◆ get_uniform()

const MTLShaderUniform & blender::gpu::MTLShaderInterface::get_uniform ( uint index) const

◆ get_uniform_block()

const MTLShaderBufferBlock & blender::gpu::MTLShaderInterface::get_uniform_block ( uint index) const

◆ get_uniform_block_size()

uint32_t blender::gpu::MTLShaderInterface::get_uniform_block_size ( uint32_t block_index) const

Definition at line 546 of file mtl_shader_interface.mm.

References blender::gpu::MTLShaderBufferBlock::size.

◆ has_storage_block()

bool blender::gpu::MTLShaderInterface::has_storage_block ( uint32_t block_index) const

Definition at line 564 of file mtl_shader_interface.mm.

◆ has_uniform_block()

bool blender::gpu::MTLShaderInterface::has_uniform_block ( uint32_t block_index) const

Definition at line 541 of file mtl_shader_interface.mm.

◆ init()

◆ insert_argument_encoder()

void blender::gpu::MTLShaderInterface::insert_argument_encoder ( int buffer_index,
id encoder )

◆ map_builtins()

◆ MEM_CXX_CLASS_ALLOC_FUNCS()

blender::gpu::MTLShaderInterface::MEM_CXX_CLASS_ALLOC_FUNCS ( "MTLShaderInterface" )

◆ prepare_common_shader_inputs()

void blender::gpu::MTLShaderInterface::prepare_common_shader_inputs ( const shader::ShaderCreateInfo * info = nullptr)

Definition at line 310 of file mtl_shader_interface.mm.

References blender::gpu::ShaderInterface::attr_len_, blender::gpu::ShaderInput::binding, BLI_assert, BLI_assert_msg, BLI_hash_string(), BLI_snprintf(), blender::gpu::MTLShaderTexture::buffer_metadata_uniform_loc, blender::gpu::ShaderInterface::constant_len_, blender::gpu::shader::ShaderCreateInfo::geometry_resources_, get_name_at_offset(), get_total_attributes(), get_total_constants(), get_total_storage_blocks(), get_total_textures(), get_total_uniform_blocks(), get_total_uniforms(), blender::gpu::ShaderInterface::inputs_, blender::gpu::MTLShaderBufferBlock::location, blender::gpu::MTLShaderInputAttribute::location, blender::gpu::MTLShaderTexture::location, blender::gpu::ShaderInput::location, map_builtins(), MEM_callocN, blender::gpu::ShaderInput::name_hash, blender::gpu::MTLShaderBufferBlock::name_offset, blender::gpu::MTLShaderConstant::name_offset, blender::gpu::MTLShaderInputAttribute::name_offset, blender::gpu::MTLShaderTexture::name_offset, blender::gpu::MTLShaderUniform::name_offset, blender::gpu::ShaderInput::name_offset, blender::gpu::MTLShaderTexture::slot_index, blender::gpu::ShaderInterface::sort_inputs(), blender::gpu::ShaderInterface::ssbo_attr_mask_, blender::gpu::ShaderInterface::ssbo_len_, blender::gpu::shader::ShaderCreateInfo::Resource::STORAGE_BUFFER, blender::gpu::MTLShaderTexture::texture_buffer_ssbo_location, blender::gpu::ShaderInterface::ubo_len_, blender::gpu::ShaderInterface::uniform_get(), blender::gpu::ShaderInterface::uniform_len_, and blender::gpu::MTLShaderTexture::used.

◆ set_sampler_properties()

void blender::gpu::MTLShaderInterface::set_sampler_properties ( bool use_argument_buffer,
uint32_t argument_buffer_bind_index_vert,
uint32_t argument_buffer_bind_index_frag,
uint32_t argument_buffer_bind_index_compute )

◆ uses_argument_buffer_for_samplers()

bool blender::gpu::MTLShaderInterface::uses_argument_buffer_for_samplers ( ) const

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