use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLCommandBufferStatus(pub NSUInteger);
impl MTLCommandBufferStatus {
#[doc(alias = "MTLCommandBufferStatusNotEnqueued")]
pub const NotEnqueued: Self = Self(0);
#[doc(alias = "MTLCommandBufferStatusEnqueued")]
pub const Enqueued: Self = Self(1);
#[doc(alias = "MTLCommandBufferStatusCommitted")]
pub const Committed: Self = Self(2);
#[doc(alias = "MTLCommandBufferStatusScheduled")]
pub const Scheduled: Self = Self(3);
#[doc(alias = "MTLCommandBufferStatusCompleted")]
pub const Completed: Self = Self(4);
#[doc(alias = "MTLCommandBufferStatusError")]
pub const Error: Self = Self(5);
}
unsafe impl Encode for MTLCommandBufferStatus {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for MTLCommandBufferStatus {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C" {
pub static MTLCommandBufferErrorDomain: &'static NSErrorDomain;
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLCommandBufferError(pub NSUInteger);
impl MTLCommandBufferError {
#[doc(alias = "MTLCommandBufferErrorNone")]
pub const None: Self = Self(0);
#[doc(alias = "MTLCommandBufferErrorInternal")]
pub const Internal: Self = Self(1);
#[doc(alias = "MTLCommandBufferErrorTimeout")]
pub const Timeout: Self = Self(2);
#[doc(alias = "MTLCommandBufferErrorPageFault")]
pub const PageFault: Self = Self(3);
#[doc(alias = "MTLCommandBufferErrorBlacklisted")]
#[deprecated]
pub const Blacklisted: Self = Self(4);
#[doc(alias = "MTLCommandBufferErrorAccessRevoked")]
pub const AccessRevoked: Self = Self(4);
#[doc(alias = "MTLCommandBufferErrorNotPermitted")]
pub const NotPermitted: Self = Self(7);
#[doc(alias = "MTLCommandBufferErrorOutOfMemory")]
pub const OutOfMemory: Self = Self(8);
#[doc(alias = "MTLCommandBufferErrorInvalidResource")]
pub const InvalidResource: Self = Self(9);
#[doc(alias = "MTLCommandBufferErrorMemoryless")]
pub const Memoryless: Self = Self(10);
#[doc(alias = "MTLCommandBufferErrorDeviceRemoved")]
pub const DeviceRemoved: Self = Self(11);
#[doc(alias = "MTLCommandBufferErrorStackOverflow")]
pub const StackOverflow: Self = Self(12);
}
unsafe impl Encode for MTLCommandBufferError {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for MTLCommandBufferError {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C" {
pub static MTLCommandBufferEncoderInfoErrorKey: &'static NSErrorUserInfoKey;
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLCommandBufferErrorOption(pub NSUInteger);
bitflags::bitflags! {
impl MTLCommandBufferErrorOption: NSUInteger {
#[doc(alias = "MTLCommandBufferErrorOptionNone")]
const None = 0;
#[doc(alias = "MTLCommandBufferErrorOptionEncoderExecutionStatus")]
const EncoderExecutionStatus = 1<<0;
}
}
unsafe impl Encode for MTLCommandBufferErrorOption {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for MTLCommandBufferErrorOption {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLCommandEncoderErrorState(pub NSInteger);
impl MTLCommandEncoderErrorState {
#[doc(alias = "MTLCommandEncoderErrorStateUnknown")]
pub const Unknown: Self = Self(0);
#[doc(alias = "MTLCommandEncoderErrorStateCompleted")]
pub const Completed: Self = Self(1);
#[doc(alias = "MTLCommandEncoderErrorStateAffected")]
pub const Affected: Self = Self(2);
#[doc(alias = "MTLCommandEncoderErrorStatePending")]
pub const Pending: Self = Self(3);
#[doc(alias = "MTLCommandEncoderErrorStateFaulted")]
pub const Faulted: Self = Self(4);
}
unsafe impl Encode for MTLCommandEncoderErrorState {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for MTLCommandEncoderErrorState {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct MTLCommandBufferDescriptor;
);
extern_conformance!(
unsafe impl NSCopying for MTLCommandBufferDescriptor {}
);
unsafe impl CopyingHelper for MTLCommandBufferDescriptor {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for MTLCommandBufferDescriptor {}
);
impl MTLCommandBufferDescriptor {
extern_methods!(
#[unsafe(method(retainedReferences))]
#[unsafe(method_family = none)]
pub fn retainedReferences(&self) -> bool;
#[unsafe(method(setRetainedReferences:))]
#[unsafe(method_family = none)]
pub fn setRetainedReferences(&self, retained_references: bool);
#[unsafe(method(errorOptions))]
#[unsafe(method_family = none)]
pub fn errorOptions(&self) -> MTLCommandBufferErrorOption;
#[unsafe(method(setErrorOptions:))]
#[unsafe(method_family = none)]
pub fn setErrorOptions(&self, error_options: MTLCommandBufferErrorOption);
#[cfg(feature = "MTLLogState")]
#[unsafe(method(logState))]
#[unsafe(method_family = none)]
pub fn logState(&self) -> Option<Retained<ProtocolObject<dyn MTLLogState>>>;
#[cfg(feature = "MTLLogState")]
#[unsafe(method(setLogState:))]
#[unsafe(method_family = none)]
pub fn setLogState(&self, log_state: Option<&ProtocolObject<dyn MTLLogState>>);
);
}
impl MTLCommandBufferDescriptor {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
impl DefaultRetained for MTLCommandBufferDescriptor {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}
extern_protocol!(
pub unsafe trait MTLCommandBufferEncoderInfo: NSObjectProtocol {
#[unsafe(method(label))]
#[unsafe(method_family = none)]
fn label(&self) -> Retained<NSString>;
#[unsafe(method(debugSignposts))]
#[unsafe(method_family = none)]
fn debugSignposts(&self) -> Retained<NSArray<NSString>>;
#[unsafe(method(errorState))]
#[unsafe(method_family = none)]
fn errorState(&self) -> MTLCommandEncoderErrorState;
}
);
#[cfg(feature = "block2")]
pub type MTLCommandBufferHandler =
*mut block2::DynBlock<dyn Fn(NonNull<ProtocolObject<dyn MTLCommandBuffer>>)>;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MTLDispatchType(pub NSUInteger);
impl MTLDispatchType {
#[doc(alias = "MTLDispatchTypeSerial")]
pub const Serial: Self = Self(0);
#[doc(alias = "MTLDispatchTypeConcurrent")]
pub const Concurrent: Self = Self(1);
}
unsafe impl Encode for MTLDispatchType {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for MTLDispatchType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_protocol!(
pub unsafe trait MTLCommandBuffer: NSObjectProtocol {
#[cfg(feature = "MTLDevice")]
#[unsafe(method(device))]
#[unsafe(method_family = none)]
fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;
#[cfg(feature = "MTLCommandQueue")]
#[unsafe(method(commandQueue))]
#[unsafe(method_family = none)]
fn commandQueue(&self) -> Retained<ProtocolObject<dyn MTLCommandQueue>>;
#[unsafe(method(retainedReferences))]
#[unsafe(method_family = none)]
fn retainedReferences(&self) -> bool;
#[unsafe(method(errorOptions))]
#[unsafe(method_family = none)]
fn errorOptions(&self) -> MTLCommandBufferErrorOption;
#[unsafe(method(label))]
#[unsafe(method_family = none)]
fn label(&self) -> Option<Retained<NSString>>;
#[unsafe(method(setLabel:))]
#[unsafe(method_family = none)]
fn setLabel(&self, label: Option<&NSString>);
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(kernelStartTime))]
#[unsafe(method_family = none)]
fn kernelStartTime(&self) -> CFTimeInterval;
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(kernelEndTime))]
#[unsafe(method_family = none)]
fn kernelEndTime(&self) -> CFTimeInterval;
#[cfg(feature = "MTLFunctionLog")]
#[unsafe(method(logs))]
#[unsafe(method_family = none)]
fn logs(&self) -> Retained<ProtocolObject<dyn MTLLogContainer>>;
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(GPUStartTime))]
#[unsafe(method_family = none)]
fn GPUStartTime(&self) -> CFTimeInterval;
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(GPUEndTime))]
#[unsafe(method_family = none)]
fn GPUEndTime(&self) -> CFTimeInterval;
#[unsafe(method(enqueue))]
#[unsafe(method_family = none)]
fn enqueue(&self);
#[unsafe(method(commit))]
#[unsafe(method_family = none)]
fn commit(&self);
#[cfg(feature = "block2")]
#[unsafe(method(addScheduledHandler:))]
#[unsafe(method_family = none)]
unsafe fn addScheduledHandler(&self, block: MTLCommandBufferHandler);
#[cfg(feature = "MTLDrawable")]
#[unsafe(method(presentDrawable:))]
#[unsafe(method_family = none)]
fn presentDrawable(&self, drawable: &ProtocolObject<dyn MTLDrawable>);
#[cfg(all(feature = "MTLDrawable", feature = "objc2-core-foundation"))]
#[unsafe(method(presentDrawable:atTime:))]
#[unsafe(method_family = none)]
fn presentDrawable_atTime(
&self,
drawable: &ProtocolObject<dyn MTLDrawable>,
presentation_time: CFTimeInterval,
);
#[cfg(all(feature = "MTLDrawable", feature = "objc2-core-foundation"))]
#[unsafe(method(presentDrawable:afterMinimumDuration:))]
#[unsafe(method_family = none)]
fn presentDrawable_afterMinimumDuration(
&self,
drawable: &ProtocolObject<dyn MTLDrawable>,
duration: CFTimeInterval,
);
#[unsafe(method(waitUntilScheduled))]
#[unsafe(method_family = none)]
fn waitUntilScheduled(&self);
#[cfg(feature = "block2")]
#[unsafe(method(addCompletedHandler:))]
#[unsafe(method_family = none)]
unsafe fn addCompletedHandler(&self, block: MTLCommandBufferHandler);
#[unsafe(method(waitUntilCompleted))]
#[unsafe(method_family = none)]
fn waitUntilCompleted(&self);
#[unsafe(method(status))]
#[unsafe(method_family = none)]
fn status(&self) -> MTLCommandBufferStatus;
#[unsafe(method(error))]
#[unsafe(method_family = none)]
fn error(&self) -> Option<Retained<NSError>>;
#[cfg(all(feature = "MTLBlitCommandEncoder", feature = "MTLCommandEncoder"))]
#[unsafe(method(blitCommandEncoder))]
#[unsafe(method_family = none)]
fn blitCommandEncoder(&self)
-> Option<Retained<ProtocolObject<dyn MTLBlitCommandEncoder>>>;
#[cfg(all(
feature = "MTLCommandEncoder",
feature = "MTLRenderCommandEncoder",
feature = "MTLRenderPass"
))]
#[unsafe(method(renderCommandEncoderWithDescriptor:))]
#[unsafe(method_family = none)]
fn renderCommandEncoderWithDescriptor(
&self,
render_pass_descriptor: &MTLRenderPassDescriptor,
) -> Option<Retained<ProtocolObject<dyn MTLRenderCommandEncoder>>>;
#[cfg(all(
feature = "MTLCommandEncoder",
feature = "MTLComputeCommandEncoder",
feature = "MTLComputePass"
))]
#[unsafe(method(computeCommandEncoderWithDescriptor:))]
#[unsafe(method_family = none)]
fn computeCommandEncoderWithDescriptor(
&self,
compute_pass_descriptor: &MTLComputePassDescriptor,
) -> Option<Retained<ProtocolObject<dyn MTLComputeCommandEncoder>>>;
#[cfg(all(
feature = "MTLBlitCommandEncoder",
feature = "MTLBlitPass",
feature = "MTLCommandEncoder"
))]
#[unsafe(method(blitCommandEncoderWithDescriptor:))]
#[unsafe(method_family = none)]
fn blitCommandEncoderWithDescriptor(
&self,
blit_pass_descriptor: &MTLBlitPassDescriptor,
) -> Option<Retained<ProtocolObject<dyn MTLBlitCommandEncoder>>>;
#[cfg(all(feature = "MTLCommandEncoder", feature = "MTLComputeCommandEncoder"))]
#[unsafe(method(computeCommandEncoder))]
#[unsafe(method_family = none)]
fn computeCommandEncoder(
&self,
) -> Option<Retained<ProtocolObject<dyn MTLComputeCommandEncoder>>>;
#[cfg(all(feature = "MTLCommandEncoder", feature = "MTLComputeCommandEncoder"))]
#[unsafe(method(computeCommandEncoderWithDispatchType:))]
#[unsafe(method_family = none)]
fn computeCommandEncoderWithDispatchType(
&self,
dispatch_type: MTLDispatchType,
) -> Option<Retained<ProtocolObject<dyn MTLComputeCommandEncoder>>>;
#[cfg(feature = "MTLEvent")]
#[unsafe(method(encodeWaitForEvent:value:))]
#[unsafe(method_family = none)]
fn encodeWaitForEvent_value(&self, event: &ProtocolObject<dyn MTLEvent>, value: u64);
#[cfg(feature = "MTLEvent")]
#[unsafe(method(encodeSignalEvent:value:))]
#[unsafe(method_family = none)]
fn encodeSignalEvent_value(&self, event: &ProtocolObject<dyn MTLEvent>, value: u64);
#[cfg(all(
feature = "MTLCommandEncoder",
feature = "MTLParallelRenderCommandEncoder",
feature = "MTLRenderPass"
))]
#[unsafe(method(parallelRenderCommandEncoderWithDescriptor:))]
#[unsafe(method_family = none)]
fn parallelRenderCommandEncoderWithDescriptor(
&self,
render_pass_descriptor: &MTLRenderPassDescriptor,
) -> Option<Retained<ProtocolObject<dyn MTLParallelRenderCommandEncoder>>>;
#[cfg(all(
feature = "MTLCommandEncoder",
feature = "MTLResourceStateCommandEncoder"
))]
#[unsafe(method(resourceStateCommandEncoder))]
#[unsafe(method_family = none)]
fn resourceStateCommandEncoder(
&self,
) -> Option<Retained<ProtocolObject<dyn MTLResourceStateCommandEncoder>>>;
#[cfg(all(
feature = "MTLCommandEncoder",
feature = "MTLResourceStateCommandEncoder",
feature = "MTLResourceStatePass"
))]
#[unsafe(method(resourceStateCommandEncoderWithDescriptor:))]
#[unsafe(method_family = none)]
fn resourceStateCommandEncoderWithDescriptor(
&self,
resource_state_pass_descriptor: &MTLResourceStatePassDescriptor,
) -> Option<Retained<ProtocolObject<dyn MTLResourceStateCommandEncoder>>>;
#[cfg(all(
feature = "MTLAccelerationStructureCommandEncoder",
feature = "MTLCommandEncoder"
))]
#[unsafe(method(accelerationStructureCommandEncoder))]
#[unsafe(method_family = none)]
fn accelerationStructureCommandEncoder(
&self,
) -> Option<Retained<ProtocolObject<dyn MTLAccelerationStructureCommandEncoder>>>;
#[cfg(all(
feature = "MTLAccelerationStructureCommandEncoder",
feature = "MTLCommandEncoder"
))]
#[unsafe(method(accelerationStructureCommandEncoderWithDescriptor:))]
#[unsafe(method_family = none)]
fn accelerationStructureCommandEncoderWithDescriptor(
&self,
descriptor: &MTLAccelerationStructurePassDescriptor,
) -> Retained<ProtocolObject<dyn MTLAccelerationStructureCommandEncoder>>;
#[unsafe(method(pushDebugGroup:))]
#[unsafe(method_family = none)]
fn pushDebugGroup(&self, string: &NSString);
#[unsafe(method(popDebugGroup))]
#[unsafe(method_family = none)]
fn popDebugGroup(&self);
#[cfg(feature = "MTLResidencySet")]
#[unsafe(method(useResidencySet:))]
#[unsafe(method_family = none)]
fn useResidencySet(&self, residency_set: &ProtocolObject<dyn MTLResidencySet>);
#[cfg(feature = "MTLResidencySet")]
#[unsafe(method(useResidencySets:count:))]
#[unsafe(method_family = none)]
unsafe fn useResidencySets_count(
&self,
residency_sets: NonNull<NonNull<ProtocolObject<dyn MTLResidencySet>>>,
count: NSUInteger,
);
}
);