diff --git a/examples/async-update/main.rs b/examples/async-update/main.rs index 62c4a416..06ce1919 100644 --- a/examples/async-update/main.rs +++ b/examples/async-update/main.rs @@ -43,8 +43,7 @@ use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, command_buffer::{ allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BufferImageCopy, - ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo, - PrimaryCommandBufferAbstract, RenderPassBeginInfo, + ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, diff --git a/examples/deferred/frame/system.rs b/examples/deferred/frame/system.rs index 09bae965..f923c768 100644 --- a/examples/deferred/frame/system.rs +++ b/examples/deferred/frame/system.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use vulkano::{ command_buffer::{ allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, - PrimaryAutoCommandBuffer, RenderPassBeginInfo, SecondaryCommandBufferAbstract, + PrimaryAutoCommandBuffer, RenderPassBeginInfo, SecondaryAutoCommandBuffer, SubpassBeginInfo, SubpassContents, }, descriptor_set::allocator::StandardDescriptorSetAllocator, @@ -487,7 +487,7 @@ pub struct DrawPass<'f, 's: 'f> { impl<'f, 's: 'f> DrawPass<'f, 's> { /// Appends a command that executes a secondary command buffer that performs drawing. - pub fn execute(&mut self, command_buffer: Arc) { + pub fn execute(&mut self, command_buffer: Arc) { self.frame .command_buffer_builder .as_mut() diff --git a/examples/image-self-copy-blit/main.rs b/examples/image-self-copy-blit/main.rs index 1e0ce57c..8396626d 100644 --- a/examples/image-self-copy-blit/main.rs +++ b/examples/image-self-copy-blit/main.rs @@ -4,7 +4,7 @@ use vulkano::{ command_buffer::{ allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BlitImageInfo, BufferImageCopy, ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo, - CopyImageInfo, ImageBlit, ImageCopy, PrimaryCommandBufferAbstract, RenderPassBeginInfo, + CopyImageInfo, ImageBlit, ImageCopy, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, diff --git a/examples/image/main.rs b/examples/image/main.rs index 32ae22b9..965cb58f 100644 --- a/examples/image/main.rs +++ b/examples/image/main.rs @@ -3,7 +3,7 @@ use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, command_buffer::{ allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, - CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, + CopyBufferToImageInfo, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, diff --git a/examples/immutable-sampler/main.rs b/examples/immutable-sampler/main.rs index ef1c02b6..ceece949 100644 --- a/examples/immutable-sampler/main.rs +++ b/examples/immutable-sampler/main.rs @@ -12,7 +12,7 @@ use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, command_buffer::{ allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, - CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, + CopyBufferToImageInfo, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, diff --git a/examples/interactive-fractal/fractal_compute_pipeline.rs b/examples/interactive-fractal/fractal_compute_pipeline.rs index e59f835e..8c3c3f0e 100644 --- a/examples/interactive-fractal/fractal_compute_pipeline.rs +++ b/examples/interactive-fractal/fractal_compute_pipeline.rs @@ -5,7 +5,6 @@ use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, - PrimaryCommandBufferAbstract, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, diff --git a/examples/msaa-renderpass/main.rs b/examples/msaa-renderpass/main.rs index 76039594..f6acb1ca 100644 --- a/examples/msaa-renderpass/main.rs +++ b/examples/msaa-renderpass/main.rs @@ -58,7 +58,7 @@ use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, command_buffer::{ allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, - CopyImageToBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, + CopyImageToBufferInfo, RenderPassBeginInfo, }, device::{ physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo, diff --git a/examples/push-descriptors/main.rs b/examples/push-descriptors/main.rs index fcb8ab05..c1662689 100644 --- a/examples/push-descriptors/main.rs +++ b/examples/push-descriptors/main.rs @@ -3,7 +3,7 @@ use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, command_buffer::{ allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, - CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, + CopyBufferToImageInfo, RenderPassBeginInfo, }, descriptor_set::{layout::DescriptorSetLayoutCreateFlags, WriteDescriptorSet}, device::{ diff --git a/examples/runtime-array/main.rs b/examples/runtime-array/main.rs index 0e01702c..92b168e9 100644 --- a/examples/runtime-array/main.rs +++ b/examples/runtime-array/main.rs @@ -3,7 +3,7 @@ use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, command_buffer::{ allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, - CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, + CopyBufferToImageInfo, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, layout::DescriptorBindingFlags, DescriptorSet, diff --git a/examples/simple-particles/main.rs b/examples/simple-particles/main.rs index ea4132e9..ef3a91ff 100644 --- a/examples/simple-particles/main.rs +++ b/examples/simple-particles/main.rs @@ -8,7 +8,7 @@ use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, command_buffer::{ allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, - CopyBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, + CopyBufferInfo, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, diff --git a/examples/texture-array/main.rs b/examples/texture-array/main.rs index ec9b2fe4..e78f842e 100644 --- a/examples/texture-array/main.rs +++ b/examples/texture-array/main.rs @@ -3,7 +3,7 @@ use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, command_buffer::{ allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage, - CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, + CopyBufferToImageInfo, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, diff --git a/vulkano/src/buffer/allocator.rs b/vulkano/src/buffer/allocator.rs index 44bc93da..774317da 100644 --- a/vulkano/src/buffer/allocator.rs +++ b/vulkano/src/buffer/allocator.rs @@ -78,9 +78,7 @@ const MAX_ARENAS: usize = 32; /// allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo}, /// BufferUsage, /// }, -/// command_buffer::{ -/// AutoCommandBufferBuilder, CommandBufferUsage, PrimaryCommandBufferAbstract, -/// }, +/// command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage}, /// memory::allocator::MemoryTypeFilter, /// sync::GpuFuture, /// }; diff --git a/vulkano/src/buffer/mod.rs b/vulkano/src/buffer/mod.rs index 4a271d78..84255c37 100644 --- a/vulkano/src/buffer/mod.rs +++ b/vulkano/src/buffer/mod.rs @@ -121,10 +121,7 @@ pub mod view; /// ``` /// use vulkano::{ /// buffer::{BufferUsage, Buffer, BufferCreateInfo}, -/// command_buffer::{ -/// AutoCommandBufferBuilder, CommandBufferUsage, CopyBufferInfo, -/// PrimaryCommandBufferAbstract, -/// }, +/// command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage, CopyBufferInfo}, /// memory::allocator::{AllocationCreateInfo, MemoryTypeFilter}, /// sync::GpuFuture, /// DeviceSize, diff --git a/vulkano/src/command_buffer/auto/mod.rs b/vulkano/src/command_buffer/auto/mod.rs index d43c415d..ae0632c0 100644 --- a/vulkano/src/command_buffer/auto/mod.rs +++ b/vulkano/src/command_buffer/auto/mod.rs @@ -64,8 +64,8 @@ pub(in crate::command_buffer) use self::builder::{ use super::{ sys::{UnsafeCommandBuffer, UnsafeCommandBufferBuilder}, CommandBufferInheritanceInfo, CommandBufferResourcesUsage, CommandBufferState, - CommandBufferUsage, PrimaryCommandBufferAbstract, ResourceInCommand, - SecondaryCommandBufferAbstract, SecondaryCommandBufferResourcesUsage, SecondaryResourceUseRef, + CommandBufferUsage, ResourceInCommand, SecondaryCommandBufferResourcesUsage, + SecondaryResourceUseRef, }; use crate::{ buffer::Subbuffer, @@ -109,24 +109,32 @@ unsafe impl DeviceOwned for PrimaryAutoCommandBuffer { } } -unsafe impl PrimaryCommandBufferAbstract for PrimaryAutoCommandBuffer { +impl Debug for PrimaryAutoCommandBuffer { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + f.debug_struct("PrimaryAutoCommandBuffer") + .field("inner", &self.inner) + .finish_non_exhaustive() + } +} + +impl PrimaryAutoCommandBuffer { + /// Returns the queue family index of this command buffer. #[inline] - fn queue_family_index(&self) -> u32 { + pub fn queue_family_index(&self) -> u32 { self.inner.queue_family_index() } + /// Returns the usage of this command buffer. #[inline] - fn usage(&self) -> CommandBufferUsage { + pub fn usage(&self) -> CommandBufferUsage { self.inner.usage() } - #[inline] - fn state(&self) -> MutexGuard<'_, CommandBufferState> { + pub(crate) fn state(&self) -> MutexGuard<'_, CommandBufferState> { self.state.lock() } - #[inline] - fn resources_usage(&self) -> &CommandBufferResourcesUsage { + pub(crate) fn resources_usage(&self) -> &CommandBufferResourcesUsage { &self.resources_usage } } @@ -154,19 +162,34 @@ unsafe impl DeviceOwned for SecondaryAutoCommandBuffer { } } -unsafe impl SecondaryCommandBufferAbstract for SecondaryAutoCommandBuffer { +impl Debug for SecondaryAutoCommandBuffer { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + f.debug_struct("SecondaryAutoCommandBuffer") + .field("inner", &self.inner) + .finish_non_exhaustive() + } +} + +impl SecondaryAutoCommandBuffer { + /// Returns the usage of this command buffer. #[inline] - fn usage(&self) -> CommandBufferUsage { + pub fn usage(&self) -> CommandBufferUsage { self.inner.usage() } + /// Returns a `CommandBufferInheritance` value describing the properties that the command + /// buffer inherits from its parent primary command buffer. #[inline] - fn inheritance_info(&self) -> &CommandBufferInheritanceInfo { + pub fn inheritance_info(&self) -> &CommandBufferInheritanceInfo { self.inner.inheritance_info().as_ref().unwrap() } + /// Checks whether this command buffer is allowed to be recorded to a command buffer, + /// and if so locks it. + /// + /// If you call this function, then you should call `unlock` afterwards. #[inline] - fn lock_record(&self) -> Result<(), Box> { + pub fn lock_record(&self) -> Result<(), Box> { match self.submit_state { SubmitState::OneTime { ref already_submitted, @@ -202,8 +225,13 @@ unsafe impl SecondaryCommandBufferAbstract for SecondaryAutoCommandBuffer { Ok(()) } + /// Unlocks the command buffer. Should be called once for each call to `lock_record`. + /// + /// # Safety + /// + /// Must not be called if you haven't called `lock_record` before. #[inline] - unsafe fn unlock(&self) { + pub unsafe fn unlock(&self) { match self.submit_state { SubmitState::OneTime { ref already_submitted, @@ -218,8 +246,7 @@ unsafe impl SecondaryCommandBufferAbstract for SecondaryAutoCommandBuffer { }; } - #[inline] - fn resources_usage(&self) -> &SecondaryCommandBufferResourcesUsage { + pub(crate) fn resources_usage(&self) -> &SecondaryCommandBufferResourcesUsage { &self.resources_usage } } @@ -304,7 +331,6 @@ mod tests { command_buffer::{ allocator::{StandardCommandBufferAllocator, StandardCommandBufferAllocatorCreateInfo}, AutoCommandBufferBuilder, BufferCopy, CommandBufferUsage, CopyBufferInfoTyped, - PrimaryCommandBufferAbstract, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, diff --git a/vulkano/src/command_buffer/commands/secondary.rs b/vulkano/src/command_buffer/commands/secondary.rs index aa6a5a32..768632da 100644 --- a/vulkano/src/command_buffer/commands/secondary.rs +++ b/vulkano/src/command_buffer/commands/secondary.rs @@ -3,7 +3,7 @@ use crate::{ auto::{RenderPassStateType, Resource, ResourceUseRef2}, sys::UnsafeCommandBufferBuilder, AutoCommandBufferBuilder, CommandBufferInheritanceRenderPassType, CommandBufferLevel, - ResourceInCommand, SecondaryCommandBufferAbstract, SecondaryCommandBufferBufferUsage, + ResourceInCommand, SecondaryAutoCommandBuffer, SecondaryCommandBufferBufferUsage, SecondaryCommandBufferImageUsage, SecondaryCommandBufferResourcesUsage, SubpassContents, }, device::{DeviceOwned, QueueFlags}, @@ -25,7 +25,7 @@ impl AutoCommandBufferBuilder { /// with `Flags::OneTimeSubmit` will set `self`'s flags to `Flags::OneTimeSubmit` also. pub fn execute_commands( &mut self, - command_buffer: Arc, + command_buffer: Arc, ) -> Result<&mut Self, Box> { let command_buffer = DropUnlockCommandBuffer::new(command_buffer)?; self.validate_execute_commands(iter::once(&**command_buffer))?; @@ -41,7 +41,7 @@ impl AutoCommandBufferBuilder { // TODO ^ would be nice if this just worked without errors pub fn execute_commands_from_vec( &mut self, - command_buffers: Vec>, + command_buffers: Vec>, ) -> Result<&mut Self, Box> { let command_buffers: SmallVec<[_; 4]> = command_buffers .into_iter() @@ -55,7 +55,7 @@ impl AutoCommandBufferBuilder { fn validate_execute_commands<'a>( &self, - command_buffers: impl Iterator + Clone, + command_buffers: impl Iterator + Clone, ) -> Result<(), Box> { self.inner .validate_execute_commands(command_buffers.clone())?; @@ -461,7 +461,7 @@ impl AutoCommandBufferBuilder { #[cfg_attr(not(feature = "document_unchecked"), doc(hidden))] pub unsafe fn execute_commands_unchecked( &mut self, - command_buffers: SmallVec<[Arc; 4]>, + command_buffers: SmallVec<[Arc; 4]>, ) -> &mut Self { self.execute_commands_locked( command_buffers @@ -552,7 +552,7 @@ impl UnsafeCommandBufferBuilder { #[inline] pub unsafe fn execute_commands( &mut self, - command_buffers: &[Arc], + command_buffers: &[Arc], ) -> Result<&mut Self, Box> { self.validate_execute_commands(command_buffers.iter().map(Deref::deref))?; @@ -561,7 +561,7 @@ impl UnsafeCommandBufferBuilder { fn validate_execute_commands<'a>( &self, - command_buffers: impl Iterator, + command_buffers: impl Iterator, ) -> Result<(), Box> { if self.level() != CommandBufferLevel::Primary { return Err(Box::new(ValidationError { @@ -609,7 +609,7 @@ impl UnsafeCommandBufferBuilder { #[cfg_attr(not(feature = "document_unchecked"), doc(hidden))] pub unsafe fn execute_commands_unchecked( &mut self, - command_buffers: &[Arc], + command_buffers: &[Arc], ) -> &mut Self { if command_buffers.is_empty() { return self; @@ -664,19 +664,17 @@ impl UnsafeCommandBufferBuilder { } } -struct DropUnlockCommandBuffer(Arc); +struct DropUnlockCommandBuffer(Arc); impl DropUnlockCommandBuffer { - fn new( - command_buffer: Arc, - ) -> Result> { + fn new(command_buffer: Arc) -> Result> { command_buffer.lock_record()?; Ok(Self(command_buffer)) } } impl std::ops::Deref for DropUnlockCommandBuffer { - type Target = Arc; + type Target = Arc; fn deref(&self) -> &Self::Target { &self.0 diff --git a/vulkano/src/command_buffer/mod.rs b/vulkano/src/command_buffer/mod.rs index d43158dc..78a3e6cb 100644 --- a/vulkano/src/command_buffer/mod.rs +++ b/vulkano/src/command_buffer/mod.rs @@ -22,10 +22,10 @@ //! //! There are two levels of command buffers: //! -//! - [`PrimaryCommandBufferAbstract`] can be executed on a queue, and is the main command buffer -//! type. It cannot be executed within another command buffer. -//! - [`SecondaryCommandBufferAbstract`] can only be executed within a primary command buffer, -//! not directly on a queue. +//! - [`PrimaryAutoCommandBuffer`] can be executed on a queue, and is the main command buffer type. +//! It cannot be executed within another command buffer. +//! - [`SecondaryAutoCommandBuffer`] can only be executed within a primary command buffer, not +//! directly on a queue. //! //! Using secondary command buffers, there is slightly more overhead than using primary command //! buffers alone, but there are also advantages. A single command buffer cannot be recorded @@ -39,28 +39,21 @@ //! # Recording a command buffer //! //! To record a new command buffer, the most direct way is to create a new -//! [`AutoCommandBufferBuilder`]. You can then call methods on this object to record new commands to -//! the command buffer. When you are done recording, you call [`build`] to finalise the command -//! buffer and turn it into either a [`PrimaryCommandBufferAbstract`] or a -//! [`SecondaryCommandBufferAbstract`]. -//! -// //! Using the standard `CommandBufferBuilder`, you must enter synchronization commands such as -// //! [pipeline barriers], to ensure that there are no races and memory access hazards. This can be -// //! difficult to do manually, so Vulkano also provides an alternative builder, -// //! [`AutoCommandBufferBuilder`]. Using this builder, you do not have to worry about managing -// //! synchronization, but the end result may not be quite as efficient. +//! [`AutoCommandBufferBuilder`]. You can then call methods on this object to record new commands +//! to the command buffer. When you are done recording, you call [`build`] to finalise the command +//! buffer and turn it into either a [`PrimaryAutoCommandBuffer`] or a +//! [`SecondaryAutoCommandBuffer`]. //! //! # Submitting a primary command buffer //! -//! Once primary a command buffer is recorded and built, you can use the -//! [`PrimaryCommandBufferAbstract`] trait to submit the command buffer to a queue. Submitting a -//! command buffer returns an object that implements the [`GpuFuture`] trait and that represents -//! the moment when the execution will end on the GPU. +//! Once a primary command buffer is recorded and built, you can submit the +//! [`PrimaryAutoCommandBuffer`] to a queue. Submitting a command buffer returns an object that +//! implements the [`GpuFuture`] trait and that represents the moment when the execution will end +//! on the GPU. //! //! ``` //! use vulkano::command_buffer::{ -//! AutoCommandBufferBuilder, CommandBufferUsage, PrimaryCommandBufferAbstract, -//! SubpassContents, +//! AutoCommandBufferBuilder, CommandBufferUsage, SubpassContents, //! }; //! //! # let device: std::sync::Arc = return; @@ -105,10 +98,7 @@ pub use self::{ acceleration_structure::*, clear::*, copy::*, debug::*, dynamic_state::*, pipeline::*, query::*, render_pass::*, secondary::*, sync::*, }, - traits::{ - CommandBufferExecError, CommandBufferExecFuture, PrimaryCommandBufferAbstract, - SecondaryCommandBufferAbstract, - }, + traits::{CommandBufferExecError, CommandBufferExecFuture}, }; use crate::{ buffer::{Buffer, Subbuffer}, @@ -801,7 +791,7 @@ pub struct CommandBufferSubmitInfo { /// The command buffer to execute. /// /// There is no default value. - pub command_buffer: Arc, + pub command_buffer: Arc, pub _ne: crate::NonExhaustive, } @@ -809,7 +799,7 @@ pub struct CommandBufferSubmitInfo { impl CommandBufferSubmitInfo { /// Returns a `CommandBufferSubmitInfo` with the specified `command_buffer`. #[inline] - pub fn new(command_buffer: Arc) -> Self { + pub fn new(command_buffer: Arc) -> Self { Self { command_buffer, _ne: crate::NonExhaustive(()), diff --git a/vulkano/src/command_buffer/traits.rs b/vulkano/src/command_buffer/traits.rs index 4b11c6e0..8a96fe59 100644 --- a/vulkano/src/command_buffer/traits.rs +++ b/vulkano/src/command_buffer/traits.rs @@ -1,8 +1,4 @@ -use super::{ - CommandBufferInheritanceInfo, CommandBufferResourcesUsage, CommandBufferState, - CommandBufferSubmitInfo, CommandBufferUsage, SecondaryCommandBufferResourcesUsage, - SemaphoreSubmitInfo, SubmitInfo, -}; +use super::{CommandBufferSubmitInfo, PrimaryAutoCommandBuffer, SemaphoreSubmitInfo, SubmitInfo}; use crate::{ buffer::Buffer, device::{Device, DeviceOwned, Queue}, @@ -15,9 +11,9 @@ use crate::{ }, PipelineStages, }, - DeviceSize, SafeDeref, Validated, ValidationError, VulkanError, VulkanObject, + DeviceSize, Validated, VulkanError, VulkanObject, }; -use parking_lot::{Mutex, MutexGuard}; +use parking_lot::Mutex; use std::{ borrow::Cow, error::Error, @@ -30,15 +26,7 @@ use std::{ thread, }; -pub unsafe trait PrimaryCommandBufferAbstract: - VulkanObject + DeviceOwned + Send + Sync -{ - /// Returns the queue family index of this command buffer. - fn queue_family_index(&self) -> u32; - - /// Returns the usage of this command buffer. - fn usage(&self) -> CommandBufferUsage; - +impl PrimaryAutoCommandBuffer { /// Executes this command buffer on a queue. /// /// This function returns an object that implements the [`GpuFuture`] trait. See the @@ -62,7 +50,7 @@ pub unsafe trait PrimaryCommandBufferAbstract: /// /// - Panics if the device of the command buffer is not the same as the device of the future. #[inline] - fn execute( + pub fn execute( self: Arc, queue: Arc, ) -> Result, CommandBufferExecError> @@ -99,7 +87,7 @@ pub unsafe trait PrimaryCommandBufferAbstract: /// # Panics /// /// - Panics if the device of the command buffer is not the same as the device of the future. - fn execute_after( + pub fn execute_after( self: Arc, future: F, queue: Arc, @@ -122,93 +110,6 @@ pub unsafe trait PrimaryCommandBufferAbstract: finished: AtomicBool::new(false), }) } - - #[doc(hidden)] - fn state(&self) -> MutexGuard<'_, CommandBufferState>; - - #[doc(hidden)] - fn resources_usage(&self) -> &CommandBufferResourcesUsage; -} - -impl Debug for dyn PrimaryCommandBufferAbstract { - fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { - Debug::fmt(&self.handle(), f) - } -} - -unsafe impl PrimaryCommandBufferAbstract for T -where - T: VulkanObject + SafeDeref + Send + Sync, - T::Target: PrimaryCommandBufferAbstract, -{ - fn queue_family_index(&self) -> u32 { - (**self).queue_family_index() - } - - fn usage(&self) -> CommandBufferUsage { - (**self).usage() - } - - fn state(&self) -> MutexGuard<'_, CommandBufferState> { - (**self).state() - } - - fn resources_usage(&self) -> &CommandBufferResourcesUsage { - (**self).resources_usage() - } -} - -pub unsafe trait SecondaryCommandBufferAbstract: - VulkanObject + DeviceOwned + Send + Sync -{ - /// Returns the usage of this command buffer. - fn usage(&self) -> CommandBufferUsage; - - /// Returns a `CommandBufferInheritance` value describing the properties that the command - /// buffer inherits from its parent primary command buffer. - fn inheritance_info(&self) -> &CommandBufferInheritanceInfo; - - /// Checks whether this command buffer is allowed to be recorded to a command buffer, - /// and if so locks it. - /// - /// If you call this function, then you should call `unlock` afterwards. - fn lock_record(&self) -> Result<(), Box>; - - /// Unlocks the command buffer. Should be called once for each call to `lock_record`. - /// - /// # Safety - /// - /// Must not be called if you haven't called `lock_record` before. - unsafe fn unlock(&self); - - #[doc(hidden)] - fn resources_usage(&self) -> &SecondaryCommandBufferResourcesUsage; -} - -unsafe impl SecondaryCommandBufferAbstract for T -where - T: VulkanObject + SafeDeref + Send + Sync, - T::Target: SecondaryCommandBufferAbstract, -{ - fn usage(&self) -> CommandBufferUsage { - (**self).usage() - } - - fn inheritance_info(&self) -> &CommandBufferInheritanceInfo { - (**self).inheritance_info() - } - - fn lock_record(&self) -> Result<(), Box> { - (**self).lock_record() - } - - unsafe fn unlock(&self) { - (**self).unlock(); - } - - fn resources_usage(&self) -> &SecondaryCommandBufferResourcesUsage { - (**self).resources_usage() - } } /// Represents a command buffer being executed by the GPU and the moment when the execution @@ -220,7 +121,7 @@ where F: GpuFuture, { previous: F, - command_buffer: Arc, + command_buffer: Arc, queue: Arc, // True if the command buffer has already been submitted. // If flush is called multiple times, we want to block so that only one flushing is executed. diff --git a/vulkano/src/sync/future/mod.rs b/vulkano/src/sync/future/mod.rs index 1ba8685e..620cb401 100644 --- a/vulkano/src/sync/future/mod.rs +++ b/vulkano/src/sync/future/mod.rs @@ -92,8 +92,8 @@ use crate::{ buffer::{Buffer, BufferState}, command_buffer::{ CommandBufferExecError, CommandBufferExecFuture, CommandBufferResourcesUsage, - CommandBufferState, CommandBufferSubmitInfo, CommandBufferUsage, - PrimaryCommandBufferAbstract, SubmitInfo, + CommandBufferState, CommandBufferSubmitInfo, CommandBufferUsage, PrimaryAutoCommandBuffer, + SubmitInfo, }, device::{DeviceOwned, Queue}, image::{Image, ImageLayout, ImageState}, @@ -242,7 +242,7 @@ pub unsafe trait GpuFuture: DeviceOwned { fn then_execute( self, queue: Arc, - command_buffer: Arc, + command_buffer: Arc, ) -> Result, CommandBufferExecError> where Self: Sized, @@ -256,7 +256,7 @@ pub unsafe trait GpuFuture: DeviceOwned { /// > `CommandBuffer` trait. fn then_execute_same_queue( self, - command_buffer: Arc, + command_buffer: Arc, ) -> Result, CommandBufferExecError> where Self: Sized,