Skip to content

Commit d27a627

Browse files
authored
Merge branch 'main' into no-std-support
2 parents d73de57 + 642dc91 commit d27a627

File tree

4 files changed

+51
-12
lines changed

4 files changed

+51
-12
lines changed

src/allocator/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ pub struct AllocatorReport {
6666
pub blocks: Vec<MemoryBlockReport>,
6767
/// Sum of the memory used by all allocations, in bytes.
6868
pub total_allocated_bytes: u64,
69-
/// Sum of the memory reserved by all memory blocks including unallocated regions, in bytes.
70-
pub total_reserved_bytes: u64,
69+
/// Sum of the memory capacity of all memory blocks including unallocated regions, in bytes.
70+
pub total_capacity_bytes: u64,
7171
}
7272

7373
impl fmt::Debug for AllocationReport {
@@ -95,7 +95,7 @@ impl fmt::Debug for AllocatorReport {
9595
&core::format_args!(
9696
"{} / {}",
9797
fmt_bytes(self.total_allocated_bytes),
98-
fmt_bytes(self.total_reserved_bytes)
98+
fmt_bytes(self.total_capacity_bytes)
9999
),
100100
)
101101
.field("blocks", &self.blocks.len())

src/d3d12/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,11 +1141,11 @@ impl Allocator {
11411141
pub fn generate_report(&self) -> AllocatorReport {
11421142
let mut allocations = vec![];
11431143
let mut blocks = vec![];
1144-
let mut total_reserved_bytes = 0;
1144+
let mut total_capacity_bytes = 0;
11451145

11461146
for memory_type in &self.memory_types {
11471147
for block in memory_type.memory_blocks.iter().flatten() {
1148-
total_reserved_bytes += block.size;
1148+
total_capacity_bytes += block.size;
11491149
let first_allocation = allocations.len();
11501150
allocations.extend(block.sub_allocator.report_allocations());
11511151
blocks.push(MemoryBlockReport {
@@ -1161,9 +1161,22 @@ impl Allocator {
11611161
allocations,
11621162
blocks,
11631163
total_allocated_bytes,
1164-
total_reserved_bytes,
1164+
total_capacity_bytes,
11651165
}
11661166
}
1167+
1168+
/// Current total capacity of memory blocks allocated on the device, in bytes
1169+
pub fn capacity(&self) -> u64 {
1170+
let mut total_capacity_bytes = 0;
1171+
1172+
for memory_type in &self.memory_types {
1173+
for block in memory_type.memory_blocks.iter().flatten() {
1174+
total_capacity_bytes += block.size;
1175+
}
1176+
}
1177+
1178+
total_capacity_bytes
1179+
}
11671180
}
11681181

11691182
impl fmt::Debug for Allocator {

src/metal/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,11 @@ impl Allocator {
534534
pub fn generate_report(&self) -> AllocatorReport {
535535
let mut allocations = vec![];
536536
let mut blocks = vec![];
537-
let mut total_reserved_bytes = 0;
537+
let mut total_capacity_bytes = 0;
538538

539539
for memory_type in &self.memory_types {
540540
for block in memory_type.memory_blocks.iter().flatten() {
541-
total_reserved_bytes += block.size;
541+
total_capacity_bytes += block.size;
542542
let first_allocation = allocations.len();
543543
allocations.extend(block.sub_allocator.report_allocations());
544544
blocks.push(MemoryBlockReport {
@@ -554,7 +554,20 @@ impl Allocator {
554554
allocations,
555555
blocks,
556556
total_allocated_bytes,
557-
total_reserved_bytes,
557+
total_capacity_bytes,
558558
}
559559
}
560+
561+
/// Current total capacity of memory blocks allocated on the device, in bytes
562+
pub fn capacity(&self) -> u64 {
563+
let mut total_capacity_bytes = 0;
564+
565+
for memory_type in &self.memory_types {
566+
for block in memory_type.memory_blocks.iter().flatten() {
567+
total_capacity_bytes += block.size;
568+
}
569+
}
570+
571+
total_capacity_bytes
572+
}
560573
}

src/vulkan/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -948,11 +948,11 @@ impl Allocator {
948948
pub fn generate_report(&self) -> AllocatorReport {
949949
let mut allocations = vec![];
950950
let mut blocks = vec![];
951-
let mut total_reserved_bytes = 0;
951+
let mut total_capacity_bytes = 0;
952952

953953
for memory_type in &self.memory_types {
954954
for block in memory_type.memory_blocks.iter().flatten() {
955-
total_reserved_bytes += block.size;
955+
total_capacity_bytes += block.size;
956956
let first_allocation = allocations.len();
957957
allocations.extend(block.sub_allocator.report_allocations());
958958
blocks.push(MemoryBlockReport {
@@ -968,9 +968,22 @@ impl Allocator {
968968
allocations,
969969
blocks,
970970
total_allocated_bytes,
971-
total_reserved_bytes,
971+
total_capacity_bytes,
972972
}
973973
}
974+
975+
/// Current total capacity of memory blocks allocated on the device, in bytes
976+
pub fn capacity(&self) -> u64 {
977+
let mut total_capacity_bytes = 0;
978+
979+
for memory_type in &self.memory_types {
980+
for block in memory_type.memory_blocks.iter().flatten() {
981+
total_capacity_bytes += block.size;
982+
}
983+
}
984+
985+
total_capacity_bytes
986+
}
974987
}
975988

976989
impl Drop for Allocator {

0 commit comments

Comments
 (0)