mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-26 08:45:59 +00:00
More work on SubmitSyncBuilderLayer
This commit is contained in:
parent
711b261a03
commit
e43b8c2b92
@ -41,6 +41,7 @@ pub struct SubmitSyncBuilderLayer<I> {
|
||||
}
|
||||
|
||||
impl<I> SubmitSyncBuilderLayer<I> {
|
||||
/// Builds a new layer that wraps around an existing builder.
|
||||
#[inline]
|
||||
pub fn new(inner: I) -> SubmitSyncBuilderLayer<I> {
|
||||
SubmitSyncBuilderLayer {
|
||||
@ -49,6 +50,30 @@ impl<I> SubmitSyncBuilderLayer<I> {
|
||||
images: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a buffer to the list.
|
||||
fn add_buffer<B>(&mut self, buffer: &B, exclusive: bool)
|
||||
where B: Buffer + Clone + 'static
|
||||
{
|
||||
for &mut (ref existing_buf, ref mut existing_exclusive) in self.buffers.iter_mut() {
|
||||
if existing_buf.conflicts_buffer(0, existing_buf.size(), buffer, 0, buffer.size()) {
|
||||
*existing_exclusive = *existing_exclusive || exclusive;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: compare with images as well
|
||||
|
||||
self.buffers.push((Box::new(buffer.clone()), exclusive));
|
||||
}
|
||||
|
||||
// Adds an image to the list.
|
||||
fn add_image<T>(&mut self, image: &T, exclusive: bool)
|
||||
where T: Image + Clone + 'static
|
||||
{
|
||||
// FIXME: actually implement
|
||||
self.images.push((Box::new(image.clone()), exclusive));
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O> CommandBufferBuild for SubmitSyncBuilderLayer<I>
|
||||
@ -80,6 +105,7 @@ unsafe impl<I> CommandBufferBuilder for SubmitSyncBuilderLayer<I>
|
||||
{
|
||||
}
|
||||
|
||||
// FIXME: implement manually
|
||||
macro_rules! pass_through {
|
||||
(($($param:ident),*), $cmd:ty) => {
|
||||
unsafe impl<'a, I, O $(, $param)*> AddCommand<$cmd> for SubmitSyncBuilderLayer<I>
|
||||
@ -99,25 +125,11 @@ macro_rules! pass_through {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: implement manually
|
||||
pass_through!((Rp, F), cmd::CmdBeginRenderPass<Rp, F>);
|
||||
pass_through!((S, Pl), cmd::CmdBindDescriptorSets<S, Pl>);
|
||||
pass_through!((Pl), cmd::CmdBindPipeline<Pl>);
|
||||
pass_through!((V), cmd::CmdBindVertexBuffers<V>);
|
||||
pass_through!((S, D), cmd::CmdBlitImage<S, D>);
|
||||
pass_through!((), cmd::CmdClearAttachments);
|
||||
pass_through!((S, D), cmd::CmdCopyBuffer<S, D>);
|
||||
pass_through!((S, D), cmd::CmdCopyBufferToImage<S, D>);
|
||||
pass_through!((S, D), cmd::CmdCopyImage<S, D>);
|
||||
pass_through!((), cmd::CmdDispatchRaw);
|
||||
pass_through!((), cmd::CmdDrawRaw);
|
||||
pass_through!((), cmd::CmdEndRenderPass);
|
||||
pass_through!((C), cmd::CmdExecuteCommands<C>);
|
||||
pass_through!((B), cmd::CmdFillBuffer<B>);
|
||||
pass_through!((), cmd::CmdNextSubpass);
|
||||
pass_through!((Pc, Pl), cmd::CmdPushConstants<Pc, Pl>);
|
||||
pass_through!((S, D), cmd::CmdResolveImage<S, D>);
|
||||
pass_through!((), cmd::CmdSetEvent);
|
||||
pass_through!((B, D), cmd::CmdUpdateBuffer<'a, B, D>);
|
||||
|
||||
unsafe impl<I, O, B> AddCommand<cmd::CmdBindIndexBuffer<B>> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdBindIndexBuffer<B>, Out = O>,
|
||||
@ -127,7 +139,7 @@ unsafe impl<I, O, B> AddCommand<cmd::CmdBindIndexBuffer<B>> for SubmitSyncBuilde
|
||||
|
||||
#[inline]
|
||||
fn add(mut self, command: cmd::CmdBindIndexBuffer<B>) -> Self::Out {
|
||||
self.buffers.push((Box::new(command.buffer().clone()), false));
|
||||
self.add_buffer(command.buffer(), false);
|
||||
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
@ -137,6 +149,244 @@ unsafe impl<I, O, B> AddCommand<cmd::CmdBindIndexBuffer<B>> for SubmitSyncBuilde
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O, P> AddCommand<cmd::CmdBindPipeline<P>> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdBindPipeline<P>, Out = O>
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(self, command: cmd::CmdBindPipeline<P>) -> Self::Out {
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O, S, D> AddCommand<cmd::CmdBlitImage<S, D>> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdBlitImage<S, D>, Out = O>,
|
||||
S: Image + Clone + 'static,
|
||||
D: Image + Clone + 'static
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(mut self, command: cmd::CmdBlitImage<S, D>) -> Self::Out {
|
||||
self.add_image(command.source(), false);
|
||||
self.add_image(command.destination(), true);
|
||||
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O> AddCommand<cmd::CmdClearAttachments> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdClearAttachments, Out = O>
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(self, command: cmd::CmdClearAttachments) -> Self::Out {
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O, S, D> AddCommand<cmd::CmdCopyBuffer<S, D>> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdCopyBuffer<S, D>, Out = O>,
|
||||
S: Buffer + Clone + 'static,
|
||||
D: Buffer + Clone + 'static
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(mut self, command: cmd::CmdCopyBuffer<S, D>) -> Self::Out {
|
||||
self.add_buffer(command.source(), false);
|
||||
self.add_buffer(command.destination(), true);
|
||||
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O, S, D> AddCommand<cmd::CmdCopyBufferToImage<S, D>> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdCopyBufferToImage<S, D>, Out = O>,
|
||||
S: Buffer + Clone + 'static,
|
||||
D: Image + Clone + 'static
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(mut self, command: cmd::CmdCopyBufferToImage<S, D>) -> Self::Out {
|
||||
self.add_buffer(command.source(), false);
|
||||
self.add_image(command.destination(), true);
|
||||
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O, S, D> AddCommand<cmd::CmdCopyImage<S, D>> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdCopyImage<S, D>, Out = O>,
|
||||
S: Image + Clone + 'static,
|
||||
D: Image + Clone + 'static
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(mut self, command: cmd::CmdCopyImage<S, D>) -> Self::Out {
|
||||
self.add_image(command.source(), false);
|
||||
self.add_image(command.destination(), true);
|
||||
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O> AddCommand<cmd::CmdDispatchRaw> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdDispatchRaw, Out = O>
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(self, command: cmd::CmdDispatchRaw) -> Self::Out {
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O> AddCommand<cmd::CmdDrawRaw> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdDrawRaw, Out = O>
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(self, command: cmd::CmdDrawRaw) -> Self::Out {
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O> AddCommand<cmd::CmdEndRenderPass> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdEndRenderPass, Out = O>
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(self, command: cmd::CmdEndRenderPass) -> Self::Out {
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O, B> AddCommand<cmd::CmdFillBuffer<B>> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdFillBuffer<B>, Out = O>,
|
||||
B: Buffer + Clone + 'static
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(mut self, command: cmd::CmdFillBuffer<B>) -> Self::Out {
|
||||
self.add_buffer(command.buffer(), true);
|
||||
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O> AddCommand<cmd::CmdNextSubpass> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdNextSubpass, Out = O>
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(self, command: cmd::CmdNextSubpass) -> Self::Out {
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O, Pc, Pl> AddCommand<cmd::CmdPushConstants<Pc, Pl>> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdPushConstants<Pc, Pl>, Out = O>
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(self, command: cmd::CmdPushConstants<Pc, Pl>) -> Self::Out {
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O, S, D> AddCommand<cmd::CmdResolveImage<S, D>> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdResolveImage<S, D>, Out = O>,
|
||||
S: Image + Clone + 'static,
|
||||
D: Image + Clone + 'static
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(mut self, command: cmd::CmdResolveImage<S, D>) -> Self::Out {
|
||||
self.add_image(command.source(), false);
|
||||
self.add_image(command.destination(), true);
|
||||
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O> AddCommand<cmd::CmdSetEvent> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdSetEvent, Out = O>
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(self, command: cmd::CmdSetEvent) -> Self::Out {
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<I, O> AddCommand<cmd::CmdSetState> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdSetState, Out = O>
|
||||
{
|
||||
@ -152,6 +402,24 @@ unsafe impl<I, O> AddCommand<cmd::CmdSetState> for SubmitSyncBuilderLayer<I>
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'a, I, O, B, D> AddCommand<cmd::CmdUpdateBuffer<'a, B, D>> for SubmitSyncBuilderLayer<I>
|
||||
where I: AddCommand<cmd::CmdUpdateBuffer<'a, B, D>, Out = O>,
|
||||
B: Buffer + Clone + 'static
|
||||
{
|
||||
type Out = SubmitSyncBuilderLayer<O>;
|
||||
|
||||
#[inline]
|
||||
fn add(mut self, command: cmd::CmdUpdateBuffer<'a, B, D>) -> Self::Out {
|
||||
self.add_buffer(command.buffer(), true);
|
||||
|
||||
SubmitSyncBuilderLayer {
|
||||
inner: AddCommand::add(self.inner, command),
|
||||
buffers: self.buffers,
|
||||
images: self.images,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Layer around a command buffer that handles synchronization between command buffers.
|
||||
pub struct SubmitSyncLayer<I> {
|
||||
inner: I,
|
||||
|
@ -53,6 +53,20 @@ pub struct CmdBlitImage<S, D> {
|
||||
|
||||
// TODO: add constructor
|
||||
|
||||
impl<S, D> CmdBlitImage<S, D> {
|
||||
/// Returns the source image.
|
||||
#[inline]
|
||||
pub fn source(&self) -> &S {
|
||||
&self.source
|
||||
}
|
||||
|
||||
/// Returns the destination image.
|
||||
#[inline]
|
||||
pub fn destination(&self) -> &D {
|
||||
&self.destination
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<S, D> DeviceOwned for CmdBlitImage<S, D> where S: DeviceOwned {
|
||||
#[inline]
|
||||
fn device(&self) -> &Arc<Device> {
|
||||
|
@ -87,6 +87,20 @@ impl<S, D> CmdCopyBuffer<S, D>
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, D> CmdCopyBuffer<S, D> {
|
||||
/// Returns the source buffer.
|
||||
#[inline]
|
||||
pub fn source(&self) -> &S {
|
||||
&self.source
|
||||
}
|
||||
|
||||
/// Returns the destination buffer.
|
||||
#[inline]
|
||||
pub fn destination(&self) -> &D {
|
||||
&self.destination
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'a, P, S, D> AddCommand<&'a CmdCopyBuffer<S, D>> for UnsafeCommandBufferBuilder<P>
|
||||
where S: Buffer,
|
||||
D: Buffer,
|
||||
|
@ -122,6 +122,20 @@ impl<S, D> CmdCopyBufferToImage<S, D> where S: Buffer, D: Image {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, D> CmdCopyBufferToImage<S, D> {
|
||||
/// Returns the source buffer.
|
||||
#[inline]
|
||||
pub fn source(&self) -> &S {
|
||||
&self.buffer
|
||||
}
|
||||
|
||||
/// Returns the destination image.
|
||||
#[inline]
|
||||
pub fn destination(&self) -> &D {
|
||||
&self.destination
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<S, D> DeviceOwned for CmdCopyBufferToImage<S, D> where S: DeviceOwned {
|
||||
#[inline]
|
||||
fn device(&self) -> &Arc<Device> {
|
||||
|
@ -52,6 +52,20 @@ pub struct CmdCopyImage<S, D> {
|
||||
|
||||
// TODO: add constructor
|
||||
|
||||
impl<S, D> CmdCopyImage<S, D> {
|
||||
/// Returns the source image.
|
||||
#[inline]
|
||||
pub fn source(&self) -> &S {
|
||||
&self.source
|
||||
}
|
||||
|
||||
/// Returns the destination image.
|
||||
#[inline]
|
||||
pub fn destination(&self) -> &D {
|
||||
&self.destination
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<S, D> DeviceOwned for CmdCopyImage<S, D> where S: DeviceOwned {
|
||||
#[inline]
|
||||
fn device(&self) -> &Arc<Device> {
|
||||
|
@ -73,6 +73,14 @@ impl<B> CmdFillBuffer<B>
|
||||
}
|
||||
}
|
||||
|
||||
impl<B> CmdFillBuffer<B> {
|
||||
/// Returns the buffer that is going to be filled.
|
||||
#[inline]
|
||||
pub fn buffer(&self) -> &B {
|
||||
&self.buffer
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'a, P, B> AddCommand<&'a CmdFillBuffer<B>> for UnsafeCommandBufferBuilder<P>
|
||||
where P: CommandPool
|
||||
{
|
||||
|
@ -52,6 +52,20 @@ pub struct CmdResolveImage<S, D> {
|
||||
|
||||
// TODO: add constructor
|
||||
|
||||
impl<S, D> CmdResolveImage<S, D> {
|
||||
/// Returns the source image.
|
||||
#[inline]
|
||||
pub fn source(&self) -> &S {
|
||||
&self.source
|
||||
}
|
||||
|
||||
/// Returns the destination image.
|
||||
#[inline]
|
||||
pub fn destination(&self) -> &D {
|
||||
&self.destination
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<S, D> DeviceOwned for CmdResolveImage<S, D> where S: DeviceOwned {
|
||||
#[inline]
|
||||
fn device(&self) -> &Arc<Device> {
|
||||
|
@ -81,6 +81,14 @@ impl<'a, B, D: ?Sized> CmdUpdateBuffer<'a, B, D>
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, B, D> CmdUpdateBuffer<'a, B, D> {
|
||||
/// Returns the buffer that is going to be written.
|
||||
#[inline]
|
||||
pub fn buffer(&self) -> &B {
|
||||
&self.buffer
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'a, B, D> DeviceOwned for CmdUpdateBuffer<'a, B, D>
|
||||
where B: DeviceOwned
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ unsafe impl<F, A> Image for ImmutableImage<F, A> where F: 'static + Send + Sync,
|
||||
|
||||
#[inline]
|
||||
fn gpu_access(&self, exclusive_access: bool, queue: &Queue) -> bool {
|
||||
false // FIXME:
|
||||
true // FIXME:
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user