Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge PrimaryAutoCommandBuffer and SecondaryAutoCommandBuffer into CommandBuffer #2425

Merged
merged 6 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions examples/async-update/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage},
command_buffer::{
allocator::StandardCommandBufferAllocator, BufferImageCopy, ClearColorImageInfo,
CommandBufferUsage, CopyBufferToImageInfo, RecordingCommandBuffer, RenderPassBeginInfo,
CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, CopyBufferToImageInfo,
RecordingCommandBuffer, RenderPassBeginInfo,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
Expand Down Expand Up @@ -331,10 +332,14 @@ fn main() -> Result<(), impl Error> {

// Initialize the textures.
{
let mut builder = RecordingCommandBuffer::primary(
let mut builder = RecordingCommandBuffer::new(
command_buffer_allocator.clone(),
graphics_queue.queue_family_index(),
CommandBufferUsage::OneTimeSubmit,
CommandBufferLevel::Primary,
CommandBufferBeginInfo {
usage: CommandBufferUsage::OneTimeSubmit,
..Default::default()
},
)
.unwrap();
for texture in &textures {
Expand Down Expand Up @@ -587,10 +592,14 @@ fn main() -> Result<(), impl Error> {
recreate_swapchain = true;
}

let mut builder = RecordingCommandBuffer::primary(
let mut builder = RecordingCommandBuffer::new(
command_buffer_allocator.clone(),
graphics_queue.queue_family_index(),
CommandBufferUsage::OneTimeSubmit,
CommandBufferLevel::Primary,
CommandBufferBeginInfo {
usage: CommandBufferUsage::OneTimeSubmit,
..Default::default()
},
)
.unwrap();
builder
Expand Down Expand Up @@ -761,10 +770,14 @@ fn run_worker(
// Write to the texture that's currently not in use for rendering.
let texture = textures[!current_index as usize].clone();

let mut builder = RecordingCommandBuffer::primary(
let mut builder = RecordingCommandBuffer::new(
command_buffer_allocator.clone(),
transfer_queue.queue_family_index(),
CommandBufferUsage::OneTimeSubmit,
CommandBufferLevel::Primary,
CommandBufferBeginInfo {
usage: CommandBufferUsage::OneTimeSubmit,
..Default::default()
},
)
.unwrap();
builder
Expand Down
11 changes: 8 additions & 3 deletions examples/basic-compute-shader/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use std::sync::Arc;
use vulkano::{
buffer::{Buffer, BufferCreateInfo, BufferUsage},
command_buffer::{
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
CommandBufferUsage, RecordingCommandBuffer,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
Expand Down Expand Up @@ -195,10 +196,14 @@ fn main() {
.unwrap();

// In order to execute our operation, we have to build a command buffer.
let mut builder = RecordingCommandBuffer::primary(
let mut builder = RecordingCommandBuffer::new(
command_buffer_allocator,
queue.queue_family_index(),
CommandBufferUsage::OneTimeSubmit,
CommandBufferLevel::Primary,
CommandBufferBeginInfo {
usage: CommandBufferUsage::OneTimeSubmit,
..Default::default()
},
)
.unwrap();
builder
Expand Down
12 changes: 8 additions & 4 deletions examples/buffer-allocator/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use vulkano::{
BufferContents, BufferUsage,
},
command_buffer::{
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
RenderPassBeginInfo,
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
Expand Down Expand Up @@ -369,10 +369,14 @@ fn main() -> Result<(), impl Error> {
let buffer = buffer_allocator.allocate_slice(data.len() as _).unwrap();
buffer.write().unwrap().copy_from_slice(&data);

let mut builder = RecordingCommandBuffer::primary(
let mut builder = RecordingCommandBuffer::new(
command_buffer_allocator.clone(),
queue.queue_family_index(),
CommandBufferUsage::OneTimeSubmit,
CommandBufferLevel::Primary,
CommandBufferBeginInfo {
usage: CommandBufferUsage::OneTimeSubmit,
..Default::default()
},
)
.unwrap();
builder
Expand Down
13 changes: 9 additions & 4 deletions examples/clear-attachments/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::{error::Error, sync::Arc};
use vulkano::{
command_buffer::{
allocator::StandardCommandBufferAllocator, ClearAttachment, ClearRect, CommandBufferUsage,
RecordingCommandBuffer, RenderPassBeginInfo,
allocator::StandardCommandBufferAllocator, ClearAttachment, ClearRect,
CommandBufferBeginInfo, CommandBufferLevel, CommandBufferUsage, RecordingCommandBuffer,
RenderPassBeginInfo,
},
device::{
physical::PhysicalDeviceType, Device, DeviceCreateInfo, DeviceExtensions, QueueCreateInfo,
Expand Down Expand Up @@ -207,10 +208,14 @@ fn main() -> Result<(), impl Error> {
recreate_swapchain = true;
}

let mut builder = RecordingCommandBuffer::primary(
let mut builder = RecordingCommandBuffer::new(
command_buffer_allocator.clone(),
queue.queue_family_index(),
CommandBufferUsage::OneTimeSubmit,
CommandBufferLevel::Primary,
CommandBufferBeginInfo {
usage: CommandBufferUsage::OneTimeSubmit,
..Default::default()
},
)
.unwrap();
builder
Expand Down
19 changes: 12 additions & 7 deletions examples/deferred/frame/ambient_lighting_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use std::sync::Arc;
use vulkano::{
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
command_buffer::{
allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo,
CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer,
allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo,
CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage,
RecordingCommandBuffer,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
Expand Down Expand Up @@ -162,7 +163,7 @@ impl AmbientLightingSystem {
viewport_dimensions: [u32; 2],
color_input: Arc<ImageView>,
ambient_color: [f32; 3],
) -> Arc<SecondaryAutoCommandBuffer> {
) -> Arc<CommandBuffer> {
let push_constants = fs::PushConstants {
color: [ambient_color[0], ambient_color[1], ambient_color[2], 1.0],
};
Expand All @@ -182,12 +183,16 @@ impl AmbientLightingSystem {
depth_range: 0.0..=1.0,
};

let mut builder = RecordingCommandBuffer::secondary(
let mut builder = RecordingCommandBuffer::new(
self.command_buffer_allocator.clone(),
self.gfx_queue.queue_family_index(),
CommandBufferUsage::MultipleSubmit,
CommandBufferInheritanceInfo {
render_pass: Some(self.subpass.clone().into()),
CommandBufferLevel::Secondary,
CommandBufferBeginInfo {
usage: CommandBufferUsage::MultipleSubmit,
inheritance_info: Some(CommandBufferInheritanceInfo {
render_pass: Some(self.subpass.clone().into()),
..Default::default()
}),
..Default::default()
},
)
Expand Down
19 changes: 12 additions & 7 deletions examples/deferred/frame/directional_lighting_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use std::sync::Arc;
use vulkano::{
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
command_buffer::{
allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo,
CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer,
allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo,
CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage,
RecordingCommandBuffer,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
Expand Down Expand Up @@ -172,7 +173,7 @@ impl DirectionalLightingSystem {
normals_input: Arc<ImageView>,
direction: Vector3<f32>,
color: [f32; 3],
) -> Arc<SecondaryAutoCommandBuffer> {
) -> Arc<CommandBuffer> {
let push_constants = fs::PushConstants {
color: [color[0], color[1], color[2], 1.0],
direction: direction.extend(0.0).into(),
Expand All @@ -196,12 +197,16 @@ impl DirectionalLightingSystem {
depth_range: 0.0..=1.0,
};

let mut builder = RecordingCommandBuffer::secondary(
let mut builder = RecordingCommandBuffer::new(
self.command_buffer_allocator.clone(),
self.gfx_queue.queue_family_index(),
CommandBufferUsage::MultipleSubmit,
CommandBufferInheritanceInfo {
render_pass: Some(self.subpass.clone().into()),
CommandBufferLevel::Secondary,
CommandBufferBeginInfo {
usage: CommandBufferUsage::MultipleSubmit,
inheritance_info: Some(CommandBufferInheritanceInfo {
render_pass: Some(self.subpass.clone().into()),
..Default::default()
}),
..Default::default()
},
)
Expand Down
19 changes: 12 additions & 7 deletions examples/deferred/frame/point_lighting_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use std::sync::Arc;
use vulkano::{
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
command_buffer::{
allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo,
CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer,
allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo,
CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage,
RecordingCommandBuffer,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, DescriptorSet, WriteDescriptorSet,
Expand Down Expand Up @@ -183,7 +184,7 @@ impl PointLightingSystem {
screen_to_world: Matrix4<f32>,
position: Vector3<f32>,
color: [f32; 3],
) -> Arc<SecondaryAutoCommandBuffer> {
) -> Arc<CommandBuffer> {
let push_constants = fs::PushConstants {
screen_to_world: screen_to_world.into(),
color: [color[0], color[1], color[2], 1.0],
Expand All @@ -209,12 +210,16 @@ impl PointLightingSystem {
depth_range: 0.0..=1.0,
};

let mut builder = RecordingCommandBuffer::secondary(
let mut builder = RecordingCommandBuffer::new(
self.command_buffer_allocator.clone(),
self.gfx_queue.queue_family_index(),
CommandBufferUsage::MultipleSubmit,
CommandBufferInheritanceInfo {
render_pass: Some(self.subpass.clone().into()),
CommandBufferLevel::Secondary,
CommandBufferBeginInfo {
usage: CommandBufferUsage::MultipleSubmit,
inheritance_info: Some(CommandBufferInheritanceInfo {
render_pass: Some(self.subpass.clone().into()),
..Default::default()
}),
..Default::default()
},
)
Expand Down
18 changes: 11 additions & 7 deletions examples/deferred/frame/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use cgmath::{Matrix4, SquareMatrix, Vector3};
use std::sync::Arc;
use vulkano::{
command_buffer::{
allocator::StandardCommandBufferAllocator, CommandBufferUsage, PrimaryAutoCommandBuffer,
RecordingCommandBuffer, RenderPassBeginInfo, SecondaryAutoCommandBuffer, SubpassBeginInfo,
SubpassContents,
allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo,
CommandBufferLevel, CommandBufferUsage, RecordingCommandBuffer, RenderPassBeginInfo,
SubpassBeginInfo, SubpassContents,
},
descriptor_set::allocator::StandardDescriptorSetAllocator,
device::Queue,
Expand Down Expand Up @@ -338,10 +338,14 @@ impl FrameSystem {
.unwrap();

// Start the command buffer builder that will be filled throughout the frame handling.
let mut command_buffer_builder = RecordingCommandBuffer::primary(
let mut command_buffer_builder = RecordingCommandBuffer::new(
self.command_buffer_allocator.clone(),
self.gfx_queue.queue_family_index(),
CommandBufferUsage::OneTimeSubmit,
CommandBufferLevel::Primary,
CommandBufferBeginInfo {
usage: CommandBufferUsage::OneTimeSubmit,
..Default::default()
},
)
.unwrap();
command_buffer_builder
Expand Down Expand Up @@ -394,7 +398,7 @@ pub struct Frame<'a> {
// Framebuffer that was used when starting the render pass.
framebuffer: Arc<Framebuffer>,
// The command buffer builder that will be built during the lifetime of this object.
command_buffer_builder: Option<RecordingCommandBuffer<PrimaryAutoCommandBuffer>>,
command_buffer_builder: Option<RecordingCommandBuffer>,
// Matrix that was passed to `frame()`.
world_to_framebuffer: Matrix4<f32>,
}
Expand Down Expand Up @@ -487,7 +491,7 @@ pub struct DrawPass<'f, 's: 'f> {

impl<'f, 's: 'f> DrawPass<'f, 's> {
/// Appends a command that executes a secondary command buffer that performs drawing.
pub fn execute(&mut self, command_buffer: Arc<SecondaryAutoCommandBuffer>) {
pub fn execute(&mut self, command_buffer: Arc<CommandBuffer>) {
self.frame
.command_buffer_builder
.as_mut()
Expand Down
19 changes: 12 additions & 7 deletions examples/deferred/triangle_draw_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use std::sync::Arc;
use vulkano::{
buffer::{Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer},
command_buffer::{
allocator::StandardCommandBufferAllocator, CommandBufferInheritanceInfo,
CommandBufferUsage, RecordingCommandBuffer, SecondaryAutoCommandBuffer,
allocator::StandardCommandBufferAllocator, CommandBuffer, CommandBufferBeginInfo,
CommandBufferInheritanceInfo, CommandBufferLevel, CommandBufferUsage,
RecordingCommandBuffer,
},
device::Queue,
memory::allocator::{AllocationCreateInfo, MemoryTypeFilter, StandardMemoryAllocator},
Expand Down Expand Up @@ -127,13 +128,17 @@ impl TriangleDrawSystem {
}

/// Builds a secondary command buffer that draws the triangle on the current subpass.
pub fn draw(&self, viewport_dimensions: [u32; 2]) -> Arc<SecondaryAutoCommandBuffer> {
let mut builder = RecordingCommandBuffer::secondary(
pub fn draw(&self, viewport_dimensions: [u32; 2]) -> Arc<CommandBuffer> {
let mut builder = RecordingCommandBuffer::new(
self.command_buffer_allocator.clone(),
self.gfx_queue.queue_family_index(),
CommandBufferUsage::MultipleSubmit,
CommandBufferInheritanceInfo {
render_pass: Some(self.subpass.clone().into()),
CommandBufferLevel::Secondary,
CommandBufferBeginInfo {
usage: CommandBufferUsage::MultipleSubmit,
inheritance_info: Some(CommandBufferInheritanceInfo {
render_pass: Some(self.subpass.clone().into()),
..Default::default()
}),
..Default::default()
},
)
Expand Down
11 changes: 8 additions & 3 deletions examples/dynamic-buffers/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use std::{iter::repeat, mem::size_of, sync::Arc};
use vulkano::{
buffer::{Buffer, BufferCreateInfo, BufferUsage},
command_buffer::{
allocator::StandardCommandBufferAllocator, CommandBufferUsage, RecordingCommandBuffer,
allocator::StandardCommandBufferAllocator, CommandBufferBeginInfo, CommandBufferLevel,
CommandBufferUsage, RecordingCommandBuffer,
},
descriptor_set::{
allocator::StandardDescriptorSetAllocator, layout::DescriptorType, DescriptorBufferInfo,
Expand Down Expand Up @@ -236,10 +237,14 @@ fn main() {
.unwrap();

// Build the command buffer, using different offsets for each call.
let mut builder = RecordingCommandBuffer::primary(
let mut builder = RecordingCommandBuffer::new(
command_buffer_allocator,
queue.queue_family_index(),
CommandBufferUsage::OneTimeSubmit,
CommandBufferLevel::Primary,
CommandBufferBeginInfo {
usage: CommandBufferUsage::OneTimeSubmit,
..Default::default()
},
)
.unwrap();

Expand Down
Loading