diff --git a/examples/basic-compute-shader/main.rs b/examples/basic-compute-shader/main.rs index 3662fb05..e927b128 100644 --- a/examples/basic-compute-shader/main.rs +++ b/examples/basic-compute-shader/main.rs @@ -8,8 +8,7 @@ use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -196,14 +195,10 @@ fn main() { .unwrap(); // In order to execute our operation, we have to build a command buffer. - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( command_buffer_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/buffer-allocator/main.rs b/examples/buffer-allocator/main.rs index 2c063d44..7c8ce7a2 100644 --- a/examples/buffer-allocator/main.rs +++ b/examples/buffer-allocator/main.rs @@ -11,8 +11,8 @@ use vulkano::{ BufferContents, BufferUsage, }, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, }, device::{ physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Queue, @@ -419,14 +419,10 @@ impl ApplicationHandler for App { .unwrap(); buffer.write().unwrap().copy_from_slice(&data); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/clear-attachments/main.rs b/examples/clear-attachments/main.rs index 455514c9..d576dabf 100644 --- a/examples/clear-attachments/main.rs +++ b/examples/clear-attachments/main.rs @@ -1,9 +1,8 @@ use std::{error::Error, sync::Arc}; use vulkano::{ command_buffer::{ - allocator::StandardCommandBufferAllocator, ClearAttachment, ClearRect, - CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, RecordingCommandBuffer, - RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, ClearAttachment, ClearRect, CommandBufferUsage, + RecordingCommandBuffer, RenderPassBeginInfo, }, device::{ physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Queue, @@ -265,14 +264,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); builder diff --git a/examples/deferred/frame/ambient_lighting_system.rs b/examples/deferred/frame/ambient_lighting_system.rs index a9966bbb..c0625854 100644 --- a/examples/deferred/frame/ambient_lighting_system.rs +++ b/examples/deferred/frame/ambient_lighting_system.rs @@ -3,9 +3,8 @@ use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo, - CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage, - RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo, + CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -158,7 +157,7 @@ impl AmbientLightingSystem { viewport_dimensions: [u32; 2], color_input: Arc, ambient_color: [f32; 3], - ) -> Arc { + ) -> Arc { let push_constants = fs::PushConstants { color: [ambient_color[0], ambient_color[1], ambient_color[2], 1.0], }; @@ -178,16 +177,12 @@ impl AmbientLightingSystem { depth_range: 0.0..=1.0, }; - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::secondary( self.command_buffer_allocator.clone(), self.gfx_queue.queue_family_index(), - CommandBufferLevel::Secondary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::MultipleSubmit, - inheritance_info: Some(CommandBufferInheritanceInfo { - render_pass: Some(self.subpass.clone().into()), - ..Default::default() - }), + CommandBufferUsage::MultipleSubmit, + CommandBufferInheritanceInfo { + render_pass: Some(self.subpass.clone().into()), ..Default::default() }, ) diff --git a/examples/deferred/frame/directional_lighting_system.rs b/examples/deferred/frame/directional_lighting_system.rs index 538a48de..35e0e1f0 100644 --- a/examples/deferred/frame/directional_lighting_system.rs +++ b/examples/deferred/frame/directional_lighting_system.rs @@ -4,9 +4,8 @@ use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo, - CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage, - RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo, + CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -168,7 +167,7 @@ impl DirectionalLightingSystem { normals_input: Arc, direction: Vec3, color: [f32; 3], - ) -> Arc { + ) -> Arc { let push_constants = fs::PushConstants { color: [color[0], color[1], color[2], 1.0], direction: direction.extend(0.0).into(), @@ -192,16 +191,12 @@ impl DirectionalLightingSystem { depth_range: 0.0..=1.0, }; - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::secondary( self.command_buffer_allocator.clone(), self.gfx_queue.queue_family_index(), - CommandBufferLevel::Secondary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::MultipleSubmit, - inheritance_info: Some(CommandBufferInheritanceInfo { - render_pass: Some(self.subpass.clone().into()), - ..Default::default() - }), + CommandBufferUsage::MultipleSubmit, + CommandBufferInheritanceInfo { + render_pass: Some(self.subpass.clone().into()), ..Default::default() }, ) diff --git a/examples/deferred/frame/point_lighting_system.rs b/examples/deferred/frame/point_lighting_system.rs index cf8d15bd..2e9e606f 100644 --- a/examples/deferred/frame/point_lighting_system.rs +++ b/examples/deferred/frame/point_lighting_system.rs @@ -4,9 +4,8 @@ use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo, - CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage, - RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo, + CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -179,7 +178,7 @@ impl PointLightingSystem { screen_to_world: Mat4, position: Vec3, color: [f32; 3], - ) -> Arc { + ) -> Arc { let push_constants = fs::PushConstants { screen_to_world: screen_to_world.to_cols_array_2d(), color: [color[0], color[1], color[2], 1.0], @@ -205,16 +204,12 @@ impl PointLightingSystem { depth_range: 0.0..=1.0, }; - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::secondary( self.command_buffer_allocator.clone(), self.gfx_queue.queue_family_index(), - CommandBufferLevel::Secondary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::MultipleSubmit, - inheritance_info: Some(CommandBufferInheritanceInfo { - render_pass: Some(self.subpass.clone().into()), - ..Default::default() - }), + CommandBufferUsage::MultipleSubmit, + CommandBufferInheritanceInfo { + render_pass: Some(self.subpass.clone().into()), ..Default::default() }, ) diff --git a/examples/deferred/frame/system.rs b/examples/deferred/frame/system.rs index 3a654df2..6f6fd95e 100644 --- a/examples/deferred/frame/system.rs +++ b/examples/deferred/frame/system.rs @@ -7,9 +7,9 @@ use glam::f32::{Mat4, Vec3}; use std::sync::Arc; use vulkano::{ command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo, - CommandBufferLevel, CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, - SubpassBeginInfo, SubpassContents, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, PrimaryAutoCommandBuffer, + RecordingCommandBuffer, RenderPassBeginInfo, SecondaryAutoCommandBuffer, SubpassBeginInfo, + SubpassContents, }, descriptor_set::allocator::StandardDescriptorSetAllocator, device::Queue, @@ -338,14 +338,10 @@ impl FrameSystem { .unwrap(); // Start the command buffer builder that will be filled throughout the frame handling. - let mut command_buffer_builder = RecordingCommandBuffer::new( + let mut command_buffer_builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.gfx_queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); command_buffer_builder @@ -398,7 +394,7 @@ pub struct Frame<'a> { // Framebuffer that was used when starting the render pass. framebuffer: Arc, // The command buffer builder that will be built during the lifetime of this object. - command_buffer_builder: Option, + command_buffer_builder: Option>, // Matrix that was passed to `frame()`. world_to_framebuffer: Mat4, } @@ -490,7 +486,7 @@ pub struct DrawPass<'f, 's: 'f> { impl<'f, 's: 'f> DrawPass<'f, 's> { /// Appends a command that executes a secondary command buffer that performs drawing. - pub fn execute(&mut self, command_buffer: Arc) { + pub fn execute(&mut self, command_buffer: Arc) { self.frame .command_buffer_builder .as_mut() diff --git a/examples/deferred/triangle_draw_system.rs b/examples/deferred/triangle_draw_system.rs index 7c13f19d..7447d6f9 100644 --- a/examples/deferred/triangle_draw_system.rs +++ b/examples/deferred/triangle_draw_system.rs @@ -2,9 +2,8 @@ use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo, - CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage, - RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo, + CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer, }, device::Queue, memory::allocator::{AllocationCreateInfo, MemoryTypeFilter, StandardMemoryAllocator}, @@ -126,17 +125,13 @@ impl TriangleDrawSystem { } /// Builds a secondary command buffer that draws the triangle on the current subpass. - pub fn draw(&self, viewport_dimensions: [u32; 2]) -> Arc { - let mut builder = RecordingCommandBuffer::new( + pub fn draw(&self, viewport_dimensions: [u32; 2]) -> Arc { + let mut builder = RecordingCommandBuffer::secondary( self.command_buffer_allocator.clone(), self.gfx_queue.queue_family_index(), - CommandBufferLevel::Secondary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::MultipleSubmit, - inheritance_info: Some(CommandBufferInheritanceInfo { - render_pass: Some(self.subpass.clone().into()), - ..Default::default() - }), + CommandBufferUsage::MultipleSubmit, + CommandBufferInheritanceInfo { + render_pass: Some(self.subpass.clone().into()), ..Default::default() }, ) diff --git a/examples/dynamic-buffers/main.rs b/examples/dynamic-buffers/main.rs index 422d87b8..317582b6 100644 --- a/examples/dynamic-buffers/main.rs +++ b/examples/dynamic-buffers/main.rs @@ -8,8 +8,7 @@ use std::{iter::repeat, mem::size_of, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, layout::DescriptorType, DescriptorBufferInfo, @@ -238,14 +237,10 @@ fn main() { .unwrap(); // Build the command buffer, using different offsets for each call. - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( command_buffer_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/dynamic-local-size/main.rs b/examples/dynamic-local-size/main.rs index 8a776cc0..89cb5347 100644 --- a/examples/dynamic-local-size/main.rs +++ b/examples/dynamic-local-size/main.rs @@ -8,8 +8,8 @@ use std::{fs::File, io::BufWriter, path::Path, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, CopyImageToBufferInfo, RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyImageToBufferInfo, + RecordingCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -249,14 +249,10 @@ fn main() { ) .unwrap(); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( command_buffer_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/gl-interop/main.rs b/examples/gl-interop/main.rs index 6f65d376..ce63e6da 100644 --- a/examples/gl-interop/main.rs +++ b/examples/gl-interop/main.rs @@ -20,9 +20,8 @@ mod linux { use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, SemaphoreSubmitInfo, - SubmitInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, SemaphoreSubmitInfo, SubmitInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -703,14 +702,10 @@ mod linux { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/image-self-copy-blit/main.rs b/examples/image-self-copy-blit/main.rs index 0f0a4ef5..2155de23 100644 --- a/examples/image-self-copy-blit/main.rs +++ b/examples/image-self-copy-blit/main.rs @@ -3,9 +3,8 @@ use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ allocator::StandardCommandBufferAllocator, BlitImageInfo, BufferImageCopy, - ClearColorImageInfo, CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, - CopyBufferToImageInfo, CopyImageInfo, ImageBlit, ImageCopy, RecordingCommandBuffer, - RenderPassBeginInfo, + ClearColorImageInfo, CommandBufferUsage, CopyBufferToImageInfo, CopyImageInfo, ImageBlit, + ImageCopy, RecordingCommandBuffer, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -186,14 +185,10 @@ impl App { ) .unwrap(); - let mut uploads = RecordingCommandBuffer::new( + let mut uploads = RecordingCommandBuffer::primary( command_buffer_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); @@ -528,14 +523,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/image/main.rs b/examples/image/main.rs index 92505b2b..3f3fc6a7 100644 --- a/examples/image/main.rs +++ b/examples/image/main.rs @@ -2,8 +2,8 @@ use std::{error::Error, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyBufferToImageInfo, + RecordingCommandBuffer, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -183,14 +183,10 @@ impl App { ) .unwrap(); - let mut uploads = RecordingCommandBuffer::new( + let mut uploads = RecordingCommandBuffer::primary( command_buffer_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); @@ -471,14 +467,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/immutable-sampler/main.rs b/examples/immutable-sampler/main.rs index a4ef4c43..bfb9348e 100644 --- a/examples/immutable-sampler/main.rs +++ b/examples/immutable-sampler/main.rs @@ -11,8 +11,8 @@ use std::{error::Error, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyBufferToImageInfo, + RecordingCommandBuffer, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -189,14 +189,10 @@ impl App { ) .unwrap(); - let mut uploads = RecordingCommandBuffer::new( + let mut uploads = RecordingCommandBuffer::primary( command_buffer_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); @@ -490,14 +486,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/indirect/main.rs b/examples/indirect/main.rs index f87c4a0b..02c85e89 100644 --- a/examples/indirect/main.rs +++ b/examples/indirect/main.rs @@ -21,8 +21,8 @@ use vulkano::{ BufferContents, BufferUsage, }, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, DrawIndirectCommand, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, DrawIndirectCommand, + RecordingCommandBuffer, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -522,14 +522,10 @@ impl ApplicationHandler for App { ) .unwrap(); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/instancing/main.rs b/examples/instancing/main.rs index d92f6539..fc18ba79 100644 --- a/examples/instancing/main.rs +++ b/examples/instancing/main.rs @@ -7,8 +7,8 @@ use std::{error::Error, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, }, device::{ physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Queue, @@ -442,14 +442,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/interactive-fractal/fractal_compute_pipeline.rs b/examples/interactive-fractal/fractal_compute_pipeline.rs index c54cdaa7..604d62a9 100644 --- a/examples/interactive-fractal/fractal_compute_pipeline.rs +++ b/examples/interactive-fractal/fractal_compute_pipeline.rs @@ -4,8 +4,7 @@ use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -147,14 +146,10 @@ impl FractalComputePipeline { [], ) .unwrap(); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/interactive-fractal/pixels_draw_pipeline.rs b/examples/interactive-fractal/pixels_draw_pipeline.rs index 452f9599..7b072efc 100644 --- a/examples/interactive-fractal/pixels_draw_pipeline.rs +++ b/examples/interactive-fractal/pixels_draw_pipeline.rs @@ -1,9 +1,8 @@ use std::sync::Arc; use vulkano::{ command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo, - CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage, - RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo, + CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -126,17 +125,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) -> Arc { - let mut builder = RecordingCommandBuffer::new( + pub fn draw( + &self, + viewport_dimensions: [u32; 2], + image: Arc, + ) -> Arc { + let mut builder = RecordingCommandBuffer::secondary( self.command_buffer_allocator.clone(), self.gfx_queue.queue_family_index(), - CommandBufferLevel::Secondary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::MultipleSubmit, - inheritance_info: Some(CommandBufferInheritanceInfo { - render_pass: Some(self.subpass.clone().into()), - ..Default::default() - }), + CommandBufferUsage::MultipleSubmit, + CommandBufferInheritanceInfo { + render_pass: Some(self.subpass.clone().into()), ..Default::default() }, ) diff --git a/examples/interactive-fractal/place_over_frame.rs b/examples/interactive-fractal/place_over_frame.rs index 78e3524c..796b7a8f 100644 --- a/examples/interactive-fractal/place_over_frame.rs +++ b/examples/interactive-fractal/place_over_frame.rs @@ -2,9 +2,8 @@ use crate::pixels_draw_pipeline::PixelsDrawPipeline; use std::sync::Arc; use vulkano::{ command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, SubpassBeginInfo, - SubpassContents, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, SubpassBeginInfo, SubpassContents, }, descriptor_set::allocator::StandardDescriptorSetAllocator, device::Queue, @@ -80,14 +79,10 @@ impl RenderPassPlaceOverFrame { let img_dims: [u32; 2] = target.image().extent()[0..2].try_into().unwrap(); // Create primary command buffer builder. - let mut command_buffer_builder = RecordingCommandBuffer::new( + let mut command_buffer_builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.gfx_queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/mesh-shader/main.rs b/examples/mesh-shader/main.rs index a27368c2..8749cbfc 100644 --- a/examples/mesh-shader/main.rs +++ b/examples/mesh-shader/main.rs @@ -17,8 +17,8 @@ use std::{error::Error, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -446,14 +446,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/msaa-renderpass/main.rs b/examples/msaa-renderpass/main.rs index 5fbf581d..ac09980c 100644 --- a/examples/msaa-renderpass/main.rs +++ b/examples/msaa-renderpass/main.rs @@ -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, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, CopyImageToBufferInfo, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyImageToBufferInfo, + RecordingCommandBuffer, RenderPassBeginInfo, }, device::{ physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo, @@ -379,14 +379,10 @@ fn main() { ) .unwrap(); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( command_buffer_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/multi-window-game-of-life/game_of_life.rs b/examples/multi-window-game-of-life/game_of_life.rs index eab55b29..1f282c3e 100644 --- a/examples/multi-window-game-of-life/game_of_life.rs +++ b/examples/multi-window-game-of-life/game_of_life.rs @@ -5,8 +5,8 @@ use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, PrimaryAutoCommandBuffer, + RecordingCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -130,14 +130,10 @@ impl GameOfLifeComputePipeline { life_color: [f32; 4], dead_color: [f32; 4], ) -> Box { - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.compute_queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); @@ -167,7 +163,7 @@ impl GameOfLifeComputePipeline { /// Builds the command for a dispatch. fn dispatch( &self, - builder: &mut RecordingCommandBuffer, + 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. diff --git a/examples/multi-window-game-of-life/pixels_draw.rs b/examples/multi-window-game-of-life/pixels_draw.rs index 6d495f15..028725ed 100644 --- a/examples/multi-window-game-of-life/pixels_draw.rs +++ b/examples/multi-window-game-of-life/pixels_draw.rs @@ -2,9 +2,8 @@ use crate::App; use std::sync::Arc; use vulkano::{ command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo, - CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage, - RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo, + CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -122,17 +121,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) -> Arc { - let mut builder = RecordingCommandBuffer::new( + pub fn draw( + &self, + viewport_dimensions: [u32; 2], + image: Arc, + ) -> Arc { + let mut builder = RecordingCommandBuffer::secondary( self.command_buffer_allocator.clone(), self.gfx_queue.queue_family_index(), - CommandBufferLevel::Secondary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::MultipleSubmit, - inheritance_info: Some(CommandBufferInheritanceInfo { - render_pass: Some(self.subpass.clone().into()), - ..Default::default() - }), + CommandBufferUsage::MultipleSubmit, + CommandBufferInheritanceInfo { + render_pass: Some(self.subpass.clone().into()), ..Default::default() }, ) diff --git a/examples/multi-window-game-of-life/render_pass.rs b/examples/multi-window-game-of-life/render_pass.rs index 63f67d83..ccd9682a 100644 --- a/examples/multi-window-game-of-life/render_pass.rs +++ b/examples/multi-window-game-of-life/render_pass.rs @@ -2,9 +2,8 @@ use crate::{pixels_draw::PixelsDrawPipeline, App}; use std::sync::Arc; use vulkano::{ command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, SubpassBeginInfo, - SubpassContents, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, SubpassBeginInfo, SubpassContents, }, device::Queue, image::view::ImageView, @@ -69,14 +68,10 @@ impl RenderPassPlaceOverFrame { let img_dims: [u32; 2] = target.image().extent()[0..2].try_into().unwrap(); // Create a primary command buffer builder. - let mut command_buffer_builder = RecordingCommandBuffer::new( + let mut command_buffer_builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.gfx_queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/multi-window/main.rs b/examples/multi-window/main.rs index 28f60c8d..a3b58e80 100644 --- a/examples/multi-window/main.rs +++ b/examples/multi-window/main.rs @@ -11,8 +11,8 @@ use std::{collections::HashMap, error::Error, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, }, device::{ physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Queue, @@ -422,14 +422,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/multiview/main.rs b/examples/multiview/main.rs index 63fcdf7f..e065c3e0 100644 --- a/examples/multiview/main.rs +++ b/examples/multiview/main.rs @@ -7,9 +7,8 @@ use std::{fs::File, io::BufWriter, path::Path, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, BufferImageCopy, CommandBufferBeginInfo, - CommandBufferLevel, CommandBufferUsage, CopyImageToBufferInfo, RecordingCommandBuffer, - RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, BufferImageCopy, CommandBufferUsage, + CopyImageToBufferInfo, RecordingCommandBuffer, RenderPassBeginInfo, }, device::{ physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures, @@ -329,14 +328,10 @@ fn main() { let buffer1 = create_buffer(); let buffer2 = create_buffer(); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( command_buffer_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/occlusion-query/main.rs b/examples/occlusion-query/main.rs index 01bb004c..1fa6eaca 100644 --- a/examples/occlusion-query/main.rs +++ b/examples/occlusion-query/main.rs @@ -6,8 +6,8 @@ use std::{error::Error, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, }, device::{ physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Queue, @@ -478,14 +478,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/offscreen/main.rs b/examples/offscreen/main.rs index cbb06220..fffaef7c 100644 --- a/examples/offscreen/main.rs +++ b/examples/offscreen/main.rs @@ -5,9 +5,8 @@ use std::{default::Default, fs::File, io::BufWriter, path::Path, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, CopyImageToBufferInfo, RecordingCommandBuffer, RenderPassBeginInfo, - SubpassBeginInfo, SubpassContents, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyImageToBufferInfo, + RecordingCommandBuffer, RenderPassBeginInfo, SubpassBeginInfo, SubpassContents, }, device::{physical::PhysicalDeviceType, Device, DeviceCreateInfo, QueueCreateInfo, QueueFlags}, format::Format, @@ -274,14 +273,10 @@ fn main() { ) .unwrap(); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( command_buffer_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/push-constants/main.rs b/examples/push-constants/main.rs index 343747fc..7c0593f1 100644 --- a/examples/push-constants/main.rs +++ b/examples/push-constants/main.rs @@ -7,8 +7,7 @@ use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -181,14 +180,10 @@ 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::new( + let mut builder = RecordingCommandBuffer::primary( command_buffer_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/push-descriptors/main.rs b/examples/push-descriptors/main.rs index e1ccf0ba..3fdb9883 100644 --- a/examples/push-descriptors/main.rs +++ b/examples/push-descriptors/main.rs @@ -2,8 +2,8 @@ use std::{error::Error, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyBufferToImageInfo, + RecordingCommandBuffer, RenderPassBeginInfo, }, descriptor_set::{layout::DescriptorSetLayoutCreateFlags, WriteDescriptorSet}, device::{ @@ -173,14 +173,10 @@ impl App { ) .unwrap(); - let mut uploads = RecordingCommandBuffer::new( + let mut uploads = RecordingCommandBuffer::primary( command_buffer_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); @@ -456,14 +452,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/runtime-array/main.rs b/examples/runtime-array/main.rs index 0e4cbb76..6882d24e 100644 --- a/examples/runtime-array/main.rs +++ b/examples/runtime-array/main.rs @@ -2,8 +2,8 @@ use std::{error::Error, io::Cursor, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyBufferToImageInfo, + RecordingCommandBuffer, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, layout::DescriptorBindingFlags, DescriptorSet, @@ -241,14 +241,10 @@ impl App { ) .unwrap(); - let mut uploads = RecordingCommandBuffer::new( + let mut uploads = RecordingCommandBuffer::primary( command_buffer_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); @@ -598,14 +594,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/runtime-shader/main.rs b/examples/runtime-shader/main.rs index bddccba5..cbb7024d 100644 --- a/examples/runtime-shader/main.rs +++ b/examples/runtime-shader/main.rs @@ -16,8 +16,8 @@ use std::{error::Error, fs::File, io::Read, path::Path, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, }, device::{ physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Queue, @@ -390,14 +390,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::MultipleSubmit, - ..Default::default() - }, + CommandBufferUsage::MultipleSubmit, ) .unwrap(); diff --git a/examples/self-copy-buffer/main.rs b/examples/self-copy-buffer/main.rs index fe53c3b2..68a6d0ae 100644 --- a/examples/self-copy-buffer/main.rs +++ b/examples/self-copy-buffer/main.rs @@ -6,8 +6,8 @@ use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage}, command_buffer::{ - allocator::StandardCommandBufferAllocator, BufferCopy, CommandBufferBeginInfo, - CommandBufferLevel, CommandBufferUsage, CopyBufferInfoTyped, RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, BufferCopy, CommandBufferUsage, + CopyBufferInfoTyped, RecordingCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -162,14 +162,10 @@ fn main() { ) .unwrap(); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( command_buffer_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/shader-include/main.rs b/examples/shader-include/main.rs index 6fc5f5c1..0d811e42 100644 --- a/examples/shader-include/main.rs +++ b/examples/shader-include/main.rs @@ -6,8 +6,7 @@ use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -167,14 +166,10 @@ fn main() { ) .unwrap(); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( command_buffer_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/shader-types-sharing/main.rs b/examples/shader-types-sharing/main.rs index 04746964..b0f35c8e 100644 --- a/examples/shader-types-sharing/main.rs +++ b/examples/shader-types-sharing/main.rs @@ -20,8 +20,7 @@ use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -193,14 +192,10 @@ fn main() { ) .unwrap(); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( command_buffer_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/simple-particles/main.rs b/examples/simple-particles/main.rs index eff06320..c41bb141 100644 --- a/examples/simple-particles/main.rs +++ b/examples/simple-particles/main.rs @@ -7,8 +7,8 @@ use std::{error::Error, sync::Arc, time::SystemTime}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, CopyBufferInfo, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyBufferInfo, + RecordingCommandBuffer, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -210,14 +210,10 @@ impl App { .unwrap(); // Create one-time command to copy between the buffers. - let mut cbb = RecordingCommandBuffer::new( + let mut cbb = RecordingCommandBuffer::primary( command_buffer_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); cbb.copy_buffer(CopyBufferInfo::buffers( @@ -542,14 +538,10 @@ impl ApplicationHandler for App { "not handling sub-optimal swapchains in this sample code", ); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/specialization-constants/main.rs b/examples/specialization-constants/main.rs index 8093eadb..07ee99a4 100644 --- a/examples/specialization-constants/main.rs +++ b/examples/specialization-constants/main.rs @@ -4,8 +4,7 @@ use std::sync::Arc; use vulkano::{ buffer::{Buffer, BufferCreateInfo, BufferUsage}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferLevel, CommandBufferUsage, - RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -170,14 +169,10 @@ fn main() { ) .unwrap(); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( command_buffer_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - vulkano::command_buffer::CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/teapot/main.rs b/examples/teapot/main.rs index ad2d12fb..d49f4f86 100644 --- a/examples/teapot/main.rs +++ b/examples/teapot/main.rs @@ -10,8 +10,8 @@ use vulkano::{ Buffer, BufferCreateInfo, BufferUsage, Subbuffer, }, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -444,14 +444,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/tessellation/main.rs b/examples/tessellation/main.rs index f3f70ef9..63f7f96d 100644 --- a/examples/tessellation/main.rs +++ b/examples/tessellation/main.rs @@ -16,8 +16,8 @@ use std::{error::Error, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, }, device::{ physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures, @@ -417,14 +417,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/texture-array/main.rs b/examples/texture-array/main.rs index 7509cafa..0118b0b8 100644 --- a/examples/texture-array/main.rs +++ b/examples/texture-array/main.rs @@ -2,8 +2,8 @@ use std::{error::Error, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, CopyBufferToImageInfo, + RecordingCommandBuffer, RenderPassBeginInfo, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -186,14 +186,10 @@ impl App { ) .unwrap(); - let mut uploads = RecordingCommandBuffer::new( + let mut uploads = RecordingCommandBuffer::primary( command_buffer_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); @@ -484,14 +480,10 @@ impl ApplicationHandler for App { rcx.recreate_swapchain = true; } - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/triangle-util/main.rs b/examples/triangle-util/main.rs index cbd3236d..17425e89 100644 --- a/examples/triangle-util/main.rs +++ b/examples/triangle-util/main.rs @@ -11,9 +11,8 @@ use std::{error::Error, sync::Arc, time::Duration}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, SubpassBeginInfo, - SubpassContents, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, SubpassBeginInfo, SubpassContents, }, image::view::ImageView, memory::allocator::{AllocationCreateInfo, MemoryTypeFilter}, @@ -382,14 +381,10 @@ impl ApplicationHandler for App { // // 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::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.context.graphics_queue().queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/triangle-v1_3/main.rs b/examples/triangle-v1_3/main.rs index 2a74e1ed..bd7a0591 100644 --- a/examples/triangle-v1_3/main.rs +++ b/examples/triangle-v1_3/main.rs @@ -16,8 +16,8 @@ use std::{error::Error, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderingAttachmentInfo, RenderingInfo, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderingAttachmentInfo, RenderingInfo, }, device::{ physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures, @@ -644,14 +644,10 @@ impl ApplicationHandler for App { // // 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::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/examples/triangle/main.rs b/examples/triangle/main.rs index cc02a145..f6adbfd5 100644 --- a/examples/triangle/main.rs +++ b/examples/triangle/main.rs @@ -11,9 +11,8 @@ use std::{error::Error, sync::Arc}; use vulkano::{ buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo, SubpassBeginInfo, - SubpassContents, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, + RenderPassBeginInfo, SubpassBeginInfo, SubpassContents, }, device::{ physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, Queue, @@ -649,14 +648,10 @@ impl ApplicationHandler for App { // // 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::new( + let mut builder = RecordingCommandBuffer::primary( self.command_buffer_allocator.clone(), self.queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/vulkano-taskgraph/src/graph/execute.rs b/vulkano-taskgraph/src/graph/execute.rs index 798704bc..b134b48b 100644 --- a/vulkano-taskgraph/src/graph/execute.rs +++ b/vulkano-taskgraph/src/graph/execute.rs @@ -21,8 +21,8 @@ use std::{ use vulkano::{ buffer::{Buffer, BufferMemory}, command_buffer::{ - sys::{RawCommandBuffer, RawRecordingCommandBuffer}, - CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, + sys::{CommandBufferBeginInfo, RawCommandBuffer, RawRecordingCommandBuffer}, + CommandBufferLevel, CommandBufferUsage, }, device::{Device, DeviceOwned, Queue}, image::Image, diff --git a/vulkano/src/buffer/allocator.rs b/vulkano/src/buffer/allocator.rs index 88324584..61345c89 100644 --- a/vulkano/src/buffer/allocator.rs +++ b/vulkano/src/buffer/allocator.rs @@ -78,9 +78,7 @@ const MAX_ARENAS: usize = 32; /// allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo}, /// BufferUsage, /// }, -/// command_buffer::{ -/// CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, RecordingCommandBuffer, -/// }, +/// command_buffer::{CommandBufferUsage, RecordingCommandBuffer}, /// memory::allocator::MemoryTypeFilter, /// sync::GpuFuture, /// }; @@ -107,14 +105,10 @@ const MAX_ARENAS: usize = 32; /// *subbuffer.write().unwrap() = data; /// /// // You can then use `subbuffer` as if it was an entirely separate buffer. -/// RecordingCommandBuffer::new( +/// RecordingCommandBuffer::primary( /// command_buffer_allocator.clone(), /// queue.queue_family_index(), -/// CommandBufferLevel::Primary, -/// CommandBufferBeginInfo { -/// usage: CommandBufferUsage::OneTimeSubmit, -/// ..Default::default() -/// }, +/// CommandBufferUsage::OneTimeSubmit, /// ) /// .unwrap() /// // For the sake of the example we just call `update_buffer` on the buffer, even though diff --git a/vulkano/src/buffer/mod.rs b/vulkano/src/buffer/mod.rs index 1a7ac923..bacb68a8 100644 --- a/vulkano/src/buffer/mod.rs +++ b/vulkano/src/buffer/mod.rs @@ -120,10 +120,7 @@ pub mod view; /// ``` /// use vulkano::{ /// buffer::{BufferUsage, Buffer, BufferCreateInfo}, -/// command_buffer::{ -/// CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, CopyBufferInfo, -/// RecordingCommandBuffer, -/// }, +/// command_buffer::{CommandBufferUsage, CopyBufferInfo, RecordingCommandBuffer}, /// memory::allocator::{AllocationCreateInfo, MemoryTypeFilter}, /// sync::GpuFuture, /// DeviceSize, @@ -173,14 +170,10 @@ pub mod view; /// .unwrap(); /// /// // Create a one-time command to copy between the buffers. -/// let mut cbb = RecordingCommandBuffer::new( +/// let mut cbb = RecordingCommandBuffer::primary( /// command_buffer_allocator.clone(), /// queue.queue_family_index(), -/// CommandBufferLevel::Primary, -/// CommandBufferBeginInfo { -/// usage: CommandBufferUsage::OneTimeSubmit, -/// ..Default::default() -/// }, +/// CommandBufferUsage::OneTimeSubmit, /// ) /// .unwrap(); /// cbb.copy_buffer(CopyBufferInfo::buffers( diff --git a/vulkano/src/command_buffer/auto/builder.rs b/vulkano/src/command_buffer/auto/builder.rs index 4a47d3e9..cdd4f1d6 100644 --- a/vulkano/src/command_buffer/auto/builder.rs +++ b/vulkano/src/command_buffer/auto/builder.rs @@ -1,11 +1,12 @@ use super::{ - CommandBuffer, CommandInfo, RenderPassCommand, Resource, ResourceUseRef2, SubmitState, + CommandInfo, PrimaryAutoCommandBuffer, RenderPassCommand, Resource, ResourceUseRef2, + SecondaryAutoCommandBuffer, SubmitState, }; use crate::{ buffer::{Buffer, IndexBuffer, Subbuffer}, command_buffer::{ allocator::CommandBufferAllocator, - sys::{CommandBufferBeginInfo, RawRecordingCommandBuffer}, + sys::{CommandBufferBeginInfo, RawCommandBuffer, RawRecordingCommandBuffer}, CommandBufferBufferRangeUsage, CommandBufferBufferUsage, CommandBufferImageRangeUsage, CommandBufferImageUsage, CommandBufferInheritanceInfo, CommandBufferInheritanceRenderPassType, CommandBufferLevel, CommandBufferResourcesUsage, @@ -45,6 +46,7 @@ use smallvec::SmallVec; use std::{ collections::hash_map::Entry, fmt::Debug, + marker::PhantomData, mem::take, ops::{Range, RangeInclusive}, sync::{atomic::AtomicBool, Arc}, @@ -57,24 +59,151 @@ 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 { +pub struct RecordingCommandBuffer { pub(in crate::command_buffer) inner: RawRecordingCommandBuffer, commands: Vec<( CommandInfo, Box, )>, pub(in crate::command_buffer) builder_state: CommandBufferBuilderState, + marker: PhantomData L>, } -impl RecordingCommandBuffer { - /// Allocates and begins recording a new command buffer. +impl RecordingCommandBuffer { + /// Allocates and begins recording a new primary command buffer. #[inline] - pub fn new( + pub fn primary( + allocator: Arc, + queue_family_index: u32, + usage: CommandBufferUsage, + ) -> Result, Validated> { + unsafe { + Self::new( + 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, + queue_family_index: u32, + usage: CommandBufferUsage, + ) -> Result, Validated> { + unsafe { + Self::new_unchecked( + allocator, + queue_family_index, + CommandBufferLevel::Primary, + CommandBufferBeginInfo { + usage, + inheritance_info: None, + _ne: crate::NonExhaustive(()), + }, + ) + } + } + + /// Ends the recording, returning a command buffer which can be submitted. + pub fn end(self) -> Result, Validated> { + self.validate_end()?; + + 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 { + /// Allocates and begins recording a new secondary command buffer. + #[inline] + pub fn secondary( + allocator: Arc, + queue_family_index: u32, + usage: CommandBufferUsage, + inheritance_info: CommandBufferInheritanceInfo, + ) -> Result, Validated> { + unsafe { + Self::new( + 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, + queue_family_index: u32, + usage: CommandBufferUsage, + inheritance_info: CommandBufferInheritanceInfo, + ) -> Result, Validated> { + unsafe { + Self::new_unchecked( + allocator, + queue_family_index, + CommandBufferLevel::Secondary, + CommandBufferBeginInfo { + usage, + inheritance_info: Some(inheritance_info), + _ne: crate::NonExhaustive(()), + }, + ) + } + } + + /// Ends the recording, returning a command buffer which can be submitted. + pub fn end(self) -> Result, Validated> { + self.validate_end()?; + + let (inner, keep_alive_objects, _, resources_usage) = unsafe { self.end_unchecked()? }; + + let submit_state = match inner.usage() { + CommandBufferUsage::MultipleSubmit => SubmitState::ExclusiveUse { + in_use: AtomicBool::new(false), + }, + CommandBufferUsage::SimultaneousUse => SubmitState::Concurrent, + CommandBufferUsage::OneTimeSubmit => SubmitState::OneTime { + already_submitted: AtomicBool::new(false), + }, + }; + + Ok(Arc::new(SecondaryAutoCommandBuffer { + inner, + _keep_alive_objects: keep_alive_objects, + resources_usage, + submit_state, + })) + } +} + +impl RecordingCommandBuffer { + unsafe fn new( allocator: Arc, queue_family_index: u32, level: CommandBufferLevel, begin_info: CommandBufferBeginInfo, - ) -> Result> { + ) -> Result> { Self::validate_new(allocator.device(), queue_family_index, level, &begin_info)?; unsafe { Self::new_unchecked(allocator, queue_family_index, level, begin_info) } @@ -91,8 +220,7 @@ impl RecordingCommandBuffer { Ok(()) } - #[cfg_attr(not(feature = "document_unchecked"), doc(hidden))] - pub unsafe fn new_unchecked( + unsafe fn new_unchecked( allocator: Arc, queue_family_index: u32, level: CommandBufferLevel, @@ -130,19 +258,14 @@ impl RecordingCommandBuffer { inner, commands: Vec::new(), builder_state, + marker: PhantomData, }) } - /// Ends the recording, returning a command buffer which can be submitted. - #[inline] - pub fn end(self) -> Result, Validated> { - self.validate_end()?; - - unsafe { self.end_unchecked() } - } - fn validate_end(&self) -> Result<(), Box> { - if self.level() == CommandBufferLevel::Primary && self.builder_state.render_pass.is_some() { + if self.inner.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"], @@ -164,8 +287,17 @@ impl RecordingCommandBuffer { Ok(()) } - #[cfg_attr(not(feature = "document_unchecked"), doc(hidden))] - pub unsafe fn end_unchecked(mut self) -> Result, Validated> { + unsafe fn end_unchecked( + mut self, + ) -> Result< + ( + RawCommandBuffer, + Vec>, + CommandBufferResourcesUsage, + SecondaryCommandBufferResourcesUsage, + ), + Validated, + > { let mut auto_sync_state = AutoSyncState::new( self.device().clone(), self.inner.level(), @@ -230,28 +362,15 @@ impl RecordingCommandBuffer { debug_assert!(barriers.is_empty()); - let submit_state = match self.inner.usage() { - CommandBufferUsage::MultipleSubmit => SubmitState::ExclusiveUse { - in_use: AtomicBool::new(false), - }, - CommandBufferUsage::SimultaneousUse => SubmitState::Concurrent, - CommandBufferUsage::OneTimeSubmit => SubmitState::OneTime { - already_submitted: AtomicBool::new(false), - }, - }; - - Ok(Arc::new(CommandBuffer { - inner: self.inner.end()?, - _keep_alive_objects: self - .commands + Ok(( + self.inner.end()?, + 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. @@ -261,7 +380,7 @@ impl RecordingCommandBuffer { } } -impl RecordingCommandBuffer { +impl RecordingCommandBuffer { pub(in crate::command_buffer) fn add_command( &mut self, name: &'static str, @@ -311,7 +430,7 @@ impl RecordingCommandBuffer { } } -unsafe impl DeviceOwned for RecordingCommandBuffer { +unsafe impl DeviceOwned for RecordingCommandBuffer { #[inline] fn device(&self) -> &Arc { self.inner.device() diff --git a/vulkano/src/command_buffer/auto/mod.rs b/vulkano/src/command_buffer/auto/mod.rs index 926c8afe..599fcad8 100644 --- a/vulkano/src/command_buffer/auto/mod.rs +++ b/vulkano/src/command_buffer/auto/mod.rs @@ -64,9 +64,9 @@ pub(in crate::command_buffer) use self::builder::{ }; use super::{ sys::{RawCommandBuffer, RawRecordingCommandBuffer}, - CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferResourcesUsage, - CommandBufferState, CommandBufferUsage, ResourceInCommand, - SecondaryCommandBufferResourcesUsage, SecondaryResourceUseRef, + CommandBufferInheritanceInfo, CommandBufferResourcesUsage, CommandBufferState, + CommandBufferUsage, ResourceInCommand, SecondaryCommandBufferResourcesUsage, + SecondaryResourceUseRef, }; use crate::{ buffer::Subbuffer, @@ -87,17 +87,14 @@ use std::{ mod builder; -pub struct CommandBuffer { +pub struct PrimaryAutoCommandBuffer { inner: RawCommandBuffer, - // TODO: Remove all of this. _keep_alive_objects: Vec>, resources_usage: CommandBufferResourcesUsage, - secondary_resources_usage: SecondaryCommandBufferResourcesUsage, state: Mutex, - submit_state: SubmitState, } -unsafe impl VulkanObject for CommandBuffer { +unsafe impl VulkanObject for PrimaryAutoCommandBuffer { type Handle = ash::vk::CommandBuffer; #[inline] @@ -106,22 +103,22 @@ unsafe impl VulkanObject for CommandBuffer { } } -unsafe impl DeviceOwned for CommandBuffer { +unsafe impl DeviceOwned for PrimaryAutoCommandBuffer { #[inline] fn device(&self) -> &Arc { self.inner.device() } } -impl Debug for CommandBuffer { +impl Debug for PrimaryAutoCommandBuffer { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { - f.debug_struct("CommandBuffer") + f.debug_struct("PrimaryAutoCommandBuffer") .field("inner", &self.inner) .finish_non_exhaustive() } } -impl CommandBuffer { +impl PrimaryAutoCommandBuffer { /// Returns the inner raw command buffer. #[inline] pub fn inner(&self) -> &RawCommandBuffer { @@ -134,10 +131,63 @@ impl CommandBuffer { self.inner.queue_family_index() } - /// Returns the level of the command buffer. + /// Returns the usage of this command buffer. #[inline] - pub fn level(&self) -> CommandBufferLevel { - self.inner.level() + 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>, + resources_usage: SecondaryCommandBufferResourcesUsage, + submit_state: SubmitState, +} + +unsafe impl VulkanObject for SecondaryAutoCommandBuffer { + type Handle = ash::vk::CommandBuffer; + + #[inline] + fn handle(&self) -> Self::Handle { + self.inner.handle() + } +} + +unsafe impl DeviceOwned for SecondaryAutoCommandBuffer { + #[inline] + fn device(&self) -> &Arc { + self.inner.device() + } +} + +impl Debug for SecondaryAutoCommandBuffer { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { + f.debug_struct("SecondaryAutoCommandBuffer") + .field("inner", &self.inner) + .finish_non_exhaustive() + } +} + +impl SecondaryAutoCommandBuffer { + /// Returns the 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 usage of this command buffer. @@ -146,31 +196,17 @@ impl CommandBuffer { self.inner.usage() } - /// Returns the inheritance info of the command buffer, if it is a secondary command buffer. + /// Returns the inheritance info of the command buffer. #[inline] - 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 + pub fn inheritance_info(&self) -> &CommandBufferInheritanceInfo { + self.inner.inheritance_info().unwrap() } /// Checks whether this command buffer is allowed to be recorded to a command buffer, /// and if so locks it. /// /// If you call this function, then you should call `unlock` afterwards. - pub(crate) fn lock_record(&self) -> Result<(), Box> { - debug_assert_eq!(self.level(), CommandBufferLevel::Secondary); - + pub fn lock_record(&self) -> Result<(), Box> { match self.submit_state { SubmitState::OneTime { ref already_submitted, @@ -211,9 +247,7 @@ impl CommandBuffer { /// # Safety /// /// Must not be called if you haven't called `lock_record` before. - pub(crate) unsafe fn unlock(&self) { - debug_assert_eq!(self.level(), CommandBufferLevel::Secondary); - + pub unsafe fn unlock(&self) { match self.submit_state { SubmitState::OneTime { ref already_submitted, @@ -228,8 +262,8 @@ impl CommandBuffer { }; } - pub(crate) fn secondary_resources_usage(&self) -> &SecondaryCommandBufferResourcesUsage { - &self.secondary_resources_usage + pub(crate) fn resources_usage(&self) -> &SecondaryCommandBufferResourcesUsage { + &self.resources_usage } } @@ -312,8 +346,7 @@ mod tests { buffer::{Buffer, BufferCreateInfo, BufferUsage}, command_buffer::{ allocator::{StandardCommandBufferAllocator, StandardCommandBufferAllocatorCreateInfo}, - BufferCopy, CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, - CopyBufferInfoTyped, RecordingCommandBuffer, + BufferCopy, CommandBufferUsage, CopyBufferInfoTyped, RecordingCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, @@ -341,14 +374,10 @@ mod tests { Default::default(), )); - RecordingCommandBuffer::new( + RecordingCommandBuffer::primary( allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::MultipleSubmit, - ..Default::default() - }, + CommandBufferUsage::MultipleSubmit, ) .unwrap(); } @@ -411,14 +440,10 @@ mod tests { device, Default::default(), )); - let mut cbb = RecordingCommandBuffer::new( + let mut cbb = RecordingCommandBuffer::primary( cb_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); @@ -461,28 +486,20 @@ mod tests { )); // Make a secondary CB that doesn't support simultaneous use. - let builder = RecordingCommandBuffer::new( + let builder = RecordingCommandBuffer::secondary( cb_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Secondary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::MultipleSubmit, - inheritance_info: Some(Default::default()), - ..Default::default() - }, + CommandBufferUsage::MultipleSubmit, + Default::default(), ) .unwrap(); let secondary = builder.end().unwrap(); { - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( cb_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::SimultaneousUse, - ..Default::default() - }, + CommandBufferUsage::SimultaneousUse, ) .unwrap(); @@ -495,27 +512,19 @@ mod tests { } { - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( cb_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::SimultaneousUse, - ..Default::default() - }, + CommandBufferUsage::SimultaneousUse, ) .unwrap(); builder.execute_commands(secondary.clone()).unwrap(); let cb1 = builder.end().unwrap(); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( cb_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::SimultaneousUse, - ..Default::default() - }, + CommandBufferUsage::SimultaneousUse, ) .unwrap(); @@ -554,14 +563,10 @@ mod tests { device, Default::default(), )); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( cb_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); @@ -616,14 +621,10 @@ mod tests { device, Default::default(), )); - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::primary( cb_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); @@ -653,14 +654,10 @@ mod tests { ..Default::default() }, )); - let cbb = RecordingCommandBuffer::new( + let cbb = RecordingCommandBuffer::primary( cb_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); @@ -693,15 +690,11 @@ mod tests { // Two secondary command buffers that both write to the buffer let secondary = (0..2) .map(|_| { - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::secondary( cb_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Secondary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::SimultaneousUse, - inheritance_info: Some(Default::default()), - ..Default::default() - }, + CommandBufferUsage::SimultaneousUse, + Default::default(), ) .unwrap(); builder @@ -712,15 +705,11 @@ mod tests { .collect::>(); { - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::secondary( cb_allocator.clone(), queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::SimultaneousUse, - inheritance_info: Some(Default::default()), - ..Default::default() - }, + CommandBufferUsage::SimultaneousUse, + Default::default(), ) .unwrap(); @@ -740,15 +729,11 @@ mod tests { } { - let mut builder = RecordingCommandBuffer::new( + let mut builder = RecordingCommandBuffer::secondary( cb_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::SimultaneousUse, - inheritance_info: Some(Default::default()), - ..Default::default() - }, + CommandBufferUsage::SimultaneousUse, + Default::default(), ) .unwrap(); @@ -772,14 +757,10 @@ mod tests { device.clone(), Default::default(), )); - let mut sync = RecordingCommandBuffer::new( + let mut sync = RecordingCommandBuffer::primary( cb_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::MultipleSubmit, - ..Default::default() - }, + CommandBufferUsage::MultipleSubmit, ) .unwrap(); @@ -815,14 +796,10 @@ mod tests { device.clone(), Default::default(), )); - let mut sync = RecordingCommandBuffer::new( + let mut sync = RecordingCommandBuffer::primary( cb_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::MultipleSubmit, - ..Default::default() - }, + CommandBufferUsage::MultipleSubmit, ) .unwrap(); let set_layout = DescriptorSetLayout::new( diff --git a/vulkano/src/command_buffer/commands/acceleration_structure.rs b/vulkano/src/command_buffer/commands/acceleration_structure.rs index 8236aa42..5cc2afa8 100644 --- a/vulkano/src/command_buffer/commands/acceleration_structure.rs +++ b/vulkano/src/command_buffer/commands/acceleration_structure.rs @@ -24,7 +24,7 @@ use smallvec::SmallVec; use std::{mem::size_of, sync::Arc}; /// # Commands to do operations on acceleration structures. -impl RecordingCommandBuffer { +impl RecordingCommandBuffer { /// Builds or updates an acceleration structure. /// /// # Safety diff --git a/vulkano/src/command_buffer/commands/bind_push.rs b/vulkano/src/command_buffer/commands/bind_push.rs index e2b75a90..6d4bb34e 100644 --- a/vulkano/src/command_buffer/commands/bind_push.rs +++ b/vulkano/src/command_buffer/commands/bind_push.rs @@ -20,7 +20,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 RecordingCommandBuffer { +impl RecordingCommandBuffer { /// Binds descriptor sets for future dispatch or draw calls. pub fn bind_descriptor_sets( &mut self, diff --git a/vulkano/src/command_buffer/commands/clear.rs b/vulkano/src/command_buffer/commands/clear.rs index 0007f249..b9dbabb0 100644 --- a/vulkano/src/command_buffer/commands/clear.rs +++ b/vulkano/src/command_buffer/commands/clear.rs @@ -14,7 +14,7 @@ use smallvec::{smallvec, SmallVec}; use std::{mem::size_of_val, sync::Arc}; /// # Commands to fill resources with new data. -impl RecordingCommandBuffer { +impl RecordingCommandBuffer { /// Clears a color image with a specific value. pub fn clear_color_image( &mut self, diff --git a/vulkano/src/command_buffer/commands/copy.rs b/vulkano/src/command_buffer/commands/copy.rs index ee61f1b8..be745c77 100644 --- a/vulkano/src/command_buffer/commands/copy.rs +++ b/vulkano/src/command_buffer/commands/copy.rs @@ -20,7 +20,7 @@ use std::{ }; /// # Commands to transfer data between resources. -impl RecordingCommandBuffer { +impl RecordingCommandBuffer { /// Copies data from a buffer to another buffer. /// /// # Panics diff --git a/vulkano/src/command_buffer/commands/debug.rs b/vulkano/src/command_buffer/commands/debug.rs index dba8a044..5dee1451 100644 --- a/vulkano/src/command_buffer/commands/debug.rs +++ b/vulkano/src/command_buffer/commands/debug.rs @@ -10,7 +10,7 @@ use crate::{ /// 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 RecordingCommandBuffer { +impl RecordingCommandBuffer { /// Opens a command buffer debug label region. pub fn begin_debug_utils_label( &mut self, diff --git a/vulkano/src/command_buffer/commands/dynamic_state.rs b/vulkano/src/command_buffer/commands/dynamic_state.rs index b01b350a..858374aa 100644 --- a/vulkano/src/command_buffer/commands/dynamic_state.rs +++ b/vulkano/src/command_buffer/commands/dynamic_state.rs @@ -22,7 +22,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 RecordingCommandBuffer { +impl RecordingCommandBuffer { // Helper function for dynamic state setting. fn validate_graphics_pipeline_fixed_state( &self, diff --git a/vulkano/src/command_buffer/commands/pipeline.rs b/vulkano/src/command_buffer/commands/pipeline.rs index d77359f0..ade9cc99 100644 --- a/vulkano/src/command_buffer/commands/pipeline.rs +++ b/vulkano/src/command_buffer/commands/pipeline.rs @@ -52,7 +52,7 @@ macro_rules! vuids { /// # Commands to execute a bound pipeline. /// /// Dispatch commands require a compute queue, draw commands require a graphics queue. -impl RecordingCommandBuffer { +impl RecordingCommandBuffer { /// Perform a single compute operation using a compute pipeline. /// /// A compute pipeline must have been bound using diff --git a/vulkano/src/command_buffer/commands/query.rs b/vulkano/src/command_buffer/commands/query.rs index 2cb61792..aa6f8488 100644 --- a/vulkano/src/command_buffer/commands/query.rs +++ b/vulkano/src/command_buffer/commands/query.rs @@ -13,7 +13,7 @@ use crate::{ use std::{ops::Range, sync::Arc}; /// # Commands related to queries. -impl RecordingCommandBuffer { +impl RecordingCommandBuffer { /// Begins a query. /// /// The query will be active until [`end_query`](Self::end_query) is called for the same query. diff --git a/vulkano/src/command_buffer/commands/render_pass.rs b/vulkano/src/command_buffer/commands/render_pass.rs index 6b04d278..11a62c1f 100644 --- a/vulkano/src/command_buffer/commands/render_pass.rs +++ b/vulkano/src/command_buffer/commands/render_pass.rs @@ -24,7 +24,7 @@ use std::{cmp::min, ops::Range, sync::Arc}; /// # Commands for render passes. /// /// These commands require a graphics queue. -impl RecordingCommandBuffer { +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,9 +328,7 @@ impl RecordingCommandBuffer { self } -} -impl RecordingCommandBuffer { /// Begins a render pass without a render pass object or framebuffer. /// /// Requires the [`dynamic_rendering`] device feature. diff --git a/vulkano/src/command_buffer/commands/secondary.rs b/vulkano/src/command_buffer/commands/secondary.rs index 4152bbcd..9c4ff157 100644 --- a/vulkano/src/command_buffer/commands/secondary.rs +++ b/vulkano/src/command_buffer/commands/secondary.rs @@ -2,8 +2,8 @@ use crate::{ command_buffer::{ auto::{RenderPassStateType, Resource, ResourceUseRef2}, sys::{RawCommandBuffer, RawRecordingCommandBuffer}, - CommandBuffer, CommandBufferInheritanceRenderPassType, CommandBufferLevel, - RecordingCommandBuffer, ResourceInCommand, SecondaryCommandBufferBufferUsage, + CommandBufferInheritanceRenderPassType, CommandBufferLevel, RecordingCommandBuffer, + ResourceInCommand, SecondaryAutoCommandBuffer, 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 RecordingCommandBuffer { +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 RecordingCommandBuffer { /// with `Flags::OneTimeSubmit` will set `self`'s flags to `Flags::OneTimeSubmit` also. pub fn execute_commands( &mut self, - command_buffer: Arc, + command_buffer: Arc, ) -> Result<&mut Self, Box> { let command_buffer = DropUnlockCommandBuffer::new(command_buffer)?; self.validate_execute_commands(iter::once(&**command_buffer))?; @@ -41,7 +41,7 @@ impl RecordingCommandBuffer { // TODO ^ would be nice if this just worked without errors pub fn execute_commands_from_vec( &mut self, - command_buffers: Vec>, + command_buffers: Vec>, ) -> Result<&mut Self, Box> { let command_buffers: SmallVec<[_; 4]> = command_buffers .into_iter() @@ -55,7 +55,7 @@ impl RecordingCommandBuffer { fn validate_execute_commands<'a>( &self, - command_buffers: impl Iterator + Clone, + command_buffers: impl Iterator + Clone, ) -> Result<(), Box> { self.inner .validate_execute_commands(command_buffers.clone().map(|cb| cb.inner()))?; @@ -89,7 +89,7 @@ impl RecordingCommandBuffer { } for (command_buffer_index, command_buffer) in command_buffers.enumerate() { - let inheritance_info = command_buffer.inheritance_info().unwrap(); + let inheritance_info = command_buffer.inheritance_info(); if let Some(render_pass_state) = &self.builder_state.render_pass { let inheritance_render_pass = @@ -459,7 +459,7 @@ impl RecordingCommandBuffer { #[cfg_attr(not(feature = "document_unchecked"), doc(hidden))] pub unsafe fn execute_commands_unchecked( &mut self, - command_buffers: SmallVec<[Arc; 4]>, + command_buffers: SmallVec<[Arc; 4]>, ) -> &mut Self { self.execute_commands_locked( command_buffers @@ -485,7 +485,7 @@ impl RecordingCommandBuffer { .flat_map(|(index, command_buffer)| { let index = index as u32; let SecondaryCommandBufferResourcesUsage { buffers, images } = - command_buffer.secondary_resources_usage(); + command_buffer.resources_usage(); (buffers.iter().map(move |usage| { let &SecondaryCommandBufferBufferUsage { @@ -670,17 +670,17 @@ impl RawRecordingCommandBuffer { } } -struct DropUnlockCommandBuffer(Arc); +struct DropUnlockCommandBuffer(Arc); impl DropUnlockCommandBuffer { - fn new(command_buffer: Arc) -> Result> { + fn new(command_buffer: Arc) -> Result> { command_buffer.lock_record()?; Ok(Self(command_buffer)) } } impl std::ops::Deref for DropUnlockCommandBuffer { - type Target = Arc; + type Target = Arc; fn deref(&self) -> &Self::Target { &self.0 diff --git a/vulkano/src/command_buffer/mod.rs b/vulkano/src/command_buffer/mod.rs index 6c1f9c61..c437520c 100644 --- a/vulkano/src/command_buffer/mod.rs +++ b/vulkano/src/command_buffer/mod.rs @@ -41,19 +41,18 @@ //! 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 a [`CommandBuffer`]. +//! buffer and turn it into either a [`PrimaryAutoCommandBuffer`] or a +//! [`SecondaryAutoCommandBuffer`]. //! //! # Submitting a primary command buffer //! -//! 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. +//! Once a primary command buffer is recorded and built, you can submit the +//! [`PrimaryAutoCommandBuffer`] to a queue. Submitting a command buffer returns an object that +//! implements the [`GpuFuture`] trait and that represents the moment when the execution will end +//! on the GPU. //! //! ``` -//! use vulkano::command_buffer::{ -//! CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, RecordingCommandBuffer, -//! SubpassContents, -//! }; +//! use vulkano::command_buffer::{CommandBufferUsage, RecordingCommandBuffer, SubpassContents}; //! //! # let device: std::sync::Arc = return; //! # let queue: std::sync::Arc = return; @@ -62,11 +61,10 @@ //! # let graphics_pipeline: std::sync::Arc = return; //! # let command_buffer_allocator: std::sync::Arc = return; //! # -//! let mut cb = RecordingCommandBuffer::new( +//! let mut cb = RecordingCommandBuffer::primary( //! command_buffer_allocator.clone(), //! queue.queue_family_index(), -//! CommandBufferLevel::Primary, -//! CommandBufferBeginInfo::default(), +//! CommandBufferUsage::OneTimeSubmit, //! ) //! .unwrap(); //! @@ -100,8 +98,7 @@ pub use self::commands::{ query::*, render_pass::*, secondary::*, sync::*, }; pub use self::{ - auto::{CommandBuffer, RecordingCommandBuffer}, - sys::CommandBufferBeginInfo, + auto::{PrimaryAutoCommandBuffer, RecordingCommandBuffer, SecondaryAutoCommandBuffer}, traits::{CommandBufferExecError, CommandBufferExecFuture}, }; use crate::{ @@ -1199,7 +1196,7 @@ pub struct CommandBufferSubmitInfo { /// The command buffer to execute. /// /// There is no default value. - pub command_buffer: Arc, + pub command_buffer: Arc, pub _ne: crate::NonExhaustive, } @@ -1207,7 +1204,7 @@ pub struct CommandBufferSubmitInfo { impl CommandBufferSubmitInfo { /// Returns a `CommandBufferSubmitInfo` with the specified `command_buffer`. #[inline] - pub fn new(command_buffer: Arc) -> Self { + pub fn new(command_buffer: Arc) -> Self { Self { command_buffer, _ne: crate::NonExhaustive(()), @@ -1223,15 +1220,6 @@ 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(()) } diff --git a/vulkano/src/command_buffer/traits.rs b/vulkano/src/command_buffer/traits.rs index d80c649c..6f7c1fc0 100644 --- a/vulkano/src/command_buffer/traits.rs +++ b/vulkano/src/command_buffer/traits.rs @@ -1,4 +1,4 @@ -use super::{CommandBuffer, CommandBufferSubmitInfo, SemaphoreSubmitInfo, SubmitInfo}; +use super::{CommandBufferSubmitInfo, PrimaryAutoCommandBuffer, SemaphoreSubmitInfo, SubmitInfo}; use crate::{ buffer::Buffer, device::{Device, DeviceOwned, Queue}, @@ -26,7 +26,7 @@ use std::{ thread, }; -impl CommandBuffer { +impl PrimaryAutoCommandBuffer { /// 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, + command_buffer: Arc, queue: Arc, // True if the command buffer has already been submitted. // If flush is called multiple times, we want to block so that only one flushing is executed. diff --git a/vulkano/src/pipeline/compute.rs b/vulkano/src/pipeline/compute.rs index ced9b1ec..2c639c59 100644 --- a/vulkano/src/pipeline/compute.rs +++ b/vulkano/src/pipeline/compute.rs @@ -433,8 +433,7 @@ mod tests { use crate::{ buffer::{Buffer, BufferCreateInfo, BufferUsage}, command_buffer::{ - allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel, - CommandBufferUsage, RecordingCommandBuffer, + allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer, }, descriptor_set::{ allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet, @@ -545,14 +544,10 @@ mod tests { device.clone(), Default::default(), )); - let mut cbb = RecordingCommandBuffer::new( + let mut cbb = RecordingCommandBuffer::primary( cb_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); @@ -700,14 +695,10 @@ mod tests { device.clone(), Default::default(), )); - let mut cbb = RecordingCommandBuffer::new( + let mut cbb = RecordingCommandBuffer::primary( cb_allocator, queue.queue_family_index(), - CommandBufferLevel::Primary, - CommandBufferBeginInfo { - usage: CommandBufferUsage::OneTimeSubmit, - ..Default::default() - }, + CommandBufferUsage::OneTimeSubmit, ) .unwrap(); diff --git a/vulkano/src/swapchain/mod.rs b/vulkano/src/swapchain/mod.rs index 4b4f9c22..71093689 100644 --- a/vulkano/src/swapchain/mod.rs +++ b/vulkano/src/swapchain/mod.rs @@ -234,7 +234,7 @@ //! # let mut swapchain: ::std::sync::Arc = return; //! // let mut (swapchain, images) = Swapchain::new(...); //! loop { -//! # let mut command_buffer: ::std::sync::Arc<::vulkano::command_buffer::CommandBuffer> = return; +//! # let mut command_buffer: ::std::sync::Arc<::vulkano::command_buffer::PrimaryAutoCommandBuffer> = return; //! let (image_index, suboptimal, acquire_future) //! = swapchain::acquire_next_image(swapchain.clone(), None).unwrap(); //! diff --git a/vulkano/src/sync/future/mod.rs b/vulkano/src/sync/future/mod.rs index ba95dba2..eedc2607 100644 --- a/vulkano/src/sync/future/mod.rs +++ b/vulkano/src/sync/future/mod.rs @@ -91,9 +91,9 @@ use super::{fence::Fence, semaphore::Semaphore}; use crate::{ buffer::{Buffer, BufferState}, command_buffer::{ - CommandBuffer, CommandBufferExecError, CommandBufferExecFuture, - CommandBufferResourcesUsage, CommandBufferState, CommandBufferSubmitInfo, - CommandBufferUsage, SubmitInfo, + CommandBufferExecError, CommandBufferExecFuture, CommandBufferResourcesUsage, + CommandBufferState, CommandBufferSubmitInfo, CommandBufferUsage, PrimaryAutoCommandBuffer, + SubmitInfo, }, device::{DeviceOwned, Queue}, image::{Image, ImageLayout, ImageState}, @@ -242,7 +242,7 @@ pub unsafe trait GpuFuture: DeviceOwned { fn then_execute( self, queue: Arc, - command_buffer: Arc, + command_buffer: Arc, ) -> Result, CommandBufferExecError> where Self: Sized, @@ -256,7 +256,7 @@ pub unsafe trait GpuFuture: DeviceOwned { /// > `CommandBuffer` trait. fn then_execute_same_queue( self, - command_buffer: Arc, + command_buffer: Arc, ) -> Result, CommandBufferExecError> where Self: Sized,