mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 00:04:15 +00:00
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:
parent
72dcbc1a28
commit
c4a960d67b
2
.rustfmt.toml
Normal file
2
.rustfmt.toml
Normal file
@ -0,0 +1,2 @@
|
||||
# imports_granularity = "Crate"
|
||||
# group_imports = "One"
|
@ -25,7 +25,7 @@ use crate::{
|
||||
memory::{
|
||||
pool::{
|
||||
AllocFromRequirementsFilter, AllocLayout, MappingRequirement, MemoryPoolAlloc,
|
||||
PotentialDedicatedAllocation, StdMemoryPoolAlloc,
|
||||
PotentialDedicatedAllocation, StandardMemoryPoolAlloc,
|
||||
},
|
||||
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
|
||||
/// the cpu needs to read data coming off the GPU.
|
||||
#[derive(Debug)]
|
||||
pub struct CpuAccessibleBuffer<T, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>>
|
||||
pub struct CpuAccessibleBuffer<T, A = PotentialDedicatedAllocation<StandardMemoryPoolAlloc>>
|
||||
where
|
||||
T: BufferContents + ?Sized,
|
||||
{
|
||||
@ -252,7 +252,7 @@ where
|
||||
let mem_reqs = buffer.memory_requirements();
|
||||
|
||||
let memory = MemoryPool::alloc_from_requirements(
|
||||
&Device::standard_pool(&device),
|
||||
&device.standard_memory_pool(),
|
||||
&mem_reqs,
|
||||
AllocLayout::Linear,
|
||||
MappingRequirement::Map,
|
||||
|
@ -17,7 +17,7 @@ use crate::{
|
||||
memory::{
|
||||
pool::{
|
||||
AllocFromRequirementsFilter, AllocLayout, MappingRequirement, MemoryPoolAlloc,
|
||||
PotentialDedicatedAllocation, StdMemoryPool,
|
||||
PotentialDedicatedAllocation, StandardMemoryPool,
|
||||
},
|
||||
DedicatedAllocation, DeviceMemoryAllocationError, MemoryPool,
|
||||
},
|
||||
@ -91,7 +91,7 @@ use std::{
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
pub struct CpuBufferPool<T, A = Arc<StdMemoryPool>>
|
||||
pub struct CpuBufferPool<T, A = Arc<StandardMemoryPool>>
|
||||
where
|
||||
[T]: BufferContents,
|
||||
A: MemoryPool,
|
||||
@ -196,11 +196,11 @@ where
|
||||
#[inline]
|
||||
pub fn new(device: Arc<Device>, usage: BufferUsage) -> CpuBufferPool<T> {
|
||||
assert!(size_of::<T>() > 0);
|
||||
let pool = Device::standard_pool(&device);
|
||||
let pool = device.standard_memory_pool();
|
||||
|
||||
CpuBufferPool {
|
||||
device: device,
|
||||
pool: pool,
|
||||
device,
|
||||
pool,
|
||||
current_buffer: Mutex::new(None),
|
||||
usage: usage.clone(),
|
||||
marker: PhantomData,
|
||||
|
@ -28,7 +28,8 @@ use crate::{
|
||||
memory::{
|
||||
pool::{
|
||||
alloc_dedicated_with_exportable_fd, AllocFromRequirementsFilter, AllocLayout,
|
||||
MappingRequirement, MemoryPoolAlloc, PotentialDedicatedAllocation, StdMemoryPoolAlloc,
|
||||
MappingRequirement, MemoryPoolAlloc, PotentialDedicatedAllocation,
|
||||
StandardMemoryPoolAlloc,
|
||||
},
|
||||
DedicatedAllocation, DeviceMemoryAllocationError, DeviceMemoryExportError,
|
||||
ExternalMemoryHandleType, MemoryPool, MemoryRequirements,
|
||||
@ -122,7 +123,7 @@ use std::{
|
||||
/// ```
|
||||
///
|
||||
#[derive(Debug)]
|
||||
pub struct DeviceLocalBuffer<T, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>>
|
||||
pub struct DeviceLocalBuffer<T, A = PotentialDedicatedAllocation<StandardMemoryPoolAlloc>>
|
||||
where
|
||||
T: BufferContents + ?Sized,
|
||||
{
|
||||
@ -358,7 +359,7 @@ where
|
||||
let (buffer, mem_reqs) = Self::build_buffer(&device, size, usage, &queue_families)?;
|
||||
|
||||
let memory = MemoryPool::alloc_from_requirements(
|
||||
&Device::standard_pool(&device),
|
||||
&device.standard_memory_pool(),
|
||||
&mem_reqs,
|
||||
AllocLayout::Linear,
|
||||
MappingRequirement::DoNotMap,
|
||||
|
@ -28,11 +28,11 @@ use super::{
|
||||
cpu_access::{ReadLockError, WriteLockError},
|
||||
BufferUsage,
|
||||
};
|
||||
use crate::range_map::RangeMap;
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
memory::{DeviceMemory, DeviceMemoryAllocationError, MemoryRequirements},
|
||||
range_map::RangeMap,
|
||||
sync::{AccessError, CurrentAccess, Sharing},
|
||||
DeviceSize, Error, OomError, Version, VulkanObject,
|
||||
};
|
||||
@ -782,13 +782,10 @@ struct BufferRangeState {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::BufferCreationError;
|
||||
use super::BufferUsage;
|
||||
use super::SparseLevel;
|
||||
use super::UnsafeBuffer;
|
||||
use super::UnsafeBufferCreateInfo;
|
||||
use crate::device::Device;
|
||||
use crate::device::DeviceOwned;
|
||||
use super::{
|
||||
BufferCreationError, BufferUsage, SparseLevel, UnsafeBuffer, UnsafeBufferCreateInfo,
|
||||
};
|
||||
use crate::device::{Device, DeviceOwned};
|
||||
|
||||
#[test]
|
||||
fn create() {
|
||||
|
@ -462,9 +462,13 @@ impl Hash for dyn BufferViewAbstract {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::buffer::view::{BufferView, BufferViewCreateInfo, BufferViewCreationError};
|
||||
use crate::buffer::{BufferUsage, DeviceLocalBuffer};
|
||||
use crate::format::Format;
|
||||
use crate::{
|
||||
buffer::{
|
||||
view::{BufferView, BufferViewCreateInfo, BufferViewCreationError},
|
||||
BufferUsage, DeviceLocalBuffer,
|
||||
},
|
||||
format::Format,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn create_uniform() {
|
||||
|
@ -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)?
|
||||
.next()
|
||||
.expect("Requested one command buffer from the command pool, but got zero.");
|
||||
|
||||
let inner = SyncCommandBufferBuilder::new(pool_builder_alloc.inner(), begin_info)?;
|
||||
|
||||
Ok(AutoCommandBufferBuilder {
|
||||
@ -249,6 +251,7 @@ impl<L> AutoCommandBufferBuilder<L, StandardCommandPoolBuilder> {
|
||||
usage,
|
||||
_data: PhantomData,
|
||||
})
|
||||
})?
|
||||
}
|
||||
|
||||
fn validate_begin(
|
||||
|
@ -89,11 +89,18 @@
|
||||
//! alternative command pool implementations and use them. See the `pool` module for more
|
||||
//! information.
|
||||
|
||||
pub use self::commands::{
|
||||
pub use self::{
|
||||
auto::{
|
||||
AutoCommandBufferBuilder, AutoCommandBufferBuilderContextError, BuildError,
|
||||
CommandBufferBeginError, DispatchError, DispatchIndirectError, DrawError, DrawIndexedError,
|
||||
DrawIndexedIndirectError, DrawIndirectError, PrimaryAutoCommandBuffer,
|
||||
SecondaryAutoCommandBuffer,
|
||||
},
|
||||
commands::{
|
||||
debug::DebugUtilsError,
|
||||
image::{
|
||||
BlitImageInfo, ClearColorImageInfo, ClearDepthStencilImageInfo, ImageBlit, ImageResolve,
|
||||
ResolveImageInfo,
|
||||
BlitImageInfo, ClearColorImageInfo, ClearDepthStencilImageInfo, ImageBlit,
|
||||
ImageResolve, ResolveImageInfo,
|
||||
},
|
||||
pipeline::{
|
||||
CheckDescriptorSetsValidityError, CheckDispatchError, CheckDynamicStateValidityError,
|
||||
@ -102,22 +109,15 @@ pub use self::commands::{
|
||||
},
|
||||
query::QueryError,
|
||||
render_pass::{
|
||||
ClearAttachment, ClearRect, RenderPassBeginInfo, RenderPassError, RenderingAttachmentInfo,
|
||||
RenderingAttachmentResolveInfo, RenderingInfo,
|
||||
ClearAttachment, ClearRect, RenderPassBeginInfo, RenderPassError,
|
||||
RenderingAttachmentInfo, RenderingAttachmentResolveInfo, RenderingInfo,
|
||||
},
|
||||
secondary::{ExecuteCommandsError, UnsafeCommandBufferBuilderExecuteCommands},
|
||||
transfer::{
|
||||
BufferCopy, BufferImageCopy, CopyBufferInfo, CopyBufferInfoTyped, CopyBufferToImageInfo,
|
||||
CopyImageInfo, CopyImageToBufferInfo, FillBufferInfo, ImageCopy,
|
||||
BufferCopy, BufferImageCopy, CopyBufferInfo, CopyBufferInfoTyped,
|
||||
CopyBufferToImageInfo, CopyImageInfo, CopyImageToBufferInfo, FillBufferInfo, ImageCopy,
|
||||
},
|
||||
CopyError, CopyErrorResource,
|
||||
};
|
||||
pub use self::{
|
||||
auto::{
|
||||
AutoCommandBufferBuilder, AutoCommandBufferBuilderContextError, BuildError,
|
||||
CommandBufferBeginError, DispatchError, DispatchIndirectError, DrawError, DrawIndexedError,
|
||||
DrawIndexedIndirectError, DrawIndirectError, PrimaryAutoCommandBuffer,
|
||||
SecondaryAutoCommandBuffer,
|
||||
},
|
||||
traits::{
|
||||
CommandBufferExecError, CommandBufferExecFuture, PrimaryCommandBuffer,
|
||||
|
@ -228,20 +228,21 @@ impl Drop for StandardCommandPoolAlloc {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
|
||||
use crate::command_buffer::pool::{CommandPool, CommandPoolBuilderAlloc};
|
||||
use crate::command_buffer::CommandBufferLevel;
|
||||
use crate::device::Device;
|
||||
use crate::VulkanObject;
|
||||
use crate::{
|
||||
command_buffer::{
|
||||
pool::{CommandPool, CommandPoolBuilderAlloc},
|
||||
CommandBufferLevel,
|
||||
},
|
||||
VulkanObject,
|
||||
};
|
||||
use std::{sync::Arc, thread};
|
||||
|
||||
#[test]
|
||||
fn reuse_command_buffers() {
|
||||
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
|
||||
.allocate(CommandBufferLevel::Primary, 1)
|
||||
.unwrap()
|
||||
@ -256,6 +257,8 @@ mod tests {
|
||||
.next()
|
||||
.unwrap();
|
||||
assert_eq!(raw, cb2.inner().internal_object());
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -265,13 +268,15 @@ mod tests {
|
||||
let thread = thread::spawn({
|
||||
let (device, queue) = (device.clone(), queue.clone());
|
||||
move || {
|
||||
let pool = Device::standard_command_pool(&device, queue.family()).unwrap();
|
||||
|
||||
device
|
||||
.with_standard_command_pool(queue.family(), |pool| {
|
||||
pool.allocate(CommandBufferLevel::Primary, 1)
|
||||
.unwrap()
|
||||
.next()
|
||||
.unwrap()
|
||||
.inner
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -7,22 +7,17 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use crate::buffer::sys::UnsafeBuffer;
|
||||
use crate::check_errors;
|
||||
use crate::device::Queue;
|
||||
use crate::image::sys::UnsafeImage;
|
||||
use crate::memory::DeviceMemory;
|
||||
use crate::sync::Fence;
|
||||
use crate::sync::Semaphore;
|
||||
use crate::DeviceSize;
|
||||
use crate::Error;
|
||||
use crate::OomError;
|
||||
use crate::SynchronizedVulkanObject;
|
||||
use crate::VulkanObject;
|
||||
use crate::{
|
||||
buffer::sys::UnsafeBuffer,
|
||||
check_errors,
|
||||
device::Queue,
|
||||
image::sys::UnsafeImage,
|
||||
memory::DeviceMemory,
|
||||
sync::{Fence, Semaphore},
|
||||
DeviceSize, Error, OomError, SynchronizedVulkanObject, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
use std::{error, fmt, marker::PhantomData};
|
||||
|
||||
// TODO: correctly implement Debug on all the structs of this module
|
||||
|
||||
|
@ -13,17 +13,16 @@
|
||||
//! 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.
|
||||
|
||||
pub use self::bind_sparse::SubmitBindSparseBatchBuilder;
|
||||
pub use self::bind_sparse::SubmitBindSparseBufferBindBuilder;
|
||||
pub use self::bind_sparse::SubmitBindSparseBuilder;
|
||||
pub use self::bind_sparse::SubmitBindSparseError;
|
||||
pub use self::bind_sparse::SubmitBindSparseImageBindBuilder;
|
||||
pub use self::bind_sparse::SubmitBindSparseImageOpaqueBindBuilder;
|
||||
pub use self::queue_present::SubmitPresentBuilder;
|
||||
pub use self::queue_present::SubmitPresentError;
|
||||
pub use self::queue_submit::SubmitCommandBufferBuilder;
|
||||
pub use self::queue_submit::SubmitCommandBufferError;
|
||||
pub use self::semaphores_wait::SubmitSemaphoresWaitBuilder;
|
||||
pub use self::{
|
||||
bind_sparse::{
|
||||
SubmitBindSparseBatchBuilder, SubmitBindSparseBufferBindBuilder, SubmitBindSparseBuilder,
|
||||
SubmitBindSparseError, SubmitBindSparseImageBindBuilder,
|
||||
SubmitBindSparseImageOpaqueBindBuilder,
|
||||
},
|
||||
queue_present::{SubmitPresentBuilder, SubmitPresentError},
|
||||
queue_submit::{SubmitCommandBufferBuilder, SubmitCommandBufferError},
|
||||
semaphores_wait::SubmitSemaphoresWaitBuilder,
|
||||
};
|
||||
|
||||
mod bind_sparse;
|
||||
mod queue_present;
|
||||
|
@ -7,23 +7,15 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{DeviceOwned, Queue},
|
||||
swapchain::{PresentRegion, Swapchain},
|
||||
sync::Semaphore,
|
||||
Error, OomError, SynchronizedVulkanObject, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::error;
|
||||
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;
|
||||
use std::{error, fmt, marker::PhantomData, ptr};
|
||||
|
||||
/// Prototype for a submission that presents a swapchain on the screen.
|
||||
// TODO: example here
|
||||
|
@ -7,20 +7,15 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use crate::check_errors;
|
||||
use crate::command_buffer::sys::UnsafeCommandBuffer;
|
||||
use crate::device::Queue;
|
||||
use crate::sync::Fence;
|
||||
use crate::sync::PipelineStages;
|
||||
use crate::sync::Semaphore;
|
||||
use crate::Error;
|
||||
use crate::OomError;
|
||||
use crate::SynchronizedVulkanObject;
|
||||
use crate::VulkanObject;
|
||||
use crate::{
|
||||
check_errors,
|
||||
command_buffer::sys::UnsafeCommandBuffer,
|
||||
device::Queue,
|
||||
sync::{Fence, PipelineStages, Semaphore},
|
||||
Error, OomError, SynchronizedVulkanObject, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
use std::{error, fmt, marker::PhantomData};
|
||||
|
||||
/// Prototype for a submission that executes command buffers.
|
||||
// TODO: example here
|
||||
|
@ -7,13 +7,12 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use crate::{
|
||||
command_buffer::submit::{SubmitCommandBufferBuilder, SubmitPresentBuilder},
|
||||
sync::{PipelineStages, Semaphore},
|
||||
};
|
||||
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.
|
||||
///
|
||||
/// This prototype can't actually be submitted because it doesn't correspond to anything in Vulkan.
|
||||
|
@ -14,7 +14,6 @@ pub use crate::command_buffer::commands::{
|
||||
},
|
||||
secondary::SyncCommandBufferBuilderExecuteCommands,
|
||||
};
|
||||
use crate::range_map::RangeMap;
|
||||
use crate::{
|
||||
buffer::{sys::UnsafeBuffer, BufferAccess},
|
||||
command_buffer::{
|
||||
@ -36,6 +35,7 @@ use crate::{
|
||||
},
|
||||
ComputePipeline, DynamicState, GraphicsPipeline, PipelineBindPoint, PipelineLayout,
|
||||
},
|
||||
range_map::RangeMap,
|
||||
range_set::RangeSet,
|
||||
sync::{
|
||||
AccessFlags, BufferMemoryBarrier, DependencyInfo, ImageMemoryBarrier, PipelineMemoryAccess,
|
||||
|
@ -74,11 +74,11 @@ use super::{
|
||||
sys::{UnsafeCommandBuffer, UnsafeCommandBufferBuilder},
|
||||
CommandBufferExecError,
|
||||
};
|
||||
use crate::range_map::RangeMap;
|
||||
use crate::{
|
||||
buffer::{sys::UnsafeBuffer, BufferAccess},
|
||||
device::{Device, DeviceOwned, Queue},
|
||||
image::{sys::UnsafeImage, ImageAccess, ImageLayout, ImageSubresourceRange},
|
||||
range_map::RangeMap,
|
||||
sync::{
|
||||
AccessCheckError, AccessError, AccessFlags, GpuFuture, PipelineMemoryAccess, PipelineStages,
|
||||
},
|
||||
@ -546,11 +546,13 @@ mod tests {
|
||||
unsafe {
|
||||
let (device, queue) = gfx_dev_and_queue!();
|
||||
|
||||
let pool = Device::standard_command_pool(&device, queue.family()).unwrap();
|
||||
let pool_builder_alloc = pool
|
||||
.allocate(CommandBufferLevel::Primary, 1)
|
||||
let pool_builder_alloc = device
|
||||
.with_standard_command_pool(queue.family(), |pool| {
|
||||
pool.allocate(CommandBufferLevel::Primary, 1)
|
||||
.unwrap()
|
||||
.next()
|
||||
.unwrap()
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
SyncCommandBufferBuilder::new(
|
||||
@ -599,11 +601,13 @@ mod tests {
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let pool = Device::standard_command_pool(&device, queue.family()).unwrap();
|
||||
let allocs = pool
|
||||
.allocate(CommandBufferLevel::Primary, 2)
|
||||
let allocs = device
|
||||
.with_standard_command_pool(queue.family(), |pool| {
|
||||
pool.allocate(CommandBufferLevel::Primary, 2)
|
||||
.unwrap()
|
||||
.collect::<Vec<_>>();
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
{
|
||||
let mut builder = SyncCommandBufferBuilder::new(
|
||||
@ -659,11 +663,13 @@ mod tests {
|
||||
unsafe {
|
||||
let (device, queue) = gfx_dev_and_queue!();
|
||||
|
||||
let pool = Device::standard_command_pool(&device, queue.family()).unwrap();
|
||||
let pool_builder_alloc = pool
|
||||
.allocate(CommandBufferLevel::Primary, 1)
|
||||
let pool_builder_alloc = device
|
||||
.with_standard_command_pool(queue.family(), |pool| {
|
||||
pool.allocate(CommandBufferLevel::Primary, 1)
|
||||
.unwrap()
|
||||
.next()
|
||||
.unwrap()
|
||||
})
|
||||
.unwrap();
|
||||
let mut sync = SyncCommandBufferBuilder::new(
|
||||
&pool_builder_alloc.inner(),
|
||||
@ -690,11 +696,13 @@ mod tests {
|
||||
unsafe {
|
||||
let (device, queue) = gfx_dev_and_queue!();
|
||||
|
||||
let pool = Device::standard_command_pool(&device, queue.family()).unwrap();
|
||||
let pool_builder_alloc = pool
|
||||
.allocate(CommandBufferLevel::Primary, 1)
|
||||
let pool_builder_alloc = device
|
||||
.with_standard_command_pool(queue.family(), |pool| {
|
||||
pool.allocate(CommandBufferLevel::Primary, 1)
|
||||
.unwrap()
|
||||
.next()
|
||||
.unwrap()
|
||||
})
|
||||
.unwrap();
|
||||
let mut sync = SyncCommandBufferBuilder::new(
|
||||
&pool_builder_alloc.inner(),
|
||||
|
@ -848,11 +848,13 @@ impl From<DescriptorType> for ash::vk::DescriptorType {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::descriptor_set::layout::DescriptorSetLayout;
|
||||
use crate::descriptor_set::layout::DescriptorSetLayoutBinding;
|
||||
use crate::descriptor_set::layout::DescriptorSetLayoutCreateInfo;
|
||||
use crate::descriptor_set::layout::DescriptorType;
|
||||
use crate::shader::ShaderStages;
|
||||
use crate::{
|
||||
descriptor_set::layout::{
|
||||
DescriptorSetLayout, DescriptorSetLayoutBinding, DescriptorSetLayoutCreateInfo,
|
||||
DescriptorType,
|
||||
},
|
||||
shader::ShaderStages,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
|
@ -65,7 +65,7 @@
|
||||
//! - 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
|
||||
//! 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
|
||||
//! a safe way. A Vulkan descriptor set is inherently unsafe, so we need safe wrappers around
|
||||
//! them.
|
||||
@ -73,27 +73,29 @@
|
||||
//! - The `DescriptorSetsCollection` trait is implemented on collections of types that implement
|
||||
//! `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 use self::update::{DescriptorSetUpdateError, WriteDescriptorSet, WriteDescriptorSetElements};
|
||||
use crate::buffer::view::BufferViewAbstract;
|
||||
use crate::buffer::BufferAccess;
|
||||
use crate::descriptor_set::layout::DescriptorType;
|
||||
use crate::device::DeviceOwned;
|
||||
use crate::image::view::ImageViewAbstract;
|
||||
use crate::sampler::Sampler;
|
||||
use crate::OomError;
|
||||
use crate::VulkanObject;
|
||||
pub use self::{
|
||||
collection::DescriptorSetsCollection,
|
||||
persistent::PersistentDescriptorSet,
|
||||
single_layout_pool::SingleLayoutDescSetPool,
|
||||
update::{DescriptorSetUpdateError, WriteDescriptorSet, WriteDescriptorSetElements},
|
||||
};
|
||||
use self::{layout::DescriptorSetLayout, sys::UnsafeDescriptorSet};
|
||||
use crate::{
|
||||
buffer::{view::BufferViewAbstract, BufferAccess},
|
||||
descriptor_set::layout::DescriptorType,
|
||||
device::DeviceOwned,
|
||||
image::view::ImageViewAbstract,
|
||||
sampler::Sampler,
|
||||
OomError, VulkanObject,
|
||||
};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use std::collections::HashMap;
|
||||
use std::hash::Hash;
|
||||
use std::hash::Hasher;
|
||||
use std::ptr;
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
hash::{Hash, Hasher},
|
||||
ptr,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
mod collection;
|
||||
pub mod layout;
|
||||
|
@ -21,20 +21,23 @@
|
||||
//! # Example
|
||||
//! TODO:
|
||||
|
||||
use crate::descriptor_set::pool::standard::StdDescriptorPoolAlloc;
|
||||
use crate::descriptor_set::pool::{DescriptorPool, DescriptorPoolAlloc};
|
||||
use crate::descriptor_set::update::WriteDescriptorSet;
|
||||
use crate::descriptor_set::{
|
||||
use crate::{
|
||||
descriptor_set::{
|
||||
pool::{standard::StandardDescriptorPoolAlloc, DescriptorPool, DescriptorPoolAlloc},
|
||||
update::WriteDescriptorSet,
|
||||
DescriptorSet, DescriptorSetCreationError, DescriptorSetInner, DescriptorSetLayout,
|
||||
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.
|
||||
pub struct PersistentDescriptorSet<P = StdDescriptorPoolAlloc> {
|
||||
pub struct PersistentDescriptorSet<P = StandardDescriptorPoolAlloc> {
|
||||
alloc: P,
|
||||
inner: DescriptorSetInner,
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
//! A pool from which descriptor sets can be allocated.
|
||||
|
||||
pub use self::{
|
||||
standard::StdDescriptorPool,
|
||||
standard::StandardDescriptorPool,
|
||||
sys::{
|
||||
DescriptorPoolAllocError, DescriptorSetAllocateInfo, UnsafeDescriptorPool,
|
||||
UnsafeDescriptorPoolCreateInfo,
|
||||
|
@ -20,15 +20,14 @@ use crate::{
|
||||
device::{Device, DeviceOwned},
|
||||
OomError,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
/// Standard implementation of a descriptor pool.
|
||||
///
|
||||
/// Interally, this implementation uses one [`SingleLayoutDescSetPool`] /
|
||||
/// [`SingleLayoutVariableDescSetPool`] per descriptor set layout.
|
||||
#[derive(Debug)]
|
||||
pub struct StdDescriptorPool {
|
||||
pub struct StandardDescriptorPool {
|
||||
device: Arc<Device>,
|
||||
pools: HashMap<Arc<DescriptorSetLayout>, Pool>,
|
||||
}
|
||||
@ -39,24 +38,24 @@ enum Pool {
|
||||
Variable(SingleLayoutVariableDescSetPool),
|
||||
}
|
||||
|
||||
impl StdDescriptorPool {
|
||||
/// Builds a new `StdDescriptorPool`.
|
||||
pub fn new(device: Arc<Device>) -> StdDescriptorPool {
|
||||
StdDescriptorPool {
|
||||
impl StandardDescriptorPool {
|
||||
/// Builds a new `StandardDescriptorPool`.
|
||||
pub fn new(device: Arc<Device>) -> StandardDescriptorPool {
|
||||
StandardDescriptorPool {
|
||||
device,
|
||||
pools: HashMap::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl DescriptorPool for StdDescriptorPool {
|
||||
type Alloc = StdDescriptorPoolAlloc;
|
||||
unsafe impl DescriptorPool for StandardDescriptorPool {
|
||||
type Alloc = StandardDescriptorPoolAlloc;
|
||||
|
||||
fn allocate(
|
||||
&mut self,
|
||||
layout: &Arc<DescriptorSetLayout>,
|
||||
variable_descriptor_count: u32,
|
||||
) -> Result<StdDescriptorPoolAlloc, OomError> {
|
||||
) -> Result<StandardDescriptorPoolAlloc, OomError> {
|
||||
assert!(
|
||||
!layout.push_descriptor(),
|
||||
"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]
|
||||
fn device(&self) -> &Arc<Device> {
|
||||
&self.device
|
||||
}
|
||||
}
|
||||
|
||||
/// A descriptor set allocated from a `StdDescriptorPool`.
|
||||
/// A descriptor set allocated from a `StandardDescriptorPool`.
|
||||
#[derive(Debug)]
|
||||
pub struct StdDescriptorPoolAlloc {
|
||||
pub struct StandardDescriptorPoolAlloc {
|
||||
// The actual descriptor alloc.
|
||||
inner: PoolAlloc,
|
||||
}
|
||||
@ -118,7 +117,7 @@ enum PoolAlloc {
|
||||
Variable(SingleLayoutVariablePoolAlloc),
|
||||
}
|
||||
|
||||
impl DescriptorPoolAlloc for StdDescriptorPoolAlloc {
|
||||
impl DescriptorPoolAlloc for StandardDescriptorPoolAlloc {
|
||||
#[inline]
|
||||
fn inner(&self) -> &UnsafeDescriptorSet {
|
||||
match &self.inner {
|
||||
|
@ -37,9 +37,9 @@ const MAX_POOLS: usize = 32;
|
||||
/// `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
|
||||
/// 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)]
|
||||
pub struct SingleLayoutDescSetPool {
|
||||
// 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
|
||||
/// 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
|
||||
/// purpose pool see [`StdDescriptorPool`].
|
||||
/// purpose pool see [`StandardDescriptorPool`].
|
||||
///
|
||||
/// [`StdDescriptorPool`]: super::pool::standard::StdDescriptorPool
|
||||
/// [`StandardDescriptorPool`]: super::pool::standard::StandardDescriptorPool
|
||||
#[derive(Debug)]
|
||||
pub struct SingleLayoutVariableDescSetPool {
|
||||
// The `SingleLayoutVariablePool` struct contains an actual Vulkan pool. Every time it is full
|
||||
|
@ -9,13 +9,16 @@
|
||||
|
||||
//! Low-level descriptor set.
|
||||
|
||||
use crate::descriptor_set::layout::DescriptorSetLayout;
|
||||
use crate::descriptor_set::update::{DescriptorWriteInfo, WriteDescriptorSet};
|
||||
use crate::device::DeviceOwned;
|
||||
use crate::VulkanObject;
|
||||
use crate::{
|
||||
descriptor_set::{
|
||||
layout::DescriptorSetLayout,
|
||||
update::{DescriptorWriteInfo, WriteDescriptorSet},
|
||||
},
|
||||
device::DeviceOwned,
|
||||
VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::fmt;
|
||||
use std::ptr;
|
||||
use std::{fmt, ptr};
|
||||
|
||||
/// Low-level descriptor set.
|
||||
///
|
||||
|
@ -8,10 +8,11 @@
|
||||
// according to those terms.
|
||||
|
||||
pub use crate::extensions::{ExtensionRestriction, ExtensionRestrictionError, OneOfRequirements};
|
||||
use crate::instance::InstanceExtensions;
|
||||
use crate::Version;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::fmt::Formatter;
|
||||
use crate::{instance::InstanceExtensions, Version};
|
||||
use std::{
|
||||
ffi::{CStr, CString},
|
||||
fmt::Formatter,
|
||||
};
|
||||
|
||||
// Generated by build.rs
|
||||
include!(concat!(env!("OUT_DIR"), "/device_extensions.rs"));
|
||||
|
@ -7,11 +7,8 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use crate::device::DeviceExtensions;
|
||||
use crate::instance::InstanceExtensions;
|
||||
use crate::Version;
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
use crate::{device::DeviceExtensions, instance::InstanceExtensions, Version};
|
||||
use std::{error, fmt};
|
||||
|
||||
// Generated by build.rs
|
||||
include!(concat!(env!("OUT_DIR"), "/features.rs"));
|
||||
|
@ -105,9 +105,9 @@ pub use self::{
|
||||
use crate::{
|
||||
check_errors,
|
||||
command_buffer::pool::StandardCommandPool,
|
||||
descriptor_set::pool::StdDescriptorPool,
|
||||
descriptor_set::pool::StandardDescriptorPool,
|
||||
instance::{debug::DebugUtilsLabel, Instance},
|
||||
memory::{pool::StdMemoryPool, ExternalMemoryHandleType},
|
||||
memory::{pool::StandardMemoryPool, ExternalMemoryHandleType},
|
||||
Error, OomError, SynchronizedVulkanObject, Version, VulkanObject,
|
||||
};
|
||||
pub use crate::{
|
||||
@ -148,7 +148,7 @@ pub struct Device {
|
||||
api_version: Version,
|
||||
|
||||
fns: DeviceFunctions,
|
||||
standard_pool: Mutex<Weak<StdMemoryPool>>,
|
||||
standard_pool: Mutex<Weak<StandardMemoryPool>>,
|
||||
enabled_extensions: DeviceExtensions,
|
||||
enabled_features: Features,
|
||||
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.
|
||||
pub fn standard_pool(me: &Arc<Self>) -> Arc<StdMemoryPool> {
|
||||
let mut pool = me.standard_pool.lock().unwrap();
|
||||
pub fn standard_memory_pool(self: &Arc<Self>) -> Arc<StandardMemoryPool> {
|
||||
let mut pool = self.standard_pool.lock().unwrap();
|
||||
|
||||
if let Some(p) = pool.upgrade() {
|
||||
return p;
|
||||
}
|
||||
|
||||
// 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);
|
||||
new_pool
|
||||
}
|
||||
@ -529,11 +529,11 @@ impl Device {
|
||||
///
|
||||
/// - Panics if called again from within the callback.
|
||||
pub fn with_standard_descriptor_pool<T>(
|
||||
self: &Arc<Device>,
|
||||
f: impl FnOnce(&mut StdDescriptorPool) -> T,
|
||||
self: &Arc<Self>,
|
||||
f: impl FnOnce(&mut StandardDescriptorPool) -> T,
|
||||
) -> T {
|
||||
thread_local! {
|
||||
static TLS: RefCell<HashMap<ash::vk::Device, StdDescriptorPool>> =
|
||||
static TLS: RefCell<HashMap<ash::vk::Device, StandardDescriptorPool>> =
|
||||
RefCell::new(HashMap::default());
|
||||
}
|
||||
|
||||
@ -541,15 +541,15 @@ impl Device {
|
||||
let mut tls = tls.borrow_mut();
|
||||
let pool = match tls.entry(self.internal_object()) {
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the standard command buffer pool used by default if you don't provide any other
|
||||
/// pool.
|
||||
/// Gives you access to the standard command buffer pool used by default if you don't provide
|
||||
/// any other pool.
|
||||
///
|
||||
/// 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.
|
||||
@ -559,10 +559,12 @@ impl Device {
|
||||
/// # Panics
|
||||
///
|
||||
/// - Panics if the device and the queue family don't belong to the same physical device.
|
||||
pub fn standard_command_pool(
|
||||
me: &Arc<Self>,
|
||||
/// - Panics if called again from within the callback.
|
||||
pub fn with_standard_command_pool<T>(
|
||||
self: &Arc<Self>,
|
||||
queue_family: QueueFamily,
|
||||
) -> Result<Arc<StandardCommandPool>, OomError> {
|
||||
f: impl FnOnce(&Arc<StandardCommandPool>) -> T,
|
||||
) -> Result<T, OomError> {
|
||||
thread_local! {
|
||||
static TLS: RefCell<HashMap<(ash::vk::Device, u32), Arc<StandardCommandPool>>> =
|
||||
RefCell::new(Default::default());
|
||||
@ -570,15 +572,15 @@ impl Device {
|
||||
|
||||
TLS.with(|tls| {
|
||||
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::Vacant(entry) => entry.insert(Arc::new(StandardCommandPool::new(
|
||||
me.clone(),
|
||||
self.clone(),
|
||||
queue_family,
|
||||
)?)),
|
||||
};
|
||||
|
||||
Ok(per_family.clone())
|
||||
Ok(f(pool))
|
||||
})
|
||||
}
|
||||
|
||||
@ -1222,9 +1224,10 @@ impl fmt::Display for DebugUtilsError {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::device::physical::PhysicalDevice;
|
||||
use crate::device::{Device, DeviceCreateInfo, DeviceCreationError, QueueCreateInfo};
|
||||
use crate::device::{FeatureRestriction, FeatureRestrictionError, Features};
|
||||
use crate::device::{
|
||||
physical::PhysicalDevice, Device, DeviceCreateInfo, DeviceCreationError,
|
||||
FeatureRestriction, FeatureRestrictionError, Features, QueueCreateInfo,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[test]
|
||||
|
@ -1,16 +1,18 @@
|
||||
use crate::device::physical::{
|
||||
ConformanceVersion, DriverId, PhysicalDeviceType, PointClippingBehavior, ShaderCoreProperties,
|
||||
ShaderFloatControlsIndependence, SubgroupFeatures,
|
||||
use crate::{
|
||||
device::{
|
||||
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 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;
|
||||
use std::{ffi::CStr, os::raw::c_char};
|
||||
|
||||
// Generated by build.rs
|
||||
include!(concat!(env!("OUT_DIR"), "/properties.rs"));
|
||||
|
@ -8,8 +8,10 @@
|
||||
// according to those terms.
|
||||
|
||||
use crate::Version;
|
||||
use std::error;
|
||||
use std::fmt::{Display, Error as FmtError, Formatter};
|
||||
use std::{
|
||||
error,
|
||||
fmt::{Display, Error as FmtError, Formatter},
|
||||
};
|
||||
|
||||
/// An error that can happen when enabling an extension on an instance or device.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
@ -18,7 +18,8 @@ use crate::{
|
||||
memory::{
|
||||
pool::{
|
||||
alloc_dedicated_with_exportable_fd, AllocFromRequirementsFilter, AllocLayout,
|
||||
MappingRequirement, MemoryPoolAlloc, PotentialDedicatedAllocation, StdMemoryPoolAlloc,
|
||||
MappingRequirement, MemoryPoolAlloc, PotentialDedicatedAllocation,
|
||||
StandardMemoryPoolAlloc,
|
||||
},
|
||||
DedicatedAllocation, DeviceMemoryExportError, ExternalMemoryHandleType,
|
||||
ExternalMemoryHandleTypes, MemoryPool,
|
||||
@ -64,7 +65,7 @@ use std::{
|
||||
///
|
||||
// TODO: forbid reading transient images outside render passes?
|
||||
#[derive(Debug)]
|
||||
pub struct AttachmentImage<A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> {
|
||||
pub struct AttachmentImage<A = PotentialDedicatedAllocation<StandardMemoryPoolAlloc>> {
|
||||
// Inner implementation.
|
||||
image: Arc<UnsafeImage>,
|
||||
|
||||
@ -442,7 +443,7 @@ impl AttachmentImage {
|
||||
|
||||
let mem_reqs = image.memory_requirements();
|
||||
let memory = MemoryPool::alloc_from_requirements(
|
||||
&Device::standard_pool(&device),
|
||||
&device.standard_memory_pool(),
|
||||
&mem_reqs,
|
||||
AllocLayout::Optimal,
|
||||
MappingRequirement::DoNotMap,
|
||||
|
@ -25,7 +25,7 @@ use crate::{
|
||||
memory::{
|
||||
pool::{
|
||||
AllocFromRequirementsFilter, AllocLayout, MappingRequirement, MemoryPoolAlloc,
|
||||
PotentialDedicatedAllocation, StdMemoryPoolAlloc,
|
||||
PotentialDedicatedAllocation, StandardMemoryPoolAlloc,
|
||||
},
|
||||
DedicatedAllocation, DeviceMemoryAllocationError, MemoryPool,
|
||||
},
|
||||
@ -45,7 +45,7 @@ use std::{
|
||||
/// but then you must only ever read from it.
|
||||
// TODO: type (2D, 3D, array, etc.) as template parameter
|
||||
#[derive(Debug)]
|
||||
pub struct ImmutableImage<A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> {
|
||||
pub struct ImmutableImage<A = PotentialDedicatedAllocation<StandardMemoryPoolAlloc>> {
|
||||
image: Arc<UnsafeImage>,
|
||||
dimensions: ImageDimensions,
|
||||
memory: A,
|
||||
@ -204,7 +204,7 @@ impl ImmutableImage {
|
||||
|
||||
let mem_reqs = image.memory_requirements();
|
||||
let memory = MemoryPool::alloc_from_requirements(
|
||||
&Device::standard_pool(&device),
|
||||
&device.standard_memory_pool(),
|
||||
&mem_reqs,
|
||||
AllocLayout::Optimal,
|
||||
MappingRequirement::DoNotMap,
|
||||
@ -411,7 +411,7 @@ where
|
||||
}
|
||||
|
||||
// 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>>,
|
||||
mip_levels_access: Range<u32>,
|
||||
array_layers_access: Range<u32>,
|
||||
|
@ -839,11 +839,10 @@ impl From<ash::vk::ImageFormatProperties> for ImageFormatProperties {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::format::Format;
|
||||
use crate::image::ImageAccess;
|
||||
use crate::image::ImageDimensions;
|
||||
use crate::image::ImmutableImage;
|
||||
use crate::image::MipmapsCount;
|
||||
use crate::{
|
||||
format::Format,
|
||||
image::{ImageAccess, ImageDimensions, ImmutableImage, MipmapsCount},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn max_mip_levels() {
|
||||
|
@ -11,16 +11,14 @@ use super::{
|
||||
sys::UnsafeImage, traits::ImageContent, ImageAccess, ImageCreateFlags, ImageCreationError,
|
||||
ImageDescriptorLayouts, ImageDimensions, ImageInner, ImageLayout, ImageUsage,
|
||||
};
|
||||
use crate::device::Queue;
|
||||
use crate::image::view::ImageView;
|
||||
use crate::{
|
||||
device::{physical::QueueFamily, Device, DeviceOwned},
|
||||
device::{physical::QueueFamily, Device, DeviceOwned, Queue},
|
||||
format::Format,
|
||||
image::sys::UnsafeImageCreateInfo,
|
||||
image::{sys::UnsafeImageCreateInfo, view::ImageView},
|
||||
memory::{
|
||||
pool::{
|
||||
alloc_dedicated_with_exportable_fd, AllocFromRequirementsFilter, AllocLayout,
|
||||
MappingRequirement, MemoryPoolAlloc, PotentialDedicatedAllocation, StdMemoryPool,
|
||||
MappingRequirement, MemoryPoolAlloc, PotentialDedicatedAllocation, StandardMemoryPool,
|
||||
},
|
||||
DedicatedAllocation, DeviceMemoryExportError, ExternalMemoryHandleType,
|
||||
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
|
||||
/// specialized image.
|
||||
#[derive(Debug)]
|
||||
pub struct StorageImage<A = Arc<StdMemoryPool>>
|
||||
pub struct StorageImage<A = Arc<StandardMemoryPool>>
|
||||
where
|
||||
A: MemoryPool,
|
||||
{
|
||||
@ -130,7 +128,7 @@ impl StorageImage {
|
||||
|
||||
let mem_reqs = image.memory_requirements();
|
||||
let memory = MemoryPool::alloc_from_requirements(
|
||||
&Device::standard_pool(&device),
|
||||
&device.standard_memory_pool(),
|
||||
&mem_reqs,
|
||||
AllocLayout::Optimal,
|
||||
MappingRequirement::DoNotMap,
|
||||
@ -352,9 +350,13 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::StorageImage;
|
||||
use crate::format::Format;
|
||||
use crate::image::view::ImageViewCreationError;
|
||||
use crate::image::{ImageAccess, ImageCreationError, ImageDimensions, ImageUsage};
|
||||
use crate::{
|
||||
format::Format,
|
||||
image::{
|
||||
view::ImageViewCreationError, ImageAccess, ImageCreationError, ImageDimensions,
|
||||
ImageUsage,
|
||||
},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn create() {
|
||||
|
@ -18,18 +18,17 @@ use super::{
|
||||
ImageSubresourceLayers, ImageSubresourceRange, ImageTiling, ImageUsage, SampleCount,
|
||||
SampleCounts,
|
||||
};
|
||||
use crate::image::view::ImageViewCreationError;
|
||||
use crate::range_map::RangeMap;
|
||||
use crate::{
|
||||
buffer::cpu_access::{ReadLockError, WriteLockError},
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
format::{ChromaSampling, Format, FormatFeatures, NumericType},
|
||||
image::{ImageFormatInfo, ImageFormatProperties, ImageType},
|
||||
image::{view::ImageViewCreationError, ImageFormatInfo, ImageFormatProperties, ImageType},
|
||||
memory::{
|
||||
DeviceMemory, DeviceMemoryAllocationError, ExternalMemoryHandleType,
|
||||
ExternalMemoryHandleTypes, MemoryRequirements,
|
||||
},
|
||||
range_map::RangeMap,
|
||||
sync::{AccessError, CurrentAccess, Sharing},
|
||||
DeviceSize, Error, OomError, Version, VulkanObject,
|
||||
};
|
||||
@ -2186,18 +2185,15 @@ impl FusedIterator for SubresourceRangeIterator {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ImageCreationError;
|
||||
use super::ImageUsage;
|
||||
use super::UnsafeImage;
|
||||
use super::UnsafeImageCreateInfo;
|
||||
use crate::format::Format;
|
||||
use crate::image::sys::SubresourceRangeIterator;
|
||||
use crate::image::ImageAspect;
|
||||
use crate::image::ImageAspects;
|
||||
use crate::image::ImageDimensions;
|
||||
use crate::image::ImageSubresourceRange;
|
||||
use crate::image::SampleCount;
|
||||
use crate::DeviceSize;
|
||||
use super::{ImageCreationError, ImageUsage, UnsafeImage, UnsafeImageCreateInfo};
|
||||
use crate::{
|
||||
format::Format,
|
||||
image::{
|
||||
sys::SubresourceRangeIterator, ImageAspect, ImageAspects, ImageDimensions,
|
||||
ImageSubresourceRange, SampleCount,
|
||||
},
|
||||
DeviceSize,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
#[test]
|
||||
|
@ -1476,9 +1476,10 @@ impl From<OomError> for MemoryMapError {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::MemoryAllocateInfo;
|
||||
use crate::memory::DeviceMemory;
|
||||
use crate::memory::DeviceMemoryAllocationError;
|
||||
use crate::OomError;
|
||||
use crate::{
|
||||
memory::{DeviceMemory, DeviceMemoryAllocationError},
|
||||
OomError,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn create() {
|
||||
|
@ -90,7 +90,7 @@
|
||||
//! 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
|
||||
//! 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::{
|
||||
device_memory::{
|
||||
|
@ -7,29 +7,31 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use crate::device::physical::MemoryType;
|
||||
use crate::device::Device;
|
||||
use crate::instance::Instance;
|
||||
use crate::memory::device_memory::MemoryAllocateInfo;
|
||||
use crate::memory::DeviceMemory;
|
||||
use crate::memory::DeviceMemoryAllocationError;
|
||||
use crate::memory::MappedDeviceMemory;
|
||||
use crate::DeviceSize;
|
||||
use std::cmp;
|
||||
use std::ops::Range;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use crate::{
|
||||
device::{physical::MemoryType, Device},
|
||||
instance::Instance,
|
||||
memory::{
|
||||
device_memory::MemoryAllocateInfo, DeviceMemory, DeviceMemoryAllocationError,
|
||||
MappedDeviceMemory,
|
||||
},
|
||||
DeviceSize,
|
||||
};
|
||||
use std::{
|
||||
cmp,
|
||||
ops::Range,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
/// Memory pool that operates on a given memory type.
|
||||
#[derive(Debug)]
|
||||
pub struct StdHostVisibleMemoryTypePool {
|
||||
pub struct StandardHostVisibleMemoryTypePool {
|
||||
device: Arc<Device>,
|
||||
memory_type: u32,
|
||||
// TODO: obviously very inefficient
|
||||
occupied: Mutex<Vec<(Arc<MappedDeviceMemory>, Vec<Range<DeviceSize>>)>>,
|
||||
}
|
||||
|
||||
impl StdHostVisibleMemoryTypePool {
|
||||
impl StandardHostVisibleMemoryTypePool {
|
||||
/// Creates a new pool that will operate on the given memory type.
|
||||
///
|
||||
/// # Panic
|
||||
@ -38,7 +40,10 @@ impl StdHostVisibleMemoryTypePool {
|
||||
/// - Panics if the memory type is not host-visible.
|
||||
///
|
||||
#[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!(
|
||||
&**device.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());
|
||||
|
||||
Arc::new(StdHostVisibleMemoryTypePool {
|
||||
Arc::new(StandardHostVisibleMemoryTypePool {
|
||||
device: device.clone(),
|
||||
memory_type: memory_type.id(),
|
||||
occupied: Mutex::new(Vec::new()),
|
||||
@ -67,7 +72,7 @@ impl StdHostVisibleMemoryTypePool {
|
||||
me: &Arc<Self>,
|
||||
size: DeviceSize,
|
||||
alignment: DeviceSize,
|
||||
) -> Result<StdHostVisibleMemoryTypePoolAlloc, DeviceMemoryAllocationError> {
|
||||
) -> Result<StandardHostVisibleMemoryTypePoolAlloc, DeviceMemoryAllocationError> {
|
||||
assert!(size != 0);
|
||||
assert!(alignment != 0);
|
||||
|
||||
@ -88,7 +93,7 @@ impl StdHostVisibleMemoryTypePool {
|
||||
let entry2 = entries[i + 1].clone();
|
||||
if entry1_end + size <= entry2.start {
|
||||
entries.insert(i + 1, entry1_end..entry1_end + size);
|
||||
return Ok(StdHostVisibleMemoryTypePoolAlloc {
|
||||
return Ok(StandardHostVisibleMemoryTypePoolAlloc {
|
||||
pool: me.clone(),
|
||||
memory: dev_mem.clone(),
|
||||
offset: entry1_end,
|
||||
@ -101,7 +106,7 @@ impl StdHostVisibleMemoryTypePool {
|
||||
let last_end = entries.last().map(|e| align(e.end, alignment)).unwrap_or(0);
|
||||
if last_end + size <= (**dev_mem).as_ref().allocation_size() {
|
||||
entries.push(last_end..last_end + size);
|
||||
return Ok(StdHostVisibleMemoryTypePoolAlloc {
|
||||
return Ok(StandardHostVisibleMemoryTypePoolAlloc {
|
||||
pool: me.clone(),
|
||||
memory: dev_mem.clone(),
|
||||
offset: last_end,
|
||||
@ -127,7 +132,7 @@ impl StdHostVisibleMemoryTypePool {
|
||||
};
|
||||
|
||||
occupied.push((new_block.clone(), vec![0..size]));
|
||||
Ok(StdHostVisibleMemoryTypePoolAlloc {
|
||||
Ok(StandardHostVisibleMemoryTypePoolAlloc {
|
||||
pool: me.clone(),
|
||||
memory: new_block,
|
||||
offset: 0,
|
||||
@ -152,14 +157,14 @@ impl StdHostVisibleMemoryTypePool {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct StdHostVisibleMemoryTypePoolAlloc {
|
||||
pool: Arc<StdHostVisibleMemoryTypePool>,
|
||||
pub struct StandardHostVisibleMemoryTypePoolAlloc {
|
||||
pool: Arc<StandardHostVisibleMemoryTypePool>,
|
||||
memory: Arc<MappedDeviceMemory>,
|
||||
offset: DeviceSize,
|
||||
size: DeviceSize,
|
||||
}
|
||||
|
||||
impl StdHostVisibleMemoryTypePoolAlloc {
|
||||
impl StandardHostVisibleMemoryTypePoolAlloc {
|
||||
#[inline]
|
||||
pub fn memory(&self) -> &MappedDeviceMemory {
|
||||
&self.memory
|
||||
@ -176,7 +181,7 @@ impl StdHostVisibleMemoryTypePoolAlloc {
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for StdHostVisibleMemoryTypePoolAlloc {
|
||||
impl Drop for StandardHostVisibleMemoryTypePoolAlloc {
|
||||
fn drop(&mut self) {
|
||||
let mut occupied = self.pool.occupied.lock().unwrap();
|
||||
|
||||
|
@ -7,22 +7,22 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
pub use self::host_visible::StdHostVisibleMemoryTypePool;
|
||||
pub use self::host_visible::StdHostVisibleMemoryTypePoolAlloc;
|
||||
pub use self::non_host_visible::StdNonHostVisibleMemoryTypePool;
|
||||
pub use self::non_host_visible::StdNonHostVisibleMemoryTypePoolAlloc;
|
||||
pub use self::pool::StdMemoryPool;
|
||||
pub use self::pool::StdMemoryPoolAlloc;
|
||||
use crate::device::physical::MemoryType;
|
||||
use crate::device::{Device, DeviceOwned};
|
||||
use crate::memory::device_memory::MemoryAllocateInfo;
|
||||
use crate::memory::DedicatedAllocation;
|
||||
use crate::memory::DeviceMemory;
|
||||
use crate::memory::DeviceMemoryAllocationError;
|
||||
use crate::memory::ExternalMemoryHandleTypes;
|
||||
use crate::memory::MappedDeviceMemory;
|
||||
use crate::memory::MemoryRequirements;
|
||||
use crate::DeviceSize;
|
||||
pub use self::{
|
||||
host_visible::{StandardHostVisibleMemoryTypePool, StandardHostVisibleMemoryTypePoolAlloc},
|
||||
non_host_visible::{
|
||||
StandardNonHostVisibleMemoryTypePool, StandardNonHostVisibleMemoryTypePoolAlloc,
|
||||
},
|
||||
pool::{StandardMemoryPool, StandardMemoryPoolAlloc},
|
||||
};
|
||||
use crate::{
|
||||
device::{physical::MemoryType, Device, DeviceOwned},
|
||||
memory::{
|
||||
device_memory::MemoryAllocateInfo, DedicatedAllocation, DeviceMemory,
|
||||
DeviceMemoryAllocationError, ExternalMemoryHandleTypes, MappedDeviceMemory,
|
||||
MemoryRequirements,
|
||||
},
|
||||
DeviceSize,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
mod host_visible;
|
||||
@ -77,7 +77,7 @@ pub(crate) fn alloc_dedicated_with_exportable_fd<F>(
|
||||
map: MappingRequirement,
|
||||
dedicated_allocation: DedicatedAllocation,
|
||||
filter: F,
|
||||
) -> Result<PotentialDedicatedAllocation<StdMemoryPoolAlloc>, DeviceMemoryAllocationError>
|
||||
) -> Result<PotentialDedicatedAllocation<StandardMemoryPoolAlloc>, DeviceMemoryAllocationError>
|
||||
where
|
||||
F: FnMut(MemoryType) -> AllocFromRequirementsFilter,
|
||||
{
|
||||
|
@ -7,28 +7,28 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use crate::device::physical::MemoryType;
|
||||
use crate::device::Device;
|
||||
use crate::instance::Instance;
|
||||
use crate::memory::device_memory::MemoryAllocateInfo;
|
||||
use crate::memory::DeviceMemory;
|
||||
use crate::memory::DeviceMemoryAllocationError;
|
||||
use crate::DeviceSize;
|
||||
use std::cmp;
|
||||
use std::ops::Range;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use crate::{
|
||||
device::{physical::MemoryType, Device},
|
||||
instance::Instance,
|
||||
memory::{device_memory::MemoryAllocateInfo, DeviceMemory, DeviceMemoryAllocationError},
|
||||
DeviceSize,
|
||||
};
|
||||
use std::{
|
||||
cmp,
|
||||
ops::Range,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
/// Memory pool that operates on a given memory type.
|
||||
#[derive(Debug)]
|
||||
pub struct StdNonHostVisibleMemoryTypePool {
|
||||
pub struct StandardNonHostVisibleMemoryTypePool {
|
||||
device: Arc<Device>,
|
||||
memory_type: u32,
|
||||
// TODO: obviously very inefficient
|
||||
occupied: Mutex<Vec<(Arc<DeviceMemory>, Vec<Range<DeviceSize>>)>>,
|
||||
}
|
||||
|
||||
impl StdNonHostVisibleMemoryTypePool {
|
||||
impl StandardNonHostVisibleMemoryTypePool {
|
||||
/// Creates a new pool that will operate on the given memory type.
|
||||
///
|
||||
/// # Panic
|
||||
@ -39,7 +39,7 @@ impl StdNonHostVisibleMemoryTypePool {
|
||||
pub fn new(
|
||||
device: Arc<Device>,
|
||||
memory_type: MemoryType,
|
||||
) -> Arc<StdNonHostVisibleMemoryTypePool> {
|
||||
) -> Arc<StandardNonHostVisibleMemoryTypePool> {
|
||||
assert_eq!(
|
||||
&**device.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()
|
||||
);
|
||||
|
||||
Arc::new(StdNonHostVisibleMemoryTypePool {
|
||||
Arc::new(StandardNonHostVisibleMemoryTypePool {
|
||||
device: device.clone(),
|
||||
memory_type: memory_type.id(),
|
||||
occupied: Mutex::new(Vec::new()),
|
||||
@ -67,7 +67,7 @@ impl StdNonHostVisibleMemoryTypePool {
|
||||
me: &Arc<Self>,
|
||||
size: DeviceSize,
|
||||
alignment: DeviceSize,
|
||||
) -> Result<StdNonHostVisibleMemoryTypePoolAlloc, DeviceMemoryAllocationError> {
|
||||
) -> Result<StandardNonHostVisibleMemoryTypePoolAlloc, DeviceMemoryAllocationError> {
|
||||
assert!(size != 0);
|
||||
assert!(alignment != 0);
|
||||
|
||||
@ -88,7 +88,7 @@ impl StdNonHostVisibleMemoryTypePool {
|
||||
let entry2 = entries[i + 1].clone();
|
||||
if entry1_end + size <= entry2.start {
|
||||
entries.insert(i + 1, entry1_end..entry1_end + size);
|
||||
return Ok(StdNonHostVisibleMemoryTypePoolAlloc {
|
||||
return Ok(StandardNonHostVisibleMemoryTypePoolAlloc {
|
||||
pool: me.clone(),
|
||||
memory: dev_mem.clone(),
|
||||
offset: entry1_end,
|
||||
@ -101,7 +101,7 @@ impl StdNonHostVisibleMemoryTypePool {
|
||||
let last_end = entries.last().map(|e| align(e.end, alignment)).unwrap_or(0);
|
||||
if last_end + size <= dev_mem.allocation_size() {
|
||||
entries.push(last_end..last_end + size);
|
||||
return Ok(StdNonHostVisibleMemoryTypePoolAlloc {
|
||||
return Ok(StandardNonHostVisibleMemoryTypePoolAlloc {
|
||||
pool: me.clone(),
|
||||
memory: dev_mem.clone(),
|
||||
offset: last_end,
|
||||
@ -126,7 +126,7 @@ impl StdNonHostVisibleMemoryTypePool {
|
||||
};
|
||||
|
||||
occupied.push((new_block.clone(), vec![0..size]));
|
||||
Ok(StdNonHostVisibleMemoryTypePoolAlloc {
|
||||
Ok(StandardNonHostVisibleMemoryTypePoolAlloc {
|
||||
pool: me.clone(),
|
||||
memory: new_block,
|
||||
offset: 0,
|
||||
@ -151,14 +151,14 @@ impl StdNonHostVisibleMemoryTypePool {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct StdNonHostVisibleMemoryTypePoolAlloc {
|
||||
pool: Arc<StdNonHostVisibleMemoryTypePool>,
|
||||
pub struct StandardNonHostVisibleMemoryTypePoolAlloc {
|
||||
pool: Arc<StandardNonHostVisibleMemoryTypePool>,
|
||||
memory: Arc<DeviceMemory>,
|
||||
offset: DeviceSize,
|
||||
size: DeviceSize,
|
||||
}
|
||||
|
||||
impl StdNonHostVisibleMemoryTypePoolAlloc {
|
||||
impl StandardNonHostVisibleMemoryTypePoolAlloc {
|
||||
#[inline]
|
||||
pub fn memory(&self) -> &DeviceMemory {
|
||||
&self.memory
|
||||
@ -175,7 +175,7 @@ impl StdNonHostVisibleMemoryTypePoolAlloc {
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for StdNonHostVisibleMemoryTypePoolAlloc {
|
||||
impl Drop for StandardNonHostVisibleMemoryTypePoolAlloc {
|
||||
fn drop(&mut self) {
|
||||
let mut occupied = self.pool.occupied.lock().unwrap();
|
||||
|
||||
|
@ -7,41 +7,38 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use crate::device::physical::MemoryType;
|
||||
use crate::device::Device;
|
||||
use crate::device::DeviceOwned;
|
||||
use crate::memory::pool::AllocLayout;
|
||||
use crate::memory::pool::MappingRequirement;
|
||||
use crate::memory::pool::MemoryPool;
|
||||
use crate::memory::pool::MemoryPoolAlloc;
|
||||
use crate::memory::pool::StdHostVisibleMemoryTypePool;
|
||||
use crate::memory::pool::StdHostVisibleMemoryTypePoolAlloc;
|
||||
use crate::memory::pool::StdNonHostVisibleMemoryTypePool;
|
||||
use crate::memory::pool::StdNonHostVisibleMemoryTypePoolAlloc;
|
||||
use crate::memory::DeviceMemory;
|
||||
use crate::memory::DeviceMemoryAllocationError;
|
||||
use crate::memory::MappedDeviceMemory;
|
||||
use crate::DeviceSize;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use crate::{
|
||||
device::{physical::MemoryType, Device, DeviceOwned},
|
||||
memory::{
|
||||
pool::{
|
||||
AllocLayout, MappingRequirement, MemoryPool, MemoryPoolAlloc,
|
||||
StandardHostVisibleMemoryTypePool, StandardHostVisibleMemoryTypePoolAlloc,
|
||||
StandardNonHostVisibleMemoryTypePool, StandardNonHostVisibleMemoryTypePoolAlloc,
|
||||
},
|
||||
DeviceMemory, DeviceMemoryAllocationError, MappedDeviceMemory,
|
||||
},
|
||||
DeviceSize,
|
||||
};
|
||||
use std::{
|
||||
collections::{hash_map::Entry, HashMap},
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct StdMemoryPool {
|
||||
pub struct StandardMemoryPool {
|
||||
device: Arc<Device>,
|
||||
|
||||
// For each memory type index, stores the associated pool.
|
||||
pools: Mutex<HashMap<(u32, AllocLayout, MappingRequirement), Pool>>,
|
||||
}
|
||||
|
||||
impl StdMemoryPool {
|
||||
impl StandardMemoryPool {
|
||||
/// Creates a new pool.
|
||||
#[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();
|
||||
|
||||
Arc::new(StdMemoryPool {
|
||||
Arc::new(StandardMemoryPool {
|
||||
device: device.clone(),
|
||||
pools: Mutex::new(HashMap::with_capacity(cap)),
|
||||
})
|
||||
@ -49,13 +46,13 @@ impl StdMemoryPool {
|
||||
}
|
||||
|
||||
fn generic_allocation(
|
||||
mem_pool: Arc<StdMemoryPool>,
|
||||
mem_pool: Arc<StandardMemoryPool>,
|
||||
memory_type: MemoryType,
|
||||
size: DeviceSize,
|
||||
alignment: DeviceSize,
|
||||
layout: AllocLayout,
|
||||
map: MappingRequirement,
|
||||
) -> Result<StdMemoryPoolAlloc, DeviceMemoryAllocationError> {
|
||||
) -> Result<StandardMemoryPoolAlloc, DeviceMemoryAllocationError> {
|
||||
let mut pools = mem_pool.pools.lock().unwrap();
|
||||
|
||||
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)) {
|
||||
Entry::Occupied(entry) => match entry.get() {
|
||||
&Pool::HostVisible(ref pool) => {
|
||||
let alloc = StdHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?;
|
||||
let inner = StdMemoryPoolAllocInner::HostVisible(alloc);
|
||||
Ok(StdMemoryPoolAlloc {
|
||||
let alloc = StandardHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?;
|
||||
let inner = StandardMemoryPoolAllocInner::HostVisible(alloc);
|
||||
Ok(StandardMemoryPoolAlloc {
|
||||
inner,
|
||||
pool: mem_pool.clone(),
|
||||
})
|
||||
}
|
||||
&Pool::NonHostVisible(ref pool) => {
|
||||
let alloc = StdNonHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?;
|
||||
let inner = StdMemoryPoolAllocInner::NonHostVisible(alloc);
|
||||
Ok(StdMemoryPoolAlloc {
|
||||
let alloc = StandardNonHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?;
|
||||
let inner = StandardMemoryPoolAllocInner::NonHostVisible(alloc);
|
||||
Ok(StandardMemoryPoolAlloc {
|
||||
inner,
|
||||
pool: mem_pool.clone(),
|
||||
})
|
||||
@ -83,21 +80,22 @@ fn generic_allocation(
|
||||
|
||||
Entry::Vacant(entry) => {
|
||||
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()));
|
||||
let alloc = StdHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?;
|
||||
let inner = StdMemoryPoolAllocInner::HostVisible(alloc);
|
||||
Ok(StdMemoryPoolAlloc {
|
||||
let alloc = StandardHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?;
|
||||
let inner = StandardMemoryPoolAllocInner::HostVisible(alloc);
|
||||
Ok(StandardMemoryPoolAlloc {
|
||||
inner,
|
||||
pool: mem_pool.clone(),
|
||||
})
|
||||
} else {
|
||||
let pool =
|
||||
StdNonHostVisibleMemoryTypePool::new(mem_pool.device.clone(), memory_type);
|
||||
StandardNonHostVisibleMemoryTypePool::new(mem_pool.device.clone(), memory_type);
|
||||
entry.insert(Pool::NonHostVisible(pool.clone()));
|
||||
let alloc = StdNonHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?;
|
||||
let inner = StdMemoryPoolAllocInner::NonHostVisible(alloc);
|
||||
Ok(StdMemoryPoolAlloc {
|
||||
let alloc = StandardNonHostVisibleMemoryTypePool::alloc(&pool, size, alignment)?;
|
||||
let inner = StandardMemoryPoolAllocInner::NonHostVisible(alloc);
|
||||
Ok(StandardMemoryPoolAlloc {
|
||||
inner,
|
||||
pool: mem_pool.clone(),
|
||||
})
|
||||
@ -106,8 +104,8 @@ fn generic_allocation(
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl MemoryPool for Arc<StdMemoryPool> {
|
||||
type Alloc = StdMemoryPoolAlloc;
|
||||
unsafe impl MemoryPool for Arc<StandardMemoryPool> {
|
||||
type Alloc = StandardMemoryPoolAlloc;
|
||||
|
||||
fn alloc_generic(
|
||||
&self,
|
||||
@ -116,12 +114,12 @@ unsafe impl MemoryPool for Arc<StdMemoryPool> {
|
||||
alignment: DeviceSize,
|
||||
layout: AllocLayout,
|
||||
map: MappingRequirement,
|
||||
) -> Result<StdMemoryPoolAlloc, DeviceMemoryAllocationError> {
|
||||
) -> Result<StandardMemoryPoolAlloc, DeviceMemoryAllocationError> {
|
||||
generic_allocation(self.clone(), memory_type, size, alignment, layout, map)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl DeviceOwned for StdMemoryPool {
|
||||
unsafe impl DeviceOwned for StandardMemoryPool {
|
||||
#[inline]
|
||||
fn device(&self) -> &Arc<Device> {
|
||||
&self.device
|
||||
@ -130,54 +128,54 @@ unsafe impl DeviceOwned for StdMemoryPool {
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Pool {
|
||||
HostVisible(Arc<StdHostVisibleMemoryTypePool>),
|
||||
NonHostVisible(Arc<StdNonHostVisibleMemoryTypePool>),
|
||||
HostVisible(Arc<StandardHostVisibleMemoryTypePool>),
|
||||
NonHostVisible(Arc<StandardNonHostVisibleMemoryTypePool>),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct StdMemoryPoolAlloc {
|
||||
inner: StdMemoryPoolAllocInner,
|
||||
pool: Arc<StdMemoryPool>,
|
||||
pub struct StandardMemoryPoolAlloc {
|
||||
inner: StandardMemoryPoolAllocInner,
|
||||
pool: Arc<StandardMemoryPool>,
|
||||
}
|
||||
|
||||
impl StdMemoryPoolAlloc {
|
||||
impl StandardMemoryPoolAlloc {
|
||||
#[inline]
|
||||
pub fn size(&self) -> DeviceSize {
|
||||
match self.inner {
|
||||
StdMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.size(),
|
||||
StdMemoryPoolAllocInner::HostVisible(ref mem) => mem.size(),
|
||||
StandardMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.size(),
|
||||
StandardMemoryPoolAllocInner::HostVisible(ref mem) => mem.size(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl MemoryPoolAlloc for StdMemoryPoolAlloc {
|
||||
unsafe impl MemoryPoolAlloc for StandardMemoryPoolAlloc {
|
||||
#[inline]
|
||||
fn memory(&self) -> &DeviceMemory {
|
||||
match self.inner {
|
||||
StdMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.memory(),
|
||||
StdMemoryPoolAllocInner::HostVisible(ref mem) => mem.memory().as_ref(),
|
||||
StandardMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.memory(),
|
||||
StandardMemoryPoolAllocInner::HostVisible(ref mem) => mem.memory().as_ref(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mapped_memory(&self) -> Option<&MappedDeviceMemory> {
|
||||
match self.inner {
|
||||
StdMemoryPoolAllocInner::NonHostVisible(_) => None,
|
||||
StdMemoryPoolAllocInner::HostVisible(ref mem) => Some(mem.memory()),
|
||||
StandardMemoryPoolAllocInner::NonHostVisible(_) => None,
|
||||
StandardMemoryPoolAllocInner::HostVisible(ref mem) => Some(mem.memory()),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn offset(&self) -> DeviceSize {
|
||||
match self.inner {
|
||||
StdMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.offset(),
|
||||
StdMemoryPoolAllocInner::HostVisible(ref mem) => mem.offset(),
|
||||
StandardMemoryPoolAllocInner::NonHostVisible(ref mem) => mem.offset(),
|
||||
StandardMemoryPoolAllocInner::HostVisible(ref mem) => mem.offset(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum StdMemoryPoolAllocInner {
|
||||
NonHostVisible(StdNonHostVisibleMemoryTypePoolAlloc),
|
||||
HostVisible(StdHostVisibleMemoryTypePoolAlloc),
|
||||
enum StandardMemoryPoolAllocInner {
|
||||
NonHostVisible(StandardNonHostVisibleMemoryTypePoolAlloc),
|
||||
HostVisible(StandardHostVisibleMemoryTypePoolAlloc),
|
||||
}
|
||||
|
@ -21,14 +21,8 @@
|
||||
//! 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.
|
||||
|
||||
use crate::check_errors;
|
||||
use crate::device::Device;
|
||||
use crate::OomError;
|
||||
use crate::Success;
|
||||
use crate::VulkanObject;
|
||||
use std::mem::MaybeUninit;
|
||||
use std::ptr;
|
||||
use std::sync::Arc;
|
||||
use crate::{check_errors, device::Device, OomError, Success, VulkanObject};
|
||||
use std::{mem::MaybeUninit, ptr, sync::Arc};
|
||||
|
||||
/// Opaque cache that contains pipeline objects.
|
||||
///
|
||||
@ -256,9 +250,10 @@ impl Drop for PipelineCache {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::pipeline::cache::PipelineCache;
|
||||
use crate::pipeline::ComputePipeline;
|
||||
use crate::shader::ShaderModule;
|
||||
use crate::{
|
||||
pipeline::{cache::PipelineCache, ComputePipeline},
|
||||
shader::ShaderModule,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[test]
|
||||
|
@ -23,28 +23,21 @@
|
||||
//! command on the command buffer.
|
||||
|
||||
use super::layout::PipelineLayoutCreateInfo;
|
||||
use crate::check_errors;
|
||||
use crate::descriptor_set::layout::{
|
||||
use crate::{
|
||||
check_errors,
|
||||
descriptor_set::layout::{
|
||||
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 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;
|
||||
use std::{collections::HashMap, error, fmt, mem, mem::MaybeUninit, ptr, sync::Arc};
|
||||
|
||||
/// A pipeline object that describes to the Vulkan implementation how it should perform compute
|
||||
/// operations.
|
||||
@ -406,20 +399,14 @@ impl From<Error> for ComputePipelineCreationError {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::buffer::BufferUsage;
|
||||
use crate::buffer::CpuAccessibleBuffer;
|
||||
use crate::command_buffer::AutoCommandBufferBuilder;
|
||||
use crate::command_buffer::CommandBufferUsage;
|
||||
use crate::descriptor_set::PersistentDescriptorSet;
|
||||
use crate::descriptor_set::WriteDescriptorSet;
|
||||
use crate::pipeline::ComputePipeline;
|
||||
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;
|
||||
use crate::{
|
||||
buffer::{BufferUsage, CpuAccessibleBuffer},
|
||||
command_buffer::{AutoCommandBufferBuilder, CommandBufferUsage},
|
||||
descriptor_set::{PersistentDescriptorSet, WriteDescriptorSet},
|
||||
pipeline::{ComputePipeline, Pipeline, PipelineBindPoint},
|
||||
shader::{ShaderModule, SpecializationConstants, SpecializationMapEntry},
|
||||
sync::{now, GpuFuture},
|
||||
};
|
||||
|
||||
// TODO: test for basic creation
|
||||
// TODO: test for pipeline layout error
|
||||
|
@ -8,15 +8,15 @@
|
||||
// according to those terms.
|
||||
|
||||
use super::VertexMemberInfo;
|
||||
use crate::pipeline::graphics::vertex_input::IncompatibleVertexDefinitionError;
|
||||
use crate::pipeline::graphics::vertex_input::Vertex;
|
||||
use crate::pipeline::graphics::vertex_input::VertexDefinition;
|
||||
use crate::pipeline::graphics::vertex_input::VertexInputAttributeDescription;
|
||||
use crate::pipeline::graphics::vertex_input::VertexInputBindingDescription;
|
||||
use crate::pipeline::graphics::vertex_input::VertexInputRate;
|
||||
use crate::pipeline::graphics::vertex_input::VertexInputState;
|
||||
use crate::shader::ShaderInterface;
|
||||
use crate::DeviceSize;
|
||||
use crate::{
|
||||
pipeline::graphics::vertex_input::{
|
||||
IncompatibleVertexDefinitionError, Vertex, VertexDefinition,
|
||||
VertexInputAttributeDescription, VertexInputBindingDescription, VertexInputRate,
|
||||
VertexInputState,
|
||||
},
|
||||
shader::ShaderInterface,
|
||||
DeviceSize,
|
||||
};
|
||||
use std::mem;
|
||||
|
||||
/// A vertex definition for any number of vertex and instance buffers.
|
||||
|
@ -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)]
|
||||
mod tests {
|
||||
use super::VertexBuffersCollection;
|
||||
use crate::buffer::BufferAccess;
|
||||
use crate::buffer::BufferAccessObject;
|
||||
use crate::buffer::BufferInner;
|
||||
use crate::device::Device;
|
||||
use crate::device::DeviceOwned;
|
||||
use crate::DeviceSize;
|
||||
use crate::{
|
||||
buffer::{BufferAccess, BufferAccessObject, BufferInner},
|
||||
device::{Device, DeviceOwned},
|
||||
DeviceSize,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
struct DummyBufferA {}
|
||||
|
@ -50,12 +50,12 @@
|
||||
//! # }
|
||||
//! ```
|
||||
|
||||
use crate::format::Format;
|
||||
use crate::pipeline::graphics::vertex_input::VertexInputState;
|
||||
use crate::pipeline::graphics::vertex_input::VertexMemberTy;
|
||||
use crate::shader::ShaderInterface;
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
use crate::{
|
||||
format::Format,
|
||||
pipeline::graphics::vertex_input::{VertexInputState, VertexMemberTy},
|
||||
shader::ShaderInterface,
|
||||
};
|
||||
use std::{error, fmt};
|
||||
|
||||
/// Trait for types that can create a [`VertexInputState`] from a [`ShaderInterface`].
|
||||
pub unsafe trait VertexDefinition {
|
||||
|
@ -1132,13 +1132,12 @@ impl Counter {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use super::PipelineLayout;
|
||||
use crate::{
|
||||
pipeline::layout::{PipelineLayoutCreateInfo, PushConstantRange},
|
||||
shader::ShaderStages,
|
||||
};
|
||||
|
||||
use super::PipelineLayout;
|
||||
|
||||
#[test]
|
||||
fn push_constant_ranges_disjoint() {
|
||||
let test_cases = [
|
||||
|
@ -17,9 +17,7 @@
|
||||
//! the CPU). Consequently it is a CPU-intensive operation that should be performed at
|
||||
//! initialization or during a loading screen.
|
||||
|
||||
pub use self::compute::ComputePipeline;
|
||||
pub use self::graphics::GraphicsPipeline;
|
||||
pub use self::layout::PipelineLayout;
|
||||
pub use self::{compute::ComputePipeline, graphics::GraphicsPipeline, layout::PipelineLayout};
|
||||
use crate::device::DeviceOwned;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -759,10 +759,7 @@ impl From<QueryResultFlags> for ash::vk::QueryResultFlags {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::QueryPoolCreateInfo;
|
||||
use crate::query::QueryPipelineStatisticFlags;
|
||||
use crate::query::QueryPool;
|
||||
use crate::query::QueryPoolCreationError;
|
||||
use crate::query::QueryType;
|
||||
use crate::query::{QueryPipelineStatisticFlags, QueryPool, QueryPoolCreationError, QueryType};
|
||||
|
||||
#[test]
|
||||
fn pipeline_statistics_feature() {
|
||||
|
@ -1,10 +1,11 @@
|
||||
use std::cmp;
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::{btree_map, BTreeMap};
|
||||
use std::fmt::{self, Debug};
|
||||
use std::iter::{FromIterator, FusedIterator, Peekable};
|
||||
use std::ops::Bound;
|
||||
use std::ops::{Add, Range, Sub};
|
||||
use std::{
|
||||
cmp,
|
||||
cmp::Ordering,
|
||||
collections::{btree_map, BTreeMap},
|
||||
fmt::{self, Debug},
|
||||
iter::{FromIterator, FusedIterator, Peekable},
|
||||
ops::{Add, Bound, Range, Sub},
|
||||
};
|
||||
|
||||
/// A map whose keys are stored as (half-open) ranges bounded
|
||||
/// inclusively below and exclusively above `(start..end)`.
|
||||
|
@ -724,13 +724,11 @@ impl From<Error> for FramebufferCreationError {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::format::Format;
|
||||
use crate::image::attachment::AttachmentImage;
|
||||
use crate::image::view::ImageView;
|
||||
use crate::render_pass::Framebuffer;
|
||||
use crate::render_pass::FramebufferCreateInfo;
|
||||
use crate::render_pass::FramebufferCreationError;
|
||||
use crate::render_pass::RenderPass;
|
||||
use crate::{
|
||||
format::Format,
|
||||
image::{attachment::AttachmentImage, view::ImageView},
|
||||
render_pass::{Framebuffer, FramebufferCreateInfo, FramebufferCreationError, RenderPass},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn simple_create() {
|
||||
|
@ -25,10 +25,10 @@
|
||||
//! 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.
|
||||
|
||||
pub use self::create::RenderPassCreationError;
|
||||
pub use self::framebuffer::Framebuffer;
|
||||
pub use self::framebuffer::FramebufferCreateInfo;
|
||||
pub use self::framebuffer::FramebufferCreationError;
|
||||
pub use self::{
|
||||
create::RenderPassCreationError,
|
||||
framebuffer::{Framebuffer, FramebufferCreateInfo, FramebufferCreationError},
|
||||
};
|
||||
use crate::{
|
||||
device::{Device, DeviceOwned},
|
||||
format::Format,
|
||||
@ -37,8 +37,8 @@ use crate::{
|
||||
sync::{AccessFlags, PipelineStages},
|
||||
Version, VulkanObject,
|
||||
};
|
||||
use std::cmp::max;
|
||||
use std::{
|
||||
cmp::max,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
ptr,
|
||||
@ -1228,9 +1228,10 @@ impl From<ash::vk::ResolveModeFlags> for ResolveModes {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::format::Format;
|
||||
use crate::render_pass::RenderPass;
|
||||
use crate::render_pass::RenderPassCreationError;
|
||||
use crate::{
|
||||
format::Format,
|
||||
render_pass::{RenderPass, RenderPassCreationError},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn empty() {
|
||||
|
@ -17,32 +17,31 @@
|
||||
//! code. You are encouraged to use the `vulkano-shaders` crate that will generate Rust code that
|
||||
//! wraps around vulkano's shaders API.
|
||||
|
||||
use crate::check_errors;
|
||||
use crate::descriptor_set::layout::DescriptorType;
|
||||
use crate::device::Device;
|
||||
use crate::format::{Format, NumericType};
|
||||
use crate::image::view::ImageViewType;
|
||||
use crate::pipeline::graphics::input_assembly::PrimitiveTopology;
|
||||
use crate::pipeline::layout::PushConstantRange;
|
||||
use crate::shader::spirv::{Capability, Spirv, SpirvError};
|
||||
use crate::sync::PipelineStages;
|
||||
use crate::DeviceSize;
|
||||
use crate::OomError;
|
||||
use crate::Version;
|
||||
use crate::VulkanObject;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::error;
|
||||
use std::error::Error;
|
||||
use std::ffi::CStr;
|
||||
use std::ffi::CString;
|
||||
use std::fmt;
|
||||
use std::fmt::Display;
|
||||
use std::mem;
|
||||
use std::mem::MaybeUninit;
|
||||
use std::ops::BitOr;
|
||||
use std::ptr;
|
||||
use std::sync::Arc;
|
||||
use crate::{
|
||||
check_errors,
|
||||
descriptor_set::layout::DescriptorType,
|
||||
device::Device,
|
||||
format::{Format, NumericType},
|
||||
image::view::ImageViewType,
|
||||
pipeline::{graphics::input_assembly::PrimitiveTopology, layout::PushConstantRange},
|
||||
shader::spirv::{Capability, Spirv, SpirvError},
|
||||
sync::PipelineStages,
|
||||
DeviceSize, OomError, Version, VulkanObject,
|
||||
};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::{HashMap, HashSet},
|
||||
error,
|
||||
error::Error,
|
||||
ffi::{CStr, CString},
|
||||
fmt,
|
||||
fmt::Display,
|
||||
mem,
|
||||
mem::MaybeUninit,
|
||||
ops::BitOr,
|
||||
ptr,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
pub mod reflect;
|
||||
pub mod spirv;
|
||||
|
@ -9,11 +9,9 @@
|
||||
|
||||
//! 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::{
|
||||
descriptor_set::layout::DescriptorType,
|
||||
image::view::ImageViewType,
|
||||
pipeline::layout::PushConstantRange,
|
||||
shader::{
|
||||
spirv::{
|
||||
@ -22,11 +20,15 @@ use crate::{
|
||||
},
|
||||
DescriptorIdentifier, DescriptorRequirements, EntryPointInfo, GeometryShaderExecution,
|
||||
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`.
|
||||
pub fn spirv_capabilities<'a>(spirv: &'a Spirv) -> impl Iterator<Item = &'a Capability> {
|
||||
|
@ -28,18 +28,11 @@
|
||||
#![allow(dead_code)] // TODO: this module isn't finished
|
||||
#![allow(unused_variables)] // TODO: this module isn't finished
|
||||
|
||||
use crate::check_errors;
|
||||
use crate::device::physical::PhysicalDevice;
|
||||
use crate::instance::Instance;
|
||||
use crate::swapchain::SupportedSurfaceTransforms;
|
||||
use crate::OomError;
|
||||
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};
|
||||
use crate::{
|
||||
check_errors, device::physical::PhysicalDevice, instance::Instance,
|
||||
swapchain::SupportedSurfaceTransforms, OomError, Success, VulkanObject,
|
||||
};
|
||||
use std::{ffi::CStr, fmt, fmt::Formatter, ptr, sync::Arc, vec::IntoIter};
|
||||
|
||||
// TODO: extract this to a `display` module and solve the visibility problems
|
||||
|
||||
|
@ -317,33 +317,19 @@
|
||||
//! ```
|
||||
//!
|
||||
|
||||
pub use self::present_region::PresentRegion;
|
||||
pub use self::present_region::RectangleLayer;
|
||||
pub use self::surface::ColorSpace;
|
||||
pub use self::surface::CompositeAlpha;
|
||||
pub use self::surface::PresentMode;
|
||||
pub use self::surface::SupportedCompositeAlpha;
|
||||
pub use self::surface::SupportedSurfaceTransforms;
|
||||
pub use self::surface::Surface;
|
||||
pub use self::surface::SurfaceApi;
|
||||
pub use self::surface::SurfaceCapabilities;
|
||||
pub use self::surface::SurfaceCreationError;
|
||||
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;
|
||||
pub use self::{
|
||||
present_region::{PresentRegion, RectangleLayer},
|
||||
surface::{
|
||||
ColorSpace, CompositeAlpha, PresentMode, SupportedCompositeAlpha,
|
||||
SupportedSurfaceTransforms, Surface, SurfaceApi, SurfaceCapabilities, SurfaceCreationError,
|
||||
SurfaceInfo, SurfaceTransform,
|
||||
},
|
||||
swapchain::{
|
||||
acquire_next_image, acquire_next_image_raw, present, present_incremental, AcquireError,
|
||||
AcquiredImage, FullScreenExclusive, FullScreenExclusiveError, PresentFuture, Swapchain,
|
||||
SwapchainAcquireFuture, SwapchainCreateInfo, SwapchainCreationError, Win32Monitor,
|
||||
},
|
||||
};
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
pub mod display;
|
||||
|
@ -7,25 +7,25 @@
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use super::FullScreenExclusive;
|
||||
use super::Win32Monitor;
|
||||
use crate::check_errors;
|
||||
use crate::image::ImageUsage;
|
||||
use crate::instance::Instance;
|
||||
use crate::swapchain::display::DisplayMode;
|
||||
use crate::swapchain::display::DisplayPlane;
|
||||
use crate::swapchain::SurfaceSwapchainLock;
|
||||
use crate::Error;
|
||||
use crate::OomError;
|
||||
use crate::VulkanObject;
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::mem::MaybeUninit;
|
||||
use std::os::raw::c_ulong;
|
||||
use std::ptr;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::Arc;
|
||||
use super::{FullScreenExclusive, Win32Monitor};
|
||||
use crate::{
|
||||
check_errors,
|
||||
image::ImageUsage,
|
||||
instance::Instance,
|
||||
swapchain::{
|
||||
display::{DisplayMode, DisplayPlane},
|
||||
SurfaceSwapchainLock,
|
||||
},
|
||||
Error, OomError, VulkanObject,
|
||||
};
|
||||
use std::{
|
||||
error, fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
os::raw::c_ulong,
|
||||
ptr,
|
||||
sync::{atomic::AtomicBool, Arc},
|
||||
};
|
||||
|
||||
/// Represents a surface on the screen.
|
||||
///
|
||||
@ -1272,8 +1272,7 @@ pub struct SurfaceCapabilities {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::swapchain::Surface;
|
||||
use crate::swapchain::SurfaceCreationError;
|
||||
use crate::swapchain::{Surface, SurfaceCreationError};
|
||||
use std::ptr;
|
||||
|
||||
#[test]
|
||||
|
@ -239,8 +239,7 @@ impl Default for EventCreateInfo {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::sync::Event;
|
||||
use crate::VulkanObject;
|
||||
use crate::{sync::Event, VulkanObject};
|
||||
|
||||
#[test]
|
||||
fn event_create() {
|
||||
|
@ -447,9 +447,10 @@ impl From<Error> for FenceWaitError {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::sync::fence::FenceCreateInfo;
|
||||
use crate::sync::Fence;
|
||||
use crate::VulkanObject;
|
||||
use crate::{
|
||||
sync::{fence::FenceCreateInfo, Fence},
|
||||
VulkanObject,
|
||||
};
|
||||
use std::time::Duration;
|
||||
|
||||
#[test]
|
||||
|
@ -103,9 +103,6 @@
|
||||
//! TODO: talk about fence + semaphore simultaneously
|
||||
//! TODO: talk about using fences to clean up
|
||||
|
||||
use crate::device::Queue;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub use self::{
|
||||
event::{Event, EventCreateInfo},
|
||||
fence::{Fence, FenceCreateInfo, FenceWaitError},
|
||||
@ -122,6 +119,8 @@ pub use self::{
|
||||
ExternalSemaphoreProperties, Semaphore, SemaphoreCreateInfo, SemaphoreCreationError,
|
||||
},
|
||||
};
|
||||
use crate::device::Queue;
|
||||
use std::sync::Arc;
|
||||
|
||||
mod event;
|
||||
mod fence;
|
||||
|
Loading…
Reference in New Issue
Block a user