Changes regarding naming and API consistency (#1946)

* Remove unneccessary `Arc`-clone

* Rename `Std*` types to `Standard*`

* New signature for `Device::standard_pool`

* Import granularity consistency
This commit is contained in:
marcot1cs 2022-08-07 19:25:28 +02:00 committed by GitHub
parent 72dcbc1a28
commit c4a960d67b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 609 additions and 640 deletions

2
.rustfmt.toml Normal file
View File

@ -0,0 +1,2 @@
# imports_granularity = "Crate"
# group_imports = "One"

View File

@ -25,7 +25,7 @@ use crate::{
memory::{ memory::{
pool::{ pool::{
AllocFromRequirementsFilter, AllocLayout, MappingRequirement, MemoryPoolAlloc, AllocFromRequirementsFilter, AllocLayout, MappingRequirement, MemoryPoolAlloc,
PotentialDedicatedAllocation, StdMemoryPoolAlloc, PotentialDedicatedAllocation, StandardMemoryPoolAlloc,
}, },
DedicatedAllocation, DeviceMemoryAllocationError, MemoryPool, DedicatedAllocation, DeviceMemoryAllocationError, MemoryPool,
}, },
@ -50,7 +50,7 @@ use std::{
/// memory caches GPU data on the CPU side. This can be more performant in cases where /// memory caches GPU data on the CPU side. This can be more performant in cases where
/// the cpu needs to read data coming off the GPU. /// the cpu needs to read data coming off the GPU.
#[derive(Debug)] #[derive(Debug)]
pub struct CpuAccessibleBuffer<T, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> pub struct CpuAccessibleBuffer<T, A = PotentialDedicatedAllocation<StandardMemoryPoolAlloc>>
where where
T: BufferContents + ?Sized, T: BufferContents + ?Sized,
{ {
@ -252,7 +252,7 @@ where
let mem_reqs = buffer.memory_requirements(); let mem_reqs = buffer.memory_requirements();
let memory = MemoryPool::alloc_from_requirements( let memory = MemoryPool::alloc_from_requirements(
&Device::standard_pool(&device), &device.standard_memory_pool(),
&mem_reqs, &mem_reqs,
AllocLayout::Linear, AllocLayout::Linear,
MappingRequirement::Map, MappingRequirement::Map,

View File

@ -17,7 +17,7 @@ use crate::{
memory::{ memory::{
pool::{ pool::{
AllocFromRequirementsFilter, AllocLayout, MappingRequirement, MemoryPoolAlloc, AllocFromRequirementsFilter, AllocLayout, MappingRequirement, MemoryPoolAlloc,
PotentialDedicatedAllocation, StdMemoryPool, PotentialDedicatedAllocation, StandardMemoryPool,
}, },
DedicatedAllocation, DeviceMemoryAllocationError, MemoryPool, DedicatedAllocation, DeviceMemoryAllocationError, MemoryPool,
}, },
@ -91,7 +91,7 @@ use std::{
/// } /// }
/// ``` /// ```
/// ///
pub struct CpuBufferPool<T, A = Arc<StdMemoryPool>> pub struct CpuBufferPool<T, A = Arc<StandardMemoryPool>>
where where
[T]: BufferContents, [T]: BufferContents,
A: MemoryPool, A: MemoryPool,
@ -196,11 +196,11 @@ where
#[inline] #[inline]
pub fn new(device: Arc<Device>, usage: BufferUsage) -> CpuBufferPool<T> { pub fn new(device: Arc<Device>, usage: BufferUsage) -> CpuBufferPool<T> {
assert!(size_of::<T>() > 0); assert!(size_of::<T>() > 0);
let pool = Device::standard_pool(&device); let pool = device.standard_memory_pool();
CpuBufferPool { CpuBufferPool {
device: device, device,
pool: pool, pool,
current_buffer: Mutex::new(None), current_buffer: Mutex::new(None),
usage: usage.clone(), usage: usage.clone(),
marker: PhantomData, marker: PhantomData,

View File

@ -28,7 +28,8 @@ use crate::{
memory::{ memory::{
pool::{ pool::{
alloc_dedicated_with_exportable_fd, AllocFromRequirementsFilter, AllocLayout, alloc_dedicated_with_exportable_fd, AllocFromRequirementsFilter, AllocLayout,
MappingRequirement, MemoryPoolAlloc, PotentialDedicatedAllocation, StdMemoryPoolAlloc, MappingRequirement, MemoryPoolAlloc, PotentialDedicatedAllocation,
StandardMemoryPoolAlloc,
}, },
DedicatedAllocation, DeviceMemoryAllocationError, DeviceMemoryExportError, DedicatedAllocation, DeviceMemoryAllocationError, DeviceMemoryExportError,
ExternalMemoryHandleType, MemoryPool, MemoryRequirements, ExternalMemoryHandleType, MemoryPool, MemoryRequirements,
@ -122,7 +123,7 @@ use std::{
/// ``` /// ```
/// ///
#[derive(Debug)] #[derive(Debug)]
pub struct DeviceLocalBuffer<T, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> pub struct DeviceLocalBuffer<T, A = PotentialDedicatedAllocation<StandardMemoryPoolAlloc>>
where where
T: BufferContents + ?Sized, T: BufferContents + ?Sized,
{ {
@ -358,7 +359,7 @@ where
let (buffer, mem_reqs) = Self::build_buffer(&device, size, usage, &queue_families)?; let (buffer, mem_reqs) = Self::build_buffer(&device, size, usage, &queue_families)?;
let memory = MemoryPool::alloc_from_requirements( let memory = MemoryPool::alloc_from_requirements(
&Device::standard_pool(&device), &device.standard_memory_pool(),
&mem_reqs, &mem_reqs,
AllocLayout::Linear, AllocLayout::Linear,
MappingRequirement::DoNotMap, MappingRequirement::DoNotMap,

View File

@ -28,11 +28,11 @@ use super::{
cpu_access::{ReadLockError, WriteLockError}, cpu_access::{ReadLockError, WriteLockError},
BufferUsage, BufferUsage,
}; };
use crate::range_map::RangeMap;
use crate::{ use crate::{
check_errors, check_errors,
device::{Device, DeviceOwned}, device::{Device, DeviceOwned},
memory::{DeviceMemory, DeviceMemoryAllocationError, MemoryRequirements}, memory::{DeviceMemory, DeviceMemoryAllocationError, MemoryRequirements},
range_map::RangeMap,
sync::{AccessError, CurrentAccess, Sharing}, sync::{AccessError, CurrentAccess, Sharing},
DeviceSize, Error, OomError, Version, VulkanObject, DeviceSize, Error, OomError, Version, VulkanObject,
}; };
@ -782,13 +782,10 @@ struct BufferRangeState {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::BufferCreationError; use super::{
use super::BufferUsage; BufferCreationError, BufferUsage, SparseLevel, UnsafeBuffer, UnsafeBufferCreateInfo,
use super::SparseLevel; };
use super::UnsafeBuffer; use crate::device::{Device, DeviceOwned};
use super::UnsafeBufferCreateInfo;
use crate::device::Device;
use crate::device::DeviceOwned;
#[test] #[test]
fn create() { fn create() {

View File

@ -462,9 +462,13 @@ impl Hash for dyn BufferViewAbstract {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::buffer::view::{BufferView, BufferViewCreateInfo, BufferViewCreationError}; use crate::{
use crate::buffer::{BufferUsage, DeviceLocalBuffer}; buffer::{
use crate::format::Format; view::{BufferView, BufferViewCreateInfo, BufferViewCreationError},
BufferUsage, DeviceLocalBuffer,
},
format::Format,
};
#[test] #[test]
fn create_uniform() { fn create_uniform() {

View File

@ -233,10 +233,12 @@ impl<L> AutoCommandBufferBuilder<L, StandardCommandPoolBuilder> {
} }
} }
let pool_builder_alloc = Device::standard_command_pool(&device, queue_family)? device.with_standard_command_pool(queue_family, |pool| {
let pool_builder_alloc = pool
.allocate(level, 1)? .allocate(level, 1)?
.next() .next()
.expect("Requested one command buffer from the command pool, but got zero."); .expect("Requested one command buffer from the command pool, but got zero.");
let inner = SyncCommandBufferBuilder::new(pool_builder_alloc.inner(), begin_info)?; let inner = SyncCommandBufferBuilder::new(pool_builder_alloc.inner(), begin_info)?;
Ok(AutoCommandBufferBuilder { Ok(AutoCommandBufferBuilder {
@ -249,6 +251,7 @@ impl<L> AutoCommandBufferBuilder<L, StandardCommandPoolBuilder> {
usage, usage,
_data: PhantomData, _data: PhantomData,
}) })
})?
} }
fn validate_begin( fn validate_begin(

View File

@ -89,11 +89,18 @@
//! alternative command pool implementations and use them. See the `pool` module for more //! alternative command pool implementations and use them. See the `pool` module for more
//! information. //! information.
pub use self::commands::{ pub use self::{
auto::{
AutoCommandBufferBuilder, AutoCommandBufferBuilderContextError, BuildError,
CommandBufferBeginError, DispatchError, DispatchIndirectError, DrawError, DrawIndexedError,
DrawIndexedIndirectError, DrawIndirectError, PrimaryAutoCommandBuffer,
SecondaryAutoCommandBuffer,
},
commands::{
debug::DebugUtilsError, debug::DebugUtilsError,
image::{ image::{
BlitImageInfo, ClearColorImageInfo, ClearDepthStencilImageInfo, ImageBlit, ImageResolve, BlitImageInfo, ClearColorImageInfo, ClearDepthStencilImageInfo, ImageBlit,
ResolveImageInfo, ImageResolve, ResolveImageInfo,
}, },
pipeline::{ pipeline::{
CheckDescriptorSetsValidityError, CheckDispatchError, CheckDynamicStateValidityError, CheckDescriptorSetsValidityError, CheckDispatchError, CheckDynamicStateValidityError,
@ -102,22 +109,15 @@ pub use self::commands::{
}, },
query::QueryError, query::QueryError,
render_pass::{ render_pass::{
ClearAttachment, ClearRect, RenderPassBeginInfo, RenderPassError, RenderingAttachmentInfo, ClearAttachment, ClearRect, RenderPassBeginInfo, RenderPassError,
RenderingAttachmentResolveInfo, RenderingInfo, RenderingAttachmentInfo, RenderingAttachmentResolveInfo, RenderingInfo,
}, },
secondary::{ExecuteCommandsError, UnsafeCommandBufferBuilderExecuteCommands}, secondary::{ExecuteCommandsError, UnsafeCommandBufferBuilderExecuteCommands},
transfer::{ transfer::{
BufferCopy, BufferImageCopy, CopyBufferInfo, CopyBufferInfoTyped, CopyBufferToImageInfo, BufferCopy, BufferImageCopy, CopyBufferInfo, CopyBufferInfoTyped,
CopyImageInfo, CopyImageToBufferInfo, FillBufferInfo, ImageCopy, CopyBufferToImageInfo, CopyImageInfo, CopyImageToBufferInfo, FillBufferInfo, ImageCopy,
}, },
CopyError, CopyErrorResource, CopyError, CopyErrorResource,
};
pub use self::{
auto::{
AutoCommandBufferBuilder, AutoCommandBufferBuilderContextError, BuildError,
CommandBufferBeginError, DispatchError, DispatchIndirectError, DrawError, DrawIndexedError,
DrawIndexedIndirectError, DrawIndirectError, PrimaryAutoCommandBuffer,
SecondaryAutoCommandBuffer,
}, },
traits::{ traits::{
CommandBufferExecError, CommandBufferExecFuture, PrimaryCommandBuffer, CommandBufferExecError, CommandBufferExecFuture, PrimaryCommandBuffer,

View File

@ -228,20 +228,21 @@ impl Drop for StandardCommandPoolAlloc {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::sync::Arc; use crate::{
use std::thread; command_buffer::{
pool::{CommandPool, CommandPoolBuilderAlloc},
use crate::command_buffer::pool::{CommandPool, CommandPoolBuilderAlloc}; CommandBufferLevel,
use crate::command_buffer::CommandBufferLevel; },
use crate::device::Device; VulkanObject,
use crate::VulkanObject; };
use std::{sync::Arc, thread};
#[test] #[test]
fn reuse_command_buffers() { fn reuse_command_buffers() {
let (device, queue) = gfx_dev_and_queue!(); let (device, queue) = gfx_dev_and_queue!();
let pool = Device::standard_command_pool(&device, queue.family()).unwrap(); device
.with_standard_command_pool(queue.family(), |pool| {
let cb = pool let cb = pool
.allocate(CommandBufferLevel::Primary, 1) .allocate(CommandBufferLevel::Primary, 1)
.unwrap() .unwrap()
@ -256,6 +257,8 @@ mod tests {
.next() .next()
.unwrap(); .unwrap();
assert_eq!(raw, cb2.inner().internal_object()); assert_eq!(raw, cb2.inner().internal_object());
})
.unwrap();
} }
#[test] #[test]
@ -265,13 +268,15 @@ mod tests {
let thread = thread::spawn({ let thread = thread::spawn({
let (device, queue) = (device.clone(), queue.clone()); let (device, queue) = (device.clone(), queue.clone());
move || { move || {
let pool = Device::standard_command_pool(&device, queue.family()).unwrap(); device
.with_standard_command_pool(queue.family(), |pool| {
pool.allocate(CommandBufferLevel::Primary, 1) pool.allocate(CommandBufferLevel::Primary, 1)
.unwrap() .unwrap()
.next() .next()
.unwrap() .unwrap()
.inner .inner
})
.unwrap()
} }
}); });

View File

@ -7,22 +7,17 @@
// notice may not be copied, modified, or distributed except // notice may not be copied, modified, or distributed except
// according to those terms. // according to those terms.
use crate::buffer::sys::UnsafeBuffer; use crate::{
use crate::check_errors; buffer::sys::UnsafeBuffer,
use crate::device::Queue; check_errors,
use crate::image::sys::UnsafeImage; device::Queue,
use crate::memory::DeviceMemory; image::sys::UnsafeImage,
use crate::sync::Fence; memory::DeviceMemory,
use crate::sync::Semaphore; sync::{Fence, Semaphore},
use crate::DeviceSize; DeviceSize, Error, OomError, SynchronizedVulkanObject, VulkanObject,
use crate::Error; };
use crate::OomError;
use crate::SynchronizedVulkanObject;
use crate::VulkanObject;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::error; use std::{error, fmt, marker::PhantomData};
use std::fmt;
use std::marker::PhantomData;
// TODO: correctly implement Debug on all the structs of this module // TODO: correctly implement Debug on all the structs of this module

View File

@ -13,17 +13,16 @@
//! module. These structs are low-level and unsafe, and are mostly used to implement other parts //! module. These structs are low-level and unsafe, and are mostly used to implement other parts
//! of vulkano, so you are encouraged to not use them directly. //! of vulkano, so you are encouraged to not use them directly.
pub use self::bind_sparse::SubmitBindSparseBatchBuilder; pub use self::{
pub use self::bind_sparse::SubmitBindSparseBufferBindBuilder; bind_sparse::{
pub use self::bind_sparse::SubmitBindSparseBuilder; SubmitBindSparseBatchBuilder, SubmitBindSparseBufferBindBuilder, SubmitBindSparseBuilder,
pub use self::bind_sparse::SubmitBindSparseError; SubmitBindSparseError, SubmitBindSparseImageBindBuilder,
pub use self::bind_sparse::SubmitBindSparseImageBindBuilder; SubmitBindSparseImageOpaqueBindBuilder,
pub use self::bind_sparse::SubmitBindSparseImageOpaqueBindBuilder; },
pub use self::queue_present::SubmitPresentBuilder; queue_present::{SubmitPresentBuilder, SubmitPresentError},
pub use self::queue_present::SubmitPresentError; queue_submit::{SubmitCommandBufferBuilder, SubmitCommandBufferError},
pub use self::queue_submit::SubmitCommandBufferBuilder; semaphores_wait::SubmitSemaphoresWaitBuilder,
pub use self::queue_submit::SubmitCommandBufferError; };
pub use self::semaphores_wait::SubmitSemaphoresWaitBuilder;
mod bind_sparse; mod bind_sparse;
mod queue_present; mod queue_present;

View File

@ -7,23 +7,15 @@
// notice may not be copied, modified, or distributed except // notice may not be copied, modified, or distributed except
// according to those terms. // according to those terms.
use crate::{
check_errors,
device::{DeviceOwned, Queue},
swapchain::{PresentRegion, Swapchain},
sync::Semaphore,
Error, OomError, SynchronizedVulkanObject, VulkanObject,
};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::error; use std::{error, fmt, marker::PhantomData, ptr};
use std::fmt;
use std::marker::PhantomData;
use std::ptr;
use crate::device::DeviceOwned;
use crate::device::Queue;
use crate::swapchain::PresentRegion;
use crate::swapchain::Swapchain;
use crate::sync::Semaphore;
use crate::check_errors;
use crate::Error;
use crate::OomError;
use crate::SynchronizedVulkanObject;
use crate::VulkanObject;
/// Prototype for a submission that presents a swapchain on the screen. /// Prototype for a submission that presents a swapchain on the screen.
// TODO: example here // TODO: example here

View File

@ -7,20 +7,15 @@
// notice may not be copied, modified, or distributed except // notice may not be copied, modified, or distributed except
// according to those terms. // according to those terms.
use crate::check_errors; use crate::{
use crate::command_buffer::sys::UnsafeCommandBuffer; check_errors,
use crate::device::Queue; command_buffer::sys::UnsafeCommandBuffer,
use crate::sync::Fence; device::Queue,
use crate::sync::PipelineStages; sync::{Fence, PipelineStages, Semaphore},
use crate::sync::Semaphore; Error, OomError, SynchronizedVulkanObject, VulkanObject,
use crate::Error; };
use crate::OomError;
use crate::SynchronizedVulkanObject;
use crate::VulkanObject;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::error; use std::{error, fmt, marker::PhantomData};
use std::fmt;
use std::marker::PhantomData;
/// Prototype for a submission that executes command buffers. /// Prototype for a submission that executes command buffers.
// TODO: example here // TODO: example here

View File

@ -7,13 +7,12 @@
// notice may not be copied, modified, or distributed except // notice may not be copied, modified, or distributed except
// according to those terms. // according to those terms.
use crate::{
command_buffer::submit::{SubmitCommandBufferBuilder, SubmitPresentBuilder},
sync::{PipelineStages, Semaphore},
};
use smallvec::SmallVec; use smallvec::SmallVec;
use crate::command_buffer::submit::SubmitCommandBufferBuilder;
use crate::command_buffer::submit::SubmitPresentBuilder;
use crate::sync::PipelineStages;
use crate::sync::Semaphore;
/// Prototype for a submission that waits on semaphores. /// Prototype for a submission that waits on semaphores.
/// ///
/// This prototype can't actually be submitted because it doesn't correspond to anything in Vulkan. /// This prototype can't actually be submitted because it doesn't correspond to anything in Vulkan.

View File

@ -14,7 +14,6 @@ pub use crate::command_buffer::commands::{
}, },
secondary::SyncCommandBufferBuilderExecuteCommands, secondary::SyncCommandBufferBuilderExecuteCommands,
}; };
use crate::range_map::RangeMap;
use crate::{ use crate::{
buffer::{sys::UnsafeBuffer, BufferAccess}, buffer::{sys::UnsafeBuffer, BufferAccess},
command_buffer::{ command_buffer::{
@ -36,6 +35,7 @@ use crate::{
}, },
ComputePipeline, DynamicState, GraphicsPipeline, PipelineBindPoint, PipelineLayout, ComputePipeline, DynamicState, GraphicsPipeline, PipelineBindPoint, PipelineLayout,
}, },
range_map::RangeMap,
range_set::RangeSet, range_set::RangeSet,
sync::{ sync::{
AccessFlags, BufferMemoryBarrier, DependencyInfo, ImageMemoryBarrier, PipelineMemoryAccess, AccessFlags, BufferMemoryBarrier, DependencyInfo, ImageMemoryBarrier, PipelineMemoryAccess,

View File

@ -74,11 +74,11 @@ use super::{
sys::{UnsafeCommandBuffer, UnsafeCommandBufferBuilder}, sys::{UnsafeCommandBuffer, UnsafeCommandBufferBuilder},
CommandBufferExecError, CommandBufferExecError,
}; };
use crate::range_map::RangeMap;
use crate::{ use crate::{
buffer::{sys::UnsafeBuffer, BufferAccess}, buffer::{sys::UnsafeBuffer, BufferAccess},
device::{Device, DeviceOwned, Queue}, device::{Device, DeviceOwned, Queue},
image::{sys::UnsafeImage, ImageAccess, ImageLayout, ImageSubresourceRange}, image::{sys::UnsafeImage, ImageAccess, ImageLayout, ImageSubresourceRange},
range_map::RangeMap,
sync::{ sync::{
AccessCheckError, AccessError, AccessFlags, GpuFuture, PipelineMemoryAccess, PipelineStages, AccessCheckError, AccessError, AccessFlags, GpuFuture, PipelineMemoryAccess, PipelineStages,
}, },
@ -546,11 +546,13 @@ mod tests {
unsafe { unsafe {
let (device, queue) = gfx_dev_and_queue!(); let (device, queue) = gfx_dev_and_queue!();
let pool = Device::standard_command_pool(&device, queue.family()).unwrap(); let pool_builder_alloc = device
let pool_builder_alloc = pool .with_standard_command_pool(queue.family(), |pool| {
.allocate(CommandBufferLevel::Primary, 1) pool.allocate(CommandBufferLevel::Primary, 1)
.unwrap() .unwrap()
.next() .next()
.unwrap()
})
.unwrap(); .unwrap();
SyncCommandBufferBuilder::new( SyncCommandBufferBuilder::new(
@ -599,11 +601,13 @@ mod tests {
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let pool = Device::standard_command_pool(&device, queue.family()).unwrap(); let allocs = device
let allocs = pool .with_standard_command_pool(queue.family(), |pool| {
.allocate(CommandBufferLevel::Primary, 2) pool.allocate(CommandBufferLevel::Primary, 2)
.unwrap() .unwrap()
.collect::<Vec<_>>(); .collect::<Vec<_>>()
})
.unwrap();
{ {
let mut builder = SyncCommandBufferBuilder::new( let mut builder = SyncCommandBufferBuilder::new(
@ -659,11 +663,13 @@ mod tests {
unsafe { unsafe {
let (device, queue) = gfx_dev_and_queue!(); let (device, queue) = gfx_dev_and_queue!();
let pool = Device::standard_command_pool(&device, queue.family()).unwrap(); let pool_builder_alloc = device
let pool_builder_alloc = pool .with_standard_command_pool(queue.family(), |pool| {
.allocate(CommandBufferLevel::Primary, 1) pool.allocate(CommandBufferLevel::Primary, 1)
.unwrap() .unwrap()
.next() .next()
.unwrap()
})
.unwrap(); .unwrap();
let mut sync = SyncCommandBufferBuilder::new( let mut sync = SyncCommandBufferBuilder::new(
&pool_builder_alloc.inner(), &pool_builder_alloc.inner(),
@ -690,11 +696,13 @@ mod tests {
unsafe { unsafe {
let (device, queue) = gfx_dev_and_queue!(); let (device, queue) = gfx_dev_and_queue!();
let pool = Device::standard_command_pool(&device, queue.family()).unwrap(); let pool_builder_alloc = device
let pool_builder_alloc = pool .with_standard_command_pool(queue.family(), |pool| {
.allocate(CommandBufferLevel::Primary, 1) pool.allocate(CommandBufferLevel::Primary, 1)
.unwrap() .unwrap()
.next() .next()
.unwrap()
})
.unwrap(); .unwrap();
let mut sync = SyncCommandBufferBuilder::new( let mut sync = SyncCommandBufferBuilder::new(
&pool_builder_alloc.inner(), &pool_builder_alloc.inner(),

View File

@ -848,11 +848,13 @@ impl From<DescriptorType> for ash::vk::DescriptorType {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::descriptor_set::layout::DescriptorSetLayout; use crate::{
use crate::descriptor_set::layout::DescriptorSetLayoutBinding; descriptor_set::layout::{
use crate::descriptor_set::layout::DescriptorSetLayoutCreateInfo; DescriptorSetLayout, DescriptorSetLayoutBinding, DescriptorSetLayoutCreateInfo,
use crate::descriptor_set::layout::DescriptorType; DescriptorType,
use crate::shader::ShaderStages; },
shader::ShaderStages,
};
use std::collections::HashMap; use std::collections::HashMap;
#[test] #[test]

View File

@ -65,7 +65,7 @@
//! - The `DescriptorPool` trait can be implemented on types from which you can allocate and free //! - The `DescriptorPool` trait can be implemented on types from which you can allocate and free
//! descriptor sets. However it is different from Vulkan descriptor pools in the sense that an //! descriptor sets. However it is different from Vulkan descriptor pools in the sense that an
//! implementation of the `DescriptorPool` trait can manage multiple Vulkan descriptor pools. //! implementation of the `DescriptorPool` trait can manage multiple Vulkan descriptor pools.
//! - The `StdDescriptorPool` type is a default implementation of the `DescriptorPool` trait. //! - The `StandardDescriptorPool` type is a default implementation of the `DescriptorPool` trait.
//! - The `DescriptorSet` trait is implemented on types that wrap around Vulkan descriptor sets in //! - The `DescriptorSet` trait is implemented on types that wrap around Vulkan descriptor sets in
//! a safe way. A Vulkan descriptor set is inherently unsafe, so we need safe wrappers around //! a safe way. A Vulkan descriptor set is inherently unsafe, so we need safe wrappers around
//! them. //! them.
@ -73,27 +73,29 @@
//! - The `DescriptorSetsCollection` trait is implemented on collections of types that implement //! - The `DescriptorSetsCollection` trait is implemented on collections of types that implement
//! `DescriptorSet`. It is what you pass to the draw functions. //! `DescriptorSet`. It is what you pass to the draw functions.
pub use self::collection::DescriptorSetsCollection;
use self::layout::DescriptorSetLayout;
pub use self::persistent::PersistentDescriptorSet;
pub use self::single_layout_pool::SingleLayoutDescSetPool;
use self::sys::UnsafeDescriptorSet;
pub(crate) use self::update::{check_descriptor_write, DescriptorWriteInfo}; pub(crate) use self::update::{check_descriptor_write, DescriptorWriteInfo};
pub use self::update::{DescriptorSetUpdateError, WriteDescriptorSet, WriteDescriptorSetElements}; pub use self::{
use crate::buffer::view::BufferViewAbstract; collection::DescriptorSetsCollection,
use crate::buffer::BufferAccess; persistent::PersistentDescriptorSet,
use crate::descriptor_set::layout::DescriptorType; single_layout_pool::SingleLayoutDescSetPool,
use crate::device::DeviceOwned; update::{DescriptorSetUpdateError, WriteDescriptorSet, WriteDescriptorSetElements},
use crate::image::view::ImageViewAbstract; };
use crate::sampler::Sampler; use self::{layout::DescriptorSetLayout, sys::UnsafeDescriptorSet};
use crate::OomError; use crate::{
use crate::VulkanObject; buffer::{view::BufferViewAbstract, BufferAccess},
descriptor_set::layout::DescriptorType,
device::DeviceOwned,
image::view::ImageViewAbstract,
sampler::Sampler,
OomError, VulkanObject,
};
use smallvec::{smallvec, SmallVec}; use smallvec::{smallvec, SmallVec};
use std::collections::HashMap; use std::{
use std::hash::Hash; collections::HashMap,
use std::hash::Hasher; hash::{Hash, Hasher},
use std::ptr; ptr,
use std::sync::Arc; sync::Arc,
};
mod collection; mod collection;
pub mod layout; pub mod layout;

View File

@ -21,20 +21,23 @@
//! # Example //! # Example
//! TODO: //! TODO:
use crate::descriptor_set::pool::standard::StdDescriptorPoolAlloc; use crate::{
use crate::descriptor_set::pool::{DescriptorPool, DescriptorPoolAlloc}; descriptor_set::{
use crate::descriptor_set::update::WriteDescriptorSet; pool::{standard::StandardDescriptorPoolAlloc, DescriptorPool, DescriptorPoolAlloc},
use crate::descriptor_set::{ update::WriteDescriptorSet,
DescriptorSet, DescriptorSetCreationError, DescriptorSetInner, DescriptorSetLayout, DescriptorSet, DescriptorSetCreationError, DescriptorSetInner, DescriptorSetLayout,
DescriptorSetResources, UnsafeDescriptorSet, DescriptorSetResources, UnsafeDescriptorSet,
},
device::{Device, DeviceOwned},
VulkanObject,
};
use std::{
hash::{Hash, Hasher},
sync::Arc,
}; };
use crate::device::{Device, DeviceOwned};
use crate::VulkanObject;
use std::hash::{Hash, Hasher};
use std::sync::Arc;
/// A simple, immutable descriptor set that is expected to be long-lived. /// A simple, immutable descriptor set that is expected to be long-lived.
pub struct PersistentDescriptorSet<P = StdDescriptorPoolAlloc> { pub struct PersistentDescriptorSet<P = StandardDescriptorPoolAlloc> {
alloc: P, alloc: P,
inner: DescriptorSetInner, inner: DescriptorSetInner,
} }

View File

@ -10,7 +10,7 @@
//! A pool from which descriptor sets can be allocated. //! A pool from which descriptor sets can be allocated.
pub use self::{ pub use self::{
standard::StdDescriptorPool, standard::StandardDescriptorPool,
sys::{ sys::{
DescriptorPoolAllocError, DescriptorSetAllocateInfo, UnsafeDescriptorPool, DescriptorPoolAllocError, DescriptorSetAllocateInfo, UnsafeDescriptorPool,
UnsafeDescriptorPoolCreateInfo, UnsafeDescriptorPoolCreateInfo,

View File

@ -20,15 +20,14 @@ use crate::{
device::{Device, DeviceOwned}, device::{Device, DeviceOwned},
OomError, OomError,
}; };
use std::collections::HashMap; use std::{collections::HashMap, sync::Arc};
use std::sync::Arc;
/// Standard implementation of a descriptor pool. /// Standard implementation of a descriptor pool.
/// ///
/// Interally, this implementation uses one [`SingleLayoutDescSetPool`] / /// Interally, this implementation uses one [`SingleLayoutDescSetPool`] /
/// [`SingleLayoutVariableDescSetPool`] per descriptor set layout. /// [`SingleLayoutVariableDescSetPool`] per descriptor set layout.
#[derive(Debug)] #[derive(Debug)]
pub struct StdDescriptorPool { pub struct StandardDescriptorPool {
device: Arc<Device>, device: Arc<Device>,
pools: HashMap<Arc<DescriptorSetLayout>, Pool>, pools: HashMap<Arc<DescriptorSetLayout>, Pool>,
} }
@ -39,24 +38,24 @@ enum Pool {
Variable(SingleLayoutVariableDescSetPool), Variable(SingleLayoutVariableDescSetPool),
} }
impl StdDescriptorPool { impl StandardDescriptorPool {
/// Builds a new `StdDescriptorPool`. /// Builds a new `StandardDescriptorPool`.
pub fn new(device: Arc<Device>) -> StdDescriptorPool { pub fn new(device: Arc<Device>) -> StandardDescriptorPool {
StdDescriptorPool { StandardDescriptorPool {
device, device,
pools: HashMap::default(), pools: HashMap::default(),
} }
} }
} }
unsafe impl DescriptorPool for StdDescriptorPool { unsafe impl DescriptorPool for StandardDescriptorPool {
type Alloc = StdDescriptorPoolAlloc; type Alloc = StandardDescriptorPoolAlloc;
fn allocate( fn allocate(
&mut self, &mut self,
layout: &Arc<DescriptorSetLayout>, layout: &Arc<DescriptorSetLayout>,
variable_descriptor_count: u32, variable_descriptor_count: u32,
) -> Result<StdDescriptorPoolAlloc, OomError> { ) -> Result<StandardDescriptorPoolAlloc, OomError> {
assert!( assert!(
!layout.push_descriptor(), !layout.push_descriptor(),
"the provided descriptor set layout is for push descriptors, and cannot be used to \ "the provided descriptor set layout is for push descriptors, and cannot be used to \
@ -94,20 +93,20 @@ unsafe impl DescriptorPool for StdDescriptorPool {
} }
}; };
Ok(StdDescriptorPoolAlloc { inner }) Ok(StandardDescriptorPoolAlloc { inner })
} }
} }
unsafe impl DeviceOwned for StdDescriptorPool { unsafe impl DeviceOwned for StandardDescriptorPool {
#[inline] #[inline]
fn device(&self) -> &Arc<Device> { fn device(&self) -> &Arc<Device> {
&self.device &self.device
} }
} }
/// A descriptor set allocated from a `StdDescriptorPool`. /// A descriptor set allocated from a `StandardDescriptorPool`.
#[derive(Debug)] #[derive(Debug)]
pub struct StdDescriptorPoolAlloc { pub struct StandardDescriptorPoolAlloc {
// The actual descriptor alloc. // The actual descriptor alloc.
inner: PoolAlloc, inner: PoolAlloc,
} }
@ -118,7 +117,7 @@ enum PoolAlloc {
Variable(SingleLayoutVariablePoolAlloc), Variable(SingleLayoutVariablePoolAlloc),
} }
impl DescriptorPoolAlloc for StdDescriptorPoolAlloc { impl DescriptorPoolAlloc for StandardDescriptorPoolAlloc {
#[inline] #[inline]
fn inner(&self) -> &UnsafeDescriptorSet { fn inner(&self) -> &UnsafeDescriptorSet {
match &self.inner { match &self.inner {

View File

@ -37,9 +37,9 @@ const MAX_POOLS: usize = 32;
/// `VkDescriptorPool`. Its function is to provide access to pool(s) to allocate descriptor sets /// `VkDescriptorPool`. Its function is to provide access to pool(s) to allocate descriptor sets
/// from and optimizes for a specific layout which must not have a variable descriptor count. If /// from and optimizes for a specific layout which must not have a variable descriptor count. If
/// you need a variable descriptor count see [`SingleLayoutVariableDescSetPool`]. For a more general /// you need a variable descriptor count see [`SingleLayoutVariableDescSetPool`]. For a more general
/// purpose pool see [`StdDescriptorPool`]. /// purpose pool see [`StandardDescriptorPool`].
/// ///
/// [`StdDescriptorPool`]: super::pool::standard::StdDescriptorPool /// [`StandardDescriptorPool`]: super::pool::standard::StandardDescriptorPool
#[derive(Debug)] #[derive(Debug)]
pub struct SingleLayoutDescSetPool { pub struct SingleLayoutDescSetPool {
// The `SingleLayoutPool` struct contains an actual Vulkan pool. Every time it is full we create // The `SingleLayoutPool` struct contains an actual Vulkan pool. Every time it is full we create
@ -252,9 +252,9 @@ impl Hash for SingleLayoutDescSet {
/// Much like [`SingleLayoutDescSetPool`], except that it allows you to allocate descriptor sets /// Much like [`SingleLayoutDescSetPool`], except that it allows you to allocate descriptor sets
/// with a variable descriptor count. As this has more overhead, you should only use this pool if /// with a variable descriptor count. As this has more overhead, you should only use this pool if
/// you need the functionality and prefer [`SingleLayoutDescSetPool`] otherwise. For a more general /// you need the functionality and prefer [`SingleLayoutDescSetPool`] otherwise. For a more general
/// purpose pool see [`StdDescriptorPool`]. /// purpose pool see [`StandardDescriptorPool`].
/// ///
/// [`StdDescriptorPool`]: super::pool::standard::StdDescriptorPool /// [`StandardDescriptorPool`]: super::pool::standard::StandardDescriptorPool
#[derive(Debug)] #[derive(Debug)]
pub struct SingleLayoutVariableDescSetPool { pub struct SingleLayoutVariableDescSetPool {
// The `SingleLayoutVariablePool` struct contains an actual Vulkan pool. Every time it is full // The `SingleLayoutVariablePool` struct contains an actual Vulkan pool. Every time it is full

View File

@ -9,13 +9,16 @@
//! Low-level descriptor set. //! Low-level descriptor set.
use crate::descriptor_set::layout::DescriptorSetLayout; use crate::{
use crate::descriptor_set::update::{DescriptorWriteInfo, WriteDescriptorSet}; descriptor_set::{
use crate::device::DeviceOwned; layout::DescriptorSetLayout,
use crate::VulkanObject; update::{DescriptorWriteInfo, WriteDescriptorSet},
},
device::DeviceOwned,
VulkanObject,
};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::fmt; use std::{fmt, ptr};
use std::ptr;
/// Low-level descriptor set. /// Low-level descriptor set.
/// ///

View File

@ -8,10 +8,11 @@
// according to those terms. // according to those terms.
pub use crate::extensions::{ExtensionRestriction, ExtensionRestrictionError, OneOfRequirements}; pub use crate::extensions::{ExtensionRestriction, ExtensionRestrictionError, OneOfRequirements};
use crate::instance::InstanceExtensions; use crate::{instance::InstanceExtensions, Version};
use crate::Version; use std::{
use std::ffi::{CStr, CString}; ffi::{CStr, CString},
use std::fmt::Formatter; fmt::Formatter,
};
// Generated by build.rs // Generated by build.rs
include!(concat!(env!("OUT_DIR"), "/device_extensions.rs")); include!(concat!(env!("OUT_DIR"), "/device_extensions.rs"));

View File

@ -7,11 +7,8 @@
// notice may not be copied, modified, or distributed except // notice may not be copied, modified, or distributed except
// according to those terms. // according to those terms.
use crate::device::DeviceExtensions; use crate::{device::DeviceExtensions, instance::InstanceExtensions, Version};
use crate::instance::InstanceExtensions; use std::{error, fmt};
use crate::Version;
use std::error;
use std::fmt;
// Generated by build.rs // Generated by build.rs
include!(concat!(env!("OUT_DIR"), "/features.rs")); include!(concat!(env!("OUT_DIR"), "/features.rs"));

View File

@ -105,9 +105,9 @@ pub use self::{
use crate::{ use crate::{
check_errors, check_errors,
command_buffer::pool::StandardCommandPool, command_buffer::pool::StandardCommandPool,
descriptor_set::pool::StdDescriptorPool, descriptor_set::pool::StandardDescriptorPool,
instance::{debug::DebugUtilsLabel, Instance}, instance::{debug::DebugUtilsLabel, Instance},
memory::{pool::StdMemoryPool, ExternalMemoryHandleType}, memory::{pool::StandardMemoryPool, ExternalMemoryHandleType},
Error, OomError, SynchronizedVulkanObject, Version, VulkanObject, Error, OomError, SynchronizedVulkanObject, Version, VulkanObject,
}; };
pub use crate::{ pub use crate::{
@ -148,7 +148,7 @@ pub struct Device {
api_version: Version, api_version: Version,
fns: DeviceFunctions, fns: DeviceFunctions,
standard_pool: Mutex<Weak<StdMemoryPool>>, standard_pool: Mutex<Weak<StandardMemoryPool>>,
enabled_extensions: DeviceExtensions, enabled_extensions: DeviceExtensions,
enabled_features: Features, enabled_features: Features,
active_queue_families: SmallVec<[u32; 2]>, active_queue_families: SmallVec<[u32; 2]>,
@ -505,15 +505,15 @@ impl Device {
} }
/// Returns the standard memory pool used by default if you don't provide any other pool. /// Returns the standard memory pool used by default if you don't provide any other pool.
pub fn standard_pool(me: &Arc<Self>) -> Arc<StdMemoryPool> { pub fn standard_memory_pool(self: &Arc<Self>) -> Arc<StandardMemoryPool> {
let mut pool = me.standard_pool.lock().unwrap(); let mut pool = self.standard_pool.lock().unwrap();
if let Some(p) = pool.upgrade() { if let Some(p) = pool.upgrade() {
return p; return p;
} }
// The weak pointer is empty, so we create the pool. // The weak pointer is empty, so we create the pool.
let new_pool = StdMemoryPool::new(me.clone()); let new_pool = StandardMemoryPool::new(self.clone());
*pool = Arc::downgrade(&new_pool); *pool = Arc::downgrade(&new_pool);
new_pool new_pool
} }
@ -529,11 +529,11 @@ impl Device {
/// ///
/// - Panics if called again from within the callback. /// - Panics if called again from within the callback.
pub fn with_standard_descriptor_pool<T>( pub fn with_standard_descriptor_pool<T>(
self: &Arc<Device>, self: &Arc<Self>,
f: impl FnOnce(&mut StdDescriptorPool) -> T, f: impl FnOnce(&mut StandardDescriptorPool) -> T,
) -> T { ) -> T {
thread_local! { thread_local! {
static TLS: RefCell<HashMap<ash::vk::Device, StdDescriptorPool>> = static TLS: RefCell<HashMap<ash::vk::Device, StandardDescriptorPool>> =
RefCell::new(HashMap::default()); RefCell::new(HashMap::default());
} }
@ -541,15 +541,15 @@ impl Device {
let mut tls = tls.borrow_mut(); let mut tls = tls.borrow_mut();
let pool = match tls.entry(self.internal_object()) { let pool = match tls.entry(self.internal_object()) {
Entry::Occupied(entry) => entry.into_mut(), Entry::Occupied(entry) => entry.into_mut(),
Entry::Vacant(entry) => entry.insert(StdDescriptorPool::new(self.clone())), Entry::Vacant(entry) => entry.insert(StandardDescriptorPool::new(self.clone())),
}; };
f(pool) f(pool)
}) })
} }
/// Returns the standard command buffer pool used by default if you don't provide any other /// Gives you access to the standard command buffer pool used by default if you don't provide
/// pool. /// any other pool.
/// ///
/// Pools are stored in thread-local storage to avoid locks, which means that a pool is only /// Pools are stored in thread-local storage to avoid locks, which means that a pool is only
/// dropped once both the thread exits and all command buffers allocated from it are dropped. /// dropped once both the thread exits and all command buffers allocated from it are dropped.
@ -559,10 +559,12 @@ impl Device {
/// # Panics /// # Panics
/// ///
/// - Panics if the device and the queue family don't belong to the same physical device. /// - Panics if the device and the queue family don't belong to the same physical device.
pub fn standard_command_pool( /// - Panics if called again from within the callback.
me: &Arc<Self>, pub fn with_standard_command_pool<T>(
self: &Arc<Self>,
queue_family: QueueFamily, queue_family: QueueFamily,
) -> Result<Arc<StandardCommandPool>, OomError> { f: impl FnOnce(&Arc<StandardCommandPool>) -> T,
) -> Result<T, OomError> {
thread_local! { thread_local! {
static TLS: RefCell<HashMap<(ash::vk::Device, u32), Arc<StandardCommandPool>>> = static TLS: RefCell<HashMap<(ash::vk::Device, u32), Arc<StandardCommandPool>>> =
RefCell::new(Default::default()); RefCell::new(Default::default());
@ -570,15 +572,15 @@ impl Device {
TLS.with(|tls| { TLS.with(|tls| {
let mut tls = tls.borrow_mut(); let mut tls = tls.borrow_mut();
let per_family = match tls.entry((me.internal_object(), queue_family.id())) { let pool = match tls.entry((self.internal_object(), queue_family.id())) {
Entry::Occupied(entry) => entry.into_mut(), Entry::Occupied(entry) => entry.into_mut(),
Entry::Vacant(entry) => entry.insert(Arc::new(StandardCommandPool::new( Entry::Vacant(entry) => entry.insert(Arc::new(StandardCommandPool::new(
me.clone(), self.clone(),
queue_family, queue_family,
)?)), )?)),
}; };
Ok(per_family.clone()) Ok(f(pool))
}) })
} }
@ -1222,9 +1224,10 @@ impl fmt::Display for DebugUtilsError {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::device::physical::PhysicalDevice; use crate::device::{
use crate::device::{Device, DeviceCreateInfo, DeviceCreationError, QueueCreateInfo}; physical::PhysicalDevice, Device, DeviceCreateInfo, DeviceCreationError,
use crate::device::{FeatureRestriction, FeatureRestrictionError, Features}; FeatureRestriction, FeatureRestrictionError, Features, QueueCreateInfo,
};
use std::sync::Arc; use std::sync::Arc;
#[test] #[test]

View File

@ -1,16 +1,18 @@
use crate::device::physical::{ use crate::{
ConformanceVersion, DriverId, PhysicalDeviceType, PointClippingBehavior, ShaderCoreProperties, device::{
ShaderFloatControlsIndependence, SubgroupFeatures, physical::{
ConformanceVersion, DriverId, PhysicalDeviceType, PointClippingBehavior,
ShaderCoreProperties, ShaderFloatControlsIndependence, SubgroupFeatures,
},
DeviceExtensions,
},
image::{SampleCount, SampleCounts},
instance::InstanceExtensions,
render_pass::ResolveModes,
shader::ShaderStages,
DeviceSize, Version,
}; };
use crate::device::DeviceExtensions; use std::{ffi::CStr, os::raw::c_char};
use crate::image::{SampleCount, SampleCounts};
use crate::instance::InstanceExtensions;
use crate::render_pass::ResolveModes;
use crate::shader::ShaderStages;
use crate::DeviceSize;
use crate::Version;
use std::ffi::CStr;
use std::os::raw::c_char;
// Generated by build.rs // Generated by build.rs
include!(concat!(env!("OUT_DIR"), "/properties.rs")); include!(concat!(env!("OUT_DIR"), "/properties.rs"));

View File

@ -8,8 +8,10 @@
// according to those terms. // according to those terms.
use crate::Version; use crate::Version;
use std::error; use std::{
use std::fmt::{Display, Error as FmtError, Formatter}; error,
fmt::{Display, Error as FmtError, Formatter},
};
/// An error that can happen when enabling an extension on an instance or device. /// An error that can happen when enabling an extension on an instance or device.
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]

View File

@ -18,7 +18,8 @@ use crate::{
memory::{ memory::{
pool::{ pool::{
alloc_dedicated_with_exportable_fd, AllocFromRequirementsFilter, AllocLayout, alloc_dedicated_with_exportable_fd, AllocFromRequirementsFilter, AllocLayout,
MappingRequirement, MemoryPoolAlloc, PotentialDedicatedAllocation, StdMemoryPoolAlloc, MappingRequirement, MemoryPoolAlloc, PotentialDedicatedAllocation,
StandardMemoryPoolAlloc,
}, },
DedicatedAllocation, DeviceMemoryExportError, ExternalMemoryHandleType, DedicatedAllocation, DeviceMemoryExportError, ExternalMemoryHandleType,
ExternalMemoryHandleTypes, MemoryPool, ExternalMemoryHandleTypes, MemoryPool,
@ -64,7 +65,7 @@ use std::{
/// ///
// TODO: forbid reading transient images outside render passes? // TODO: forbid reading transient images outside render passes?
#[derive(Debug)] #[derive(Debug)]
pub struct AttachmentImage<A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> { pub struct AttachmentImage<A = PotentialDedicatedAllocation<StandardMemoryPoolAlloc>> {
// Inner implementation. // Inner implementation.
image: Arc<UnsafeImage>, image: Arc<UnsafeImage>,
@ -442,7 +443,7 @@ impl AttachmentImage {
let mem_reqs = image.memory_requirements(); let mem_reqs = image.memory_requirements();
let memory = MemoryPool::alloc_from_requirements( let memory = MemoryPool::alloc_from_requirements(
&Device::standard_pool(&device), &device.standard_memory_pool(),
&mem_reqs, &mem_reqs,
AllocLayout::Optimal, AllocLayout::Optimal,
MappingRequirement::DoNotMap, MappingRequirement::DoNotMap,

View File

@ -25,7 +25,7 @@ use crate::{
memory::{ memory::{
pool::{ pool::{
AllocFromRequirementsFilter, AllocLayout, MappingRequirement, MemoryPoolAlloc, AllocFromRequirementsFilter, AllocLayout, MappingRequirement, MemoryPoolAlloc,
PotentialDedicatedAllocation, StdMemoryPoolAlloc, PotentialDedicatedAllocation, StandardMemoryPoolAlloc,
}, },
DedicatedAllocation, DeviceMemoryAllocationError, MemoryPool, DedicatedAllocation, DeviceMemoryAllocationError, MemoryPool,
}, },
@ -45,7 +45,7 @@ use std::{
/// but then you must only ever read from it. /// but then you must only ever read from it.
// TODO: type (2D, 3D, array, etc.) as template parameter // TODO: type (2D, 3D, array, etc.) as template parameter
#[derive(Debug)] #[derive(Debug)]
pub struct ImmutableImage<A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> { pub struct ImmutableImage<A = PotentialDedicatedAllocation<StandardMemoryPoolAlloc>> {
image: Arc<UnsafeImage>, image: Arc<UnsafeImage>,
dimensions: ImageDimensions, dimensions: ImageDimensions,
memory: A, memory: A,
@ -204,7 +204,7 @@ impl ImmutableImage {
let mem_reqs = image.memory_requirements(); let mem_reqs = image.memory_requirements();
let memory = MemoryPool::alloc_from_requirements( let memory = MemoryPool::alloc_from_requirements(
&Device::standard_pool(&device), &device.standard_memory_pool(),
&mem_reqs, &mem_reqs,
AllocLayout::Optimal, AllocLayout::Optimal,
MappingRequirement::DoNotMap, MappingRequirement::DoNotMap,
@ -411,7 +411,7 @@ where
} }
// Must not implement Clone, as that would lead to multiple `used` values. // Must not implement Clone, as that would lead to multiple `used` values.
pub struct ImmutableImageInitialization<A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> { pub struct ImmutableImageInitialization<A = PotentialDedicatedAllocation<StandardMemoryPoolAlloc>> {
image: Arc<ImmutableImage<A>>, image: Arc<ImmutableImage<A>>,
mip_levels_access: Range<u32>, mip_levels_access: Range<u32>,
array_layers_access: Range<u32>, array_layers_access: Range<u32>,

View File

@ -839,11 +839,10 @@ impl From<ash::vk::ImageFormatProperties> for ImageFormatProperties {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::format::Format; use crate::{
use crate::image::ImageAccess; format::Format,
use crate::image::ImageDimensions; image::{ImageAccess, ImageDimensions, ImmutableImage, MipmapsCount},
use crate::image::ImmutableImage; };
use crate::image::MipmapsCount;
#[test] #[test]
fn max_mip_levels() { fn max_mip_levels() {

View File

@ -11,16 +11,14 @@ use super::{
sys::UnsafeImage, traits::ImageContent, ImageAccess, ImageCreateFlags, ImageCreationError, sys::UnsafeImage, traits::ImageContent, ImageAccess, ImageCreateFlags, ImageCreationError,
ImageDescriptorLayouts, ImageDimensions, ImageInner, ImageLayout, ImageUsage, ImageDescriptorLayouts, ImageDimensions, ImageInner, ImageLayout, ImageUsage,
}; };
use crate::device::Queue;
use crate::image::view::ImageView;
use crate::{ use crate::{
device::{physical::QueueFamily, Device, DeviceOwned}, device::{physical::QueueFamily, Device, DeviceOwned, Queue},
format::Format, format::Format,
image::sys::UnsafeImageCreateInfo, image::{sys::UnsafeImageCreateInfo, view::ImageView},
memory::{ memory::{
pool::{ pool::{
alloc_dedicated_with_exportable_fd, AllocFromRequirementsFilter, AllocLayout, alloc_dedicated_with_exportable_fd, AllocFromRequirementsFilter, AllocLayout,
MappingRequirement, MemoryPoolAlloc, PotentialDedicatedAllocation, StdMemoryPool, MappingRequirement, MemoryPoolAlloc, PotentialDedicatedAllocation, StandardMemoryPool,
}, },
DedicatedAllocation, DeviceMemoryExportError, ExternalMemoryHandleType, DedicatedAllocation, DeviceMemoryExportError, ExternalMemoryHandleType,
ExternalMemoryHandleTypes, MemoryPool, ExternalMemoryHandleTypes, MemoryPool,
@ -38,7 +36,7 @@ use std::{
/// General-purpose image in device memory. Can be used for any usage, but will be slower than a /// General-purpose image in device memory. Can be used for any usage, but will be slower than a
/// specialized image. /// specialized image.
#[derive(Debug)] #[derive(Debug)]
pub struct StorageImage<A = Arc<StdMemoryPool>> pub struct StorageImage<A = Arc<StandardMemoryPool>>
where where
A: MemoryPool, A: MemoryPool,
{ {
@ -130,7 +128,7 @@ impl StorageImage {
let mem_reqs = image.memory_requirements(); let mem_reqs = image.memory_requirements();
let memory = MemoryPool::alloc_from_requirements( let memory = MemoryPool::alloc_from_requirements(
&Device::standard_pool(&device), &device.standard_memory_pool(),
&mem_reqs, &mem_reqs,
AllocLayout::Optimal, AllocLayout::Optimal,
MappingRequirement::DoNotMap, MappingRequirement::DoNotMap,
@ -352,9 +350,13 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::StorageImage; use super::StorageImage;
use crate::format::Format; use crate::{
use crate::image::view::ImageViewCreationError; format::Format,
use crate::image::{ImageAccess, ImageCreationError, ImageDimensions, ImageUsage}; image::{
view::ImageViewCreationError, ImageAccess, ImageCreationError, ImageDimensions,
ImageUsage,
},
};
#[test] #[test]
fn create() { fn create() {

View File

@ -18,18 +18,17 @@ use super::{
ImageSubresourceLayers, ImageSubresourceRange, ImageTiling, ImageUsage, SampleCount, ImageSubresourceLayers, ImageSubresourceRange, ImageTiling, ImageUsage, SampleCount,
SampleCounts, SampleCounts,
}; };
use crate::image::view::ImageViewCreationError;
use crate::range_map::RangeMap;
use crate::{ use crate::{
buffer::cpu_access::{ReadLockError, WriteLockError}, buffer::cpu_access::{ReadLockError, WriteLockError},
check_errors, check_errors,
device::{Device, DeviceOwned}, device::{Device, DeviceOwned},
format::{ChromaSampling, Format, FormatFeatures, NumericType}, format::{ChromaSampling, Format, FormatFeatures, NumericType},
image::{ImageFormatInfo, ImageFormatProperties, ImageType}, image::{view::ImageViewCreationError, ImageFormatInfo, ImageFormatProperties, ImageType},
memory::{ memory::{
DeviceMemory, DeviceMemoryAllocationError, ExternalMemoryHandleType, DeviceMemory, DeviceMemoryAllocationError, ExternalMemoryHandleType,
ExternalMemoryHandleTypes, MemoryRequirements, ExternalMemoryHandleTypes, MemoryRequirements,
}, },
range_map::RangeMap,
sync::{AccessError, CurrentAccess, Sharing}, sync::{AccessError, CurrentAccess, Sharing},
DeviceSize, Error, OomError, Version, VulkanObject, DeviceSize, Error, OomError, Version, VulkanObject,
}; };
@ -2186,18 +2185,15 @@ impl FusedIterator for SubresourceRangeIterator {}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::ImageCreationError; use super::{ImageCreationError, ImageUsage, UnsafeImage, UnsafeImageCreateInfo};
use super::ImageUsage; use crate::{
use super::UnsafeImage; format::Format,
use super::UnsafeImageCreateInfo; image::{
use crate::format::Format; sys::SubresourceRangeIterator, ImageAspect, ImageAspects, ImageDimensions,
use crate::image::sys::SubresourceRangeIterator; ImageSubresourceRange, SampleCount,
use crate::image::ImageAspect; },
use crate::image::ImageAspects; DeviceSize,
use crate::image::ImageDimensions; };
use crate::image::ImageSubresourceRange;
use crate::image::SampleCount;
use crate::DeviceSize;
use smallvec::SmallVec; use smallvec::SmallVec;
#[test] #[test]

View File

@ -1476,9 +1476,10 @@ impl From<OomError> for MemoryMapError {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::MemoryAllocateInfo; use super::MemoryAllocateInfo;
use crate::memory::DeviceMemory; use crate::{
use crate::memory::DeviceMemoryAllocationError; memory::{DeviceMemory, DeviceMemoryAllocationError},
use crate::OomError; OomError,
};
#[test] #[test]
fn create() { fn create() {

View File

@ -90,7 +90,7 @@
//! A memory pool is any object that implements the `MemoryPool` trait. You can implement that //! A memory pool is any object that implements the `MemoryPool` trait. You can implement that
//! trait on your own structure and then use it when you create buffers and images so that they //! trait on your own structure and then use it when you create buffers and images so that they
//! get memory from that pool. By default if you don't specify any pool when creating a buffer or //! get memory from that pool. By default if you don't specify any pool when creating a buffer or
//! an image, an instance of `StdMemoryPool` that is shared by the `Device` object is used. //! an image, an instance of `StandardMemoryPool` that is shared by the `Device` object is used.
pub use self::{ pub use self::{
device_memory::{ device_memory::{

View File

@ -7,29 +7,31 @@
// notice may not be copied, modified, or distributed except // notice may not be copied, modified, or distributed except
// according to those terms. // according to those terms.
use crate::device::physical::MemoryType; use crate::{
use crate::device::Device; device::{physical::MemoryType, Device},
use crate::instance::Instance; instance::Instance,
use crate::memory::device_memory::MemoryAllocateInfo; memory::{
use crate::memory::DeviceMemory; device_memory::MemoryAllocateInfo, DeviceMemory, DeviceMemoryAllocationError,
use crate::memory::DeviceMemoryAllocationError; MappedDeviceMemory,
use crate::memory::MappedDeviceMemory; },
use crate::DeviceSize; DeviceSize,
use std::cmp; };
use std::ops::Range; use std::{
use std::sync::Arc; cmp,
use std::sync::Mutex; ops::Range,
sync::{Arc, Mutex},
};
/// Memory pool that operates on a given memory type. /// Memory pool that operates on a given memory type.
#[derive(Debug)] #[derive(Debug)]
pub struct StdHostVisibleMemoryTypePool { pub struct StandardHostVisibleMemoryTypePool {
device: Arc<Device>, device: Arc<Device>,
memory_type: u32, memory_type: u32,
// TODO: obviously very inefficient // TODO: obviously very inefficient
occupied: Mutex<Vec<(Arc<MappedDeviceMemory>, Vec<Range<DeviceSize>>)>>, occupied: Mutex<Vec<(Arc<MappedDeviceMemory>, Vec<Range<DeviceSize>>)>>,
} }
impl StdHostVisibleMemoryTypePool { impl StandardHostVisibleMemoryTypePool {
/// Creates a new pool that will operate on the given memory type. /// Creates a new pool that will operate on the given memory type.
/// ///
/// # Panic /// # Panic
@ -38,7 +40,10 @@ impl StdHostVisibleMemoryTypePool {
/// - Panics if the memory type is not host-visible. /// - Panics if the memory type is not host-visible.
/// ///
#[inline] #[inline]
pub fn new(device: Arc<Device>, memory_type: MemoryType) -> Arc<StdHostVisibleMemoryTypePool> { pub fn new(
device: Arc<Device>,
memory_type: MemoryType,
) -> Arc<StandardHostVisibleMemoryTypePool> {
assert_eq!( assert_eq!(
&**device.physical_device().instance() as *const Instance, &**device.physical_device().instance() as *const Instance,
&**memory_type.physical_device().instance() as *const Instance &**memory_type.physical_device().instance() as *const Instance
@ -49,7 +54,7 @@ impl StdHostVisibleMemoryTypePool {
); );
assert!(memory_type.is_host_visible()); assert!(memory_type.is_host_visible());
Arc::new(StdHostVisibleMemoryTypePool { Arc::new(StandardHostVisibleMemoryTypePool {
device: device.clone(), device: device.clone(),
memory_type: memory_type.id(), memory_type: memory_type.id(),
occupied: Mutex::new(Vec::new()), occupied: Mutex::new(Vec::new()),
@ -67,7 +72,7 @@ impl StdHostVisibleMemoryTypePool {
me: &Arc<Self>, me: &Arc<Self>,
size: DeviceSize, size: DeviceSize,
alignment: DeviceSize, alignment: DeviceSize,
) -> Result<StdHostVisibleMemoryTypePoolAlloc, DeviceMemoryAllocationError> { ) -> Result<StandardHostVisibleMemoryTypePoolAlloc, DeviceMemoryAllocationError> {
assert!(size != 0); assert!(size != 0);
assert!(alignment != 0); assert!(alignment != 0);
@ -88,7 +93,7 @@ impl StdHostVisibleMemoryTypePool {
let entry2 = entries[i + 1].clone(); let entry2 = entries[i + 1].clone();
if entry1_end + size <= entry2.start { if entry1_end + size <= entry2.start {
entries.insert(i + 1, entry1_end..entry1_end + size); entries.insert(i + 1, entry1_end..entry1_end + size);
return Ok(StdHostVisibleMemoryTypePoolAlloc { return Ok(StandardHostVisibleMemoryTypePoolAlloc {
pool: me.clone(), pool: me.clone(),
memory: dev_mem.clone(), memory: dev_mem.clone(),
offset: entry1_end, offset: entry1_end,
@ -101,7 +106,7 @@ impl StdHostVisibleMemoryTypePool {
let last_end = entries.last().map(|e| align(e.end, alignment)).unwrap_or(0); let last_end = entries.last().map(|e| align(e.end, alignment)).unwrap_or(0);
if last_end + size <= (**dev_mem).as_ref().allocation_size() { if last_end + size <= (**dev_mem).as_ref().allocation_size() {
entries.push(last_end..last_end + size); entries.push(last_end..last_end + size);
return Ok(StdHostVisibleMemoryTypePoolAlloc { return Ok(StandardHostVisibleMemoryTypePoolAlloc {
pool: me.clone(), pool: me.clone(),
memory: dev_mem.clone(), memory: dev_mem.clone(),
offset: last_end, offset: last_end,
@ -127,7 +132,7 @@ impl StdHostVisibleMemoryTypePool {
}; };
occupied.push((new_block.clone(), vec![0..size])); occupied.push((new_block.clone(), vec![0..size]));
Ok(StdHostVisibleMemoryTypePoolAlloc { Ok(StandardHostVisibleMemoryTypePoolAlloc {
pool: me.clone(), pool: me.clone(),
memory: new_block, memory: new_block,
offset: 0, offset: 0,
@ -152,14 +157,14 @@ impl StdHostVisibleMemoryTypePool {
} }
#[derive(Debug)] #[derive(Debug)]
pub struct StdHostVisibleMemoryTypePoolAlloc { pub struct StandardHostVisibleMemoryTypePoolAlloc {
pool: Arc<StdHostVisibleMemoryTypePool>, pool: Arc<StandardHostVisibleMemoryTypePool>,
memory: Arc<MappedDeviceMemory>, memory: Arc<MappedDeviceMemory>,
offset: DeviceSize, offset: DeviceSize,
size: DeviceSize, size: DeviceSize,
} }
impl StdHostVisibleMemoryTypePoolAlloc { impl StandardHostVisibleMemoryTypePoolAlloc {
#[inline] #[inline]
pub fn memory(&self) -> &MappedDeviceMemory { pub fn memory(&self) -> &MappedDeviceMemory {
&self.memory &self.memory
@ -176,7 +181,7 @@ impl StdHostVisibleMemoryTypePoolAlloc {
} }
} }
impl Drop for StdHostVisibleMemoryTypePoolAlloc { impl Drop for StandardHostVisibleMemoryTypePoolAlloc {
fn drop(&mut self) { fn drop(&mut self) {
let mut occupied = self.pool.occupied.lock().unwrap(); let mut occupied = self.pool.occupied.lock().unwrap();

View File

@ -7,22 +7,22 @@
// notice may not be copied, modified, or distributed except // notice may not be copied, modified, or distributed except
// according to those terms. // according to those terms.
pub use self::host_visible::StdHostVisibleMemoryTypePool; pub use self::{
pub use self::host_visible::StdHostVisibleMemoryTypePoolAlloc; host_visible::{StandardHostVisibleMemoryTypePool, StandardHostVisibleMemoryTypePoolAlloc},
pub use self::non_host_visible::StdNonHostVisibleMemoryTypePool; non_host_visible::{
pub use self::non_host_visible::StdNonHostVisibleMemoryTypePoolAlloc; StandardNonHostVisibleMemoryTypePool, StandardNonHostVisibleMemoryTypePoolAlloc,
pub use self::pool::StdMemoryPool; },
pub use self::pool::StdMemoryPoolAlloc; pool::{StandardMemoryPool, StandardMemoryPoolAlloc},
use crate::device::physical::MemoryType; };
use crate::device::{Device, DeviceOwned}; use crate::{
use crate::memory::device_memory::MemoryAllocateInfo; device::{physical::MemoryType, Device, DeviceOwned},
use crate::memory::DedicatedAllocation; memory::{
use crate::memory::DeviceMemory; device_memory::MemoryAllocateInfo, DedicatedAllocation, DeviceMemory,
use crate::memory::DeviceMemoryAllocationError; DeviceMemoryAllocationError, ExternalMemoryHandleTypes, MappedDeviceMemory,
use crate::memory::ExternalMemoryHandleTypes; MemoryRequirements,
use crate::memory::MappedDeviceMemory; },
use crate::memory::MemoryRequirements; DeviceSize,
use crate::DeviceSize; };
use std::sync::Arc; use std::sync::Arc;
mod host_visible; mod host_visible;
@ -77,7 +77,7 @@ pub(crate) fn alloc_dedicated_with_exportable_fd<F>(
map: MappingRequirement, map: MappingRequirement,
dedicated_allocation: DedicatedAllocation, dedicated_allocation: DedicatedAllocation,
filter: F, filter: F,
) -> Result<PotentialDedicatedAllocation<StdMemoryPoolAlloc>, DeviceMemoryAllocationError> ) -> Result<PotentialDedicatedAllocation<StandardMemoryPoolAlloc>, DeviceMemoryAllocationError>
where where
F: FnMut(MemoryType) -> AllocFromRequirementsFilter, F: FnMut(MemoryType) -> AllocFromRequirementsFilter,
{ {

View File

@ -7,28 +7,28 @@
// notice may not be copied, modified, or distributed except // notice may not be copied, modified, or distributed except
// according to those terms. // according to those terms.
use crate::device::physical::MemoryType; use crate::{
use crate::device::Device; device::{physical::MemoryType, Device},
use crate::instance::Instance; instance::Instance,
use crate::memory::device_memory::MemoryAllocateInfo; memory::{device_memory::MemoryAllocateInfo, DeviceMemory, DeviceMemoryAllocationError},
use crate::memory::DeviceMemory; DeviceSize,
use crate::memory::DeviceMemoryAllocationError; };
use crate::DeviceSize; use std::{
use std::cmp; cmp,
use std::ops::Range; ops::Range,
use std::sync::Arc; sync::{Arc, Mutex},
use std::sync::Mutex; };
/// Memory pool that operates on a given memory type. /// Memory pool that operates on a given memory type.
#[derive(Debug)] #[derive(Debug)]
pub struct StdNonHostVisibleMemoryTypePool { pub struct StandardNonHostVisibleMemoryTypePool {
device: Arc<Device>, device: Arc<Device>,
memory_type: u32, memory_type: u32,
// TODO: obviously very inefficient // TODO: obviously very inefficient
occupied: Mutex<Vec<(Arc<DeviceMemory>, Vec<Range<DeviceSize>>)>>, occupied: Mutex<Vec<(Arc<DeviceMemory>, Vec<Range<DeviceSize>>)>>,
} }
impl StdNonHostVisibleMemoryTypePool { impl StandardNonHostVisibleMemoryTypePool {
/// Creates a new pool that will operate on the given memory type. /// Creates a new pool that will operate on the given memory type.
/// ///
/// # Panic /// # Panic
@ -39,7 +39,7 @@ impl StdNonHostVisibleMemoryTypePool {
pub fn new( pub fn new(
device: Arc<Device>, device: Arc<Device>,
memory_type: MemoryType, memory_type: MemoryType,
) -> Arc<StdNonHostVisibleMemoryTypePool> { ) -> Arc<StandardNonHostVisibleMemoryTypePool> {
assert_eq!( assert_eq!(
&**device.physical_device().instance() as *const Instance, &**device.physical_device().instance() as *const Instance,
&**memory_type.physical_device().instance() as *const Instance &**memory_type.physical_device().instance() as *const Instance
@ -49,7 +49,7 @@ impl StdNonHostVisibleMemoryTypePool {
memory_type.physical_device().index() memory_type.physical_device().index()
); );
Arc::new(StdNonHostVisibleMemoryTypePool { Arc::new(StandardNonHostVisibleMemoryTypePool {
device: device.clone(), device: device.clone(),
memory_type: memory_type.id(), memory_type: memory_type.id(),
occupied: Mutex::new(Vec::new()), occupied: Mutex::new(Vec::new()),
@ -67,7 +67,7 @@ impl StdNonHostVisibleMemoryTypePool {
me: &Arc<Self>, me: &Arc<Self>,
size: DeviceSize, size: DeviceSize,
alignment: DeviceSize, alignment: DeviceSize,
) -> Result<StdNonHostVisibleMemoryTypePoolAlloc, DeviceMemoryAllocationError> { ) -> Result<StandardNonHostVisibleMemoryTypePoolAlloc, DeviceMemoryAllocationError> {
assert!(size != 0); assert!(size != 0);
assert!(alignment != 0); assert!(alignment != 0);
@ -88,7 +88,7 @@ impl StdNonHostVisibleMemoryTypePool {
let entry2 = entries[i + 1].clone(); let entry2 = entries[i + 1].clone();
if entry1_end + size <= entry2.start { if entry1_end + size <= entry2.start {
entries.insert(i + 1, entry1_end..entry1_end + size); entries.insert(i + 1, entry1_end..entry1_end + size);
return Ok(StdNonHostVisibleMemoryTypePoolAlloc { return Ok(StandardNonHostVisibleMemoryTypePoolAlloc {
pool: me.clone(), pool: me.clone(),
memory: dev_mem.clone(), memory: dev_mem.clone(),
offset: entry1_end, offset: entry1_end,
@ -101,7 +101,7 @@ impl StdNonHostVisibleMemoryTypePool {
let last_end = entries.last().map(|e| align(e.end, alignment)).unwrap_or(0); let last_end = entries.last().map(|e| align(e.end, alignment)).unwrap_or(0);
if last_end + size <= dev_mem.allocation_size() { if last_end + size <= dev_mem.allocation_size() {
entries.push(last_end..last_end + size); entries.push(last_end..last_end + size);
return Ok(StdNonHostVisibleMemoryTypePoolAlloc { return Ok(StandardNonHostVisibleMemoryTypePoolAlloc {
pool: me.clone(), pool: me.clone(),
memory: dev_mem.clone(), memory: dev_mem.clone(),
offset: last_end, offset: last_end,
@ -126,7 +126,7 @@ impl StdNonHostVisibleMemoryTypePool {
}; };
occupied.push((new_block.clone(), vec![0..size])); occupied.push((new_block.clone(), vec![0..size]));
Ok(StdNonHostVisibleMemoryTypePoolAlloc { Ok(StandardNonHostVisibleMemoryTypePoolAlloc {
pool: me.clone(), pool: me.clone(),
memory: new_block, memory: new_block,
offset: 0, offset: 0,
@ -151,14 +151,14 @@ impl StdNonHostVisibleMemoryTypePool {
} }
#[derive(Debug)] #[derive(Debug)]
pub struct StdNonHostVisibleMemoryTypePoolAlloc { pub struct StandardNonHostVisibleMemoryTypePoolAlloc {
pool: Arc<StdNonHostVisibleMemoryTypePool>, pool: Arc<StandardNonHostVisibleMemoryTypePool>,
memory: Arc<DeviceMemory>, memory: Arc<DeviceMemory>,
offset: DeviceSize, offset: DeviceSize,
size: DeviceSize, size: DeviceSize,
} }
impl StdNonHostVisibleMemoryTypePoolAlloc { impl StandardNonHostVisibleMemoryTypePoolAlloc {
#[inline] #[inline]
pub fn memory(&self) -> &DeviceMemory { pub fn memory(&self) -> &DeviceMemory {
&self.memory &self.memory
@ -175,7 +175,7 @@ impl StdNonHostVisibleMemoryTypePoolAlloc {
} }
} }
impl Drop for StdNonHostVisibleMemoryTypePoolAlloc { impl Drop for StandardNonHostVisibleMemoryTypePoolAlloc {
fn drop(&mut self) { fn drop(&mut self) {
let mut occupied = self.pool.occupied.lock().unwrap(); let mut occupied = self.pool.occupied.lock().unwrap();

View File

@ -7,41 +7,38 @@
// notice may not be copied, modified, or distributed except // notice may not be copied, modified, or distributed except
// according to those terms. // according to those terms.
use crate::device::physical::MemoryType; use crate::{
use crate::device::Device; device::{physical::MemoryType, Device, DeviceOwned},
use crate::device::DeviceOwned; memory::{
use crate::memory::pool::AllocLayout; pool::{
use crate::memory::pool::MappingRequirement; AllocLayout, MappingRequirement, MemoryPool, MemoryPoolAlloc,
use crate::memory::pool::MemoryPool; StandardHostVisibleMemoryTypePool, StandardHostVisibleMemoryTypePoolAlloc,
use crate::memory::pool::MemoryPoolAlloc; StandardNonHostVisibleMemoryTypePool, StandardNonHostVisibleMemoryTypePoolAlloc,
use crate::memory::pool::StdHostVisibleMemoryTypePool; },
use crate::memory::pool::StdHostVisibleMemoryTypePoolAlloc; DeviceMemory, DeviceMemoryAllocationError, MappedDeviceMemory,
use crate::memory::pool::StdNonHostVisibleMemoryTypePool; },
use crate::memory::pool::StdNonHostVisibleMemoryTypePoolAlloc; DeviceSize,
use crate::memory::DeviceMemory; };
use crate::memory::DeviceMemoryAllocationError; use std::{
use crate::memory::MappedDeviceMemory; collections::{hash_map::Entry, HashMap},
use crate::DeviceSize; sync::{Arc, Mutex},
use std::collections::hash_map::Entry; };
use std::collections::HashMap;
use std::sync::Arc;
use std::sync::Mutex;
#[derive(Debug)] #[derive(Debug)]
pub struct StdMemoryPool { pub struct StandardMemoryPool {
device: Arc<Device>, device: Arc<Device>,
// For each memory type index, stores the associated pool. // For each memory type index, stores the associated pool.
pools: Mutex<HashMap<(u32, AllocLayout, MappingRequirement), Pool>>, pools: Mutex<HashMap<(u32, AllocLayout, MappingRequirement), Pool>>,
} }
impl StdMemoryPool { impl StandardMemoryPool {
/// Creates a new pool. /// Creates a new pool.
#[inline] #[inline]
pub fn new(device: Arc<Device>) -> Arc<StdMemoryPool> { pub fn new(device: Arc<Device>) -> Arc<StandardMemoryPool> {
let cap = device.physical_device().memory_types().len(); let cap = device.physical_device().memory_types().len();
Arc::new(StdMemoryPool { Arc::new(StandardMemoryPool {
device: device.clone(), device: device.clone(),
pools: Mutex::new(HashMap::with_capacity(cap)), pools: Mutex::new(HashMap::with_capacity(cap)),
}) })
@ -49,13 +46,13 @@ impl StdMemoryPool {
} }
fn generic_allocation( fn generic_allocation(
mem_pool: Arc<StdMemoryPool>, mem_pool: Arc<StandardMemoryPool>,
memory_type: MemoryType, memory_type: MemoryType,
size: DeviceSize, size: DeviceSize,
alignment: DeviceSize, alignment: DeviceSize,
layout: AllocLayout, layout: AllocLayout,
map: MappingRequirement, map: MappingRequirement,
) -> Result<StdMemoryPoolAlloc, DeviceMemoryAllocationError> { ) -> Result<StandardMemoryPoolAlloc, DeviceMemoryAllocationError> {
let mut pools = mem_pool.pools.lock().unwrap(); let mut pools = mem_pool.pools.lock().unwrap();
let memory_type_host_visible = memory_type.is_host_visible(); let memory_type_host_visible = memory_type.is_host_visible();
@ -64,17 +61,17 @@ fn generic_allocation(
match pools.entry((memory_type.id(), layout, map)) { match pools.entry((memory_type.id(), layout, map)) {
Entry::Occupied(entry) => match entry.get() { Entry::Occupied(entry) => match entry.get() {
&Pool::HostVisible(ref pool) => { &Pool::HostVisible(ref pool) => {
let alloc = StdHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?; let alloc = StandardHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?;
let inner = StdMemoryPoolAllocInner::HostVisible(alloc); let inner = StandardMemoryPoolAllocInner::HostVisible(alloc);
Ok(StdMemoryPoolAlloc { Ok(StandardMemoryPoolAlloc {
inner, inner,
pool: mem_pool.clone(), pool: mem_pool.clone(),
}) })
} }
&Pool::NonHostVisible(ref pool) => { &Pool::NonHostVisible(ref pool) => {
let alloc = StdNonHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?; let alloc = StandardNonHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?;
let inner = StdMemoryPoolAllocInner::NonHostVisible(alloc); let inner = StandardMemoryPoolAllocInner::NonHostVisible(alloc);
Ok(StdMemoryPoolAlloc { Ok(StandardMemoryPoolAlloc {
inner, inner,
pool: mem_pool.clone(), pool: mem_pool.clone(),
}) })
@ -83,21 +80,22 @@ fn generic_allocation(
Entry::Vacant(entry) => { Entry::Vacant(entry) => {
if memory_type_host_visible { if memory_type_host_visible {
let pool = StdHostVisibleMemoryTypePool::new(mem_pool.device.clone(), memory_type); let pool =
StandardHostVisibleMemoryTypePool::new(mem_pool.device.clone(), memory_type);
entry.insert(Pool::HostVisible(pool.clone())); entry.insert(Pool::HostVisible(pool.clone()));
let alloc = StdHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?; let alloc = StandardHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?;
let inner = StdMemoryPoolAllocInner::HostVisible(alloc); let inner = StandardMemoryPoolAllocInner::HostVisible(alloc);
Ok(StdMemoryPoolAlloc { Ok(StandardMemoryPoolAlloc {
inner, inner,
pool: mem_pool.clone(), pool: mem_pool.clone(),
}) })
} else { } else {
let pool = let pool =
StdNonHostVisibleMemoryTypePool::new(mem_pool.device.clone(), memory_type); StandardNonHostVisibleMemoryTypePool::new(mem_pool.device.clone(), memory_type);
entry.insert(Pool::NonHostVisible(pool.clone())); entry.insert(Pool::NonHostVisible(pool.clone()));
let alloc = StdNonHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?; let alloc = StandardNonHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?;
let inner = StdMemoryPoolAllocInner::NonHostVisible(alloc); let inner = StandardMemoryPoolAllocInner::NonHostVisible(alloc);
Ok(StdMemoryPoolAlloc { Ok(StandardMemoryPoolAlloc {
inner, inner,
pool: mem_pool.clone(), pool: mem_pool.clone(),
}) })
@ -106,8 +104,8 @@ fn generic_allocation(
} }
} }
unsafe impl MemoryPool for Arc<StdMemoryPool> { unsafe impl MemoryPool for Arc<StandardMemoryPool> {
type Alloc = StdMemoryPoolAlloc; type Alloc = StandardMemoryPoolAlloc;
fn alloc_generic( fn alloc_generic(
&self, &self,
@ -116,12 +114,12 @@ unsafe impl MemoryPool for Arc<StdMemoryPool> {
alignment: DeviceSize, alignment: DeviceSize,
layout: AllocLayout, layout: AllocLayout,
map: MappingRequirement, map: MappingRequirement,
) -> Result<StdMemoryPoolAlloc, DeviceMemoryAllocationError> { ) -> Result<StandardMemoryPoolAlloc, DeviceMemoryAllocationError> {
generic_allocation(self.clone(), memory_type, size, alignment, layout, map) generic_allocation(self.clone(), memory_type, size, alignment, layout, map)
} }
} }
unsafe impl DeviceOwned for StdMemoryPool { unsafe impl DeviceOwned for StandardMemoryPool {
#[inline] #[inline]
fn device(&self) -> &Arc<Device> { fn device(&self) -> &Arc<Device> {
&self.device &self.device
@ -130,54 +128,54 @@ unsafe impl DeviceOwned for StdMemoryPool {
#[derive(Debug)] #[derive(Debug)]
enum Pool { enum Pool {
HostVisible(Arc<StdHostVisibleMemoryTypePool>), HostVisible(Arc<StandardHostVisibleMemoryTypePool>),
NonHostVisible(Arc<StdNonHostVisibleMemoryTypePool>), NonHostVisible(Arc<StandardNonHostVisibleMemoryTypePool>),
} }
#[derive(Debug)] #[derive(Debug)]
pub struct StdMemoryPoolAlloc { pub struct StandardMemoryPoolAlloc {
inner: StdMemoryPoolAllocInner, inner: StandardMemoryPoolAllocInner,
pool: Arc<StdMemoryPool>, pool: Arc<StandardMemoryPool>,
} }
impl StdMemoryPoolAlloc { impl StandardMemoryPoolAlloc {
#[inline] #[inline]
pub fn size(&self) -> DeviceSize { pub fn size(&self) -> DeviceSize {
match self.inner { match self.inner {
StdMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.size(), StandardMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.size(),
StdMemoryPoolAllocInner::HostVisible(ref mem) => mem.size(), StandardMemoryPoolAllocInner::HostVisible(ref mem) => mem.size(),
} }
} }
} }
unsafe impl MemoryPoolAlloc for StdMemoryPoolAlloc { unsafe impl MemoryPoolAlloc for StandardMemoryPoolAlloc {
#[inline] #[inline]
fn memory(&self) -> &DeviceMemory { fn memory(&self) -> &DeviceMemory {
match self.inner { match self.inner {
StdMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.memory(), StandardMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.memory(),
StdMemoryPoolAllocInner::HostVisible(ref mem) => mem.memory().as_ref(), StandardMemoryPoolAllocInner::HostVisible(ref mem) => mem.memory().as_ref(),
} }
} }
#[inline] #[inline]
fn mapped_memory(&self) -> Option<&MappedDeviceMemory> { fn mapped_memory(&self) -> Option<&MappedDeviceMemory> {
match self.inner { match self.inner {
StdMemoryPoolAllocInner::NonHostVisible(_) => None, StandardMemoryPoolAllocInner::NonHostVisible(_) => None,
StdMemoryPoolAllocInner::HostVisible(ref mem) => Some(mem.memory()), StandardMemoryPoolAllocInner::HostVisible(ref mem) => Some(mem.memory()),
} }
} }
#[inline] #[inline]
fn offset(&self) -> DeviceSize { fn offset(&self) -> DeviceSize {
match self.inner { match self.inner {
StdMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.offset(), StandardMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.offset(),
StdMemoryPoolAllocInner::HostVisible(ref mem) => mem.offset(), StandardMemoryPoolAllocInner::HostVisible(ref mem) => mem.offset(),
} }
} }
} }
#[derive(Debug)] #[derive(Debug)]
enum StdMemoryPoolAllocInner { enum StandardMemoryPoolAllocInner {
NonHostVisible(StdNonHostVisibleMemoryTypePoolAlloc), NonHostVisible(StandardNonHostVisibleMemoryTypePoolAlloc),
HostVisible(StdHostVisibleMemoryTypePoolAlloc), HostVisible(StandardHostVisibleMemoryTypePoolAlloc),
} }

View File

@ -21,14 +21,8 @@
//! of [`get_data`](crate::pipeline::cache::PipelineCache::get_data) for example of how to store the data //! of [`get_data`](crate::pipeline::cache::PipelineCache::get_data) for example of how to store the data
//! on the disk, and [`with_data`](crate::pipeline::cache::PipelineCache::with_data) for how to reload it. //! on the disk, and [`with_data`](crate::pipeline::cache::PipelineCache::with_data) for how to reload it.
use crate::check_errors; use crate::{check_errors, device::Device, OomError, Success, VulkanObject};
use crate::device::Device; use std::{mem::MaybeUninit, ptr, sync::Arc};
use crate::OomError;
use crate::Success;
use crate::VulkanObject;
use std::mem::MaybeUninit;
use std::ptr;
use std::sync::Arc;
/// Opaque cache that contains pipeline objects. /// Opaque cache that contains pipeline objects.
/// ///
@ -256,9 +250,10 @@ impl Drop for PipelineCache {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::pipeline::cache::PipelineCache; use crate::{
use crate::pipeline::ComputePipeline; pipeline::{cache::PipelineCache, ComputePipeline},
use crate::shader::ShaderModule; shader::ShaderModule,
};
use std::sync::Arc; use std::sync::Arc;
#[test] #[test]

View File

@ -23,28 +23,21 @@
//! command on the command buffer. //! command on the command buffer.
use super::layout::PipelineLayoutCreateInfo; use super::layout::PipelineLayoutCreateInfo;
use crate::check_errors; use crate::{
use crate::descriptor_set::layout::{ check_errors,
descriptor_set::layout::{
DescriptorSetLayout, DescriptorSetLayoutCreateInfo, DescriptorSetLayoutCreationError, DescriptorSetLayout, DescriptorSetLayoutCreateInfo, DescriptorSetLayoutCreationError,
},
device::{Device, DeviceOwned},
pipeline::{
cache::PipelineCache,
layout::{PipelineLayout, PipelineLayoutCreationError, PipelineLayoutSupersetError},
Pipeline, PipelineBindPoint,
},
shader::{DescriptorRequirements, EntryPoint, SpecializationConstants},
DeviceSize, Error, OomError, VulkanObject,
}; };
use crate::device::{Device, DeviceOwned}; use std::{collections::HashMap, error, fmt, mem, mem::MaybeUninit, ptr, sync::Arc};
use crate::pipeline::cache::PipelineCache;
use crate::pipeline::layout::{
PipelineLayout, PipelineLayoutCreationError, PipelineLayoutSupersetError,
};
use crate::pipeline::{Pipeline, PipelineBindPoint};
use crate::shader::{DescriptorRequirements, EntryPoint, SpecializationConstants};
use crate::DeviceSize;
use crate::Error;
use crate::OomError;
use crate::VulkanObject;
use std::collections::HashMap;
use std::error;
use std::fmt;
use std::mem;
use std::mem::MaybeUninit;
use std::ptr;
use std::sync::Arc;
/// A pipeline object that describes to the Vulkan implementation how it should perform compute /// A pipeline object that describes to the Vulkan implementation how it should perform compute
/// operations. /// operations.
@ -406,20 +399,14 @@ impl From<Error> for ComputePipelineCreationError {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::buffer::BufferUsage; use crate::{
use crate::buffer::CpuAccessibleBuffer; buffer::{BufferUsage, CpuAccessibleBuffer},
use crate::command_buffer::AutoCommandBufferBuilder; command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage},
use crate::command_buffer::CommandBufferUsage; descriptor_set::{PersistentDescriptorSet, WriteDescriptorSet},
use crate::descriptor_set::PersistentDescriptorSet; pipeline::{ComputePipeline, Pipeline, PipelineBindPoint},
use crate::descriptor_set::WriteDescriptorSet; shader::{ShaderModule, SpecializationConstants, SpecializationMapEntry},
use crate::pipeline::ComputePipeline; sync::{now, GpuFuture},
use crate::pipeline::Pipeline; };
use crate::pipeline::PipelineBindPoint;
use crate::shader::ShaderModule;
use crate::shader::SpecializationConstants;
use crate::shader::SpecializationMapEntry;
use crate::sync::now;
use crate::sync::GpuFuture;
// TODO: test for basic creation // TODO: test for basic creation
// TODO: test for pipeline layout error // TODO: test for pipeline layout error

View File

@ -8,15 +8,15 @@
// according to those terms. // according to those terms.
use super::VertexMemberInfo; use super::VertexMemberInfo;
use crate::pipeline::graphics::vertex_input::IncompatibleVertexDefinitionError; use crate::{
use crate::pipeline::graphics::vertex_input::Vertex; pipeline::graphics::vertex_input::{
use crate::pipeline::graphics::vertex_input::VertexDefinition; IncompatibleVertexDefinitionError, Vertex, VertexDefinition,
use crate::pipeline::graphics::vertex_input::VertexInputAttributeDescription; VertexInputAttributeDescription, VertexInputBindingDescription, VertexInputRate,
use crate::pipeline::graphics::vertex_input::VertexInputBindingDescription; VertexInputState,
use crate::pipeline::graphics::vertex_input::VertexInputRate; },
use crate::pipeline::graphics::vertex_input::VertexInputState; shader::ShaderInterface,
use crate::shader::ShaderInterface; DeviceSize,
use crate::DeviceSize; };
use std::mem; use std::mem;
/// A vertex definition for any number of vertex and instance buffers. /// A vertex definition for any number of vertex and instance buffers.

View File

@ -82,12 +82,11 @@ impl_collection!(Z, Y, X, W, V, U, T, S, R, Q, P, O, N, M, L, K, J, I, H, G, F,
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::VertexBuffersCollection; use super::VertexBuffersCollection;
use crate::buffer::BufferAccess; use crate::{
use crate::buffer::BufferAccessObject; buffer::{BufferAccess, BufferAccessObject, BufferInner},
use crate::buffer::BufferInner; device::{Device, DeviceOwned},
use crate::device::Device; DeviceSize,
use crate::device::DeviceOwned; };
use crate::DeviceSize;
use std::sync::Arc; use std::sync::Arc;
struct DummyBufferA {} struct DummyBufferA {}

View File

@ -50,12 +50,12 @@
//! # } //! # }
//! ``` //! ```
use crate::format::Format; use crate::{
use crate::pipeline::graphics::vertex_input::VertexInputState; format::Format,
use crate::pipeline::graphics::vertex_input::VertexMemberTy; pipeline::graphics::vertex_input::{VertexInputState, VertexMemberTy},
use crate::shader::ShaderInterface; shader::ShaderInterface,
use std::error; };
use std::fmt; use std::{error, fmt};
/// Trait for types that can create a [`VertexInputState`] from a [`ShaderInterface`]. /// Trait for types that can create a [`VertexInputState`] from a [`ShaderInterface`].
pub unsafe trait VertexDefinition { pub unsafe trait VertexDefinition {

View File

@ -1132,13 +1132,12 @@ impl Counter {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::PipelineLayout;
use crate::{ use crate::{
pipeline::layout::{PipelineLayoutCreateInfo, PushConstantRange}, pipeline::layout::{PipelineLayoutCreateInfo, PushConstantRange},
shader::ShaderStages, shader::ShaderStages,
}; };
use super::PipelineLayout;
#[test] #[test]
fn push_constant_ranges_disjoint() { fn push_constant_ranges_disjoint() {
let test_cases = [ let test_cases = [

View File

@ -17,9 +17,7 @@
//! the CPU). Consequently it is a CPU-intensive operation that should be performed at //! the CPU). Consequently it is a CPU-intensive operation that should be performed at
//! initialization or during a loading screen. //! initialization or during a loading screen.
pub use self::compute::ComputePipeline; pub use self::{compute::ComputePipeline, graphics::GraphicsPipeline, layout::PipelineLayout};
pub use self::graphics::GraphicsPipeline;
pub use self::layout::PipelineLayout;
use crate::device::DeviceOwned; use crate::device::DeviceOwned;
use std::sync::Arc; use std::sync::Arc;

View File

@ -759,10 +759,7 @@ impl From<QueryResultFlags> for ash::vk::QueryResultFlags {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::QueryPoolCreateInfo; use super::QueryPoolCreateInfo;
use crate::query::QueryPipelineStatisticFlags; use crate::query::{QueryPipelineStatisticFlags, QueryPool, QueryPoolCreationError, QueryType};
use crate::query::QueryPool;
use crate::query::QueryPoolCreationError;
use crate::query::QueryType;
#[test] #[test]
fn pipeline_statistics_feature() { fn pipeline_statistics_feature() {

View File

@ -1,10 +1,11 @@
use std::cmp; use std::{
use std::cmp::Ordering; cmp,
use std::collections::{btree_map, BTreeMap}; cmp::Ordering,
use std::fmt::{self, Debug}; collections::{btree_map, BTreeMap},
use std::iter::{FromIterator, FusedIterator, Peekable}; fmt::{self, Debug},
use std::ops::Bound; iter::{FromIterator, FusedIterator, Peekable},
use std::ops::{Add, Range, Sub}; ops::{Add, Bound, Range, Sub},
};
/// A map whose keys are stored as (half-open) ranges bounded /// A map whose keys are stored as (half-open) ranges bounded
/// inclusively below and exclusively above `(start..end)`. /// inclusively below and exclusively above `(start..end)`.

View File

@ -724,13 +724,11 @@ impl From<Error> for FramebufferCreationError {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::format::Format; use crate::{
use crate::image::attachment::AttachmentImage; format::Format,
use crate::image::view::ImageView; image::{attachment::AttachmentImage, view::ImageView},
use crate::render_pass::Framebuffer; render_pass::{Framebuffer, FramebufferCreateInfo, FramebufferCreationError, RenderPass},
use crate::render_pass::FramebufferCreateInfo; };
use crate::render_pass::FramebufferCreationError;
use crate::render_pass::RenderPass;
#[test] #[test]
fn simple_create() { fn simple_create() {

View File

@ -25,10 +25,10 @@
//! Consequently you can create graphics pipelines from a render pass object alone. //! Consequently you can create graphics pipelines from a render pass object alone.
//! A `Framebuffer` object is only needed when you actually add draw commands to a command buffer. //! A `Framebuffer` object is only needed when you actually add draw commands to a command buffer.
pub use self::create::RenderPassCreationError; pub use self::{
pub use self::framebuffer::Framebuffer; create::RenderPassCreationError,
pub use self::framebuffer::FramebufferCreateInfo; framebuffer::{Framebuffer, FramebufferCreateInfo, FramebufferCreationError},
pub use self::framebuffer::FramebufferCreationError; };
use crate::{ use crate::{
device::{Device, DeviceOwned}, device::{Device, DeviceOwned},
format::Format, format::Format,
@ -37,8 +37,8 @@ use crate::{
sync::{AccessFlags, PipelineStages}, sync::{AccessFlags, PipelineStages},
Version, VulkanObject, Version, VulkanObject,
}; };
use std::cmp::max;
use std::{ use std::{
cmp::max,
hash::{Hash, Hasher}, hash::{Hash, Hasher},
mem::MaybeUninit, mem::MaybeUninit,
ptr, ptr,
@ -1228,9 +1228,10 @@ impl From<ash::vk::ResolveModeFlags> for ResolveModes {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::format::Format; use crate::{
use crate::render_pass::RenderPass; format::Format,
use crate::render_pass::RenderPassCreationError; render_pass::{RenderPass, RenderPassCreationError},
};
#[test] #[test]
fn empty() { fn empty() {

View File

@ -17,32 +17,31 @@
//! code. You are encouraged to use the `vulkano-shaders` crate that will generate Rust code that //! code. You are encouraged to use the `vulkano-shaders` crate that will generate Rust code that
//! wraps around vulkano's shaders API. //! wraps around vulkano's shaders API.
use crate::check_errors; use crate::{
use crate::descriptor_set::layout::DescriptorType; check_errors,
use crate::device::Device; descriptor_set::layout::DescriptorType,
use crate::format::{Format, NumericType}; device::Device,
use crate::image::view::ImageViewType; format::{Format, NumericType},
use crate::pipeline::graphics::input_assembly::PrimitiveTopology; image::view::ImageViewType,
use crate::pipeline::layout::PushConstantRange; pipeline::{graphics::input_assembly::PrimitiveTopology, layout::PushConstantRange},
use crate::shader::spirv::{Capability, Spirv, SpirvError}; shader::spirv::{Capability, Spirv, SpirvError},
use crate::sync::PipelineStages; sync::PipelineStages,
use crate::DeviceSize; DeviceSize, OomError, Version, VulkanObject,
use crate::OomError; };
use crate::Version; use std::{
use crate::VulkanObject; borrow::Cow,
use std::borrow::Cow; collections::{HashMap, HashSet},
use std::collections::{HashMap, HashSet}; error,
use std::error; error::Error,
use std::error::Error; ffi::{CStr, CString},
use std::ffi::CStr; fmt,
use std::ffi::CString; fmt::Display,
use std::fmt; mem,
use std::fmt::Display; mem::MaybeUninit,
use std::mem; ops::BitOr,
use std::mem::MaybeUninit; ptr,
use std::ops::BitOr; sync::Arc,
use std::ptr; };
use std::sync::Arc;
pub mod reflect; pub mod reflect;
pub mod spirv; pub mod spirv;

View File

@ -9,11 +9,9 @@
//! Extraction of information from SPIR-V modules, that is needed by the rest of Vulkano. //! Extraction of information from SPIR-V modules, that is needed by the rest of Vulkano.
use crate::descriptor_set::layout::DescriptorType;
use crate::image::view::ImageViewType;
use crate::shader::ShaderScalarType;
use crate::DeviceSize;
use crate::{ use crate::{
descriptor_set::layout::DescriptorType,
image::view::ImageViewType,
pipeline::layout::PushConstantRange, pipeline::layout::PushConstantRange,
shader::{ shader::{
spirv::{ spirv::{
@ -22,11 +20,15 @@ use crate::{
}, },
DescriptorIdentifier, DescriptorRequirements, EntryPointInfo, GeometryShaderExecution, DescriptorIdentifier, DescriptorRequirements, EntryPointInfo, GeometryShaderExecution,
GeometryShaderInput, ShaderExecution, ShaderInterface, ShaderInterfaceEntry, GeometryShaderInput, ShaderExecution, ShaderInterface, ShaderInterfaceEntry,
ShaderInterfaceEntryType, ShaderStage, SpecializationConstantRequirements, ShaderInterfaceEntryType, ShaderScalarType, ShaderStage,
SpecializationConstantRequirements,
}, },
DeviceSize,
};
use std::{
borrow::Cow,
collections::{HashMap, HashSet},
}; };
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
/// Returns an iterator of the capabilities used by `spirv`. /// Returns an iterator of the capabilities used by `spirv`.
pub fn spirv_capabilities<'a>(spirv: &'a Spirv) -> impl Iterator<Item = &'a Capability> { pub fn spirv_capabilities<'a>(spirv: &'a Spirv) -> impl Iterator<Item = &'a Capability> {

View File

@ -28,18 +28,11 @@
#![allow(dead_code)] // TODO: this module isn't finished #![allow(dead_code)] // TODO: this module isn't finished
#![allow(unused_variables)] // TODO: this module isn't finished #![allow(unused_variables)] // TODO: this module isn't finished
use crate::check_errors; use crate::{
use crate::device::physical::PhysicalDevice; check_errors, device::physical::PhysicalDevice, instance::Instance,
use crate::instance::Instance; swapchain::SupportedSurfaceTransforms, OomError, Success, VulkanObject,
use crate::swapchain::SupportedSurfaceTransforms; };
use crate::OomError; use std::{ffi::CStr, fmt, fmt::Formatter, ptr, sync::Arc, vec::IntoIter};
use crate::Success;
use crate::VulkanObject;
use std::ffi::CStr;
use std::fmt::Formatter;
use std::sync::Arc;
use std::vec::IntoIter;
use std::{fmt, ptr};
// TODO: extract this to a `display` module and solve the visibility problems // TODO: extract this to a `display` module and solve the visibility problems

View File

@ -317,33 +317,19 @@
//! ``` //! ```
//! //!
pub use self::present_region::PresentRegion; pub use self::{
pub use self::present_region::RectangleLayer; present_region::{PresentRegion, RectangleLayer},
pub use self::surface::ColorSpace; surface::{
pub use self::surface::CompositeAlpha; ColorSpace, CompositeAlpha, PresentMode, SupportedCompositeAlpha,
pub use self::surface::PresentMode; SupportedSurfaceTransforms, Surface, SurfaceApi, SurfaceCapabilities, SurfaceCreationError,
pub use self::surface::SupportedCompositeAlpha; SurfaceInfo, SurfaceTransform,
pub use self::surface::SupportedSurfaceTransforms; },
pub use self::surface::Surface; swapchain::{
pub use self::surface::SurfaceApi; acquire_next_image, acquire_next_image_raw, present, present_incremental, AcquireError,
pub use self::surface::SurfaceCapabilities; AcquiredImage, FullScreenExclusive, FullScreenExclusiveError, PresentFuture, Swapchain,
pub use self::surface::SurfaceCreationError; SwapchainAcquireFuture, SwapchainCreateInfo, SwapchainCreationError, Win32Monitor,
pub use self::surface::SurfaceInfo; },
pub use self::surface::SurfaceTransform; };
pub use self::swapchain::acquire_next_image;
pub use self::swapchain::acquire_next_image_raw;
pub use self::swapchain::present;
pub use self::swapchain::present_incremental;
pub use self::swapchain::AcquireError;
pub use self::swapchain::AcquiredImage;
pub use self::swapchain::FullScreenExclusive;
pub use self::swapchain::FullScreenExclusiveError;
pub use self::swapchain::PresentFuture;
pub use self::swapchain::Swapchain;
pub use self::swapchain::SwapchainAcquireFuture;
pub use self::swapchain::SwapchainCreateInfo;
pub use self::swapchain::SwapchainCreationError;
pub use self::swapchain::Win32Monitor;
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
pub mod display; pub mod display;

View File

@ -7,25 +7,25 @@
// notice may not be copied, modified, or distributed except // notice may not be copied, modified, or distributed except
// according to those terms. // according to those terms.
use super::FullScreenExclusive; use super::{FullScreenExclusive, Win32Monitor};
use super::Win32Monitor; use crate::{
use crate::check_errors; check_errors,
use crate::image::ImageUsage; image::ImageUsage,
use crate::instance::Instance; instance::Instance,
use crate::swapchain::display::DisplayMode; swapchain::{
use crate::swapchain::display::DisplayPlane; display::{DisplayMode, DisplayPlane},
use crate::swapchain::SurfaceSwapchainLock; SurfaceSwapchainLock,
use crate::Error; },
use crate::OomError; Error, OomError, VulkanObject,
use crate::VulkanObject; };
use std::error; use std::{
use std::fmt; error, fmt,
use std::hash::{Hash, Hasher}; hash::{Hash, Hasher},
use std::mem::MaybeUninit; mem::MaybeUninit,
use std::os::raw::c_ulong; os::raw::c_ulong,
use std::ptr; ptr,
use std::sync::atomic::AtomicBool; sync::{atomic::AtomicBool, Arc},
use std::sync::Arc; };
/// Represents a surface on the screen. /// Represents a surface on the screen.
/// ///
@ -1272,8 +1272,7 @@ pub struct SurfaceCapabilities {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::swapchain::Surface; use crate::swapchain::{Surface, SurfaceCreationError};
use crate::swapchain::SurfaceCreationError;
use std::ptr; use std::ptr;
#[test] #[test]

View File

@ -239,8 +239,7 @@ impl Default for EventCreateInfo {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::sync::Event; use crate::{sync::Event, VulkanObject};
use crate::VulkanObject;
#[test] #[test]
fn event_create() { fn event_create() {

View File

@ -447,9 +447,10 @@ impl From<Error> for FenceWaitError {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::sync::fence::FenceCreateInfo; use crate::{
use crate::sync::Fence; sync::{fence::FenceCreateInfo, Fence},
use crate::VulkanObject; VulkanObject,
};
use std::time::Duration; use std::time::Duration;
#[test] #[test]

View File

@ -103,9 +103,6 @@
//! TODO: talk about fence + semaphore simultaneously //! TODO: talk about fence + semaphore simultaneously
//! TODO: talk about using fences to clean up //! TODO: talk about using fences to clean up
use crate::device::Queue;
use std::sync::Arc;
pub use self::{ pub use self::{
event::{Event, EventCreateInfo}, event::{Event, EventCreateInfo},
fence::{Fence, FenceCreateInfo, FenceWaitError}, fence::{Fence, FenceCreateInfo, FenceWaitError},
@ -122,6 +119,8 @@ pub use self::{
ExternalSemaphoreProperties, Semaphore, SemaphoreCreateInfo, SemaphoreCreationError, ExternalSemaphoreProperties, Semaphore, SemaphoreCreateInfo, SemaphoreCreationError,
}, },
}; };
use crate::device::Queue;
use std::sync::Arc;
mod event; mod event;
mod fence; mod fence;