Blender
V3.3
|
#include <mtl_context.hh>
Static Public Member Functions | |
static MTLContext * | get () |
static MTLBufferPool & | get_global_memory_manager () |
![]() | |
static Context * | get () |
Public Attributes | |
MTLContextGlobalShaderPipelineState | pipeline_state |
id< MTLCommandQueue > | queue = nil |
id< MTLDevice > | device = nil |
MTLScratchBufferManager | memory_manager |
MTLCommandBufferManager | main_command_buffer |
![]() | |
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 |
Static Public Attributes | |
static MTLBufferPool | global_memory_manager |
Friends | |
class | MTLBackend |
MTLContext | |
MTLContext (void *ghost_window) | |
~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 *total_mem, int *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 () |
static void | check_error (const char *info) |
Additional Inherited Members | |
![]() | |
pthread_t | thread_ |
bool | is_active_ |
void * | ghost_window_ |
MTLContext – Core render loop and state management.
Definition at line 570 of file mtl_context.hh.
blender::gpu::MTLContext::MTLContext | ( | void * | ghost_window | ) |
Definition at line 27 of file mtl_context.mm.
References blender::gpu::Context::active_fb, blender::gpu::Context::back_left, blender::gpu::DEFAULT_SAMPLER_STATE, device, blender::gpu::Context::front_left, generate_sampler_from_state(), get_texture_utils(), global_memory_manager, GPU_SAMPLER_MAX, blender::gpu::MTLContextTextureUtils::init(), blender::gpu::MTLScratchBufferManager::init(), blender::gpu::MTLBufferPool::init(), main_command_buffer, memory_manager, blender::gpu::debug::mtl_debug_init(), MTL_MAX_TEXTURE_SLOTS, blender::gpu::MTLSamplerArray::mtl_sampler, blender::gpu::MTLSamplerArray::mtl_sampler_flags, blender::gpu::MTLCommandBufferManager::prepare(), state, and blender::gpu::Context::state_manager.
blender::gpu::MTLContext::~MTLContext | ( | ) |
Definition at line 74 of file mtl_context.mm.
References BLI_assert, blender::gpu::MTLContextTextureUtils::cleanup(), end_frame(), finish(), blender::gpu::MTLBackend::get(), get_inside_frame(), get_texture_utils(), GPU_context_active_get(), and GPU_SAMPLER_MAX.
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 125 of file mtl_context.mm.
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 98 of file mtl_context.mm.
References BLI_assert, blender::gpu::MTLBackend::get(), and get_inside_frame().
Referenced by ensure_begin_render_pass().
|
static |
Definition at line 120 of file mtl_context.mm.
void blender::gpu::MTLContext::clear_visibility_dirty | ( | ) |
Definition at line 402 of file mtl_context.mm.
Referenced by blender::gpu::MTLCommandBufferManager::ensure_begin_render_command_encoder().
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 129 of file mtl_context.mm.
|
overridevirtual |
Reimplemented from blender::gpu::Context.
Definition at line 46 of file mtl_debug.mm.
References G, G_DEBUG_GPU, main_command_buffer, and blender::gpu::MTLCommandBufferManager::push_debug_group().
|
overridevirtual |
Reimplemented from blender::gpu::Context.
Definition at line 53 of file mtl_debug.mm.
References G, G_DEBUG_GPU, main_command_buffer, and blender::gpu::MTLCommandBufferManager::pop_debug_group().
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 109 of file mtl_context.mm.
References BLI_assert, flush(), and get_inside_frame().
Referenced by ~MTLContext().
id< MTLRenderCommandEncoder > blender::gpu::MTLContext::ensure_begin_render_pass | ( | ) |
Definition at line 164 of file mtl_context.mm.
References blender::gpu::Context::active_fb, begin_frame(), BLI_assert, blender::gpu::MTLContextGlobalShaderPipelineState::dirty_flags, blender::gpu::MTLCommandBufferManager::do_break_submission(), blender::gpu::MTLCommandBufferManager::ensure_begin_render_command_encoder(), flush(), framebuffer_restore(), blender::gpu::MTLCommandBufferManager::get_active_framebuffer(), blender::gpu::MTLCommandBufferManager::get_active_render_command_encoder(), blender::gpu::MTLFrameBuffer::get_dirty(), get_inside_frame(), blender::gpu::MTLCommandBufferManager::is_inside_render_pass(), main_command_buffer, MTL_LOG_ERROR, MTL_LOG_WARNING, blender::gpu::MTL_PIPELINE_STATE_ALL_FLAG, and pipeline_state.
Referenced by blender::gpu::MTLQueryPool::begin_query().
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 138 of file mtl_context.mm.
Referenced by ~MTLContext().
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 134 of file mtl_context.mm.
Referenced by end_frame(), and ensure_begin_render_pass().
void blender::gpu::MTLContext::framebuffer_bind | ( | MTLFrameBuffer * | framebuffer | ) |
Metal Context Core functions.
Definition at line 150 of file mtl_context.mm.
References blender::gpu::Context::active_fb, and BLI_assert.
Referenced by blender::gpu::MTLFrameBuffer::bind().
void blender::gpu::MTLContext::framebuffer_restore | ( | ) |
Definition at line 157 of file mtl_context.mm.
References blender::gpu::Context::active_fb, and blender::gpu::Context::back_left.
Referenced by ensure_begin_render_pass().
id< MTLSamplerState > blender::gpu::MTLContext::generate_sampler_from_state | ( | MTLSamplerState | state | ) |
Definition at line 487 of file mtl_context.mm.
References BLI_assert, device, GPU_SAMPLER_CLAMP_BORDER, GPU_SAMPLER_COMPARE, GPU_SAMPLER_FILTER, GPU_SAMPLER_MIPMAP, GPU_SAMPLER_REPEAT_R, GPU_SAMPLER_REPEAT_S, GPU_SAMPLER_REPEAT_T, init, max_ff(), usdtokens::st(), state, and blender::gpu::MTLSamplerState::state.
Referenced by MTLContext().
|
inlinestatic |
Definition at line 629 of file mtl_context.hh.
References blender::gpu::Context::get().
Referenced by blender::gpu::MTLUniformBuf::bind(), and blender::gpu::MTLUniformBuf::~MTLUniformBuf().
|
inline |
Definition at line 693 of file mtl_context.hh.
References blender::gpu::Context::is_active_.
MTLShader* blender::gpu::MTLContext::get_active_shader | ( | ) |
|
inline |
Definition at line 703 of file mtl_context.hh.
Referenced by blender::gpu::MTLScratchBufferManager::ensure_increment_scratch_buffer(), blender::gpu::MTLCircularBuffer::MTLCircularBuffer(), and blender::gpu::MTLCircularBuffer::reset().
MTLFrameBuffer * blender::gpu::MTLContext::get_current_framebuffer | ( | ) |
Definition at line 219 of file mtl_context.mm.
References blender::gpu::Context::active_fb, and get_default_framebuffer().
MTLFrameBuffer * blender::gpu::MTLContext::get_default_framebuffer | ( | ) |
Definition at line 225 of file mtl_context.mm.
References blender::gpu::Context::back_left.
Referenced by get_current_framebuffer().
id< MTLSamplerState > blender::gpu::MTLContext::get_default_sampler_state | ( | ) |
Definition at line 538 of file mtl_context.mm.
References blender::gpu::DEFAULT_SAMPLER_STATE, and get_sampler_from_state().
|
inlinestatic |
Definition at line 713 of file mtl_context.hh.
References global_memory_manager.
Referenced by blender::gpu::MTLSafeFreeList::decrement_reference(), blender::gpu::MTLBuffer::free(), blender::gpu::MTLBackend::render_step(), blender::gpu::MTLCommandBufferManager::submit(), and blender::gpu::MTLUniformBuf::update().
|
inline |
Definition at line 698 of file mtl_context.hh.
Referenced by blender::gpu::MTLFrameBuffer::bake_render_pass_descriptor(), begin_frame(), end_frame(), ensure_begin_render_pass(), blender::gpu::MTLQueryPool::get_occlusion_result(), and ~MTLContext().
id< MTLSamplerState > blender::gpu::MTLContext::get_sampler_from_state | ( | MTLSamplerState | state | ) |
Definition at line 481 of file mtl_context.mm.
References BLI_assert, and GPU_SAMPLER_MAX.
Referenced by get_default_sampler_state().
|
inline |
Definition at line 708 of file mtl_context.hh.
References memory_manager.
Referenced by blender::gpu::MTLTexture::update_sub().
|
inline |
Definition at line 688 of file mtl_context.hh.
Referenced by MTLContext(), and ~MTLContext().
gpu::MTLBuffer * blender::gpu::MTLContext::get_visibility_buffer | ( | ) | const |
Definition at line 397 of file mtl_context.mm.
Referenced by blender::gpu::MTLCommandBufferManager::ensure_begin_render_command_encoder().
bool blender::gpu::MTLContext::is_visibility_dirty | ( | ) | const |
Definition at line 407 of file mtl_context.mm.
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 143 of file mtl_context.mm.
void blender::gpu::MTLContext::pipeline_state_init | ( | ) |
Definition at line 237 of file mtl_context.mm.
References blender::gpu::MTLContextGlobalShaderPipelineState::active_shader, blender::gpu::MTLContextGlobalShaderPipelineState::alpha_blend_op, blender::gpu::MTLContextGlobalShaderPipelineState::blending_enabled, blender::gpu::MTLUniformBufferBinding::bound, blender::gpu::MTLContextGlobalShaderPipelineState::color_write_mask, blender::gpu::MTLContextGlobalShaderPipelineState::cull_mode, blender::gpu::MTLContextGlobalShaderPipelineState::culling_enabled, blender::gpu::MTLContextDepthStencilState::depth_bias, blender::gpu::MTLContextDepthStencilState::depth_bias_enabled_for_lines, blender::gpu::MTLContextDepthStencilState::depth_bias_enabled_for_points, blender::gpu::MTLContextDepthStencilState::depth_bias_enabled_for_tris, blender::gpu::MTLContextDepthStencilState::depth_function, blender::gpu::MTLContextDepthStencilState::depth_range_far, blender::gpu::MTLContextDepthStencilState::depth_range_near, blender::gpu::MTLContextDepthStencilState::depth_slope_scale, 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, GPU_COUNTERCLOCKWISE, GPU_CULL_NONE, GPU_max_textures(), blender::gpu::MTLContextGlobalShaderPipelineState::initialised, MTL_MAX_SAMPLER_SLOTS, MTL_MAX_UNIFORM_BUFFER_BINDINGS, NULL, pipeline_state, blender::gpu::MTLContextGlobalShaderPipelineState::rgb_blend_op, blender::gpu::MTLContextGlobalShaderPipelineState::sampler_bindings, 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, t, blender::gpu::MTLContextGlobalShaderPipelineState::texture_bindings, blender::gpu::MTLTextureBinding::texture_resource, blender::gpu::MTLTextureBinding::texture_slot_index, blender::gpu::MTLUniformBufferBinding::ubo, blender::gpu::MTLContextGlobalShaderPipelineState::ubo_bindings, blender::gpu::MTLContextGlobalShaderPipelineState::unpack_row_length, blender::gpu::MTLTextureBinding::used, blender::gpu::MTLSamplerBinding::used, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_height, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_offset_x, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_offset_y, and blender::gpu::MTLContextGlobalShaderPipelineState::viewport_width.
void blender::gpu::MTLContext::sampler_bind | ( | MTLSamplerState | sampler_state, |
uint | sampler_unit | ||
) |
Definition at line 438 of file mtl_context.mm.
References BLI_assert, GPU_max_textures(), MTL_LOG_WARNING, MTL_MAX_SAMPLER_SLOTS, pipeline_state, and blender::gpu::MTLContextGlobalShaderPipelineState::sampler_bindings.
Referenced by blender::gpu::MTLStateManager::texture_bind().
void blender::gpu::MTLContext::set_scissor | ( | int | scissor_x, |
int | scissor_y, | ||
int | scissor_width, | ||
int | scissor_height | ||
) |
Definition at line 339 of file mtl_context.mm.
References BLI_assert, blender::gpu::MTLContextGlobalShaderPipelineState::dirty_flags, blender::gpu::MTL_PIPELINE_STATE_SCISSOR_FLAG, pipeline_state, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_enabled, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_height, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_width, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_x, and blender::gpu::MTLContextGlobalShaderPipelineState::scissor_y.
Referenced by blender::gpu::MTLFrameBuffer::apply_state().
Definition at line 359 of file mtl_context.mm.
References blender::gpu::MTLContextGlobalShaderPipelineState::dirty_flags, blender::gpu::MTL_PIPELINE_STATE_SCISSOR_FLAG, pipeline_state, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_enabled, blender::gpu::MTLContextGlobalShaderPipelineState::scissor_height, and blender::gpu::MTLContextGlobalShaderPipelineState::scissor_width.
Referenced by blender::gpu::MTLFrameBuffer::apply_state().
void blender::gpu::MTLContext::set_viewport | ( | int | origin_x, |
int | origin_y, | ||
int | width, | ||
int | height | ||
) |
Definition at line 318 of file mtl_context.mm.
References BLI_assert, blender::gpu::MTLContextGlobalShaderPipelineState::dirty_flags, height, blender::gpu::MTL_PIPELINE_STATE_VIEWPORT_FLAG, pipeline_state, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_height, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_offset_x, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_offset_y, blender::gpu::MTLContextGlobalShaderPipelineState::viewport_width, and width.
Referenced by blender::gpu::MTLFrameBuffer::apply_state().
void blender::gpu::MTLContext::set_visibility_buffer | ( | gpu::MTLBuffer * | buffer | ) |
Definition at line 379 of file mtl_context.mm.
References buffer, and blender::gpu::MTLBuffer::debug_ensure_used().
Referenced by blender::gpu::MTLQueryPool::begin_query(), and blender::gpu::MTLQueryPool::get_occlusion_result().
void blender::gpu::MTLContext::texture_bind | ( | gpu::MTLTexture * | mtl_texture, |
uint | texture_unit | ||
) |
Definition at line 418 of file mtl_context.mm.
References BLI_assert, blender::gpu::MTLTexture::get_name(), GPU_max_textures(), MTL_LOG_WARNING, MTL_MAX_TEXTURE_SLOTS, pipeline_state, blender::gpu::MTLContextGlobalShaderPipelineState::texture_bindings, blender::gpu::MTLTextureBinding::texture_resource, and blender::gpu::MTLTextureBinding::used.
Referenced by blender::gpu::MTLStateManager::texture_bind().
void blender::gpu::MTLContext::texture_unbind | ( | gpu::MTLTexture * | mtl_texture | ) |
Definition at line 452 of file mtl_context.mm.
References BLI_assert, GPU_max_textures(), min_uu(), MTL_MAX_TEXTURE_SLOTS, pipeline_state, blender::gpu::MTLContextGlobalShaderPipelineState::texture_bindings, blender::gpu::MTLTextureBinding::texture_resource, and blender::gpu::MTLTextureBinding::used.
Referenced by blender::gpu::MTLStateManager::texture_unbind().
void blender::gpu::MTLContext::texture_unbind_all | ( | ) |
Definition at line 468 of file mtl_context.mm.
References GPU_max_textures(), min_uu(), MTL_MAX_TEXTURE_SLOTS, pipeline_state, t, blender::gpu::MTLContextGlobalShaderPipelineState::texture_bindings, blender::gpu::MTLTextureBinding::texture_resource, and blender::gpu::MTLTextureBinding::used.
Referenced by blender::gpu::MTLStateManager::texture_unbind_all().
|
friend |
Definition at line 571 of file mtl_context.hh.
id<MTLDevice> blender::gpu::MTLContext::device = nil |
Definition at line 604 of file mtl_context.hh.
Referenced by blender::gpu::MTLCircularBuffer::allocate_range_aligned(), blender::gpu::MTLFrameBuffer::bake_render_pass_descriptor(), blender::gpu::MTLTexture::generate_mipmap(), generate_sampler_from_state(), blender::gpu::MTLQueryPool::get_occlusion_result(), blender::gpu::MTLScratchBufferManager::init(), blender::gpu::MTLStateManager::issue_barrier(), blender::gpu::MTLCircularBuffer::MTLCircularBuffer(), MTLContext(), blender::gpu::MTLCommandBufferManager::submit(), and blender::gpu::MTLUniformBuf::update().
|
static |
Definition at line 608 of file mtl_context.hh.
Referenced by get_global_memory_manager(), and MTLContext().
MTLCommandBufferManager blender::gpu::MTLContext::main_command_buffer |
Definition at line 611 of file mtl_context.hh.
Referenced by blender::gpu::MTLQueryPool::begin_query(), blender::gpu::MTLFrameBuffer::blit(), blender::gpu::MTLTexture::copy_to(), debug_group_begin(), debug_group_end(), blender::gpu::MTLQueryPool::end_query(), ensure_begin_render_pass(), blender::gpu::MTLTexture::generate_mipmap(), blender::gpu::MTLQueryPool::get_occlusion_result(), blender::gpu::MTLStateManager::issue_barrier(), MTLContext(), blender::gpu::MTLTexture::update_sub(), and blender::gpu::MTLFrameBuffer::~MTLFrameBuffer().
MTLScratchBufferManager blender::gpu::MTLContext::memory_manager |
Definition at line 607 of file mtl_context.hh.
Referenced by get_scratchbuffer_manager(), MTLContext(), and blender::gpu::MTLCommandBufferManager::submit().
MTLContextGlobalShaderPipelineState blender::gpu::MTLContext::pipeline_state |
Definition at line 600 of file mtl_context.hh.
Referenced by blender::gpu::MTLUniformBuf::bind(), ensure_begin_render_pass(), pipeline_state_init(), sampler_bind(), set_scissor(), set_scissor_enabled(), set_viewport(), texture_bind(), texture_unbind(), texture_unbind_all(), blender::gpu::MTLStateManager::texture_unpack_row_length_set(), blender::gpu::MTLUniformBuf::unbind(), blender::gpu::MTLTexture::update_sub(), and blender::gpu::MTLUniformBuf::~MTLUniformBuf().
id<MTLCommandQueue> blender::gpu::MTLContext::queue = nil |
Definition at line 603 of file mtl_context.hh.