Blender  V3.3
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
blender::gpu::MTLContext Class Reference

#include <mtl_context.hh>

Inheritance diagram for blender::gpu::MTLContext:
blender::gpu::Context

Public Member Functions

MTLShader * get_active_shader ()
 
MTLContextTextureUtilsget_texture_utils ()
 
bool get_active ()
 
bool get_inside_frame ()
 
uint get_current_frame_index ()
 
MTLScratchBufferManagerget_scratchbuffer_manager ()
 
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
 
Texture State Management
void texture_bind (gpu::MTLTexture *mtl_texture, uint texture_unit)
 
void sampler_bind (MTLSamplerState, uint sampler_unit)
 
void texture_unbind (gpu::MTLTexture *mtl_texture)
 
void texture_unbind_all ()
 
id< MTLSamplerStateget_sampler_from_state (MTLSamplerState state)
 
id< MTLSamplerStategenerate_sampler_from_state (MTLSamplerState state)
 
id< MTLSamplerStateget_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_scissor (int scissor_x, int scissor_y, int scissor_width, int scissor_height)
 
void set_scissor_enabled (bool scissor_enabled)
 
Visibility buffer control for MTLQueryPool.
void set_visibility_buffer (gpu::MTLBuffer *buffer)
 
gpu::MTLBufferget_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 ()
 

Static Public Member Functions

static MTLContextget ()
 
static MTLBufferPoolget_global_memory_manager ()
 
- Static Public Member Functions inherited from blender::gpu::Context
static Contextget ()
 

Public Attributes

MTLContextGlobalShaderPipelineState pipeline_state
 
id< MTLCommandQueue > queue = nil
 
id< MTLDevice > device = nil
 
MTLScratchBufferManager memory_manager
 
MTLCommandBufferManager main_command_buffer
 
- Public Attributes inherited from blender::gpu::Context
Shadershader = nullptr
 
FrameBufferactive_fb = nullptr
 
GPUMatrixStatematrix_state = nullptr
 
StateManagerstate_manager = nullptr
 
Immediateimm = nullptr
 
FrameBufferback_left = nullptr
 
FrameBufferfront_left = nullptr
 
FrameBufferback_right = nullptr
 
FrameBufferfront_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 ()
 
MTLFrameBufferget_current_framebuffer ()
 
MTLFrameBufferget_default_framebuffer ()
 
static void check_error (const char *info)
 

Additional Inherited Members

- Protected Attributes inherited from blender::gpu::Context
pthread_t thread_
 
bool is_active_
 
voidghost_window_
 

Detailed Description

MTLContext – Core render loop and state management.

Definition at line 570 of file mtl_context.hh.

Constructor & Destructor Documentation

◆ MTLContext()

blender::gpu::MTLContext::MTLContext ( void ghost_window)

◆ ~MTLContext()

blender::gpu::MTLContext::~MTLContext ( )

Member Function Documentation

◆ activate()

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

Implements blender::gpu::Context.

Definition at line 125 of file mtl_context.mm.

◆ begin_frame()

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

◆ check_error()

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

Definition at line 120 of file mtl_context.mm.

◆ clear_visibility_dirty()

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

◆ deactivate()

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

Implements blender::gpu::Context.

Definition at line 129 of file mtl_context.mm.

◆ debug_group_begin()

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

◆ debug_group_end()

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

◆ end_frame()

void blender::gpu::MTLContext::end_frame ( )
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().

◆ ensure_begin_render_pass()

id< MTLRenderCommandEncoder > blender::gpu::MTLContext::ensure_begin_render_pass ( )

◆ finish()

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

Implements blender::gpu::Context.

Definition at line 138 of file mtl_context.mm.

Referenced by ~MTLContext().

◆ flush()

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

Implements blender::gpu::Context.

Definition at line 134 of file mtl_context.mm.

Referenced by end_frame(), and ensure_begin_render_pass().

◆ framebuffer_bind()

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().

◆ framebuffer_restore()

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

◆ generate_sampler_from_state()

id< MTLSamplerState > blender::gpu::MTLContext::generate_sampler_from_state ( MTLSamplerState  state)

◆ get()

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

◆ get_active()

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

Definition at line 693 of file mtl_context.hh.

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

◆ get_active_shader()

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

◆ get_current_frame_index()

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

◆ get_current_framebuffer()

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().

◆ 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().

◆ get_default_sampler_state()

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

◆ get_global_memory_manager()

static MTLBufferPool& blender::gpu::MTLContext::get_global_memory_manager ( )
inlinestatic

◆ get_inside_frame()

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

◆ get_sampler_from_state()

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().

◆ get_scratchbuffer_manager()

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

Definition at line 708 of file mtl_context.hh.

References memory_manager.

Referenced by blender::gpu::MTLTexture::update_sub().

◆ get_texture_utils()

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

Definition at line 688 of file mtl_context.hh.

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

◆ get_visibility_buffer()

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

◆ is_visibility_dirty()

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

Definition at line 407 of file mtl_context.mm.

◆ memory_statistics_get()

void blender::gpu::MTLContext::memory_statistics_get ( int *  total_mem,
int *  free_mem 
)
overridevirtual

Implements blender::gpu::Context.

Definition at line 143 of file mtl_context.mm.

◆ pipeline_state_init()

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.

◆ sampler_bind()

void blender::gpu::MTLContext::sampler_bind ( MTLSamplerState  sampler_state,
uint  sampler_unit 
)

◆ set_scissor()

void blender::gpu::MTLContext::set_scissor ( int  scissor_x,
int  scissor_y,
int  scissor_width,
int  scissor_height 
)

◆ set_scissor_enabled()

void blender::gpu::MTLContext::set_scissor_enabled ( bool  scissor_enabled)

◆ set_viewport()

void blender::gpu::MTLContext::set_viewport ( int  origin_x,
int  origin_y,
int  width,
int  height 
)

◆ set_visibility_buffer()

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

◆ texture_bind()

void blender::gpu::MTLContext::texture_bind ( gpu::MTLTexture mtl_texture,
uint  texture_unit 
)

◆ texture_unbind()

void blender::gpu::MTLContext::texture_unbind ( gpu::MTLTexture mtl_texture)

◆ texture_unbind_all()

void blender::gpu::MTLContext::texture_unbind_all ( )

Friends And Related Function Documentation

◆ MTLBackend

friend class MTLBackend
friend

Definition at line 571 of file mtl_context.hh.

Member Data Documentation

◆ device

id<MTLDevice> blender::gpu::MTLContext::device = nil

◆ global_memory_manager

MTLBufferPool blender::gpu::MTLContext::global_memory_manager
static

Definition at line 608 of file mtl_context.hh.

Referenced by get_global_memory_manager(), and MTLContext().

◆ main_command_buffer

MTLCommandBufferManager blender::gpu::MTLContext::main_command_buffer

◆ memory_manager

MTLScratchBufferManager blender::gpu::MTLContext::memory_manager

◆ pipeline_state

MTLContextGlobalShaderPipelineState blender::gpu::MTLContext::pipeline_state

◆ queue

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

Definition at line 603 of file mtl_context.hh.


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