Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/metal/mtl_shader_interface.hh
| Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | |||||
| }; | }; | ||||
| struct MTLShaderTexture { | struct MTLShaderTexture { | ||||
| bool used; | bool used; | ||||
| uint32_t name_offset; | uint32_t name_offset; | ||||
| /* Texture resource bind slot in shader `[[texture(n)]]`. */ | /* Texture resource bind slot in shader `[[texture(n)]]`. */ | ||||
| int slot_index; | int slot_index; | ||||
| eGPUTextureType type; | eGPUTextureType type; | ||||
| eGPUSamplerFormat sampler_format; | |||||
| ShaderStage stage_mask; | ShaderStage stage_mask; | ||||
| }; | }; | ||||
| struct MTLShaderSampler { | struct MTLShaderSampler { | ||||
| uint32_t name_offset; | uint32_t name_offset; | ||||
| /* Sampler resource bind slot in shader `[[sampler(n)]]`. */ | /* Sampler resource bind slot in shader `[[sampler(n)]]`. */ | ||||
| uint32_t slot_index = 0; | uint32_t slot_index = 0; | ||||
| }; | }; | ||||
| Show All 22 Lines | private: | ||||
| MTLShaderInputAttribute attributes_[MTL_MAX_VERTEX_INPUT_ATTRIBUTES]; | MTLShaderInputAttribute attributes_[MTL_MAX_VERTEX_INPUT_ATTRIBUTES]; | ||||
| /* Uniforms. */ | /* Uniforms. */ | ||||
| uint32_t total_uniforms_; | uint32_t total_uniforms_; | ||||
| MTLShaderUniform uniforms_[MTL_MAX_UNIFORMS_PER_BLOCK]; | MTLShaderUniform uniforms_[MTL_MAX_UNIFORMS_PER_BLOCK]; | ||||
| /* Uniform Blocks. */ | /* Uniform Blocks. */ | ||||
| uint32_t total_uniform_blocks_; | uint32_t total_uniform_blocks_; | ||||
| uint32_t max_uniformbuf_index_; | |||||
| MTLShaderUniformBlock ubos_[MTL_MAX_UNIFORM_BUFFER_BINDINGS]; | MTLShaderUniformBlock ubos_[MTL_MAX_UNIFORM_BUFFER_BINDINGS]; | ||||
| MTLShaderUniformBlock push_constant_block_; | MTLShaderUniformBlock push_constant_block_; | ||||
| /* Textures. */ | /* Textures. */ | ||||
| /* Textures support explicit binding indices, so some texture slots | /* Textures support explicit binding indices, so some texture slots | ||||
| * remain unused. */ | * remain unused. */ | ||||
| uint32_t total_textures_; | uint32_t total_textures_; | ||||
| int max_texture_index_; | int max_texture_index_; | ||||
| Show All 25 Lines | public: | ||||
| uint32_t add_uniform_block(uint32_t name_offset, | uint32_t add_uniform_block(uint32_t name_offset, | ||||
| uint32_t buffer_index, | uint32_t buffer_index, | ||||
| uint32_t size, | uint32_t size, | ||||
| ShaderStage stage_mask = ShaderStage::BOTH); | ShaderStage stage_mask = ShaderStage::BOTH); | ||||
| void add_uniform(uint32_t name_offset, eMTLDataType type, int array_len = 1); | void add_uniform(uint32_t name_offset, eMTLDataType type, int array_len = 1); | ||||
| void add_texture(uint32_t name_offset, | void add_texture(uint32_t name_offset, | ||||
| uint32_t texture_slot, | uint32_t texture_slot, | ||||
| eGPUTextureType tex_binding_type, | eGPUTextureType tex_binding_type, | ||||
| eGPUSamplerFormat sampler_format, | |||||
| ShaderStage stage_mask = ShaderStage::FRAGMENT); | ShaderStage stage_mask = ShaderStage::FRAGMENT); | ||||
| void add_push_constant_block(uint32_t name_offset); | void add_push_constant_block(uint32_t name_offset); | ||||
| /* Resolve and cache locations of builtin uniforms and uniform blocks. */ | /* Resolve and cache locations of builtin uniforms and uniform blocks. */ | ||||
| void map_builtins(); | void map_builtins(); | ||||
| void set_sampler_properties(bool use_argument_buffer, | void set_sampler_properties(bool use_argument_buffer, | ||||
| uint32_t argument_buffer_bind_index_vert, | uint32_t argument_buffer_bind_index_vert, | ||||
| uint32_t argument_buffer_bind_index_frag); | uint32_t argument_buffer_bind_index_frag); | ||||
| /* Prepare #ShaderInput interface for binding resolution. */ | /* Prepare #ShaderInput interface for binding resolution. */ | ||||
| void prepare_common_shader_inputs(); | void prepare_common_shader_inputs(); | ||||
| /* Fetch Uniforms. */ | /* Fetch Uniforms. */ | ||||
| const MTLShaderUniform &get_uniform(uint index) const; | const MTLShaderUniform &get_uniform(uint index) const; | ||||
| uint32_t get_total_uniforms() const; | uint32_t get_total_uniforms() const; | ||||
| /* Fetch Uniform Blocks. */ | /* Fetch Uniform Blocks. */ | ||||
| const MTLShaderUniformBlock &get_uniform_block(uint index) const; | const MTLShaderUniformBlock &get_uniform_block(uint index) const; | ||||
| uint32_t get_total_uniform_blocks() const; | uint32_t get_total_uniform_blocks() const; | ||||
| uint32_t get_max_ubo_index() const; | |||||
| bool has_uniform_block(uint32_t block_index) const; | bool has_uniform_block(uint32_t block_index) const; | ||||
| uint32_t get_uniform_block_size(uint32_t block_index) const; | uint32_t get_uniform_block_size(uint32_t block_index) const; | ||||
| /* Push constant uniform data block should always be available. */ | /* Push constant uniform data block should always be available. */ | ||||
| const MTLShaderUniformBlock &get_push_constant_block() const; | const MTLShaderUniformBlock &get_push_constant_block() const; | ||||
| /* Fetch textures. */ | /* Fetch textures. */ | ||||
| const MTLShaderTexture &get_texture(uint index) const; | const MTLShaderTexture &get_texture(uint index) const; | ||||
| Show All 29 Lines | |||||