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