From 5de743221b6914885eb2e8cfdf028d84d8f2e105 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 20 Apr 2017 09:43:57 +0200 Subject: [PATCH] Adding a command to a builder can now return an error --- examples/src/bin/image.rs | 6 +- examples/src/bin/teapot.rs | 6 +- examples/src/bin/triangle.rs | 3 + vulkano/src/command_buffer/auto.rs | 9 +- vulkano/src/command_buffer/builder.rs | 179 +++++++++++++++--- .../src/command_buffer/cb/abstract_storage.rs | 9 +- .../src/command_buffer/cb/auto_barriers.rs | 9 +- .../src/command_buffer/cb/context_check.rs | 86 +++++---- vulkano/src/command_buffer/cb/device_check.rs | 17 +- .../src/command_buffer/cb/queue_ty_check.rs | 77 +++++--- vulkano/src/command_buffer/cb/state_cache.rs | 33 ++-- vulkano/src/command_buffer/cb/submit_sync.rs | 153 +++++++-------- vulkano/src/command_buffer/cb/traits.rs | 4 +- .../command_buffer/commands_extra/dispatch.rs | 11 +- .../commands_extra/dispatch_indirect.rs | 1 + .../src/command_buffer/commands_extra/draw.rs | 15 +- .../commands_extra/draw_indexed.rs | 17 +- .../commands_raw/begin_render_pass.rs | 5 +- .../commands_raw/bind_descriptor_sets.rs | 5 +- .../commands_raw/bind_index_buffer.rs | 5 +- .../commands_raw/bind_pipeline.rs | 5 +- .../commands_raw/bind_vertex_buffers.rs | 5 +- .../command_buffer/commands_raw/blit_image.rs | 5 +- .../commands_raw/clear_attachments.rs | 5 +- .../commands_raw/copy_buffer.rs | 5 +- .../commands_raw/copy_buffer_to_image.rs | 5 +- .../command_buffer/commands_raw/copy_image.rs | 5 +- .../commands_raw/dispatch_raw.rs | 5 +- .../commands_raw/draw_indexed_raw.rs | 5 +- .../commands_raw/draw_indirect_raw.rs | 5 +- .../command_buffer/commands_raw/draw_raw.rs | 5 +- .../commands_raw/end_render_pass.rs | 5 +- .../command_buffer/commands_raw/execute.rs | 5 +- .../commands_raw/fill_buffer.rs | 5 +- .../commands_raw/next_subpass.rs | 5 +- .../commands_raw/pipeline_barrier.rs | 7 +- .../commands_raw/push_constants.rs | 5 +- .../commands_raw/resolve_image.rs | 5 +- .../command_buffer/commands_raw/set_event.rs | 5 +- .../command_buffer/commands_raw/set_state.rs | 5 +- .../commands_raw/update_buffer.rs | 5 +- vulkano/src/command_buffer/mod.rs | 2 +- 42 files changed, 476 insertions(+), 283 deletions(-) diff --git a/examples/src/bin/image.rs b/examples/src/bin/image.rs index c77647d3a..b050cbce3 100644 --- a/examples/src/bin/image.rs +++ b/examples/src/bin/image.rs @@ -180,10 +180,10 @@ fn main() { .begin_render_pass( framebuffers[image_num].clone(), false, renderpass.desc().start_clear_values() - .color([0.0, 0.0, 1.0, 1.0])) + .color([0.0, 0.0, 1.0, 1.0])).unwrap() .draw(pipeline.clone(), vulkano::command_buffer::DynamicState::none(), vertex_buffer.clone(), - set.clone(), ()) - .end_render_pass() + set.clone(), ()).unwrap() + .end_render_pass().unwrap() .build().unwrap(); let future = future diff --git a/examples/src/bin/teapot.rs b/examples/src/bin/teapot.rs index 0f7b9082f..66642eb03 100644 --- a/examples/src/bin/teapot.rs +++ b/examples/src/bin/teapot.rs @@ -184,12 +184,12 @@ fn main() { .begin_render_pass( framebuffers[image_num].clone(), false, renderpass.desc().start_clear_values() - .color([0.0, 0.0, 1.0, 1.0]).depth((1f32))) + .color([0.0, 0.0, 1.0, 1.0]).depth((1f32))).unwrap() .draw_indexed( pipeline.clone(), vulkano::command_buffer::DynamicState::none(), (vertex_buffer.clone(), normals_buffer.clone()), - index_buffer.clone(), set.clone(), ()) - .end_render_pass() + index_buffer.clone(), set.clone(), ()).unwrap() + .end_render_pass().unwrap() .build().unwrap(); let future = future diff --git a/examples/src/bin/triangle.rs b/examples/src/bin/triangle.rs index d3066edbb..e7e16f78c 100644 --- a/examples/src/bin/triangle.rs +++ b/examples/src/bin/triangle.rs @@ -384,17 +384,20 @@ fn main() { // only the attachments that use `load: Clear` appear in the list. .begin_render_pass(framebuffers[image_num].clone(), false, render_pass.desc().start_clear_values().color([0.0, 0.0, 1.0, 1.0])) + .unwrap() // We are now inside the first subpass of the render pass. We add a draw command. // // The last two parameters contain the list of resources to pass to the shaders. // Since we used an `EmptyPipeline` object, the objects have to be `()`. .draw(pipeline.clone(), DynamicState::none(), vertex_buffer.clone(), (), ()) + .unwrap() // We leave the render pass by calling `draw_end`. Note that if we had multiple // subpasses we could have called `next_inline` (or `next_secondary`) to jump to the // next subpass. .end_render_pass() + .unwrap() // Finish building the command buffer by calling `build`. .build().unwrap(); diff --git a/vulkano/src/command_buffer/auto.rs b/vulkano/src/command_buffer/auto.rs index 7aae78292..89e95031b 100644 --- a/vulkano/src/command_buffer/auto.rs +++ b/vulkano/src/command_buffer/auto.rs @@ -16,6 +16,7 @@ use command_buffer::commands_raw; use command_buffer::cb::AddCommand; use command_buffer::cb::CommandBufferBuild; use command_buffer::cb::UnsafeCommandBuffer; +use command_buffer::CommandAddError; use command_buffer::CommandBuffer; use command_buffer::CommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -142,10 +143,10 @@ macro_rules! pass_through { type Out = AutoCommandBufferBuilder

; #[inline] - fn add(self, command: $cmd) -> Self::Out { - AutoCommandBufferBuilder { - inner: self.inner.add(command), - } + fn add(self, command: $cmd) -> Result { + Ok(AutoCommandBufferBuilder { + inner: self.inner.add(command)?, + }) } } } diff --git a/vulkano/src/command_buffer/builder.rs b/vulkano/src/command_buffer/builder.rs index d176a61cd..03386fece 100644 --- a/vulkano/src/command_buffer/builder.rs +++ b/vulkano/src/command_buffer/builder.rs @@ -7,6 +7,8 @@ // notice may not be copied, modified, or distributed except // according to those terms. +use std::error; +use std::fmt; use std::sync::Arc; use buffer::Buffer; @@ -42,33 +44,45 @@ pub unsafe trait CommandBufferBuilder: DeviceOwned { /// > this function only for zeroing the content of a buffer by passing `0` for the data. // TODO: not safe because of signalling NaNs #[inline] - fn fill_buffer(self, buffer: B, data: u32) -> Result + fn fill_buffer(self, buffer: B, data: u32) -> Result> where Self: Sized + AddCommand, Out = O>, B: Buffer { - let cmd = commands_raw::CmdFillBuffer::new(buffer.access(), data)?; - Ok(self.add(cmd)) + let cmd = match commands_raw::CmdFillBuffer::new(buffer.access(), data) { + Ok(cmd) => cmd, + Err(err) => return Err(CommandBufferBuilderError::CommandBuildError(err)), + }; + + Ok(self.add(cmd)?) } /// Adds a command that writes data to a buffer. #[inline] - fn update_buffer(self, buffer: B, data: D) -> Result + fn update_buffer(self, buffer: B, data: D) -> Result> where Self: Sized + AddCommand, Out = O>, B: Buffer { - let cmd = commands_raw::CmdUpdateBuffer::new(buffer.access(), data)?; - Ok(self.add(cmd)) + let cmd = match commands_raw::CmdUpdateBuffer::new(buffer.access(), data) { + Ok(cmd) => cmd, + Err(err) => return Err(CommandBufferBuilderError::CommandBuildError(err)), + }; + + Ok(self.add(cmd)?) } /// Adds a command that copies from a buffer to another. #[inline] - fn copy_buffer(self, src: S, dest: D) -> Result + fn copy_buffer(self, src: S, dest: D) -> Result> where Self: Sized + AddCommand, Out = O>, S: Buffer, D: Buffer { - let cmd = commands_raw::CmdCopyBuffer::new(src.access(), dest.access())?; - Ok(self.add(cmd)) + let cmd = match commands_raw::CmdCopyBuffer::new(src.access(), dest.access()) { + Ok(cmd) => cmd, + Err(err) => return Err(CommandBufferBuilderError::CommandBuildError(err)), + }; + + Ok(self.add(cmd)?) } /// Adds a command that copies the content of a buffer to an image. @@ -84,26 +98,35 @@ pub unsafe trait CommandBufferBuilder: DeviceOwned { // TODO: not safe because of signalling NaNs #[inline] fn copy_buffer_to_image(self, buffer: B, image: I) - -> Result + -> Result> where Self: Sized + AddCommand, Out = O>, B: Buffer, I: Image { - let cmd = commands_raw::CmdCopyBufferToImage::new(buffer.access(), image.access())?; - Ok(self.add(cmd)) + let cmd = match commands_raw::CmdCopyBufferToImage::new(buffer.access(), image.access()) { + Ok(cmd) => cmd, + Err(err) => return Err(CommandBufferBuilderError::CommandBuildError(err)), + }; + + Ok(self.add(cmd)?) } /// Same as `copy_buffer_to_image` but lets you specify a range for the destination image. #[inline] fn copy_buffer_to_image_dimensions(self, buffer: B, image: I, offset: [u32; 3], size: [u32; 3], first_layer: u32, num_layers: u32, - mipmap: u32) -> Result + mipmap: u32) -> Result> where Self: Sized + AddCommand, Out = O>, B: Buffer, I: Image { - let cmd = commands_raw::CmdCopyBufferToImage::with_dimensions(buffer.access(), - image.access(), offset, size, - first_layer, num_layers, mipmap)?; - Ok(self.add(cmd)) + let cmd = match commands_raw::CmdCopyBufferToImage::with_dimensions(buffer.access(), + image.access(), offset, size, + first_layer, num_layers, mipmap) + { + Ok(cmd) => cmd, + Err(err) => return Err(CommandBufferBuilderError::CommandBuildError(err)), + }; + + Ok(self.add(cmd)?) } /// Adds a command that starts a render pass. @@ -115,7 +138,7 @@ pub unsafe trait CommandBufferBuilder: DeviceOwned { /// You must call this before you can add draw commands. #[inline] fn begin_render_pass(self, framebuffer: F, secondary: bool, clear_values: C) - -> O + -> Result where Self: Sized + AddCommand, F>, Out = O>, F: FramebufferAbstract + RenderPassDescClearValues { @@ -125,7 +148,7 @@ pub unsafe trait CommandBufferBuilder: DeviceOwned { /// Adds a command that jumps to the next subpass of the current render pass. #[inline] - fn next_subpass(self, secondary: bool) -> O + fn next_subpass(self, secondary: bool) -> Result where Self: Sized + AddCommand { let cmd = commands_raw::CmdNextSubpass::new(secondary); @@ -137,7 +160,7 @@ pub unsafe trait CommandBufferBuilder: DeviceOwned { /// This must be called after you went through all the subpasses and before you can build /// the command buffer or add further commands. #[inline] - fn end_render_pass(self) -> O + fn end_render_pass(self) -> Result where Self: Sized + AddCommand { let cmd = commands_raw::CmdEndRenderPass::new(); @@ -149,7 +172,7 @@ pub unsafe trait CommandBufferBuilder: DeviceOwned { /// Can only be used from inside a render pass. #[inline] fn draw(self, pipeline: P, dynamic: DynamicState, vertices: V, sets: S, - push_constants: Pc) -> O + push_constants: Pc) -> Result where Self: Sized + AddCommand, Out = O>, S: DescriptorSetsCollection, P: VertexSource + GraphicsPipelineAbstract + Clone @@ -163,7 +186,7 @@ pub unsafe trait CommandBufferBuilder: DeviceOwned { /// Can only be used from inside a render pass. #[inline] fn draw_indexed(self, pipeline: P, dynamic: DynamicState, - vertices: V, index_buffer: Ib, sets: S, push_constants: Pc) -> O + vertices: V, index_buffer: Ib, sets: S, push_constants: Pc) -> Result where Self: Sized + AddCommand, Out = O>, S: DescriptorSetsCollection, P: VertexSource + GraphicsPipelineAbstract + Clone, @@ -178,13 +201,17 @@ pub unsafe trait CommandBufferBuilder: DeviceOwned { /// Executes a compute shader. fn dispatch(self, dimensions: [u32; 3], pipeline: P, sets: S, push_constants: Pc) - -> Result + -> Result> where Self: Sized + AddCommand, Out = O>, S: DescriptorSetsCollection, P: Clone + ComputePipelineAbstract, { - let cmd = try!(commands_extra::CmdDispatch::new(dimensions, pipeline, sets, push_constants)); - Ok(self.add(cmd)) + let cmd = match commands_extra::CmdDispatch::new(dimensions, pipeline, sets, push_constants) { + Ok(cmd) => cmd, + Err(err) => return Err(CommandBufferBuilderError::CommandBuildError(err)), + }; + + Ok(self.add(cmd)?) } /// Builds the actual command buffer. @@ -206,11 +233,101 @@ pub unsafe trait CommandBufferBuilder: DeviceOwned { fn supports_compute(&self) -> bool; } -pub unsafe trait CommandBufferBuilderBuffered { - /// Adds a pipeline barrier to the underlying command buffer and bypasses the flushing - /// mechanism. - fn add_non_buffered_pipeline_barrier(&mut self, cmd: &commands_raw::CmdPipelineBarrier); +/// Error that can happen when adding a command to a command buffer builder. +#[derive(Debug, Copy, Clone)] +pub enum CommandBufferBuilderError { + /// Error while creating the command. + CommandBuildError(E), - /// Flushes all the commands that haven't been flushed to the inner builder. - fn flush(&mut self); + /// Error while adding the command to the builder. + CommandAddError(CommandAddError), +} + +impl From for CommandBufferBuilderError { + #[inline] + fn from(err: CommandAddError) -> CommandBufferBuilderError { + CommandBufferBuilderError::CommandAddError(err) + } +} + +impl error::Error for CommandBufferBuilderError where E: error::Error { + #[inline] + fn description(&self) -> &str { + match *self { + CommandBufferBuilderError::CommandBuildError(_) => { + "error while creating a command to add to a builder" + }, + CommandBufferBuilderError::CommandAddError(_) => { + "error while adding a command to the builder" + }, + } + } + + #[inline] + fn cause(&self) -> Option<&error::Error> { + match *self { + CommandBufferBuilderError::CommandBuildError(ref err) => { + Some(err) + }, + CommandBufferBuilderError::CommandAddError(ref err) => { + Some(err) + }, + } + } +} + +impl fmt::Display for CommandBufferBuilderError where E: error::Error { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } +} + +/// Error that can happen when adding a command to a command buffer builder. +#[derive(Debug, Copy, Clone)] +pub enum CommandAddError { + /// This command is forbidden when inside a render pass. + ForbiddenInsideRenderPass, + + /// This command is forbidden when outside of a render pass. + ForbiddenOutsideRenderPass, + + /// This command is forbidden in a secondary command buffer. + ForbiddenInSecondaryCommandBuffer, + + /// The queue family doesn't support graphics operations. + GraphicsOperationsNotSupported, + + /// The queue family doesn't support compute operations. + ComputeOperationsNotSupported, +} + +impl error::Error for CommandAddError { + #[inline] + fn description(&self) -> &str { + match *self { + CommandAddError::ForbiddenInsideRenderPass => { + "this command is forbidden when inside a render pass" + }, + CommandAddError::ForbiddenOutsideRenderPass => { + "this command is forbidden when outside of a render pass" + }, + CommandAddError::ForbiddenInSecondaryCommandBuffer => { + "this command is forbidden in a secondary command buffer" + }, + CommandAddError::GraphicsOperationsNotSupported => { + "the queue family doesn't support graphics operations" + }, + CommandAddError::ComputeOperationsNotSupported => { + "the queue family doesn't support compute operations" + }, + } + } +} + +impl fmt::Display for CommandAddError { + #[inline] + fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { + write!(fmt, "{}", error::Error::description(self)) + } } diff --git a/vulkano/src/command_buffer/cb/abstract_storage.rs b/vulkano/src/command_buffer/cb/abstract_storage.rs index cf5fda946..b6022e880 100644 --- a/vulkano/src/command_buffer/cb/abstract_storage.rs +++ b/vulkano/src/command_buffer/cb/abstract_storage.rs @@ -16,6 +16,7 @@ use command_buffer::cb::AddCommand; use command_buffer::cb::CommandBufferBuild; use command_buffer::cb::UnsafeCommandBuffer; use command_buffer::commands_raw; +use command_buffer::CommandAddError; use command_buffer::CommandBuffer; use command_buffer::CommandBufferBuilder; use device::Device; @@ -115,15 +116,15 @@ macro_rules! pass_through { type Out = AbstractStorageLayer; #[inline] - fn add(mut self, command: $cmd) -> Self::Out { - let new_inner = AddCommand::add(self.inner, &command); + fn add(mut self, command: $cmd) -> Result { + let new_inner = AddCommand::add(self.inner, &command)?; // TODO: should store a lightweight version of the command self.commands.push(Box::new(command) as Box<_>); - AbstractStorageLayer { + Ok(AbstractStorageLayer { inner: new_inner, commands: self.commands, - } + }) } } } diff --git a/vulkano/src/command_buffer/cb/auto_barriers.rs b/vulkano/src/command_buffer/cb/auto_barriers.rs index ade76ba81..73c8ee35b 100644 --- a/vulkano/src/command_buffer/cb/auto_barriers.rs +++ b/vulkano/src/command_buffer/cb/auto_barriers.rs @@ -10,6 +10,7 @@ use std::sync::Arc; use command_buffer::cb::AddCommand; use command_buffer::cb::CommandBufferBuild; +use command_buffer::CommandAddError; use command_buffer::CommandBufferBuilder; use command_buffer::commands_raw; use device::Device; @@ -84,10 +85,10 @@ macro_rules! pass_through { type Out = AutoPipelineBarriersLayer; #[inline] - fn add(self, command: $cmd) -> Self::Out { - AutoPipelineBarriersLayer { - inner: AddCommand::add(self.inner, command), - } + fn add(self, command: $cmd) -> Result { + Ok(AutoPipelineBarriersLayer { + inner: AddCommand::add(self.inner, command)?, + }) } } } diff --git a/vulkano/src/command_buffer/cb/context_check.rs b/vulkano/src/command_buffer/cb/context_check.rs index e4ea3459f..573865c68 100644 --- a/vulkano/src/command_buffer/cb/context_check.rs +++ b/vulkano/src/command_buffer/cb/context_check.rs @@ -10,6 +10,7 @@ use std::sync::Arc; use command_buffer::cb::AddCommand; use command_buffer::cb::CommandBufferBuild; +use command_buffer::CommandAddError; use command_buffer::CommandBufferBuilder; use command_buffer::commands_raw; use device::Device; @@ -119,12 +120,12 @@ macro_rules! impl_always { type Out = ContextCheckLayer; #[inline] - fn add(self, command: $cmd) -> Self::Out { - ContextCheckLayer { - inner: self.inner.add(command), + fn add(self, command: $cmd) -> Result { + Ok(ContextCheckLayer { + inner: self.inner.add(command)?, inside_render_pass: self.inside_render_pass, allow_render_pass_ops: self.allow_render_pass_ops, - } + }) } } } @@ -145,14 +146,16 @@ macro_rules! impl_inside_only { type Out = ContextCheckLayer; #[inline] - fn add(self, command: $cmd) -> Self::Out { - assert!(self.inside_render_pass); // TODO: proper error + fn add(self, command: $cmd) -> Result { + if !self.inside_render_pass { + return Err(CommandAddError::ForbiddenOutsideRenderPass); + } - ContextCheckLayer { - inner: self.inner.add(command), + Ok(ContextCheckLayer { + inner: self.inner.add(command)?, inside_render_pass: self.inside_render_pass, allow_render_pass_ops: self.allow_render_pass_ops, - } + }) } } } @@ -171,14 +174,16 @@ macro_rules! impl_outside_only { type Out = ContextCheckLayer; #[inline] - fn add(self, command: $cmd) -> Self::Out { - assert!(!self.inside_render_pass); // TODO: proper error + fn add(self, command: $cmd) -> Result { + if self.inside_render_pass { + return Err(CommandAddError::ForbiddenInsideRenderPass); + } - ContextCheckLayer { - inner: self.inner.add(command), + Ok(ContextCheckLayer { + inner: self.inner.add(command)?, inside_render_pass: self.inside_render_pass, allow_render_pass_ops: self.allow_render_pass_ops, - } + }) } } } @@ -200,15 +205,20 @@ unsafe impl<'a, I, O, Rp, F> AddCommand> type Out = ContextCheckLayer; #[inline] - fn add(self, command: commands_raw::CmdBeginRenderPass) -> Self::Out { - assert!(!self.inside_render_pass); // TODO: proper error - assert!(self.allow_render_pass_ops); // TODO: proper error + fn add(self, command: commands_raw::CmdBeginRenderPass) -> Result { + if self.inside_render_pass { + return Err(CommandAddError::ForbiddenInsideRenderPass); + } + + if !self.allow_render_pass_ops { + return Err(CommandAddError::ForbiddenInSecondaryCommandBuffer); + } - ContextCheckLayer { - inner: self.inner.add(command), + Ok(ContextCheckLayer { + inner: self.inner.add(command)?, inside_render_pass: true, allow_render_pass_ops: true, - } + }) } } @@ -218,16 +228,22 @@ unsafe impl<'a, I, O> AddCommand for ContextCheckL type Out = ContextCheckLayer; #[inline] - fn add(self, command: commands_raw::CmdNextSubpass) -> Self::Out { - assert!(self.inside_render_pass); // TODO: proper error - assert!(self.allow_render_pass_ops); // TODO: proper error + fn add(self, command: commands_raw::CmdNextSubpass) -> Result { + if !self.inside_render_pass { + return Err(CommandAddError::ForbiddenOutsideRenderPass); + } + + if !self.allow_render_pass_ops { + return Err(CommandAddError::ForbiddenInSecondaryCommandBuffer); + } + // FIXME: check number of subpasses - ContextCheckLayer { - inner: self.inner.add(command), + Ok(ContextCheckLayer { + inner: self.inner.add(command)?, inside_render_pass: true, allow_render_pass_ops: true, - } + }) } } @@ -237,15 +253,21 @@ unsafe impl<'a, I, O> AddCommand for ContextChec type Out = ContextCheckLayer; #[inline] - fn add(self, command: commands_raw::CmdEndRenderPass) -> Self::Out { - assert!(self.inside_render_pass); // TODO: proper error - assert!(self.allow_render_pass_ops); // TODO: proper error + fn add(self, command: commands_raw::CmdEndRenderPass) -> Result { + if !self.inside_render_pass { + return Err(CommandAddError::ForbiddenOutsideRenderPass); + } + + if !self.allow_render_pass_ops { + return Err(CommandAddError::ForbiddenInSecondaryCommandBuffer); + } + // FIXME: check number of subpasses - ContextCheckLayer { - inner: self.inner.add(command), + Ok(ContextCheckLayer { + inner: self.inner.add(command)?, inside_render_pass: false, allow_render_pass_ops: true, - } + }) } } diff --git a/vulkano/src/command_buffer/cb/device_check.rs b/vulkano/src/command_buffer/cb/device_check.rs index fd5b6005e..9653d0dfd 100644 --- a/vulkano/src/command_buffer/cb/device_check.rs +++ b/vulkano/src/command_buffer/cb/device_check.rs @@ -10,6 +10,7 @@ use std::sync::Arc; use command_buffer::cb::AddCommand; use command_buffer::cb::CommandBufferBuild; +use command_buffer::CommandAddError; use command_buffer::CommandBufferBuilder; use command_buffer::commands_raw; use device::Device; @@ -81,14 +82,14 @@ macro_rules! pass_through { type Out = DeviceCheckLayer; #[inline] - fn add(self, command: $cmd) -> Self::Out { + fn add(self, command: $cmd) -> Result { let inner_device = self.inner.device().internal_object(); let cmd_device = command.device().internal_object(); assert_eq!(inner_device, cmd_device); - DeviceCheckLayer { - inner: self.inner.add(command), - } + Ok(DeviceCheckLayer { + inner: self.inner.add(command)?, + }) } } ); @@ -100,10 +101,10 @@ macro_rules! pass_through { type Out = DeviceCheckLayer; #[inline] - fn add(self, command: $cmd) -> Self::Out { - DeviceCheckLayer { - inner: self.inner.add(command), - } + fn add(self, command: $cmd) -> Result { + Ok(DeviceCheckLayer { + inner: self.inner.add(command)?, + }) } } ); diff --git a/vulkano/src/command_buffer/cb/queue_ty_check.rs b/vulkano/src/command_buffer/cb/queue_ty_check.rs index dec1cc436..ecfc68c92 100644 --- a/vulkano/src/command_buffer/cb/queue_ty_check.rs +++ b/vulkano/src/command_buffer/cb/queue_ty_check.rs @@ -10,6 +10,7 @@ use std::sync::Arc; use command_buffer::cb::AddCommand; use command_buffer::cb::CommandBufferBuild; +use command_buffer::CommandAddError; use command_buffer::CommandBufferBuilder; use command_buffer::commands_raw; use device::Device; @@ -110,12 +111,12 @@ macro_rules! q_ty_impl_always { type Out = QueueTyCheckLayer; #[inline] - fn add(self, command: $cmd) -> Self::Out { - QueueTyCheckLayer { - inner: self.inner.add(command), + fn add(self, command: $cmd) -> Result { + Ok(QueueTyCheckLayer { + inner: self.inner.add(command)?, supports_graphics: self.supports_graphics, supports_compute: self.supports_compute, - } + }) } } } @@ -135,13 +136,16 @@ macro_rules! q_ty_impl_graphics { type Out = QueueTyCheckLayer; #[inline] - fn add(self, command: $cmd) -> Self::Out { - assert!(self.supports_graphics()); // TODO: proper error - QueueTyCheckLayer { - inner: self.inner.add(command), + fn add(self, command: $cmd) -> Result { + if !self.supports_graphics() { + return Err(CommandAddError::GraphicsOperationsNotSupported); + } + + Ok(QueueTyCheckLayer { + inner: self.inner.add(command)?, supports_graphics: self.supports_graphics, supports_compute: self.supports_compute, - } + }) } } } @@ -167,13 +171,16 @@ macro_rules! q_ty_impl_compute { type Out = QueueTyCheckLayer; #[inline] - fn add(self, command: $cmd) -> Self::Out { - assert!(self.supports_compute()); // TODO: proper error - QueueTyCheckLayer { - inner: self.inner.add(command), + fn add(self, command: $cmd) -> Result { + if !self.supports_compute() { + return Err(CommandAddError::ComputeOperationsNotSupported); + } + + Ok(QueueTyCheckLayer { + inner: self.inner.add(command)?, supports_graphics: self.supports_graphics, supports_compute: self.supports_compute, - } + }) } } } @@ -189,13 +196,13 @@ macro_rules! q_ty_impl_graphics_or_compute { type Out = QueueTyCheckLayer; #[inline] - fn add(self, command: $cmd) -> Self::Out { - assert!(self.supports_graphics() || self.supports_compute()); // TODO: proper error - QueueTyCheckLayer { - inner: self.inner.add(command), + fn add(self, command: $cmd) -> Result { + assert!(self.supports_graphics() || self.supports_compute()); // TODO: proper error? + Ok(QueueTyCheckLayer { + inner: self.inner.add(command)?, supports_graphics: self.supports_graphics, supports_compute: self.supports_compute, - } + }) } } } @@ -211,18 +218,22 @@ unsafe impl AddCommand> for QueueTyC type Out = QueueTyCheckLayer; #[inline] - fn add(self, command: commands_raw::CmdBindPipeline) -> Self::Out { + fn add(self, command: commands_raw::CmdBindPipeline) -> Result { if command.is_graphics() { - assert!(self.supports_graphics()); // TODO: proper error + if !self.supports_graphics() { + return Err(CommandAddError::GraphicsOperationsNotSupported); + } } else { - assert!(self.supports_compute()); // TODO: proper error + if !self.supports_compute() { + return Err(CommandAddError::ComputeOperationsNotSupported); + } } - QueueTyCheckLayer { - inner: self.inner.add(command), + Ok(QueueTyCheckLayer { + inner: self.inner.add(command)?, supports_graphics: self.supports_graphics, supports_compute: self.supports_compute, - } + }) } } @@ -232,17 +243,21 @@ unsafe impl AddCommand> type Out = QueueTyCheckLayer; #[inline] - fn add(self, command: commands_raw::CmdBindDescriptorSets) -> Self::Out { + fn add(self, command: commands_raw::CmdBindDescriptorSets) -> Result { if command.is_graphics() { - assert!(self.supports_graphics()); // TODO: proper error + if !self.supports_graphics() { + return Err(CommandAddError::GraphicsOperationsNotSupported); + } } else { - assert!(self.supports_compute()); // TODO: proper error + if !self.supports_compute() { + return Err(CommandAddError::ComputeOperationsNotSupported); + } } - QueueTyCheckLayer { - inner: self.inner.add(command), + Ok(QueueTyCheckLayer { + inner: self.inner.add(command)?, supports_graphics: self.supports_graphics, supports_compute: self.supports_compute, - } + }) } } diff --git a/vulkano/src/command_buffer/cb/state_cache.rs b/vulkano/src/command_buffer/cb/state_cache.rs index 73b8e3868..f32585baf 100644 --- a/vulkano/src/command_buffer/cb/state_cache.rs +++ b/vulkano/src/command_buffer/cb/state_cache.rs @@ -10,6 +10,7 @@ use std::sync::Arc; use command_buffer::cb::AddCommand; use command_buffer::cb::CommandBufferBuild; +use command_buffer::CommandAddError; use command_buffer::CommandBufferBuilder; use command_buffer::commands_raw; use command_buffer::DynamicState; @@ -95,7 +96,7 @@ unsafe impl AddCommand> for StateCac type Out = StateCacheLayer; #[inline] - fn add(mut self, command: commands_raw::CmdBindPipeline) -> Self::Out { + fn add(mut self, command: commands_raw::CmdBindPipeline) -> Result { let raw_pipeline = command.sys().internal_object(); let new_command = { @@ -116,12 +117,12 @@ unsafe impl AddCommand> for StateCac } }; - StateCacheLayer { - inner: self.inner.add(new_command), + Ok(StateCacheLayer { + inner: self.inner.add(new_command)?, dynamic_state: DynamicState::none(), graphics_pipeline: self.graphics_pipeline, compute_pipeline: self.compute_pipeline, - } + }) } } @@ -131,16 +132,16 @@ unsafe impl AddCommand> for State type Out = StateCacheLayer; #[inline] - fn add(self, command: commands_raw::CmdExecuteCommands) -> Self::Out { + fn add(self, command: commands_raw::CmdExecuteCommands) -> Result { // After a secondary command buffer is added, all states at reset to the "unknown" state. - let new_inner = self.inner.add(command); + let new_inner = self.inner.add(command)?; - StateCacheLayer { + Ok(StateCacheLayer { inner: new_inner, dynamic_state: DynamicState::none(), compute_pipeline: 0, graphics_pipeline: 0, - } + }) } } @@ -150,7 +151,7 @@ unsafe impl AddCommand for StateCacheLayer type Out = StateCacheLayer; #[inline] - fn add(mut self, command: commands_raw::CmdSetState) -> Self::Out { + fn add(mut self, command: commands_raw::CmdSetState) -> Result { // We need to synchronize `self.dynamic_state` with the state in `command`. // While doing so, we tweak `command` to erase the states that are the same as what's // already in `self.dynamic_state`. @@ -168,12 +169,12 @@ unsafe impl AddCommand for StateCacheLayer // TODO: missing implementations - StateCacheLayer { - inner: self.inner.add(commands_raw::CmdSetState::new(command.device().clone(), command_state)), + Ok(StateCacheLayer { + inner: self.inner.add(commands_raw::CmdSetState::new(command.device().clone(), command_state))?, dynamic_state: self.dynamic_state, graphics_pipeline: self.graphics_pipeline, compute_pipeline: self.compute_pipeline, - } + }) } } @@ -197,13 +198,13 @@ macro_rules! pass_through { type Out = StateCacheLayer; #[inline] - fn add(self, command: $cmd) -> Self::Out { - StateCacheLayer { - inner: self.inner.add(command), + fn add(self, command: $cmd) -> Result { + Ok(StateCacheLayer { + inner: self.inner.add(command)?, dynamic_state: self.dynamic_state, graphics_pipeline: self.graphics_pipeline, compute_pipeline: self.compute_pipeline, - } + }) } } } diff --git a/vulkano/src/command_buffer/cb/submit_sync.rs b/vulkano/src/command_buffer/cb/submit_sync.rs index 75cfbd6c9..57da75d55 100644 --- a/vulkano/src/command_buffer/cb/submit_sync.rs +++ b/vulkano/src/command_buffer/cb/submit_sync.rs @@ -14,6 +14,7 @@ use buffer::BufferAccess; use command_buffer::cb::AddCommand; use command_buffer::cb::CommandBufferBuild; use command_buffer::cb::UnsafeCommandBuffer; +use command_buffer::CommandAddError; use command_buffer::CommandBuffer; use command_buffer::CommandBufferBuilder; use command_buffer::commands_raw; @@ -126,12 +127,12 @@ macro_rules! pass_through { type Out = SubmitSyncBuilderLayer; #[inline] - fn add(self, command: $cmd) -> Self::Out { - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + fn add(self, command: $cmd) -> Result { + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } } @@ -150,14 +151,14 @@ unsafe impl AddCommand> for SubmitS type Out = SubmitSyncBuilderLayer; #[inline] - fn add(mut self, command: commands_raw::CmdBindIndexBuffer) -> Self::Out { + fn add(mut self, command: commands_raw::CmdBindIndexBuffer) -> Result { self.add_buffer(command.buffer(), false); - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -167,12 +168,12 @@ unsafe impl AddCommand> for SubmitSync type Out = SubmitSyncBuilderLayer; #[inline] - fn add(self, command: commands_raw::CmdBindPipeline

) -> Self::Out { - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + fn add(self, command: commands_raw::CmdBindPipeline

) -> Result { + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -184,15 +185,15 @@ unsafe impl AddCommand> for SubmitS type Out = SubmitSyncBuilderLayer; #[inline] - fn add(mut self, command: commands_raw::CmdBlitImage) -> Self::Out { + fn add(mut self, command: commands_raw::CmdBlitImage) -> Result { self.add_image(command.source(), false); self.add_image(command.destination(), true); - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -202,12 +203,12 @@ unsafe impl AddCommand for SubmitSyncBu type Out = SubmitSyncBuilderLayer; #[inline] - fn add(self, command: commands_raw::CmdClearAttachments) -> Self::Out { - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + fn add(self, command: commands_raw::CmdClearAttachments) -> Result { + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -219,15 +220,15 @@ unsafe impl AddCommand> for Submit type Out = SubmitSyncBuilderLayer; #[inline] - fn add(mut self, command: commands_raw::CmdCopyBuffer) -> Self::Out { + fn add(mut self, command: commands_raw::CmdCopyBuffer) -> Result { self.add_buffer(command.source(), false); self.add_buffer(command.destination(), true); - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -239,15 +240,15 @@ unsafe impl AddCommand> for type Out = SubmitSyncBuilderLayer; #[inline] - fn add(mut self, command: commands_raw::CmdCopyBufferToImage) -> Self::Out { + fn add(mut self, command: commands_raw::CmdCopyBufferToImage) -> Result { self.add_buffer(command.source(), false); self.add_image(command.destination(), true); - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -259,15 +260,15 @@ unsafe impl AddCommand> for SubmitS type Out = SubmitSyncBuilderLayer; #[inline] - fn add(mut self, command: commands_raw::CmdCopyImage) -> Self::Out { + fn add(mut self, command: commands_raw::CmdCopyImage) -> Result { self.add_image(command.source(), false); self.add_image(command.destination(), true); - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -277,12 +278,12 @@ unsafe impl AddCommand for SubmitSyncBuilder type Out = SubmitSyncBuilderLayer; #[inline] - fn add(self, command: commands_raw::CmdDispatchRaw) -> Self::Out { - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + fn add(self, command: commands_raw::CmdDispatchRaw) -> Result { + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -292,12 +293,12 @@ unsafe impl AddCommand for SubmitSyncBuilderLaye type Out = SubmitSyncBuilderLayer; #[inline] - fn add(self, command: commands_raw::CmdDrawRaw) -> Self::Out { - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + fn add(self, command: commands_raw::CmdDrawRaw) -> Result { + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -307,12 +308,12 @@ unsafe impl AddCommand for SubmitSyncBuil type Out = SubmitSyncBuilderLayer; #[inline] - fn add(self, command: commands_raw::CmdDrawIndexedRaw) -> Self::Out { - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + fn add(self, command: commands_raw::CmdDrawIndexedRaw) -> Result { + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -322,12 +323,12 @@ unsafe impl AddCommand for SubmitSyncBuild type Out = SubmitSyncBuilderLayer; #[inline] - fn add(self, command: commands_raw::CmdEndRenderPass) -> Self::Out { - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + fn add(self, command: commands_raw::CmdEndRenderPass) -> Result { + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -338,14 +339,14 @@ unsafe impl AddCommand> for SubmitSyncBu type Out = SubmitSyncBuilderLayer; #[inline] - fn add(mut self, command: commands_raw::CmdFillBuffer) -> Self::Out { + fn add(mut self, command: commands_raw::CmdFillBuffer) -> Result { self.add_buffer(command.buffer(), true); - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -355,12 +356,12 @@ unsafe impl AddCommand for SubmitSyncBuilder type Out = SubmitSyncBuilderLayer; #[inline] - fn add(self, command: commands_raw::CmdNextSubpass) -> Self::Out { - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + fn add(self, command: commands_raw::CmdNextSubpass) -> Result { + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -370,12 +371,12 @@ unsafe impl AddCommand> for type Out = SubmitSyncBuilderLayer; #[inline] - fn add(self, command: commands_raw::CmdPushConstants) -> Self::Out { - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + fn add(self, command: commands_raw::CmdPushConstants) -> Result { + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -387,15 +388,15 @@ unsafe impl AddCommand> for Subm type Out = SubmitSyncBuilderLayer; #[inline] - fn add(mut self, command: commands_raw::CmdResolveImage) -> Self::Out { + fn add(mut self, command: commands_raw::CmdResolveImage) -> Result { self.add_image(command.source(), false); self.add_image(command.destination(), true); - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -405,12 +406,12 @@ unsafe impl AddCommand for SubmitSyncBuilderLay type Out = SubmitSyncBuilderLayer; #[inline] - fn add(self, command: commands_raw::CmdSetEvent) -> Self::Out { - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + fn add(self, command: commands_raw::CmdSetEvent) -> Result { + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -420,12 +421,12 @@ unsafe impl AddCommand for SubmitSyncBuilderLay type Out = SubmitSyncBuilderLayer; #[inline] - fn add(self, command: commands_raw::CmdSetState) -> Self::Out { - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + fn add(self, command: commands_raw::CmdSetState) -> Result { + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } @@ -436,14 +437,14 @@ unsafe impl AddCommand> for Subm type Out = SubmitSyncBuilderLayer; #[inline] - fn add(mut self, command: commands_raw::CmdUpdateBuffer) -> Self::Out { + fn add(mut self, command: commands_raw::CmdUpdateBuffer) -> Result { self.add_buffer(command.buffer(), true); - SubmitSyncBuilderLayer { - inner: AddCommand::add(self.inner, command), + Ok(SubmitSyncBuilderLayer { + inner: AddCommand::add(self.inner, command)?, buffers: self.buffers, images: self.images, - } + }) } } diff --git a/vulkano/src/command_buffer/cb/traits.rs b/vulkano/src/command_buffer/cb/traits.rs index d167f59c3..72e59e436 100644 --- a/vulkano/src/command_buffer/cb/traits.rs +++ b/vulkano/src/command_buffer/cb/traits.rs @@ -7,6 +7,8 @@ // notice may not be copied, modified, or distributed except // according to those terms. +use command_buffer::CommandAddError; + /// Adds a command to a command buffer builder. pub unsafe trait AddCommand { /// The new command buffer builder type. @@ -14,5 +16,5 @@ pub unsafe trait AddCommand { /// Adds the command. This takes ownership of the builder and returns a new builder with the /// command appended at the end of it. - fn add(self, cmd: C) -> Self::Out; + fn add(self, cmd: C) -> Result; } diff --git a/vulkano/src/command_buffer/commands_extra/dispatch.rs b/vulkano/src/command_buffer/commands_extra/dispatch.rs index 9918679cc..1b45275d0 100644 --- a/vulkano/src/command_buffer/commands_extra/dispatch.rs +++ b/vulkano/src/command_buffer/commands_extra/dispatch.rs @@ -11,6 +11,7 @@ use std::error; use std::fmt; use command_buffer::cb::AddCommand; +use command_buffer::CommandAddError; use command_buffer::commands_raw::CmdBindDescriptorSets; use command_buffer::commands_raw::CmdBindDescriptorSetsError; use command_buffer::commands_raw::CmdBindPipeline; @@ -60,11 +61,11 @@ unsafe impl AddCommand> for C type Out = O; #[inline] - fn add(self, command: CmdDispatch) -> O { - self.add(command.push_constants) - .add(command.descriptor_sets) - .add(command.bind_pipeline) - .add(command.dispatch_raw) + fn add(self, command: CmdDispatch) -> Result { + Ok(self.add(command.push_constants)? + .add(command.descriptor_sets)? + .add(command.bind_pipeline)? + .add(command.dispatch_raw)?) } } diff --git a/vulkano/src/command_buffer/commands_extra/dispatch_indirect.rs b/vulkano/src/command_buffer/commands_extra/dispatch_indirect.rs index cabcac0a1..8551d4104 100644 --- a/vulkano/src/command_buffer/commands_extra/dispatch_indirect.rs +++ b/vulkano/src/command_buffer/commands_extra/dispatch_indirect.rs @@ -19,6 +19,7 @@ use command_buffer::commands_raw::CmdBindDescriptorSetsError; use command_buffer::commands_raw::CmdBindPipeline; use command_buffer::commands_raw::CmdPushConstants; use command_buffer::commands_raw::CmdPushConstantsError; +use command_buffer::CommandAddError; use command_buffer::DispatchIndirectCommand; use command_buffer::RawCommandBufferPrototype; use command_buffer::CommandsList; diff --git a/vulkano/src/command_buffer/commands_extra/draw.rs b/vulkano/src/command_buffer/commands_extra/draw.rs index 0162fce2b..023edabe6 100644 --- a/vulkano/src/command_buffer/commands_extra/draw.rs +++ b/vulkano/src/command_buffer/commands_extra/draw.rs @@ -7,6 +7,7 @@ // notice may not be copied, modified, or distributed except // according to those terms. +use command_buffer::CommandAddError; use command_buffer::DynamicState; use command_buffer::cb::AddCommand; use command_buffer::commands_raw::CmdBindDescriptorSets; @@ -69,12 +70,12 @@ unsafe impl AddCommand) -> O { - self.add(command.vertex_buffers) - .add(command.push_constants) - .add(command.descriptor_sets) - .add(command.set_state) - .add(command.bind_pipeline) - .add(command.draw_raw) + fn add(self, command: CmdDraw) -> Result { + Ok(self.add(command.vertex_buffers)? + .add(command.push_constants)? + .add(command.descriptor_sets)? + .add(command.set_state)? + .add(command.bind_pipeline)? + .add(command.draw_raw)?) } } diff --git a/vulkano/src/command_buffer/commands_extra/draw_indexed.rs b/vulkano/src/command_buffer/commands_extra/draw_indexed.rs index 23e8af402..37f982109 100644 --- a/vulkano/src/command_buffer/commands_extra/draw_indexed.rs +++ b/vulkano/src/command_buffer/commands_extra/draw_indexed.rs @@ -9,6 +9,7 @@ use buffer::BufferAccess; use buffer::TypedBuffer; +use command_buffer::CommandAddError; use command_buffer::DynamicState; use command_buffer::cb::AddCommand; use command_buffer::commands_raw::CmdBindDescriptorSets; @@ -88,13 +89,13 @@ unsafe impl AddCommand) -> O { - self.add(command.vertex_buffers) - .add(command.index_buffer) - .add(command.push_constants) - .add(command.descriptor_sets) - .add(command.set_state) - .add(command.bind_pipeline) - .add(command.draw_indexed_raw) + fn add(self, command: CmdDrawIndexed) -> Result { + Ok(self.add(command.vertex_buffers)? + .add(command.index_buffer)? + .add(command.push_constants)? + .add(command.descriptor_sets)? + .add(command.set_state)? + .add(command.bind_pipeline)? + .add(command.draw_indexed_raw)?) } } diff --git a/vulkano/src/command_buffer/commands_raw/begin_render_pass.rs b/vulkano/src/command_buffer/commands_raw/begin_render_pass.rs index 7ef82e57e..6352b7cf3 100644 --- a/vulkano/src/command_buffer/commands_raw/begin_render_pass.rs +++ b/vulkano/src/command_buffer/commands_raw/begin_render_pass.rs @@ -12,6 +12,7 @@ use std::ops::Range; use std::ptr; use smallvec::SmallVec; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -124,7 +125,7 @@ unsafe impl<'a, P, Rp, F> AddCommand<&'a CmdBeginRenderPass> for UnsafeCo type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdBeginRenderPass) -> Self::Out { + fn add(self, command: &'a CmdBeginRenderPass) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -151,6 +152,6 @@ unsafe impl<'a, P, Rp, F> AddCommand<&'a CmdBeginRenderPass> for UnsafeCo vk.CmdBeginRenderPass(cmd, &begin, command.contents); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/bind_descriptor_sets.rs b/vulkano/src/command_buffer/commands_raw/bind_descriptor_sets.rs index 93ac9365c..cc8f84eae 100644 --- a/vulkano/src/command_buffer/commands_raw/bind_descriptor_sets.rs +++ b/vulkano/src/command_buffer/commands_raw/bind_descriptor_sets.rs @@ -13,6 +13,7 @@ use std::ptr; use std::sync::Arc; use smallvec::SmallVec; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -119,7 +120,7 @@ unsafe impl<'a, P, Pl, S> AddCommand<&'a CmdBindDescriptorSets> for Unsaf type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdBindDescriptorSets) -> Self::Out { + fn add(self, command: &'a CmdBindDescriptorSets) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -131,7 +132,7 @@ unsafe impl<'a, P, Pl, S> AddCommand<&'a CmdBindDescriptorSets> for Unsaf } } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/bind_index_buffer.rs b/vulkano/src/command_buffer/commands_raw/bind_index_buffer.rs index fa5980408..daf29b2ec 100644 --- a/vulkano/src/command_buffer/commands_raw/bind_index_buffer.rs +++ b/vulkano/src/command_buffer/commands_raw/bind_index_buffer.rs @@ -11,6 +11,7 @@ use std::sync::Arc; use buffer::BufferAccess; use buffer::TypedBuffer; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -89,13 +90,13 @@ unsafe impl<'a, P, B> AddCommand<&'a CmdBindIndexBuffer> for UnsafeCommandBuf type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdBindIndexBuffer) -> Self::Out { + fn add(self, command: &'a CmdBindIndexBuffer) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); vk.CmdBindIndexBuffer(cmd, command.raw_buffer, command.offset, command.index_type); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/bind_pipeline.rs b/vulkano/src/command_buffer/commands_raw/bind_pipeline.rs index e9a95b685..d5567af91 100644 --- a/vulkano/src/command_buffer/commands_raw/bind_pipeline.rs +++ b/vulkano/src/command_buffer/commands_raw/bind_pipeline.rs @@ -10,6 +10,7 @@ use std::marker::PhantomData; use std::sync::Arc; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -105,7 +106,7 @@ unsafe impl<'a, P, Pl> AddCommand<&'a CmdBindPipeline> for UnsafeCommandBuff type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdBindPipeline) -> Self::Out { + fn add(self, command: &'a CmdBindPipeline) -> Result { if command.raw_pipeline != 0 { unsafe { let vk = self.device().pointers(); @@ -114,7 +115,7 @@ unsafe impl<'a, P, Pl> AddCommand<&'a CmdBindPipeline> for UnsafeCommandBuff } } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/bind_vertex_buffers.rs b/vulkano/src/command_buffer/commands_raw/bind_vertex_buffers.rs index a65a8cf52..edd67e8f1 100644 --- a/vulkano/src/command_buffer/commands_raw/bind_vertex_buffers.rs +++ b/vulkano/src/command_buffer/commands_raw/bind_vertex_buffers.rs @@ -10,6 +10,7 @@ use std::sync::Arc; use smallvec::SmallVec; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -70,7 +71,7 @@ unsafe impl<'a, P, B> AddCommand<&'a CmdBindVertexBuffers> for UnsafeCommandB type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdBindVertexBuffers) -> Self::Out { + fn add(self, command: &'a CmdBindVertexBuffers) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -78,6 +79,6 @@ unsafe impl<'a, P, B> AddCommand<&'a CmdBindVertexBuffers> for UnsafeCommandB command.raw_buffers.as_ptr(), command.offsets.as_ptr()); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/blit_image.rs b/vulkano/src/command_buffer/commands_raw/blit_image.rs index 45739b9f6..e4e485d32 100644 --- a/vulkano/src/command_buffer/commands_raw/blit_image.rs +++ b/vulkano/src/command_buffer/commands_raw/blit_image.rs @@ -10,6 +10,7 @@ use std::error; use std::fmt; use std::sync::Arc; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -80,7 +81,7 @@ unsafe impl<'a, P, S, D> AddCommand<&'a CmdBlitImage> for UnsafeCommandBuf type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdBlitImage) -> Self::Out { + fn add(self, command: &'a CmdBlitImage) -> Result { unsafe { debug_assert!(command.source_layout == vk::IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL || command.source_layout == vk::IMAGE_LAYOUT_GENERAL); @@ -133,7 +134,7 @@ unsafe impl<'a, P, S, D> AddCommand<&'a CmdBlitImage> for UnsafeCommandBuf 1, ®ion as *const _, command.filter); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/clear_attachments.rs b/vulkano/src/command_buffer/commands_raw/clear_attachments.rs index d4e7fee4a..f855daf9a 100644 --- a/vulkano/src/command_buffer/commands_raw/clear_attachments.rs +++ b/vulkano/src/command_buffer/commands_raw/clear_attachments.rs @@ -9,6 +9,7 @@ use smallvec::SmallVec; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -33,7 +34,7 @@ unsafe impl<'a, P> AddCommand<&'a CmdClearAttachments> for UnsafeCommandBufferBu type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdClearAttachments) -> Self::Out { + fn add(self, command: &'a CmdClearAttachments) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -43,6 +44,6 @@ unsafe impl<'a, P> AddCommand<&'a CmdClearAttachments> for UnsafeCommandBufferBu command.rects.as_ptr()); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/copy_buffer.rs b/vulkano/src/command_buffer/commands_raw/copy_buffer.rs index 05da9062a..849def48b 100644 --- a/vulkano/src/command_buffer/commands_raw/copy_buffer.rs +++ b/vulkano/src/command_buffer/commands_raw/copy_buffer.rs @@ -13,6 +13,7 @@ use std::fmt; use std::sync::Arc; use buffer::BufferAccess; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -120,7 +121,7 @@ unsafe impl<'a, P, S, D> AddCommand<&'a CmdCopyBuffer> for UnsafeCommandBu type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdCopyBuffer) -> Self::Out { + fn add(self, command: &'a CmdCopyBuffer) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -134,7 +135,7 @@ unsafe impl<'a, P, S, D> AddCommand<&'a CmdCopyBuffer> for UnsafeCommandBu vk.CmdCopyBuffer(cmd, command.source_raw, command.destination_raw, 1, ®ion); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/copy_buffer_to_image.rs b/vulkano/src/command_buffer/commands_raw/copy_buffer_to_image.rs index 1d3aa32f2..63f98939b 100644 --- a/vulkano/src/command_buffer/commands_raw/copy_buffer_to_image.rs +++ b/vulkano/src/command_buffer/commands_raw/copy_buffer_to_image.rs @@ -11,6 +11,7 @@ use std::error; use std::fmt; use std::sync::Arc; use buffer::BufferAccess; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -149,7 +150,7 @@ unsafe impl<'a, P, S, D> AddCommand<&'a CmdCopyBufferToImage> for UnsafeCo type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdCopyBufferToImage) -> Self::Out { + fn add(self, command: &'a CmdCopyBufferToImage) -> Result { unsafe { debug_assert!(command.destination_layout == vk::IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL || command.destination_layout == vk::IMAGE_LAYOUT_GENERAL); @@ -182,7 +183,7 @@ unsafe impl<'a, P, S, D> AddCommand<&'a CmdCopyBufferToImage> for UnsafeCo command.destination_layout, 1, ®ion as *const _); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/copy_image.rs b/vulkano/src/command_buffer/commands_raw/copy_image.rs index fcf7b10fe..0f50ac982 100644 --- a/vulkano/src/command_buffer/commands_raw/copy_image.rs +++ b/vulkano/src/command_buffer/commands_raw/copy_image.rs @@ -10,6 +10,7 @@ use std::error; use std::fmt; use std::sync::Arc; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -79,7 +80,7 @@ unsafe impl<'a, P, S, D> AddCommand<&'a CmdCopyImage> for UnsafeCommandBuf type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdCopyImage) -> Self::Out { + fn add(self, command: &'a CmdCopyImage) -> Result { unsafe { debug_assert!(command.source_layout == vk::IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL || command.source_layout == vk::IMAGE_LAYOUT_GENERAL); @@ -123,7 +124,7 @@ unsafe impl<'a, P, S, D> AddCommand<&'a CmdCopyImage> for UnsafeCommandBuf 1, ®ion as *const _); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/dispatch_raw.rs b/vulkano/src/command_buffer/commands_raw/dispatch_raw.rs index a4962cf82..4fdc3413f 100644 --- a/vulkano/src/command_buffer/commands_raw/dispatch_raw.rs +++ b/vulkano/src/command_buffer/commands_raw/dispatch_raw.rs @@ -11,6 +11,7 @@ use std::error; use std::fmt; use std::sync::Arc; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -97,7 +98,7 @@ unsafe impl<'a, P> AddCommand<&'a CmdDispatchRaw> for UnsafeCommandBufferBuilder type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdDispatchRaw) -> Self::Out { + fn add(self, command: &'a CmdDispatchRaw) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -105,7 +106,7 @@ unsafe impl<'a, P> AddCommand<&'a CmdDispatchRaw> for UnsafeCommandBufferBuilder command.dimensions[2]); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/draw_indexed_raw.rs b/vulkano/src/command_buffer/commands_raw/draw_indexed_raw.rs index e39cb6df8..393dc6592 100644 --- a/vulkano/src/command_buffer/commands_raw/draw_indexed_raw.rs +++ b/vulkano/src/command_buffer/commands_raw/draw_indexed_raw.rs @@ -7,6 +7,7 @@ // notice may not be copied, modified, or distributed except // according to those terms. +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -66,7 +67,7 @@ unsafe impl<'a, P> AddCommand<&'a CmdDrawIndexedRaw> for UnsafeCommandBufferBuil type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdDrawIndexedRaw) -> Self::Out { + fn add(self, command: &'a CmdDrawIndexedRaw) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -74,6 +75,6 @@ unsafe impl<'a, P> AddCommand<&'a CmdDrawIndexedRaw> for UnsafeCommandBufferBuil command.first_index, command.vertex_offset, command.first_instance); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/draw_indirect_raw.rs b/vulkano/src/command_buffer/commands_raw/draw_indirect_raw.rs index 5b685b988..a5a13a2f7 100644 --- a/vulkano/src/command_buffer/commands_raw/draw_indirect_raw.rs +++ b/vulkano/src/command_buffer/commands_raw/draw_indirect_raw.rs @@ -9,6 +9,7 @@ use std::sync::Arc; use buffer::BufferAccess; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -58,7 +59,7 @@ unsafe impl<'a, B, P> AddCommand<&'a CmdDrawIndirectRaw> for UnsafeCommandBuf type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdDrawIndirectRaw) -> Self::Out { + fn add(self, command: &'a CmdDrawIndirectRaw) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -66,6 +67,6 @@ unsafe impl<'a, B, P> AddCommand<&'a CmdDrawIndirectRaw> for UnsafeCommandBuf command.offset, command.draw_count, command.stride); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/draw_raw.rs b/vulkano/src/command_buffer/commands_raw/draw_raw.rs index fe15a7014..a6a6393e6 100644 --- a/vulkano/src/command_buffer/commands_raw/draw_raw.rs +++ b/vulkano/src/command_buffer/commands_raw/draw_raw.rs @@ -7,6 +7,7 @@ // notice may not be copied, modified, or distributed except // according to those terms. +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -61,7 +62,7 @@ unsafe impl<'a, P> AddCommand<&'a CmdDrawRaw> for UnsafeCommandBufferBuilder

type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdDrawRaw) -> Self::Out { + fn add(self, command: &'a CmdDrawRaw) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -69,6 +70,6 @@ unsafe impl<'a, P> AddCommand<&'a CmdDrawRaw> for UnsafeCommandBufferBuilder

command.first_instance); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/end_render_pass.rs b/vulkano/src/command_buffer/commands_raw/end_render_pass.rs index 9a27e3ee2..0862688e9 100644 --- a/vulkano/src/command_buffer/commands_raw/end_render_pass.rs +++ b/vulkano/src/command_buffer/commands_raw/end_render_pass.rs @@ -7,6 +7,7 @@ // notice may not be copied, modified, or distributed except // according to those terms. +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -32,13 +33,13 @@ unsafe impl<'a, P> AddCommand<&'a CmdEndRenderPass> for UnsafeCommandBufferBuild type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdEndRenderPass) -> Self::Out { + fn add(self, command: &'a CmdEndRenderPass) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); vk.CmdEndRenderPass(cmd); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/execute.rs b/vulkano/src/command_buffer/commands_raw/execute.rs index a4bd1922c..e67261876 100644 --- a/vulkano/src/command_buffer/commands_raw/execute.rs +++ b/vulkano/src/command_buffer/commands_raw/execute.rs @@ -10,6 +10,7 @@ use std::sync::Arc; use smallvec::SmallVec; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -60,13 +61,13 @@ unsafe impl<'a, P, Cb> AddCommand<&'a CmdExecuteCommands> for UnsafeCommandB type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdExecuteCommands) -> Self::Out { + fn add(self, command: &'a CmdExecuteCommands) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); vk.CmdExecuteCommands(cmd, command.raw_list.len() as u32, command.raw_list.as_ptr()); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/fill_buffer.rs b/vulkano/src/command_buffer/commands_raw/fill_buffer.rs index 00d8c9515..da4efeee4 100644 --- a/vulkano/src/command_buffer/commands_raw/fill_buffer.rs +++ b/vulkano/src/command_buffer/commands_raw/fill_buffer.rs @@ -13,6 +13,7 @@ use std::sync::Arc; use buffer::BufferAccess; use buffer::BufferInner; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -87,7 +88,7 @@ unsafe impl<'a, P, B> AddCommand<&'a CmdFillBuffer> for UnsafeCommandBufferBu type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdFillBuffer) -> Self::Out { + fn add(self, command: &'a CmdFillBuffer) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -95,7 +96,7 @@ unsafe impl<'a, P, B> AddCommand<&'a CmdFillBuffer> for UnsafeCommandBufferBu command.size, command.data); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/next_subpass.rs b/vulkano/src/command_buffer/commands_raw/next_subpass.rs index d6e9627b7..729398673 100644 --- a/vulkano/src/command_buffer/commands_raw/next_subpass.rs +++ b/vulkano/src/command_buffer/commands_raw/next_subpass.rs @@ -7,6 +7,7 @@ // notice may not be copied, modified, or distributed except // according to those terms. +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -39,13 +40,13 @@ unsafe impl<'a, P> AddCommand<&'a CmdNextSubpass> for UnsafeCommandBufferBuilder type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdNextSubpass) -> Self::Out { + fn add(self, command: &'a CmdNextSubpass) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); vk.CmdNextSubpass(cmd, command.contents); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/pipeline_barrier.rs b/vulkano/src/command_buffer/commands_raw/pipeline_barrier.rs index a13bab9f6..8824e3c9d 100644 --- a/vulkano/src/command_buffer/commands_raw/pipeline_barrier.rs +++ b/vulkano/src/command_buffer/commands_raw/pipeline_barrier.rs @@ -15,6 +15,7 @@ use smallvec::SmallVec; use buffer::BufferAccess; use buffer::BufferInner; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -239,14 +240,14 @@ unsafe impl<'a, P> AddCommand<&'a CmdPipelineBarrier<'a>> for UnsafeCommandBuffe type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdPipelineBarrier<'a>) -> Self::Out { + fn add(self, command: &'a CmdPipelineBarrier<'a>) -> Result { // If barrier is empty, don't do anything. if command.src_stage_mask == 0 || command.dst_stage_mask == 0 { debug_assert!(command.src_stage_mask == 0 && command.dst_stage_mask == 0); debug_assert!(command.memory_barriers.is_empty()); debug_assert!(command.buffer_barriers.is_empty()); debug_assert!(command.image_barriers.is_empty()); - return self; + return Ok(self); } unsafe { @@ -262,6 +263,6 @@ unsafe impl<'a, P> AddCommand<&'a CmdPipelineBarrier<'a>> for UnsafeCommandBuffe command.image_barriers.as_ptr()); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/push_constants.rs b/vulkano/src/command_buffer/commands_raw/push_constants.rs index b5cba3721..43cc63d2e 100644 --- a/vulkano/src/command_buffer/commands_raw/push_constants.rs +++ b/vulkano/src/command_buffer/commands_raw/push_constants.rs @@ -11,6 +11,7 @@ use std::error; use std::fmt; use std::sync::Arc; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -70,7 +71,7 @@ unsafe impl<'a, P, Pc, Pl> AddCommand<&'a CmdPushConstants> for UnsafeCo type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdPushConstants) -> Self::Out { + fn add(self, command: &'a CmdPushConstants) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -92,7 +93,7 @@ unsafe impl<'a, P, Pc, Pl> AddCommand<&'a CmdPushConstants> for UnsafeCo } } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/resolve_image.rs b/vulkano/src/command_buffer/commands_raw/resolve_image.rs index 49b875ae2..c46260ee5 100644 --- a/vulkano/src/command_buffer/commands_raw/resolve_image.rs +++ b/vulkano/src/command_buffer/commands_raw/resolve_image.rs @@ -10,6 +10,7 @@ use std::error; use std::fmt; use std::sync::Arc; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -79,7 +80,7 @@ unsafe impl<'a, P, S, D> AddCommand<&'a CmdResolveImage> for UnsafeCommand type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdResolveImage) -> Self::Out { + fn add(self, command: &'a CmdResolveImage) -> Result { unsafe { debug_assert!(command.source_layout == vk::IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL || command.source_layout == vk::IMAGE_LAYOUT_GENERAL); @@ -123,7 +124,7 @@ unsafe impl<'a, P, S, D> AddCommand<&'a CmdResolveImage> for UnsafeCommand 1, ®ion as *const _); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/set_event.rs b/vulkano/src/command_buffer/commands_raw/set_event.rs index d895d8e5e..3b37ca68a 100644 --- a/vulkano/src/command_buffer/commands_raw/set_event.rs +++ b/vulkano/src/command_buffer/commands_raw/set_event.rs @@ -8,6 +8,7 @@ // according to those terms. use std::sync::Arc; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -44,7 +45,7 @@ unsafe impl<'a, P> AddCommand<&'a CmdSetEvent> for UnsafeCommandBufferBuilder

type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdSetEvent) -> Self::Out { + fn add(self, command: &'a CmdSetEvent) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -55,6 +56,6 @@ unsafe impl<'a, P> AddCommand<&'a CmdSetEvent> for UnsafeCommandBufferBuilder

} } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/set_state.rs b/vulkano/src/command_buffer/commands_raw/set_state.rs index 3165162fe..00475b4ea 100644 --- a/vulkano/src/command_buffer/commands_raw/set_state.rs +++ b/vulkano/src/command_buffer/commands_raw/set_state.rs @@ -10,6 +10,7 @@ use std::sync::Arc; use smallvec::SmallVec; +use command_buffer::CommandAddError; use command_buffer::DynamicState; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; @@ -73,7 +74,7 @@ unsafe impl<'a, P> AddCommand<&'a CmdSetState> for UnsafeCommandBufferBuilder

type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdSetState) -> Self::Out { + fn add(self, command: &'a CmdSetState) -> Result { unsafe { let vk = self.device().pointers(); let cmd = self.internal_object(); @@ -93,6 +94,6 @@ unsafe impl<'a, P> AddCommand<&'a CmdSetState> for UnsafeCommandBufferBuilder

} } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/commands_raw/update_buffer.rs b/vulkano/src/command_buffer/commands_raw/update_buffer.rs index 2afe036cc..7d75888d0 100644 --- a/vulkano/src/command_buffer/commands_raw/update_buffer.rs +++ b/vulkano/src/command_buffer/commands_raw/update_buffer.rs @@ -15,6 +15,7 @@ use std::ptr; use buffer::BufferAccess; use buffer::BufferInner; +use command_buffer::CommandAddError; use command_buffer::cb::AddCommand; use command_buffer::cb::UnsafeCommandBufferBuilder; use command_buffer::pool::CommandPool; @@ -109,7 +110,7 @@ unsafe impl<'a, P, B, D> AddCommand<&'a CmdUpdateBuffer> for UnsafeCommand type Out = UnsafeCommandBufferBuilder

; #[inline] - fn add(self, command: &'a CmdUpdateBuffer) -> Self::Out { + fn add(self, command: &'a CmdUpdateBuffer) -> Result { unsafe { let data = if command.data_ptr.is_null() { &command.data as *const D as *const _ @@ -122,7 +123,7 @@ unsafe impl<'a, P, B, D> AddCommand<&'a CmdUpdateBuffer> for UnsafeCommand vk.CmdUpdateBuffer(cmd, command.buffer_handle, command.offset, command.size, data); } - self + Ok(self) } } diff --git a/vulkano/src/command_buffer/mod.rs b/vulkano/src/command_buffer/mod.rs index 87deb272a..3d2d4bad6 100644 --- a/vulkano/src/command_buffer/mod.rs +++ b/vulkano/src/command_buffer/mod.rs @@ -75,8 +75,8 @@ //! information. pub use self::auto::AutoCommandBufferBuilder; +pub use self::builder::CommandAddError; pub use self::builder::CommandBufferBuilder; -pub use self::builder::CommandBufferBuilderBuffered; pub use self::traits::CommandBuffer; pub use self::traits::CommandBufferBuild; pub use self::traits::CommandBufferExecFuture;