Skip to content

Commit bf3948a

Browse files
bors[bot]kvark
andcommitted
Merge #2183
2183: Heap-less descriptor sets in Metal r=grovesNL a=kvark Fixes the heap allocations in descriptor sets, to help #2161. Edit: the improvement is there, but it's not the one we were looking for. Adds real value semantics for the `DescriptorPool`, which now owns the allocation and has the actual descriptor sets pointing to it. PR checklist: - [x] `make` succeeds (on *nix) - [x] `make reftests` succeeds - [x] tested examples with the following backends: metal ~~Note: it doesn't work correctly yet, but I'd be happy to get the review comments and notes. Perhaps, you can spot the mistake? ;) Sadly, my CTS is non-operational atm, so it's not easy to figure out a test case. Note2: the individual commits are not build-able. Will squash once finished.~~ Co-authored-by: Dzmitry Malyshau <[email protected]>
2 parents 8a39ce4 + 1f9b40e commit bf3948a

File tree

12 files changed

+668
-507
lines changed

12 files changed

+668
-507
lines changed

src/backend/auxil/range_alloc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ where
1919
pub fn new(range: Range<T>) -> Self {
2020
RangeAllocator {
2121
initial_range: range.clone(),
22-
free_ranges: vec![range.clone()],
22+
free_ranges: vec![range],
2323
}
2424
}
2525

2626
pub fn allocate_range(&mut self, length: T) -> Option<Range<T>> {
27+
assert_ne!(length + length, length);
2728
let mut best_fit: Option<(usize, Range<T>)> = None;
2829
for (index, range) in self.free_ranges.iter().cloned().enumerate() {
2930
let range_length = range.end - range.start;

src/backend/dx11/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,10 @@ impl hal::DescriptorPool<Backend> for DescriptorPool {
15251525
Ok(DescriptorSet::new())
15261526
}
15271527

1528-
fn free_sets(&mut self, descriptor_sets: &[DescriptorSet]) {
1528+
fn free_sets<I>(&mut self, _descriptor_sets: I)
1529+
where
1530+
I: IntoIterator<Item = DescriptorSet>
1531+
{
15291532
unimplemented!()
15301533
}
15311534

src/backend/dx12/src/native.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,10 @@ impl HalDescriptorPool<Backend> for DescriptorPool {
494494
})
495495
}
496496

497-
fn free_sets(&mut self, descriptor_sets: &[DescriptorSet]) {
497+
fn free_sets<I>(&mut self, descriptor_sets: I)
498+
where
499+
I: IntoIterator<Item = DescriptorSet>
500+
{
498501
for descriptor_set in descriptor_sets {
499502
for binding_info in &descriptor_set.binding_infos {
500503
if let Some(ref view_range) = binding_info.view_range {

src/backend/empty/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,10 @@ impl command::RawCommandBuffer<Backend> for RawCommandBuffer {
755755
#[derive(Debug)]
756756
pub struct DescriptorPool;
757757
impl pso::DescriptorPool<Backend> for DescriptorPool {
758-
fn free_sets(&mut self, _descriptor_sets: &[()]) {
758+
fn free_sets<I>(&mut self, _descriptor_sets: I)
759+
where
760+
I: IntoIterator<Item = ()>
761+
{
759762
unimplemented!()
760763
}
761764

src/backend/gl/src/native.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ impl pso::DescriptorPool<Backend> for DescriptorPool {
185185
})).collect()
186186
}
187187

188-
fn free_sets(&mut self, _descriptor_sets: &[DescriptorSet]) {
188+
fn free_sets<I>(&mut self, _descriptor_sets: I)
189+
where
190+
I: IntoIterator<Item = DescriptorSet>
191+
{
189192
// Poof! Does nothing, because OpenGL doesn't have a meaningful concept of a `DescriptorSet`.
190193
}
191194

0 commit comments

Comments
 (0)