mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 00:04:15 +00:00
Error naming consistency (#2370)
This commit is contained in:
parent
755dcbc6e2
commit
9526e772e2
@ -10,7 +10,7 @@
|
||||
//! Efficiently suballocates buffers into smaller subbuffers.
|
||||
|
||||
use super::{
|
||||
sys::BufferCreateInfo, Buffer, BufferAllocateError, BufferContents, BufferMemory, BufferUsage,
|
||||
sys::BufferCreateInfo, AllocateBufferError, Buffer, BufferContents, BufferMemory, BufferUsage,
|
||||
Subbuffer,
|
||||
};
|
||||
use crate::{
|
||||
@ -370,7 +370,7 @@ where
|
||||
DeviceLayout::from_size_alignment(self.arena_size, 1).unwrap(),
|
||||
)
|
||||
.map_err(|err| match err {
|
||||
Validated::Error(BufferAllocateError::AllocateMemory(err)) => err,
|
||||
Validated::Error(AllocateBufferError::AllocateMemory(err)) => err,
|
||||
// We don't use sparse-binding, concurrent sharing or external memory, therefore the
|
||||
// other errors can't happen.
|
||||
_ => unreachable!("{err:?}"),
|
||||
|
@ -244,7 +244,7 @@ impl Buffer {
|
||||
create_info: BufferCreateInfo,
|
||||
allocation_info: AllocationCreateInfo,
|
||||
data: T,
|
||||
) -> Result<Subbuffer<T>, Validated<BufferAllocateError>>
|
||||
) -> Result<Subbuffer<T>, Validated<AllocateBufferError>>
|
||||
where
|
||||
T: BufferContents,
|
||||
{
|
||||
@ -275,7 +275,7 @@ impl Buffer {
|
||||
create_info: BufferCreateInfo,
|
||||
allocation_info: AllocationCreateInfo,
|
||||
iter: I,
|
||||
) -> Result<Subbuffer<[T]>, Validated<BufferAllocateError>>
|
||||
) -> Result<Subbuffer<[T]>, Validated<AllocateBufferError>>
|
||||
where
|
||||
T: BufferContents,
|
||||
I: IntoIterator<Item = T>,
|
||||
@ -310,7 +310,7 @@ impl Buffer {
|
||||
allocator: Arc<dyn MemoryAllocator>,
|
||||
create_info: BufferCreateInfo,
|
||||
allocation_info: AllocationCreateInfo,
|
||||
) -> Result<Subbuffer<T>, Validated<BufferAllocateError>>
|
||||
) -> Result<Subbuffer<T>, Validated<AllocateBufferError>>
|
||||
where
|
||||
T: BufferContents,
|
||||
{
|
||||
@ -337,7 +337,7 @@ impl Buffer {
|
||||
create_info: BufferCreateInfo,
|
||||
allocation_info: AllocationCreateInfo,
|
||||
len: DeviceSize,
|
||||
) -> Result<Subbuffer<[T]>, Validated<BufferAllocateError>>
|
||||
) -> Result<Subbuffer<[T]>, Validated<AllocateBufferError>>
|
||||
where
|
||||
T: BufferContents,
|
||||
{
|
||||
@ -356,7 +356,7 @@ impl Buffer {
|
||||
create_info: BufferCreateInfo,
|
||||
allocation_info: AllocationCreateInfo,
|
||||
len: DeviceSize,
|
||||
) -> Result<Subbuffer<T>, Validated<BufferAllocateError>>
|
||||
) -> Result<Subbuffer<T>, Validated<AllocateBufferError>>
|
||||
where
|
||||
T: BufferContents + ?Sized,
|
||||
{
|
||||
@ -383,7 +383,7 @@ impl Buffer {
|
||||
mut create_info: BufferCreateInfo,
|
||||
allocation_info: AllocationCreateInfo,
|
||||
layout: DeviceLayout,
|
||||
) -> Result<Arc<Self>, Validated<BufferAllocateError>> {
|
||||
) -> Result<Arc<Self>, Validated<AllocateBufferError>> {
|
||||
assert!(layout.alignment().as_devicesize() <= 64);
|
||||
// TODO: Enable once sparse binding materializes
|
||||
// assert!(!allocate_info.flags.contains(BufferCreateFlags::SPARSE_BINDING));
|
||||
@ -398,7 +398,7 @@ impl Buffer {
|
||||
|
||||
let raw_buffer =
|
||||
RawBuffer::new(allocator.device().clone(), create_info).map_err(|err| match err {
|
||||
Validated::Error(err) => Validated::Error(BufferAllocateError::CreateBuffer(err)),
|
||||
Validated::Error(err) => Validated::Error(AllocateBufferError::CreateBuffer(err)),
|
||||
Validated::ValidationError(err) => err.into(),
|
||||
})?;
|
||||
let mut requirements = *raw_buffer.memory_requirements();
|
||||
@ -411,11 +411,11 @@ impl Buffer {
|
||||
allocation_info,
|
||||
Some(DedicatedAllocation::Buffer(&raw_buffer)),
|
||||
)
|
||||
.map_err(BufferAllocateError::AllocateMemory)?;
|
||||
.map_err(AllocateBufferError::AllocateMemory)?;
|
||||
let allocation = unsafe { ResourceMemory::from_allocation(allocator, allocation) };
|
||||
|
||||
let buffer = raw_buffer.bind_memory(allocation).map_err(|(err, _, _)| {
|
||||
err.map(BufferAllocateError::BindMemory)
|
||||
err.map(AllocateBufferError::BindMemory)
|
||||
.map_validation(|err| err.add_context("RawBuffer::bind_memory"))
|
||||
})?;
|
||||
|
||||
@ -569,13 +569,13 @@ impl Hash for Buffer {
|
||||
|
||||
/// Error that can happen when allocating a new buffer.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum BufferAllocateError {
|
||||
pub enum AllocateBufferError {
|
||||
CreateBuffer(VulkanError),
|
||||
AllocateMemory(MemoryAllocatorError),
|
||||
BindMemory(VulkanError),
|
||||
}
|
||||
|
||||
impl Error for BufferAllocateError {
|
||||
impl Error for AllocateBufferError {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
Self::CreateBuffer(err) => Some(err),
|
||||
@ -585,7 +585,7 @@ impl Error for BufferAllocateError {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for BufferAllocateError {
|
||||
impl Display for AllocateBufferError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::CreateBuffer(_) => write!(f, "creating the buffer failed"),
|
||||
@ -595,8 +595,8 @@ impl Display for BufferAllocateError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BufferAllocateError> for Validated<BufferAllocateError> {
|
||||
fn from(err: BufferAllocateError) -> Self {
|
||||
impl From<AllocateBufferError> for Validated<AllocateBufferError> {
|
||||
fn from(err: AllocateBufferError) -> Self {
|
||||
Self::Error(err)
|
||||
}
|
||||
}
|
||||
|
@ -148,14 +148,14 @@ impl Image {
|
||||
allocator: Arc<dyn MemoryAllocator>,
|
||||
create_info: ImageCreateInfo,
|
||||
allocation_info: AllocationCreateInfo,
|
||||
) -> Result<Arc<Self>, Validated<ImageAllocateError>> {
|
||||
) -> Result<Arc<Self>, Validated<AllocateImageError>> {
|
||||
// TODO: adjust the code below to make this safe
|
||||
assert!(!create_info.flags.intersects(ImageCreateFlags::DISJOINT));
|
||||
|
||||
let allocation_type = create_info.tiling.into();
|
||||
let raw_image =
|
||||
RawImage::new(allocator.device().clone(), create_info).map_err(|err| match err {
|
||||
Validated::Error(err) => Validated::Error(ImageAllocateError::CreateImage(err)),
|
||||
Validated::Error(err) => Validated::Error(AllocateImageError::CreateImage(err)),
|
||||
Validated::ValidationError(err) => err.into(),
|
||||
})?;
|
||||
let requirements = raw_image.memory_requirements()[0];
|
||||
@ -167,11 +167,11 @@ impl Image {
|
||||
allocation_info,
|
||||
Some(DedicatedAllocation::Image(&raw_image)),
|
||||
)
|
||||
.map_err(ImageAllocateError::AllocateMemory)?;
|
||||
.map_err(AllocateImageError::AllocateMemory)?;
|
||||
let allocation = unsafe { ResourceMemory::from_allocation(allocator, allocation) };
|
||||
|
||||
let image = raw_image.bind_memory([allocation]).map_err(|(err, _, _)| {
|
||||
err.map(ImageAllocateError::BindMemory)
|
||||
err.map(AllocateImageError::BindMemory)
|
||||
.map_validation(|err| err.add_context("RawImage::bind_memory"))
|
||||
})?;
|
||||
|
||||
@ -572,13 +572,13 @@ impl Hash for Image {
|
||||
|
||||
/// Error that can happen when allocating a new image.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum ImageAllocateError {
|
||||
pub enum AllocateImageError {
|
||||
CreateImage(VulkanError),
|
||||
AllocateMemory(MemoryAllocatorError),
|
||||
BindMemory(VulkanError),
|
||||
}
|
||||
|
||||
impl Error for ImageAllocateError {
|
||||
impl Error for AllocateImageError {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
Self::CreateImage(err) => Some(err),
|
||||
@ -588,7 +588,7 @@ impl Error for ImageAllocateError {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for ImageAllocateError {
|
||||
impl Display for AllocateImageError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::CreateImage(_) => write!(f, "creating the image failed"),
|
||||
@ -598,8 +598,8 @@ impl Display for ImageAllocateError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ImageAllocateError> for Validated<ImageAllocateError> {
|
||||
fn from(err: ImageAllocateError) -> Self {
|
||||
impl From<AllocateImageError> for Validated<AllocateImageError> {
|
||||
fn from(err: AllocateImageError) -> Self {
|
||||
Self::Error(err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user