diff --git a/vulkano/src/command_buffer/cb/buffered.rs b/vulkano/src/command_buffer/cb/buffered.rs deleted file mode 100644 index 1c7088f3..00000000 --- a/vulkano/src/command_buffer/cb/buffered.rs +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) 2016 The vulkano developers -// Licensed under the Apache License, Version 2.0 -// or the MIT -// license , -// at your option. All files in the project carrying such -// notice may not be copied, modified, or distributed except -// according to those terms. - -use std::error::Error; -use std::sync::Arc; - -use command_buffer::cb::AddCommand; -use command_buffer::cb::CommandBufferBuild; -use command_buffer::cb::CommandsList; -use command_buffer::cb::UnsafeCommandBuffer; -use command_buffer::CommandBuffer; -use command_buffer::CommandBufferBuilder; -use command_buffer::CommandBufferBuilderBuffered; -use command_buffer::cmd; -use device::Device; -use device::DeviceOwned; -use device::Queue; - -/// Layer around a command buffer builder or a command buffer that stores the commands and has a -/// buffering mechanism. -/// -/// Whenever you add a command (with the `AddCommand` trait), the command is not immediately added -/// to the underlying builder. Pending commands are added for real when you call `flush()` or when -/// you build the builder into a real command buffer. -/// -/// The purpose of this buffering mechanism is to allow inserting pipeline barrier commands between -/// commands that are already submitted and commands that are pending thanks to the -/// `add_non_buffered_pipeline_barrier` method. -pub struct BufferedCommandsListLayer { - inner: Option, - commands: L, - // Number of commands in the list that haven't been flushed. Since the latest commands appear - // first in the list, it is more convenient to store the number of commands that haven't been - // flushed rather than the number of commands that have been flushed. - non_flushed: u32, -} - -/// Helper trait for `BufferedCommandsListLayer`. -/// -/// Whenever you manipulate a `BufferedCommandsListLayer`, the template parameter `L` should -/// implement `BufferedCommandsListLayerCommands`. -pub unsafe trait BufferedCommandsListLayerCommands { - /// Sends the `num` last commands of the list to `dest`. - fn flush(&self, num: u32, dest: I) -> I; -} - -unsafe impl BufferedCommandsListLayerCommands for () { - #[inline] - fn flush(&self, num: u32, dest: I) -> I { - debug_assert_eq!(num, 0); - dest - } -} - -unsafe impl BufferedCommandsListLayerCommands for (L, C) - where I: for<'r> AddCommand<&'r C, Out = I>, - L: BufferedCommandsListLayerCommands, -{ - #[inline] - fn flush(&self, num: u32, dest: I) -> I { - if num == 0 { - dest - } else { - self.0.flush(num - 1, dest).add(&self.1) - } - } -} - -unsafe impl CommandsList for BufferedCommandsListLayer { - type List = L; - - #[inline] - unsafe fn list(&self) -> &L { - &self.commands - } -} - -impl BufferedCommandsListLayer { - /// Builds a new `BufferedCommandsListLayer`. - #[inline] - pub fn new(inner: I) -> BufferedCommandsListLayer { - BufferedCommandsListLayer { - inner: Some(inner), - commands: (), - non_flushed: 0, - } - } -} - -impl BufferedCommandsListLayer - where L: BufferedCommandsListLayerCommands, -{ - #[inline] - fn flush_inner(&mut self) { - let inner = self.inner.take().unwrap(); - self.inner = Some(self.commands.flush(self.non_flushed, inner)); - self.non_flushed = 0; - } -} - -unsafe impl CommandBufferBuilderBuffered for BufferedCommandsListLayer - where I: for<'r> AddCommand<&'r cmd::CmdPipelineBarrier<'r>, Out = I>, - L: BufferedCommandsListLayerCommands, -{ - #[inline] - fn add_non_buffered_pipeline_barrier(&mut self, cmd: &cmd::CmdPipelineBarrier) { - let inner = self.inner.take().unwrap(); - self.inner = Some(inner.add(cmd)); - } - - #[inline] - fn flush(&mut self) { - self.flush_inner(); - } -} - -unsafe impl CommandBufferBuild for BufferedCommandsListLayer - where I: CommandBufferBuild, - L: BufferedCommandsListLayerCommands // Necessary in order to flush -{ - type Out = BufferedCommandsListLayer; - - #[inline] - fn build(mut self) -> Self::Out { - self.flush_inner(); - debug_assert_eq!(self.non_flushed, 0); - - let inner = self.inner.take().unwrap().build(); - - BufferedCommandsListLayer { - inner: Some(inner), - commands: self.commands, - non_flushed: 0, - } - } -} - -unsafe impl CommandBuffer for BufferedCommandsListLayer where I: CommandBuffer { - type Pool = I::Pool; - - #[inline] - fn inner(&self) -> &UnsafeCommandBuffer { - self.inner.as_ref().unwrap().inner() - } -} - -unsafe impl DeviceOwned for BufferedCommandsListLayer where I: DeviceOwned { - #[inline] - fn device(&self) -> &Arc { - self.inner.as_ref().unwrap().device() - } -} - -unsafe impl CommandBufferBuilder for BufferedCommandsListLayer where I: DeviceOwned { -} - -macro_rules! pass_through { - (($($param:ident),*), $cmd:ty) => { - unsafe impl<'a, I, L $(, $param)*> AddCommand<$cmd> for BufferedCommandsListLayer - where I: for<'r> AddCommand<&'r $cmd, Out = I> - { - type Out = BufferedCommandsListLayer; - - #[inline] - fn add(self, command: $cmd) -> Self::Out { - debug_assert!(self.inner.is_some()); - BufferedCommandsListLayer { - inner: self.inner, - commands: (self.commands, command), - non_flushed: self.non_flushed + 1, - } - } - } - } -} - -pass_through!((Rp, F), cmd::CmdBeginRenderPass); -pass_through!((S, Pl), cmd::CmdBindDescriptorSets); -pass_through!((B), cmd::CmdBindIndexBuffer); -pass_through!((Pl), cmd::CmdBindPipeline); -pass_through!((V), cmd::CmdBindVertexBuffers); -pass_through!((S, D), cmd::CmdBlitImage); -pass_through!((), cmd::CmdClearAttachments); -pass_through!((S, D), cmd::CmdCopyBuffer); -pass_through!((S, D), cmd::CmdCopyImage); -pass_through!((), cmd::CmdDispatchRaw); -pass_through!((), cmd::CmdDrawIndexedRaw); -pass_through!((B), cmd::CmdDrawIndirectRaw); -pass_through!((), cmd::CmdDrawRaw); -pass_through!((), cmd::CmdEndRenderPass); -pass_through!((C), cmd::CmdExecuteCommands); -pass_through!((B), cmd::CmdFillBuffer); -pass_through!((), cmd::CmdNextSubpass); -pass_through!((Pc, Pl), cmd::CmdPushConstants); -pass_through!((S, D), cmd::CmdResolveImage); -pass_through!((), cmd::CmdSetEvent); -pass_through!((), cmd::CmdSetState); -pass_through!((B, D), cmd::CmdUpdateBuffer<'a, B, D>); diff --git a/vulkano/src/command_buffer/cb/commands_list.rs b/vulkano/src/command_buffer/cb/commands_list.rs deleted file mode 100644 index 2d6f93bd..00000000 --- a/vulkano/src/command_buffer/cb/commands_list.rs +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) 2016 The vulkano developers -// Licensed under the Apache License, Version 2.0 -// or the MIT -// license , -// at your option. All files in the project carrying such -// notice may not be copied, modified, or distributed except -// according to those terms. - -use std::error::Error; -use std::sync::Arc; - -use command_buffer::cb::AddCommand; -use command_buffer::cb::UnsafeCommandBuffer; -use command_buffer::cmd; -use command_buffer::CommandBuffer; -use command_buffer::CommandBufferBuilder; -use device::Device; -use device::DeviceOwned; -use device::Queue; - -pub struct CommandsListLayer { - inner: I, - commands: L, -} - -/// -// TODO: consider changing this to a more flexible API because right now we're forcing -// implementations to hold a tuple of commands -pub unsafe trait CommandsList { - type List; - - /// - /// # Safety - /// - /// This function is unsafe because the commands must not be modified through - /// interior mutability. - unsafe fn list(&self) -> &Self::List; -} - -unsafe impl CommandsList for CommandsListLayer { - type List = L; - - #[inline] - unsafe fn list(&self) -> &L { - &self.commands - } -} - -impl CommandsListLayer { - #[inline] - pub fn new(inner: I) -> CommandsListLayer { - CommandsListLayer { - inner: inner, - commands: (), - } - } -} - -// TODO: implement CommandBufferBuild - -unsafe impl CommandBuffer for CommandsListLayer where I: CommandBuffer { - type Pool = I::Pool; - - #[inline] - fn inner(&self) -> &UnsafeCommandBuffer { - self.inner.inner() - } -} - -unsafe impl DeviceOwned for CommandsListLayer where I: DeviceOwned { - #[inline] - fn device(&self) -> &Arc { - self.inner.device() - } -} - -unsafe impl CommandBufferBuilder for CommandsListLayer where I: DeviceOwned { -} - -macro_rules! pass_through { - (($($param:ident),*), $cmd:ty) => { - unsafe impl<'a, I, L $(, $param)*> AddCommand<$cmd> for CommandsListLayer - where I: for<'r> AddCommand<&'r $cmd, Out = I> - { - type Out = CommandsListLayer; - - #[inline] - fn add(self, command: $cmd) -> Self::Out { - CommandsListLayer { - inner: AddCommand::add(self.inner, &command), - commands: (self.commands, command), - } - } - } - } -} - -pass_through!((Rp, F), cmd::CmdBeginRenderPass); -pass_through!((S, Pl), cmd::CmdBindDescriptorSets); -pass_through!((B), cmd::CmdBindIndexBuffer); -pass_through!((Pl), cmd::CmdBindPipeline); -pass_through!((V), cmd::CmdBindVertexBuffers); -pass_through!((S, D), cmd::CmdBlitImage); -pass_through!((), cmd::CmdClearAttachments); -pass_through!((S, D), cmd::CmdCopyBuffer); -pass_through!((S, D), cmd::CmdCopyImage); -pass_through!((), cmd::CmdDispatchRaw); -pass_through!((), cmd::CmdDrawIndexedRaw); -pass_through!((B), cmd::CmdDrawIndirectRaw); -pass_through!((), cmd::CmdDrawRaw); -pass_through!((), cmd::CmdEndRenderPass); -pass_through!((C), cmd::CmdExecuteCommands); -pass_through!((B), cmd::CmdFillBuffer); -pass_through!((), cmd::CmdNextSubpass); -pass_through!((Pc, Pl), cmd::CmdPushConstants); -pass_through!((S, D), cmd::CmdResolveImage); -pass_through!((), cmd::CmdSetEvent); -pass_through!((), cmd::CmdSetState); -pass_through!((B, D), cmd::CmdUpdateBuffer<'a, B, D>); diff --git a/vulkano/src/command_buffer/cb/mod.rs b/vulkano/src/command_buffer/cb/mod.rs index 132c3543..1f9be96d 100644 --- a/vulkano/src/command_buffer/cb/mod.rs +++ b/vulkano/src/command_buffer/cb/mod.rs @@ -76,10 +76,6 @@ use device::DeviceOwned; pub use self::abstract_storage::AbstractStorageLayer; pub use self::auto_barriers::AutoPipelineBarriersLayer; -pub use self::buffered::BufferedCommandsListLayer; -pub use self::buffered::BufferedCommandsListLayerCommands; -pub use self::commands_list::CommandsList; -pub use self::commands_list::CommandsListLayer; pub use self::context_check::ContextCheckLayer; pub use self::device_check::DeviceCheckLayer; pub use self::queue_ty_check::QueueTyCheckLayer; @@ -95,8 +91,6 @@ pub use self::traits::CommandBufferBuild; mod abstract_storage; mod auto_barriers; -mod buffered; -mod commands_list; mod device_check; mod context_check; mod queue_ty_check;