Skip to content

Commit 2ec2298

Browse files
committed
Clean up in-crate use statements
1 parent b0d15c6 commit 2ec2298

File tree

3 files changed

+35
-27
lines changed

3 files changed

+35
-27
lines changed

src/d3d12/mod.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ mod visualizer;
2020
#[cfg(feature = "visualizer")]
2121
pub use visualizer::AllocatorVisualizer;
2222

23-
use super::{allocator, allocator::AllocationType};
2423
use crate::{
25-
allocator::{AllocatorReport, MemoryBlockReport},
24+
allocator::{
25+
AllocationType, AllocatorReport, DedicatedBlockAllocator, FreeListAllocator,
26+
MemoryBlockReport, SubAllocator,
27+
},
2628
AllocationError, AllocationSizes, AllocatorDebugSettings, MemoryLocation, Result,
2729
};
2830

@@ -257,7 +259,7 @@ impl Allocation {
257259
struct MemoryBlock {
258260
heap: ID3D12Heap,
259261
size: u64,
260-
sub_allocator: Box<dyn allocator::SubAllocator>,
262+
sub_allocator: Box<dyn SubAllocator>,
261263
}
262264
impl MemoryBlock {
263265
fn new(
@@ -297,10 +299,10 @@ impl MemoryBlock {
297299
}?
298300
};
299301

300-
let sub_allocator: Box<dyn allocator::SubAllocator> = if dedicated {
301-
Box::new(allocator::DedicatedBlockAllocator::new(size))
302+
let sub_allocator: Box<dyn SubAllocator> = if dedicated {
303+
Box::new(DedicatedBlockAllocator::new(size))
302304
} else {
303-
Box::new(allocator::FreeListAllocator::new(size))
305+
Box::new(FreeListAllocator::new(size))
304306
};
305307

306308
Ok(Self {

src/metal/mod.rs

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
use std::{backtrace::Backtrace, sync::Arc};
22

3-
#[cfg(feature = "visualizer")]
4-
mod visualizer;
5-
#[cfg(feature = "visualizer")]
6-
pub use visualizer::AllocatorVisualizer;
7-
83
use log::debug;
94
use objc2::{rc::Retained, runtime::ProtocolObject};
105
use objc2_foundation::NSString;
@@ -13,8 +8,16 @@ use objc2_metal::{
138
MTLStorageMode, MTLTextureDescriptor,
149
};
1510

11+
#[cfg(feature = "visualizer")]
12+
mod visualizer;
13+
#[cfg(feature = "visualizer")]
14+
pub use visualizer::AllocatorVisualizer;
15+
1616
use crate::{
17-
allocator::{self, AllocatorReport, MemoryBlockReport},
17+
allocator::{
18+
AllocationType, AllocatorReport, DedicatedBlockAllocator, FreeListAllocator,
19+
MemoryBlockReport, SubAllocator,
20+
},
1821
AllocationError, AllocationSizes, AllocatorDebugSettings, MemoryLocation, Result,
1922
};
2023

@@ -175,7 +178,7 @@ pub struct CommittedAllocationStatistics {
175178
struct MemoryBlock {
176179
heap: Retained<ProtocolObject<dyn MTLHeap>>,
177180
size: u64,
178-
sub_allocator: Box<dyn allocator::SubAllocator>,
181+
sub_allocator: Box<dyn SubAllocator>,
179182
}
180183

181184
impl MemoryBlock {
@@ -196,10 +199,10 @@ impl MemoryBlock {
196199
"MemoryBlock {memory_location:?}"
197200
))));
198201

199-
let sub_allocator: Box<dyn allocator::SubAllocator> = if dedicated {
200-
Box::new(allocator::DedicatedBlockAllocator::new(size))
202+
let sub_allocator: Box<dyn SubAllocator> = if dedicated {
203+
Box::new(DedicatedBlockAllocator::new(size))
201204
} else {
202-
Box::new(allocator::FreeListAllocator::new(size))
205+
Box::new(FreeListAllocator::new(size))
203206
};
204207

205208
Ok(Self {
@@ -228,7 +231,7 @@ impl MemoryType {
228231
backtrace: Arc<Backtrace>,
229232
allocation_sizes: &AllocationSizes,
230233
) -> Result<Allocation> {
231-
let allocation_type = allocator::AllocationType::Linear;
234+
let allocation_type = AllocationType::Linear;
232235

233236
let is_host = self.heap_properties.storageMode() != MTLStorageMode::Private;
234237
let memblock_size = allocation_sizes.get_memblock_size(is_host, self.active_general_blocks);

src/vulkan/mod.rs

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
#[cfg(feature = "visualizer")]
2-
mod visualizer;
31
use std::{backtrace::Backtrace, fmt, marker::PhantomData, sync::Arc};
42

53
use ash::vk;
64
use log::{debug, Level};
5+
6+
#[cfg(feature = "visualizer")]
7+
mod visualizer;
78
#[cfg(feature = "visualizer")]
89
pub use visualizer::AllocatorVisualizer;
910

10-
use super::allocator;
1111
use crate::{
12-
allocator::{AllocatorReport, MemoryBlockReport},
12+
allocator::{
13+
AllocationType, AllocatorReport, DedicatedBlockAllocator, FreeListAllocator,
14+
MemoryBlockReport, SubAllocator,
15+
},
1316
AllocationError, AllocationSizes, AllocatorDebugSettings, MemoryLocation, Result,
1417
};
1518

@@ -337,7 +340,7 @@ pub(crate) struct MemoryBlock {
337340
pub(crate) device_memory: vk::DeviceMemory,
338341
pub(crate) size: u64,
339342
pub(crate) mapped_ptr: Option<SendSyncPtr>,
340-
pub(crate) sub_allocator: Box<dyn allocator::SubAllocator>,
343+
pub(crate) sub_allocator: Box<dyn SubAllocator>,
341344
#[cfg(feature = "visualizer")]
342345
pub(crate) dedicated_allocation: bool,
343346
}
@@ -411,13 +414,13 @@ impl MemoryBlock {
411414
})
412415
.transpose()?;
413416

414-
let sub_allocator: Box<dyn allocator::SubAllocator> = if allocation_scheme
417+
let sub_allocator: Box<dyn SubAllocator> = if allocation_scheme
415418
!= AllocationScheme::GpuAllocatorManaged
416419
|| requires_personal_block
417420
{
418-
Box::new(allocator::DedicatedBlockAllocator::new(size))
421+
Box::new(DedicatedBlockAllocator::new(size))
419422
} else {
420-
Box::new(allocator::FreeListAllocator::new(size))
423+
Box::new(FreeListAllocator::new(size))
421424
};
422425

423426
Ok(Self {
@@ -460,9 +463,9 @@ impl MemoryType {
460463
allocation_sizes: &AllocationSizes,
461464
) -> Result<Allocation> {
462465
let allocation_type = if desc.linear {
463-
allocator::AllocationType::Linear
466+
AllocationType::Linear
464467
} else {
465-
allocator::AllocationType::NonLinear
468+
AllocationType::NonLinear
466469
};
467470

468471
let is_host = self

0 commit comments

Comments
 (0)