mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2025-02-17 01:23:00 +00:00
parent
b9ac687d59
commit
82db4298fb
@ -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, RenderPassBeginInfo,
|
CopyImageInfo, ImageBlit, ImageCopy, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
|
@ -3,7 +3,7 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyBufferToImageInfo, RenderPassBeginInfo,
|
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
|
@ -12,7 +12,7 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyBufferToImageInfo, RenderPassBeginInfo,
|
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
|
@ -5,6 +5,7 @@ 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, RenderPassBeginInfo,
|
CopyImageToBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
device::{
|
device::{
|
||||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
||||||
|
@ -6,7 +6,8 @@ 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, RenderPassBeginInfo, SubpassBeginInfo, SubpassContents,
|
CopyImageToBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo, SubpassBeginInfo,
|
||||||
|
SubpassContents,
|
||||||
},
|
},
|
||||||
device::{physical::PhysicalDeviceType, Device, DeviceCreateInfo, QueueCreateInfo, QueueFlags},
|
device::{physical::PhysicalDeviceType, Device, DeviceCreateInfo, QueueCreateInfo, QueueFlags},
|
||||||
format::Format,
|
format::Format,
|
||||||
|
@ -3,7 +3,7 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyBufferToImageInfo, RenderPassBeginInfo,
|
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{layout::DescriptorSetLayoutCreateFlags, WriteDescriptorSet},
|
descriptor_set::{layout::DescriptorSetLayoutCreateFlags, WriteDescriptorSet},
|
||||||
device::{
|
device::{
|
||||||
|
@ -3,7 +3,7 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyBufferToImageInfo, RenderPassBeginInfo,
|
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, 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, Subbuffer},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyBufferInfo, RenderPassBeginInfo,
|
CopyBufferInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
|
@ -3,7 +3,7 @@ use vulkano::{
|
|||||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||||
command_buffer::{
|
command_buffer::{
|
||||||
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
allocator::StandardCommandBufferAllocator, AutoCommandBufferBuilder, CommandBufferUsage,
|
||||||
CopyBufferToImageInfo, RenderPassBeginInfo,
|
CopyBufferToImageInfo, PrimaryCommandBufferAbstract, RenderPassBeginInfo,
|
||||||
},
|
},
|
||||||
descriptor_set::{
|
descriptor_set::{
|
||||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||||
|
@ -78,7 +78,9 @@ const MAX_ARENAS: usize = 32;
|
|||||||
/// allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
|
/// allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
|
||||||
/// BufferUsage,
|
/// BufferUsage,
|
||||||
/// },
|
/// },
|
||||||
/// command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage},
|
/// command_buffer::{
|
||||||
|
/// AutoCommandBufferBuilder, CommandBufferUsage, PrimaryCommandBufferAbstract,
|
||||||
|
/// },
|
||||||
/// memory::allocator::MemoryTypeFilter,
|
/// memory::allocator::MemoryTypeFilter,
|
||||||
/// sync::GpuFuture,
|
/// sync::GpuFuture,
|
||||||
/// };
|
/// };
|
||||||
|
@ -121,7 +121,10 @@ pub mod view;
|
|||||||
/// ```
|
/// ```
|
||||||
/// use vulkano::{
|
/// use vulkano::{
|
||||||
/// buffer::{BufferUsage, Buffer, BufferCreateInfo},
|
/// buffer::{BufferUsage, Buffer, BufferCreateInfo},
|
||||||
/// command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage, CopyBufferInfo},
|
/// command_buffer::{
|
||||||
|
/// AutoCommandBufferBuilder, CommandBufferUsage, CopyBufferInfo,
|
||||||
|
/// PrimaryCommandBufferAbstract,
|
||||||
|
/// },
|
||||||
/// memory::allocator::{AllocationCreateInfo, MemoryTypeFilter},
|
/// memory::allocator::{AllocationCreateInfo, MemoryTypeFilter},
|
||||||
/// sync::GpuFuture,
|
/// sync::GpuFuture,
|
||||||
/// DeviceSize,
|
/// DeviceSize,
|
||||||
|
@ -65,8 +65,8 @@ pub(in crate::command_buffer) use self::builder::{
|
|||||||
use super::{
|
use super::{
|
||||||
sys::{CommandBuffer, RecordingCommandBuffer},
|
sys::{CommandBuffer, RecordingCommandBuffer},
|
||||||
CommandBufferInheritanceInfo, CommandBufferResourcesUsage, CommandBufferState,
|
CommandBufferInheritanceInfo, CommandBufferResourcesUsage, CommandBufferState,
|
||||||
CommandBufferUsage, ResourceInCommand, SecondaryCommandBufferResourcesUsage,
|
CommandBufferUsage, PrimaryCommandBufferAbstract, ResourceInCommand,
|
||||||
SecondaryResourceUseRef,
|
SecondaryCommandBufferAbstract, SecondaryCommandBufferResourcesUsage, SecondaryResourceUseRef,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::Subbuffer,
|
buffer::Subbuffer,
|
||||||
@ -118,30 +118,27 @@ impl Debug for PrimaryAutoCommandBuffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrimaryAutoCommandBuffer {
|
unsafe impl PrimaryCommandBufferAbstract for PrimaryAutoCommandBuffer {
|
||||||
/// Returns the inner raw command buffer.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner(&self) -> &CommandBuffer {
|
fn as_raw(&self) -> &CommandBuffer {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the queue family index of this command buffer.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn queue_family_index(&self) -> u32 {
|
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]
|
||||||
pub fn usage(&self) -> CommandBufferUsage {
|
fn usage(&self) -> CommandBufferUsage {
|
||||||
self.inner.usage()
|
self.inner.usage()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn state(&self) -> MutexGuard<'_, CommandBufferState> {
|
fn state(&self) -> MutexGuard<'_, CommandBufferState> {
|
||||||
self.state.lock()
|
self.state.lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn resources_usage(&self) -> &CommandBufferResourcesUsage {
|
fn resources_usage(&self) -> &CommandBufferResourcesUsage {
|
||||||
&self.resources_usage
|
&self.resources_usage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,36 +174,23 @@ impl Debug for SecondaryAutoCommandBuffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SecondaryAutoCommandBuffer {
|
unsafe impl SecondaryCommandBufferAbstract for SecondaryAutoCommandBuffer {
|
||||||
/// Returns the inner raw command buffer.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inner(&self) -> &CommandBuffer {
|
fn as_raw(&self) -> &CommandBuffer {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the queue family index of this command buffer.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn queue_family_index(&self) -> u32 {
|
fn usage(&self) -> CommandBufferUsage {
|
||||||
self.inner.queue_family_index()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the usage of this command buffer.
|
|
||||||
#[inline]
|
|
||||||
pub fn usage(&self) -> CommandBufferUsage {
|
|
||||||
self.inner.usage()
|
self.inner.usage()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the inheritance info of the command buffer.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inheritance_info(&self) -> &CommandBufferInheritanceInfo {
|
fn inheritance_info(&self) -> &CommandBufferInheritanceInfo {
|
||||||
self.inner.inheritance_info().unwrap()
|
self.inner.inheritance_info().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether this command buffer is allowed to be recorded to a command buffer,
|
fn lock_record(&self) -> Result<(), Box<ValidationError>> {
|
||||||
/// and if so locks it.
|
|
||||||
///
|
|
||||||
/// If you call this function, then you should call `unlock` afterwards.
|
|
||||||
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,
|
||||||
@ -242,12 +226,7 @@ impl SecondaryAutoCommandBuffer {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unlocks the command buffer. Should be called once for each call to `lock_record`.
|
unsafe fn unlock(&self) {
|
||||||
///
|
|
||||||
/// # Safety
|
|
||||||
///
|
|
||||||
/// Must not be called if you haven't called `lock_record` before.
|
|
||||||
pub unsafe fn unlock(&self) {
|
|
||||||
match self.submit_state {
|
match self.submit_state {
|
||||||
SubmitState::OneTime {
|
SubmitState::OneTime {
|
||||||
ref already_submitted,
|
ref already_submitted,
|
||||||
@ -262,7 +241,7 @@ impl SecondaryAutoCommandBuffer {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn resources_usage(&self) -> &SecondaryCommandBufferResourcesUsage {
|
fn resources_usage(&self) -> &SecondaryCommandBufferResourcesUsage {
|
||||||
&self.resources_usage
|
&self.resources_usage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,6 +326,7 @@ 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::{CommandBuffer, RecordingCommandBuffer},
|
sys::{CommandBuffer, RecordingCommandBuffer},
|
||||||
AutoCommandBufferBuilder, CommandBufferInheritanceRenderPassType, CommandBufferLevel,
|
AutoCommandBufferBuilder, CommandBufferInheritanceRenderPassType, CommandBufferLevel,
|
||||||
ResourceInCommand, SecondaryAutoCommandBuffer, SecondaryCommandBufferBufferUsage,
|
ResourceInCommand, SecondaryCommandBufferAbstract, 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<SecondaryAutoCommandBuffer>,
|
command_buffer: Arc<dyn SecondaryCommandBufferAbstract>,
|
||||||
) -> 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<SecondaryAutoCommandBuffer>>,
|
command_buffers: Vec<Arc<dyn SecondaryCommandBufferAbstract>>,
|
||||||
) -> 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,10 +55,10 @@ impl<L> AutoCommandBufferBuilder<L> {
|
|||||||
|
|
||||||
fn validate_execute_commands<'a>(
|
fn validate_execute_commands<'a>(
|
||||||
&self,
|
&self,
|
||||||
command_buffers: impl Iterator<Item = &'a SecondaryAutoCommandBuffer> + Clone,
|
command_buffers: impl Iterator<Item = &'a dyn SecondaryCommandBufferAbstract> + Clone,
|
||||||
) -> Result<(), Box<ValidationError>> {
|
) -> Result<(), Box<ValidationError>> {
|
||||||
self.inner
|
self.inner
|
||||||
.validate_execute_commands(command_buffers.clone().map(|cb| cb.inner()))?;
|
.validate_execute_commands(command_buffers.clone().map(|cb| cb.as_raw()))?;
|
||||||
|
|
||||||
if let Some(render_pass_state) = &self.builder_state.render_pass {
|
if let Some(render_pass_state) = &self.builder_state.render_pass {
|
||||||
if render_pass_state.contents != SubpassContents::SecondaryCommandBuffers {
|
if render_pass_state.contents != SubpassContents::SecondaryCommandBuffers {
|
||||||
@ -459,7 +459,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<SecondaryAutoCommandBuffer>; 4]>,
|
command_buffers: SmallVec<[Arc<dyn SecondaryCommandBufferAbstract>; 4]>,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.execute_commands_locked(
|
self.execute_commands_locked(
|
||||||
command_buffers
|
command_buffers
|
||||||
@ -670,17 +670,19 @@ impl RecordingCommandBuffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DropUnlockCommandBuffer(Arc<SecondaryAutoCommandBuffer>);
|
struct DropUnlockCommandBuffer(Arc<dyn SecondaryCommandBufferAbstract>);
|
||||||
|
|
||||||
impl DropUnlockCommandBuffer {
|
impl DropUnlockCommandBuffer {
|
||||||
fn new(command_buffer: Arc<SecondaryAutoCommandBuffer>) -> Result<Self, Box<ValidationError>> {
|
fn new(
|
||||||
|
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<SecondaryAutoCommandBuffer>;
|
type Target = Arc<dyn SecondaryCommandBufferAbstract>;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.0
|
&self.0
|
||||||
|
@ -52,7 +52,10 @@
|
|||||||
//! on the GPU.
|
//! on the GPU.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use vulkano::command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage, SubpassContents};
|
//! use vulkano::command_buffer::{
|
||||||
|
//! AutoCommandBufferBuilder, CommandBufferUsage, PrimaryCommandBufferAbstract,
|
||||||
|
//! SubpassContents,
|
||||||
|
//! };
|
||||||
//!
|
//!
|
||||||
//! # let device: std::sync::Arc<vulkano::device::Device> = return;
|
//! # let device: std::sync::Arc<vulkano::device::Device> = return;
|
||||||
//! # let queue: std::sync::Arc<vulkano::device::Queue> = return;
|
//! # let queue: std::sync::Arc<vulkano::device::Queue> = return;
|
||||||
@ -97,7 +100,10 @@ pub use self::commands::{
|
|||||||
pub use self::{
|
pub use self::{
|
||||||
auto::{AutoCommandBufferBuilder, PrimaryAutoCommandBuffer, SecondaryAutoCommandBuffer},
|
auto::{AutoCommandBufferBuilder, PrimaryAutoCommandBuffer, SecondaryAutoCommandBuffer},
|
||||||
sys::{CommandBuffer, CommandBufferBeginInfo, RecordingCommandBuffer},
|
sys::{CommandBuffer, CommandBufferBeginInfo, RecordingCommandBuffer},
|
||||||
traits::{CommandBufferExecError, CommandBufferExecFuture},
|
traits::{
|
||||||
|
CommandBufferExecError, CommandBufferExecFuture, PrimaryCommandBufferAbstract,
|
||||||
|
SecondaryCommandBufferAbstract,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::{Buffer, Subbuffer},
|
buffer::{Buffer, Subbuffer},
|
||||||
@ -1185,7 +1191,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<PrimaryAutoCommandBuffer>,
|
pub command_buffer: Arc<dyn PrimaryCommandBufferAbstract>,
|
||||||
|
|
||||||
pub _ne: crate::NonExhaustive,
|
pub _ne: crate::NonExhaustive,
|
||||||
}
|
}
|
||||||
@ -1193,7 +1199,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<PrimaryAutoCommandBuffer>) -> Self {
|
pub fn new(command_buffer: Arc<dyn PrimaryCommandBufferAbstract>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
command_buffer,
|
command_buffer,
|
||||||
_ne: crate::NonExhaustive(()),
|
_ne: crate::NonExhaustive(()),
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
use super::{CommandBufferSubmitInfo, PrimaryAutoCommandBuffer, SemaphoreSubmitInfo, SubmitInfo};
|
use super::{
|
||||||
|
CommandBuffer, CommandBufferInheritanceInfo, CommandBufferResourcesUsage, CommandBufferState,
|
||||||
|
CommandBufferSubmitInfo, CommandBufferUsage, SecondaryCommandBufferResourcesUsage,
|
||||||
|
SemaphoreSubmitInfo, SubmitInfo,
|
||||||
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
device::{Device, DeviceOwned, Queue},
|
device::{Device, DeviceOwned, Queue},
|
||||||
@ -11,9 +15,9 @@ use crate::{
|
|||||||
},
|
},
|
||||||
PipelineStages,
|
PipelineStages,
|
||||||
},
|
},
|
||||||
DeviceSize, Validated, VulkanError, VulkanObject,
|
DeviceSize, SafeDeref, Validated, ValidationError, VulkanError, VulkanObject,
|
||||||
};
|
};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::{Mutex, MutexGuard};
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
error::Error,
|
error::Error,
|
||||||
@ -26,7 +30,18 @@ use std::{
|
|||||||
thread,
|
thread,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl PrimaryAutoCommandBuffer {
|
pub unsafe trait PrimaryCommandBufferAbstract:
|
||||||
|
VulkanObject<Handle = ash::vk::CommandBuffer> + DeviceOwned + Send + Sync
|
||||||
|
{
|
||||||
|
/// Returns the underlying raw command buffer.
|
||||||
|
fn as_raw(&self) -> &CommandBuffer;
|
||||||
|
|
||||||
|
/// 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
|
||||||
@ -50,7 +65,7 @@ impl PrimaryAutoCommandBuffer {
|
|||||||
///
|
///
|
||||||
/// - 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]
|
||||||
pub fn execute(
|
fn execute(
|
||||||
self: Arc<Self>,
|
self: Arc<Self>,
|
||||||
queue: Arc<Queue>,
|
queue: Arc<Queue>,
|
||||||
) -> Result<CommandBufferExecFuture<NowFuture>, CommandBufferExecError>
|
) -> Result<CommandBufferExecFuture<NowFuture>, CommandBufferExecError>
|
||||||
@ -87,7 +102,7 @@ impl PrimaryAutoCommandBuffer {
|
|||||||
/// # 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.
|
||||||
pub fn execute_after<F>(
|
fn execute_after<F>(
|
||||||
self: Arc<Self>,
|
self: Arc<Self>,
|
||||||
future: F,
|
future: F,
|
||||||
queue: Arc<Queue>,
|
queue: Arc<Queue>,
|
||||||
@ -110,6 +125,104 @@ impl PrimaryAutoCommandBuffer {
|
|||||||
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 as_raw(&self) -> &CommandBuffer {
|
||||||
|
(**self).as_raw()
|
||||||
|
}
|
||||||
|
|
||||||
|
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 underlying raw command buffer.
|
||||||
|
fn as_raw(&self) -> &CommandBuffer;
|
||||||
|
|
||||||
|
/// 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 as_raw(&self) -> &CommandBuffer {
|
||||||
|
(**self).as_raw()
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
@ -121,7 +234,7 @@ where
|
|||||||
F: GpuFuture,
|
F: GpuFuture,
|
||||||
{
|
{
|
||||||
previous: F,
|
previous: F,
|
||||||
command_buffer: Arc<PrimaryAutoCommandBuffer>,
|
command_buffer: Arc<dyn PrimaryCommandBufferAbstract>,
|
||||||
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, PrimaryAutoCommandBuffer,
|
CommandBufferState, CommandBufferSubmitInfo, CommandBufferUsage,
|
||||||
SubmitInfo,
|
PrimaryCommandBufferAbstract, 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<PrimaryAutoCommandBuffer>,
|
command_buffer: Arc<impl PrimaryCommandBufferAbstract + 'static>,
|
||||||
) -> 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<PrimaryAutoCommandBuffer>,
|
command_buffer: Arc<impl PrimaryCommandBufferAbstract + 'static>,
|
||||||
) -> Result<CommandBufferExecFuture<Self>, CommandBufferExecError>
|
) -> Result<CommandBufferExecFuture<Self>, CommandBufferExecError>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
|
Loading…
Reference in New Issue
Block a user