Blender V5.3
blender::gpu::MTLContext Class Reference

#include <mtl_context.hh>

Inherits blender::gpu::Context.

Public Member Functions

void debug_unbind_all_ubo () override
void debug_unbind_all_ssbo () override
MTLContextTextureUtils & get_texture_utils ()
MTLContextComputeUtils & get_compute_utils ()
bool get_active ()
bool get_inside_frame ()
uint get_current_frame_index ()
MTLScratchBufferManager & get_scratch_buffer_manager ()
MTLSamplerArray & get_sampler_array ()
Map< MTLSamplerArray, gpu::MTLBuffer * > & get_sampler_arg_buf_cache ()
Texture State Management
void texture_bind (gpu::MTLTexture *mtl_texture, uint texture_unit, bool is_image)
void sampler_bind (MTLSamplerState, uint sampler_unit)
void texture_unbind (gpu::MTLTexture *mtl_texture, bool is_image, StateManager *state_manager)
void texture_unbind_all (bool is_image)
void sampler_state_cache_init ()
id< MTLSamplerState > get_sampler_from_state (MTLSamplerState state)
id< MTLSamplerState > get_default_sampler_state ()
Global Context State
void pipeline_state_init ()
void set_viewport (int origin_x, int origin_y, int width, int height)
void set_viewports (int count, const int(&viewports)[GPU_MAX_VIEWPORTS][4])
void set_scissor (int scissor_x, int scissor_y, int scissor_width, int scissor_height)
void set_scissor_enabled (bool scissor_enabled)
Command Encoder and pipeline state

These utilities ensure that all of the globally bound resources and state have been correctly encoded within the current RenderCommandEncoder. This involves managing buffer bindings, texture bindings, depth stencil state and dynamic pipeline state.

We will also trigger compilation of new PSOs where the input state has changed and is required. All of this setup is required in order to perform a valid draw call.

bool ensure_render_pipeline_state (MTLPrimitiveType prim_type)
void ensure_depth_stencil_state ()
Compute dispatch.
const MTLComputePipelineStateInstance * ensure_compute_pipeline_state ()
void compute_dispatch (int groups_x_len, int groups_y_len, int groups_z_len)
void compute_dispatch_indirect (StorageBuf *indirect_buf)
Visibility buffer control for MTLQueryPool.
void set_visibility_buffer (gpu::MTLBuffer *buffer)
gpu::MTLBuffer * get_visibility_buffer () const
bool is_visibility_dirty () const
void clear_visibility_dirty ()
Public Member Functions inherited from blender::gpu::Context
 Context ()
virtual ~Context ()
bool is_active_on_thread ()
VertBuf * dummy_vbo_get ()
Batch * procedural_points_batch_get ()
Batch * procedural_lines_batch_get ()
Batch * procedural_triangles_batch_get ()
Batch * procedural_triangle_strips_batch_get ()
void assert_framebuffer_shader_compatibility (Shader *sh)

Static Public Member Functions

static MTLContext * get ()
static void global_memory_manager_acquire_ref ()
static void global_memory_manager_release_ref ()
static MTLBufferPool * get_global_memory_manager ()
static void latency_resolve_average (int64_t frame_latency_us)
Static Public Member Functions inherited from blender::gpu::Context
static Context * get ()

Public Attributes

MTLContextGlobalShaderPipelineState pipeline_state
id< MTLCommandQueue > queue = nil
id< MTLDevice > device = nil
NSString * label = nil
MTLScratchBufferManager memory_manager
MTLCommandBufferManager main_command_buffer
shader::SpecializationConstants constants_state
Public Attributes inherited from blender::gpu::Context
Shader * shader = nullptr
FrameBuffer * active_fb = nullptr
GPUMatrixState * matrix_state = nullptr
StateManager * state_manager = nullptr
Immediate * imm = nullptr
FrameBuffer * back_left = nullptr
FrameBuffer * front_left = nullptr
FrameBuffer * back_right = nullptr
FrameBuffer * front_right = nullptr
DebugStack debug_stack
bool debug_is_capturing = false
bool debug_pipeline_creation = false
int context_id = 0
Vector< StorageBuf * > printf_buf
VertBuf * dummy_vbo = nullptr
Batch * procedural_points_batch = nullptr
Batch * procedural_lines_batch = nullptr
Batch * procedural_triangles_batch = nullptr
Batch * procedural_triangle_strips_batch = nullptr
TexturePool * texture_pool = nullptr
int shader_builtin_srgb_transform = 0
bool shader_builtin_srgb_is_dirty = false

Static Public Attributes

static std::atomic< int > max_drawables_in_flight = 0
static std::atomic< int64_t > avg_drawable_latency_us = 0
static int64_t frame_latency [MTL_FRAME_AVERAGE_COUNT] = {0}
static std::mutex global_memory_manager_reflock
static int global_memory_manager_refcount = 0
static MTLBufferPool * global_memory_manager = nullptr
Static Public Attributes inherited from blender::gpu::Context
static std::atomic< int > context_counter = 0

Friends

class MTLBackend
class MTLRenderPassState
class MTLComputeState

Debug Groups

Useful for debugging through render-doc. This makes all the API calls grouped into "passes".

void debug_group_begin (const char *name, int index) override
void debug_group_end () override
bool debug_capture_begin (const char *title) override
void debug_capture_end () override
void * debug_capture_scope_create (const char *name) override
bool debug_capture_scope_begin (void *scope) override
void debug_capture_scope_end (void *scope) override

MTLContext

 MTLContext (GHOST_IWindow *ghost_window, GHOST_IContext *ghost_context)
 ~MTLContext ()
void activate () override
void deactivate () override
void begin_frame () override
void end_frame () override
void flush () override
void finish () override
void memory_statistics_get (int *r_total_mem, int *r_free_mem) override
void framebuffer_bind (MTLFrameBuffer *framebuffer)
void framebuffer_restore ()
id< MTLRenderCommandEncoder > ensure_begin_render_pass ()
MTLFrameBuffer * get_current_framebuffer ()
MTLFrameBuffer * get_default_framebuffer ()
void specialization_constants_set (const shader::SpecializationConstants *constants_state)
MTLShader * get_active_shader ()
id< MTLBuffer > get_null_buffer ()
id< MTLBuffer > get_null_attribute_buffer ()
gpu::MTLTexture * get_dummy_texture (GPUTextureType type, GPUSamplerFormat sampler_format)
void free_dummy_resources ()
static void check_error (const char *info)

Additional Inherited Members

Protected Member Functions inherited from blender::gpu::Context
void free_resources ()
Protected Attributes inherited from blender::gpu::Context
pthread_t thread_
bool is_active_
GHOST_IWindow * ghost_window_

Detailed Description

MTLContext – Core render loop and state management.

NOTE(Metal): Partial MTLContext stub to provide wrapper functionality for work-in-progress MTL* classes.

Definition at line 620 of file mtl_context.hh.

Constructor & Destructor Documentation

◆ MTLContext()

◆ ~MTLContext()

Member Function Documentation

◆ activate()

◆ begin_frame()

void blender::gpu::MTLContext::begin_frame ( )
overridevirtual

◆ check_error()

void blender::gpu::MTLContext::check_error ( const char * info)
static

Definition at line 396 of file mtl_context.mm.

◆ clear_visibility_dirty()

void blender::gpu::MTLContext::clear_visibility_dirty ( )

Definition at line 1697 of file mtl_context.mm.

◆ compute_dispatch()

void blender::gpu::MTLContext::compute_dispatch ( int groups_x_len,
int groups_y_len,
int groups_z_len )

◆ compute_dispatch_indirect()

void blender::gpu::MTLContext::compute_dispatch_indirect ( StorageBuf * indirect_buf)

Ensure resource bindings.

Definition at line 1588 of file mtl_context.mm.

References blender::gpu::MTLContextGlobalShaderPipelineState::active_shader, blender::gpu::MTLComputeState::bind_pso(), blender::BLI_assert(), blender::StringRefNull::c_str(), blender::gpu::MTLComputePipelineStateInstance::compute, blender::gpu::MTLComputeState::compute_bindings, blender::gpu::MTLCommandBufferManager::ensure_begin_compute_encoder(), blender::gpu::ensure_buffer_bindings(), ensure_compute_pipeline_state(), blender::gpu::ensure_push_constant(), blender::gpu::ensure_texture_bindings(), blender::G, blender::G_DEBUG_GPU, blender::gpu::MTLShader::get_compute_common_state(), blender::gpu::MTLCommandBufferManager::get_compute_state(), blender::gpu::MTLStorageBuf::get_metal_buffer(), blender::gpu::MTLShader::get_push_constant_buf(), blender::GPU_flush(), blender::gpu::MTLPushConstantBuf::is_dirty(), main_command_buffer, MTL_LOG_WARNING, MTLComputeState, blender::gpu::Shader::name_get(), pipeline_state, blender::gpu::MTLComputePipelineStateInstance::pso, blender::gpu::Context::shader, blender::gpu::MTLPushConstantBuf::tag_dirty(), blender::gpu::MTLPushConstantBuf::tag_updated(), blender::gpu::MTLComputePipelineStateCommon::threadgroup_x_len, blender::gpu::MTLComputePipelineStateCommon::threadgroup_y_len, blender::gpu::MTLComputePipelineStateCommon::threadgroup_z_len, and blender::gpu::MTLCommandBufferManager::unfold_pending_debug_groups().

Referenced by blender::gpu::MTLBackend::compute_dispatch_indirect().

◆ deactivate()

void blender::gpu::MTLContext::deactivate ( )
overridevirtual

◆ debug_capture_begin()

bool blender::gpu::MTLContext::debug_capture_begin ( const char * title)
overridevirtual

Implements blender::gpu::Context.

Definition at line 127 of file mtl_debug.mm.

References CLOG_ERROR, device, blender::bke::subdiv::init(), and blender::gpu::LOG.

Referenced by debug_capture_scope_begin().

◆ debug_capture_end()

void blender::gpu::MTLContext::debug_capture_end ( )
overridevirtual

Implements blender::gpu::Context.

Definition at line 152 of file mtl_debug.mm.

Referenced by debug_capture_scope_end().

◆ debug_capture_scope_begin()

bool blender::gpu::MTLContext::debug_capture_scope_begin ( void * scope)
overridevirtual

Implements blender::gpu::Context.

Definition at line 177 of file mtl_debug.mm.

References debug_capture_begin(), blender::G, and label.

◆ debug_capture_scope_create()

void * blender::gpu::MTLContext::debug_capture_scope_create ( const char * name)
overridevirtual

Implements blender::gpu::Context.

Definition at line 162 of file mtl_debug.mm.

References device.

◆ debug_capture_scope_end()

void blender::gpu::MTLContext::debug_capture_scope_end ( void * scope)
overridevirtual

Implements blender::gpu::Context.

Definition at line 191 of file mtl_debug.mm.

References debug_capture_end(), blender::G, and label.

◆ debug_group_begin()

void blender::gpu::MTLContext::debug_group_begin ( const char * name,
int index )
overridevirtual

Reimplemented from blender::gpu::Context.

Definition at line 52 of file mtl_debug.mm.

References blender::G.

◆ debug_group_end()

void blender::gpu::MTLContext::debug_group_end ( )
overridevirtual

Reimplemented from blender::gpu::Context.

Definition at line 70 of file mtl_debug.mm.

References CLOG_ERROR, blender::G, and blender::gpu::debug::LOG.

◆ debug_unbind_all_ssbo()

void blender::gpu::MTLContext::debug_unbind_all_ssbo ( )
inlineoverridevirtual

Implements blender::gpu::Context.

Definition at line 752 of file mtl_context.hh.

◆ debug_unbind_all_ubo()

void blender::gpu::MTLContext::debug_unbind_all_ubo ( )
inlineoverridevirtual

Implements blender::gpu::Context.

Definition at line 751 of file mtl_context.hh.

◆ end_frame()

void blender::gpu::MTLContext::end_frame ( )
overridevirtual

Implements blender::gpu::Context.

Definition at line 383 of file mtl_context.mm.

References blender::BLI_assert(), flush(), and get_inside_frame().

Referenced by ~MTLContext().

◆ ensure_begin_render_pass()

◆ ensure_compute_pipeline_state()

◆ ensure_depth_stencil_state()

void blender::gpu::MTLContext::ensure_depth_stencil_state ( )

Prepare Depth-stencil state based on current global pipeline state.

Definition at line 1364 of file mtl_context.mm.

References blender::BLI_assert(), blender::gpu::MTLRenderPassState::bound_ds_state, clamp(), blender::gpu::MTLContextDepthStencilState::depth_function, blender::gpu::MTLContextGlobalShaderPipelineState::depth_stencil_state, blender::gpu::MTLContextDepthStencilState::depth_test_enabled, blender::gpu::MTLContextDepthStencilState::depth_write_enable, device, blender::gpu::MTLContextGlobalShaderPipelineState::dirty_flags, blender::fb(), blender::gpu::MTLCommandBufferManager::get_active_render_command_encoder(), get_current_framebuffer(), blender::gpu::MTLCommandBufferManager::get_render_pass_state(), blender::gpu::MTLContextDepthStencilState::has_depth_target, blender::gpu::MTLContextDepthStencilState::has_stencil_target, blender::bke::subdiv::init(), blender::gpu::MTLRenderPassState::last_used_stencil_ref_value, main_command_buffer, blender::gpu::MTL_PIPELINE_STATE_DEPTHSTENCIL_FLAG, MTLRenderPassState, pipeline_state, blender::gpu::MTLContextDepthStencilState::stencil_func, blender::gpu::MTLContextDepthStencilState::stencil_op_back_depth_fail, blender::gpu::MTLContextDepthStencilState::stencil_op_back_depthstencil_pass, blender::gpu::MTLContextDepthStencilState::stencil_op_back_stencil_fail, blender::gpu::MTLContextDepthStencilState::stencil_op_front_depth_fail, blender::gpu::MTLContextDepthStencilState::stencil_op_front_depthstencil_pass, blender::gpu::MTLContextDepthStencilState::stencil_op_front_stencil_fail, blender::gpu::MTLContextDepthStencilState::stencil_read_mask, blender::gpu::MTLContextDepthStencilState::stencil_ref, blender::gpu::MTLContextDepthStencilState::stencil_test_enabled, and blender::gpu::MTLContextDepthStencilState::stencil_write_mask.

◆ ensure_render_pipeline_state()

bool blender::gpu::MTLContext::ensure_render_pipeline_state ( MTLPrimitiveType prim_type)

Ensure resource bindings.

Dynamic Per-draw Render State on RenderCommandEncoder.

Definition at line 1128 of file mtl_context.mm.

References blender::gpu::MTLContextGlobalShaderPipelineState::active_shader, blender::gpu::StateManager::apply_state(), blender::assign_if_different(), blender::gpu::MTLShader::bake_current_pipeline_state(), blender::gpu::MTLRenderPassState::bind_vertex_buffer(), blender::BLI_assert(), BLI_assert_unreachable, blender::gpu::MTLRenderPassState::bound_pso, blender::gpu::MTLContextGlobalShaderPipelineState::cull_mode, blender::gpu::MTLContextGlobalShaderPipelineState::culling_enabled, blender::gpu::MTLContextGlobalShaderPipelineState::dirty_flags, blender::gpu::ensure_buffer_bindings(), blender::gpu::ensure_push_constant(), blender::gpu::ensure_texture_bindings(), blender::gpu::MTLRenderPipelineStateInstance::frag, blender::gpu::MTLRenderPassState::fragment_bindings, blender::gpu::MTLContextGlobalShaderPipelineState::front_face, blender::G, blender::G_DEBUG_GPU, blender::gpu::MTLCommandBufferManager::get_active_framebuffer(), blender::gpu::MTLCommandBufferManager::get_active_render_command_encoder(), blender::gpu::MTLFrameBuffer::get_attachment_height(), blender::gpu::MTLFrameBuffer::get_attachment_width(), blender::gpu::MTLFrameBuffer::get_dirty(), blender::gpu::MTLFrameBuffer::get_height(), blender::gpu::MTLShader::get_interface(), get_null_attribute_buffer(), blender::gpu::MTLShader::get_push_constant_buf(), blender::gpu::MTLCommandBufferManager::get_render_pass_state(), blender::gpu::MTLFrameBuffer::get_width(), blender::GPU_CLOCKWISE, blender::GPU_CULL_BACK, blender::GPU_CULL_FRONT, blender::GPU_CULL_NONE, blender::GPU_shader_uniform_1f(), blender::gpu::MTLPushConstantBuf::is_dirty(), blender::gpu::MTLShader::is_valid(), blender::gpu::MTLRenderPassState::last_bound_shader_state, blender::gpu::MTLRenderPassState::last_scissor_rect, main_command_buffer, blender::max_ii(), blender::min_ii(), MTL_LOG_DEBUG, MTL_LOG_ERROR, MTL_LOG_WARNING, blender::gpu::MTL_PIPELINE_STATE_CULLMODE_FLAG, blender::gpu::MTL_PIPELINE_STATE_FRONT_FACING_FLAG, blender::gpu::MTL_PIPELINE_STATE_SCISSOR_FLAG, MTLRenderPassState, blender::gpu::StateManager::mutable_state, blender::gpu::MTLShaderInterface::name_get(), blender::gpu::MTLRenderPipelineStateInstance::null_attribute_buffer_index, blender::gpu::MTLContextGlobalShaderPipelineState::num_active_viewports, pipeline_state, blender::gpu::MTLRenderPipelineStateInstance::pso, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_enabled, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_height, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_width, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_x, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_y, blender::gpu::Context::shader, blender::gpu::Context::state_manager, blender::gpu::MTLPushConstantBuf::tag_dirty(), blender::gpu::MTLPushConstantBuf::tag_updated(), blender::gpu::MTLRenderPipelineStateInstance::used_buf_frag_mask, blender::gpu::MTLRenderPipelineStateInstance::used_buf_vert_mask, blender::gpu::MTLRenderPipelineStateInstance::used_ima_frag_mask, blender::gpu::MTLRenderPipelineStateInstance::used_ima_vert_mask, blender::gpu::MTLRenderPipelineStateInstance::used_tex_frag_mask, blender::gpu::MTLRenderPipelineStateInstance::used_tex_vert_mask, blender::v, blender::gpu::MTLRenderPipelineStateInstance::vert, blender::gpu::MTLRenderPassState::vertex_bindings, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_height, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_offset_x, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_offset_y, and blender::gpu::MTLContextGlobalShaderPipelineState::viewport_width.

Referenced by blender::gpu::MTLBatch::bind().

◆ finish()

void blender::gpu::MTLContext::finish ( )
overridevirtual

Implements blender::gpu::Context.

Definition at line 453 of file mtl_context.mm.

References main_command_buffer, and blender::gpu::MTLCommandBufferManager::submit().

Referenced by ~MTLContext().

◆ flush()

◆ framebuffer_bind()

void blender::gpu::MTLContext::framebuffer_bind ( MTLFrameBuffer * framebuffer)

Metal Context Core functions.

Definition at line 465 of file mtl_context.mm.

References blender::gpu::Context::active_fb, and blender::BLI_assert().

Referenced by blender::gpu::MTLFrameBuffer::bind().

◆ framebuffer_restore()

void blender::gpu::MTLContext::framebuffer_restore ( )

◆ free_dummy_resources()

void blender::gpu::MTLContext::free_dummy_resources ( )

◆ get()

MTLContext * blender::gpu::MTLContext::get ( )
inlinestatic

Definition at line 738 of file mtl_context.hh.

References blender::gpu::Context::get(), and MTLContext().

Referenced by blender::gpu::MTLFrameBuffer::apply_state(), blender::gpu::MTLStorageBuf::async_flush_to_host(), blender::gpu::MTLShader::bake_current_pipeline_state(), blender::gpu::MTLFrameBuffer::bake_render_pass_descriptor(), blender::gpu::MTLQueryPool::begin_query(), blender::gpu::MTLBatch::bind(), blender::gpu::MTLFrameBuffer::bind(), blender::gpu::MTLShader::bind(), blender::gpu::MTLStorageBuf::bind(), blender::gpu::MTLTopLevelAS::bind(), blender::gpu::MTLUniformBuf::bind(), blender::gpu::MTLVertBuf::bind(), blender::gpu::MTLFrameBuffer::blit(), blender::gpu::MTLBottomLevelAS::build(), blender::gpu::MTLTopLevelAS::build(), blender::gpu::MTLFrameBuffer::clear(), blender::gpu::MTLStorageBuf::clear(), blender::gpu::MTLTexture::clear(), blender::gpu::MTLFrameBuffer::clear_attachment(), blender::gpu::MTLBackend::compute_dispatch(), blender::gpu::MTLBackend::compute_dispatch_indirect(), blender::gpu::MTLIndexBuf::copy_sub(), blender::gpu::MTLStorageBuf::copy_sub(), blender::gpu::MTLVertBuf::copy_sub(), blender::gpu::MTLTexture::copy_to(), blender::gpu::MTLImmediate::end(), blender::gpu::MTLQueryPool::end_query(), blender::gpu::MTLWorkInFlight::end_work(), blender::gpu::MTLBackend::framebuffer_alloc(), blender::gpu::MTLTexture::generate_mipmap(), blender::gpu::MTLContextComputeUtils::get_buffer_clear_pso(), blender::gpu::MTLPixelBuffer::get_native_handle(), blender::gpu::MTLQueryPool::get_occlusion_result(), blender::gpu::MTLStateManager::image_bind(), blender::gpu::MTLStateManager::image_unbind(), blender::gpu::MTLStateManager::image_unbind_all(), blender::gpu::MTLStorageBuf::init(), blender::gpu::MTLTexture::init_internal(), blender::gpu::MTLStateManager::issue_barrier(), blender::gpu::MTLPixelBuffer::map(), blender::gpu::MTLWorkInFlight::MTLWorkInFlight(), blender::gpu::present(), blender::gpu::MTLIndexBuf::read(), blender::gpu::MTLStorageBuf::read(), blender::gpu::MTLVertBuf::read(), blender::gpu::MTLBackend::shader_alloc(), blender::gpu::MTLFence::signal(), blender::gpu::MTLStateManager::texture_bind(), blender::gpu::MTLStateManager::texture_unbind(), blender::gpu::MTLStateManager::texture_unbind_all(), blender::gpu::MTLShader::unbind(), blender::gpu::MTLCommandBufferManager::unfold_pending_debug_groups(), blender::gpu::MTLStorageBuf::update(), blender::gpu::MTLUniformBuf::update(), blender::gpu::MTLIndexBuf::update_sub(), blender::gpu::MTLTexture::update_sub(), blender::gpu::MTLTexture::update_sub(), blender::gpu::MTLVertBuf::update_sub(), blender::gpu::MTLFence::wait(), blender::gpu::MTLShader::warm_cache(), blender::gpu::MTLTexture::xr_blit, ~MTLContext(), blender::gpu::MTLFrameBuffer::~MTLFrameBuffer(), blender::gpu::MTLStorageBuf::~MTLStorageBuf(), blender::gpu::MTLTexture::~MTLTexture(), blender::gpu::MTLTopLevelAS::~MTLTopLevelAS(), and blender::gpu::MTLUniformBuf::~MTLUniformBuf().

◆ get_active()

bool blender::gpu::MTLContext::get_active ( )
inline

Definition at line 850 of file mtl_context.hh.

References blender::gpu::Context::is_active_.

◆ get_active_shader()

MTLShader * blender::gpu::MTLContext::get_active_shader ( )

◆ get_compute_utils()

MTLContextComputeUtils & blender::gpu::MTLContext::get_compute_utils ( )
inline

Definition at line 845 of file mtl_context.hh.

Referenced by blender::gpu::MTLStorageBuf::clear(), and ~MTLContext().

◆ get_current_frame_index()

uint blender::gpu::MTLContext::get_current_frame_index ( )
inline

Definition at line 860 of file mtl_context.hh.

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

◆ get_current_framebuffer()

◆ get_default_framebuffer()

MTLFrameBuffer * blender::gpu::MTLContext::get_default_framebuffer ( )

Definition at line 541 of file mtl_context.mm.

References blender::gpu::Context::back_left.

Referenced by get_current_framebuffer().

◆ get_default_sampler_state()

id< MTLSamplerState > blender::gpu::MTLContext::get_default_sampler_state ( )

◆ get_dummy_texture()

◆ get_global_memory_manager()

◆ get_inside_frame()

◆ get_null_attribute_buffer()

id< MTLBuffer > blender::gpu::MTLContext::get_null_attribute_buffer ( )

Definition at line 575 of file mtl_context.mm.

References blender::BLI_assert(), blender::data, device, and options.

Referenced by ensure_render_pipeline_state().

◆ get_null_buffer()

id< MTLBuffer > blender::gpu::MTLContext::get_null_buffer ( )

Definition at line 551 of file mtl_context.mm.

References blender::BLI_assert(), device, blender::bke::subdiv::free(), and options.

◆ get_sampler_arg_buf_cache()

Map< MTLSamplerArray, gpu::MTLBuffer * > & blender::gpu::MTLContext::get_sampler_arg_buf_cache ( )
inline

Definition at line 906 of file mtl_context.hh.

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

◆ get_sampler_array()

MTLSamplerArray & blender::gpu::MTLContext::get_sampler_array ( )
inline

Definition at line 901 of file mtl_context.hh.

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

◆ get_sampler_from_state()

◆ get_scratch_buffer_manager()

MTLScratchBufferManager & blender::gpu::MTLContext::get_scratch_buffer_manager ( )
inline

◆ get_texture_utils()

MTLContextTextureUtils & blender::gpu::MTLContext::get_texture_utils ( )
inline

Definition at line 839 of file mtl_context.hh.

Referenced by MTLContext(), and ~MTLContext().

◆ get_visibility_buffer()

gpu::MTLBuffer * blender::gpu::MTLContext::get_visibility_buffer ( ) const

Definition at line 1692 of file mtl_context.mm.

◆ global_memory_manager_acquire_ref()

void blender::gpu::MTLContext::global_memory_manager_acquire_ref ( )
inlinestatic

◆ global_memory_manager_release_ref()

void blender::gpu::MTLContext::global_memory_manager_release_ref ( )
inlinestatic

◆ is_visibility_dirty()

bool blender::gpu::MTLContext::is_visibility_dirty ( ) const

Definition at line 1702 of file mtl_context.mm.

◆ latency_resolve_average()

void blender::gpu::MTLContext::latency_resolve_average ( int64_t frame_latency_us)
inlinestatic

Definition at line 912 of file mtl_context.hh.

References avg_drawable_latency_us, frame_latency, and MTL_FRAME_AVERAGE_COUNT.

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

◆ memory_statistics_get()

void blender::gpu::MTLContext::memory_statistics_get ( int * r_total_mem,
int * r_free_mem )
overridevirtual

Implements blender::gpu::Context.

Definition at line 458 of file mtl_context.mm.

◆ pipeline_state_init()

void blender::gpu::MTLContext::pipeline_state_init ( )

Default States.

Definition at line 974 of file mtl_context.mm.

References blender::gpu::MTLContextGlobalShaderPipelineState::alpha_blend_op, blender::gpu::MTLContextGlobalShaderPipelineState::blending_enabled, blender::gpu::MTLContextGlobalShaderPipelineState::color_write_mask, blender::gpu::MTLContextGlobalShaderPipelineState::cull_mode, blender::gpu::MTLContextGlobalShaderPipelineState::culling_enabled, blender::gpu::MTLContextDepthStencilState::depth_function, blender::gpu::MTLContextGlobalShaderPipelineState::depth_stencil_state, blender::gpu::MTLContextDepthStencilState::depth_test_enabled, blender::gpu::MTLContextDepthStencilState::depth_write_enable, blender::gpu::MTLContextGlobalShaderPipelineState::dest_alpha_blend_factor, blender::gpu::MTLContextGlobalShaderPipelineState::dest_rgb_blend_factor, blender::gpu::MTLContextGlobalShaderPipelineState::front_face, blender::GPU_COUNTERCLOCKWISE, blender::GPU_CULL_NONE, pipeline_state, blender::gpu::MTLContextGlobalShaderPipelineState::rgb_blend_op, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_enabled, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_height, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_width, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_x, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_y, blender::gpu::MTLContextGlobalShaderPipelineState::src_alpha_blend_factor, blender::gpu::MTLContextGlobalShaderPipelineState::src_rgb_blend_factor, blender::gpu::MTLContextDepthStencilState::stencil_func, blender::gpu::MTLContextDepthStencilState::stencil_op_back_depth_fail, blender::gpu::MTLContextDepthStencilState::stencil_op_back_depthstencil_pass, blender::gpu::MTLContextDepthStencilState::stencil_op_back_stencil_fail, blender::gpu::MTLContextDepthStencilState::stencil_op_front_depth_fail, blender::gpu::MTLContextDepthStencilState::stencil_op_front_depthstencil_pass, blender::gpu::MTLContextDepthStencilState::stencil_op_front_stencil_fail, blender::gpu::MTLContextDepthStencilState::stencil_read_mask, blender::gpu::MTLContextDepthStencilState::stencil_ref, blender::gpu::MTLContextDepthStencilState::stencil_test_enabled, blender::gpu::MTLContextDepthStencilState::stencil_write_mask, blender::v, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_height, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_offset_x, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_offset_y, and blender::gpu::MTLContextGlobalShaderPipelineState::viewport_width.

◆ sampler_bind()

◆ sampler_state_cache_init()

◆ set_scissor()

◆ set_scissor_enabled()

◆ set_viewport()

◆ set_viewports()

◆ set_visibility_buffer()

void blender::gpu::MTLContext::set_visibility_buffer ( gpu::MTLBuffer * buffer)

◆ specialization_constants_set()

void blender::gpu::MTLContext::specialization_constants_set ( const shader::SpecializationConstants * constants_state)

Definition at line 701 of file mtl_context.mm.

References constants_state.

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

◆ texture_bind()

◆ texture_unbind()

◆ texture_unbind_all()

◆ MTLBackend

friend class MTLBackend
friend

Definition at line 621 of file mtl_context.hh.

References MTLBackend.

Referenced by MTLBackend.

◆ MTLComputeState

friend class MTLComputeState
friend

Definition at line 623 of file mtl_context.hh.

References MTLComputeState.

Referenced by compute_dispatch(), compute_dispatch_indirect(), and MTLComputeState.

◆ MTLRenderPassState

friend class MTLRenderPassState
friend

Member Data Documentation

◆ avg_drawable_latency_us

std::atomic< int64_t > blender::gpu::MTLContext::avg_drawable_latency_us = 0
static

Definition at line 628 of file mtl_context.hh.

Referenced by latency_resolve_average(), and blender::gpu::present().

◆ constants_state

shader::SpecializationConstants blender::gpu::MTLContext::constants_state

Definition at line 784 of file mtl_context.hh.

Referenced by ensure_compute_pipeline_state(), and specialization_constants_set().

◆ device

◆ frame_latency

int64_t blender::gpu::MTLContext::frame_latency = {0}
static

Definition at line 629 of file mtl_context.hh.

Referenced by latency_resolve_average().

◆ global_memory_manager

MTLBufferPool * blender::gpu::MTLContext::global_memory_manager = nullptr
static

◆ global_memory_manager_refcount

int blender::gpu::MTLContext::global_memory_manager_refcount = 0
static

◆ global_memory_manager_reflock

std::mutex blender::gpu::MTLContext::global_memory_manager_reflock
static

◆ label

NSString* blender::gpu::MTLContext::label = nil

Definition at line 641 of file mtl_context.hh.

Referenced by debug_capture_scope_begin(), and debug_capture_scope_end().

◆ main_command_buffer

◆ max_drawables_in_flight

std::atomic< int > blender::gpu::MTLContext::max_drawables_in_flight = 0
static

Definition at line 627 of file mtl_context.hh.

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

◆ memory_manager

MTLScratchBufferManager blender::gpu::MTLContext::memory_manager

Definition at line 645 of file mtl_context.hh.

Referenced by MTLContext().

◆ pipeline_state

◆ queue

id<MTLCommandQueue> blender::gpu::MTLContext::queue = nil

Definition at line 636 of file mtl_context.hh.

Referenced by MTLContext(), blender::gpu::present(), and ~MTLContext().


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