mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 00:04:15 +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},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BufferImageCopy,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BufferImageCopy,
|
||||||
ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo,
|
ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo, RenderPassBeginInfo,
|
||||||
PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
|
@ -8,7 +8,7 @@ use std::sync::Arc;
|
|||||||
use vulkano::{
|
use vulkano::{
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
PrimaryAutoCommandBuffer, RenderPassBeginInfo, SecondaryCommandBufferAbstract,
|
PrimaryAutoCommandBuffer, RenderPassBeginInfo, SecondaryAutoCommandBuffer,
|
||||||
SubpassBeginInfo, SubpassContents,
|
SubpassBeginInfo, SubpassContents,
|
||||||
},
|
},
|
||||||
descriptor_set::allocator::StandardDescriptorSetAllocator,
|
descriptor_set::allocator::StandardDescriptorSetAllocator,
|
||||||
@ -487,7 +487,7 @@ pub struct DrawPass<'f, 's: 'f> {
|
|||||||
|
|
||||||
impl<'f, 's: 'f> DrawPass<'f, 's> {
|
impl<'f, 's: 'f> DrawPass<'f, 's> {
|
||||||
/// Appends a command that executes a secondary command buffer that performs drawing.
|
/// 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
|
self.frame
|
||||||
.command_buffer_builder
|
.command_buffer_builder
|
||||||
.as_mut()
|
.as_mut()
|
||||||
|
@ -4,7 +4,7 @@ use vulkano::{
|
|||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BlitImageInfo,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, BlitImageInfo,
|
||||||
BufferImageCopy, ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo,
|
BufferImageCopy, ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo,
|
||||||
CopyImageInfo, ImageBlit, ImageCopy, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
CopyImageInfo, ImageBlit, ImageCopy, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
|
@ -3,7 +3,7 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
CopyBufferToImageInfo, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
|
@ -12,7 +12,7 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
CopyBufferToImageInfo, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
|
@ -5,7 +5,6 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
PrimaryCommandBufferAbstract,
|
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
|
@ -58,7 +58,7 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyImageToBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
CopyImageToBufferInfo, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
device::{
|
device::{
|
||||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
||||||
|
@ -3,7 +3,7 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
CopyBufferToImageInfo, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{layout::DescriptorSetLayoutCreateFlags, WriteDescriptorSet},
|
descriptor_set::{layout::DescriptorSetLayoutCreateFlags, WriteDescriptorSet},
|
||||||
device::{
|
device::{
|
||||||
|
@ -3,7 +3,7 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
CopyBufferToImageInfo, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, layout::DescriptorBindingFlags, DescriptorSet,
|
allocator::StandardDescriptorSetAllocator, layout::DescriptorBindingFlags, DescriptorSet,
|
||||||
|
@ -8,7 +8,7 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
CopyBufferInfo, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
|
@ -3,7 +3,7 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
CopyBufferToImageInfo, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
|
@ -78,9 +78,7 @@ const MAX_ARENAS: usize = 32;
|
|||||||
/// allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
|
/// allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
|
||||||
/// BufferUsage,
|
/// BufferUsage,
|
||||||
/// },
|
/// },
|
||||||
/// command_buffer::{
|
/// command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage},
|
||||||
/// AutoCommandBufferBuilder, CommandBufferUsage, PrimaryCommandBufferAbstract,
|
|
||||||
/// },
|
|
||||||
/// memory::allocator::MemoryTypeFilter,
|
/// memory::allocator::MemoryTypeFilter,
|
||||||
/// sync::GpuFuture,
|
/// sync::GpuFuture,
|
||||||
/// };
|
/// };
|
||||||
|
@ -121,10 +121,7 @@ pub mod view;
|
|||||||
/// ```
|
/// ```
|
||||||
/// use vulkano::{
|
/// use vulkano::{
|
||||||
/// buffer::{BufferUsage, Buffer, BufferCreateInfo},
|
/// buffer::{BufferUsage, Buffer, BufferCreateInfo},
|
||||||
/// command_buffer::{
|
/// command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage, CopyBufferInfo},
|
||||||
/// AutoCommandBufferBuilder, CommandBufferUsage, CopyBufferInfo,
|
|
||||||
/// PrimaryCommandBufferAbstract,
|
|
||||||
/// },
|
|
||||||
/// memory::allocator::{AllocationCreateInfo, MemoryTypeFilter},
|
/// memory::allocator::{AllocationCreateInfo, MemoryTypeFilter},
|
||||||
/// sync::GpuFuture,
|
/// sync::GpuFuture,
|
||||||
/// DeviceSize,
|
/// DeviceSize,
|
||||||
|
@ -64,8 +64,8 @@ pub(in crate::command_buffer) use self::builder::{
|
|||||||
use super::{
|
use super::{
|
||||||
sys::{UnsafeCommandBuffer, UnsafeCommandBufferBuilder},
|
sys::{UnsafeCommandBuffer, UnsafeCommandBufferBuilder},
|
||||||
CommandBufferInheritanceInfo, CommandBufferResourcesUsage, CommandBufferState,
|
CommandBufferInheritanceInfo, CommandBufferResourcesUsage, CommandBufferState,
|
||||||
CommandBufferUsage, PrimaryCommandBufferAbstract, ResourceInCommand,
|
CommandBufferUsage, ResourceInCommand, SecondaryCommandBufferResourcesUsage,
|
||||||
SecondaryCommandBufferAbstract, SecondaryCommandBufferResourcesUsage, SecondaryResourceUseRef,
|
SecondaryResourceUseRef,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::Subbuffer,
|
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]
|
#[inline]
|
||||||
fn queue_family_index(&self) -> u32 {
|
pub fn queue_family_index(&self) -> u32 {
|
||||||
self.inner.queue_family_index()
|
self.inner.queue_family_index()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the usage of this command buffer.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn usage(&self) -> CommandBufferUsage {
|
pub fn usage(&self) -> CommandBufferUsage {
|
||||||
self.inner.usage()
|
self.inner.usage()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
pub(crate) fn state(&self) -> MutexGuard<'_, CommandBufferState> {
|
||||||
fn state(&self) -> MutexGuard<'_, CommandBufferState> {
|
|
||||||
self.state.lock()
|
self.state.lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
pub(crate) fn resources_usage(&self) -> &CommandBufferResourcesUsage {
|
||||||
fn resources_usage(&self) -> &CommandBufferResourcesUsage {
|
|
||||||
&self.resources_usage
|
&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]
|
#[inline]
|
||||||
fn usage(&self) -> CommandBufferUsage {
|
pub fn usage(&self) -> CommandBufferUsage {
|
||||||
self.inner.usage()
|
self.inner.usage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a `CommandBufferInheritance` value describing the properties that the command
|
||||||
|
/// buffer inherits from its parent primary command buffer.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn inheritance_info(&self) -> &CommandBufferInheritanceInfo {
|
pub fn inheritance_info(&self) -> &CommandBufferInheritanceInfo {
|
||||||
self.inner.inheritance_info().as_ref().unwrap()
|
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]
|
#[inline]
|
||||||
fn lock_record(&self) -> Result<(), Box<ValidationError>> {
|
pub fn lock_record(&self) -> Result<(), Box<ValidationError>> {
|
||||||
match self.submit_state {
|
match self.submit_state {
|
||||||
SubmitState::OneTime {
|
SubmitState::OneTime {
|
||||||
ref already_submitted,
|
ref already_submitted,
|
||||||
@ -202,8 +225,13 @@ unsafe impl SecondaryCommandBufferAbstract for SecondaryAutoCommandBuffer {
|
|||||||
Ok(())
|
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]
|
#[inline]
|
||||||
unsafe fn unlock(&self) {
|
pub unsafe fn unlock(&self) {
|
||||||
match self.submit_state {
|
match self.submit_state {
|
||||||
SubmitState::OneTime {
|
SubmitState::OneTime {
|
||||||
ref already_submitted,
|
ref already_submitted,
|
||||||
@ -218,8 +246,7 @@ unsafe impl SecondaryCommandBufferAbstract for SecondaryAutoCommandBuffer {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
pub(crate) fn resources_usage(&self) -> &SecondaryCommandBufferResourcesUsage {
|
||||||
fn resources_usage(&self) -> &SecondaryCommandBufferResourcesUsage {
|
|
||||||
&self.resources_usage
|
&self.resources_usage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -304,7 +331,6 @@ mod tests {
|
|||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::{StandardCommandBufferAllocator, StandardCommandBufferAllocatorCreateInfo},
|
allocator::{StandardCommandBufferAllocator, StandardCommandBufferAllocatorCreateInfo},
|
||||||
AutoCommandBufferBuilder, BufferCopy, CommandBufferUsage, CopyBufferInfoTyped,
|
AutoCommandBufferBuilder, BufferCopy, CommandBufferUsage, CopyBufferInfoTyped,
|
||||||
PrimaryCommandBufferAbstract,
|
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator,
|
allocator::StandardDescriptorSetAllocator,
|
||||||
|
@ -3,7 +3,7 @@ use crate::{
|
|||||||
auto::{RenderPassStateType, Resource, ResourceUseRef2},
|
auto::{RenderPassStateType, Resource, ResourceUseRef2},
|
||||||
sys::UnsafeCommandBufferBuilder,
|
sys::UnsafeCommandBufferBuilder,
|
||||||
AutoCommandBufferBuilder, CommandBufferInheritanceRenderPassType, CommandBufferLevel,
|
AutoCommandBufferBuilder, CommandBufferInheritanceRenderPassType, CommandBufferLevel,
|
||||||
ResourceInCommand, SecondaryCommandBufferAbstract, SecondaryCommandBufferBufferUsage,
|
ResourceInCommand, SecondaryAutoCommandBuffer, SecondaryCommandBufferBufferUsage,
|
||||||
SecondaryCommandBufferImageUsage, SecondaryCommandBufferResourcesUsage, SubpassContents,
|
SecondaryCommandBufferImageUsage, SecondaryCommandBufferResourcesUsage, SubpassContents,
|
||||||
},
|
},
|
||||||
device::{DeviceOwned, QueueFlags},
|
device::{DeviceOwned, QueueFlags},
|
||||||
@ -25,7 +25,7 @@ impl<L> AutoCommandBufferBuilder<L> {
|
|||||||
/// with `Flags::OneTimeSubmit` will set `self`'s flags to `Flags::OneTimeSubmit` also.
|
/// with `Flags::OneTimeSubmit` will set `self`'s flags to `Flags::OneTimeSubmit` also.
|
||||||
pub fn execute_commands(
|
pub fn execute_commands(
|
||||||
&mut self,
|
&mut self,
|
||||||
command_buffer: Arc<dyn SecondaryCommandBufferAbstract>,
|
command_buffer: Arc<SecondaryAutoCommandBuffer>,
|
||||||
) -> Result<&mut Self, Box<ValidationError>> {
|
) -> Result<&mut Self, Box<ValidationError>> {
|
||||||
let command_buffer = DropUnlockCommandBuffer::new(command_buffer)?;
|
let command_buffer = DropUnlockCommandBuffer::new(command_buffer)?;
|
||||||
self.validate_execute_commands(iter::once(&**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
|
// TODO ^ would be nice if this just worked without errors
|
||||||
pub fn execute_commands_from_vec(
|
pub fn execute_commands_from_vec(
|
||||||
&mut self,
|
&mut self,
|
||||||
command_buffers: Vec<Arc<dyn SecondaryCommandBufferAbstract>>,
|
command_buffers: Vec<Arc<SecondaryAutoCommandBuffer>>,
|
||||||
) -> Result<&mut Self, Box<ValidationError>> {
|
) -> Result<&mut Self, Box<ValidationError>> {
|
||||||
let command_buffers: SmallVec<[_; 4]> = command_buffers
|
let command_buffers: SmallVec<[_; 4]> = command_buffers
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -55,7 +55,7 @@ impl<L> AutoCommandBufferBuilder<L> {
|
|||||||
|
|
||||||
fn validate_execute_commands<'a>(
|
fn validate_execute_commands<'a>(
|
||||||
&self,
|
&self,
|
||||||
command_buffers: impl Iterator<Item = &'a dyn SecondaryCommandBufferAbstract> + Clone,
|
command_buffers: impl Iterator<Item = &'a SecondaryAutoCommandBuffer> + Clone,
|
||||||
) -> Result<(), Box<ValidationError>> {
|
) -> Result<(), Box<ValidationError>> {
|
||||||
self.inner
|
self.inner
|
||||||
.validate_execute_commands(command_buffers.clone())?;
|
.validate_execute_commands(command_buffers.clone())?;
|
||||||
@ -461,7 +461,7 @@ impl<L> AutoCommandBufferBuilder<L> {
|
|||||||
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
|
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
|
||||||
pub unsafe fn execute_commands_unchecked(
|
pub unsafe fn execute_commands_unchecked(
|
||||||
&mut self,
|
&mut self,
|
||||||
command_buffers: SmallVec<[Arc<dyn SecondaryCommandBufferAbstract>; 4]>,
|
command_buffers: SmallVec<[Arc<SecondaryAutoCommandBuffer>; 4]>,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.execute_commands_locked(
|
self.execute_commands_locked(
|
||||||
command_buffers
|
command_buffers
|
||||||
@ -552,7 +552,7 @@ impl UnsafeCommandBufferBuilder {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn execute_commands(
|
pub unsafe fn execute_commands(
|
||||||
&mut self,
|
&mut self,
|
||||||
command_buffers: &[Arc<dyn SecondaryCommandBufferAbstract>],
|
command_buffers: &[Arc<SecondaryAutoCommandBuffer>],
|
||||||
) -> Result<&mut Self, Box<ValidationError>> {
|
) -> Result<&mut Self, Box<ValidationError>> {
|
||||||
self.validate_execute_commands(command_buffers.iter().map(Deref::deref))?;
|
self.validate_execute_commands(command_buffers.iter().map(Deref::deref))?;
|
||||||
|
|
||||||
@ -561,7 +561,7 @@ impl UnsafeCommandBufferBuilder {
|
|||||||
|
|
||||||
fn validate_execute_commands<'a>(
|
fn validate_execute_commands<'a>(
|
||||||
&self,
|
&self,
|
||||||
command_buffers: impl Iterator<Item = &'a dyn SecondaryCommandBufferAbstract>,
|
command_buffers: impl Iterator<Item = &'a SecondaryAutoCommandBuffer>,
|
||||||
) -> Result<(), Box<ValidationError>> {
|
) -> Result<(), Box<ValidationError>> {
|
||||||
if self.level() != CommandBufferLevel::Primary {
|
if self.level() != CommandBufferLevel::Primary {
|
||||||
return Err(Box::new(ValidationError {
|
return Err(Box::new(ValidationError {
|
||||||
@ -609,7 +609,7 @@ impl UnsafeCommandBufferBuilder {
|
|||||||
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
|
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
|
||||||
pub unsafe fn execute_commands_unchecked(
|
pub unsafe fn execute_commands_unchecked(
|
||||||
&mut self,
|
&mut self,
|
||||||
command_buffers: &[Arc<dyn SecondaryCommandBufferAbstract>],
|
command_buffers: &[Arc<SecondaryAutoCommandBuffer>],
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
if command_buffers.is_empty() {
|
if command_buffers.is_empty() {
|
||||||
return self;
|
return self;
|
||||||
@ -664,19 +664,17 @@ impl UnsafeCommandBufferBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DropUnlockCommandBuffer(Arc<dyn SecondaryCommandBufferAbstract>);
|
struct DropUnlockCommandBuffer(Arc<SecondaryAutoCommandBuffer>);
|
||||||
|
|
||||||
impl DropUnlockCommandBuffer {
|
impl DropUnlockCommandBuffer {
|
||||||
fn new(
|
fn new(command_buffer: Arc<SecondaryAutoCommandBuffer>) -> Result<Self, Box<ValidationError>> {
|
||||||
command_buffer: Arc<dyn SecondaryCommandBufferAbstract>,
|
|
||||||
) -> Result<Self, Box<ValidationError>> {
|
|
||||||
command_buffer.lock_record()?;
|
command_buffer.lock_record()?;
|
||||||
Ok(Self(command_buffer))
|
Ok(Self(command_buffer))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::ops::Deref for DropUnlockCommandBuffer {
|
impl std::ops::Deref for DropUnlockCommandBuffer {
|
||||||
type Target = Arc<dyn SecondaryCommandBufferAbstract>;
|
type Target = Arc<SecondaryAutoCommandBuffer>;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.0
|
&self.0
|
||||||
|
@ -22,10 +22,10 @@
|
|||||||
//!
|
//!
|
||||||
//! There are two levels of command buffers:
|
//! There are two levels of command buffers:
|
||||||
//!
|
//!
|
||||||
//! - [`PrimaryCommandBufferAbstract`] can be executed on a queue, and is the main command buffer
|
//! - [`PrimaryAutoCommandBuffer`] can be executed on a queue, and is the main command buffer type.
|
||||||
//! type. It cannot be executed within another command buffer.
|
//! It cannot be executed within another command buffer.
|
||||||
//! - [`SecondaryCommandBufferAbstract`] can only be executed within a primary command buffer,
|
//! - [`SecondaryAutoCommandBuffer`] can only be executed within a primary command buffer, not
|
||||||
//! not directly on a queue.
|
//! directly on a queue.
|
||||||
//!
|
//!
|
||||||
//! Using secondary command buffers, there is slightly more overhead than using primary command
|
//! 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
|
//! buffers alone, but there are also advantages. A single command buffer cannot be recorded
|
||||||
@ -39,28 +39,21 @@
|
|||||||
//! # Recording a command buffer
|
//! # Recording a command buffer
|
||||||
//!
|
//!
|
||||||
//! To record a new command buffer, the most direct way is to create a new
|
//! 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
|
//! [`AutoCommandBufferBuilder`]. You can then call methods on this object to record new commands
|
||||||
//! the command buffer. When you are done recording, you call [`build`] to finalise the command
|
//! 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
|
//! buffer and turn it into either a [`PrimaryAutoCommandBuffer`] or a
|
||||||
//! [`SecondaryCommandBufferAbstract`].
|
//! [`SecondaryAutoCommandBuffer`].
|
||||||
//!
|
|
||||||
// //! 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.
|
|
||||||
//!
|
//!
|
||||||
//! # Submitting a primary command buffer
|
//! # Submitting a primary command buffer
|
||||||
//!
|
//!
|
||||||
//! Once primary a command buffer is recorded and built, you can use the
|
//! Once a primary command buffer is recorded and built, you can submit the
|
||||||
//! [`PrimaryCommandBufferAbstract`] trait to submit the command buffer to a queue. Submitting a
|
//! [`PrimaryAutoCommandBuffer`] to a queue. Submitting a command buffer returns an object that
|
||||||
//! command buffer returns an object that implements the [`GpuFuture`] trait and that represents
|
//! implements the [`GpuFuture`] trait and that represents the moment when the execution will end
|
||||||
//! the moment when the execution will end on the GPU.
|
//! on the GPU.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use vulkano::command_buffer::{
|
//! use vulkano::command_buffer::{
|
||||||
//! AutoCommandBufferBuilder, CommandBufferUsage, PrimaryCommandBufferAbstract,
|
//! AutoCommandBufferBuilder, CommandBufferUsage, SubpassContents,
|
||||||
//! SubpassContents,
|
|
||||||
//! };
|
//! };
|
||||||
//!
|
//!
|
||||||
//! # let device: std::sync::Arc<vulkano::device::Device> = return;
|
//! # let device: std::sync::Arc<vulkano::device::Device> = return;
|
||||||
@ -105,10 +98,7 @@ pub use self::{
|
|||||||
acceleration_structure::*, clear::*, copy::*, debug::*, dynamic_state::*, pipeline::*,
|
acceleration_structure::*, clear::*, copy::*, debug::*, dynamic_state::*, pipeline::*,
|
||||||
query::*, render_pass::*, secondary::*, sync::*,
|
query::*, render_pass::*, secondary::*, sync::*,
|
||||||
},
|
},
|
||||||
traits::{
|
traits::{CommandBufferExecError, CommandBufferExecFuture},
|
||||||
CommandBufferExecError, CommandBufferExecFuture, PrimaryCommandBufferAbstract,
|
|
||||||
SecondaryCommandBufferAbstract,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::{Buffer, Subbuffer},
|
buffer::{Buffer, Subbuffer},
|
||||||
@ -801,7 +791,7 @@ pub struct CommandBufferSubmitInfo {
|
|||||||
/// The command buffer to execute.
|
/// The command buffer to execute.
|
||||||
///
|
///
|
||||||
/// There is no default value.
|
/// There is no default value.
|
||||||
pub command_buffer: Arc<dyn PrimaryCommandBufferAbstract>,
|
pub command_buffer: Arc<PrimaryAutoCommandBuffer>,
|
||||||
|
|
||||||
pub _ne: crate::NonExhaustive,
|
pub _ne: crate::NonExhaustive,
|
||||||
}
|
}
|
||||||
@ -809,7 +799,7 @@ pub struct CommandBufferSubmitInfo {
|
|||||||
impl CommandBufferSubmitInfo {
|
impl CommandBufferSubmitInfo {
|
||||||
/// Returns a `CommandBufferSubmitInfo` with the specified `command_buffer`.
|
/// Returns a `CommandBufferSubmitInfo` with the specified `command_buffer`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(command_buffer: Arc<dyn PrimaryCommandBufferAbstract>) -> Self {
|
pub fn new(command_buffer: Arc<PrimaryAutoCommandBuffer>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
command_buffer,
|
command_buffer,
|
||||||
_ne: crate::NonExhaustive(()),
|
_ne: crate::NonExhaustive(()),
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
use super::{
|
use super::{CommandBufferSubmitInfo, PrimaryAutoCommandBuffer, SemaphoreSubmitInfo, SubmitInfo};
|
||||||
CommandBufferInheritanceInfo, CommandBufferResourcesUsage, CommandBufferState,
|
|
||||||
CommandBufferSubmitInfo, CommandBufferUsage, SecondaryCommandBufferResourcesUsage,
|
|
||||||
SemaphoreSubmitInfo, SubmitInfo,
|
|
||||||
};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
device::{Device, DeviceOwned, Queue},
|
device::{Device, DeviceOwned, Queue},
|
||||||
@ -15,9 +11,9 @@ use crate::{
|
|||||||
},
|
},
|
||||||
PipelineStages,
|
PipelineStages,
|
||||||
},
|
},
|
||||||
DeviceSize, SafeDeref, Validated, ValidationError, VulkanError, VulkanObject,
|
DeviceSize, Validated, VulkanError, VulkanObject,
|
||||||
};
|
};
|
||||||
use parking_lot::{Mutex, MutexGuard};
|
use parking_lot::Mutex;
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
error::Error,
|
error::Error,
|
||||||
@ -30,15 +26,7 @@ use std::{
|
|||||||
thread,
|
thread,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub unsafe trait PrimaryCommandBufferAbstract:
|
impl PrimaryAutoCommandBuffer {
|
||||||
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;
|
|
||||||
|
|
||||||
/// Executes this command buffer on a queue.
|
/// Executes this command buffer on a queue.
|
||||||
///
|
///
|
||||||
/// This function returns an object that implements the [`GpuFuture`] trait. See the
|
/// 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.
|
/// - Panics if the device of the command buffer is not the same as the device of the future.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn execute(
|
pub fn execute(
|
||||||
self: Arc<Self>,
|
self: Arc<Self>,
|
||||||
queue: Arc<Queue>,
|
queue: Arc<Queue>,
|
||||||
) -> Result<CommandBufferExecFuture<NowFuture>, CommandBufferExecError>
|
) -> Result<CommandBufferExecFuture<NowFuture>, CommandBufferExecError>
|
||||||
@ -99,7 +87,7 @@ pub unsafe trait PrimaryCommandBufferAbstract:
|
|||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// - Panics if the device of the command buffer is not the same as the device of the future.
|
/// - 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>,
|
self: Arc<Self>,
|
||||||
future: F,
|
future: F,
|
||||||
queue: Arc<Queue>,
|
queue: Arc<Queue>,
|
||||||
@ -122,93 +110,6 @@ pub unsafe trait PrimaryCommandBufferAbstract:
|
|||||||
finished: AtomicBool::new(false),
|
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
|
/// Represents a command buffer being executed by the GPU and the moment when the execution
|
||||||
@ -220,7 +121,7 @@ where
|
|||||||
F: GpuFuture,
|
F: GpuFuture,
|
||||||
{
|
{
|
||||||
previous: F,
|
previous: F,
|
||||||
command_buffer: Arc<dyn PrimaryCommandBufferAbstract>,
|
command_buffer: Arc<PrimaryAutoCommandBuffer>,
|
||||||
queue: Arc<Queue>,
|
queue: Arc<Queue>,
|
||||||
// True if the command buffer has already been submitted.
|
// 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.
|
// 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},
|
buffer::{Buffer, BufferState},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
CommandBufferExecError, CommandBufferExecFuture, CommandBufferResourcesUsage,
|
CommandBufferExecError, CommandBufferExecFuture, CommandBufferResourcesUsage,
|
||||||
CommandBufferState, CommandBufferSubmitInfo, CommandBufferUsage,
|
CommandBufferState, CommandBufferSubmitInfo, CommandBufferUsage, PrimaryAutoCommandBuffer,
|
||||||
PrimaryCommandBufferAbstract, SubmitInfo,
|
SubmitInfo,
|
||||||
},
|
},
|
||||||
device::{DeviceOwned, Queue},
|
device::{DeviceOwned, Queue},
|
||||||
image::{Image, ImageLayout, ImageState},
|
image::{Image, ImageLayout, ImageState},
|
||||||
@ -242,7 +242,7 @@ pub unsafe trait GpuFuture: DeviceOwned {
|
|||||||
fn then_execute(
|
fn then_execute(
|
||||||
self,
|
self,
|
||||||
queue: Arc<Queue>,
|
queue: Arc<Queue>,
|
||||||
command_buffer: Arc<impl PrimaryCommandBufferAbstract + 'static>,
|
command_buffer: Arc<PrimaryAutoCommandBuffer>,
|
||||||
) -> Result<CommandBufferExecFuture<Self>, CommandBufferExecError>
|
) -> Result<CommandBufferExecFuture<Self>, CommandBufferExecError>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
@ -256,7 +256,7 @@ pub unsafe trait GpuFuture: DeviceOwned {
|
|||||||
/// > `CommandBuffer` trait.
|
/// > `CommandBuffer` trait.
|
||||||
fn then_execute_same_queue(
|
fn then_execute_same_queue(
|
||||||
self,
|
self,
|
||||||
command_buffer: Arc<impl PrimaryCommandBufferAbstract + 'static>,
|
command_buffer: Arc<PrimaryAutoCommandBuffer>,
|
||||||
) -> Result<CommandBufferExecFuture<Self>, CommandBufferExecError>
|
) -> Result<CommandBufferExecFuture<Self>, CommandBufferExecError>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
|
Loading…
Reference in New Issue
Block a user