Add buildable_state() to commands lists

This commit is contained in:
Pierre Krieger 2016-08-19 14:52:32 +02:00
parent 5a933bc963
commit 97c3a07e83
4 changed files with 23 additions and 0 deletions

View File

@ -116,6 +116,11 @@ unsafe impl<'a, L, Pl, S, Pc> StdCommandsList for DispatchCommand<'a, L, Pl, S,
self.previous.extract_current_image_state(image)
}
#[inline]
fn buildable_state(&self) -> bool {
true
}
unsafe fn raw_build<I, F>(self, additional_elements: F, barriers: I,
mut final_barrier: PipelineBarrierBuilder) -> Self::Output
where F: FnOnce(&mut UnsafeCommandBufferBuilder<L::Pool>),

View File

@ -85,6 +85,11 @@ unsafe impl<P> StdCommandsList for PrimaryCbBuilder<P> where P: CommandPool {
None
}
#[inline]
fn buildable_state(&self) -> bool {
true
}
unsafe fn raw_build<I, F>(self, additional_elements: F, barriers: I,
final_barrier: PipelineBarrierBuilder) -> Self::Output
where F: FnOnce(&mut UnsafeCommandBufferBuilder<Self::Pool>),

View File

@ -66,8 +66,14 @@ pub unsafe trait StdCommandsList {
DispatchCommand::new(self, pipeline, sets, dimensions, push_constants)
}
/// Returns true if the command buffer can be built. This function should always return true,
/// except when we're building a primary command buffer that is inside a render pass.
fn buildable_state(&self) -> bool;
/// Turns the commands list into a command buffer that can be submitted.
fn build(self) -> Self::Output where Self: Sized {
assert!(self.buildable_state());
unsafe {
self.raw_build(|_| {}, iter::empty(), PipelineBarrierBuilder::new())
}
@ -122,6 +128,8 @@ pub unsafe trait StdCommandsList {
/// the command numbers to be inferior to `num_commands`.
/// - `final_barrier` is a pipeline barrier that must be added at the end of the
/// command buffer builder.
///
/// This function doesn't check that `buildable_state` returns true.
unsafe fn raw_build<I, F>(self, additional_elements: F, barriers: I,
final_barrier: PipelineBarrierBuilder) -> Self::Output
where F: FnOnce(&mut UnsafeCommandBufferBuilder<Self::Pool>),

View File

@ -101,6 +101,11 @@ unsafe impl<'a, L, B, D: ?Sized> StdCommandsList for UpdateCommand<'a, L, B, D>
self.previous.check_queue_validity(queue)
}
#[inline]
fn buildable_state(&self) -> bool {
true
}
unsafe fn extract_current_buffer_state<Ob>(&mut self, buffer: &Ob)
-> Option<Ob::CommandListState>
where Ob: TrackedBuffer