use core::ops::Range;
use objc2::{Message, extern_protocol, msg_send, rc::Retained, runtime::ProtocolObject};
use objc2_foundation::{NSObjectProtocol, NSRange};
use crate::{MTLIndirectComputeCommand, MTLIndirectRenderCommand, types::MTLResourceID};
extern_protocol!(
pub unsafe trait MTLIndirectCommandBuffer: NSObjectProtocol {
#[unsafe(method(size))]
#[unsafe(method_family = none)]
fn size(&self) -> usize;
#[unsafe(method(gpuResourceID))]
#[unsafe(method_family = none)]
fn gpu_resource_id(&self) -> MTLResourceID;
#[unsafe(method(indirectRenderCommandAtIndex:))]
#[unsafe(method_family = none)]
fn indirect_render_command_at_index(
&self,
command_index: usize,
) -> Retained<ProtocolObject<dyn MTLIndirectRenderCommand>>;
#[unsafe(method(indirectComputeCommandAtIndex:))]
#[unsafe(method_family = none)]
fn indirect_compute_command_at_index(
&self,
command_index: usize,
) -> Retained<ProtocolObject<dyn MTLIndirectComputeCommand>>;
}
);
pub trait MTLIndirectCommandBufferExt: MTLIndirectCommandBuffer + Message {
fn reset_with_range(
&self,
range: Range<usize>,
) where
Self: Sized,
{
unsafe {
let _: () = msg_send![self, resetWithRange: NSRange::from(range)];
}
}
}
impl<T: MTLIndirectCommandBuffer + Message> MTLIndirectCommandBufferExt for T {}