Crate objc2_metal
source ·Expand description
§Bindings to the Metal framework
See Apple’s docs and the general docs on framework crates for more information.
Metal has tools for validating that you’re using it correctly, using these
is highly recommended! See Apple’s documentation on it, or
run man MetalValidation to get information on environment variables.
Note: To use MTLCreateSystemDefaultDevice you need to link to
CoreGraphics, this can be done by using objc2-app-kit, or by doing:
#[link(name = "CoreGraphics", kind = "framework")]
extern "C" {}§Example
Drawing a rotating triangle.
ⓘ
#![deny(unsafe_op_in_unsafe_fn)]
#![allow(clippy::incompatible_msrv)]
use core::{cell::OnceCell, ptr::NonNull};
use objc2::{
declare_class, msg_send_id, mutability::MainThreadOnly, rc::Retained, runtime::ProtocolObject,
ClassType, DeclaredClass,
};
use objc2_app_kit::{
NSApplication, NSApplicationActivationPolicy, NSApplicationDelegate, NSBackingStoreType,
NSWindow, NSWindowStyleMask,
};
use objc2_foundation::{
ns_string, MainThreadMarker, NSDate, NSNotification, NSObject, NSObjectProtocol, NSPoint,
NSRect, NSSize,
};
use objc2_metal::{
MTLCommandBuffer, MTLCommandEncoder, MTLCommandQueue, MTLCreateSystemDefaultDevice, MTLDevice,
MTLLibrary, MTLPackedFloat3, MTLPrimitiveType, MTLRenderCommandEncoder,
MTLRenderPipelineDescriptor, MTLRenderPipelineState,
};
use objc2_metal_kit::{MTKView, MTKViewDelegate};
#[derive(Copy, Clone)]
#[repr(C)]
struct SceneProperties {
time: f32,
}
#[derive(Copy, Clone)]
#[repr(C)]
struct VertexInput {
position: MTLPackedFloat3,
color: MTLPackedFloat3,
}
macro_rules! idcell {
($name:ident => $this:expr) => {
$this.ivars().$name.set($name).expect(&format!(
"ivar should not already be initialized: `{}`",
stringify!($name)
));
};
($name:ident <= $this:expr) => {
#[rustfmt::skip]
let Some($name) = $this.ivars().$name.get() else {
unreachable!(
"ivar should be initialized: `{}`",
stringify!($name)
)
};
};
}
// declare the desired instance variables
struct Ivars {
start_date: Retained<NSDate>,
command_queue: OnceCell<Retained<ProtocolObject<dyn MTLCommandQueue>>>,
pipeline_state: OnceCell<Retained<ProtocolObject<dyn MTLRenderPipelineState>>>,
window: OnceCell<Retained<NSWindow>>,
}
// declare the Objective-C class machinery
declare_class!(
struct Delegate;
// SAFETY:
// - The superclass NSObject does not have any subclassing requirements.
// - Main thread only mutability is correct, since this is an application delegate.
// - `Delegate` does not implement `Drop`.
unsafe impl ClassType for Delegate {
type Super = NSObject;
type Mutability = MainThreadOnly;
const NAME: &'static str = "Delegate";
}
impl DeclaredClass for Delegate {
type Ivars = Ivars;
}
unsafe impl NSObjectProtocol for Delegate {}
// define the delegate methods for the `NSApplicationDelegate` protocol
unsafe impl NSApplicationDelegate for Delegate {
#[method(applicationDidFinishLaunching:)]
#[allow(non_snake_case)]
unsafe fn applicationDidFinishLaunching(&self, _notification: &NSNotification) {
let mtm = MainThreadMarker::from(self);
// create the app window
let window = {
let content_rect = NSRect::new(NSPoint::new(0., 0.), NSSize::new(768., 768.));
let style = NSWindowStyleMask::Closable
| NSWindowStyleMask::Resizable
| NSWindowStyleMask::Titled;
let backing_store_type = NSBackingStoreType::NSBackingStoreBuffered;
let flag = false;
unsafe {
NSWindow::initWithContentRect_styleMask_backing_defer(
mtm.alloc(),
content_rect,
style,
backing_store_type,
flag,
)
}
};
// get the default device
let device = {
let ptr = unsafe { MTLCreateSystemDefaultDevice() };
unsafe { Retained::retain(ptr) }.expect("Failed to get default system device.")
};
// create the command queue
let command_queue = device
.newCommandQueue()
.expect("Failed to create a command queue.");
// create the metal view
let mtk_view = {
let frame_rect = window.frame();
unsafe { MTKView::initWithFrame_device(mtm.alloc(), frame_rect, Some(&device)) }
};
// create the pipeline descriptor
let pipeline_descriptor = MTLRenderPipelineDescriptor::new();
unsafe {
pipeline_descriptor
.colorAttachments()
.objectAtIndexedSubscript(0)
.setPixelFormat(mtk_view.colorPixelFormat());
}
// compile the shaders
let library = device
.newLibraryWithSource_options_error(
ns_string!(include_str!("triangle.metal")),
None,
)
.expect("Failed to create a library.");
// configure the vertex shader
let vertex_function = library.newFunctionWithName(ns_string!("vertex_main"));
pipeline_descriptor.setVertexFunction(vertex_function.as_deref());
// configure the fragment shader
let fragment_function = library.newFunctionWithName(ns_string!("fragment_main"));
pipeline_descriptor.setFragmentFunction(fragment_function.as_deref());
// create the pipeline state
let pipeline_state = device
.newRenderPipelineStateWithDescriptor_error(&pipeline_descriptor)
.expect("Failed to create a pipeline state.");
// configure the metal view delegate
unsafe {
let object = ProtocolObject::from_ref(self);
mtk_view.setDelegate(Some(object));
}
// configure the window
window.setContentView(Some(&mtk_view));
window.center();
window.setTitle(ns_string!("metal example"));
window.makeKeyAndOrderFront(None);
// initialize the delegate state
idcell!(command_queue => self);
idcell!(pipeline_state => self);
idcell!(window => self);
}
}
// define the delegate methods for the `MTKViewDelegate` protocol
unsafe impl MTKViewDelegate for Delegate {
#[method(drawInMTKView:)]
#[allow(non_snake_case)]
unsafe fn drawInMTKView(&self, mtk_view: &MTKView) {
idcell!(command_queue <= self);
idcell!(pipeline_state <= self);
// prepare for drawing
let Some(current_drawable) = (unsafe { mtk_view.currentDrawable() }) else {
return;
};
let Some(command_buffer) = command_queue.commandBuffer() else {
return;
};
let Some(pass_descriptor) = (unsafe { mtk_view.currentRenderPassDescriptor() }) else {
return;
};
let Some(encoder) = command_buffer.renderCommandEncoderWithDescriptor(&pass_descriptor)
else {
return;
};
// compute the scene properties
let scene_properties_data = &SceneProperties {
time: unsafe { self.ivars().start_date.timeIntervalSinceNow() } as f32,
};
// write the scene properties to the vertex shader argument buffer at index 0
let scene_properties_bytes = NonNull::from(scene_properties_data);
unsafe {
encoder.setVertexBytes_length_atIndex(
scene_properties_bytes.cast::<core::ffi::c_void>(),
core::mem::size_of_val(scene_properties_data),
0,
)
};
// compute the triangle geometry
let vertex_input_data: &[VertexInput] = &[
VertexInput {
position: MTLPackedFloat3 {
x: -f32::sqrt(3.0) / 4.0,
y: -0.25,
z: 0.,
},
color: MTLPackedFloat3 {
x: 1.,
y: 0.,
z: 0.,
},
},
VertexInput {
position: MTLPackedFloat3 {
x: f32::sqrt(3.0) / 4.0,
y: -0.25,
z: 0.,
},
color: MTLPackedFloat3 {
x: 0.,
y: 1.,
z: 0.,
},
},
VertexInput {
position: MTLPackedFloat3 {
x: 0.,
y: 0.5,
z: 0.,
},
color: MTLPackedFloat3 {
x: 0.,
y: 0.,
z: 1.,
},
},
];
// write the triangle geometry to the vertex shader argument buffer at index 1
let vertex_input_bytes = NonNull::from(vertex_input_data);
unsafe {
encoder.setVertexBytes_length_atIndex(
vertex_input_bytes.cast::<core::ffi::c_void>(),
core::mem::size_of_val(vertex_input_data),
1,
)
};
// configure the encoder with the pipeline and draw the triangle
encoder.setRenderPipelineState(pipeline_state);
unsafe {
encoder.drawPrimitives_vertexStart_vertexCount(MTLPrimitiveType::Triangle, 0, 3)
};
encoder.endEncoding();
// schedule the command buffer for display and commit
command_buffer.presentDrawable(ProtocolObject::from_ref(&*current_drawable));
command_buffer.commit();
}
#[method(mtkView:drawableSizeWillChange:)]
#[allow(non_snake_case)]
unsafe fn mtkView_drawableSizeWillChange(&self, _view: &MTKView, _size: NSSize) {
// println!("mtkView_drawableSizeWillChange");
}
}
);
impl Delegate {
fn new(mtm: MainThreadMarker) -> Retained<Self> {
let this = mtm.alloc();
let this = this.set_ivars(Ivars {
start_date: unsafe { NSDate::now() },
command_queue: OnceCell::default(),
pipeline_state: OnceCell::default(),
window: OnceCell::default(),
});
unsafe { msg_send_id![super(this), init] }
}
}
fn main() {
let mtm = MainThreadMarker::new().unwrap();
// configure the app
let app = NSApplication::sharedApplication(mtm);
app.setActivationPolicy(NSApplicationActivationPolicy::Regular);
// configure the application delegate
let delegate = Delegate::new(mtm);
let object = ProtocolObject::from_ref(&*delegate);
app.setDelegate(Some(object));
// run the app
unsafe { app.run() };
}With the following shader.
ⓘ
#include <metal_stdlib>
struct SceneProperties {
float time;
};
struct VertexInput {
metal::packed_float3 position;
metal::packed_float3 color;
};
struct VertexOutput {
metal::float4 position [[position]];
metal::float4 color;
};
vertex VertexOutput vertex_main(
device const SceneProperties& properties [[buffer(0)]],
device const VertexInput* vertices [[buffer(1)]],
uint vertex_idx [[vertex_id]]
) {
VertexOutput out;
VertexInput in = vertices[vertex_idx];
out.position =
metal::float4(
metal::float2x2(
metal::cos(properties.time), -metal::sin(properties.time),
metal::sin(properties.time), metal::cos(properties.time)
) * in.position.xy,
in.position.z,
1);
out.color = metal::float4(in.color, 1);
return out;
}
fragment metal::float4 fragment_main(VertexOutput in [[stage_in]]) {
return in.color;
}Structs§
- MTLAccelerationStructureBoundingBoxGeometryDescriptor
MTLAccelerationStructure - MTLAccelerationStructureCurveGeometryDescriptor
MTLAccelerationStructure - MTLAccelerationStructureDescriptor
MTLAccelerationStructure - MTLAccelerationStructureGeometryDescriptor
MTLAccelerationStructure - MTLAccelerationStructureInstanceDescriptor
MTLAccelerationStructureandMTLAccelerationStructureTypes - MTLAccelerationStructureInstanceDescriptorType
MTLAccelerationStructure - MTLAccelerationStructureInstanceOptions
MTLAccelerationStructure - MTLAccelerationStructureMotionBoundingBoxGeometryDescriptor
MTLAccelerationStructure - MTLAccelerationStructureMotionCurveGeometryDescriptor
MTLAccelerationStructure - MTLAccelerationStructureMotionInstanceDescriptor
MTLAccelerationStructure - MTLAccelerationStructureMotionTriangleGeometryDescriptor
MTLAccelerationStructure - MTLAccelerationStructurePassDescriptor
MTLAccelerationStructureCommandEncoder - MTLAccelerationStructurePassSampleBufferAttachmentDescriptor
MTLAccelerationStructureCommandEncoder - MTLAccelerationStructurePassSampleBufferAttachmentDescriptorArray
MTLAccelerationStructureCommandEncoder - MTLAccelerationStructureRefitOptions
MTLAccelerationStructureCommandEncoder - MTLAccelerationStructureSizes
MTLDevice - MTLAccelerationStructureTriangleGeometryDescriptor
MTLAccelerationStructure - MTLAccelerationStructureUsage
MTLAccelerationStructure - MTLAccelerationStructureUserIDInstanceDescriptor
MTLAccelerationStructureandMTLAccelerationStructureTypes - MTLArchitecture
MTLDevice - MTLArgumentBuffersTier
MTLDevice - MTLArgumentDescriptor
MTLDevice - MTLArrayType
MTLArgument - MTLAttribute
MTLLibrary - MTLAttributeDescriptor
MTLStageInputOutputDescriptor - MTLAttributeDescriptorArray
MTLStageInputOutputDescriptor - MTLAttributeFormat
MTLStageInputOutputDescriptor - MTLBarrierScope
MTLCommandEncoder - MTLBinaryArchiveDescriptor
MTLBinaryArchive - MTLBinaryArchiveError
MTLBinaryArchive - MTLBindingAccess
MTLArgument - MTLBindingType
MTLArgument - MTLBlendFactor
MTLRenderPipeline - MTLBlendOperation
MTLRenderPipeline - MTLBlitOption
MTLBlitCommandEncoder - MTLBlitPassDescriptor
MTLBlitPass - MTLBlitPassSampleBufferAttachmentDescriptor
MTLBlitPass - MTLBufferLayoutDescriptor
MTLStageInputOutputDescriptor - MTLBufferLayoutDescriptorArray
MTLStageInputOutputDescriptor - MTLCPUCacheMode
MTLResource - MTLCaptureDescriptor
MTLCaptureManager - MTLCaptureDestination
MTLCaptureManager - MTLCaptureError
MTLCaptureManager - MTLCaptureManager
MTLCaptureManager - MTLClearColor
MTLRenderPass - MTLColorWriteMask
MTLRenderPipeline - MTLCommandBufferDescriptor
MTLCommandBuffer - MTLCommandBufferError
MTLCommandBuffer - MTLCommandBufferErrorOption
MTLCommandBuffer - MTLCommandBufferStatus
MTLCommandBuffer - MTLCommandEncoderErrorState
MTLCommandBuffer - MTLCompareFunction
MTLDepthStencil - MTLCompileOptions
MTLLibrary - MTLCompileSymbolVisibility
MTLLibrary - MTLComputePassDescriptor
MTLComputePass - MTLComputePassSampleBufferAttachmentDescriptor
MTLComputePass - MTLComputePassSampleBufferAttachmentDescriptorArray
MTLComputePass - MTLComputePipelineDescriptor
MTLComputePipeline - MTLComputePipelineReflection
MTLComputePipeline - MTLCounterResultStageUtilization
MTLCounters - MTLCounterResultStatistic
MTLCounters - MTLCounterResultTimestamp
MTLCounters - MTLCounterSampleBufferDescriptor
MTLCounters - MTLCounterSampleBufferError
MTLCounters - MTLCounterSamplingPoint
MTLDevice - MTLCullMode
MTLRenderCommandEncoder - MTLCurveBasis
MTLAccelerationStructure - MTLCurveEndCaps
MTLAccelerationStructure - MTLCurveType
MTLAccelerationStructure - MTLDataType
MTLArgument - MTLDepthClipMode
MTLRenderCommandEncoder - MTLDepthStencilDescriptor
MTLDepthStencil - MTLDeviceLocation
MTLDevice - MTLDispatchThreadgroupsIndirectArguments
MTLComputeCommandEncoder - MTLDispatchType
MTLCommandBuffer - MTLDrawIndexedPrimitivesIndirectArguments
MTLRenderCommandEncoder - MTLDrawPatchIndirectArguments
MTLRenderCommandEncoder - MTLDrawPrimitivesIndirectArguments
MTLRenderCommandEncoder - MTLDynamicLibraryError
MTLDynamicLibrary - MTLFunctionConstant
MTLLibrary - MTLFunctionConstantValues
MTLFunctionConstantValues - MTLFunctionDescriptor
MTLFunctionDescriptor - MTLFunctionLogType
MTLFunctionLog - MTLFunctionOptions
MTLFunctionDescriptor - MTLFunctionStitchingAttributeAlwaysInline
MTLFunctionStitching - MTLFunctionStitchingFunctionNode
MTLFunctionStitching - MTLFunctionStitchingGraph
MTLFunctionStitching - MTLFunctionStitchingInputNode
MTLFunctionStitching - MTLFunctionType
MTLLibrary - MTLGPUFamily
MTLDevice - MTLHazardTrackingMode
MTLResource - MTLHeapDescriptor
MTLHeap - MTLHeapType
MTLHeap - MTLIOCommandQueueDescriptor
MTLIOCommandQueue - MTLIOCommandQueueType
MTLIOCommandQueue - MTLIOCompressionMethod
MTLDevice - MTLIOCompressionStatus
MTLIOCompressor - MTLIOError
MTLIOCommandQueue - MTLIOPriority
MTLIOCommandQueue - MTLIOStatus
MTLIOCommandBuffer - MTLIndexType
MTLStageInputOutputDescriptor - MTLIndirectAccelerationStructureInstanceDescriptor
MTLAccelerationStructureandMTLAccelerationStructureTypesandMTLTypes - MTLIndirectAccelerationStructureMotionInstanceDescriptor
MTLAccelerationStructureandMTLTypes - MTLIndirectCommandBufferDescriptor
MTLIndirectCommandBuffer - MTLIndirectCommandBufferExecutionRange
MTLIndirectCommandBuffer - MTLIndirectCommandType
MTLIndirectCommandBuffer - MTLIndirectInstanceAccelerationStructureDescriptor
MTLAccelerationStructure - MTLInstanceAccelerationStructureDescriptor
MTLAccelerationStructure - MTLIntersectionFunctionDescriptor
MTLFunctionDescriptor - MTLIntersectionFunctionSignature
MTLIntersectionFunctionTable - MTLIntersectionFunctionTableDescriptor
MTLIntersectionFunctionTable - MTLLanguageVersion
MTLLibrary - MTLLibraryError
MTLLibrary - MTLLibraryOptimizationLevel
MTLLibrary - MTLLibraryType
MTLLibrary - MTLLinkedFunctions
MTLLinkedFunctions - MTLLoadAction
MTLRenderPass - MTLMapIndirectArguments
MTLResourceStateCommandEncoder - MTLMeshRenderPipelineDescriptor
MTLRenderPipeline - MTLMotionBorderMode
MTLAccelerationStructure - MTLMotionKeyframeData
MTLAccelerationStructure - MTLMultisampleDepthResolveFilter
MTLRenderPass - MTLMultisampleStencilResolveFilter
MTLRenderPass - MTLMutability
MTLPipeline - MTLOrigin
MTLTypes - MTLPackedFloat3
MTLAccelerationStructureTypes - MTLPatchType
MTLLibrary - MTLPipelineBufferDescriptor
MTLPipeline - MTLPipelineBufferDescriptorArray
MTLPipeline - MTLPipelineOption
MTLDevice - MTLPixelFormat
MTLPixelFormat - MTLPointerType
MTLArgument - MTLPrimitiveAccelerationStructureDescriptor
MTLAccelerationStructure - MTLPrimitiveTopologyClass
MTLRenderPipeline - MTLPrimitiveType
MTLRenderCommandEncoder - MTLPurgeableState
MTLResource - MTLQuadTessellationFactorsHalf
MTLRenderCommandEncoder - MTLRasterizationRateLayerArray
MTLRasterizationRate - MTLRasterizationRateLayerDescriptor
MTLRasterizationRate - MTLRasterizationRateMapDescriptor
MTLRasterizationRate - MTLRasterizationRateSampleArray
MTLRasterizationRate - MTLReadWriteTextureTier
MTLDevice - MTLRegion
MTLTypes - MTLRenderPassAttachmentDescriptor
MTLRenderPass - MTLRenderPassColorAttachmentDescriptor
MTLRenderPass - MTLRenderPassColorAttachmentDescriptorArray
MTLRenderPass - MTLRenderPassDepthAttachmentDescriptor
MTLRenderPass - MTLRenderPassDescriptor
MTLRenderPass - MTLRenderPassSampleBufferAttachmentDescriptor
MTLRenderPass - MTLRenderPassSampleBufferAttachmentDescriptorArray
MTLRenderPass - MTLRenderPassStencilAttachmentDescriptor
MTLRenderPass - MTLRenderPipelineColorAttachmentDescriptor
MTLRenderPipeline - MTLRenderPipelineColorAttachmentDescriptorArray
MTLRenderPipeline - MTLRenderPipelineDescriptor
MTLRenderPipeline - MTLRenderPipelineFunctionsDescriptor
MTLRenderPipeline - MTLRenderPipelineReflection
MTLRenderPipeline - MTLRenderStages
MTLRenderCommandEncoder - MTLResourceID
MTLTypes - MTLResourceOptions
MTLResource - MTLResourceStatePassDescriptor
MTLResourceStatePass - MTLResourceStatePassSampleBufferAttachmentDescriptor
MTLResourceStatePass - MTLResourceStatePassSampleBufferAttachmentDescriptorArray
MTLResourceStatePass - MTLResourceUsage
MTLCommandEncoder - MTLSamplePosition
MTLTypes - MTLSamplerAddressMode
MTLSampler - MTLSamplerBorderColor
MTLSampler - MTLSamplerDescriptor
MTLSampler - MTLSamplerMinMagFilter
MTLSampler - MTLSamplerMipFilter
MTLSampler - MTLScissorRect
MTLRenderCommandEncoder - MTLSharedEventHandle
MTLEvent - MTLSharedEventListener
MTLEvent - MTLSharedTextureHandle
MTLTexture - MTLSize
MTLTypes - MTLSizeAndAlign
MTLDevice - MTLSparsePageSize
MTLDevice - MTLSparseTextureMappingMode
MTLResourceStateCommandEncoder - MTLSparseTextureRegionAlignmentMode
MTLDevice - MTLStageInRegionIndirectArguments
MTLComputeCommandEncoder - MTLStageInputOutputDescriptor
MTLStageInputOutputDescriptor - MTLStencilDescriptor
MTLDepthStencil - MTLStencilOperation
MTLDepthStencil - MTLStepFunction
MTLStageInputOutputDescriptor - MTLStitchedLibraryDescriptor
MTLFunctionStitching - MTLStorageMode
MTLResource - MTLStoreAction
MTLRenderPass - MTLStoreActionOptions
MTLRenderPass - MTLStructMember
MTLArgument - MTLStructType
MTLArgument - MTLTessellationControlPointIndexType
MTLRenderPipeline - MTLTessellationFactorFormat
MTLRenderPipeline - MTLTessellationFactorStepFunction
MTLRenderPipeline - MTLTessellationPartitionMode
MTLRenderPipeline - MTLTextureCompressionType
MTLTexture - MTLTextureDescriptor
MTLTexture - MTLTextureReferenceType
MTLArgument - MTLTextureSwizzle
MTLTexture - MTLTextureSwizzleChannels
MTLTexture - MTLTextureType
MTLTexture - MTLTextureUsage
MTLTexture - MTLTileRenderPipelineColorAttachmentDescriptor
MTLRenderPipeline - MTLTileRenderPipelineColorAttachmentDescriptorArray
MTLRenderPipeline - MTLTileRenderPipelineDescriptor
MTLRenderPipeline - MTLTriangleFillMode
MTLRenderCommandEncoder - MTLTriangleTessellationFactorsHalf
MTLRenderCommandEncoder - MTLType
MTLArgument - MTLVertexAmplificationViewMapping
MTLRenderCommandEncoder - MTLVertexAttribute
MTLLibrary - MTLVertexAttributeDescriptor
MTLVertexDescriptor - MTLVertexAttributeDescriptorArray
MTLVertexDescriptor - MTLVertexBufferLayoutDescriptor
MTLVertexDescriptor - MTLVertexBufferLayoutDescriptorArray
MTLVertexDescriptor - MTLVertexDescriptor
MTLVertexDescriptor - MTLVertexFormat
MTLVertexDescriptor - MTLVertexStepFunction
MTLVertexDescriptor - MTLViewport
MTLRenderCommandEncoder - MTLVisibilityResultMode
MTLRenderCommandEncoder - MTLVisibleFunctionTableDescriptor
MTLVisibleFunctionTable - MTLWinding
MTLRenderCommandEncoder
Constants§
- MTLCounterDontSample
MTLCounters - MTLCounterErrorValue
MTLCounters - MTLResourceCPUCacheModeMask
MTLResource - MTLResourceCPUCacheModeShift
MTLResource - MTLResourceHazardTrackingModeMask
MTLResource - MTLResourceHazardTrackingModeShift
MTLResource - MTLResourceStorageModeMask
MTLResource - MTLResourceStorageModeShift
MTLResource - MTLTextureSwizzleChannelsDefault
MTLTexture
Statics§
- MTLAttributeStrideStatic
MTLArgumentEncoder - MTLBinaryArchiveDomain
MTLBinaryArchive - MTLBufferLayoutStrideDynamic
MTLVertexDescriptor - MTLCaptureErrorDomain
MTLCaptureManager - MTLCommandBufferEncoderInfoErrorKey
MTLCommandBuffer - MTLCommandBufferErrorDomain
MTLCommandBuffer - MTLCommonCounterClipperInvocations
MTLCounters - MTLCommonCounterClipperPrimitivesOut
MTLCounters - MTLCommonCounterComputeKernelInvocations
MTLCounters - MTLCommonCounterFragmentCycles
MTLCounters - MTLCommonCounterFragmentInvocations
MTLCounters - MTLCommonCounterFragmentsPassed
MTLCounters - MTLCommonCounterPostTessellationVertexCycles
MTLCounters - MTLCommonCounterRenderTargetWriteCycles
MTLCounters - MTLCommonCounterSetStageUtilization
MTLCounters - MTLCommonCounterSetStatistic
MTLCounters - MTLCommonCounterSetTimestamp
MTLCounters - MTLCommonCounterTessellationCycles
MTLCounters - MTLCommonCounterTessellationInputPatches
MTLCounters - MTLCommonCounterTimestamp
MTLCounters - MTLCommonCounterTotalCycles
MTLCounters - MTLCommonCounterVertexCycles
MTLCounters - MTLCommonCounterVertexInvocations
MTLCounters - MTLCounterErrorDomain
MTLCounters - MTLDeviceWasAddedNotification
MTLDevice - MTLDeviceWasRemovedNotification
MTLDevice - MTLDynamicLibraryDomain
MTLDynamicLibrary - MTLIOErrorDomain
MTLIOCommandQueue - MTLLibraryErrorDomain
MTLLibrary
Traits§
- MTLAccelerationStructure
MTLAccelerationStructureandMTLResource - MTLAccelerationStructureCommandEncoder
MTLAccelerationStructureCommandEncoderandMTLCommandEncoder - MTLArgumentEncoder
MTLArgumentEncoder - MTLBinaryArchive
MTLBinaryArchive - MTLBinding
MTLArgument - MTLBlitCommandEncoder
MTLBlitCommandEncoderandMTLCommandEncoder - MTLBuffer
MTLBufferandMTLResource - MTLBufferBinding
MTLArgument - MTLCaptureScope
MTLCaptureScope - MTLCommandBuffer
MTLCommandBuffer - MTLCommandBufferEncoderInfo
MTLCommandBuffer - MTLCommandEncoder
MTLCommandEncoder - MTLCommandQueue
MTLCommandQueue - MTLComputeCommandEncoder
MTLCommandEncoderandMTLComputeCommandEncoder - MTLComputePipelineState
MTLComputePipeline - MTLCounter
MTLCounters - MTLCounterSampleBuffer
MTLCounters - MTLCounterSet
MTLCounters - MTLDepthStencilState
MTLDepthStencil - MTLDevice
MTLDevice - MTLDrawable
MTLDrawable - MTLDynamicLibrary
MTLDynamicLibrary - MTLEvent
MTLEvent - MTLFence
MTLFence - MTLFunction
MTLLibrary - MTLFunctionHandle
MTLFunctionHandle - MTLFunctionLog
MTLFunctionLog - MTLFunctionLogDebugLocation
MTLFunctionLog - MTLFunctionStitchingAttribute
MTLFunctionStitching - MTLFunctionStitchingNode
MTLFunctionStitching - MTLHeap
MTLHeap - MTLIOCommandBuffer
MTLIOCommandBuffer - MTLIOCommandQueue
MTLIOCommandQueue - MTLIOFileHandle
MTLIOCommandQueue - MTLIOScratchBuffer
MTLIOCommandQueue - MTLIOScratchBufferAllocator
MTLIOCommandQueue - MTLIndirectCommandBuffer
MTLIndirectCommandBufferandMTLResource - MTLIndirectComputeCommand
MTLIndirectCommandEncoder - MTLIndirectRenderCommand
MTLIndirectCommandEncoder - MTLIntersectionFunctionTable
MTLIntersectionFunctionTableandMTLResource - MTLLibrary
MTLLibrary - MTLLogContainer
MTLFunctionLog - MTLObjectPayloadBinding
MTLArgument - MTLParallelRenderCommandEncoder
MTLCommandEncoderandMTLParallelRenderCommandEncoder - MTLRasterizationRateMap
MTLRasterizationRate - MTLRenderCommandEncoder
MTLCommandEncoderandMTLRenderCommandEncoder - MTLRenderCommandEncoderSliceExt
MTLRenderCommandEncoderandMTLCommandEncoder - MTLRenderPipelineState
MTLRenderPipeline - MTLResource
MTLResource - MTLResourceStateCommandEncoder
MTLCommandEncoderandMTLResourceStateCommandEncoder - MTLSamplerState
MTLSampler - MTLSharedEvent
MTLEvent - MTLTexture
MTLResourceandMTLTexture - MTLTextureBinding
MTLArgument - MTLThreadgroupBinding
MTLArgument - MTLVisibleFunctionTable
MTLResourceandMTLVisibleFunctionTable
Functions§
- MTLCopyAllDevices⚠
MTLDevice - MTLCreateSystemDefaultDevice⚠
MTLDevice - MTLIOCompressionContextAppendData⚠
MTLIOCompressor - MTLIOCompressionContextDefaultChunkSize⚠
MTLIOCompressor - MTLIOCreateCompressionContext⚠
MTLIOCompressorandMTLDevice - MTLIOFlushAndDestroyCompressionContext⚠
MTLIOCompressor - MTLRemoveDeviceObserver⚠
MTLDevice
Type Aliases§
- MTLArgumentAccess
MTLArgument - MTLAxisAlignedBoundingBox
MTLAccelerationStructureTypes - MTLCommandBufferHandler
MTLCommandBufferandblock2 - MTLCommonCounter
MTLCounters - MTLCommonCounterSet
MTLCounters - MTLCoordinate2D
MTLTypes - MTLDeviceNotificationHandler
MTLDeviceandblock2 - MTLDeviceNotificationName
MTLDevice - MTLDrawablePresentedHandler
MTLDrawableandblock2 - MTLIOCommandBufferHandler
MTLIOCommandBufferandblock2 - MTLIOCompressionContext
MTLIOCompressor - MTLNewComputePipelineStateCompletionHandler
MTLComputePipelineandMTLDeviceandblock2 - MTLNewComputePipelineStateWithReflectionCompletionHandler
MTLComputePipelineandMTLDeviceandblock2 - MTLNewLibraryCompletionHandler
MTLDeviceandMTLLibraryandblock2 - MTLNewRenderPipelineStateCompletionHandler
MTLDeviceandMTLRenderPipelineandblock2 - MTLNewRenderPipelineStateWithReflectionCompletionHandler
MTLDeviceandMTLRenderPipelineandblock2 - MTLPackedFloat4x3
MTLAccelerationStructureTypes - MTLSharedEventNotificationBlock
MTLEventandblock2 - MTLTimestamp
MTLDevice