Skip to content

Commit

Permalink
Merge #2183
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bors[bot] and kvark committed Jun 28, 2018
2 parents 8a39ce4 + 1f9b40e commit bf3948a
Show file tree
Hide file tree
Showing 12 changed files with 668 additions and 507 deletions.
3 changes: 2 additions & 1 deletion src/backend/auxil/range_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ where
pub fn new(range: Range<T>) -> Self {
RangeAllocator {
initial_range: range.clone(),
free_ranges: vec![range.clone()],
free_ranges: vec![range],
}
}

pub fn allocate_range(&mut self, length: T) -> Option<Range<T>> {
assert_ne!(length + length, length);
let mut best_fit: Option<(usize, Range<T>)> = None;
for (index, range) in self.free_ranges.iter().cloned().enumerate() {
let range_length = range.end - range.start;
Expand Down
5 changes: 4 additions & 1 deletion src/backend/dx11/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,10 @@ impl hal::DescriptorPool<Backend> for DescriptorPool {
Ok(DescriptorSet::new())
}

fn free_sets(&mut self, descriptor_sets: &[DescriptorSet]) {
fn free_sets<I>(&mut self, _descriptor_sets: I)
where
I: IntoIterator<Item = DescriptorSet>
{
unimplemented!()
}

Expand Down
5 changes: 4 additions & 1 deletion src/backend/dx12/src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,10 @@ impl HalDescriptorPool<Backend> for DescriptorPool {
})
}

fn free_sets(&mut self, descriptor_sets: &[DescriptorSet]) {
fn free_sets<I>(&mut self, descriptor_sets: I)
where
I: IntoIterator<Item = DescriptorSet>
{
for descriptor_set in descriptor_sets {
for binding_info in &descriptor_set.binding_infos {
if let Some(ref view_range) = binding_info.view_range {
Expand Down
5 changes: 4 additions & 1 deletion src/backend/empty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,10 @@ impl command::RawCommandBuffer<Backend> for RawCommandBuffer {
#[derive(Debug)]
pub struct DescriptorPool;
impl pso::DescriptorPool<Backend> for DescriptorPool {
fn free_sets(&mut self, _descriptor_sets: &[()]) {
fn free_sets<I>(&mut self, _descriptor_sets: I)
where
I: IntoIterator<Item = ()>
{
unimplemented!()
}

Expand Down
5 changes: 4 additions & 1 deletion src/backend/gl/src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ impl pso::DescriptorPool<Backend> for DescriptorPool {
})).collect()
}

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

Expand Down
Loading

0 comments on commit bf3948a

Please sign in to comment.