|
Blender V5.3
|
#include <mtl_shader.hh>
Inherits blender::gpu::Shader.
Shader stage creation. | |
| void | vertex_shader_from_glsl (const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override |
| void | geometry_shader_from_glsl (const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override |
| void | fragment_shader_from_glsl (const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override |
| void | compute_shader_from_glsl (const shader::ShaderCreateInfo &info, MutableSpan< StringRefNull > sources) override |
| bool | finalize (const shader::ShaderCreateInfo *info=nullptr) override |
Additional Inherited Members | |
| Static Public Member Functions inherited from blender::gpu::Shader | |
| 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) |
| 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) |
| static std::string | run_preprocessor (StringRef source, bool no_dead_code_elimination) |
| Public Attributes inherited from blender::gpu::Shader | |
| 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 inherited from blender::gpu::Shader | |
| void | print_log (Span< StringRefNull > sources, const char *log, const char *stage, bool error, GPULogParser *parser) |
| Protected Attributes inherited from blender::gpu::Shader | |
| char | name [64] |
| Shader * | parent_shader_ = nullptr |
| std::unique_ptr< PatchedShaderCreateInfo > | patched_info_ |
MTLShader implements shader compilation, Pipeline State Object (PSO) creation for rendering and uniform data binding. Shaders can either be created from native MSL, or generated from a GLSL source shader using #GPUShaderCreateInfo.
Shader creation process:
Definition at line 125 of file mtl_shader.hh.
| blender::gpu::MTLShader::MTLShader | ( | MTLContext * | ctx, |
| const char * | name ) |
Definition at line 91 of file mtl_shader.mm.
References blender::gpu::Shader::name, and blender::gpu::Shader::Shader().
Referenced by blender::gpu::MTLBackend::shader_alloc(), and warm_cache().
| blender::gpu::MTLShader::~MTLShader | ( | ) |
Definition at line 96 of file mtl_shader.mm.
References is_valid().
| MTLComputePipelineStateInstance * blender::gpu::MTLShader::bake_compute_pipeline_state | ( | MTLContext * | ctx, |
| MTLComputePipelineStateDescriptor & | compute_pipeline_descriptor ) |
Definition at line 1022 of file mtl_shader.mm.
References blender::BLI_assert(), CLOG_ERROR, CLOG_WARN, blender::gpu::COMPUTE, blender::gpu::MTLComputePipelineStateInstance::compute, blender::gpu::Shader::constants, blender::gpu::MTLContext::device, init(), is_valid(), blender::gpu::LOG, MTL_LOG_WARNING, options, blender::gpu::populate_specialization_constant_values(), blender::gpu::MTLComputePipelineStateInstance::pso, blender::gpu::MTLComputePipelineStateInstance::shader_pso_index, and blender::gpu::MTLComputePipelineStateDescriptor::specialization_state.
Referenced by blender::gpu::MTLContext::ensure_compute_pipeline_state(), and finalize().
| MTLRenderPipelineStateInstance * blender::gpu::MTLShader::bake_current_pipeline_state | ( | MTLContext * | ctx, |
| MTLPrimitiveTopologyClass | prim_type ) |
Bakes or fetches a pipeline state using the current MTLRenderPipelineStateDescriptor state.
This state contains information on shader inputs/outputs, such as the vertex descriptor, used to control vertex assembly for current vertex data, and active render target information, describing the output attachment pixel formats.
Other rendering parameters such as global point-size, blend state, color mask etc; are also used. See mtl_shader.h for full #MLRenderPipelineStateDescriptor.
Populate global pipeline descriptor and use this to prepare new PSO.
Definition at line 667 of file mtl_shader.mm.
References blender::gpu::MTLContextGlobalShaderPipelineState::alpha_blend_op, blender::gpu::MTLRenderPipelineStateDescriptor::alpha_blend_op, bake_graphic_pipeline_state(), blender::gpu::MTLContextGlobalShaderPipelineState::blending_enabled, blender::gpu::MTLRenderPipelineStateDescriptor::blending_enabled, blender::BLI_assert(), blender::gpu::MTLContextGlobalShaderPipelineState::clip_distance_enabled, blender::gpu::MTLRenderPipelineStateDescriptor::clipping_plane_enable_mask, blender::gpu::MTLRenderPipelineStateDescriptor::color_attachment_format, blender::gpu::MTLRenderPipelineStateDescriptor::color_attachment_mask, blender::gpu::MTLContextGlobalShaderPipelineState::color_write_mask, blender::gpu::MTLRenderPipelineStateDescriptor::color_write_mask, blender::gpu::MTLRenderPipelineStateDescriptor::depth_attachment_format, blender::gpu::MTLContextGlobalShaderPipelineState::dest_alpha_blend_factor, blender::gpu::MTLRenderPipelineStateDescriptor::dest_alpha_blend_factor, blender::gpu::MTLContextGlobalShaderPipelineState::dest_rgb_blend_factor, blender::gpu::MTLRenderPipelineStateDescriptor::dest_rgb_blend_factor, blender::gpu::Texture::format_get(), blender::gpu::MTLContext::get(), blender::gpu::MTLFrameBuffer::get_color_attachment(), blender::gpu::MTLContext::get_current_framebuffer(), blender::gpu::MTLFrameBuffer::get_depth_attachment(), get_interface(), blender::gpu::MTLFrameBuffer::get_is_srgb(), blender::gpu::MTLStateManager::get_pipeline_descriptor(), blender::gpu::MTLFrameBuffer::get_srgb_enabled(), blender::gpu::MTLFrameBuffer::get_stencil_attachment(), GPU_FB_MAX_COLOR_ATTACHMENT, blender::gpu::gpu_texture_format_to_metal(), blender::gpu::MTLAttachment::ignored, blender::IndexRange::IndexRange(), blender::gpu::Shader::interface, is_valid(), blender::gpu::MTLRenderPipelineStateDescriptor::num_color_attachments, blender::gpu::MTLContext::pipeline_state, blender::gpu::MTLContextGlobalShaderPipelineState::point_size, blender::gpu::MTLRenderPipelineStateDescriptor::point_size, blender::gpu::MTLVertexDescriptor::prim_topology_class, blender::gpu::MTLContextGlobalShaderPipelineState::rgb_blend_op, blender::gpu::MTLRenderPipelineStateDescriptor::rgb_blend_op, blender::gpu::MTLRenderPipelineStateDescriptor::specialization_state, blender::gpu::MTLContextGlobalShaderPipelineState::src_alpha_blend_factor, blender::gpu::MTLRenderPipelineStateDescriptor::src_alpha_blend_factor, blender::gpu::MTLContextGlobalShaderPipelineState::src_rgb_blend_factor, blender::gpu::MTLRenderPipelineStateDescriptor::src_rgb_blend_factor, blender::gpu::Context::state_manager, blender::gpu::MTLRenderPipelineStateDescriptor::stencil_attachment_format, blender::gpu::MTLAttachment::texture, blender::gpu::MTLAttachment::used, and blender::gpu::MTLRenderPipelineStateDescriptor::vertex_descriptor.
Referenced by blender::gpu::MTLContext::ensure_render_pipeline_state().
| MTLRenderPipelineStateInstance * blender::gpu::MTLShader::bake_graphic_pipeline_state | ( | MTLContext * | ctx, |
| MTLPrimitiveTopologyClass | prim_type, | ||
| const MTLRenderPipelineStateDescriptor & | pipeline_descriptor ) |
Definition at line 758 of file mtl_shader.mm.
References blender::gpu::MTLRenderPipelineStateDescriptor::alpha_blend_op, blender::gpu::ShaderInterface::attr_len_, blender::gpu::MTLVertexDescriptor::attributes, blender::bitscan_reverse_uint(), blender::gpu::MTLRenderPipelineStateDescriptor::blending_enabled, blender::BLI_assert(), BLI_assert_msg, blender::gpu::MTLVertexAttributeDescriptorPSO::buffer_index, blender::gpu::MTLVertexDescriptor::buffer_layouts, blender::gpu::MTLVertexBufferLayoutDescriptorPSO::buffer_slot, CLOG_DEBUG, CLOG_ERROR, CLOG_WARN, blender::gpu::MTLRenderPipelineStateDescriptor::color_attachment_format, blender::gpu::MTLRenderPipelineStateDescriptor::color_attachment_mask, blender::gpu::MTLRenderPipelineStateDescriptor::color_write_mask, blender::gpu::Shader::constants, blender::gpu::MTLRenderPipelineStateDescriptor::depth_attachment_format, blender::gpu::MTLRenderPipelineStateDescriptor::dest_alpha_blend_factor, blender::gpu::MTLRenderPipelineStateDescriptor::dest_rgb_blend_factor, blender::gpu::MTLContext::device, fabsf, blender::gpu::MTLVertexAttributeDescriptorPSO::format, blender::gpu::MTLRenderPipelineStateInstance::frag, blender::gpu::FRAGMENT, get_interface(), GPU_FB_MAX_COLOR_ATTACHMENT, blender::gpu::gpu_type_to_metal_vertex_format(), blender::gpu::MTLRenderPipelineStateDescriptor::hash(), blender::IndexRange::IndexRange(), blender::gpu::ShaderInterface::inputs_, blender::gpu::Shader::interface, is_valid(), blender::gpu::LOG, blender::gpu::MTLVertexDescriptor::max_attribute_value, blender::gpu::mtl_format_supports_blending(), MTL_LOG_ERROR, MTL_MAX_BUFFER_BINDINGS, blender::gpu::MTLRenderPipelineStateInstance::null_attribute_buffer_index, blender::gpu::MTLVertexDescriptor::num_vert_buffers, blender::gpu::MTLVertexAttributeDescriptorPSO::offset, options, blender::gpu::MTLRenderPipelineStateInstance::parse_reflection_data(), blender::gpu::MTLRenderPipelineStateDescriptor::point_size, blender::gpu::populate_specialization_constant_values(), blender::gpu::MTLVertexDescriptor::prim_topology_class, blender::gpu::MTLRenderPipelineStateInstance::prim_type, blender::gpu::MTLRenderPipelineStateInstance::pso, reset(), blender::gpu::MTLRenderPipelineStateDescriptor::rgb_blend_op, blender::gpu::MTLRenderPipelineStateInstance::shader_pso_index, blender::gpu::MTLRenderPipelineStateDescriptor::specialization_state, blender::gpu::MTLRenderPipelineStateDescriptor::src_alpha_blend_factor, blender::gpu::MTLRenderPipelineStateDescriptor::src_rgb_blend_factor, blender::gpu::MTLRenderPipelineStateDescriptor::stencil_attachment_format, blender::gpu::MTLVertexBufferLayoutDescriptorPSO::step_function, blender::gpu::MTLVertexBufferLayoutDescriptorPSO::step_rate, blender::gpu::MTLVertexBufferLayoutDescriptorPSO::stride, blender::gpu::MTLRenderPipelineStateInstance::used_buf_vert_mask, blender::gpu::MTLRenderPipelineStateInstance::vert, blender::gpu::VERTEX, and blender::gpu::MTLRenderPipelineStateDescriptor::vertex_descriptor.
Referenced by bake_current_pipeline_state(), and warm_cache().
|
overridevirtual |
Implements blender::gpu::Shader.
Definition at line 430 of file mtl_shader.mm.
References blender::gpu::MTLContextGlobalShaderPipelineState::active_shader, blender::gpu::MTLContext::get(), blender::gpu::Shader::interface, is_valid(), MTL_LOG_WARNING, blender::gpu::Shader::name_get(), blender::gpu::MTLContext::pipeline_state, and blender::gpu::MTLContext::specialization_constants_set().
|
inlineoverridevirtual |
Implements blender::gpu::Shader.
Definition at line 233 of file mtl_shader.hh.
|
overridevirtual |
Implements blender::gpu::Shader.
Definition at line 363 of file mtl_shader.mm.
References blender::gpu::COMPUTE.
|
overridevirtual |
Implements blender::gpu::Shader.
Definition at line 369 of file mtl_shader.mm.
References bake_compute_pipeline_state(), blender::gpu::shader::ShaderCreateInfo::compute_layout_, blender::gpu::Shader::constants, init(), is_valid(), blender::gpu::shader::ShaderCreateInfo::ComputeStageLayout::local_size_x, blender::gpu::shader::ShaderCreateInfo::ComputeStageLayout::local_size_y, blender::gpu::shader::ShaderCreateInfo::ComputeStageLayout::local_size_z, MTL_LOG_ERROR, blender::gpu::Shader::name, blender::gpu::Shader::name_get(), and blender::gpu::shader::ShaderCreateInfo::push_constants_.
| bool blender::gpu::MTLShader::finalize_compute | ( | const shader::ShaderCreateInfo * | info | ) |
References warm_cache().
|
inlineoverridevirtual |
Implements blender::gpu::Shader.
Definition at line 221 of file mtl_shader.hh.
|
overridevirtual |
Implements blender::gpu::Shader.
Definition at line 357 of file mtl_shader.mm.
References blender::gpu::FRAGMENT.
|
inlineoverridevirtual |
Implements blender::gpu::Shader.
Definition at line 225 of file mtl_shader.hh.
|
inlineoverridevirtual |
Implements blender::gpu::Shader.
Definition at line 229 of file mtl_shader.hh.
|
overridevirtual |
Implements blender::gpu::Shader.
Definition at line 351 of file mtl_shader.mm.
References MTL_LOG_ERROR.
|
inline |
Definition at line 256 of file mtl_shader.hh.
Referenced by blender::gpu::MTLContext::compute_dispatch(), and blender::gpu::MTLContext::compute_dispatch_indirect().
|
inline |
Definition at line 194 of file mtl_shader.hh.
|
inline |
Definition at line 199 of file mtl_shader.hh.
References blender::gpu::Shader::interface.
Referenced by bake_current_pipeline_state(), bake_graphic_pipeline_state(), and blender::gpu::MTLContext::ensure_render_pipeline_state().
|
inline |
Definition at line 205 of file mtl_shader.hh.
Referenced by blender::gpu::MTLContext::compute_dispatch(), blender::gpu::MTLContext::compute_dispatch_indirect(), and blender::gpu::MTLContext::ensure_render_pipeline_state().
|
inline |
Definition at line 186 of file mtl_shader.hh.
|
inline |
Definition at line 190 of file mtl_shader.hh.
References blender::gpu::Shader::parent_shader_.
|
inlineoverridevirtual |
Implements blender::gpu::Shader.
Definition at line 160 of file mtl_shader.hh.
Referenced by bake_compute_pipeline_state(), and finalize().
|
inline |
Definition at line 182 of file mtl_shader.hh.
Referenced by bake_compute_pipeline_state(), bake_current_pipeline_state(), bake_graphic_pipeline_state(), bind(), blender::gpu::MTLImmediate::end(), blender::gpu::MTLContext::ensure_compute_pipeline_state(), blender::gpu::MTLContext::ensure_render_pipeline_state(), finalize(), uniform_float(), and ~MTLShader().
|
overridevirtual |
Implements blender::gpu::Shader.
Definition at line 165 of file mtl_shader.mm.
References blender::gpu::MTLBackend::get_capabilities(), blender::gpu::shader::ShaderCreateInfo::max_sampler_slot(), blender::gpu::patch_create_info_atomic_workaround(), blender::gpu::Shader::patched_info_, and blender::gpu::shader::USE_SAMPLER_ARG_BUFFER.
|
inlineoverridevirtual |
Implements blender::gpu::Shader.
Definition at line 213 of file mtl_shader.hh.
|
overridevirtual |
Implements blender::gpu::Shader.
Definition at line 445 of file mtl_shader.mm.
References blender::gpu::MTLContextGlobalShaderPipelineState::active_shader, blender::gpu::MTLContext::get(), and blender::gpu::MTLContext::pipeline_state.
|
overridevirtual |
Implements blender::gpu::Shader.
Definition at line 451 of file mtl_shader.mm.
References blender::BLI_assert(), blender::data, float, blender::IndexRange::IndexRange(), is_valid(), and MTL_LOG_WARNING.
Referenced by uniform_int().
|
overridevirtual |
Implements blender::gpu::Shader.
Definition at line 503 of file mtl_shader.mm.
References blender::data, float, and uniform_float().
Referenced by blender::gpu::bind_atomic_workaround_buffer().
|
inlineoverridevirtual |
Implements blender::gpu::Shader.
Definition at line 217 of file mtl_shader.hh.
|
overridevirtual |
Implements blender::gpu::Shader.
Definition at line 345 of file mtl_shader.mm.
References blender::gpu::VERTEX.
|
overridevirtual |
Implements blender::gpu::Shader.
Definition at line 511 of file mtl_shader.mm.
References bake_graphic_pipeline_state(), blender::gpu::MTLContext::get(), blender::IndexRange::IndexRange(), blender::min_ii(), MTLShader(), blender::gpu::Shader::parent_shader_, blender::gpu::MTLRenderPipelineStateInstance::prim_type, and lexit::Vector< T >::size().
Referenced by finalize_compute().