File tree 7 files changed +14
-33
lines changed
dedicated_block_allocator
7 files changed +14
-33
lines changed Original file line number Diff line number Diff line change @@ -68,11 +68,11 @@ fn create_d3d12_device(
68
68
)
69
69
} ;
70
70
match hr {
71
- winapi :: shared :: winerror:: S_OK => {
71
+ winerror:: S_OK => {
72
72
info ! ( "Using D3D12 feature level: {}." , feature_level_name) ;
73
73
Some ( device)
74
74
}
75
- winapi :: shared :: winerror:: E_NOINTERFACE => {
75
+ winerror:: E_NOINTERFACE => {
76
76
error ! ( "ID3D12Device interface not supported." ) ;
77
77
None
78
78
}
@@ -106,11 +106,7 @@ fn main() {
106
106
)
107
107
} ;
108
108
109
- assert_eq ! (
110
- hr,
111
- winapi:: shared:: winerror:: S_OK ,
112
- "Failed to create DXGI factory" ,
113
- ) ;
109
+ assert_eq ! ( hr, winerror:: S_OK , "Failed to create DXGI factory" , ) ;
114
110
dxgi_factory
115
111
} ;
116
112
Original file line number Diff line number Diff line change @@ -122,10 +122,6 @@ impl SubAllocator for DedicatedBlockAllocator {
122
122
} ]
123
123
}
124
124
125
- fn size ( & self ) -> u64 {
126
- self . size
127
- }
128
-
129
125
fn allocated ( & self ) -> u64 {
130
126
self . allocated
131
127
}
Original file line number Diff line number Diff line change @@ -405,10 +405,6 @@ impl SubAllocator for FreeListAllocator {
405
405
. collect :: < Vec < _ > > ( )
406
406
}
407
407
408
- fn size ( & self ) -> u64 {
409
- self . size
410
- }
411
-
412
408
fn allocated ( & self ) -> u64 {
413
409
self . allocated
414
410
}
Original file line number Diff line number Diff line change @@ -73,16 +73,8 @@ pub(crate) trait SubAllocator: SubAllocatorBase + std::fmt::Debug + Sync + Send
73
73
#[ must_use]
74
74
fn supports_general_allocations ( & self ) -> bool ;
75
75
#[ must_use]
76
- fn size ( & self ) -> u64 ;
77
- #[ must_use]
78
76
fn allocated ( & self ) -> u64 ;
79
77
80
- /// Helper function: reports how much memory is available in this suballocator
81
- #[ must_use]
82
- fn available_memory ( & self ) -> u64 {
83
- self . size ( ) - self . allocated ( )
84
- }
85
-
86
78
/// Helper function: reports if the suballocator is empty (meaning, having no allocations).
87
79
#[ must_use]
88
80
fn is_empty ( & self ) -> bool {
Original file line number Diff line number Diff line change @@ -271,12 +271,16 @@ pub struct AllocatorCreateDesc {
271
271
}
272
272
273
273
pub enum ResourceType < ' a > {
274
- /// Allocation equivalent to Dx12's CommittedResource.
274
+ /// Create a D3D12 [`CommittedResource`].
275
+ ///
276
+ /// [`CommittedResource`]: https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-createcommittedresource
275
277
Committed {
276
278
heap_properties : & ' a D3D12_HEAP_PROPERTIES ,
277
279
heap_flags : D3D12_HEAP_FLAGS ,
278
280
} ,
279
- /// Allocation equivalent to Dx12's PlacedResource.
281
+ /// Create a D3D12 [`PlacedResource`].
282
+ ///
283
+ /// [`PlacedResource`]: https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-createplacedresource
280
284
Placed ,
281
285
}
282
286
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ impl AllocatorVisualizer {
92
92
let mut total_allocated = 0 ;
93
93
94
94
for block in mem_type. memory_blocks . iter ( ) . flatten ( ) {
95
- total_block_size += block. sub_allocator . size ( ) ;
95
+ total_block_size += block. size ;
96
96
total_allocated += block. sub_allocator . allocated ( ) ;
97
97
}
98
98
@@ -134,10 +134,7 @@ impl AllocatorVisualizer {
134
134
let Some ( block) = block else { continue } ;
135
135
136
136
ui. collapsing ( format ! ( "Block: {}" , block_idx) , |ui| {
137
- ui. label ( format ! (
138
- "size: {} KiB" ,
139
- block. sub_allocator. size( ) / 1024
140
- ) ) ;
137
+ ui. label ( format ! ( "size: {} KiB" , block. size / 1024 ) ) ;
141
138
ui. label ( format ! (
142
139
"allocated: {} KiB" ,
143
140
block. sub_allocator. allocated( ) / 1024
@@ -205,7 +202,7 @@ impl AllocatorVisualizer {
205
202
"Memory type {}, Memory block {}, Block size: {} KiB" ,
206
203
window. memory_type_index,
207
204
window. block_index,
208
- memblock. sub_allocator . size( ) / 1024
205
+ memblock. size / 1024
209
206
) ) ;
210
207
211
208
window
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ unsafe impl Sync for SendSyncPtr {}
58
58
pub struct AllocatorCreateDesc {
59
59
pub instance : ash:: Instance ,
60
60
pub device : ash:: Device ,
61
- pub physical_device : ash :: vk:: PhysicalDevice ,
61
+ pub physical_device : vk:: PhysicalDevice ,
62
62
pub debug_settings : AllocatorDebugSettings ,
63
63
pub buffer_device_address : bool ,
64
64
pub allocation_sizes : AllocationSizes ,
@@ -737,7 +737,7 @@ impl fmt::Debug for Allocator {
737
737
738
738
impl Allocator {
739
739
pub fn new ( desc : & AllocatorCreateDesc ) -> Result < Self > {
740
- if desc. physical_device == ash :: vk:: PhysicalDevice :: null ( ) {
740
+ if desc. physical_device == vk:: PhysicalDevice :: null ( ) {
741
741
return Err ( AllocationError :: InvalidAllocatorCreateDesc (
742
742
"AllocatorCreateDesc field `physical_device` is null." . into ( ) ,
743
743
) ) ;
You can’t perform that action at this time.
0 commit comments