pub use self::{
auto::{
AutoCommandBufferBuilder, BuildError, CommandBufferBeginError, PrimaryAutoCommandBuffer,
SecondaryAutoCommandBuffer,
},
commands::{
debug::DebugUtilsError,
image::{
BlitImageInfo, ClearColorImageInfo, ClearDepthStencilImageInfo, ImageBlit,
ImageResolve, ResolveImageInfo,
},
pipeline::PipelineExecutionError,
query::QueryError,
render_pass::{
ClearAttachment, ClearRect, RenderPassBeginInfo, RenderPassError,
RenderingAttachmentInfo, RenderingAttachmentResolveInfo, RenderingInfo,
},
secondary::{ExecuteCommandsError, UnsafeCommandBufferBuilderExecuteCommands},
transfer::{
BufferCopy, BufferImageCopy, CopyBufferInfo, CopyBufferInfoTyped,
CopyBufferToImageInfo, CopyImageInfo, CopyImageToBufferInfo, FillBufferInfo, ImageCopy,
},
CopyError, CopyErrorResource,
},
traits::{
CommandBufferExecError, CommandBufferExecFuture, PrimaryCommandBufferAbstract,
SecondaryCommandBufferAbstract,
},
};
use crate::{
buffer::sys::Buffer,
format::Format,
image::{sys::Image, ImageLayout, SampleCount},
macros::vulkan_enum,
query::{QueryControlFlags, QueryPipelineStatisticFlags},
range_map::RangeMap,
render_pass::{Framebuffer, Subpass},
sync::{AccessFlags, PipelineStages, Semaphore},
DeviceSize,
};
use bytemuck::{Pod, Zeroable};
use std::{borrow::Cow, sync::Arc};
pub mod allocator;
mod auto;
mod commands;
pub mod pool;
pub mod synced;
pub mod sys;
mod traits;
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, Zeroable, Pod, PartialEq, Eq)]
pub struct DrawIndirectCommand {
pub vertex_count: u32,
pub instance_count: u32,
pub first_vertex: u32,
pub first_instance: u32,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, Zeroable, Pod, PartialEq, Eq)]
pub struct DrawIndexedIndirectCommand {
pub index_count: u32,
pub instance_count: u32,
pub first_index: u32,
pub vertex_offset: u32,
pub first_instance: u32,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, Zeroable, Pod, PartialEq, Eq)]
pub struct DispatchIndirectCommand {
pub x: u32,
pub y: u32,
pub z: u32,
}
vulkan_enum! {
#[non_exhaustive]
SubpassContents = SubpassContents(i32);
Inline = INLINE,
SecondaryCommandBuffers = SECONDARY_COMMAND_BUFFERS,
}
impl From<SubpassContents> for ash::vk::RenderingFlags {
#[inline]
fn from(val: SubpassContents) -> Self {
match val {
SubpassContents::Inline => Self::empty(),
SubpassContents::SecondaryCommandBuffers => Self::CONTENTS_SECONDARY_COMMAND_BUFFERS,
}
}
}
vulkan_enum! {
CommandBufferLevel = CommandBufferLevel(i32);
Primary = PRIMARY,
Secondary = SECONDARY,
}
#[derive(Clone, Debug)]
pub struct CommandBufferInheritanceInfo {
pub render_pass: Option<CommandBufferInheritanceRenderPassType>,
pub occlusion_query: Option<QueryControlFlags>,
pub query_statistics_flags: QueryPipelineStatisticFlags,
pub _ne: crate::NonExhaustive,
}
impl Default for CommandBufferInheritanceInfo {
#[inline]
fn default() -> Self {
Self {
render_pass: None,
occlusion_query: None,
query_statistics_flags: QueryPipelineStatisticFlags::empty(),
_ne: crate::NonExhaustive(()),
}
}
}
#[derive(Clone, Debug)]
pub enum CommandBufferInheritanceRenderPassType {
BeginRenderPass(CommandBufferInheritanceRenderPassInfo),
BeginRendering(CommandBufferInheritanceRenderingInfo),
}
impl From<Subpass> for CommandBufferInheritanceRenderPassType {
#[inline]
fn from(val: Subpass) -> Self {
Self::BeginRenderPass(val.into())
}
}
impl From<CommandBufferInheritanceRenderPassInfo> for CommandBufferInheritanceRenderPassType {
#[inline]
fn from(val: CommandBufferInheritanceRenderPassInfo) -> Self {
Self::BeginRenderPass(val)
}
}
impl From<CommandBufferInheritanceRenderingInfo> for CommandBufferInheritanceRenderPassType {
#[inline]
fn from(val: CommandBufferInheritanceRenderingInfo) -> Self {
Self::BeginRendering(val)
}
}
#[derive(Clone, Debug)]
pub struct CommandBufferInheritanceRenderPassInfo {
pub subpass: Subpass,
pub framebuffer: Option<Arc<Framebuffer>>,
}
impl CommandBufferInheritanceRenderPassInfo {
#[inline]
pub fn subpass(subpass: Subpass) -> Self {
Self {
subpass,
framebuffer: None,
}
}
}
impl From<Subpass> for CommandBufferInheritanceRenderPassInfo {
#[inline]
fn from(subpass: Subpass) -> Self {
Self {
subpass,
framebuffer: None,
}
}
}
#[derive(Clone, Debug)]
pub struct CommandBufferInheritanceRenderingInfo {
pub view_mask: u32,
pub color_attachment_formats: Vec<Option<Format>>,
pub depth_attachment_format: Option<Format>,
pub stencil_attachment_format: Option<Format>,
pub rasterization_samples: SampleCount,
}
impl Default for CommandBufferInheritanceRenderingInfo {
#[inline]
fn default() -> Self {
Self {
view_mask: 0,
color_attachment_formats: Vec::new(),
depth_attachment_format: None,
stencil_attachment_format: None,
rasterization_samples: SampleCount::Sample1,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[repr(u32)]
pub enum CommandBufferUsage {
OneTimeSubmit = ash::vk::CommandBufferUsageFlags::ONE_TIME_SUBMIT.as_raw(),
MultipleSubmit = 0,
SimultaneousUse = ash::vk::CommandBufferUsageFlags::SIMULTANEOUS_USE.as_raw(),
}
impl From<CommandBufferUsage> for ash::vk::CommandBufferUsageFlags {
#[inline]
fn from(val: CommandBufferUsage) -> Self {
Self::from_raw(val as u32)
}
}
#[derive(Clone, Debug)]
pub struct SubmitInfo {
pub wait_semaphores: Vec<SemaphoreSubmitInfo>,
pub command_buffers: Vec<Arc<dyn PrimaryCommandBufferAbstract>>,
pub signal_semaphores: Vec<SemaphoreSubmitInfo>,
pub _ne: crate::NonExhaustive,
}
impl Default for SubmitInfo {
#[inline]
fn default() -> Self {
Self {
wait_semaphores: Vec::new(),
command_buffers: Vec::new(),
signal_semaphores: Vec::new(),
_ne: crate::NonExhaustive(()),
}
}
}
#[derive(Clone, Debug)]
pub struct SemaphoreSubmitInfo {
pub semaphore: Arc<Semaphore>,
pub stages: PipelineStages,
pub _ne: crate::NonExhaustive,
}
impl SemaphoreSubmitInfo {
#[inline]
pub fn semaphore(semaphore: Arc<Semaphore>) -> Self {
Self {
semaphore,
stages: PipelineStages {
all_commands: true,
..PipelineStages::empty()
},
_ne: crate::NonExhaustive(()),
}
}
}
#[derive(Debug, Default)]
pub struct CommandBufferState {
has_been_submitted: bool,
pending_submits: u32,
}
impl CommandBufferState {
pub(crate) fn has_been_submitted(&self) -> bool {
self.has_been_submitted
}
pub(crate) fn is_submit_pending(&self) -> bool {
self.pending_submits != 0
}
pub(crate) unsafe fn add_queue_submit(&mut self) {
self.has_been_submitted = true;
self.pending_submits += 1;
}
pub(crate) unsafe fn set_submit_finished(&mut self) {
self.pending_submits -= 1;
}
}
#[derive(Debug)]
pub struct CommandBufferResourcesUsage {
pub(crate) buffers: Vec<CommandBufferBufferUsage>,
pub(crate) images: Vec<CommandBufferImageUsage>,
}
#[derive(Debug)]
pub(crate) struct CommandBufferBufferUsage {
pub(crate) buffer: Arc<Buffer>,
pub(crate) ranges: RangeMap<DeviceSize, CommandBufferBufferRangeUsage>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct CommandBufferBufferRangeUsage {
pub(crate) first_use: FirstResourceUse,
pub(crate) mutable: bool,
pub(crate) final_stages: PipelineStages,
pub(crate) final_access: AccessFlags,
}
#[derive(Debug)]
pub(crate) struct CommandBufferImageUsage {
pub(crate) image: Arc<Image>,
pub(crate) ranges: RangeMap<DeviceSize, CommandBufferImageRangeUsage>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct CommandBufferImageRangeUsage {
pub(crate) first_use: FirstResourceUse,
pub(crate) mutable: bool,
pub(crate) final_stages: PipelineStages,
pub(crate) final_access: AccessFlags,
pub(crate) expected_layout: ImageLayout,
pub(crate) final_layout: ImageLayout,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct FirstResourceUse {
pub(crate) command_index: usize,
pub(crate) command_name: &'static str,
pub(crate) description: Cow<'static, str>,
}