-
Notifications
You must be signed in to change notification settings - Fork 549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote command sink in Metal #2260
Changes from 1 commit
d159730
524d026
ecde19c
62d16de
b5266e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,23 +119,32 @@ pub trait DescriptorPool<B: Backend>: Send + Sync + fmt::Debug { | |
/// Descriptors will become invalid once the pool is reset. Usage of invalidated descriptor sets results | ||
/// in undefined behavior. | ||
fn allocate_set(&mut self, layout: &B::DescriptorSetLayout) -> Result<B::DescriptorSet, AllocationError> { | ||
self.allocate_sets(Some(layout)).remove(0) | ||
let mut sets = Vec::with_capacity(1); | ||
self.allocate_sets(Some(layout), &mut sets) | ||
.map(|_| sets.remove(0)) | ||
} | ||
|
||
/// Allocate one or multiple descriptor sets from the pool. | ||
/// | ||
/// Each descriptor set will be allocated from the pool according to the corresponding set layout. | ||
/// Descriptors will become invalid once the pool is reset. Usage of invalidated descriptor sets results | ||
/// in undefined behavior. | ||
fn allocate_sets<I>(&mut self, layouts: I) -> Vec<Result<B::DescriptorSet, AllocationError>> | ||
fn allocate_sets<I>(&mut self, layouts: I, sets: &mut Vec<B::DescriptorSet>) -> Result<(), AllocationError> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this signature could be confusing. For example, it's unclear from the signature whether the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took a few attempts to make this API nicer before, and failed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be cool to figure this out, because I think we could use that pattern in a few places. Anyway I don't think it's worth holding up this PR, we can change it later if we figure it out (or if |
||
where | ||
I: IntoIterator, | ||
I::Item: Borrow<B::DescriptorSetLayout>, | ||
{ | ||
layouts | ||
.into_iter() | ||
.map(|layout| self.allocate_set(layout.borrow())) | ||
.collect() | ||
let base = sets.len(); | ||
for layout in layouts { | ||
match self.allocate_set(layout.borrow()) { | ||
Ok(set) => sets.push(set), | ||
Err(e) => { | ||
self.free_sets(sets.drain(base ..)); | ||
return Err(e) | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} | ||
|
||
/// Free the given descriptor sets provided as an iterator. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change isn't part of this PR, but
layout_bindinds
is a typo here