use objc2::{Message, msg_send, runtime::ProtocolObject};
use crate::util::ref_ptr_cast_const;
use crate::*;
pub trait MTL4CommandQueueExt: MTL4CommandQueue + Message {
fn commit(&self, command_buffers: &[&ProtocolObject<dyn MTL4CommandBuffer>])
where
Self: Sized,
{
let ptr = ref_ptr_cast_const(command_buffers.as_ptr());
unsafe { msg_send![self, commit: ptr, count: command_buffers.len()] }
}
fn commit_with_options(
&self,
command_buffers: &[&ProtocolObject<dyn MTL4CommandBuffer>],
options: &MTL4CommitOptions,
) where
Self: Sized,
{
let ptr = ref_ptr_cast_const(command_buffers.as_ptr());
unsafe { msg_send![self, commit: ptr, count: command_buffers.len(), options: options] }
}
fn add_residency_sets(&self, residency_sets: &[&ProtocolObject<dyn MTLResidencySet>])
where
Self: Sized,
{
let ptr = ref_ptr_cast_const(residency_sets.as_ptr());
unsafe { msg_send![self, addResidencySets: ptr, count: residency_sets.len()] }
}
fn remove_residency_sets(&self, residency_sets: &[&ProtocolObject<dyn MTLResidencySet>])
where
Self: Sized,
{
let ptr = ref_ptr_cast_const(residency_sets.as_ptr());
unsafe { msg_send![self, removeResidencySets: ptr, count: residency_sets.len()] }
}
}
impl<T: MTL4CommandQueue + Message> MTL4CommandQueueExt for T {}