Skip to content

Commit

Permalink
metal: Use our own MemoryLocation for MTLHeap (MemoryBlock) labels
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Jun 12, 2024
1 parent 91a839d commit b1407d5
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/metal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,12 @@ impl MemoryBlock {
size: u64,
heap_descriptor: &metal::HeapDescriptor,
dedicated: bool,
memory_location: MemoryLocation,
) -> Result<Self> {
heap_descriptor.set_size(size);

let heap = Arc::new(device.new_heap(heap_descriptor));
heap.set_label(&format!(
"MemoryBlock {:?}",
heap_descriptor.resource_options(),
));
heap.set_label(&format!("MemoryBlock {memory_location:?}"));

let sub_allocator: Box<dyn allocator::SubAllocator> = if dedicated {
Box::new(allocator::DedicatedBlockAllocator::new(size))
Expand Down Expand Up @@ -218,7 +216,13 @@ impl MemoryType {

// Create a dedicated block for large memory allocations
if size > memblock_size {
let mem_block = MemoryBlock::new(device, size, &self.heap_properties, true)?;
let mem_block = MemoryBlock::new(
device,
size,
&self.heap_properties,
true,
self.memory_location,
)?;

let block_index = self.memory_blocks.iter().position(|block| block.is_none());
let block_index = match block_index {
Expand Down Expand Up @@ -288,8 +292,13 @@ impl MemoryType {
}
}

let new_memory_block =
MemoryBlock::new(device, memblock_size, &self.heap_properties, false)?;
let new_memory_block = MemoryBlock::new(
device,
memblock_size,
&self.heap_properties,
false,
self.memory_location,
)?;

let new_block_index = if let Some(block_index) = empty_block_index {
self.memory_blocks[block_index] = Some(new_memory_block);
Expand Down

0 comments on commit b1407d5

Please sign in to comment.