Add CommandsListJoin

This commit is contained in:
Pierre Krieger 2016-11-10 15:41:08 +01:00
parent b3ce7729cc
commit c284de4454
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,38 @@
// Copyright (c) 2016 The vulkano developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
// at your option. All files in the project carrying such
// notice may not be copied, modified, or distributed except
// according to those terms.
use command_buffer::CommandsList;
use command_buffer::CommandsListSink;
/// Wraps around two commands lists and joins them together in one list.
#[derive(Debug, Copy, Clone)]
pub struct CommandsListJoin<A, B> where A: CommandsList, B: CommandsList {
// First commands list.
first: A,
// Second commands list.
second: B,
}
impl<A, B> CommandsListJoin<A, B> where A: CommandsList, B: CommandsList {
#[inline]
pub fn new(first: A, second: B) -> CommandsListJoin<A, B> {
CommandsListJoin {
first: first,
second: second,
}
}
}
unsafe impl<A, B> CommandsList for CommandsListJoin<A, B> where A: CommandsList, B: CommandsList {
#[inline]
fn append<'a>(&'a self, builder: &mut CommandsListSink<'a>) {
self.first.append(builder);
self.second.append(builder);
}
}

View File

@ -37,6 +37,7 @@ pub use self::draw::CmdDraw;
pub use self::empty::{empty, EmptyCommandsList};
pub use self::end_render_pass::CmdEndRenderPass;
pub use self::fill_buffer::{CmdFillBuffer, CmdFillBufferError};
pub use self::join::CommandsListJoin;
pub use self::next_subpass::CmdNextSubpass;
pub use self::push_constants::{CmdPushConstants, CmdPushConstantsError};
pub use self::set_state::{CmdSetState};
@ -55,6 +56,7 @@ mod empty;
mod end_render_pass;
//pub mod execute; // TODO: reenable when the concept of a command buffer is well defined
mod fill_buffer;
mod join;
mod next_subpass;
mod push_constants;
mod set_state;
@ -197,6 +199,12 @@ pub unsafe trait CommandsList {
CmdDraw::new(self, pipeline, dynamic, vertices, sets, push_constants)
}
/// Appends another list at the end of this one.
#[inline]
fn join<L>(self, other: L) -> CommandsListJoin<Self, L> where Self: Sized, L: CommandsList {
CommandsListJoin::new(self, other)
}
/// Appends this list of commands at the end of a command buffer in construction.
///
/// The `CommandsListSink` typically represents a command buffer being constructed.