mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-21 14:24:18 +00:00
Merge PrimaryAutoCommandBuffer
and SecondaryAutoCommandBuffer
into CommandBuffer
(#2425)
* Merge `PrimaryAutoCommandBuffer` and `SecondaryAutoCommandBuffer` * Fix docs * Fix examples * Move command buffer creation validation to `RawRecordingCommandBuffer` * Fix `RawRecordingCommandBuffer::end` being safe to call * Remove unsafe block inside `RawRecordingCommandBuffer::end`
This commit is contained in:
parent
648f3ce715
commit
00bb62171f
@ -43,7 +43,8 @@ use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, BufferImageCopy, ClearColorImageInfo,
|
||||
CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, CopyBufferToImageInfo,
|
||||
RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -331,10 +332,14 @@ fn main() -> Result<(), impl Error> {
|
||||
|
||||
// Initialize the textures.
|
||||
{
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
graphics_queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
for texture in &textures {
|
||||
@ -587,10 +592,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
graphics_queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
@ -761,10 +770,14 @@ fn run_worker(
|
||||
// Write to the texture that's currently not in use for rendering.
|
||||
let texture = textures[!current_index as usize].clone();
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
transfer_queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -8,7 +8,8 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -195,10 +196,14 @@ fn main() {
|
||||
.unwrap();
|
||||
|
||||
// In order to execute our operation, we have to build a command buffer.
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -11,8 +11,8 @@ use vulkano::{
|
||||
BufferContents, BufferUsage,
|
||||
},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
||||
@ -369,10 +369,14 @@ fn main() -> Result<(), impl Error> {
|
||||
let buffer = buffer_allocator.allocate_slice(data.len() as _).unwrap();
|
||||
buffer.write().unwrap().copy_from_slice(&data);
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -1,8 +1,9 @@
|
||||
use std::{error::Error, sync::Arc};
|
||||
use vulkano::{
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, ClearAttachment, ClearRect, CommandBufferUsage,
|
||||
RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, ClearAttachment, ClearRect,
|
||||
CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo,
|
||||
},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
||||
@ -207,10 +208,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -2,8 +2,9 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo,
|
||||
CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo,
|
||||
CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage,
|
||||
RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -162,7 +163,7 @@ impl AmbientLightingSystem {
|
||||
viewport_dimensions: [u32; 2],
|
||||
color_input: Arc<ImageView>,
|
||||
ambient_color: [f32; 3],
|
||||
) -> Arc<SecondaryAutoCommandBuffer> {
|
||||
) -> Arc<CommandBuffer> {
|
||||
let push_constants = fs::PushConstants {
|
||||
color: [ambient_color[0], ambient_color[1], ambient_color[2], 1.0],
|
||||
};
|
||||
@ -182,12 +183,16 @@ impl AmbientLightingSystem {
|
||||
depth_range: 0.0..=1.0,
|
||||
};
|
||||
|
||||
let mut builder = RecordingCommandBuffer::secondary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
self.command_buffer_allocator.clone(),
|
||||
self.gfx_queue.queue_family_index(),
|
||||
CommandBufferUsage::MultipleSubmit,
|
||||
CommandBufferInheritanceInfo {
|
||||
render_pass: Some(self.subpass.clone().into()),
|
||||
CommandBufferLevel::Secondary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::MultipleSubmit,
|
||||
inheritance_info: Some(CommandBufferInheritanceInfo {
|
||||
render_pass: Some(self.subpass.clone().into()),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
|
@ -3,8 +3,9 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo,
|
||||
CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo,
|
||||
CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage,
|
||||
RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -172,7 +173,7 @@ impl DirectionalLightingSystem {
|
||||
normals_input: Arc<ImageView>,
|
||||
direction: Vector3<f32>,
|
||||
color: [f32; 3],
|
||||
) -> Arc<SecondaryAutoCommandBuffer> {
|
||||
) -> Arc<CommandBuffer> {
|
||||
let push_constants = fs::PushConstants {
|
||||
color: [color[0], color[1], color[2], 1.0],
|
||||
direction: direction.extend(0.0).into(),
|
||||
@ -196,12 +197,16 @@ impl DirectionalLightingSystem {
|
||||
depth_range: 0.0..=1.0,
|
||||
};
|
||||
|
||||
let mut builder = RecordingCommandBuffer::secondary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
self.command_buffer_allocator.clone(),
|
||||
self.gfx_queue.queue_family_index(),
|
||||
CommandBufferUsage::MultipleSubmit,
|
||||
CommandBufferInheritanceInfo {
|
||||
render_pass: Some(self.subpass.clone().into()),
|
||||
CommandBufferLevel::Secondary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::MultipleSubmit,
|
||||
inheritance_info: Some(CommandBufferInheritanceInfo {
|
||||
render_pass: Some(self.subpass.clone().into()),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
|
@ -3,8 +3,9 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo,
|
||||
CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo,
|
||||
CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage,
|
||||
RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -183,7 +184,7 @@ impl PointLightingSystem {
|
||||
screen_to_world: Matrix4<f32>,
|
||||
position: Vector3<f32>,
|
||||
color: [f32; 3],
|
||||
) -> Arc<SecondaryAutoCommandBuffer> {
|
||||
) -> Arc<CommandBuffer> {
|
||||
let push_constants = fs::PushConstants {
|
||||
screen_to_world: screen_to_world.into(),
|
||||
color: [color[0], color[1], color[2], 1.0],
|
||||
@ -209,12 +210,16 @@ impl PointLightingSystem {
|
||||
depth_range: 0.0..=1.0,
|
||||
};
|
||||
|
||||
let mut builder = RecordingCommandBuffer::secondary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
self.command_buffer_allocator.clone(),
|
||||
self.gfx_queue.queue_family_index(),
|
||||
CommandBufferUsage::MultipleSubmit,
|
||||
CommandBufferInheritanceInfo {
|
||||
render_pass: Some(self.subpass.clone().into()),
|
||||
CommandBufferLevel::Secondary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::MultipleSubmit,
|
||||
inheritance_info: Some(CommandBufferInheritanceInfo {
|
||||
render_pass: Some(self.subpass.clone().into()),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
|
@ -7,9 +7,9 @@ use cgmath::{Matrix4, SquareMatrix, Vector3};
|
||||
use std::sync::Arc;
|
||||
use vulkano::{
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, PrimaryAutoCommandBuffer,
|
||||
RecordingCommandBuffer, RenderPassBeginInfo, SecondaryAutoCommandBuffer, SubpassBeginInfo,
|
||||
SubpassContents,
|
||||
allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo,
|
||||
CommandBufferLevel, CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
SubpassBeginInfo, SubpassContents,
|
||||
},
|
||||
descriptor_set::allocator::StandardDescriptorSetAllocator,
|
||||
device::Queue,
|
||||
@ -338,10 +338,14 @@ impl FrameSystem {
|
||||
.unwrap();
|
||||
|
||||
// Start the command buffer builder that will be filled throughout the frame handling.
|
||||
let mut command_buffer_builder = RecordingCommandBuffer::primary(
|
||||
let mut command_buffer_builder = RecordingCommandBuffer::new(
|
||||
self.command_buffer_allocator.clone(),
|
||||
self.gfx_queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
command_buffer_builder
|
||||
@ -394,7 +398,7 @@ pub struct Frame<'a> {
|
||||
// Framebuffer that was used when starting the render pass.
|
||||
framebuffer: Arc<Framebuffer>,
|
||||
// The command buffer builder that will be built during the lifetime of this object.
|
||||
command_buffer_builder: Option<RecordingCommandBuffer<PrimaryAutoCommandBuffer>>,
|
||||
command_buffer_builder: Option<RecordingCommandBuffer>,
|
||||
// Matrix that was passed to `frame()`.
|
||||
world_to_framebuffer: Matrix4<f32>,
|
||||
}
|
||||
@ -487,7 +491,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<SecondaryAutoCommandBuffer>) {
|
||||
pub fn execute(&mut self, command_buffer: Arc<CommandBuffer>) {
|
||||
self.frame
|
||||
.command_buffer_builder
|
||||
.as_mut()
|
||||
|
@ -2,8 +2,9 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo,
|
||||
CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo,
|
||||
CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage,
|
||||
RecordingCommandBuffer,
|
||||
},
|
||||
device::Queue,
|
||||
memory::allocator::{AllocationCreateInfo, MemoryTypeFilter, StandardMemoryAllocator},
|
||||
@ -127,13 +128,17 @@ impl TriangleDrawSystem {
|
||||
}
|
||||
|
||||
/// Builds a secondary command buffer that draws the triangle on the current subpass.
|
||||
pub fn draw(&self, viewport_dimensions: [u32; 2]) -> Arc<SecondaryAutoCommandBuffer> {
|
||||
let mut builder = RecordingCommandBuffer::secondary(
|
||||
pub fn draw(&self, viewport_dimensions: [u32; 2]) -> Arc<CommandBuffer> {
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
self.command_buffer_allocator.clone(),
|
||||
self.gfx_queue.queue_family_index(),
|
||||
CommandBufferUsage::MultipleSubmit,
|
||||
CommandBufferInheritanceInfo {
|
||||
render_pass: Some(self.subpass.clone().into()),
|
||||
CommandBufferLevel::Secondary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::MultipleSubmit,
|
||||
inheritance_info: Some(CommandBufferInheritanceInfo {
|
||||
render_pass: Some(self.subpass.clone().into()),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
|
@ -8,7 +8,8 @@ use std::{iter::repeat, mem::size_of, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, layout::DescriptorType, DescriptorBufferInfo,
|
||||
@ -236,10 +237,14 @@ fn main() {
|
||||
.unwrap();
|
||||
|
||||
// Build the command buffer, using different offsets for each call.
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -8,8 +8,8 @@ use std::{fs::File, io::BufWriter, path::Path, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyImageToBufferInfo,
|
||||
RecordingCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, CopyImageToBufferInfo, RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -249,10 +249,14 @@ fn main() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -20,8 +20,9 @@ mod linux {
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo, SemaphoreSubmitInfo, SubmitInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, SemaphoreSubmitInfo,
|
||||
SubmitInfo,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -390,10 +391,14 @@ mod linux {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -3,8 +3,9 @@ use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, BlitImageInfo, BufferImageCopy,
|
||||
ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo, CopyImageInfo, ImageBlit,
|
||||
ImageCopy, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
ClearColorImageInfo, CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage,
|
||||
CopyBufferToImageInfo, CopyImageInfo, ImageBlit, ImageCopy, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -210,10 +211,14 @@ fn main() -> Result<(), impl Error> {
|
||||
Default::default(),
|
||||
));
|
||||
|
||||
let mut uploads = RecordingCommandBuffer::primary(
|
||||
let mut uploads = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -470,10 +475,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -2,8 +2,8 @@ use std::{error::Error, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyBufferToImageInfo,
|
||||
RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -210,10 +210,14 @@ fn main() -> Result<(), impl Error> {
|
||||
Default::default(),
|
||||
));
|
||||
|
||||
let mut uploads = RecordingCommandBuffer::primary(
|
||||
let mut uploads = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -418,10 +422,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -11,8 +11,8 @@ use std::{error::Error, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyBufferToImageInfo,
|
||||
RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -216,10 +216,14 @@ fn main() -> Result<(), impl Error> {
|
||||
Default::default(),
|
||||
));
|
||||
|
||||
let mut uploads = RecordingCommandBuffer::primary(
|
||||
let mut uploads = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -436,10 +440,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -21,8 +21,8 @@ use vulkano::{
|
||||
BufferContents, BufferUsage,
|
||||
},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, DrawIndirectCommand,
|
||||
RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, DrawIndirectCommand, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -467,10 +467,14 @@ fn main() -> Result<(), impl Error> {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -7,8 +7,8 @@ use std::{error::Error, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
||||
@ -402,10 +402,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -4,7 +4,8 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -147,10 +148,14 @@ impl FractalComputePipeline {
|
||||
[],
|
||||
)
|
||||
.unwrap();
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
self.command_buffer_allocator.clone(),
|
||||
self.queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -2,8 +2,9 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo,
|
||||
CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo,
|
||||
CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage,
|
||||
RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -199,17 +200,17 @@ impl PixelsDrawPipeline {
|
||||
}
|
||||
|
||||
/// Draws input `image` over a quad of size -1.0 to 1.0.
|
||||
pub fn draw(
|
||||
&self,
|
||||
viewport_dimensions: [u32; 2],
|
||||
image: Arc<ImageView>,
|
||||
) -> Arc<SecondaryAutoCommandBuffer> {
|
||||
let mut builder = RecordingCommandBuffer::secondary(
|
||||
pub fn draw(&self, viewport_dimensions: [u32; 2], image: Arc<ImageView>) -> Arc<CommandBuffer> {
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
self.command_buffer_allocator.clone(),
|
||||
self.gfx_queue.queue_family_index(),
|
||||
CommandBufferUsage::MultipleSubmit,
|
||||
CommandBufferInheritanceInfo {
|
||||
render_pass: Some(self.subpass.clone().into()),
|
||||
CommandBufferLevel::Secondary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::MultipleSubmit,
|
||||
inheritance_info: Some(CommandBufferInheritanceInfo {
|
||||
render_pass: Some(self.subpass.clone().into()),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
|
@ -2,8 +2,9 @@ use crate::pixels_draw_pipeline::PixelsDrawPipeline;
|
||||
use std::sync::Arc;
|
||||
use vulkano::{
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo, SubpassBeginInfo, SubpassContents,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, SubpassBeginInfo,
|
||||
SubpassContents,
|
||||
},
|
||||
descriptor_set::allocator::StandardDescriptorSetAllocator,
|
||||
device::Queue,
|
||||
@ -88,10 +89,14 @@ impl RenderPassPlaceOverFrame {
|
||||
.unwrap();
|
||||
|
||||
// Create primary command buffer builder.
|
||||
let mut command_buffer_builder = RecordingCommandBuffer::primary(
|
||||
let mut command_buffer_builder = RecordingCommandBuffer::new(
|
||||
self.command_buffer_allocator.clone(),
|
||||
self.gfx_queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -57,8 +57,8 @@ use std::{fs::File, io::BufWriter, path::Path, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyImageToBufferInfo,
|
||||
RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, CopyImageToBufferInfo, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
||||
@ -380,10 +380,14 @@ fn main() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -5,8 +5,8 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, PrimaryAutoCommandBuffer,
|
||||
RecordingCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -130,10 +130,14 @@ impl GameOfLifeComputePipeline {
|
||||
life_color: [f32; 4],
|
||||
dead_color: [f32; 4],
|
||||
) -> Box<dyn GpuFuture> {
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
self.command_buffer_allocator.clone(),
|
||||
self.compute_queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -163,7 +167,7 @@ impl GameOfLifeComputePipeline {
|
||||
/// Builds the command for a dispatch.
|
||||
fn dispatch(
|
||||
&self,
|
||||
builder: &mut RecordingCommandBuffer<PrimaryAutoCommandBuffer>,
|
||||
builder: &mut RecordingCommandBuffer,
|
||||
life_color: [f32; 4],
|
||||
dead_color: [f32; 4],
|
||||
// Step determines whether we color or compute life (see branch in the shader)s.
|
||||
|
@ -3,8 +3,9 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo,
|
||||
CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo,
|
||||
CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage,
|
||||
RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -195,17 +196,17 @@ impl PixelsDrawPipeline {
|
||||
}
|
||||
|
||||
/// Draws input `image` over a quad of size -1.0 to 1.0.
|
||||
pub fn draw(
|
||||
&self,
|
||||
viewport_dimensions: [u32; 2],
|
||||
image: Arc<ImageView>,
|
||||
) -> Arc<SecondaryAutoCommandBuffer> {
|
||||
let mut builder = RecordingCommandBuffer::secondary(
|
||||
pub fn draw(&self, viewport_dimensions: [u32; 2], image: Arc<ImageView>) -> Arc<CommandBuffer> {
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
self.command_buffer_allocator.clone(),
|
||||
self.gfx_queue.queue_family_index(),
|
||||
CommandBufferUsage::MultipleSubmit,
|
||||
CommandBufferInheritanceInfo {
|
||||
render_pass: Some(self.subpass.clone().into()),
|
||||
CommandBufferLevel::Secondary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::MultipleSubmit,
|
||||
inheritance_info: Some(CommandBufferInheritanceInfo {
|
||||
render_pass: Some(self.subpass.clone().into()),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
|
@ -2,8 +2,9 @@ use crate::{app::App, pixels_draw::PixelsDrawPipeline};
|
||||
use std::sync::Arc;
|
||||
use vulkano::{
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo, SubpassBeginInfo, SubpassContents,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, SubpassBeginInfo,
|
||||
SubpassContents,
|
||||
},
|
||||
device::Queue,
|
||||
format::Format,
|
||||
@ -78,10 +79,14 @@ impl RenderPassPlaceOverFrame {
|
||||
.unwrap();
|
||||
|
||||
// Create a primary command buffer builder.
|
||||
let mut command_buffer_builder = RecordingCommandBuffer::primary(
|
||||
let mut command_buffer_builder = RecordingCommandBuffer::new(
|
||||
self.command_buffer_allocator.clone(),
|
||||
self.gfx_queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -11,8 +11,8 @@ use std::{collections::HashMap, error::Error, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
||||
@ -447,10 +447,14 @@ fn main() -> Result<(), impl Error> {
|
||||
*recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -7,8 +7,9 @@ use std::{fs::File, io::BufWriter, path::Path, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, BufferImageCopy, CommandBufferUsage,
|
||||
CopyImageToBufferInfo, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, BufferImageCopy, CommandBufferBeginInfo,
|
||||
CommandBufferLevel, CommandBufferUsage, CopyImageToBufferInfo, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo,
|
||||
},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Features,
|
||||
@ -330,10 +331,14 @@ fn main() {
|
||||
let buffer1 = create_buffer();
|
||||
let buffer2 = create_buffer();
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -6,8 +6,8 @@ use std::{error::Error, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
||||
@ -426,10 +426,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -7,7 +7,8 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -180,10 +181,14 @@ fn main() {
|
||||
//
|
||||
// Note that there is no type safety for the push constant data, so be careful to only pass an
|
||||
// instance of the struct generated by the `vulkano_shaders::shaders!` macro.
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -2,8 +2,8 @@ use std::{error::Error, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyBufferToImageInfo,
|
||||
RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
descriptor_set::{layout::DescriptorSetLayoutCreateFlags, WriteDescriptorSet},
|
||||
device::{
|
||||
@ -201,10 +201,14 @@ fn main() -> Result<(), impl Error> {
|
||||
device.clone(),
|
||||
Default::default(),
|
||||
));
|
||||
let mut uploads = RecordingCommandBuffer::primary(
|
||||
let mut uploads = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -405,10 +409,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -2,8 +2,8 @@ use std::{error::Error, io::Cursor, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyBufferToImageInfo,
|
||||
RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, layout::DescriptorBindingFlags, DescriptorSet,
|
||||
@ -270,10 +270,14 @@ fn main() -> Result<(), impl Error> {
|
||||
Default::default(),
|
||||
));
|
||||
|
||||
let mut uploads = RecordingCommandBuffer::primary(
|
||||
let mut uploads = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -539,10 +543,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -16,8 +16,8 @@ use std::{error::Error, fs::File, io::Read, path::Path, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
||||
@ -348,10 +348,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::MultipleSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::MultipleSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -6,8 +6,8 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, BufferCopy, CommandBufferUsage,
|
||||
CopyBufferInfoTyped, RecordingCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, BufferCopy, CommandBufferBeginInfo,
|
||||
CommandBufferLevel, CommandBufferUsage, CopyBufferInfoTyped, RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -162,10 +162,14 @@ fn main() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -6,7 +6,8 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -166,10 +167,14 @@ fn main() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -20,7 +20,8 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -192,10 +193,14 @@ fn main() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -7,8 +7,8 @@ use std::{error::Error, sync::Arc, time::SystemTime};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyBufferInfo,
|
||||
RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, CopyBufferInfo, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -386,10 +386,14 @@ fn main() -> Result<(), impl Error> {
|
||||
.unwrap();
|
||||
|
||||
// Create one-time command to copy between the buffers.
|
||||
let mut cbb = RecordingCommandBuffer::primary(
|
||||
let mut cbb = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
cbb.copy_buffer(CopyBufferInfo::buffers(
|
||||
@ -581,10 +585,14 @@ fn main() -> Result<(), impl Error> {
|
||||
None => sync::now(device.clone()).boxed(),
|
||||
};
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -4,7 +4,8 @@ use std::sync::Arc;
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferLevel, CommandBufferUsage,
|
||||
RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -167,10 +168,14 @@ fn main() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
vulkano::command_buffer::CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -7,8 +7,8 @@ use vulkano::{
|
||||
Buffer, BufferCreateInfo, BufferUsage,
|
||||
},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -365,10 +365,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -16,8 +16,8 @@ use std::{error::Error, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Features,
|
||||
@ -466,10 +466,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -2,8 +2,8 @@ use std::{error::Error, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyBufferToImageInfo,
|
||||
RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -212,10 +212,14 @@ fn main() -> Result<(), impl Error> {
|
||||
Default::default(),
|
||||
));
|
||||
|
||||
let mut uploads = RecordingCommandBuffer::primary(
|
||||
let mut uploads = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -429,10 +433,14 @@ fn main() -> Result<(), impl Error> {
|
||||
recreate_swapchain = true;
|
||||
}
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
|
@ -16,8 +16,8 @@ use std::{error::Error, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderingAttachmentInfo, RenderingInfo,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer, RenderingAttachmentInfo, RenderingInfo,
|
||||
},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Features,
|
||||
@ -597,10 +597,14 @@ fn main() -> Result<(), impl Error> {
|
||||
//
|
||||
// Note that we have to pass a queue family when we create the command buffer. The
|
||||
// command buffer will only be executable on that given queue family.
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -11,8 +11,9 @@ use std::{error::Error, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
RenderPassBeginInfo, SubpassBeginInfo, SubpassContents,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, SubpassBeginInfo,
|
||||
SubpassContents,
|
||||
},
|
||||
device::{
|
||||
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
|
||||
@ -599,10 +600,14 @@ fn main() -> Result<(), impl Error> {
|
||||
//
|
||||
// Note that we have to pass a queue family when we create the command buffer. The
|
||||
// command buffer will only be executable on that given queue family.
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
command_buffer_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -78,7 +78,9 @@ const MAX_ARENAS: usize = 32;
|
||||
/// allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
|
||||
/// BufferUsage,
|
||||
/// },
|
||||
/// command_buffer::{CommandBufferUsage, RecordingCommandBuffer},
|
||||
/// command_buffer::{
|
||||
/// CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, RecordingCommandBuffer,
|
||||
/// },
|
||||
/// memory::allocator::MemoryTypeFilter,
|
||||
/// sync::GpuFuture,
|
||||
/// };
|
||||
@ -105,10 +107,14 @@ const MAX_ARENAS: usize = 32;
|
||||
/// *subbuffer.write().unwrap() = data;
|
||||
///
|
||||
/// // You can then use `subbuffer` as if it was an entirely separate buffer.
|
||||
/// RecordingCommandBuffer::primary(
|
||||
/// RecordingCommandBuffer::new(
|
||||
/// command_buffer_allocator.clone(),
|
||||
/// queue.queue_family_index(),
|
||||
/// CommandBufferUsage::OneTimeSubmit,
|
||||
/// CommandBufferLevel::Primary,
|
||||
/// CommandBufferBeginInfo {
|
||||
/// usage: CommandBufferUsage::OneTimeSubmit,
|
||||
/// ..Default::default()
|
||||
/// },
|
||||
/// )
|
||||
/// .unwrap()
|
||||
/// // For the sake of the example we just call `update_buffer` on the buffer, even though
|
||||
|
@ -121,7 +121,10 @@ pub mod view;
|
||||
/// ```
|
||||
/// use vulkano::{
|
||||
/// buffer::{BufferUsage, Buffer, BufferCreateInfo},
|
||||
/// command_buffer::{CommandBufferUsage, CopyBufferInfo, RecordingCommandBuffer},
|
||||
/// command_buffer::{
|
||||
/// CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, CopyBufferInfo,
|
||||
/// RecordingCommandBuffer,
|
||||
/// },
|
||||
/// memory::allocator::{AllocationCreateInfo, MemoryTypeFilter},
|
||||
/// sync::GpuFuture,
|
||||
/// DeviceSize,
|
||||
@ -171,10 +174,14 @@ pub mod view;
|
||||
/// .unwrap();
|
||||
///
|
||||
/// // Create a one-time command to copy between the buffers.
|
||||
/// let mut cbb = RecordingCommandBuffer::primary(
|
||||
/// let mut cbb = RecordingCommandBuffer::new(
|
||||
/// command_buffer_allocator.clone(),
|
||||
/// queue.queue_family_index(),
|
||||
/// CommandBufferUsage::OneTimeSubmit,
|
||||
/// CommandBufferLevel::Primary,
|
||||
/// CommandBufferBeginInfo {
|
||||
/// usage: CommandBufferUsage::OneTimeSubmit,
|
||||
/// ..Default::default()
|
||||
/// },
|
||||
/// )
|
||||
/// .unwrap();
|
||||
/// cbb.copy_buffer(CopyBufferInfo::buffers(
|
||||
|
@ -1,18 +1,16 @@
|
||||
use super::{
|
||||
CommandInfo, PrimaryAutoCommandBuffer, RenderPassCommand, Resource, ResourceUseRef2,
|
||||
SubmitState,
|
||||
CommandBuffer, CommandInfo, RenderPassCommand, Resource, ResourceUseRef2, SubmitState,
|
||||
};
|
||||
use crate::{
|
||||
buffer::{Buffer, IndexBuffer, Subbuffer},
|
||||
command_buffer::{
|
||||
allocator::CommandBufferAllocator,
|
||||
sys::{CommandBufferBeginInfo, RawCommandBuffer, RawRecordingCommandBuffer},
|
||||
sys::{CommandBufferBeginInfo, RawRecordingCommandBuffer},
|
||||
CommandBufferBufferRangeUsage, CommandBufferBufferUsage, CommandBufferImageRangeUsage,
|
||||
CommandBufferImageUsage, CommandBufferInheritanceInfo,
|
||||
CommandBufferInheritanceRenderPassType, CommandBufferLevel, CommandBufferResourcesUsage,
|
||||
CommandBufferUsage, RenderingInfo, ResourceUseRef, SecondaryAutoCommandBuffer,
|
||||
SecondaryCommandBufferBufferUsage, SecondaryCommandBufferImageUsage,
|
||||
SecondaryCommandBufferResourcesUsage, SubpassContents,
|
||||
CommandBufferUsage, RenderingInfo, ResourceUseRef, SecondaryCommandBufferBufferUsage,
|
||||
SecondaryCommandBufferImageUsage, SecondaryCommandBufferResourcesUsage, SubpassContents,
|
||||
},
|
||||
descriptor_set::{DescriptorSetResources, DescriptorSetWithOffsets},
|
||||
device::{Device, DeviceOwned},
|
||||
@ -45,7 +43,6 @@ use smallvec::SmallVec;
|
||||
use std::{
|
||||
collections::hash_map::Entry,
|
||||
fmt::Debug,
|
||||
marker::PhantomData,
|
||||
mem::take,
|
||||
ops::{Range, RangeInclusive},
|
||||
sync::{atomic::AtomicBool, Arc},
|
||||
@ -58,134 +55,42 @@ use std::{
|
||||
///
|
||||
/// Note that command buffers in the recording state don't implement the `Send` and `Sync` traits.
|
||||
/// Once a command buffer has finished recording, however, it *does* implement `Send` and `Sync`.
|
||||
pub struct RecordingCommandBuffer<L> {
|
||||
pub struct RecordingCommandBuffer {
|
||||
pub(in crate::command_buffer) inner: RawRecordingCommandBuffer,
|
||||
commands: Vec<(
|
||||
CommandInfo,
|
||||
Box<dyn Fn(&mut RawRecordingCommandBuffer) + Send + Sync + 'static>,
|
||||
)>,
|
||||
pub(in crate::command_buffer) builder_state: CommandBufferBuilderState,
|
||||
_data: PhantomData<L>,
|
||||
}
|
||||
|
||||
impl RecordingCommandBuffer<PrimaryAutoCommandBuffer> {
|
||||
/// Starts recording a primary command buffer.
|
||||
impl RecordingCommandBuffer {
|
||||
/// Allocates and begins recording a new command buffer.
|
||||
#[inline]
|
||||
pub fn primary(
|
||||
allocator: Arc<dyn CommandBufferAllocator>,
|
||||
queue_family_index: u32,
|
||||
usage: CommandBufferUsage,
|
||||
) -> Result<RecordingCommandBuffer<PrimaryAutoCommandBuffer>, Validated<VulkanError>> {
|
||||
unsafe {
|
||||
RecordingCommandBuffer::begin(
|
||||
allocator,
|
||||
queue_family_index,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage,
|
||||
inheritance_info: None,
|
||||
_ne: crate::NonExhaustive(()),
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
|
||||
#[inline]
|
||||
pub unsafe fn primary_unchecked(
|
||||
allocator: Arc<dyn CommandBufferAllocator>,
|
||||
queue_family_index: u32,
|
||||
usage: CommandBufferUsage,
|
||||
) -> Result<RecordingCommandBuffer<PrimaryAutoCommandBuffer>, Validated<VulkanError>> {
|
||||
RecordingCommandBuffer::begin_unchecked(
|
||||
allocator,
|
||||
queue_family_index,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage,
|
||||
inheritance_info: None,
|
||||
_ne: crate::NonExhaustive(()),
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl RecordingCommandBuffer<SecondaryAutoCommandBuffer> {
|
||||
/// Starts recording a secondary command buffer.
|
||||
#[inline]
|
||||
pub fn secondary(
|
||||
allocator: Arc<dyn CommandBufferAllocator>,
|
||||
queue_family_index: u32,
|
||||
usage: CommandBufferUsage,
|
||||
inheritance_info: CommandBufferInheritanceInfo,
|
||||
) -> Result<RecordingCommandBuffer<SecondaryAutoCommandBuffer>, Validated<VulkanError>> {
|
||||
unsafe {
|
||||
RecordingCommandBuffer::begin(
|
||||
allocator,
|
||||
queue_family_index,
|
||||
CommandBufferLevel::Secondary,
|
||||
CommandBufferBeginInfo {
|
||||
usage,
|
||||
inheritance_info: Some(inheritance_info),
|
||||
_ne: crate::NonExhaustive(()),
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
|
||||
#[inline]
|
||||
pub unsafe fn secondary_unchecked(
|
||||
allocator: Arc<dyn CommandBufferAllocator>,
|
||||
queue_family_index: u32,
|
||||
usage: CommandBufferUsage,
|
||||
inheritance_info: CommandBufferInheritanceInfo,
|
||||
) -> Result<RecordingCommandBuffer<SecondaryAutoCommandBuffer>, Validated<VulkanError>> {
|
||||
RecordingCommandBuffer::begin_unchecked(
|
||||
allocator,
|
||||
queue_family_index,
|
||||
CommandBufferLevel::Secondary,
|
||||
CommandBufferBeginInfo {
|
||||
usage,
|
||||
inheritance_info: Some(inheritance_info),
|
||||
_ne: crate::NonExhaustive(()),
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
/// Actual constructor. Private.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// `begin_info.inheritance_info` must match `level`.
|
||||
unsafe fn begin(
|
||||
pub fn new(
|
||||
allocator: Arc<dyn CommandBufferAllocator>,
|
||||
queue_family_index: u32,
|
||||
level: CommandBufferLevel,
|
||||
begin_info: CommandBufferBeginInfo,
|
||||
) -> Result<RecordingCommandBuffer<L>, Validated<VulkanError>> {
|
||||
Self::validate_begin(allocator.device(), queue_family_index, level, &begin_info)?;
|
||||
) -> Result<RecordingCommandBuffer, Validated<VulkanError>> {
|
||||
Self::validate_new(allocator.device(), queue_family_index, level, &begin_info)?;
|
||||
|
||||
unsafe { Self::begin_unchecked(allocator, queue_family_index, level, begin_info) }
|
||||
unsafe { Self::new_unchecked(allocator, queue_family_index, level, begin_info) }
|
||||
}
|
||||
|
||||
fn validate_begin(
|
||||
fn validate_new(
|
||||
device: &Device,
|
||||
_queue_family_index: u32,
|
||||
_level: CommandBufferLevel,
|
||||
queue_family_index: u32,
|
||||
level: CommandBufferLevel,
|
||||
begin_info: &CommandBufferBeginInfo,
|
||||
) -> Result<(), Box<ValidationError>> {
|
||||
begin_info
|
||||
.validate(device)
|
||||
.map_err(|err| err.add_context("begin_info"))?;
|
||||
RawRecordingCommandBuffer::validate_new(device, queue_family_index, level, begin_info)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn begin_unchecked(
|
||||
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
|
||||
pub unsafe fn new_unchecked(
|
||||
allocator: Arc<dyn CommandBufferAllocator>,
|
||||
queue_family_index: u32,
|
||||
level: CommandBufferLevel,
|
||||
@ -212,28 +117,53 @@ impl<L> RecordingCommandBuffer<L> {
|
||||
}
|
||||
}
|
||||
|
||||
let inner =
|
||||
RawRecordingCommandBuffer::new(allocator, queue_family_index, level, begin_info)?;
|
||||
let inner = RawRecordingCommandBuffer::new_unchecked(
|
||||
allocator,
|
||||
queue_family_index,
|
||||
level,
|
||||
begin_info,
|
||||
)?;
|
||||
|
||||
Ok(RecordingCommandBuffer {
|
||||
inner,
|
||||
commands: Vec::new(),
|
||||
builder_state,
|
||||
_data: PhantomData,
|
||||
})
|
||||
}
|
||||
|
||||
unsafe fn end_unchecked(
|
||||
mut self,
|
||||
) -> Result<
|
||||
(
|
||||
RawCommandBuffer,
|
||||
Vec<Box<dyn Fn(&mut RawRecordingCommandBuffer) + Send + Sync + 'static>>,
|
||||
CommandBufferResourcesUsage,
|
||||
SecondaryCommandBufferResourcesUsage,
|
||||
),
|
||||
Validated<VulkanError>,
|
||||
> {
|
||||
/// Ends the recording, returning a command buffer which can be submitted.
|
||||
#[inline]
|
||||
pub fn end(self) -> Result<Arc<CommandBuffer>, Validated<VulkanError>> {
|
||||
self.validate_end()?;
|
||||
|
||||
unsafe { self.end_unchecked() }
|
||||
}
|
||||
|
||||
fn validate_end(&self) -> Result<(), Box<ValidationError>> {
|
||||
if self.level() == CommandBufferLevel::Primary && self.builder_state.render_pass.is_some() {
|
||||
return Err(Box::new(ValidationError {
|
||||
problem: "a render pass instance is still active".into(),
|
||||
vuids: &["VUID-vkEndCommandBuffer-commandBuffer-00060"],
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
if !self.builder_state.queries.is_empty() {
|
||||
return Err(Box::new(ValidationError {
|
||||
problem: "a query is still active".into(),
|
||||
vuids: &["VUID-vkEndCommandBuffer-commandBuffer-00061"],
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// VUID-vkEndCommandBuffer-commandBuffer-01815
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
|
||||
pub unsafe fn end_unchecked(mut self) -> Result<Arc<CommandBuffer>, Validated<VulkanError>> {
|
||||
let mut auto_sync_state = AutoSyncState::new(
|
||||
self.device().clone(),
|
||||
self.inner.level(),
|
||||
@ -298,65 +228,6 @@ impl<L> RecordingCommandBuffer<L> {
|
||||
|
||||
debug_assert!(barriers.is_empty());
|
||||
|
||||
Ok((
|
||||
self.inner.end()?,
|
||||
self.commands
|
||||
.into_iter()
|
||||
.map(|(_, record_func)| record_func)
|
||||
.collect(),
|
||||
resources_usage,
|
||||
secondary_resources_usage,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl RecordingCommandBuffer<PrimaryAutoCommandBuffer> {
|
||||
/// Ends the recording, returning a command buffer which can be submitted.
|
||||
pub fn end(self) -> Result<Arc<PrimaryAutoCommandBuffer>, Validated<VulkanError>> {
|
||||
if self.builder_state.render_pass.is_some() {
|
||||
return Err(Box::new(ValidationError {
|
||||
problem: "a render pass instance is still active".into(),
|
||||
vuids: &["VUID-vkEndCommandBuffer-commandBuffer-00060"],
|
||||
..Default::default()
|
||||
})
|
||||
.into());
|
||||
}
|
||||
|
||||
if !self.builder_state.queries.is_empty() {
|
||||
return Err(Box::new(ValidationError {
|
||||
problem: "a query is still active".into(),
|
||||
vuids: &["VUID-vkEndCommandBuffer-commandBuffer-00061"],
|
||||
..Default::default()
|
||||
})
|
||||
.into());
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// VUID-vkEndCommandBuffer-commandBuffer-01815
|
||||
|
||||
let (inner, keep_alive_objects, resources_usage, _) = unsafe { self.end_unchecked()? };
|
||||
|
||||
Ok(Arc::new(PrimaryAutoCommandBuffer {
|
||||
inner,
|
||||
_keep_alive_objects: keep_alive_objects,
|
||||
resources_usage,
|
||||
state: Mutex::new(Default::default()),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
impl RecordingCommandBuffer<SecondaryAutoCommandBuffer> {
|
||||
/// Ends the recording, returning a command buffer which can be submitted.
|
||||
pub fn end(self) -> Result<Arc<SecondaryAutoCommandBuffer>, Validated<VulkanError>> {
|
||||
if !self.builder_state.queries.is_empty() {
|
||||
return Err(Box::new(ValidationError {
|
||||
problem: "a query is still active".into(),
|
||||
vuids: &["VUID-vkEndCommandBuffer-commandBuffer-00061"],
|
||||
..Default::default()
|
||||
})
|
||||
.into());
|
||||
}
|
||||
|
||||
let submit_state = match self.inner.usage() {
|
||||
CommandBufferUsage::MultipleSubmit => SubmitState::ExclusiveUse {
|
||||
in_use: AtomicBool::new(false),
|
||||
@ -367,18 +238,28 @@ impl RecordingCommandBuffer<SecondaryAutoCommandBuffer> {
|
||||
},
|
||||
};
|
||||
|
||||
let (inner, keep_alive_objects, _, resources_usage) = unsafe { self.end_unchecked()? };
|
||||
|
||||
Ok(Arc::new(SecondaryAutoCommandBuffer {
|
||||
inner,
|
||||
_keep_alive_objects: keep_alive_objects,
|
||||
Ok(Arc::new(CommandBuffer {
|
||||
inner: self.inner.end()?,
|
||||
_keep_alive_objects: self
|
||||
.commands
|
||||
.into_iter()
|
||||
.map(|(_, record_func)| record_func)
|
||||
.collect(),
|
||||
resources_usage,
|
||||
secondary_resources_usage,
|
||||
state: Mutex::new(Default::default()),
|
||||
submit_state,
|
||||
}))
|
||||
}
|
||||
|
||||
/// Returns the level of the command buffer.
|
||||
#[inline]
|
||||
pub fn level(&self) -> CommandBufferLevel {
|
||||
self.inner.level()
|
||||
}
|
||||
}
|
||||
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
impl RecordingCommandBuffer {
|
||||
pub(in crate::command_buffer) fn add_command(
|
||||
&mut self,
|
||||
name: &'static str,
|
||||
@ -428,7 +309,8 @@ impl<L> RecordingCommandBuffer<L> {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<L> DeviceOwned for RecordingCommandBuffer<L> {
|
||||
unsafe impl DeviceOwned for RecordingCommandBuffer {
|
||||
#[inline]
|
||||
fn device(&self) -> &Arc<Device> {
|
||||
self.inner.device()
|
||||
}
|
||||
|
@ -63,9 +63,9 @@ pub(in crate::command_buffer) use self::builder::{
|
||||
};
|
||||
use super::{
|
||||
sys::{RawCommandBuffer, RawRecordingCommandBuffer},
|
||||
CommandBufferInheritanceInfo, CommandBufferResourcesUsage, CommandBufferState,
|
||||
CommandBufferUsage, ResourceInCommand, SecondaryCommandBufferResourcesUsage,
|
||||
SecondaryResourceUseRef,
|
||||
CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferResourcesUsage,
|
||||
CommandBufferState, CommandBufferUsage, ResourceInCommand,
|
||||
SecondaryCommandBufferResourcesUsage, SecondaryResourceUseRef,
|
||||
};
|
||||
use crate::{
|
||||
buffer::Subbuffer,
|
||||
@ -86,67 +86,17 @@ use std::{
|
||||
|
||||
mod builder;
|
||||
|
||||
pub struct PrimaryAutoCommandBuffer {
|
||||
pub struct CommandBuffer {
|
||||
inner: RawCommandBuffer,
|
||||
// TODO: Remove all of this.
|
||||
_keep_alive_objects: Vec<Box<dyn Fn(&mut RawRecordingCommandBuffer) + Send + Sync + 'static>>,
|
||||
resources_usage: CommandBufferResourcesUsage,
|
||||
secondary_resources_usage: SecondaryCommandBufferResourcesUsage,
|
||||
state: Mutex<CommandBufferState>,
|
||||
}
|
||||
|
||||
unsafe impl VulkanObject for PrimaryAutoCommandBuffer {
|
||||
type Handle = ash::vk::CommandBuffer;
|
||||
|
||||
#[inline]
|
||||
fn handle(&self) -> Self::Handle {
|
||||
self.inner.handle()
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl DeviceOwned for PrimaryAutoCommandBuffer {
|
||||
#[inline]
|
||||
fn device(&self) -> &Arc<Device> {
|
||||
self.inner.device()
|
||||
}
|
||||
}
|
||||
|
||||
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]
|
||||
pub fn queue_family_index(&self) -> u32 {
|
||||
self.inner.queue_family_index()
|
||||
}
|
||||
|
||||
/// Returns the usage of this command buffer.
|
||||
#[inline]
|
||||
pub fn usage(&self) -> CommandBufferUsage {
|
||||
self.inner.usage()
|
||||
}
|
||||
|
||||
pub(crate) fn state(&self) -> MutexGuard<'_, CommandBufferState> {
|
||||
self.state.lock()
|
||||
}
|
||||
|
||||
pub(crate) fn resources_usage(&self) -> &CommandBufferResourcesUsage {
|
||||
&self.resources_usage
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SecondaryAutoCommandBuffer {
|
||||
inner: RawCommandBuffer,
|
||||
_keep_alive_objects: Vec<Box<dyn Fn(&mut RawRecordingCommandBuffer) + Send + Sync + 'static>>,
|
||||
resources_usage: SecondaryCommandBufferResourcesUsage,
|
||||
submit_state: SubmitState,
|
||||
}
|
||||
|
||||
unsafe impl VulkanObject for SecondaryAutoCommandBuffer {
|
||||
unsafe impl VulkanObject for CommandBuffer {
|
||||
type Handle = ash::vk::CommandBuffer;
|
||||
|
||||
#[inline]
|
||||
@ -155,47 +105,71 @@ unsafe impl VulkanObject for SecondaryAutoCommandBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl DeviceOwned for SecondaryAutoCommandBuffer {
|
||||
unsafe impl DeviceOwned for CommandBuffer {
|
||||
#[inline]
|
||||
fn device(&self) -> &Arc<Device> {
|
||||
self.inner.device()
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for SecondaryAutoCommandBuffer {
|
||||
impl Debug for CommandBuffer {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
|
||||
f.debug_struct("SecondaryAutoCommandBuffer")
|
||||
f.debug_struct("CommandBuffer")
|
||||
.field("inner", &self.inner)
|
||||
.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl SecondaryAutoCommandBuffer {
|
||||
impl CommandBuffer {
|
||||
/// Returns the inner raw command buffer.
|
||||
#[inline]
|
||||
pub fn inner(&self) -> &RawCommandBuffer {
|
||||
&self.inner
|
||||
}
|
||||
|
||||
/// Returns the queue family index of this command buffer.
|
||||
#[inline]
|
||||
pub fn queue_family_index(&self) -> u32 {
|
||||
self.inner.queue_family_index()
|
||||
}
|
||||
|
||||
/// Returns the level of the command buffer.
|
||||
#[inline]
|
||||
pub fn level(&self) -> CommandBufferLevel {
|
||||
self.inner.level()
|
||||
}
|
||||
|
||||
/// Returns the usage of this command buffer.
|
||||
#[inline]
|
||||
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.
|
||||
/// Returns the inheritance info of the command buffer, if it is a secondary command buffer.
|
||||
#[inline]
|
||||
pub fn inheritance_info(&self) -> &CommandBufferInheritanceInfo {
|
||||
self.inner.inheritance_info().as_ref().unwrap()
|
||||
pub fn inheritance_info(&self) -> Option<&CommandBufferInheritanceInfo> {
|
||||
self.inner.inheritance_info()
|
||||
}
|
||||
|
||||
pub(crate) fn state(&self) -> MutexGuard<'_, CommandBufferState> {
|
||||
debug_assert_eq!(self.level(), CommandBufferLevel::Primary);
|
||||
|
||||
self.state.lock()
|
||||
}
|
||||
|
||||
pub(crate) fn resources_usage(&self) -> &CommandBufferResourcesUsage {
|
||||
debug_assert_eq!(self.level(), CommandBufferLevel::Primary);
|
||||
|
||||
&self.resources_usage
|
||||
}
|
||||
|
||||
/// 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]
|
||||
pub fn lock_record(&self) -> Result<(), Box<ValidationError>> {
|
||||
pub(crate) fn lock_record(&self) -> Result<(), Box<ValidationError>> {
|
||||
debug_assert_eq!(self.level(), CommandBufferLevel::Secondary);
|
||||
|
||||
match self.submit_state {
|
||||
SubmitState::OneTime {
|
||||
ref already_submitted,
|
||||
@ -236,8 +210,9 @@ impl SecondaryAutoCommandBuffer {
|
||||
/// # Safety
|
||||
///
|
||||
/// Must not be called if you haven't called `lock_record` before.
|
||||
#[inline]
|
||||
pub unsafe fn unlock(&self) {
|
||||
pub(crate) unsafe fn unlock(&self) {
|
||||
debug_assert_eq!(self.level(), CommandBufferLevel::Secondary);
|
||||
|
||||
match self.submit_state {
|
||||
SubmitState::OneTime {
|
||||
ref already_submitted,
|
||||
@ -252,8 +227,8 @@ impl SecondaryAutoCommandBuffer {
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) fn resources_usage(&self) -> &SecondaryCommandBufferResourcesUsage {
|
||||
&self.resources_usage
|
||||
pub(crate) fn secondary_resources_usage(&self) -> &SecondaryCommandBufferResourcesUsage {
|
||||
&self.secondary_resources_usage
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,7 +311,8 @@ mod tests {
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::{StandardCommandBufferAllocator, StandardCommandBufferAllocatorCreateInfo},
|
||||
BufferCopy, CommandBufferUsage, CopyBufferInfoTyped, RecordingCommandBuffer,
|
||||
BufferCopy, CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage,
|
||||
CopyBufferInfoTyped, RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator,
|
||||
@ -364,10 +340,14 @@ mod tests {
|
||||
Default::default(),
|
||||
));
|
||||
|
||||
RecordingCommandBuffer::primary(
|
||||
RecordingCommandBuffer::new(
|
||||
allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::MultipleSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::MultipleSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
@ -430,10 +410,14 @@ mod tests {
|
||||
device,
|
||||
Default::default(),
|
||||
));
|
||||
let mut cbb = RecordingCommandBuffer::primary(
|
||||
let mut cbb = RecordingCommandBuffer::new(
|
||||
cb_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -476,20 +460,28 @@ mod tests {
|
||||
));
|
||||
|
||||
// Make a secondary CB that doesn't support simultaneous use.
|
||||
let builder = RecordingCommandBuffer::secondary(
|
||||
let builder = RecordingCommandBuffer::new(
|
||||
cb_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::MultipleSubmit,
|
||||
Default::default(),
|
||||
CommandBufferLevel::Secondary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::MultipleSubmit,
|
||||
inheritance_info: Some(Default::default()),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
let secondary = builder.end().unwrap();
|
||||
|
||||
{
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
cb_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::SimultaneousUse,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::SimultaneousUse,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -502,19 +494,27 @@ mod tests {
|
||||
}
|
||||
|
||||
{
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
cb_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::SimultaneousUse,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::SimultaneousUse,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder.execute_commands(secondary.clone()).unwrap();
|
||||
let cb1 = builder.end().unwrap();
|
||||
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
cb_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::SimultaneousUse,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::SimultaneousUse,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -553,10 +553,14 @@ mod tests {
|
||||
device,
|
||||
Default::default(),
|
||||
));
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
cb_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -611,10 +615,14 @@ mod tests {
|
||||
device,
|
||||
Default::default(),
|
||||
));
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
cb_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -644,10 +652,14 @@ mod tests {
|
||||
..Default::default()
|
||||
},
|
||||
));
|
||||
let cbb = RecordingCommandBuffer::primary(
|
||||
let cbb = RecordingCommandBuffer::new(
|
||||
cb_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -680,11 +692,15 @@ mod tests {
|
||||
// Two secondary command buffers that both write to the buffer
|
||||
let secondary = (0..2)
|
||||
.map(|_| {
|
||||
let mut builder = RecordingCommandBuffer::secondary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
cb_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::SimultaneousUse,
|
||||
Default::default(),
|
||||
CommandBufferLevel::Secondary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::SimultaneousUse,
|
||||
inheritance_info: Some(Default::default()),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
@ -695,10 +711,15 @@ mod tests {
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
{
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
cb_allocator.clone(),
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::SimultaneousUse,
|
||||
CommandBufferLevel::Secondary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::SimultaneousUse,
|
||||
inheritance_info: Some(Default::default()),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -718,10 +739,15 @@ mod tests {
|
||||
}
|
||||
|
||||
{
|
||||
let mut builder = RecordingCommandBuffer::primary(
|
||||
let mut builder = RecordingCommandBuffer::new(
|
||||
cb_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::SimultaneousUse,
|
||||
CommandBufferLevel::Secondary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::SimultaneousUse,
|
||||
inheritance_info: Some(Default::default()),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -745,10 +771,14 @@ mod tests {
|
||||
device.clone(),
|
||||
Default::default(),
|
||||
));
|
||||
let mut sync = RecordingCommandBuffer::primary(
|
||||
let mut sync = RecordingCommandBuffer::new(
|
||||
cb_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::MultipleSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::MultipleSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@ -784,10 +814,14 @@ mod tests {
|
||||
device.clone(),
|
||||
Default::default(),
|
||||
));
|
||||
let mut sync = RecordingCommandBuffer::primary(
|
||||
let mut sync = RecordingCommandBuffer::new(
|
||||
cb_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::MultipleSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::MultipleSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
let set_layout = DescriptorSetLayout::new(
|
||||
|
@ -24,7 +24,7 @@ use smallvec::SmallVec;
|
||||
use std::{mem::size_of, sync::Arc};
|
||||
|
||||
/// # Commands to do operations on acceleration structures.
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
impl RecordingCommandBuffer {
|
||||
/// Builds or updates an acceleration structure.
|
||||
///
|
||||
/// # Safety
|
||||
|
@ -21,7 +21,7 @@ use std::{cmp::min, ffi::c_void, mem::size_of, ptr, sync::Arc};
|
||||
/// # Commands to bind or push state for pipeline execution commands.
|
||||
///
|
||||
/// These commands require a queue with a pipeline type that uses the given state.
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
impl RecordingCommandBuffer {
|
||||
/// Binds descriptor sets for future dispatch or draw calls.
|
||||
pub fn bind_descriptor_sets(
|
||||
&mut self,
|
||||
|
@ -14,7 +14,7 @@ use smallvec::{smallvec, SmallVec};
|
||||
use std::{mem::size_of_val, sync::Arc};
|
||||
|
||||
/// # Commands to fill resources with new data.
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
impl RecordingCommandBuffer {
|
||||
/// Clears a color image with a specific value.
|
||||
pub fn clear_color_image(
|
||||
&mut self,
|
||||
|
@ -20,7 +20,7 @@ use std::{
|
||||
};
|
||||
|
||||
/// # Commands to transfer data between resources.
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
impl RecordingCommandBuffer {
|
||||
/// Copies data from a buffer to another buffer.
|
||||
///
|
||||
/// # Panics
|
||||
|
@ -11,7 +11,7 @@ use std::ffi::CString;
|
||||
/// These commands all require the [`ext_debug_utils`] extension to be enabled on the instance.
|
||||
///
|
||||
/// [`ext_debug_utils`]: crate::instance::InstanceExtensions::ext_debug_utils
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
impl RecordingCommandBuffer {
|
||||
/// Opens a command buffer debug label region.
|
||||
pub fn begin_debug_utils_label(
|
||||
&mut self,
|
||||
|
@ -23,7 +23,7 @@ use std::ops::RangeInclusive;
|
||||
/// # Commands to set dynamic state for pipelines.
|
||||
///
|
||||
/// These commands require a queue with a pipeline type that uses the given state.
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
impl RecordingCommandBuffer {
|
||||
// Helper function for dynamic state setting.
|
||||
fn validate_graphics_pipeline_fixed_state(
|
||||
&self,
|
||||
|
@ -44,7 +44,7 @@ macro_rules! vuids {
|
||||
/// # Commands to execute a bound pipeline.
|
||||
///
|
||||
/// Dispatch commands require a compute queue, draw commands require a graphics queue.
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
impl RecordingCommandBuffer {
|
||||
/// Perform a single compute operation using a compute pipeline.
|
||||
///
|
||||
/// A compute pipeline must have been bound using
|
||||
|
@ -13,7 +13,7 @@ use crate::{
|
||||
use std::{ops::Range, sync::Arc};
|
||||
|
||||
/// # Commands related to queries.
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
impl RecordingCommandBuffer {
|
||||
/// Begins a query.
|
||||
///
|
||||
/// The query will be active until [`end_query`](Self::end_query) is called for the same query.
|
||||
|
@ -24,7 +24,7 @@ use std::{cmp::min, ops::Range, sync::Arc};
|
||||
/// # Commands for render passes.
|
||||
///
|
||||
/// These commands require a graphics queue.
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
impl RecordingCommandBuffer {
|
||||
/// Begins a render pass using a render pass object and framebuffer.
|
||||
///
|
||||
/// You must call this or `begin_rendering` before you can record draw commands.
|
||||
@ -328,7 +328,7 @@ impl<L> RecordingCommandBuffer<L> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
impl RecordingCommandBuffer {
|
||||
/// Begins a render pass without a render pass object or framebuffer.
|
||||
///
|
||||
/// You must call this or `begin_render_pass` before you can record draw commands.
|
||||
|
@ -2,8 +2,8 @@ use crate::{
|
||||
command_buffer::{
|
||||
auto::{RenderPassStateType, Resource, ResourceUseRef2},
|
||||
sys::{RawCommandBuffer, RawRecordingCommandBuffer},
|
||||
CommandBufferInheritanceRenderPassType, CommandBufferLevel, RecordingCommandBuffer,
|
||||
ResourceInCommand, SecondaryAutoCommandBuffer, SecondaryCommandBufferBufferUsage,
|
||||
CommandBuffer, CommandBufferInheritanceRenderPassType, CommandBufferLevel,
|
||||
RecordingCommandBuffer, ResourceInCommand, SecondaryCommandBufferBufferUsage,
|
||||
SecondaryCommandBufferImageUsage, SecondaryCommandBufferResourcesUsage, SubpassContents,
|
||||
},
|
||||
device::{DeviceOwned, QueueFlags},
|
||||
@ -17,7 +17,7 @@ use std::{cmp::min, iter, sync::Arc};
|
||||
///
|
||||
/// These commands can be called on any queue that can execute the commands recorded in the
|
||||
/// secondary command buffer.
|
||||
impl<L> RecordingCommandBuffer<L> {
|
||||
impl RecordingCommandBuffer {
|
||||
/// Executes a secondary command buffer.
|
||||
///
|
||||
/// If the `flags` that `command_buffer` was created with are more restrictive than those of
|
||||
@ -25,7 +25,7 @@ impl<L> RecordingCommandBuffer<L> {
|
||||
/// with `Flags::OneTimeSubmit` will set `self`'s flags to `Flags::OneTimeSubmit` also.
|
||||
pub fn execute_commands(
|
||||
&mut self,
|
||||
command_buffer: Arc<SecondaryAutoCommandBuffer>,
|
||||
command_buffer: Arc<CommandBuffer>,
|
||||
) -> 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> RecordingCommandBuffer<L> {
|
||||
// TODO ^ would be nice if this just worked without errors
|
||||
pub fn execute_commands_from_vec(
|
||||
&mut self,
|
||||
command_buffers: Vec<Arc<SecondaryAutoCommandBuffer>>,
|
||||
command_buffers: Vec<Arc<CommandBuffer>>,
|
||||
) -> Result<&mut Self, Box<ValidationError>> {
|
||||
let command_buffers: SmallVec<[_; 4]> = command_buffers
|
||||
.into_iter()
|
||||
@ -55,7 +55,7 @@ impl<L> RecordingCommandBuffer<L> {
|
||||
|
||||
fn validate_execute_commands<'a>(
|
||||
&self,
|
||||
command_buffers: impl Iterator<Item = &'a SecondaryAutoCommandBuffer> + Clone,
|
||||
command_buffers: impl Iterator<Item = &'a CommandBuffer> + Clone,
|
||||
) -> Result<(), Box<ValidationError>> {
|
||||
self.inner
|
||||
.validate_execute_commands(command_buffers.clone().map(|cb| cb.inner()))?;
|
||||
@ -89,17 +89,16 @@ impl<L> RecordingCommandBuffer<L> {
|
||||
}
|
||||
|
||||
for (command_buffer_index, command_buffer) in command_buffers.enumerate() {
|
||||
let inheritance_info = command_buffer.inheritance_info().unwrap();
|
||||
|
||||
if let Some(render_pass_state) = &self.builder_state.render_pass {
|
||||
let inheritance_render_pass = command_buffer
|
||||
.inheritance_info()
|
||||
.render_pass
|
||||
.as_ref()
|
||||
.ok_or_else(|| {
|
||||
let inheritance_render_pass =
|
||||
inheritance_info.render_pass.as_ref().ok_or_else(|| {
|
||||
Box::new(ValidationError {
|
||||
problem: format!(
|
||||
"a render pass instance is active, but \
|
||||
`command_buffers[{}].inheritance_info().render_pass` is `None`",
|
||||
command_buffer_index
|
||||
`command_buffers[{}].inheritance_info().render_pass` is `None`",
|
||||
command_buffer_index,
|
||||
)
|
||||
.into(),
|
||||
vuids: &["VUID-vkCmdExecuteCommands-pCommandBuffers-00096"],
|
||||
@ -375,7 +374,7 @@ impl<L> RecordingCommandBuffer<L> {
|
||||
// VUID-vkCmdExecuteCommands-pCommandBuffers-06535
|
||||
// VUID-vkCmdExecuteCommands-pCommandBuffers-06536
|
||||
} else {
|
||||
if command_buffer.inheritance_info().render_pass.is_some() {
|
||||
if inheritance_info.render_pass.is_some() {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: format!(
|
||||
"command_buffers[{}].inheritance_info().render_pass",
|
||||
@ -392,10 +391,8 @@ impl<L> RecordingCommandBuffer<L> {
|
||||
for state in self.builder_state.queries.values() {
|
||||
match state.query_pool.query_type() {
|
||||
QueryType::Occlusion => {
|
||||
let inherited_flags = command_buffer
|
||||
.inheritance_info()
|
||||
.occlusion_query
|
||||
.ok_or_else(|| {
|
||||
let inherited_flags =
|
||||
inheritance_info.occlusion_query.ok_or_else(|| {
|
||||
Box::new(ValidationError {
|
||||
context: format!(
|
||||
"command_buffers[{}].inheritance_info().occlusion_query",
|
||||
@ -426,8 +423,7 @@ impl<L> RecordingCommandBuffer<L> {
|
||||
}
|
||||
}
|
||||
&QueryType::PipelineStatistics(state_flags) => {
|
||||
let inherited_flags =
|
||||
command_buffer.inheritance_info().query_statistics_flags;
|
||||
let inherited_flags = inheritance_info.query_statistics_flags;
|
||||
|
||||
if !inherited_flags.contains(state_flags) {
|
||||
return Err(Box::new(ValidationError {
|
||||
@ -461,7 +457,7 @@ impl<L> RecordingCommandBuffer<L> {
|
||||
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
|
||||
pub unsafe fn execute_commands_unchecked(
|
||||
&mut self,
|
||||
command_buffers: SmallVec<[Arc<SecondaryAutoCommandBuffer>; 4]>,
|
||||
command_buffers: SmallVec<[Arc<CommandBuffer>; 4]>,
|
||||
) -> &mut Self {
|
||||
self.execute_commands_locked(
|
||||
command_buffers
|
||||
@ -487,7 +483,7 @@ impl<L> RecordingCommandBuffer<L> {
|
||||
.flat_map(|(index, command_buffer)| {
|
||||
let index = index as u32;
|
||||
let SecondaryCommandBufferResourcesUsage { buffers, images } =
|
||||
command_buffer.resources_usage();
|
||||
command_buffer.secondary_resources_usage();
|
||||
|
||||
(buffers.iter().map(move |usage| {
|
||||
let &SecondaryCommandBufferBufferUsage {
|
||||
@ -672,22 +668,23 @@ impl RawRecordingCommandBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
struct DropUnlockCommandBuffer(Arc<SecondaryAutoCommandBuffer>);
|
||||
struct DropUnlockCommandBuffer(Arc<CommandBuffer>);
|
||||
|
||||
impl DropUnlockCommandBuffer {
|
||||
fn new(command_buffer: Arc<SecondaryAutoCommandBuffer>) -> Result<Self, Box<ValidationError>> {
|
||||
fn new(command_buffer: Arc<CommandBuffer>) -> Result<Self, Box<ValidationError>> {
|
||||
command_buffer.lock_record()?;
|
||||
Ok(Self(command_buffer))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for DropUnlockCommandBuffer {
|
||||
type Target = Arc<SecondaryAutoCommandBuffer>;
|
||||
type Target = Arc<CommandBuffer>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl SafeDeref for DropUnlockCommandBuffer {}
|
||||
|
||||
impl Drop for DropUnlockCommandBuffer {
|
||||
|
@ -2,9 +2,9 @@
|
||||
//!
|
||||
//! With Vulkan, to get the device to perform work, even relatively simple tasks, you must create a
|
||||
//! command buffer. A command buffer is a list of commands that will executed by the device.
|
||||
//! You must first record commands to a command buffer builder, then build it into an actual
|
||||
//! command buffer, and then it can be used. Depending on how a command buffer is created, it can
|
||||
//! be used only once, or reused many times.
|
||||
//! You must first record commands to a recording command buffer, then end the recording to turn it
|
||||
//! into an actual command buffer, and then it can be used. Depending on how a command buffer is
|
||||
//! created, it can be used only once, or reused many times.
|
||||
//!
|
||||
//! # Command pools and allocators
|
||||
//!
|
||||
@ -22,10 +22,10 @@
|
||||
//!
|
||||
//! There are two levels of command buffers:
|
||||
//!
|
||||
//! - [`PrimaryAutoCommandBuffer`] can be executed on a queue, and is the main command buffer type.
|
||||
//! - A primary command buffer can be executed on a queue, and is the main command buffer level.
|
||||
//! It cannot be executed within another command buffer.
|
||||
//! - [`SecondaryAutoCommandBuffer`] can only be executed within a primary command buffer, not
|
||||
//! directly on a queue.
|
||||
//! - A secondary command buffer 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
|
||||
@ -41,18 +41,19 @@
|
||||
//! To record a new command buffer, the most direct way is to create a new
|
||||
//! [`RecordingCommandBuffer`]. You can then call methods on this object to record new commands to
|
||||
//! the command buffer. When you are done recording, you call [`end`] to finalise the command
|
||||
//! buffer and turn it into either a [`PrimaryAutoCommandBuffer`] or a
|
||||
//! [`SecondaryAutoCommandBuffer`].
|
||||
//! buffer and turn it into a [`CommandBuffer`].
|
||||
//!
|
||||
//! # Submitting a primary command buffer
|
||||
//!
|
||||
//! 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.
|
||||
//! Once a primary command buffer has finished recording, you can submit the [`CommandBuffer`] 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::{CommandBufferUsage, RecordingCommandBuffer, SubpassContents};
|
||||
//! use vulkano::command_buffer::{
|
||||
//! CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, RecordingCommandBuffer,
|
||||
//! SubpassContents,
|
||||
//! };
|
||||
//!
|
||||
//! # let device: std::sync::Arc<vulkano::device::Device> = return;
|
||||
//! # let queue: std::sync::Arc<vulkano::device::Queue> = return;
|
||||
@ -61,10 +62,11 @@
|
||||
//! # let graphics_pipeline: std::sync::Arc<vulkano::pipeline::graphics::GraphicsPipeline> = return;
|
||||
//! # let command_buffer_allocator: std::sync::Arc<vulkano::command_buffer::allocator::StandardCommandBufferAllocator> = return;
|
||||
//! #
|
||||
//! let cb = RecordingCommandBuffer::primary(
|
||||
//! let cb = RecordingCommandBuffer::new(
|
||||
//! command_buffer_allocator.clone(),
|
||||
//! queue.queue_family_index(),
|
||||
//! CommandBufferUsage::MultipleSubmit,
|
||||
//! CommandBufferLevel::Primary,
|
||||
//! CommandBufferBeginInfo::default(),
|
||||
//! )
|
||||
//! .unwrap()
|
||||
//! .begin_render_pass(render_pass_begin_info, Default::default())
|
||||
@ -90,11 +92,12 @@
|
||||
//! [`GpuFuture`]: crate::sync::GpuFuture
|
||||
|
||||
pub use self::{
|
||||
auto::{PrimaryAutoCommandBuffer, RecordingCommandBuffer, SecondaryAutoCommandBuffer},
|
||||
auto::{CommandBuffer, RecordingCommandBuffer},
|
||||
commands::{
|
||||
acceleration_structure::*, clear::*, copy::*, debug::*, dynamic_state::*, pipeline::*,
|
||||
query::*, render_pass::*, secondary::*, sync::*,
|
||||
},
|
||||
sys::CommandBufferBeginInfo,
|
||||
traits::{CommandBufferExecError, CommandBufferExecFuture},
|
||||
};
|
||||
use crate::{
|
||||
@ -788,7 +791,7 @@ pub struct CommandBufferSubmitInfo {
|
||||
/// The command buffer to execute.
|
||||
///
|
||||
/// There is no default value.
|
||||
pub command_buffer: Arc<PrimaryAutoCommandBuffer>,
|
||||
pub command_buffer: Arc<CommandBuffer>,
|
||||
|
||||
pub _ne: crate::NonExhaustive,
|
||||
}
|
||||
@ -796,7 +799,7 @@ pub struct CommandBufferSubmitInfo {
|
||||
impl CommandBufferSubmitInfo {
|
||||
/// Returns a `CommandBufferSubmitInfo` with the specified `command_buffer`.
|
||||
#[inline]
|
||||
pub fn new(command_buffer: Arc<PrimaryAutoCommandBuffer>) -> Self {
|
||||
pub fn new(command_buffer: Arc<CommandBuffer>) -> Self {
|
||||
Self {
|
||||
command_buffer,
|
||||
_ne: crate::NonExhaustive(()),
|
||||
@ -812,6 +815,15 @@ impl CommandBufferSubmitInfo {
|
||||
// VUID?
|
||||
assert_eq!(device, command_buffer.device().as_ref());
|
||||
|
||||
if self.command_buffer.level() != CommandBufferLevel::Primary {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: "command_buffer".into(),
|
||||
problem: "is not a primary command buffer".into(),
|
||||
vuids: &["VUID-VkCommandBufferSubmitInfo-commandBuffer-03890"],
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -35,12 +35,46 @@ pub struct RawRecordingCommandBuffer {
|
||||
|
||||
impl RawRecordingCommandBuffer {
|
||||
/// Allocates and begins recording a new command buffer.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// - `begin_info` must be valid.
|
||||
#[inline]
|
||||
pub unsafe fn new(
|
||||
pub fn new(
|
||||
allocator: Arc<dyn CommandBufferAllocator>,
|
||||
queue_family_index: u32,
|
||||
level: CommandBufferLevel,
|
||||
begin_info: CommandBufferBeginInfo,
|
||||
) -> Result<Self, Validated<VulkanError>> {
|
||||
Self::validate_new(allocator.device(), queue_family_index, level, &begin_info)?;
|
||||
|
||||
unsafe { Self::new_unchecked(allocator, queue_family_index, level, begin_info) }
|
||||
}
|
||||
|
||||
pub(super) fn validate_new(
|
||||
device: &Device,
|
||||
_queue_family_index: u32,
|
||||
level: CommandBufferLevel,
|
||||
begin_info: &CommandBufferBeginInfo,
|
||||
) -> Result<(), Box<ValidationError>> {
|
||||
// VUID-vkBeginCommandBuffer-commandBuffer-00049
|
||||
// VUID-vkBeginCommandBuffer-commandBuffer-00050
|
||||
// Guaranteed by `CommandBufferAllocator`.
|
||||
|
||||
if level == CommandBufferLevel::Secondary && begin_info.inheritance_info.is_none() {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: "begin_info.inheritance_info".into(),
|
||||
problem: "is `None` while `level` is `CommandBufferLevel::Secondary`".into(),
|
||||
vuids: &["VUID-vkBeginCommandBuffer-commandBuffer-00051"],
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
begin_info
|
||||
.validate(device)
|
||||
.map_err(|err| err.add_context("begin_info"))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
|
||||
pub unsafe fn new_unchecked(
|
||||
allocator: Arc<dyn CommandBufferAllocator>,
|
||||
queue_family_index: u32,
|
||||
level: CommandBufferLevel,
|
||||
@ -169,13 +203,11 @@ impl RawRecordingCommandBuffer {
|
||||
|
||||
/// Ends the recording, returning a command buffer which can be submitted.
|
||||
#[inline]
|
||||
pub fn end(self) -> Result<RawCommandBuffer, VulkanError> {
|
||||
unsafe {
|
||||
let fns = self.device().fns();
|
||||
(fns.v1_0.end_command_buffer)(self.handle())
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
}
|
||||
pub unsafe fn end(self) -> Result<RawCommandBuffer, VulkanError> {
|
||||
let fns = self.device().fns();
|
||||
(fns.v1_0.end_command_buffer)(self.handle())
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
Ok(RawCommandBuffer { inner: self })
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use super::{CommandBufferSubmitInfo, PrimaryAutoCommandBuffer, SemaphoreSubmitInfo, SubmitInfo};
|
||||
use super::{CommandBuffer, CommandBufferSubmitInfo, SemaphoreSubmitInfo, SubmitInfo};
|
||||
use crate::{
|
||||
buffer::Buffer,
|
||||
device::{Device, DeviceOwned, Queue},
|
||||
@ -26,7 +26,7 @@ use std::{
|
||||
thread,
|
||||
};
|
||||
|
||||
impl PrimaryAutoCommandBuffer {
|
||||
impl CommandBuffer {
|
||||
/// Executes this command buffer on a queue.
|
||||
///
|
||||
/// This function returns an object that implements the [`GpuFuture`] trait. See the
|
||||
@ -121,7 +121,7 @@ where
|
||||
F: GpuFuture,
|
||||
{
|
||||
previous: F,
|
||||
command_buffer: Arc<PrimaryAutoCommandBuffer>,
|
||||
command_buffer: Arc<CommandBuffer>,
|
||||
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.
|
||||
|
@ -445,7 +445,8 @@ mod tests {
|
||||
use crate::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage},
|
||||
command_buffer::{
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
|
||||
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
|
||||
CommandBufferUsage, RecordingCommandBuffer,
|
||||
},
|
||||
descriptor_set::{
|
||||
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
|
||||
@ -556,10 +557,14 @@ mod tests {
|
||||
device.clone(),
|
||||
Default::default(),
|
||||
));
|
||||
let mut cbb = RecordingCommandBuffer::primary(
|
||||
let mut cbb = RecordingCommandBuffer::new(
|
||||
cb_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
cbb.bind_pipeline_compute(pipeline.clone())
|
||||
@ -703,10 +708,14 @@ mod tests {
|
||||
device.clone(),
|
||||
Default::default(),
|
||||
));
|
||||
let mut cbb = RecordingCommandBuffer::primary(
|
||||
let mut cbb = RecordingCommandBuffer::new(
|
||||
cb_allocator,
|
||||
queue.queue_family_index(),
|
||||
CommandBufferUsage::OneTimeSubmit,
|
||||
CommandBufferLevel::Primary,
|
||||
CommandBufferBeginInfo {
|
||||
usage: CommandBufferUsage::OneTimeSubmit,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
cbb.bind_pipeline_compute(pipeline.clone())
|
||||
|
@ -233,7 +233,7 @@
|
||||
//! # let mut swapchain: ::std::sync::Arc<swapchain::Swapchain> = return;
|
||||
//! // let mut (swapchain, images) = Swapchain::new(...);
|
||||
//! loop {
|
||||
//! # let mut command_buffer: ::std::sync::Arc<::vulkano::command_buffer::PrimaryAutoCommandBuffer> = return;
|
||||
//! # let mut command_buffer: ::std::sync::Arc<::vulkano::command_buffer::CommandBuffer> = return;
|
||||
//! let (image_index, suboptimal, acquire_future)
|
||||
//! = swapchain::acquire_next_image(swapchain.clone(), None).unwrap();
|
||||
//!
|
||||
|
@ -91,9 +91,9 @@ use super::{fence::Fence, semaphore::Semaphore};
|
||||
use crate::{
|
||||
buffer::{Buffer, BufferState},
|
||||
command_buffer::{
|
||||
CommandBufferExecError, CommandBufferExecFuture, CommandBufferResourcesUsage,
|
||||
CommandBufferState, CommandBufferSubmitInfo, CommandBufferUsage, PrimaryAutoCommandBuffer,
|
||||
SubmitInfo,
|
||||
CommandBuffer, CommandBufferExecError, CommandBufferExecFuture,
|
||||
CommandBufferResourcesUsage, CommandBufferState, CommandBufferSubmitInfo,
|
||||
CommandBufferUsage, 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<PrimaryAutoCommandBuffer>,
|
||||
command_buffer: Arc<CommandBuffer>,
|
||||
) -> 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<PrimaryAutoCommandBuffer>,
|
||||
command_buffer: Arc<CommandBuffer>,
|
||||
) -> Result<CommandBufferExecFuture<Self>, CommandBufferExecError>
|
||||
where
|
||||
Self: Sized,
|
||||
|
Loading…
Reference in New Issue
Block a user