diff --git a/Cargo.toml b/Cargo.toml index 6384c5f..8e6f586 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,9 +35,9 @@ egui_extras = { version = ">=0.24, <=0.27", optional = true, default-features = hashbrown = { version = "0.16.0", optional = true } [target.'cfg(target_vendor = "apple")'.dependencies] -objc2 = { version = "0.6", default-features = false, optional = true } -objc2-foundation = { version = "0.3", default-features = false, optional = true } -objc2-metal = { version = "0.3", default-features = false, features = [ +objc2 = { version = "0.6.3", default-features = false, optional = true } +objc2-foundation = { version = "0.3.2", default-features = false, optional = true } +objc2-metal = { version = "0.3.2", default-features = false, features = [ "MTLAccelerationStructure", "MTLAllocation", "MTLBuffer", @@ -72,7 +72,7 @@ features = [ ] [target.'cfg(target_vendor = "apple")'.dev-dependencies] -objc2-metal = { version = "0.3", default-features = false, features = [ +objc2-metal = { version = "0.3.2", default-features = false, features = [ "MTLPixelFormat", ] } diff --git a/examples/metal-buffer.rs b/examples/metal-buffer.rs index 1d30bbe..b60979b 100644 --- a/examples/metal-buffer.rs +++ b/examples/metal-buffer.rs @@ -99,7 +99,7 @@ fn main() { // Test allocating texture { - let texture_desc = unsafe { MTLTextureDescriptor::new() }; + let texture_desc = MTLTextureDescriptor::new(); texture_desc.setPixelFormat(MTLPixelFormat::RGBA8Unorm); unsafe { texture_desc.setWidth(64) }; unsafe { texture_desc.setHeight(64) }; diff --git a/src/metal/mod.rs b/src/metal/mod.rs index 1397220..a4ee582 100644 --- a/src/metal/mod.rs +++ b/src/metal/mod.rs @@ -261,7 +261,7 @@ impl MemoryType { )?; if let Some(rs) = &self.global_residency_set { - unsafe { rs.addAllocation(mem_block.heap.as_ref()) } + rs.addAllocation(mem_block.heap.as_ref()) } let block_index = self.memory_blocks.iter().position(|block| block.is_none()); @@ -343,7 +343,7 @@ impl MemoryType { )?; if let Some(rs) = &self.global_residency_set { - unsafe { rs.addAllocation(mem_block.heap.as_ref()) } + rs.addAllocation(mem_block.heap.as_ref()) } let new_block_index = if let Some(block_index) = empty_block_index { @@ -411,7 +411,7 @@ impl MemoryType { } if let Some(rs) = &self.global_residency_set { - unsafe { rs.removeAllocation(block.heap.as_ref()) } + rs.removeAllocation(block.heap.as_ref()) } // Note that `block` will be destroyed on `drop` here @@ -425,21 +425,21 @@ impl Allocator { pub fn new(desc: &AllocatorCreateDesc) -> Result { let heap_types = [ (MemoryLocation::GpuOnly, { - let heap_desc = unsafe { MTLHeapDescriptor::new() }; + let heap_desc = MTLHeapDescriptor::new(); heap_desc.setCpuCacheMode(MTLCPUCacheMode::DefaultCache); heap_desc.setStorageMode(MTLStorageMode::Private); heap_desc.setType(MTLHeapType::Placement); heap_desc }), (MemoryLocation::CpuToGpu, { - let heap_desc = unsafe { MTLHeapDescriptor::new() }; + let heap_desc = MTLHeapDescriptor::new(); heap_desc.setCpuCacheMode(MTLCPUCacheMode::WriteCombined); heap_desc.setStorageMode(MTLStorageMode::Shared); heap_desc.setType(MTLHeapType::Placement); heap_desc }), (MemoryLocation::GpuToCpu, { - let heap_desc = unsafe { MTLHeapDescriptor::new() }; + let heap_desc = MTLHeapDescriptor::new(); heap_desc.setCpuCacheMode(MTLCPUCacheMode::DefaultCache); heap_desc.setStorageMode(MTLStorageMode::Shared); heap_desc.setType(MTLHeapType::Placement); @@ -448,13 +448,13 @@ impl Allocator { ]; let global_residency_set = if desc.create_residency_set { - Some(unsafe { - let rs_desc = objc2_metal::MTLResidencySetDescriptor::new(); - rs_desc.setLabel(Some(ns_string!("gpu-allocator global residency set"))); + let rs_desc = objc2_metal::MTLResidencySetDescriptor::new(); + rs_desc.setLabel(Some(ns_string!("gpu-allocator global residency set"))); + Some( desc.device .newResidencySetWithDescriptor_error(&rs_desc) - .expect("Failed to create MTLResidencySet. Unsupported MacOS/iOS version?") - }) + .expect("Failed to create MTLResidencySet. Unsupported MacOS/iOS version?"), + ) } else { None };