diff --git a/vulkano/src/memory/allocator/mod.rs b/vulkano/src/memory/allocator/mod.rs index 07dc53c8..a1bca1e1 100644 --- a/vulkano/src/memory/allocator/mod.rs +++ b/vulkano/src/memory/allocator/mod.rs @@ -716,14 +716,6 @@ pub struct MemoryAlloc { /// allocation. pub suballocation: Option, - /// The type of resources that can be bound to this memory block. This will be exactly equal to - /// the requested allocation type. - /// - /// For dedicated allocations it doesn't matter what this is, as there aren't going to be any - /// neighboring suballocations. Therefore the allocator implementation is advised to always set - /// this to [`AllocationType::Unknown`] in that case for maximum flexibility. - pub allocation_type: AllocationType, - /// An opaque handle identifying the allocation inside the allocator. pub allocation_handle: AllocationHandle, } @@ -1443,7 +1435,6 @@ unsafe impl MemoryAllocator for GenericMemoryA Ok(MemoryAlloc { device_memory, suballocation: None, - allocation_type: AllocationType::Unknown, allocation_handle: AllocationHandle(ptr::null_mut()), }) } @@ -1567,7 +1558,6 @@ impl Block { Ok(MemoryAlloc { device_memory: self.device_memory.clone(), suballocation: Some(suballocation), - allocation_type, allocation_handle: AllocationHandle(self as *const Block as _), }) } diff --git a/vulkano/src/memory/allocator/suballocator.rs b/vulkano/src/memory/allocator/suballocator.rs index db2e591f..05aca577 100644 --- a/vulkano/src/memory/allocator/suballocator.rs +++ b/vulkano/src/memory/allocator/suballocator.rs @@ -207,6 +207,10 @@ pub struct Suballocation { /// The size of the allocation. This will be exactly equal to the requested size. pub size: DeviceSize, + /// The type of resources that can be bound to this memory block. This will be exactly equal to + /// the requested allocation type. + pub allocation_type: AllocationType, + /// An opaque handle identifying the allocation within the allocator. pub handle: AllocationHandle, } @@ -404,6 +408,7 @@ unsafe impl Suballocator for FreeListAllocator { return Ok(Suballocation { offset, size, + allocation_type, handle: AllocationHandle(id.get() as _), }); } @@ -885,6 +890,7 @@ unsafe impl Suballocator for BuddyAllocator { return Ok(Suballocation { offset, size: layout.size(), + allocation_type, handle: AllocationHandle(min_order as _), }); } @@ -1090,6 +1096,7 @@ unsafe impl Suballocator for BumpAllocator { Ok(Suballocation { offset, size, + allocation_type, handle: AllocationHandle(ptr::null_mut()), }) } diff --git a/vulkano/src/memory/mod.rs b/vulkano/src/memory/mod.rs index c7d624b9..5ddccf80 100644 --- a/vulkano/src/memory/mod.rs +++ b/vulkano/src/memory/mod.rs @@ -180,7 +180,7 @@ impl ResourceMemory { ResourceMemory { offset: suballocation.offset, size: suballocation.size, - allocation_type: allocation.allocation_type, + allocation_type: suballocation.allocation_type, allocation_handle: allocation.allocation_handle, suballocation_handle: Some(suballocation.handle), allocator: Some(allocator), @@ -190,7 +190,7 @@ impl ResourceMemory { ResourceMemory { offset: 0, size: allocation.device_memory.allocation_size(), - allocation_type: allocation.allocation_type, + allocation_type: AllocationType::Unknown, allocation_handle: allocation.allocation_handle, suballocation_handle: None, allocator: Some(allocator), @@ -242,6 +242,7 @@ impl ResourceMemory { self.suballocation_handle.map(|handle| Suballocation { offset: self.offset, size: self.size, + allocation_type: self.allocation_type, handle, }) } @@ -426,7 +427,6 @@ impl Drop for ResourceMemory { let allocation = MemoryAlloc { device_memory, suballocation: self.suballocation(), - allocation_type: self.allocation_type, allocation_handle: self.allocation_handle, };