|
Blender V5.0
|
#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_scratchbuffer_manager () |
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) |
| bool | ensure_buffer_bindings (id< MTLRenderCommandEncoder > rec, const MTLShaderInterface *shader_interface, const MTLRenderPipelineStateInstance *pipeline_state_instance) |
| bool | ensure_buffer_bindings (id< MTLComputeCommandEncoder > rec, const MTLShaderInterface *shader_interface, const MTLComputePipelineStateInstance *pipeline_state_instance) |
| void | ensure_texture_bindings (id< MTLRenderCommandEncoder > rec, MTLShaderInterface *shader_interface, const MTLRenderPipelineStateInstance *pipeline_state_instance) |
| void | ensure_texture_bindings (id< MTLComputeCommandEncoder > rec, MTLShaderInterface *shader_interface, const MTLComputePipelineStateInstance *pipeline_state_instance) |
| void | ensure_depth_stencil_state (MTLPrimitiveType prim_type) |
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 () |
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 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 (void *ghost_window, void *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_ |
| void * | ghost_window_ |
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 696 of file mtl_context.hh.
| blender::gpu::MTLContext::MTLContext | ( | void * | ghost_window, |
| void * | ghost_context ) |
Fetch GHOSTContext and fetch Metal device/queue.
Definition at line 187 of file mtl_context.mm.
References blender::gpu::Context::active_fb, blender::gpu::Context::back_left, BLI_assert, blender::gpu::DEFAULT_SAMPLER_STATE, device, blender::gpu::Context::front_left, get_global_memory_manager(), get_texture_utils(), GHOST_Window::getContext(), blender::gpu::Context::ghost_window_, global_memory_manager_acquire_ref(), i, blender::gpu::Context::imm, blender::gpu::MTLBufferPool::init(), blender::gpu::MTLContextTextureUtils::init(), main_command_buffer, memory_manager, blender::gpu::debug::mtl_debug_init(), MTL_MAX_TEXTURE_SLOTS, pipeline_state, blender::gpu::present(), queue, sampler_state_cache_init(), and blender::gpu::Context::state_manager.
Referenced by get().
| blender::gpu::MTLContext::~MTLContext | ( | ) |
Definition at line 279 of file mtl_context.mm.
References BLI_assert, blender::gpu::MTLContextComputeUtils::cleanup(), blender::gpu::MTLContextTextureUtils::cleanup(), device, end_frame(), finish(), blender::gpu::MTLScratchBufferManager::free(), free_dummy_resources(), blender::gpu::Context::free_resources(), blender::gpu::MTLBackend::get(), get(), get_compute_utils(), get_inside_frame(), get_scratchbuffer_manager(), get_texture_utils(), global_memory_manager_release_ref(), GPU_SAMPLER_CUSTOM_TYPES_COUNT, GPU_SAMPLER_EXTEND_MODES_COUNT, GPU_SAMPLER_FILTERING_TYPES_COUNT, GPU_texture_free(), GPU_texture_unbind_all(), GPU_uniformbuf_unbind(), i, main_command_buffer, MTL_MAX_BUFFER_BINDINGS, pipeline_state, and queue.
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 417 of file mtl_context.mm.
References BLI_assert, blender::gpu::Context::ghost_window_, i, immActivate(), blender::gpu::Context::is_active_, MTL_MAX_BUFFER_BINDINGS, pipeline_state, and blender::gpu::Context::thread_.
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 388 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 412 of file mtl_context.mm.
| void blender::gpu::MTLContext::clear_visibility_dirty | ( | ) |
Definition at line 2354 of file mtl_context.mm.
| void blender::gpu::MTLContext::compute_dispatch | ( | int | groups_x_len, |
| int | groups_y_len, | ||
| int | groups_z_len ) |
Ensure resource bindings.
Definition at line 2213 of file mtl_context.mm.
References blender::gpu::MTLComputeState::bind_pso(), BLI_assert, ensure_buffer_bindings(), ensure_compute_pipeline_state(), ensure_texture_bindings(), blender::gpu::MTLShaderInterface::get_total_textures(), GPU_flush(), main_command_buffer, max_ii(), MTLComputeState, pipeline_state, blender::gpu::MTLComputePipelineStateInstance::pso, blender::gpu::MTLComputePipelineStateCommon::threadgroup_x_len, blender::gpu::MTLComputePipelineStateCommon::threadgroup_y_len, and blender::gpu::MTLComputePipelineStateCommon::threadgroup_z_len.
Referenced by blender::gpu::MTLBackend::compute_dispatch().
| void blender::gpu::MTLContext::compute_dispatch_indirect | ( | StorageBuf * | indirect_buf | ) |
Ensure resource bindings.
Definition at line 2266 of file mtl_context.mm.
References blender::gpu::MTLComputeState::bind_pso(), BLI_assert, ensure_buffer_bindings(), ensure_compute_pipeline_state(), ensure_texture_bindings(), blender::gpu::MTLStorageBuf::get_metal_buffer(), blender::gpu::MTLShaderInterface::get_total_textures(), GPU_flush(), main_command_buffer, MTL_LOG_WARNING, MTLComputeState, pipeline_state, blender::gpu::MTLComputePipelineStateInstance::pso, blender::gpu::MTLComputePipelineStateCommon::threadgroup_x_len, blender::gpu::MTLComputePipelineStateCommon::threadgroup_y_len, and blender::gpu::MTLComputePipelineStateCommon::threadgroup_z_len.
Referenced by blender::gpu::MTLBackend::compute_dispatch_indirect().
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 456 of file mtl_context.mm.
References BLI_assert, flush(), immDeactivate(), blender::gpu::Context::is_active_, and blender::gpu::Context::is_active_on_thread().
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 125 of file mtl_debug.mm.
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 142 of file mtl_debug.mm.
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 167 of file mtl_debug.mm.
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 152 of file mtl_debug.mm.
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 177 of file mtl_debug.mm.
|
overridevirtual |
Reimplemented from blender::gpu::Context.
Definition at line 50 of file mtl_debug.mm.
References G, G_DEBUG_GPU, main_command_buffer, and name.
|
overridevirtual |
Reimplemented from blender::gpu::Context.
Definition at line 68 of file mtl_debug.mm.
References CLOG_ERROR, G, G_DEBUG_GPU, i, blender::gpu::debug::LOG, and main_command_buffer.
|
inlineoverridevirtual |
Implements blender::gpu::Context.
Definition at line 828 of file mtl_context.hh.
|
inlineoverridevirtual |
Implements blender::gpu::Context.
Definition at line 827 of file mtl_context.hh.
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 399 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 496 of file mtl_context.mm.
References blender::gpu::Context::active_fb, begin_frame(), BLI_assert, flush(), framebuffer_restore(), get_inside_frame(), 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(), and blender::gpu::MTLBatch::bind().
| bool blender::gpu::MTLContext::ensure_buffer_bindings | ( | id< MTLComputeCommandEncoder > | rec, |
| const MTLShaderInterface * | shader_interface, | ||
| const MTLComputePipelineStateInstance * | pipeline_state_instance ) |
Definition at line 1380 of file mtl_context.mm.
References blender::gpu::MTLComputePipelineStateInstance::base_storage_buffer_index, blender::gpu::MTLComputePipelineStateInstance::base_uniform_buffer_index, blender::gpu::MTLComputeState::bind_compute_buffer(), blender::gpu::MTLComputeState::bind_compute_bytes(), BLI_assert, blender::gpu::MTLShaderBufferBlock::buffer_index, blender::gpu::COMPUTE, blender::gpu::MTLShaderInterface::get_name(), blender::gpu::MTLShaderInterface::get_name_at_offset(), get_null_buffer(), blender::gpu::MTLShaderInterface::get_push_constant_block(), blender::gpu::MTLShaderInterface::get_storage_block(), blender::gpu::MTLShaderInterface::get_total_storage_blocks(), blender::gpu::MTLShaderInterface::get_total_uniform_blocks(), blender::gpu::MTLShaderInterface::get_uniform_block(), length(), blender::gpu::MTLShaderBufferBlock::location, main_command_buffer, MTL_LOG_SSBO_ERROR, MTL_LOG_UBO_ERROR, MTL_MAX_BUFFER_BINDINGS, MTLComputeState, blender::gpu::MTLShaderBufferBlock::name_offset, pipeline_state, blender::gpu::MTLShaderBufferBlock::size, blender::gpu::MTLShaderBufferBlock::stage_mask, and UNUSED_VARS_NDEBUG.
| bool blender::gpu::MTLContext::ensure_buffer_bindings | ( | id< MTLRenderCommandEncoder > | rec, |
| const MTLShaderInterface * | shader_interface, | ||
| const MTLRenderPipelineStateInstance * | pipeline_state_instance ) |
Definition at line 1135 of file mtl_context.mm.
References blender::gpu::MTLRenderPipelineStateInstance::base_storage_buffer_index, blender::gpu::MTLRenderPipelineStateInstance::base_uniform_buffer_index, blender::gpu::MTLRenderPassState::bind_fragment_buffer(), blender::gpu::MTLRenderPassState::bind_fragment_bytes(), blender::gpu::MTLRenderPassState::bind_vertex_buffer(), blender::gpu::MTLRenderPassState::bind_vertex_bytes(), BLI_assert, BLI_assert_msg, blender::gpu::MTLRenderPipelineStateInstance::buffer_bindings_reflection_data_frag, blender::gpu::MTLRenderPipelineStateInstance::buffer_bindings_reflection_data_vert, blender::gpu::MTLShaderBufferBlock::buffer_index, blender::gpu::MTLRenderPassState::cached_fragment_buffer_bindings, blender::gpu::MTLRenderPassState::cached_vertex_buffer_bindings, blender::gpu::FRAGMENT, blender::gpu::MTLShaderInterface::get_name(), blender::gpu::MTLShaderInterface::get_name_at_offset(), get_null_buffer(), blender::gpu::MTLShaderInterface::get_push_constant_block(), blender::gpu::MTLShaderInterface::get_storage_block(), blender::gpu::MTLShaderInterface::get_total_storage_blocks(), blender::gpu::MTLShaderInterface::get_total_uniform_blocks(), blender::gpu::MTLShaderInterface::get_uniform_block(), blender::gpu::BufferBindingCached::is_bytes, blender::gpu::MTLRenderPassState::last_bound_shader_state, length(), blender::gpu::MTLShaderBufferBlock::location, main_command_buffer, MTL_LOG_SSBO_ERROR, MTL_LOG_UBO_ERROR, MTL_MAX_BUFFER_BINDINGS, MTLRenderPassState, blender::gpu::MTLShaderBufferBlock::name_offset, pipeline_state, blender::gpu::MTLBoundShaderState::pso_index_, blender::gpu::MTLRenderPipelineStateInstance::reflection_data_available, blender::gpu::MTLBoundShaderState::set(), blender::gpu::MTLBoundShaderState::shader_, blender::gpu::MTLRenderPipelineStateInstance::shader_pso_index, blender::gpu::MTLShaderBufferBlock::size, blender::gpu::MTLShaderBufferBlock::stage_mask, UNUSED_VARS_NDEBUG, and blender::gpu::VERTEX.
Referenced by compute_dispatch(), compute_dispatch_indirect(), and ensure_render_pipeline_state().
| const MTLComputePipelineStateInstance * blender::gpu::MTLContext::ensure_compute_pipeline_state | ( | ) |
Definition at line 2175 of file mtl_context.mm.
References blender::gpu::MTLShader::bake_compute_pipeline_state(), constants_state, MTL_LOG_WARNING, pipeline_state, and blender::gpu::MTLComputePipelineStateInstance::pso.
Referenced by compute_dispatch(), and compute_dispatch_indirect().
| void blender::gpu::MTLContext::ensure_depth_stencil_state | ( | MTLPrimitiveType | prim_type | ) |
Prepare Depth-stencil state based on current global pipeline state.
Definition at line 2037 of file mtl_context.mm.
References BLI_assert, blender::gpu::MTLRenderPassState::bound_ds_state, clamp(), device, fb(), get_current_framebuffer(), init(), blender::gpu::MTLRenderPassState::last_used_stencil_ref_value, main_command_buffer, blender::gpu::MTL_PIPELINE_STATE_DEPTHSTENCIL_FLAG, MTLRenderPassState, and 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 923 of file mtl_context.mm.
References blender::gpu::MTLRenderPassState::bind_vertex_buffer(), BLI_assert, BLI_assert_unreachable, blender::gpu::MTLRenderPassState::bound_pso, count, ensure_buffer_bindings(), ensure_texture_bindings(), G, G_DEBUG_GPU, blender::gpu::MTLFrameBuffer::get_default_height(), blender::gpu::MTLFrameBuffer::get_default_width(), blender::gpu::MTLFrameBuffer::get_height(), blender::gpu::MTLShaderInterface::get_name(), get_null_attribute_buffer(), blender::gpu::MTLShaderInterface::get_total_textures(), blender::gpu::MTLFrameBuffer::get_width(), GPU_CLOCKWISE, GPU_CULL_BACK, GPU_CULL_FRONT, GPU_CULL_NONE, GPU_MAX_VIEWPORTS, blender::gpu::MTLRenderPassState::last_scissor_rect, main_command_buffer, max_ii(), 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, blender::gpu::mtl_prim_type_to_topology_class(), MTLRenderPassState, blender::gpu::MTLRenderPipelineStateInstance::null_attribute_buffer_index, pipeline_state, blender::gpu::MTLRenderPipelineStateInstance::pso, result, blender::gpu::Context::state_manager, and v.
Referenced by blender::gpu::MTLBatch::bind().
| void blender::gpu::MTLContext::ensure_texture_bindings | ( | id< MTLComputeCommandEncoder > | rec, |
| MTLShaderInterface * | shader_interface, | ||
| const MTLComputePipelineStateInstance * | pipeline_state_instance ) |
Definition at line 1804 of file mtl_context.mm.
References blender::gpu::MTLBufferPool::allocate(), assert, blender::gpu::MTLComputePipelineStateInstance::base_uniform_buffer_index, blender::gpu::MTLStorageBuf::bind(), blender::gpu::MTLComputeState::bind_compute_buffer(), blender::gpu::MTLComputeState::bind_compute_sampler(), blender::gpu::MTLComputeState::bind_compute_texture(), BLI_assert, blender::gpu::MTLShaderTexture::buffer_metadata_uniform_loc, blender::gpu::COMPUTE, blender::gpu::MTLComputePipelineStateInstance::compute, blender::gpu::DEFAULT_SAMPLER_STATE, blender::gpu::MTLShaderInterface::find_argument_encoder(), blender::gpu::MTLBuffer::flush(), blender::gpu::MTLShaderInterface::get_argument_buffer_bind_index(), get_dummy_texture(), get_global_memory_manager(), blender::gpu::MTLShaderInterface::get_max_texture_index(), blender::gpu::MTLBuffer::get_metal_buffer(), blender::gpu::MTLShaderInterface::get_name(), blender::gpu::MTLTexture::get_name(), blender::gpu::MTLShaderInterface::get_name_at_offset(), blender::gpu::MTLTexture::get_storagebuf(), blender::gpu::MTLShaderInterface::get_texture(), blender::gpu::MTLTexture::get_texture_metadata_ptr(), GPU_max_textures(), GPU_TEXTURE_USAGE_ATOMIC, blender::gpu::MTLTexture::has_custom_swizzle(), i, blender::gpu::MTLShaderInterface::insert_argument_encoder(), blender::gpu::MTLShaderTexture::is_texture_sampler, blender::gpu::MTLShaderTexture::location, main_command_buffer, max_uu(), MTL_LOG_ERROR, MTL_MAX_TEXTURE_SLOTS, MTLComputeState, blender::gpu::MTLShaderTexture::name_offset, pipeline_state, blender::gpu::MTLShaderTexture::sampler_format, size(), blender::gpu::MTLShaderTexture::slot_index, blender::gpu::MTLShaderTexture::stage_mask, texture(), blender::gpu::MTLShaderTexture::texture_buffer_ssbo_location, blender::gpu::MTLShaderTexture::type, blender::gpu::Texture::type_, blender::gpu::MTLShader::uniform_int(), UNUSED_VARS_NDEBUG, blender::gpu::Texture::usage_get(), blender::gpu::MTLSamplerBinding::used, blender::gpu::MTLShaderTexture::used, and blender::gpu::MTLShaderInterface::uses_argument_buffer_for_samplers().
| void blender::gpu::MTLContext::ensure_texture_bindings | ( | id< MTLRenderCommandEncoder > | rec, |
| MTLShaderInterface * | shader_interface, | ||
| const MTLRenderPipelineStateInstance * | pipeline_state_instance ) |
Definition at line 1552 of file mtl_context.mm.
References blender::gpu::MTLBufferPool::allocate(), assert, blender::gpu::MTLRenderPipelineStateInstance::base_uniform_buffer_index, blender::gpu::MTLStorageBuf::bind(), blender::gpu::MTLRenderPassState::bind_fragment_buffer(), blender::gpu::MTLRenderPassState::bind_fragment_sampler(), blender::gpu::MTLRenderPassState::bind_fragment_texture(), blender::gpu::MTLRenderPassState::bind_vertex_buffer(), blender::gpu::MTLRenderPassState::bind_vertex_sampler(), blender::gpu::MTLRenderPassState::bind_vertex_texture(), BLI_assert, blender::gpu::MTLShaderTexture::buffer_metadata_uniform_loc, blender::gpu::DEFAULT_SAMPLER_STATE, blender::gpu::MTLShaderInterface::find_argument_encoder(), blender::gpu::MTLBuffer::flush(), blender::gpu::FRAGMENT, blender::gpu::MTLShaderInterface::get_argument_buffer_bind_index(), get_dummy_texture(), get_global_memory_manager(), blender::gpu::MTLShaderInterface::get_max_texture_index(), blender::gpu::MTLBuffer::get_metal_buffer(), blender::gpu::MTLShaderInterface::get_name(), blender::gpu::MTLTexture::get_name(), blender::gpu::MTLShaderInterface::get_name_at_offset(), blender::gpu::MTLTexture::get_storagebuf(), blender::gpu::MTLShaderInterface::get_texture(), blender::gpu::MTLTexture::get_texture_metadata_ptr(), GPU_max_textures(), GPU_TEXTURE_USAGE_ATOMIC, i, blender::gpu::MTLShaderInterface::insert_argument_encoder(), blender::gpu::MTLShaderTexture::is_texture_sampler, blender::gpu::MTLShaderTexture::location, main_command_buffer, max_uu(), MTL_LOG_ERROR, MTL_MAX_TEXTURE_SLOTS, MTLRenderPassState, blender::gpu::MTLShaderTexture::name_offset, pipeline_state, blender::gpu::MTLShaderTexture::sampler_format, size(), blender::gpu::MTLShaderTexture::slot_index, blender::gpu::MTLShaderTexture::stage_mask, texture(), blender::gpu::MTLShaderTexture::texture_buffer_ssbo_location, blender::gpu::MTLShaderTexture::type, blender::gpu::Texture::type_, blender::gpu::MTLShader::uniform_int(), UNUSED_VARS_NDEBUG, blender::gpu::Texture::usage_get(), blender::gpu::MTLSamplerBinding::used, blender::gpu::MTLShaderTexture::used, blender::gpu::MTLShaderInterface::uses_argument_buffer_for_samplers(), blender::gpu::MTLRenderPipelineStateInstance::vert, and blender::gpu::VERTEX.
Referenced by compute_dispatch(), compute_dispatch_indirect(), and ensure_render_pipeline_state().
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 470 of file mtl_context.mm.
References main_command_buffer.
Referenced by ~MTLContext().
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 465 of file mtl_context.mm.
References main_command_buffer.
Referenced by deactivate(), end_frame(), ensure_begin_render_pass(), and blender::gpu::present().
| void blender::gpu::MTLContext::framebuffer_bind | ( | MTLFrameBuffer * | framebuffer | ) |
Metal Context Core functions.
Definition at line 482 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 489 of file mtl_context.mm.
References blender::gpu::Context::active_fb, and blender::gpu::Context::back_left.
Referenced by ensure_begin_render_pass().
| void blender::gpu::MTLContext::free_dummy_resources | ( | ) |
Definition at line 702 of file mtl_context.mm.
References blender::gpu::GPU_SAMPLER_TYPE_MAX, blender::gpu::GPU_TEXTURE_BUFFER, GPU_texture_free(), and GPU_vertbuf_discard().
Referenced by ~MTLContext().
|
inlinestatic |
Definition at line 814 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::MTLUniformBuf::bind(), blender::gpu::MTLVertBuf::bind(), blender::gpu::MTLFrameBuffer::blit(), 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::MTLStorageBuf::copy_sub(), blender::gpu::MTLTexture::copy_to(), blender::gpu::MTLImmediate::end(), blender::gpu::MTLQueryPool::end_query(), 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::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::MTLStateManager::texture_unpack_row_length_set(), blender::gpu::MTLShader::unbind(), 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(), ~MTLContext(), blender::gpu::MTLFrameBuffer::~MTLFrameBuffer(), blender::gpu::MTLStorageBuf::~MTLStorageBuf(), blender::gpu::MTLTexture::~MTLTexture(), and blender::gpu::MTLUniformBuf::~MTLUniformBuf().
|
inline |
Definition at line 938 of file mtl_context.hh.
References blender::gpu::Context::is_active_.
| MTLShader * blender::gpu::MTLContext::get_active_shader | ( | ) |
Definition at line 563 of file mtl_context.mm.
References pipeline_state.
|
inline |
Definition at line 933 of file mtl_context.hh.
Referenced by blender::gpu::MTLStorageBuf::clear(), and ~MTLContext().
|
inline |
Definition at line 948 of file mtl_context.hh.
Referenced by blender::gpu::MTLCircularBuffer::MTLCircularBuffer().
| MTLFrameBuffer * blender::gpu::MTLContext::get_current_framebuffer | ( | ) |
Definition at line 552 of file mtl_context.mm.
References blender::gpu::Context::active_fb, and get_default_framebuffer().
Referenced by blender::gpu::MTLShader::bake_current_pipeline_state(), and ensure_depth_stencil_state().
| MTLFrameBuffer * blender::gpu::MTLContext::get_default_framebuffer | ( | ) |
Definition at line 558 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 2563 of file mtl_context.mm.
References GPUSamplerState::default_sampler(), and get_sampler_from_state().
| gpu::MTLTexture * blender::gpu::MTLContext::get_dummy_texture | ( | GPUTextureType | type, |
| GPUSamplerFormat | sampler_format ) |
Definition at line 612 of file mtl_context.mm.
References BLI_assert_msg, BLI_assert_unreachable, blender::gpu::GPU_SAMPLER_TYPE_DEPTH, blender::gpu::GPU_SAMPLER_TYPE_FLOAT, blender::gpu::GPU_SAMPLER_TYPE_INT, blender::gpu::GPU_SAMPLER_TYPE_UINT, blender::gpu::GPU_TEXTURE_1D, blender::gpu::GPU_TEXTURE_1D_ARRAY, blender::gpu::GPU_TEXTURE_2D, blender::gpu::GPU_TEXTURE_2D_ARRAY, blender::gpu::GPU_TEXTURE_3D, blender::gpu::GPU_TEXTURE_BUFFER, GPU_texture_create_1d(), GPU_texture_create_1d_array(), GPU_texture_create_2d(), GPU_texture_create_2d_array(), GPU_texture_create_3d(), GPU_texture_create_cube(), GPU_texture_create_cube_array(), GPU_texture_create_from_vertbuf(), blender::gpu::GPU_TEXTURE_CUBE, blender::gpu::GPU_TEXTURE_CUBE_ARRAY, GPU_TEXTURE_USAGE_GENERAL, GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY, GPU_USAGE_STATIC, GPU_vertbuf_create_with_format_ex(), GPU_vertbuf_data_alloc(), GPU_vertformat_attr_add(), and GPU_vertformat_clear().
Referenced by ensure_texture_bindings(), and ensure_texture_bindings().
|
inlinestatic |
Definition at line 983 of file mtl_context.hh.
References BLI_assert, and global_memory_manager.
Referenced by blender::gpu::MTLVertBuf::bind(), blender::gpu::MTLSafeFreeList::decrement_reference(), ensure_texture_bindings(), ensure_texture_bindings(), blender::gpu::MTLBuffer::free(), blender::gpu::MTLIndexBuf::get_index_buffer(), blender::gpu::MTLStorageBuf::init(), MTLContext(), blender::gpu::MTLStorageBuf::MTLStorageBuf(), blender::gpu::present(), blender::gpu::MTLStorageBuf::read(), blender::gpu::MTLVertBuf::read(), blender::gpu::MTLBackend::render_step(), blender::gpu::MTLCommandBufferManager::submit(), blender::gpu::MTLStorageBuf::update(), blender::gpu::MTLUniformBuf::update(), blender::gpu::MTLTexture::update_sub(), and blender::gpu::MTLIndexBuf::upload_data().
|
inline |
Definition at line 943 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< MTLBuffer > blender::gpu::MTLContext::get_null_attribute_buffer | ( | ) |
Definition at line 592 of file mtl_context.mm.
References BLI_assert, data, device, and options.
Referenced by ensure_render_pipeline_state().
| id< MTLBuffer > blender::gpu::MTLContext::get_null_buffer | ( | ) |
Definition at line 568 of file mtl_context.mm.
References BLI_assert, device, free(), and options.
Referenced by ensure_buffer_bindings(), and ensure_buffer_bindings().
| id< MTLSamplerState > blender::gpu::MTLContext::get_sampler_from_state | ( | MTLSamplerState | state | ) |
Definition at line 2453 of file mtl_context.mm.
References BLI_assert, GPUSamplerState::custom_type, GPUSamplerState::extend_x, GPUSamplerState::extend_yz, GPUSamplerState::filtering, GPU_SAMPLER_STATE_TYPE_CUSTOM, GPU_SAMPLER_STATE_TYPE_INTERNAL, blender::gpu::MTLSamplerState::state, and GPUSamplerState::type.
Referenced by get_default_sampler_state().
|
inline |
Definition at line 953 of file mtl_context.hh.
Referenced by blender::gpu::MTLIndexBuf::update_sub(), blender::gpu::MTLVertBuf::update_sub(), and ~MTLContext().
|
inline |
Definition at line 927 of file mtl_context.hh.
Referenced by MTLContext(), and ~MTLContext().
| gpu::MTLBuffer * blender::gpu::MTLContext::get_visibility_buffer | ( | ) | const |
Definition at line 2349 of file mtl_context.mm.
|
inlinestatic |
Definition at line 958 of file mtl_context.hh.
References BLI_assert, global_memory_manager, global_memory_manager_refcount, and global_memory_manager_reflock.
Referenced by MTLContext().
|
inlinestatic |
Definition at line 969 of file mtl_context.hh.
References BLI_assert, global_memory_manager, global_memory_manager_refcount, and global_memory_manager_reflock.
Referenced by ~MTLContext().
| bool blender::gpu::MTLContext::is_visibility_dirty | ( | ) | const |
Definition at line 2359 of file mtl_context.mm.
|
inlinestatic |
Definition at line 990 of file mtl_context.hh.
References avg_drawable_latency_us, frame_latency, i, and MTL_FRAME_AVERAGE_COUNT.
Referenced by blender::gpu::present().
|
overridevirtual |
Implements blender::gpu::Context.
Definition at line 475 of file mtl_context.mm.
| void blender::gpu::MTLContext::pipeline_state_init | ( | ) |
Definition at line 732 of file mtl_context.mm.
References GPU_COUNTERCLOCKWISE, GPU_CULL_NONE, GPU_max_textures(), GPU_MAX_VIEWPORTS, MTL_MAX_BUFFER_BINDINGS, MTL_MAX_SAMPLER_SLOTS, pipeline_state, and v.
| void blender::gpu::MTLContext::sampler_bind | ( | MTLSamplerState | sampler_state, |
| uint | sampler_unit ) |
Definition at line 2396 of file mtl_context.mm.
References BLI_assert, GPU_max_textures(), MTL_LOG_ERROR, MTL_MAX_SAMPLER_SLOTS, and pipeline_state.
Referenced by blender::gpu::MTLStateManager::texture_bind().
| void blender::gpu::MTLContext::sampler_state_cache_init | ( | ) |
Definition at line 2484 of file mtl_context.mm.
References BLI_assert, device, GPU_SAMPLER_CUSTOM_COMPARE, GPU_SAMPLER_CUSTOM_ICON, GPU_SAMPLER_EXTEND_MODES_COUNT, GPU_SAMPLER_FILTERING_LINEAR, GPU_SAMPLER_FILTERING_MIPMAP, GPU_SAMPLER_FILTERING_TYPES_COUNT, init(), max_ff(), state, blender::gpu::to_mtl_type(), and U.
Referenced by MTLContext().
| void blender::gpu::MTLContext::set_scissor | ( | int | scissor_x, |
| int | scissor_y, | ||
| int | scissor_width, | ||
| int | scissor_height ) |
Definition at line 876 of file mtl_context.mm.
References BLI_assert, blender::gpu::MTL_PIPELINE_STATE_SCISSOR_FLAG, and pipeline_state.
Referenced by blender::gpu::MTLFrameBuffer::apply_state().
| void blender::gpu::MTLContext::set_scissor_enabled | ( | bool | scissor_enabled | ) |
Definition at line 896 of file mtl_context.mm.
References blender::gpu::MTL_PIPELINE_STATE_SCISSOR_FLAG, and pipeline_state.
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 823 of file mtl_context.mm.
References BLI_assert, blender::gpu::MTL_PIPELINE_STATE_VIEWPORT_FLAG, and pipeline_state.
Referenced by blender::gpu::MTLFrameBuffer::apply_state().
| void blender::gpu::MTLContext::set_viewports | ( | int | count, |
| const int(&) | viewports[GPU_MAX_VIEWPORTS][4] ) |
Definition at line 847 of file mtl_context.mm.
References BLI_assert, count, GPU_MAX_VIEWPORTS, blender::gpu::MTL_PIPELINE_STATE_VIEWPORT_FLAG, pipeline_state, and v.
Referenced by blender::gpu::MTLFrameBuffer::apply_state().
| void blender::gpu::MTLContext::set_visibility_buffer | ( | gpu::MTLBuffer * | buffer | ) |
Definition at line 2331 of file mtl_context.mm.
References blender::gpu::MTLBuffer::debug_ensure_used().
Referenced by blender::gpu::MTLQueryPool::begin_query(), and blender::gpu::MTLQueryPool::get_occlusion_result().
| void blender::gpu::MTLContext::specialization_constants_set | ( | const shader::SpecializationConstants * | constants_state | ) |
Definition at line 718 of file mtl_context.mm.
References constants_state.
Referenced by blender::gpu::MTLShader::bind().
| void blender::gpu::MTLContext::texture_bind | ( | gpu::MTLTexture * | mtl_texture, |
| uint | texture_unit, | ||
| bool | is_image ) |
Definition at line 2370 of file mtl_context.mm.
References BLI_assert, blender::gpu::MTLTexture::get_name(), GPU_max_textures(), MTL_LOG_ERROR, MTL_MAX_TEXTURE_SLOTS, and pipeline_state.
Referenced by blender::gpu::MTLStateManager::image_bind(), and blender::gpu::MTLStateManager::texture_bind().
| void blender::gpu::MTLContext::texture_unbind | ( | gpu::MTLTexture * | mtl_texture, |
| bool | is_image, | ||
| StateManager * | state_manager ) |
Definition at line 2411 of file mtl_context.mm.
References BLI_assert, GPU_max_textures(), i, blender::gpu::Invalid, min_uu(), MTL_MAX_TEXTURE_SLOTS, pipeline_state, and blender::gpu::Context::state_manager.
Referenced by blender::gpu::MTLStateManager::image_unbind(), and blender::gpu::MTLStateManager::texture_unbind().
| void blender::gpu::MTLContext::texture_unbind_all | ( | bool | is_image | ) |
Definition at line 2437 of file mtl_context.mm.
References GPU_max_textures(), min_uu(), MTL_MAX_TEXTURE_SLOTS, and pipeline_state.
Referenced by blender::gpu::MTLStateManager::image_unbind_all(), and blender::gpu::MTLStateManager::texture_unbind_all().
|
friend |
|
friend |
Definition at line 699 of file mtl_context.hh.
References MTLComputeState.
Referenced by compute_dispatch(), compute_dispatch_indirect(), ensure_buffer_bindings(), ensure_texture_bindings(), and MTLComputeState.
|
friend |
Definition at line 698 of file mtl_context.hh.
References MTLRenderPassState.
Referenced by ensure_buffer_bindings(), ensure_depth_stencil_state(), ensure_render_pipeline_state(), ensure_texture_bindings(), and MTLRenderPassState.
|
static |
Definition at line 704 of file mtl_context.hh.
Referenced by latency_resolve_average(), and blender::gpu::present().
| shader::SpecializationConstants blender::gpu::MTLContext::constants_state |
Definition at line 860 of file mtl_context.hh.
Referenced by blender::gpu::MTLShader::bake_current_pipeline_state(), ensure_compute_pipeline_state(), and specialization_constants_set().
| id<MTLDevice> blender::gpu::MTLContext::device = nil |
Definition at line 713 of file mtl_context.hh.
Referenced by blender::gpu::MTLStorageBuf::async_flush_to_host(), blender::gpu::MTLShader::bake_compute_pipeline_state(), blender::gpu::MTLShader::bake_pipeline_state(), debug_capture_begin(), debug_capture_scope_create(), ensure_depth_stencil_state(), blender::gpu::MTLTexture::generate_mipmap(), blender::gpu::MTLContextComputeUtils::get_buffer_clear_pso(), blender::gpu::MTLPixelBuffer::get_native_handle(), get_null_attribute_buffer(), get_null_buffer(), blender::gpu::MTLQueryPool::get_occlusion_result(), blender::gpu::MTLStorageBuf::init(), blender::gpu::MTLTexture::init_internal(), blender::gpu::MTLPixelBuffer::map(), MTLContext(), sampler_state_cache_init(), blender::gpu::MTLFence::signal(), blender::gpu::MTLUniformBuf::update(), blender::gpu::MTLTexture::update_sub(), blender::gpu::MTLVertBuf::update_sub(), and ~MTLContext().
|
static |
Definition at line 705 of file mtl_context.hh.
Referenced by latency_resolve_average().
|
static |
Definition at line 724 of file mtl_context.hh.
Referenced by get_global_memory_manager(), global_memory_manager_acquire_ref(), and global_memory_manager_release_ref().
|
static |
Definition at line 723 of file mtl_context.hh.
Referenced by global_memory_manager_acquire_ref(), and global_memory_manager_release_ref().
|
static |
Definition at line 722 of file mtl_context.hh.
Referenced by global_memory_manager_acquire_ref(), and global_memory_manager_release_ref().
| NSString* blender::gpu::MTLContext::label = nil |
Definition at line 717 of file mtl_context.hh.
| MTLCommandBufferManager blender::gpu::MTLContext::main_command_buffer |
Definition at line 727 of file mtl_context.hh.
Referenced by blender::gpu::MTLStorageBuf::async_flush_to_host(), blender::gpu::MTLQueryPool::begin_query(), blender::gpu::MTLBatch::bind(), blender::gpu::MTLVertBuf::bind(), blender::gpu::MTLFrameBuffer::blit(), blender::gpu::MTLStorageBuf::clear(), blender::gpu::MTLTexture::clear(), compute_dispatch(), compute_dispatch_indirect(), blender::gpu::MTLStorageBuf::copy_sub(), blender::gpu::MTLTexture::copy_to(), debug_group_begin(), debug_group_end(), blender::gpu::MTLQueryPool::end_query(), ensure_begin_render_pass(), ensure_buffer_bindings(), ensure_buffer_bindings(), ensure_depth_stencil_state(), ensure_render_pipeline_state(), ensure_texture_bindings(), ensure_texture_bindings(), finish(), flush(), blender::gpu::MTLTexture::generate_mipmap(), blender::gpu::MTLQueryPool::get_occlusion_result(), blender::gpu::MTLStateManager::issue_barrier(), MTLContext(), blender::gpu::present(), blender::gpu::MTLIndexBuf::read(), blender::gpu::MTLStorageBuf::read(), blender::gpu::MTLVertBuf::read(), blender::gpu::MTLFence::signal(), blender::gpu::MTLStorageBuf::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(), and ~MTLContext().
|
static |
Definition at line 703 of file mtl_context.hh.
Referenced by blender::gpu::present().
| MTLScratchBufferManager blender::gpu::MTLContext::memory_manager |
Definition at line 721 of file mtl_context.hh.
Referenced by MTLContext().
| MTLContextGlobalShaderPipelineState blender::gpu::MTLContext::pipeline_state |
Definition at line 709 of file mtl_context.hh.
Referenced by activate(), blender::gpu::MTLShader::bake_current_pipeline_state(), blender::gpu::MTLShader::bake_pipeline_state(), blender::gpu::MTLShader::bind(), blender::gpu::MTLStorageBuf::bind(), blender::gpu::MTLUniformBuf::bind(), blender::gpu::MTLTexture::clear(), compute_dispatch(), compute_dispatch_indirect(), ensure_begin_render_pass(), ensure_buffer_bindings(), ensure_buffer_bindings(), ensure_compute_pipeline_state(), ensure_depth_stencil_state(), ensure_render_pipeline_state(), ensure_texture_bindings(), ensure_texture_bindings(), get_active_shader(), MTLContext(), pipeline_state_init(), sampler_bind(), set_scissor(), set_scissor_enabled(), set_viewport(), set_viewports(), texture_bind(), texture_unbind(), texture_unbind_all(), blender::gpu::MTLStateManager::texture_unpack_row_length_set(), blender::gpu::MTLShader::unbind(), blender::gpu::MTLTexture::update_sub(), ~MTLContext(), blender::gpu::MTLStorageBuf::~MTLStorageBuf(), and blender::gpu::MTLUniformBuf::~MTLUniformBuf().
| id<MTLCommandQueue> blender::gpu::MTLContext::queue = nil |
Definition at line 712 of file mtl_context.hh.
Referenced by MTLContext(), blender::gpu::present(), and ~MTLContext().