Add an ability to downgrade CommandBuffer mutable reference.
//!
use Backend;
+use queue::capability::Supports;
use std::marker::PhantomData;
mod compute;
@@ -47,6 +48,17 @@ impl<'a, B: Backend, C> CommandBuffer<'a, B, C> {
pub fn finish(self) -> Submit<B, C> {
unsafe { Submit::new(self) }
}
+
+ /// Downgrade a command buffer to a lesser capability type.
+ ///
+ /// This is safe as you can't `submit` downgraded version since `submit`
+ /// requires `self` by move.
+ pub fn downgrade<D>(&mut self) -> &mut CommandBuffer<'a, B, D>
+ where
+ C: Supports<D>
+ {
+ unsafe { ::std::mem::transmute(self) }
+ }
}
impl<'a, B: Backend, C> Drop for CommandBuffer<'a, B, C> {
