diff --git a/cidre-macros/src/lib.rs b/cidre-macros/src/lib.rs index c2bbfc13..bd87d768 100644 --- a/cidre-macros/src/lib.rs +++ b/cidre-macros/src/lib.rs @@ -462,6 +462,9 @@ fn gen_msg_send( }; let fn_name = fn_name.to_string(); + if extern_name.starts_with("new") && fn_name.ends_with("_ar") { + panic!("can't use _ar functions with methods started with `new`. See #3"); + } let mut generics = Vec::new(); let args = loop { diff --git a/cidre/src/mtl/buffer.rs b/cidre/src/mtl/buffer.rs index 7bddd73f..85e33557 100644 --- a/cidre/src/mtl/buffer.rs +++ b/cidre/src/mtl/buffer.rs @@ -30,14 +30,6 @@ impl Buf { pub fn did_modify_range(&self, range: ns::Range); #[objc::msg_send(newTextureWithDescriptor:offset:bytesPerRow:)] - pub fn new_texture_with_descriptor_ar( - &self, - descritptor: &mtl::TextureDescriptor, - offset: usize, - bytes_per_row: usize, - ) -> Option<&'ar mtl::Texture>; - - #[objc::rar_retain()] pub fn new_texture_with_descriptor( &self, descritptor: &mtl::TextureDescriptor, diff --git a/cidre/src/mtl/device.rs b/cidre/src/mtl/device.rs index b0876a4c..0d976bd8 100644 --- a/cidre/src/mtl/device.rs +++ b/cidre/src/mtl/device.rs @@ -108,9 +108,6 @@ impl Device { /// queue.as_type_ref().show(); /// #[objc::msg_send(newCommandQueue)] - pub fn new_cmd_queue_ar(&self) -> Option<&'ar CmdQueue>; - - #[objc::rar_retain()] pub fn new_cmd_queue(&self) -> Option>; /// ``` @@ -123,32 +120,15 @@ impl Device { /// queue.as_type_ref().show(); /// #[objc::msg_send(newCommandQueueWithMaxCommandBufferCount:)] - pub fn new_cmd_queue_max_cmd_buf_count_ar( - &self, - max_cmd_buf_count: usize, - ) -> Option<&'ar CmdQueue>; - - #[objc::rar_retain()] pub fn new_cmd_queue_max_cmd_buf_count( &self, max_cmd_buf_count: usize, ) -> Option>; #[objc::msg_send(newTextureWithDescriptor:)] - pub fn new_texture_ar(&self, descriptor: &mtl::TextureDescriptor) -> Option<&'ar mtl::Texture>; - - #[objc::rar_retain()] pub fn new_texture(&self, descriptor: &mtl::TextureDescriptor) -> Option>; #[objc::msg_send(newTextureWithDescriptor:iosurface:plane:)] - pub fn new_texture_with_surface_ar( - &self, - descriptor: &mtl::TextureDescriptor, - surface: &io::Surface, - plane: usize, - ) -> Option<&'ar mtl::Texture>; - - #[objc::rar_retain()] pub fn new_texture_with_surface( &self, descriptor: &mtl::TextureDescriptor, @@ -157,20 +137,9 @@ impl Device { ) -> Option>; #[objc::msg_send(newDefaultLibrary)] - pub fn new_default_lib_ar(&self) -> Option<&'ar Lib>; - - #[objc::rar_retain()] pub fn new_default_lib(&self) -> Option>; #[objc::msg_send(newLibraryWithSource:options:error:)] - pub fn new_lib_with_src_err_ar( - &self, - source: &ns::String, - options: Option<&mtl::CompileOptions>, - error: *mut Option<&ns::Error>, - ) -> Option<&'ar Lib>; - - #[objc::rar_retain()] pub fn new_lib_with_src_err( &self, source: &ns::String, @@ -212,13 +181,6 @@ impl Device { F: FnOnce(Option<&'ar mtl::library::Lib>, Option<&'ar ns::Error>) + 'static; #[objc::msg_send(newComputePipelineStateWithFunction:error:)] - pub fn new_compute_ps_with_fn_err_ar<'a>( - &self, - function: &mtl::Fn, - error: &mut Option<&'a ns::Error>, - ) -> Option<&'ar mtl::ComputePipelineState>; - - #[objc::rar_retain()] pub fn new_compute_ps_with_fn_err<'a>( &self, function: &mtl::Fn, @@ -226,13 +188,6 @@ impl Device { ) -> Option>; #[objc::msg_send(newRenderPipelineStateWithDescriptor:error:)] - pub unsafe fn new_render_ps_err_ar( - &self, - descriptor: &mtl::RenderPipelineDescriptor, - error: &mut Option<&ns::Error>, - ) -> Option<&'ar mtl::RenderPipelineState>; - - #[objc::rar_retain] pub unsafe fn new_render_ps_err( &self, descriptor: &mtl::RenderPipelineDescriptor, @@ -271,22 +226,10 @@ impl Device { } #[objc::msg_send(newBufferWithLength:options:)] - pub fn new_buf_ar(&self, length: usize, options: mtl::ResourceOptions) - -> Option<&'ar mtl::Buf>; - - #[objc::rar_retain()] pub fn new_buf(&self, length: usize, options: mtl::ResourceOptions) -> Option>; #[objc::msg_send(newBufferWithBytes:length:options:)] - pub fn new_buf_with_bytes_ar( - &self, - bytes: *const c_void, - length: usize, - options: mtl::ResourceOptions, - ) -> Option<&'ar Buf>; - - #[objc::rar_retain()] pub fn new_buf_with_bytes( &self, bytes: *const c_void, @@ -295,43 +238,25 @@ impl Device { ) -> Option>; #[inline] - pub fn new_buf_with_slice_ar<'ar, T: Sized>( + pub fn new_buf_with_slice( &self, slice: &[T], options: mtl::ResourceOptions, - ) -> Option<&'ar mtl::Buf> { - self.new_buf_with_bytes_ar( + ) -> Option> { + self.new_buf_with_bytes( slice.as_ptr() as _, std::mem::size_of::() * slice.len(), options, ) } - #[inline] - pub fn new_buf_with_slice( - &self, - slice: &[T], - options: mtl::ResourceOptions, - ) -> Option> { - arc::rar_retain_option(self.new_buf_with_slice_ar(slice, options)) - } - #[objc::msg_send(newFence)] - pub fn new_fence_ar(&self) -> Option<&'ar Fence>; - - #[objc::rar_retain()] pub fn new_fence(&self) -> Option>; #[objc::msg_send(newEvent)] - pub fn new_event_ar(&self) -> Option<&'ar Event>; - - #[objc::rar_retain()] pub fn new_event(&self) -> Option>; #[objc::msg_send(newSharedEvent)] - pub fn new_shared_event_ar(&self) -> Option<&'ar SharedEvent>; - - #[objc::rar_retain()] pub fn new_shared_event(&self) -> Option>; #[objc::msg_send(maxBufferLength)] @@ -350,9 +275,6 @@ impl Device { ) -> SizeAndAlign; #[objc::msg_send(newHeapWithDescriptor:)] - pub fn new_heap_desc_ar(&self, descriptor: &mtl::HeapDescriptor) -> Option<&'ar mtl::Heap>; - - #[objc::rar_retain()] pub fn new_heap_desc(&self, descriptor: &mtl::HeapDescriptor) -> Option>; /// The maximum threadgroup memory available to a compute kernel, in bytes. @@ -438,7 +360,6 @@ mod tests { let tier = device.argument_buffers_support(); assert_ne!(tier, mtl::ArgumentBuffersTier::_1); - assert!(device.new_default_lib_ar().is_none()); assert!(device.new_default_lib().is_none()); let td = mtl::TextureDescriptor::new_2d_with_pixel_format( @@ -449,11 +370,9 @@ mod tests { ); let _t = device.new_texture(&td).unwrap(); - let _t = device.new_texture_ar(&td).unwrap(); assert!(device.max_buffer_length() > 10); - let _queue = device.new_cmd_queue_ar().unwrap(); let _queue = device.new_cmd_queue().unwrap(); let source = ns::String::with_str("void function_a() {}"); diff --git a/cidre/src/mtl/heap.rs b/cidre/src/mtl/heap.rs index bbbace11..0041d33f 100644 --- a/cidre/src/mtl/heap.rs +++ b/cidre/src/mtl/heap.rs @@ -93,31 +93,16 @@ impl Heap { /// Create a new buffer backed by heap memory. #[objc::msg_send(newBufferWithLength:options:)] - pub fn new_buf_ar(&self, length: usize, options: mtl::ResourceOptions) - -> Option<&'ar mtl::Buf>; - - #[objc::rar_retain()] pub fn new_buf(&self, length: usize, options: mtl::ResourceOptions) -> Option>; #[objc::msg_send(newTextureWithDescriptor:)] - pub fn new_texture_ar(&self, descriptor: &mtl::TextureDescriptor) -> Option<&'ar mtl::Texture>; - - #[objc::rar_retain()] pub fn new_texture(&self, descriptor: &mtl::TextureDescriptor) -> Option>; #[objc::msg_send(setPurgeableState:)] pub fn set_purgeable_state(&mut self, state: mtl::PurgableState); #[objc::msg_send(newBufferWithLength:options:offset:)] - pub fn new_buf_with_offset_ar( - &self, - length: usize, - options: mtl::ResouceOptions, - offset: usize, - ) -> Option<&'ar mtl::Buf>; - - #[objc::rar_retain] pub fn new_buf_with_offset( &self, length: usize, @@ -126,13 +111,6 @@ impl Heap { ) -> Option>; #[objc::msg_send(newTextureWithDescriptor:offset:)] - pub fn new_texture_with_offset_ar( - &self, - descriptor: &mtl::TextureDescriptor, - offset: usize, - ) -> Option<&'ar mtl::Texture>; - - #[objc::rar_retain] pub fn new_texture_with_offset( &self, descriptor: &mtl::TextureDescriptor, @@ -140,13 +118,6 @@ impl Heap { ) -> Option>; #[objc::msg_send(newTextureWithDescriptor:offset:)] - pub fn new_texture_with_desc_offset_ar( - &self, - descriptor: &mtl::TextureDescriptor, - offset: usize, - ) -> Option<&'ar mtl::Texture>; - - #[objc::rar_retain] pub fn new_texture_with_desc_offset( &self, descriptor: &mtl::TextureDescriptor, @@ -154,25 +125,12 @@ impl Heap { ) -> Option>; #[objc::msg_send(newAccelerationStructureWithSize:)] - pub fn new_acceleration_structure_size_ar( - &self, - size: usize, - ) -> Option<&'ar mtl::AccelerationStructure>; - - #[objc::rar_retain] pub fn new_acceleration_structure_size( &self, size: usize, ) -> Option>; #[objc::msg_send(newAccelerationStructureWithSize:offset:)] - pub fn new_acceleration_structure_size_offset_ar( - &self, - size: usize, - offset: usize, - ) -> Option<&'ar mtl::AccelerationStructure>; - - #[objc::rar_retain] pub fn new_acceleration_structure_size_offset( &self, size: usize, @@ -180,25 +138,12 @@ impl Heap { ) -> Option>; #[objc::msg_send(newAccelerationStructureWithDescriptor:)] - pub fn new_acceleration_structure_with_desc_ar( - &self, - descriptor: &mtl::AccelerationStructureDescriptor, - ) -> Option<&'ar mtl::AccelerationStructure>; - - #[objc::rar_retain] pub fn new_acceleration_structure_with_desc( &self, descriptor: &mtl::AccelerationStructureDescriptor, ) -> Option>; #[objc::msg_send(newAccelerationStructureWithDescriptor:offset:)] - pub fn new_acceleration_structure_with_desc_offset_ar( - &self, - descriptor: &mtl::AccelerationStructureDescriptor, - offset: usize, - ) -> Option<&'ar mtl::AccelerationStructure>; - - #[objc::rar_retain] pub fn new_acceleration_structure_with_desc_offset( &self, descriptor: &mtl::AccelerationStructureDescriptor, @@ -228,7 +173,5 @@ mod tests { let device = mtl::Device::default().unwrap(); let heap = device.new_heap_desc(&desc).unwrap(); assert!(heap.size() >= 1024); - let heap = device.new_heap_desc_ar(&desc).unwrap(); - assert!(heap.size() >= 1024); } } diff --git a/cidre/src/mtl/library.rs b/cidre/src/mtl/library.rs index 883a6742..1d63ab09 100644 --- a/cidre/src/mtl/library.rs +++ b/cidre/src/mtl/library.rs @@ -134,12 +134,6 @@ impl Fn { pub fn name(&self) -> &ns::String; #[objc::msg_send(newArgumentEncoderWithBufferIndex:)] - pub fn new_argument_enc_with_buf_index_ar( - &self, - index: ns::UInteger, - ) -> &'ar mtl::ArgumentEncoder; - - #[objc::rar_retain()] pub fn new_argument_enc_with_buf_index( &self, index: ns::UInteger, @@ -174,22 +168,11 @@ impl Lib { pub fn fn_names(&self) -> &ns::Array; #[objc::msg_send(newFunctionWithName:)] - pub fn new_fn_ar(&self, name: &ns::String) -> Option<&'ar Fn>; - - #[objc::rar_retain()] pub fn new_fn(&self, name: &ns::String) -> Option>; /// # Safety /// Use new_fn_const_values #[objc::msg_send(newFunctionWithName:constantValues:error:)] - pub unsafe fn new_fn_with_consts_err_ar( - &self, - name: &ns::String, - constant_values: &mtl::FnConstValues, - error: *mut Option<&'ar ns::Error>, - ) -> Option<&'ar Fn>; - - #[objc::rar_retain()] pub unsafe fn new_fn_with_consts_err<'ar>( &self, name: &ns::String, @@ -215,14 +198,6 @@ impl Lib { } #[objc::msg_send(newFunctionWithName:descriptor:error:)] - pub unsafe fn new_fn_with_desc_err_ar( - &self, - name: &ns::String, - descriptor: &mtl::FnDescriptor, - error: &mut Option<&'ar ns::Error>, - ) -> Option<&'ar Fn>; - - #[objc::rar_retain()] pub unsafe fn new_fn_with_desc_err<'ar>( &self, name: &ns::String, diff --git a/cidre/src/mtl/texture.rs b/cidre/src/mtl/texture.rs index f17870b7..2bd003c5 100644 --- a/cidre/src/mtl/texture.rs +++ b/cidre/src/mtl/texture.rs @@ -224,12 +224,6 @@ impl Texture { pub fn parent_texture(&self) -> Option<&Texture>; #[objc::msg_send(newTextureViewWithPixelFormat:)] - pub fn texture_view_with_pixel_format_ar( - &self, - pixel_format: mtl::PixelFormat, - ) -> Option<&'ar Texture>; - - #[objc::rar_retain()] pub fn texture_view_with_pixel_format( &self, pixel_format: mtl::PixelFormat,