Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
] }

Expand Down
2 changes: 1 addition & 1 deletion examples/metal-buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) };
Expand Down
22 changes: 11 additions & 11 deletions src/metal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -425,21 +425,21 @@ impl Allocator {
pub fn new(desc: &AllocatorCreateDesc) -> Result<Self> {
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);
Expand All @@ -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
};
Expand Down