mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-21 22:34:43 +00:00
Remove the command buffer traits (#2419)
* Remove command buffer traits * Fix docs * Fix examples
This commit is contained in:
parent
3fe821a754
commit
4cd3b74f14
@ -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,
|
||||
|
@ -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<dyn SecondaryCommandBufferAbstract>) {
|
||||
pub fn execute(&mut self, command_buffer: Arc<SecondaryAutoCommandBuffer>) {
|
||||
self.frame
|
||||
.command_buffer_builder
|
||||
.as_mut()
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -5,7 +5,6 @@ use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||
PrimaryCommandBufferAbstract,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
|
@ -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,
|
||||
|
@ -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::{
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
/// };
|
||||
|
@ -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,
|
||||
|
@ -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<ValidationError>> {
|
||||
pub fn lock_record(&self) -> Result<(), Box<ValidationError>> {
|
||||
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,
|
||||
|
@ -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<L> AutoCommandBufferBuilder<L> {
|
||||
/// with `Flags::OneTimeSubmit` will set `self`'s flags to `Flags::OneTimeSubmit` also.
|
||||
pub fn execute_commands(
|
||||
&mut self,
|
||||
command_buffer: Arc<dyn SecondaryCommandBufferAbstract>,
|
||||
command_buffer: Arc<SecondaryAutoCommandBuffer>,
|
||||
) -> Result<&mut Self, Box<ValidationError>> {
|
||||
let command_buffer = DropUnlockCommandBuffer::new(command_buffer)?;
|
||||
self.validate_execute_commands(iter::once(&**command_buffer))?;
|
||||
@ -41,7 +41,7 @@ impl<L> AutoCommandBufferBuilder<L> {
|
||||
// TODO ^ would be nice if this just worked without errors
|
||||
pub fn execute_commands_from_vec(
|
||||
&mut self,
|
||||
command_buffers: Vec<Arc<dyn SecondaryCommandBufferAbstract>>,
|
||||
command_buffers: Vec<Arc<SecondaryAutoCommandBuffer>>,
|
||||
) -> Result<&mut Self, Box<ValidationError>> {
|
||||
let command_buffers: SmallVec<[_; 4]> = command_buffers
|
||||
.into_iter()
|
||||
@ -55,7 +55,7 @@ impl<L> AutoCommandBufferBuilder<L> {
|
||||
|
||||
fn validate_execute_commands<'a>(
|
||||
&self,
|
||||
command_buffers: impl Iterator<Item = &'a dyn SecondaryCommandBufferAbstract> + Clone,
|
||||
command_buffers: impl Iterator<Item = &'a SecondaryAutoCommandBuffer> + Clone,
|
||||
) -> Result<(), Box<ValidationError>> {
|
||||
self.inner
|
||||
.validate_execute_commands(command_buffers.clone())?;
|
||||
@ -461,7 +461,7 @@ impl<L> AutoCommandBufferBuilder<L> {
|
||||
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
|
||||
pub unsafe fn execute_commands_unchecked(
|
||||
&mut self,
|
||||
command_buffers: SmallVec<[Arc<dyn SecondaryCommandBufferAbstract>; 4]>,
|
||||
command_buffers: SmallVec<[Arc<SecondaryAutoCommandBuffer>; 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<dyn SecondaryCommandBufferAbstract>],
|
||||
command_buffers: &[Arc<SecondaryAutoCommandBuffer>],
|
||||
) -> Result<&mut Self, Box<ValidationError>> {
|
||||
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<Item = &'a dyn SecondaryCommandBufferAbstract>,
|
||||
command_buffers: impl Iterator<Item = &'a SecondaryAutoCommandBuffer>,
|
||||
) -> Result<(), Box<ValidationError>> {
|
||||
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<dyn SecondaryCommandBufferAbstract>],
|
||||
command_buffers: &[Arc<SecondaryAutoCommandBuffer>],
|
||||
) -> &mut Self {
|
||||
if command_buffers.is_empty() {
|
||||
return self;
|
||||
@ -664,19 +664,17 @@ impl UnsafeCommandBufferBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
struct DropUnlockCommandBuffer(Arc<dyn SecondaryCommandBufferAbstract>);
|
||||
struct DropUnlockCommandBuffer(Arc<SecondaryAutoCommandBuffer>);
|
||||
|
||||
impl DropUnlockCommandBuffer {
|
||||
fn new(
|
||||
command_buffer: Arc<dyn SecondaryCommandBufferAbstract>,
|
||||
) -> Result<Self, Box<ValidationError>> {
|
||||
fn new(command_buffer: Arc<SecondaryAutoCommandBuffer>) -> Result<Self, Box<ValidationError>> {
|
||||
command_buffer.lock_record()?;
|
||||
Ok(Self(command_buffer))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for DropUnlockCommandBuffer {
|
||||
type Target = Arc<dyn SecondaryCommandBufferAbstract>;
|
||||
type Target = Arc<SecondaryAutoCommandBuffer>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
|
@ -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<vulkano::device::Device> = 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<dyn PrimaryCommandBufferAbstract>,
|
||||
pub command_buffer: Arc<PrimaryAutoCommandBuffer>,
|
||||
|
||||
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<dyn PrimaryCommandBufferAbstract>) -> Self {
|
||||
pub fn new(command_buffer: Arc<PrimaryAutoCommandBuffer>) -> Self {
|
||||
Self {
|
||||
command_buffer,
|
||||
_ne: crate::NonExhaustive(()),
|
||||
|
@ -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<Handle = ash::vk::CommandBuffer> + 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<Self>,
|
||||
queue: Arc<Queue>,
|
||||
) -> Result<CommandBufferExecFuture<NowFuture>, 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<F>(
|
||||
pub fn execute_after<F>(
|
||||
self: Arc<Self>,
|
||||
future: F,
|
||||
queue: Arc<Queue>,
|
||||
@ -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<T> PrimaryCommandBufferAbstract for T
|
||||
where
|
||||
T: VulkanObject<Handle = ash::vk::CommandBuffer> + 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<Handle = ash::vk::CommandBuffer> + 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<ValidationError>>;
|
||||
|
||||
/// 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<T> SecondaryCommandBufferAbstract for T
|
||||
where
|
||||
T: VulkanObject<Handle = ash::vk::CommandBuffer> + 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<ValidationError>> {
|
||||
(**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<dyn PrimaryCommandBufferAbstract>,
|
||||
command_buffer: Arc<PrimaryAutoCommandBuffer>,
|
||||
queue: Arc<Queue>,
|
||||
// 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.
|
||||
|
@ -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<Queue>,
|
||||
command_buffer: Arc<impl PrimaryCommandBufferAbstract + 'static>,
|
||||
command_buffer: Arc<PrimaryAutoCommandBuffer>,
|
||||
) -> Result<CommandBufferExecFuture<Self>, CommandBufferExecError>
|
||||
where
|
||||
Self: Sized,
|
||||
@ -256,7 +256,7 @@ pub unsafe trait GpuFuture: DeviceOwned {
|
||||
/// > `CommandBuffer` trait.
|
||||
fn then_execute_same_queue(
|
||||
self,
|
||||
command_buffer: Arc<impl PrimaryCommandBufferAbstract + 'static>,
|
||||
command_buffer: Arc<PrimaryAutoCommandBuffer>,
|
||||
) -> Result<CommandBufferExecFuture<Self>, CommandBufferExecError>
|
||||
where
|
||||
Self: Sized,
|
||||
|
Loading…
Reference in New Issue
Block a user