Single type for all validation errors (#2194)

* Single type for all validation errors

* Documentation

* Small improvement

* Rename VulkanError to RuntimeError

* Simplify the error type by using an intermediate struct

* Update vulkano/src/lib.rs

Co-authored-by: marc0246 <40955683+marc0246@users.noreply.github.com>

* Update vulkano/src/lib.rs

Co-authored-by: marc0246 <40955683+marc0246@users.noreply.github.com>

* Update vulkano/src/lib.rs

Co-authored-by: marc0246 <40955683+marc0246@users.noreply.github.com>

* Better solution

* Revert to original state

---------

Co-authored-by: marc0246 <40955683+marc0246@users.noreply.github.com>
This commit is contained in:
Rua 2023-05-05 18:11:43 +02:00 committed by GitHub
parent d68001943f
commit 59e0df378e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 711 additions and 621 deletions

View File

@ -42,13 +42,13 @@ fn errors_output(members: &[ErrorsMember]) -> TokenStream {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[repr(i32)]
#[non_exhaustive]
pub enum VulkanError {
pub enum RuntimeError {
#(#enum_items)*
Unnamed(ash::vk::Result),
}
impl From<ash::vk::Result> for VulkanError {
fn from(val: ash::vk::Result) -> VulkanError {
impl From<ash::vk::Result> for RuntimeError {
fn from(val: ash::vk::Result) -> RuntimeError {
match val {
#(#try_from_items)*
x => Self::Unnamed(x),

View File

@ -123,7 +123,7 @@ use crate::{
},
range_map::RangeMap,
sync::{future::AccessError, CurrentAccess, Sharing},
DeviceSize, NonZeroDeviceSize, RequirementNotMet, RequiresOneOf, Version, VulkanError,
DeviceSize, NonZeroDeviceSize, RequirementNotMet, RequiresOneOf, RuntimeError, Version,
VulkanObject,
};
use parking_lot::{Mutex, MutexGuard};
@ -780,7 +780,7 @@ struct BufferRangeState {
/// Error that can happen in buffer functions.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum BufferError {
VulkanError(VulkanError),
RuntimeError(RuntimeError),
/// Allocating memory failed.
AllocError(AllocationCreationError),
@ -870,7 +870,7 @@ pub enum BufferError {
impl Error for BufferError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
Self::VulkanError(err) => Some(err),
Self::RuntimeError(err) => Some(err),
Self::AllocError(err) => Some(err),
_ => None,
}
@ -880,7 +880,7 @@ impl Error for BufferError {
impl Display for BufferError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
match self {
Self::VulkanError(_) => write!(f, "a runtime error occurred"),
Self::RuntimeError(_) => write!(f, "a runtime error occurred"),
Self::AllocError(_) => write!(f, "allocating memory failed"),
Self::RequirementNotMet {
required_for,
@ -992,9 +992,9 @@ impl Display for BufferError {
}
}
impl From<VulkanError> for BufferError {
fn from(err: VulkanError) -> Self {
Self::VulkanError(err)
impl From<RuntimeError> for BufferError {
fn from(err: RuntimeError) -> Self {
Self::RuntimeError(err)
}
}

View File

@ -23,7 +23,7 @@ use crate::{
MemoryPropertyFlags, MemoryRequirements,
},
sync::Sharing,
DeviceSize, RequiresOneOf, Version, VulkanError, VulkanObject,
DeviceSize, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use smallvec::SmallVec;
use std::{mem::MaybeUninit, num::NonZeroU64, ptr, sync::Arc};
@ -200,7 +200,7 @@ impl RawBuffer {
pub unsafe fn new_unchecked(
device: Arc<Device>,
create_info: BufferCreateInfo,
) -> Result<Self, VulkanError> {
) -> Result<Self, RuntimeError> {
let &BufferCreateInfo {
flags,
ref sharing,
@ -252,7 +252,7 @@ impl RawBuffer {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -521,7 +521,7 @@ impl RawBuffer {
pub unsafe fn bind_memory_unchecked(
self,
allocation: MemoryAlloc,
) -> Result<Buffer, (VulkanError, RawBuffer, MemoryAlloc)> {
) -> Result<Buffer, (RuntimeError, RawBuffer, MemoryAlloc)> {
let memory = allocation.device_memory();
let memory_offset = allocation.offset();
@ -561,7 +561,7 @@ impl RawBuffer {
.result();
if let Err(err) = result {
return Err((VulkanError::from(err), self, allocation));
return Err((RuntimeError::from(err), self, allocation));
}
Ok(Buffer::from_raw(self, BufferMemory::Normal(allocation)))

View File

@ -53,7 +53,7 @@ use crate::{
format::{Format, FormatFeatures},
macros::impl_id_counter,
memory::{is_aligned, DeviceAlignment},
DeviceSize, OomError, RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
DeviceSize, OomError, RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use std::{
error::Error,
@ -235,7 +235,7 @@ impl BufferView {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -411,8 +411,8 @@ impl From<OomError> for BufferViewCreationError {
}
}
impl From<VulkanError> for BufferViewCreationError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for BufferViewCreationError {
fn from(err: RuntimeError) -> Self {
OomError::from(err).into()
}
}

View File

@ -19,7 +19,7 @@ use crate::{
command_buffer::CommandBufferLevel,
device::{Device, DeviceOwned},
macros::impl_id_counter,
OomError, RequiresOneOf, Version, VulkanError, VulkanObject,
OomError, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use smallvec::SmallVec;
use std::{
@ -169,7 +169,7 @@ impl CommandPool {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -195,7 +195,7 @@ impl CommandPool {
let fns = self.device.fns();
(fns.v1_0.reset_command_pool)(self.device.handle(), self.handle, flags)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Ok(())
}
@ -232,7 +232,7 @@ impl CommandPool {
out.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
out.set_len(command_buffer_count as usize);
out
}
@ -390,10 +390,10 @@ impl Display for CommandPoolCreationError {
}
}
impl From<VulkanError> for CommandPoolCreationError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for CommandPoolCreationError {
fn from(err: RuntimeError) -> Self {
match err {
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ RuntimeError::OutOfHostMemory => Self::OomError(OomError::from(err)),
_ => panic!("unexpected error: {:?}", err),
}
}
@ -522,8 +522,8 @@ impl Display for CommandPoolTrimError {
}
}
impl From<VulkanError> for CommandPoolTrimError {
fn from(err: VulkanError) -> CommandPoolTrimError {
impl From<RuntimeError> for CommandPoolTrimError {
fn from(err: RuntimeError) -> CommandPoolTrimError {
panic!("unexpected error: {:?}", err)
}
}

View File

@ -55,7 +55,7 @@ use crate::{
BufferMemoryBarrier, DependencyInfo, ImageMemoryBarrier, PipelineStage,
PipelineStageAccess, PipelineStageAccessSet, PipelineStages,
},
DeviceSize, OomError, RequiresOneOf, VulkanError, VulkanObject,
DeviceSize, OomError, RequiresOneOf, RuntimeError, VulkanObject,
};
use ahash::HashMap;
use parking_lot::Mutex;
@ -548,7 +548,7 @@ where
(fns.v1_0.begin_command_buffer)(builder_alloc.inner().handle(), &begin_info_vk)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
}
let mut builder_state: CommandBufferBuilderState = Default::default();
@ -608,7 +608,7 @@ where
let fns = self.device().fns();
(fns.v1_0.end_command_buffer)(self.builder_alloc.inner().handle())
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Ok(PrimaryCommandBuffer {
alloc: self.builder_alloc.into_alloc(),
@ -638,7 +638,7 @@ where
let fns = self.device().fns();
(fns.v1_0.end_command_buffer)(self.builder_alloc.inner().handle())
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let submit_state = match self.usage {
CommandBufferUsage::MultipleSubmit => SubmitState::ExclusiveUse {

View File

@ -21,7 +21,7 @@ use crate::{
},
device::{Device, DeviceOwned},
query::QueryControlFlags,
OomError, VulkanError, VulkanObject,
OomError, RuntimeError, VulkanObject,
};
use smallvec::SmallVec;
use std::{ptr, sync::Arc};
@ -179,7 +179,7 @@ impl UnsafeCommandBufferBuilder {
(fns.v1_0.begin_command_buffer)(pool_alloc.handle(), &begin_info_vk)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
}
Ok(UnsafeCommandBufferBuilder {
@ -196,7 +196,7 @@ impl UnsafeCommandBufferBuilder {
let fns = self.device.fns();
(fns.v1_0.end_command_buffer)(self.handle)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Ok(UnsafeCommandBuffer {
command_buffer: self.handle,

View File

@ -18,7 +18,7 @@
use crate::{
device::{Device, DeviceOwned},
RequiresOneOf, VulkanError, VulkanObject,
RequiresOneOf, RuntimeError, VulkanObject,
};
use std::{
error::Error,
@ -66,7 +66,7 @@ impl DeferredOperation {
}
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn new_unchecked(device: Arc<Device>) -> Result<Arc<Self>, VulkanError> {
pub unsafe fn new_unchecked(device: Arc<Device>) -> Result<Arc<Self>, RuntimeError> {
let handle = {
let fns = device.fns();
let mut output = MaybeUninit::uninit();
@ -75,7 +75,7 @@ impl DeferredOperation {
device.handle(), ptr::null(), output.as_mut_ptr()
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -96,7 +96,7 @@ impl DeferredOperation {
}
/// Executes a portion of the operation on the current thread.
pub fn join(&self) -> Result<DeferredOperationJoinStatus, VulkanError> {
pub fn join(&self) -> Result<DeferredOperationJoinStatus, RuntimeError> {
let result = unsafe {
let fns = self.device.fns();
(fns.khr_deferred_host_operations.deferred_operation_join_khr)(
@ -109,12 +109,12 @@ impl DeferredOperation {
ash::vk::Result::SUCCESS => Ok(DeferredOperationJoinStatus::Complete),
ash::vk::Result::THREAD_DONE_KHR => Ok(DeferredOperationJoinStatus::ThreadDone),
ash::vk::Result::THREAD_IDLE_KHR => Ok(DeferredOperationJoinStatus::ThreadIdle),
err => Err(VulkanError::from(err)),
err => Err(RuntimeError::from(err)),
}
}
/// Returns the result of the operation, or `None` if the operation is not yet complete.
pub fn result(&self) -> Option<Result<(), VulkanError>> {
pub fn result(&self) -> Option<Result<(), RuntimeError>> {
let result = unsafe {
let fns = self.device.fns();
(fns.khr_deferred_host_operations
@ -124,12 +124,12 @@ impl DeferredOperation {
match result {
ash::vk::Result::NOT_READY => None,
ash::vk::Result::SUCCESS => Some(Ok(())),
err => Some(Err(VulkanError::from(err))),
err => Some(Err(RuntimeError::from(err))),
}
}
/// Waits for the operation to complete, then returns its result.
pub fn wait(&self) -> Result<Result<(), VulkanError>, VulkanError> {
pub fn wait(&self) -> Result<Result<(), RuntimeError>, RuntimeError> {
// Based on example code on the extension's spec page.
// Call `join` until we get `Complete` or `ThreadDone`.
@ -207,7 +207,7 @@ unsafe impl DeviceOwned for DeferredOperation {
/// Error that can happen when creating a `DeferredOperation`.
#[derive(Clone, Debug)]
pub enum DeferredOperationCreateError {
VulkanError(VulkanError),
RuntimeError(RuntimeError),
RequirementNotMet {
required_for: &'static str,
@ -218,7 +218,7 @@ pub enum DeferredOperationCreateError {
impl Display for DeferredOperationCreateError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::VulkanError(_) => write!(f, "a runtime error occurred"),
Self::RuntimeError(_) => write!(f, "a runtime error occurred"),
Self::RequirementNotMet {
required_for,
requires_one_of,
@ -234,15 +234,15 @@ impl Display for DeferredOperationCreateError {
impl Error for DeferredOperationCreateError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
Self::VulkanError(err) => Some(err),
Self::RuntimeError(err) => Some(err),
_ => None,
}
}
}
impl From<VulkanError> for DeferredOperationCreateError {
fn from(err: VulkanError) -> Self {
Self::VulkanError(err)
impl From<RuntimeError> for DeferredOperationCreateError {
fn from(err: RuntimeError) -> Self {
Self::RuntimeError(err)
}
}

View File

@ -16,7 +16,7 @@ use crate::{
macros::{impl_id_counter, vulkan_enum},
sampler::Sampler,
shader::{DescriptorBindingRequirements, ShaderStages},
OomError, RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
OomError, RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use ahash::HashMap;
use std::{
@ -229,7 +229,7 @@ impl DescriptorSetLayout {
pub unsafe fn new_unchecked(
device: Arc<Device>,
create_info: DescriptorSetLayoutCreateInfo,
) -> Result<Arc<DescriptorSetLayout>, VulkanError> {
) -> Result<Arc<DescriptorSetLayout>, RuntimeError> {
let &DescriptorSetLayoutCreateInfo {
ref bindings,
push_descriptor,
@ -314,7 +314,7 @@ impl DescriptorSetLayout {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -487,8 +487,8 @@ pub enum DescriptorSetLayoutCreationError {
VariableDescriptorCountDescriptorTypeIncompatible { binding_num: u32 },
}
impl From<VulkanError> for DescriptorSetLayoutCreationError {
fn from(error: VulkanError) -> Self {
impl From<RuntimeError> for DescriptorSetLayoutCreationError {
fn from(error: RuntimeError) -> Self {
Self::OomError(error.into())
}
}

View File

@ -14,7 +14,7 @@ use crate::{
},
device::{Device, DeviceOwned},
macros::impl_id_counter,
OomError, Version, VulkanError, VulkanObject,
OomError, RuntimeError, Version, VulkanObject,
};
use ahash::HashMap;
use smallvec::SmallVec;
@ -109,7 +109,7 @@ impl DescriptorPool {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
}
};
@ -297,7 +297,7 @@ impl DescriptorPool {
sets.as_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
}
Ok(())
@ -315,7 +315,7 @@ impl DescriptorPool {
ash::vk::DescriptorPoolResetFlags::empty(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Ok(())
}

View File

@ -115,7 +115,7 @@ pub use crate::{
};
use crate::{
instance::Instance, macros::impl_id_counter, memory::ExternalMemoryHandleType, OomError,
RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use ash::vk::Handle;
use parking_lot::Mutex;
@ -395,7 +395,7 @@ impl Device {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -557,7 +557,7 @@ impl Device {
&mut memory_fd_properties,
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Ok(MemoryFdProperties {
memory_type_bits: memory_fd_properties.memory_type_bits,
@ -590,7 +590,7 @@ impl Device {
let fns = self.instance().fns();
(fns.ext_debug_utils.set_debug_utils_object_name_ext)(self.handle, &info)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
}
Ok(())
@ -611,7 +611,7 @@ impl Device {
let fns = self.fns();
(fns.v1_0.device_wait_idle)(self.handle)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Ok(())
}
@ -716,16 +716,16 @@ impl Display for DeviceCreationError {
}
}
impl From<VulkanError> for DeviceCreationError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for DeviceCreationError {
fn from(err: RuntimeError) -> Self {
match err {
VulkanError::InitializationFailed => Self::InitializationFailed,
VulkanError::OutOfHostMemory => Self::OutOfHostMemory,
VulkanError::OutOfDeviceMemory => Self::OutOfDeviceMemory,
VulkanError::DeviceLost => Self::DeviceLost,
VulkanError::ExtensionNotPresent => Self::ExtensionNotPresent,
VulkanError::FeatureNotPresent => Self::FeatureNotPresent,
VulkanError::TooManyObjects => Self::TooManyObjects,
RuntimeError::InitializationFailed => Self::InitializationFailed,
RuntimeError::OutOfHostMemory => Self::OutOfHostMemory,
RuntimeError::OutOfDeviceMemory => Self::OutOfDeviceMemory,
RuntimeError::DeviceLost => Self::DeviceLost,
RuntimeError::ExtensionNotPresent => Self::ExtensionNotPresent,
RuntimeError::FeatureNotPresent => Self::FeatureNotPresent,
RuntimeError::TooManyObjects => Self::TooManyObjects,
_ => panic!("Unexpected error value"),
}
}
@ -891,11 +891,11 @@ impl Display for MemoryFdPropertiesError {
}
}
impl From<VulkanError> for MemoryFdPropertiesError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for MemoryFdPropertiesError {
fn from(err: RuntimeError) -> Self {
match err {
VulkanError::OutOfHostMemory => Self::OutOfHostMemory,
VulkanError::InvalidExternalHandle => Self::InvalidExternalHandle,
RuntimeError::OutOfHostMemory => Self::OutOfHostMemory,
RuntimeError::InvalidExternalHandle => Self::InvalidExternalHandle,
_ => panic!("Unexpected error value"),
}
}

View File

@ -28,7 +28,7 @@ use crate::{
fence::{ExternalFenceInfo, ExternalFenceProperties},
semaphore::{ExternalSemaphoreInfo, ExternalSemaphoreProperties},
},
ExtensionProperties, RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
ExtensionProperties, RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use bytemuck::cast_slice;
use std::{
@ -95,7 +95,7 @@ impl PhysicalDevice {
pub unsafe fn from_handle(
instance: Arc<Instance>,
handle: ash::vk::PhysicalDevice,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let api_version = Self::get_api_version(handle, &instance);
let extension_properties = Self::get_extension_properties(handle, &instance)?;
let supported_extensions: DeviceExtensions = extension_properties
@ -160,7 +160,7 @@ impl PhysicalDevice {
unsafe fn get_extension_properties(
handle: ash::vk::PhysicalDevice,
instance: &Instance,
) -> Result<Vec<ExtensionProperties>, VulkanError> {
) -> Result<Vec<ExtensionProperties>, RuntimeError> {
let fns = instance.fns();
loop {
@ -172,7 +172,7 @@ impl PhysicalDevice {
ptr::null_mut(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut output = Vec::with_capacity(count as usize);
let result = (fns.v1_0.enumerate_device_extension_properties)(
@ -188,7 +188,7 @@ impl PhysicalDevice {
return Ok(output.into_iter().map(Into::into).collect());
}
ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err)),
err => return Err(RuntimeError::from(err)),
}
}
}
@ -1034,7 +1034,7 @@ impl PhysicalDevice {
pub unsafe fn image_format_properties_unchecked(
&self,
mut image_format_info: ImageFormatInfo,
) -> Result<Option<ImageFormatProperties>, VulkanError> {
) -> Result<Option<ImageFormatProperties>, RuntimeError> {
{
let ImageFormatInfo {
format,
@ -1179,7 +1179,7 @@ impl PhysicalDevice {
)
}
.result()
.map_err(VulkanError::from)
.map_err(RuntimeError::from)
};
Ok(match result {
@ -1197,7 +1197,7 @@ impl PhysicalDevice {
}),
..properties2_vk.image_format_properties.into()
}),
Err(VulkanError::FormatNotSupported) => None,
Err(RuntimeError::FormatNotSupported) => None,
Err(err) => return Err(err),
})
})
@ -1546,7 +1546,7 @@ impl PhysicalDevice {
&self,
surface: &Surface,
surface_info: SurfaceInfo,
) -> Result<SurfaceCapabilities, VulkanError> {
) -> Result<SurfaceCapabilities, RuntimeError> {
/* Input */
let SurfaceInfo {
@ -1625,7 +1625,7 @@ impl PhysicalDevice {
&mut capabilities_vk,
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
} else {
(fns.khr_surface.get_physical_device_surface_capabilities_khr)(
self.handle(),
@ -1633,7 +1633,7 @@ impl PhysicalDevice {
&mut capabilities_vk.surface_capabilities,
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
};
Ok(SurfaceCapabilities {
@ -1785,7 +1785,7 @@ impl PhysicalDevice {
&self,
surface: &Surface,
surface_info: SurfaceInfo,
) -> Result<Vec<(Format, ColorSpace)>, VulkanError> {
) -> Result<Vec<(Format, ColorSpace)>, RuntimeError> {
surface.surface_formats.get_or_try_insert(
(self.handle, surface_info),
|(_, surface_info)| {
@ -1849,7 +1849,7 @@ impl PhysicalDevice {
ptr::null_mut(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut surface_format2s =
vec![ash::vk::SurfaceFormat2KHR::default(); count as usize];
@ -1868,7 +1868,7 @@ impl PhysicalDevice {
break surface_format2s;
}
ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err)),
err => return Err(RuntimeError::from(err)),
}
};
@ -1889,7 +1889,7 @@ impl PhysicalDevice {
ptr::null_mut(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut surface_formats = Vec::with_capacity(count as usize);
let result = (fns.khr_surface.get_physical_device_surface_formats_khr)(
@ -1905,7 +1905,7 @@ impl PhysicalDevice {
break surface_formats;
}
ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err)),
err => return Err(RuntimeError::from(err)),
}
};
@ -1967,7 +1967,7 @@ impl PhysicalDevice {
pub unsafe fn surface_present_modes_unchecked(
&self,
surface: &Surface,
) -> Result<impl Iterator<Item = PresentMode>, VulkanError> {
) -> Result<impl Iterator<Item = PresentMode>, RuntimeError> {
surface
.surface_present_modes
.get_or_try_insert(self.handle, |_| {
@ -1983,7 +1983,7 @@ impl PhysicalDevice {
ptr::null_mut(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut modes = Vec::with_capacity(count as usize);
let result = (fns
@ -2001,7 +2001,7 @@ impl PhysicalDevice {
break modes;
}
ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err)),
err => return Err(RuntimeError::from(err)),
}
};
@ -2059,7 +2059,7 @@ impl PhysicalDevice {
&self,
queue_family_index: u32,
surface: &Surface,
) -> Result<bool, VulkanError> {
) -> Result<bool, RuntimeError> {
surface
.surface_support
.get_or_try_insert((self.handle, queue_family_index), |_| {
@ -2073,7 +2073,7 @@ impl PhysicalDevice {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Ok(output.assume_init() != 0)
})
@ -2111,7 +2111,7 @@ impl PhysicalDevice {
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
#[inline]
pub unsafe fn tool_properties_unchecked(&self) -> Result<Vec<ToolProperties>, VulkanError> {
pub unsafe fn tool_properties_unchecked(&self) -> Result<Vec<ToolProperties>, RuntimeError> {
let fns = self.instance.fns();
loop {
@ -2131,7 +2131,7 @@ impl PhysicalDevice {
)
}
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut tool_properties = Vec::with_capacity(count as usize);
let result = if self.api_version() >= Version::V1_3 {
@ -2180,7 +2180,7 @@ impl PhysicalDevice {
})
.collect());
}
err => return Err(VulkanError::from(err)),
err => return Err(RuntimeError::from(err)),
}
}
}
@ -2787,7 +2787,7 @@ vulkan_enum! {
/// Error that can happen when using a physical device.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum PhysicalDeviceError {
VulkanError(VulkanError),
RuntimeError(RuntimeError),
RequirementNotMet {
required_for: &'static str,
@ -2811,7 +2811,7 @@ pub enum PhysicalDeviceError {
impl Error for PhysicalDeviceError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
Self::VulkanError(err) => Some(err),
Self::RuntimeError(err) => Some(err),
_ => None,
}
}
@ -2820,7 +2820,7 @@ impl Error for PhysicalDeviceError {
impl Display for PhysicalDeviceError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
match self {
Self::VulkanError(_) => write!(f, "a runtime error occurred"),
Self::RuntimeError(_) => write!(f, "a runtime error occurred"),
Self::RequirementNotMet {
required_for,
requires_one_of,
@ -2851,9 +2851,9 @@ impl Display for PhysicalDeviceError {
}
}
impl From<VulkanError> for PhysicalDeviceError {
fn from(err: VulkanError) -> Self {
Self::VulkanError(err)
impl From<RuntimeError> for PhysicalDeviceError {
fn from(err: RuntimeError) -> Self {
Self::RuntimeError(err)
}
}

View File

@ -26,7 +26,7 @@ use crate::{
future::{AccessCheckError, FlushError, GpuFuture},
semaphore::SemaphoreState,
},
OomError, RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
OomError, RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use ahash::HashMap;
use parking_lot::{Mutex, MutexGuard};
@ -172,7 +172,7 @@ impl<'a> QueueGuard<'a> {
&mut self,
bind_infos: impl IntoIterator<Item = BindSparseInfo>,
fence: Option<Arc<Fence>>,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
let bind_infos: SmallVec<[_; 4]> = bind_infos.into_iter().collect();
let mut states = States::from_bind_infos(&bind_infos);
@ -191,7 +191,7 @@ impl<'a> QueueGuard<'a> {
bind_infos: &SmallVec<[BindSparseInfo; 4]>,
fence: Option<(&Arc<Fence>, MutexGuard<'_, FenceState>)>,
states: &mut States<'_>,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
struct PerBindSparseInfo {
wait_semaphores_vk: SmallVec<[ash::vk::Semaphore; 4]>,
buffer_bind_infos_vk: SmallVec<[ash::vk::SparseBufferMemoryBindInfo; 4]>,
@ -448,7 +448,7 @@ impl<'a> QueueGuard<'a> {
.map_or_else(Default::default, |(fence, _)| fence.handle()),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
for bind_info in bind_infos {
let BindSparseInfo {
@ -488,7 +488,7 @@ impl<'a> QueueGuard<'a> {
pub unsafe fn present_unchecked(
&mut self,
present_info: PresentInfo,
) -> Result<impl ExactSizeIterator<Item = Result<bool, VulkanError>>, VulkanError> {
) -> Result<impl ExactSizeIterator<Item = Result<bool, RuntimeError>>, RuntimeError> {
let mut states = States::from_present_info(&present_info);
self.present_unchecked_locked(&present_info, &mut states)
}
@ -497,7 +497,7 @@ impl<'a> QueueGuard<'a> {
&mut self,
present_info: &PresentInfo,
states: &mut States<'_>,
) -> Result<impl ExactSizeIterator<Item = Result<bool, VulkanError>>, VulkanError> {
) -> Result<impl ExactSizeIterator<Item = Result<bool, RuntimeError>>, RuntimeError> {
let PresentInfo {
ref wait_semaphores,
ref swapchain_infos,
@ -607,7 +607,7 @@ impl<'a> QueueGuard<'a> {
| ash::vk::Result::ERROR_SURFACE_LOST_KHR
| ash::vk::Result::ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT,
) {
return Err(VulkanError::from(result));
return Err(RuntimeError::from(result));
}
for semaphore in wait_semaphores {
@ -633,7 +633,7 @@ impl<'a> QueueGuard<'a> {
Ok(results.into_iter().map(|result| match result {
ash::vk::Result::SUCCESS => Ok(false),
ash::vk::Result::SUBOPTIMAL_KHR => Ok(true),
err => Err(VulkanError::from(err)),
err => Err(RuntimeError::from(err)),
}))
}
@ -767,7 +767,7 @@ impl<'a> QueueGuard<'a> {
&mut self,
submit_infos: impl IntoIterator<Item = SubmitInfo>,
fence: Option<Arc<Fence>>,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
let submit_infos: SmallVec<[_; 4]> = submit_infos.into_iter().collect();
let mut states = States::from_submit_infos(&submit_infos);
@ -786,7 +786,7 @@ impl<'a> QueueGuard<'a> {
submit_infos: &SmallVec<[SubmitInfo; 4]>,
fence: Option<(&Arc<Fence>, MutexGuard<'_, FenceState>)>,
states: &mut States<'_>,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
if self.queue.device.enabled_features().synchronization2 {
struct PerSubmitInfo {
wait_semaphore_infos_vk: SmallVec<[ash::vk::SemaphoreSubmitInfo; 4]>,
@ -915,7 +915,7 @@ impl<'a> QueueGuard<'a> {
)
}
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
} else {
struct PerSubmitInfo {
wait_semaphores_vk: SmallVec<[ash::vk::Semaphore; 4]>,
@ -1017,7 +1017,7 @@ impl<'a> QueueGuard<'a> {
.map_or_else(Default::default, |(fence, _)| fence.handle()),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
}
for submit_info in submit_infos {
@ -1276,7 +1276,7 @@ impl QueueState {
let fns = device.fns();
(fns.v1_0.queue_wait_idle)(handle)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
// Since we now know that the queue is finished with all work,
// we can safely release all resources.
@ -1649,7 +1649,7 @@ vulkan_bitflags! {
/// Error that can happen when submitting work to a queue.
#[derive(Clone, Debug)]
pub enum QueueError {
VulkanError(VulkanError),
RuntimeError(RuntimeError),
RequirementNotMet {
required_for: &'static str,
@ -1660,7 +1660,7 @@ pub enum QueueError {
impl Error for QueueError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
QueueError::VulkanError(err) => Some(err),
QueueError::RuntimeError(err) => Some(err),
_ => None,
}
}
@ -1669,7 +1669,7 @@ impl Error for QueueError {
impl Display for QueueError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
match self {
Self::VulkanError(_) => write!(f, "a runtime error occurred"),
Self::RuntimeError(_) => write!(f, "a runtime error occurred"),
Self::RequirementNotMet {
required_for,
requires_one_of,
@ -1682,9 +1682,9 @@ impl Display for QueueError {
}
}
impl From<VulkanError> for QueueError {
fn from(err: VulkanError) -> Self {
Self::VulkanError(err)
impl From<RuntimeError> for QueueError {
fn from(err: RuntimeError) -> Self {
Self::RuntimeError(err)
}
}

View File

@ -31,7 +31,7 @@ use crate::{
},
sampler::Filter,
sync::Sharing,
DeviceSize, VulkanError,
DeviceSize, RuntimeError,
};
use smallvec::{smallvec, SmallVec};
use std::{
@ -455,8 +455,8 @@ impl From<AllocationCreationError> for ImmutableImageCreationError {
}
}
impl From<VulkanError> for ImmutableImageCreationError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for ImmutableImageCreationError {
fn from(err: RuntimeError) -> Self {
Self::AllocError(err.into())
}
}

View File

@ -36,7 +36,7 @@ use crate::{
range_map::RangeMap,
swapchain::Swapchain,
sync::{future::AccessError, CurrentAccess, Sharing},
DeviceSize, RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
DeviceSize, RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use ash::vk::ImageDrmFormatModifierExplicitCreateInfoEXT;
use parking_lot::{Mutex, MutexGuard};
@ -871,7 +871,7 @@ impl RawImage {
pub unsafe fn new_unchecked(
device: Arc<Device>,
create_info: ImageCreateInfo,
) -> Result<Self, VulkanError> {
) -> Result<Self, RuntimeError> {
let &ImageCreateInfo {
flags,
dimensions,
@ -980,7 +980,7 @@ impl RawImage {
let mut output = MaybeUninit::uninit();
(fns.v1_0.create_image)(device.handle(), &info_vk, ptr::null(), output.as_mut_ptr())
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -1537,7 +1537,7 @@ impl RawImage {
) -> Result<
Image,
(
VulkanError,
RuntimeError,
RawImage,
impl ExactSizeIterator<Item = MemoryAlloc>,
),
@ -1624,7 +1624,7 @@ impl RawImage {
.result();
if let Err(err) = result {
return Err((VulkanError::from(err), self, allocations.into_iter()));
return Err((RuntimeError::from(err), self, allocations.into_iter()));
}
Ok(Image::from_raw(self, ImageMemory::Normal(allocations)))
@ -2792,7 +2792,7 @@ pub struct SubresourceLayout {
/// Error that can happen in image functions.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ImageError {
VulkanError(VulkanError),
RuntimeError(RuntimeError),
/// Allocating memory failed.
AllocError(AllocationCreationError),
@ -3013,7 +3013,7 @@ impl Error for ImageError {
impl Display for ImageError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
match self {
Self::VulkanError(_) => write!(f, "a runtime error occurred"),
Self::RuntimeError(_) => write!(f, "a runtime error occurred"),
Self::AllocError(_) => write!(f, "allocating memory failed"),
Self::RequirementNotMet {
required_for,
@ -3263,9 +3263,9 @@ impl Display for ImageError {
}
}
impl From<VulkanError> for ImageError {
fn from(err: VulkanError) -> Self {
Self::VulkanError(err)
impl From<RuntimeError> for ImageError {
fn from(err: RuntimeError) -> Self {
Self::RuntimeError(err)
}
}

View File

@ -22,7 +22,7 @@ use crate::{
image::{ImageAspects, ImageCreateFlags, ImageTiling, ImageType, SampleCount},
macros::{impl_id_counter, vulkan_enum},
sampler::{ycbcr::SamplerYcbcrConversion, ComponentMapping},
OomError, RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
OomError, RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use std::{
error::Error,
@ -525,7 +525,7 @@ where
pub unsafe fn new_unchecked(
image: Arc<I>,
create_info: ImageViewCreateInfo,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let format_features = Self::get_format_features(create_info.format.unwrap(), image.inner());
Self::new_unchecked_with_format_features(image, create_info, format_features)
}
@ -534,7 +534,7 @@ where
image: Arc<I>,
create_info: ImageViewCreateInfo,
format_features: FormatFeatures,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let &ImageViewCreateInfo {
view_type,
format,
@ -600,7 +600,7 @@ where
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -624,7 +624,7 @@ where
image: Arc<I>,
handle: ash::vk::ImageView,
create_info: ImageViewCreateInfo,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let format_features = Self::get_format_features(create_info.format.unwrap(), image.inner());
Self::from_handle_with_format_features(image, handle, create_info, format_features)
}
@ -634,7 +634,7 @@ where
handle: ash::vk::ImageView,
create_info: ImageViewCreateInfo,
format_features: FormatFeatures,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let ImageViewCreateInfo {
view_type,
format,
@ -1139,11 +1139,11 @@ impl From<OomError> for ImageViewCreationError {
}
}
impl From<VulkanError> for ImageViewCreationError {
fn from(err: VulkanError) -> ImageViewCreationError {
impl From<RuntimeError> for ImageViewCreationError {
fn from(err: RuntimeError) -> ImageViewCreationError {
match err {
err @ VulkanError::OutOfHostMemory => OomError::from(err).into(),
err @ VulkanError::OutOfDeviceMemory => OomError::from(err).into(),
err @ RuntimeError::OutOfHostMemory => OomError::from(err).into(),
err @ RuntimeError::OutOfDeviceMemory => OomError::from(err).into(),
_ => panic!("unexpected error: {:?}", err),
}
}

View File

@ -44,7 +44,7 @@
use super::Instance;
use crate::{
macros::{vulkan_bitflags, vulkan_enum},
RequirementNotMet, RequiresOneOf, VulkanError, VulkanObject,
RequirementNotMet, RequiresOneOf, RuntimeError, VulkanObject,
};
use std::{
error::Error,
@ -169,7 +169,7 @@ impl DebugUtilsMessenger {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -270,8 +270,8 @@ impl Display for DebugUtilsMessengerCreationError {
}
}
impl From<VulkanError> for DebugUtilsMessengerCreationError {
fn from(err: VulkanError) -> DebugUtilsMessengerCreationError {
impl From<RuntimeError> for DebugUtilsMessengerCreationError {
fn from(err: RuntimeError) -> DebugUtilsMessengerCreationError {
panic!("unexpected error: {:?}", err)
}
}

View File

@ -85,7 +85,7 @@ use self::debug::{
pub use self::{extensions::InstanceExtensions, layers::LayerProperties};
use crate::{
device::physical::PhysicalDevice, instance::debug::trampoline, macros::impl_id_counter,
OomError, RequiresOneOf, VulkanError, VulkanLibrary, VulkanObject,
OomError, RequiresOneOf, RuntimeError, VulkanLibrary, VulkanObject,
};
pub use crate::{
extensions::{ExtensionRestriction, ExtensionRestrictionError},
@ -517,7 +517,7 @@ impl Instance {
let fns = library.fns();
(fns.v1_0.create_instance)(&create_info_vk, ptr::null(), output.as_mut_ptr())
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -601,7 +601,7 @@ impl Instance {
/// ```
pub fn enumerate_physical_devices(
self: &Arc<Self>,
) -> Result<impl ExactSizeIterator<Item = Arc<PhysicalDevice>>, VulkanError> {
) -> Result<impl ExactSizeIterator<Item = Arc<PhysicalDevice>>, RuntimeError> {
let fns = self.fns();
unsafe {
@ -609,7 +609,7 @@ impl Instance {
let mut count = 0;
(fns.v1_0.enumerate_physical_devices)(self.handle, &mut count, ptr::null_mut())
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut handles = Vec::with_capacity(count as usize);
let result = (fns.v1_0.enumerate_physical_devices)(
@ -624,7 +624,7 @@ impl Instance {
break handles;
}
ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err)),
err => return Err(RuntimeError::from(err)),
}
};
@ -872,15 +872,15 @@ impl From<ExtensionRestrictionError> for InstanceCreationError {
}
}
impl From<VulkanError> for InstanceCreationError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for InstanceCreationError {
fn from(err: RuntimeError) -> Self {
match err {
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ VulkanError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
VulkanError::InitializationFailed => Self::InitializationFailed,
VulkanError::LayerNotPresent => Self::LayerNotPresent,
VulkanError::ExtensionNotPresent => Self::ExtensionNotPresent,
VulkanError::IncompatibleDriver => Self::IncompatibleDriver,
err @ RuntimeError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ RuntimeError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
RuntimeError::InitializationFailed => Self::InitializationFailed,
RuntimeError::LayerNotPresent => Self::LayerNotPresent,
RuntimeError::ExtensionNotPresent => Self::ExtensionNotPresent,
RuntimeError::IncompatibleDriver => Self::IncompatibleDriver,
_ => panic!("unexpected error: {:?}", err),
}
}

View File

@ -157,6 +157,7 @@ pub use ash::vk::Handle;
pub use half;
pub use library::{LoadingError, VulkanLibrary};
use std::{
borrow::Cow,
error::Error,
fmt::{Display, Error as FmtError, Formatter},
num::NonZeroU64,
@ -237,140 +238,114 @@ where
}
}
/// Error type returned by most Vulkan functions.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum OomError {
/// There is no memory available on the host (ie. the CPU, RAM, etc.).
OutOfHostMemory,
/// There is no memory available on the device (ie. video memory).
OutOfDeviceMemory,
/// An error that can happen when calling a safe (validated) function that makes a call to the
/// Vulkan API.
#[derive(Clone, Debug)]
pub enum VulkanError {
/// The function call was invalid in some way.
ValidationError(ValidationError),
/// The Vulkan driver returned an error and was unable to complete the operation.
RuntimeError(RuntimeError),
}
impl Error for OomError {}
impl Display for OomError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(
f,
"{}",
match self {
OomError::OutOfHostMemory => "no memory available on the host",
OomError::OutOfDeviceMemory => "no memory available on the graphical device",
}
)
}
}
impl From<VulkanError> for OomError {
fn from(err: VulkanError) -> OomError {
match err {
VulkanError::OutOfHostMemory => OomError::OutOfHostMemory,
VulkanError::OutOfDeviceMemory => OomError::OutOfDeviceMemory,
_ => panic!("unexpected error: {:?}", err),
impl Display for VulkanError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::ValidationError(_) => write!(f, "a validation error occurred"),
Self::RuntimeError(_) => write!(f, "a runtime error occurred"),
}
}
}
// Generated by build.rs
include!(concat!(env!("OUT_DIR"), "/errors.rs"));
impl Error for VulkanError {}
impl Display for VulkanError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(
f,
"{}",
match self {
VulkanError::OutOfHostMemory => "a host memory allocation has failed",
VulkanError::OutOfDeviceMemory => "a device memory allocation has failed",
VulkanError::InitializationFailed => {
"initialization of an object could not be completed for \
implementation-specific reasons"
}
VulkanError::DeviceLost => "the logical or physical device has been lost",
VulkanError::MemoryMapFailed => "mapping of a memory object has failed",
VulkanError::LayerNotPresent => {
"a requested layer is not present or could not be loaded"
}
VulkanError::ExtensionNotPresent => "a requested extension is not supported",
VulkanError::FeatureNotPresent => "a requested feature is not supported",
VulkanError::IncompatibleDriver => {
"the requested version of Vulkan is not supported by the driver or is \
otherwise incompatible for implementation-specific reasons"
}
VulkanError::TooManyObjects => {
"too many objects of the type have already been created"
}
VulkanError::FormatNotSupported => {
"a requested format is not supported on this device"
}
VulkanError::FragmentedPool => {
"a pool allocation has failed due to fragmentation of the pool's memory"
}
VulkanError::Unknown => {
"an unknown error has occurred; either the application has provided invalid \
input, or an implementation failure has occurred"
}
VulkanError::OutOfPoolMemory => "a pool memory allocation has failed",
VulkanError::InvalidExternalHandle => {
"an external handle is not a valid handle of the specified type"
}
VulkanError::Fragmentation => {
"a descriptor pool creation has failed due to fragmentation"
}
VulkanError::InvalidOpaqueCaptureAddress => {
"a buffer creation or memory allocation failed because the requested address \
is not available. A shader group handle assignment failed because the \
requested shader group handle information is no longer valid"
}
VulkanError::IncompatibleDisplay => {
"the display used by a swapchain does not use the same presentable image \
layout, or is incompatible in a way that prevents sharing an image"
}
VulkanError::NotPermitted => "a requested operation was not permitted",
VulkanError::SurfaceLost => "a surface is no longer available",
VulkanError::NativeWindowInUse => {
"the requested window is already in use by Vulkan or another API in a manner \
which prevents it from being used again"
}
VulkanError::OutOfDate => {
"a surface has changed in such a way that it is no longer compatible with the \
swapchain, and further presentation requests using the swapchain will fail"
}
VulkanError::ValidationFailed => "validation failed",
VulkanError::FullScreenExclusiveModeLost => {
"an operation on a swapchain created with application controlled full-screen \
access failed as it did not have exclusive full-screen access"
}
VulkanError::InvalidDrmFormatModifierPlaneLayout => {
"the requested DRM format modifier plane layout is invalid"
}
VulkanError::InvalidShader => "one or more shaders failed to compile or link",
VulkanError::ImageUsageNotSupported =>
"the requested `ImageUsage` are not supported",
VulkanError::VideoPictureLayoutNotSupported =>
"the requested video picture layout is not supported",
VulkanError::VideoProfileOperationNotSupported =>
"a video profile operation specified via \
`VideoProfileInfo::video_codec_operation` is not supported",
VulkanError::VideoProfileFormatNotSupported =>
"format parameters in a requested `VideoProfileInfo` chain are not supported",
VulkanError::VideoProfileCodecNotSupported =>
"codec-specific parameters in a requested `VideoProfileInfo` chain are not \
supported",
VulkanError::VideoStdVersionNotSupported =>
"the specified video Std header version is not supported",
VulkanError::CompressionExhausted =>
"an image creation failed because internal resources required for compression \
are exhausted",
VulkanError::Unnamed(result) =>
return write!(f, "unnamed error, VkResult value {}", result.as_raw()),
}
)
impl Error for VulkanError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
Self::ValidationError(err) => Some(err),
Self::RuntimeError(err) => Some(err),
}
}
}
impl From<ValidationError> for VulkanError {
fn from(err: ValidationError) -> Self {
Self::ValidationError(err)
}
}
impl From<RuntimeError> for VulkanError {
fn from(err: RuntimeError) -> Self {
Self::RuntimeError(err)
}
}
/// The arguments or other context of a call to a Vulkan function were not valid.
#[derive(Clone, Debug, Default)]
pub struct ValidationError {
/// The context in which the problem exists (e.g. a specific parameter).
pub context: Cow<'static, str>,
/// A description of the problem.
pub problem: Cow<'static, str>,
/// If applicable, settings that the user could enable to avoid the problem in the future.
pub requires_one_of: Option<RequiresOneOf>,
/// *Valid Usage IDs* (VUIDs) in the Vulkan specification that relate to the problem.
pub vuids: &'static [&'static str],
}
impl ValidationError {
fn from_requirement(err: RequirementNotMet) -> Self {
Self {
context: "".into(),
problem: err.required_for.into(),
vuids: &[],
requires_one_of: Some(err.requires_one_of),
}
}
fn from_error<E: Error>(err: E) -> Self {
Self {
context: "".into(),
problem: err.to_string().into(),
requires_one_of: None,
vuids: &[],
}
}
}
impl Display for ValidationError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let Self {
context,
problem,
requires_one_of,
vuids,
} = self;
write!(f, "{}: {}", context, problem)?;
if let Some(requires_one_of) = requires_one_of {
write!(f, " -- Requires one of: {}", requires_one_of)?;
}
if !vuids.is_empty() {
write!(f, " (Vulkan VUIDs: {}", vuids[0])?;
for vuid in &vuids[1..] {
write!(f, ", {}", vuid)?;
}
write!(f, ")")?;
}
Ok(())
}
}
impl Error for ValidationError {}
/// Used in errors to indicate a set of alternatives that needs to be available/enabled to allow
/// a given operation.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
@ -475,6 +450,140 @@ pub(crate) struct RequirementNotMet {
pub(crate) requires_one_of: RequiresOneOf,
}
/// Error type returned by most Vulkan functions.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum OomError {
/// There is no memory available on the host (ie. the CPU, RAM, etc.).
OutOfHostMemory,
/// There is no memory available on the device (ie. video memory).
OutOfDeviceMemory,
}
impl Error for OomError {}
impl Display for OomError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(
f,
"{}",
match self {
OomError::OutOfHostMemory => "no memory available on the host",
OomError::OutOfDeviceMemory => "no memory available on the graphical device",
}
)
}
}
impl From<RuntimeError> for OomError {
fn from(err: RuntimeError) -> OomError {
match err {
RuntimeError::OutOfHostMemory => OomError::OutOfHostMemory,
RuntimeError::OutOfDeviceMemory => OomError::OutOfDeviceMemory,
_ => panic!("unexpected error: {:?}", err),
}
}
}
// Generated by build.rs
include!(concat!(env!("OUT_DIR"), "/errors.rs"));
impl Error for RuntimeError {}
impl Display for RuntimeError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
write!(
f,
"{}",
match self {
RuntimeError::OutOfHostMemory => "a host memory allocation has failed",
RuntimeError::OutOfDeviceMemory => "a device memory allocation has failed",
RuntimeError::InitializationFailed => {
"initialization of an object could not be completed for \
implementation-specific reasons"
}
RuntimeError::DeviceLost => "the logical or physical device has been lost",
RuntimeError::MemoryMapFailed => "mapping of a memory object has failed",
RuntimeError::LayerNotPresent => {
"a requested layer is not present or could not be loaded"
}
RuntimeError::ExtensionNotPresent => "a requested extension is not supported",
RuntimeError::FeatureNotPresent => "a requested feature is not supported",
RuntimeError::IncompatibleDriver => {
"the requested version of Vulkan is not supported by the driver or is \
otherwise incompatible for implementation-specific reasons"
}
RuntimeError::TooManyObjects => {
"too many objects of the type have already been created"
}
RuntimeError::FormatNotSupported => {
"a requested format is not supported on this device"
}
RuntimeError::FragmentedPool => {
"a pool allocation has failed due to fragmentation of the pool's memory"
}
RuntimeError::Unknown => {
"an unknown error has occurred; either the application has provided invalid \
input, or an implementation failure has occurred"
}
RuntimeError::OutOfPoolMemory => "a pool memory allocation has failed",
RuntimeError::InvalidExternalHandle => {
"an external handle is not a valid handle of the specified type"
}
RuntimeError::Fragmentation => {
"a descriptor pool creation has failed due to fragmentation"
}
RuntimeError::InvalidOpaqueCaptureAddress => {
"a buffer creation or memory allocation failed because the requested address \
is not available. A shader group handle assignment failed because the \
requested shader group handle information is no longer valid"
}
RuntimeError::IncompatibleDisplay => {
"the display used by a swapchain does not use the same presentable image \
layout, or is incompatible in a way that prevents sharing an image"
}
RuntimeError::NotPermitted => "a requested operation was not permitted",
RuntimeError::SurfaceLost => "a surface is no longer available",
RuntimeError::NativeWindowInUse => {
"the requested window is already in use by Vulkan or another API in a manner \
which prevents it from being used again"
}
RuntimeError::OutOfDate => {
"a surface has changed in such a way that it is no longer compatible with the \
swapchain, and further presentation requests using the swapchain will fail"
}
RuntimeError::ValidationFailed => "validation failed",
RuntimeError::FullScreenExclusiveModeLost => {
"an operation on a swapchain created with application controlled full-screen \
access failed as it did not have exclusive full-screen access"
}
RuntimeError::InvalidDrmFormatModifierPlaneLayout => {
"the requested DRM format modifier plane layout is invalid"
}
RuntimeError::InvalidShader => "one or more shaders failed to compile or link",
RuntimeError::ImageUsageNotSupported =>
"the requested `ImageUsage` are not supported",
RuntimeError::VideoPictureLayoutNotSupported =>
"the requested video picture layout is not supported",
RuntimeError::VideoProfileOperationNotSupported =>
"a video profile operation specified via \
`VideoProfileInfo::video_codec_operation` is not supported",
RuntimeError::VideoProfileFormatNotSupported =>
"format parameters in a requested `VideoProfileInfo` chain are not supported",
RuntimeError::VideoProfileCodecNotSupported =>
"codec-specific parameters in a requested `VideoProfileInfo` chain are not \
supported",
RuntimeError::VideoStdVersionNotSupported =>
"the specified video Std header version is not supported",
RuntimeError::CompressionExhausted =>
"an image creation failed because internal resources required for compression \
are exhausted",
RuntimeError::Unnamed(result) =>
return write!(f, "unnamed error, VkResult value {}", result.as_raw()),
}
)
}
}
/// A helper type for non-exhaustive structs.
///
/// This type cannot be constructed outside Vulkano. Structures with a field of this type can only

View File

@ -21,7 +21,7 @@
pub use crate::fns::EntryFunctions;
use crate::{
instance::{InstanceExtensions, LayerProperties},
ExtensionProperties, OomError, SafeDeref, Version, VulkanError,
ExtensionProperties, OomError, RuntimeError, SafeDeref, Version,
};
use libloading::{Error as LibloadingError, Library};
use std::{
@ -108,7 +108,7 @@ impl VulkanLibrary {
}))
}
unsafe fn get_api_version(loader: &impl Loader) -> Result<Version, VulkanError> {
unsafe fn get_api_version(loader: &impl Loader) -> Result<Version, RuntimeError> {
// Per the Vulkan spec:
// If the vkGetInstanceProcAddr returns NULL for vkEnumerateInstanceVersion, it is a
// Vulkan 1.0 implementation. Otherwise, the application can call vkEnumerateInstanceVersion
@ -120,7 +120,9 @@ impl VulkanLibrary {
let version = if let Some(func) = func {
let func: ash::vk::PFN_vkEnumerateInstanceVersion = transmute(func);
let mut api_version = 0;
func(&mut api_version).result().map_err(VulkanError::from)?;
func(&mut api_version)
.result()
.map_err(RuntimeError::from)?;
Version::from(api_version)
} else {
Version {
@ -136,7 +138,7 @@ impl VulkanLibrary {
unsafe fn get_extension_properties(
fns: &EntryFunctions,
layer: Option<&str>,
) -> Result<Vec<ExtensionProperties>, VulkanError> {
) -> Result<Vec<ExtensionProperties>, RuntimeError> {
let layer_vk = layer.map(|layer| CString::new(layer).unwrap());
loop {
@ -149,7 +151,7 @@ impl VulkanLibrary {
ptr::null_mut(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut output = Vec::with_capacity(count as usize);
let result = (fns.v1_0.enumerate_instance_extension_properties)(
@ -166,7 +168,7 @@ impl VulkanLibrary {
return Ok(output.into_iter().map(Into::into).collect());
}
ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err)),
err => return Err(RuntimeError::from(err)),
}
}
}
@ -228,7 +230,7 @@ impl VulkanLibrary {
let mut count = 0;
(fns.v1_0.enumerate_instance_layer_properties)(&mut count, ptr::null_mut())
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut properties = Vec::with_capacity(count as usize);
let result = (fns.v1_0.enumerate_instance_layer_properties)(
@ -242,7 +244,7 @@ impl VulkanLibrary {
break properties;
}
ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err).into()),
err => return Err(RuntimeError::from(err).into()),
}
}
};
@ -257,7 +259,7 @@ impl VulkanLibrary {
pub fn layer_extension_properties(
&self,
layer: &str,
) -> Result<Vec<ExtensionProperties>, VulkanError> {
) -> Result<Vec<ExtensionProperties>, RuntimeError> {
unsafe { Self::get_extension_properties(&self.fns, Some(layer)) }
}
@ -266,7 +268,7 @@ impl VulkanLibrary {
pub fn supported_layer_extensions(
&self,
layer: &str,
) -> Result<InstanceExtensions, VulkanError> {
) -> Result<InstanceExtensions, RuntimeError> {
Ok(self
.layer_extension_properties(layer)?
.iter()
@ -280,7 +282,7 @@ impl VulkanLibrary {
pub fn supported_extensions_with_layers<'a>(
&self,
layers: impl IntoIterator<Item = &'a str>,
) -> Result<InstanceExtensions, VulkanError> {
) -> Result<InstanceExtensions, RuntimeError> {
layers
.into_iter()
.try_fold(self.supported_extensions, |extensions, layer| {
@ -438,11 +440,11 @@ impl Display for LoadingError {
}
}
impl From<VulkanError> for LoadingError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for LoadingError {
fn from(err: RuntimeError) -> Self {
match err {
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ VulkanError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
err @ RuntimeError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ RuntimeError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
_ => panic!("unexpected error: {:?}", err),
}
}

View File

@ -234,7 +234,7 @@ use super::{
};
use crate::{
device::{Device, DeviceOwned},
DeviceSize, RequirementNotMet, RequiresOneOf, Version, VulkanError,
DeviceSize, RequirementNotMet, RequiresOneOf, RuntimeError, Version,
};
use ash::vk::{MAX_MEMORY_HEAPS, MAX_MEMORY_TYPES};
use parking_lot::RwLock;
@ -524,7 +524,7 @@ pub enum MemoryAllocatePreference {
/// [memory allocator]: MemoryAllocator
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum AllocationCreationError {
VulkanError(VulkanError),
RuntimeError(RuntimeError),
/// There is not enough memory in the pool.
///
@ -554,7 +554,7 @@ pub enum AllocationCreationError {
impl Error for AllocationCreationError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
Self::VulkanError(err) => Some(err),
Self::RuntimeError(err) => Some(err),
_ => None,
}
}
@ -563,7 +563,7 @@ impl Error for AllocationCreationError {
impl Display for AllocationCreationError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
match self {
Self::VulkanError(_) => write!(f, "a runtime error occurred"),
Self::RuntimeError(_) => write!(f, "a runtime error occurred"),
Self::OutOfPoolMemory => write!(f, "the pool doesn't have enough free space"),
Self::DedicatedAllocationRequired => write!(
f,
@ -582,9 +582,9 @@ impl Display for AllocationCreationError {
}
}
impl From<VulkanError> for AllocationCreationError {
fn from(err: VulkanError) -> Self {
AllocationCreationError::VulkanError(err)
impl From<RuntimeError> for AllocationCreationError {
fn from(err: RuntimeError) -> Self {
AllocationCreationError::RuntimeError(err)
}
}
@ -971,7 +971,7 @@ unsafe impl<S: Suballocator> MemoryAllocator for GenericMemoryAllocator<S> {
/// [`protected_memory`]: crate::device::Features::protected_memory
/// [`DEVICE_COHERENT`]: MemoryPropertyFlags::DEVICE_COHERENT
/// [`device_coherent_memory`]: crate::device::Features::device_coherent_memory
/// [`TooManyObjects`]: VulkanError::TooManyObjects
/// [`TooManyObjects`]: RuntimeError::TooManyObjects
/// [`BlockSizeExceeded`]: AllocationCreationError::BlockSizeExceeded
/// [`SuballocatorBlockSizeExceeded`]: AllocationCreationError::SuballocatorBlockSizeExceeded
fn allocate_from_type(
@ -1128,7 +1128,9 @@ unsafe impl<S: Suballocator> MemoryAllocator for GenericMemoryAllocator<S> {
break S::new(MemoryAlloc::new(device_memory)?);
}
// Retry up to 3 times, halving the allocation size each time.
Err(VulkanError::OutOfHostMemory | VulkanError::OutOfDeviceMemory) if i < 3 => {
Err(RuntimeError::OutOfHostMemory | RuntimeError::OutOfDeviceMemory)
if i < 3 =>
{
i += 1;
}
Err(err) => return Err(err.into()),
@ -1144,7 +1146,7 @@ unsafe impl<S: Suballocator> MemoryAllocator for GenericMemoryAllocator<S> {
// This can happen if the block ended up smaller than advertised because there wasn't
// enough memory.
Err(SuballocationCreationError::OutOfRegionMemory) => Err(
AllocationCreationError::VulkanError(VulkanError::OutOfDeviceMemory),
AllocationCreationError::RuntimeError(RuntimeError::OutOfDeviceMemory),
),
// This can not happen as the block is fresher than Febreze and we're still holding an
// exclusive lock.
@ -1187,7 +1189,7 @@ unsafe impl<S: Suballocator> MemoryAllocator for GenericMemoryAllocator<S> {
/// `create_info.size` is greater than `BLOCK_SIZE` and a dedicated allocation was not
/// created.
///
/// [`TooManyObjects`]: VulkanError::TooManyObjects
/// [`TooManyObjects`]: RuntimeError::TooManyObjects
/// [`OutOfPoolMemory`]: AllocationCreationError::OutOfPoolMemory
/// [`DedicatedAllocationRequired`]: AllocationCreationError::DedicatedAllocationRequired
/// [`BlockSizeExceeded`]: AllocationCreationError::BlockSizeExceeded

View File

@ -22,7 +22,7 @@ use crate::{
device::{Device, DeviceOwned},
image::ImageTiling,
memory::{is_aligned, DeviceMemory, MemoryPropertyFlags},
DeviceSize, NonZeroDeviceSize, VulkanError, VulkanObject,
DeviceSize, NonZeroDeviceSize, RuntimeError, VulkanObject,
};
use crossbeam_queue::ArrayQueue;
use parking_lot::Mutex;
@ -125,7 +125,7 @@ impl MemoryAlloc {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Some(NonNull::new(output.assume_init()).unwrap())
}
@ -230,7 +230,7 @@ impl MemoryAlloc {
/// [host-coherent]: crate::memory::MemoryPropertyFlags::HOST_COHERENT
/// [`non_coherent_atom_size`]: crate::device::Properties::non_coherent_atom_size
#[inline]
pub unsafe fn invalidate_range(&self, range: Range<DeviceSize>) -> Result<(), VulkanError> {
pub unsafe fn invalidate_range(&self, range: Range<DeviceSize>) -> Result<(), RuntimeError> {
// VUID-VkMappedMemoryRange-memory-00684
if let Some(atom_size) = self.atom_size {
let range = self.create_memory_range(range, atom_size);
@ -238,7 +238,7 @@ impl MemoryAlloc {
let fns = device.fns();
(fns.v1_0.invalidate_mapped_memory_ranges)(device.handle(), 1, &range)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
} else {
self.debug_validate_memory_range(&range);
}
@ -270,7 +270,7 @@ impl MemoryAlloc {
/// [host-coherent]: crate::memory::MemoryPropertyFlags::HOST_COHERENT
/// [`non_coherent_atom_size`]: crate::device::Properties::non_coherent_atom_size
#[inline]
pub unsafe fn flush_range(&self, range: Range<DeviceSize>) -> Result<(), VulkanError> {
pub unsafe fn flush_range(&self, range: Range<DeviceSize>) -> Result<(), RuntimeError> {
// VUID-VkMappedMemoryRange-memory-00684
if let Some(atom_size) = self.atom_size {
let range = self.create_memory_range(range, atom_size);
@ -278,7 +278,7 @@ impl MemoryAlloc {
let fns = device.fns();
(fns.v1_0.flush_mapped_memory_ranges)(device.handle(), 1, &range)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
} else {
self.debug_validate_memory_range(&range);
}

View File

@ -12,7 +12,7 @@ use crate::{
device::{Device, DeviceOwned},
macros::{impl_id_counter, vulkan_bitflags, vulkan_bitflags_enum},
memory::{is_aligned, MemoryPropertyFlags},
DeviceSize, OomError, RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
DeviceSize, OomError, RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use std::{
error::Error,
@ -432,7 +432,7 @@ impl DeviceMemory {
device: Arc<Device>,
allocate_info: MemoryAllocateInfo<'_>,
import_info: Option<MemoryImportInfo>,
) -> Result<Self, VulkanError> {
) -> Result<Self, RuntimeError> {
let MemoryAllocateInfo {
allocation_size,
memory_type_index,
@ -537,7 +537,7 @@ impl DeviceMemory {
.fetch_update(Ordering::Acquire, Ordering::Relaxed, move |count| {
(count < max_allocations).then_some(count + 1)
})
.map_err(|_| VulkanError::TooManyObjects)?;
.map_err(|_| RuntimeError::TooManyObjects)?;
let handle = {
let fns = device.fns();
@ -551,7 +551,7 @@ impl DeviceMemory {
.result()
.map_err(|e| {
device.allocation_count.fetch_sub(1, Ordering::Release);
VulkanError::from(e)
RuntimeError::from(e)
})?;
output.assume_init()
@ -710,7 +710,7 @@ impl DeviceMemory {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -1109,13 +1109,13 @@ impl Display for DeviceMemoryError {
}
}
impl From<VulkanError> for DeviceMemoryError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for DeviceMemoryError {
fn from(err: RuntimeError) -> Self {
match err {
e @ VulkanError::OutOfHostMemory | e @ VulkanError::OutOfDeviceMemory => {
e @ RuntimeError::OutOfHostMemory | e @ RuntimeError::OutOfDeviceMemory => {
Self::OomError(e.into())
}
VulkanError::TooManyObjects => Self::TooManyObjects,
RuntimeError::TooManyObjects => Self::TooManyObjects,
_ => panic!("unexpected error: {:?}", err),
}
}
@ -1267,7 +1267,7 @@ impl MappedDeviceMemory {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -1333,7 +1333,7 @@ impl MappedDeviceMemory {
let fns = self.memory.device().fns();
(fns.v1_0.invalidate_mapped_memory_ranges)(self.memory.device().handle(), 1, &range)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Ok(())
}
@ -1379,7 +1379,7 @@ impl MappedDeviceMemory {
let fns = self.device().fns();
(fns.v1_0.flush_mapped_memory_ranges)(self.memory.device().handle(), 1, &range)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Ok(())
}
@ -1561,13 +1561,13 @@ impl Display for MemoryMapError {
}
}
impl From<VulkanError> for MemoryMapError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for MemoryMapError {
fn from(err: RuntimeError) -> Self {
match err {
e @ VulkanError::OutOfHostMemory | e @ VulkanError::OutOfDeviceMemory => {
e @ RuntimeError::OutOfHostMemory | e @ RuntimeError::OutOfDeviceMemory => {
Self::OomError(e.into())
}
VulkanError::MemoryMapFailed => Self::MemoryMapFailed,
RuntimeError::MemoryMapFailed => Self::MemoryMapFailed,
_ => panic!("unexpected error: {:?}", err),
}
}

View File

@ -23,7 +23,7 @@
use crate::{
device::{Device, DeviceOwned},
OomError, VulkanError, VulkanObject,
OomError, RuntimeError, VulkanObject,
};
use std::{mem::MaybeUninit, ptr, sync::Arc};
@ -128,7 +128,7 @@ impl PipelineCache {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -170,7 +170,7 @@ impl PipelineCache {
pipelines.as_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Ok(())
}
@ -218,7 +218,7 @@ impl PipelineCache {
ptr::null_mut(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut data: Vec<u8> = Vec::with_capacity(count);
let result = (fns.v1_0.get_pipeline_cache_data)(
@ -234,7 +234,7 @@ impl PipelineCache {
break data;
}
ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err).into()),
err => return Err(RuntimeError::from(err).into()),
}
}
};

View File

@ -36,7 +36,7 @@ use crate::{
DescriptorBindingRequirements, PipelineShaderStageCreateInfo, ShaderExecution, ShaderStage,
SpecializationConstant,
},
OomError, RequirementNotMet, RequiresOneOf, VulkanError, VulkanObject,
OomError, RequiresOneOf, RuntimeError, ValidationError, VulkanError, VulkanObject,
};
use ahash::HashMap;
use std::{
@ -73,7 +73,7 @@ impl ComputePipeline {
device: Arc<Device>,
cache: Option<Arc<PipelineCache>>,
create_info: ComputePipelineCreateInfo,
) -> Result<Arc<ComputePipeline>, ComputePipelineCreationError> {
) -> Result<Arc<ComputePipeline>, VulkanError> {
Self::validate_new(&device, cache.as_ref().map(AsRef::as_ref), &create_info)?;
unsafe { Ok(Self::new_unchecked(device, cache, create_info)?) }
@ -83,7 +83,7 @@ impl ComputePipeline {
device: &Device,
cache: Option<&PipelineCache>,
create_info: &ComputePipelineCreateInfo,
) -> Result<(), ComputePipelineCreationError> {
) -> Result<(), ValidationError> {
// VUID-vkCreateComputePipelines-pipelineCache-parent
if let Some(cache) = &cache {
assert_eq!(device, cache.device().as_ref());
@ -104,16 +104,25 @@ impl ComputePipeline {
_ne: _,
} = &stage;
// VUID-VkPipelineShaderStageCreateInfo-flags-parameter
flags.validate_device(device)?;
flags
.validate_device(device)
.map_err(|err| ValidationError {
context: "create_info.stage.flags".into(),
vuids: &["VUID-VkPipelineShaderStageCreateInfo-flags-parameter"],
..ValidationError::from_requirement(err)
})?;
let entry_point_info = entry_point.info();
// VUID-VkComputePipelineCreateInfo-stage-00701
// VUID-VkPipelineShaderStageCreateInfo-stage-parameter
if !matches!(entry_point_info.execution, ShaderExecution::Compute) {
return Err(ComputePipelineCreationError::ShaderStageInvalid {
stage: ShaderStage::from(&entry_point_info.execution),
return Err(ValidationError {
context: "create_info.stage.entry_point".into(),
problem: "is not a compute shader".into(),
vuids: &[
"VUID-VkComputePipelineCreateInfo-stage-00701",
"VUID-VkPipelineShaderStageCreateInfo-stage-parameter",
],
..Default::default()
});
}
@ -125,32 +134,43 @@ impl ComputePipeline {
if let Some(default_value) =
entry_point_info.specialization_constants.get(&constant_id)
{
// VUID-VkSpecializationMapEntry-constantID-00776
// Check for equal types rather than only equal size.
if !provided_value.eq_type(default_value) {
return Err(
ComputePipelineCreationError::ShaderSpecializationConstantTypeMismatch {
constant_id,
default_value: *default_value,
provided_value: *provided_value,
},
);
return Err(ValidationError {
context: format!(
"create_info.stage.specialization_info[{}]",
constant_id
)
.into(),
problem: "the provided value has a different type than the constant's \
default value"
.into(),
vuids: &["VUID-VkSpecializationMapEntry-constantID-00776"],
..Default::default()
});
}
}
}
// VUID-VkComputePipelineCreateInfo-layout-07987
// VUID-VkComputePipelineCreateInfo-layout-07988
// VUID-VkComputePipelineCreateInfo-layout-07990
// VUID-VkComputePipelineCreateInfo-layout-07991
// TODO: Make sure that all of these are indeed checked.
layout.ensure_compatible_with_shader(
entry_point_info
.descriptor_binding_requirements
.iter()
.map(|(k, v)| (*k, v)),
entry_point_info.push_constant_requirements.as_ref(),
)?;
// TODO: Make sure that all VUIDs are indeed checked.
layout
.ensure_compatible_with_shader(
entry_point_info
.descriptor_binding_requirements
.iter()
.map(|(k, v)| (*k, v)),
entry_point_info.push_constant_requirements.as_ref(),
)
.map_err(|err| ValidationError {
context: "create_info.stage.entry_point".into(),
vuids: &[
"VUID-VkComputePipelineCreateInfo-layout-07987",
"VUID-VkComputePipelineCreateInfo-layout-07988",
"VUID-VkComputePipelineCreateInfo-layout-07990",
"VUID-VkComputePipelineCreateInfo-layout-07991",
],
..ValidationError::from_error(err)
})?;
// VUID-VkComputePipelineCreateInfo-stage-00702
// VUID-VkComputePipelineCreateInfo-layout-01687
@ -165,7 +185,7 @@ impl ComputePipeline {
device: Arc<Device>,
cache: Option<Arc<PipelineCache>>,
create_info: ComputePipelineCreateInfo,
) -> Result<Arc<ComputePipeline>, VulkanError> {
) -> Result<Arc<ComputePipeline>, RuntimeError> {
let &ComputePipelineCreateInfo {
flags,
ref stage,
@ -248,7 +268,7 @@ impl ComputePipeline {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -482,49 +502,6 @@ impl Display for ComputePipelineCreationError {
}
}
impl From<OomError> for ComputePipelineCreationError {
fn from(err: OomError) -> ComputePipelineCreationError {
Self::OomError(err)
}
}
impl From<RequirementNotMet> for ComputePipelineCreationError {
fn from(err: RequirementNotMet) -> Self {
Self::RequirementNotMet {
required_for: err.required_for,
requires_one_of: err.requires_one_of,
}
}
}
impl From<DescriptorSetLayoutCreationError> for ComputePipelineCreationError {
fn from(err: DescriptorSetLayoutCreationError) -> Self {
Self::DescriptorSetLayoutCreationError(err)
}
}
impl From<PipelineLayoutCreationError> for ComputePipelineCreationError {
fn from(err: PipelineLayoutCreationError) -> Self {
Self::PipelineLayoutCreationError(err)
}
}
impl From<PipelineLayoutSupersetError> for ComputePipelineCreationError {
fn from(err: PipelineLayoutSupersetError) -> Self {
Self::IncompatiblePipelineLayout(err)
}
}
impl From<VulkanError> for ComputePipelineCreationError {
fn from(err: VulkanError) -> ComputePipelineCreationError {
match err {
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ VulkanError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
_ => panic!("unexpected error: {:?}", err),
}
}
}
#[cfg(test)]
mod tests {
use crate::{

View File

@ -94,7 +94,7 @@ use crate::{
PipelineShaderStageCreateInfo, ShaderExecution, ShaderInterfaceMismatchError,
ShaderScalarType, ShaderStage, ShaderStages, SpecializationConstant,
},
DeviceSize, OomError, RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
DeviceSize, OomError, RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use ahash::HashMap;
use smallvec::SmallVec;
@ -2590,7 +2590,7 @@ impl GraphicsPipeline {
device: Arc<Device>,
cache: Option<Arc<PipelineCache>>,
create_info: GraphicsPipelineCreateInfo,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let &GraphicsPipelineCreateInfo {
flags,
ref stages,
@ -3569,7 +3569,7 @@ impl GraphicsPipeline {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -4785,11 +4785,11 @@ impl From<PipelineLayoutSupersetError> for GraphicsPipelineCreationError {
}
}
impl From<VulkanError> for GraphicsPipelineCreationError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for GraphicsPipelineCreationError {
fn from(err: RuntimeError) -> Self {
match err {
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ VulkanError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
err @ RuntimeError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ RuntimeError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
_ => panic!("unexpected error: {:?}", err),
}
}

View File

@ -71,7 +71,7 @@ use crate::{
device::{Device, DeviceOwned},
macros::impl_id_counter,
shader::{DescriptorBindingRequirements, PipelineShaderStageCreateInfo, ShaderStages},
OomError, RequirementNotMet, RequiresOneOf, VulkanError, VulkanObject,
OomError, RequirementNotMet, RequiresOneOf, RuntimeError, VulkanObject,
};
use ahash::HashMap;
use smallvec::SmallVec;
@ -420,7 +420,7 @@ impl PipelineLayout {
pub unsafe fn new_unchecked(
device: Arc<Device>,
create_info: PipelineLayoutCreateInfo,
) -> Result<Arc<PipelineLayout>, VulkanError> {
) -> Result<Arc<PipelineLayout>, RuntimeError> {
let &PipelineLayoutCreateInfo {
ref set_layouts,
ref push_constant_ranges,
@ -456,7 +456,7 @@ impl PipelineLayout {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -991,13 +991,13 @@ impl From<OomError> for PipelineLayoutCreationError {
}
}
impl From<VulkanError> for PipelineLayoutCreationError {
fn from(err: VulkanError) -> PipelineLayoutCreationError {
impl From<RuntimeError> for PipelineLayoutCreationError {
fn from(err: RuntimeError) -> PipelineLayoutCreationError {
match err {
err @ VulkanError::OutOfHostMemory => {
err @ RuntimeError::OutOfHostMemory => {
PipelineLayoutCreationError::OomError(OomError::from(err))
}
err @ VulkanError::OutOfDeviceMemory => {
err @ RuntimeError::OutOfDeviceMemory => {
PipelineLayoutCreationError::OomError(OomError::from(err))
}
_ => panic!("unexpected error: {:?}", err),

View File

@ -17,7 +17,7 @@ use crate::{
buffer::BufferContents,
device::{Device, DeviceOwned},
macros::{impl_id_counter, vulkan_bitflags},
DeviceSize, OomError, RequirementNotMet, RequiresOneOf, VulkanError, VulkanObject,
DeviceSize, OomError, RequirementNotMet, RequiresOneOf, RuntimeError, VulkanObject,
};
use std::{
error::Error,
@ -93,7 +93,7 @@ impl QueryPool {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -268,13 +268,13 @@ impl From<OomError> for QueryPoolCreationError {
}
}
impl From<VulkanError> for QueryPoolCreationError {
fn from(err: VulkanError) -> QueryPoolCreationError {
impl From<RuntimeError> for QueryPoolCreationError {
fn from(err: RuntimeError) -> QueryPoolCreationError {
match err {
err @ VulkanError::OutOfHostMemory => {
err @ RuntimeError::OutOfHostMemory => {
QueryPoolCreationError::OomError(OomError::from(err))
}
err @ VulkanError::OutOfDeviceMemory => {
err @ RuntimeError::OutOfDeviceMemory => {
QueryPoolCreationError::OomError(OomError::from(err))
}
_ => panic!("unexpected error: {:?}", err),
@ -373,7 +373,7 @@ impl<'a> QueriesRange<'a> {
match result {
ash::vk::Result::SUCCESS => Ok(true),
ash::vk::Result::NOT_READY => Ok(false),
err => Err(VulkanError::from(err).into()),
err => Err(RuntimeError::from(err).into()),
}
}
@ -481,13 +481,13 @@ impl Display for GetResultsError {
}
}
impl From<VulkanError> for GetResultsError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for GetResultsError {
fn from(err: RuntimeError) -> Self {
match err {
VulkanError::OutOfHostMemory | VulkanError::OutOfDeviceMemory => {
RuntimeError::OutOfHostMemory | RuntimeError::OutOfDeviceMemory => {
Self::OomError(OomError::from(err))
}
VulkanError::DeviceLost => Self::DeviceLost,
RuntimeError::DeviceLost => Self::DeviceLost,
_ => panic!("unexpected error: {:?}", err),
}
}

View File

@ -16,7 +16,7 @@ use crate::{
format::FormatFeatures,
image::{ImageAspects, ImageLayout, SampleCount},
sync::{AccessFlags, DependencyFlags, PipelineStages},
OomError, RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
OomError, RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use smallvec::SmallVec;
use std::{
@ -1242,7 +1242,7 @@ impl RenderPass {
)
}
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
})
@ -1491,7 +1491,7 @@ impl RenderPass {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
})
}
@ -1955,13 +1955,13 @@ impl From<OomError> for RenderPassCreationError {
}
}
impl From<VulkanError> for RenderPassCreationError {
fn from(err: VulkanError) -> RenderPassCreationError {
impl From<RuntimeError> for RenderPassCreationError {
fn from(err: RuntimeError) -> RenderPassCreationError {
match err {
err @ VulkanError::OutOfHostMemory => {
err @ RuntimeError::OutOfHostMemory => {
RenderPassCreationError::OomError(OomError::from(err))
}
err @ VulkanError::OutOfDeviceMemory => {
err @ RuntimeError::OutOfDeviceMemory => {
RenderPassCreationError::OomError(OomError::from(err))
}
_ => panic!("unexpected error: {:?}", err),

View File

@ -13,7 +13,7 @@ use crate::{
format::Format,
image::{view::ImageViewType, ImageDimensions, ImageUsage, ImageViewAbstract, SampleCount},
macros::impl_id_counter,
OomError, VulkanError, VulkanObject,
OomError, RuntimeError, VulkanObject,
};
use smallvec::SmallVec;
use std::{
@ -321,7 +321,7 @@ impl Framebuffer {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -700,8 +700,8 @@ impl Display for FramebufferCreationError {
}
}
impl From<VulkanError> for FramebufferCreationError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for FramebufferCreationError {
fn from(err: RuntimeError) -> Self {
Self::from(OomError::from(err))
}
}

View File

@ -54,7 +54,7 @@ use crate::{
macros::{impl_id_counter, vulkan_enum},
pipeline::graphics::depth_stencil::CompareOp,
shader::ShaderScalarType,
OomError, RequirementNotMet, RequiresOneOf, VulkanError, VulkanObject,
OomError, RequirementNotMet, RequiresOneOf, RuntimeError, VulkanObject,
};
use std::{
error::Error,
@ -434,7 +434,7 @@ impl Sampler {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -967,12 +967,12 @@ impl From<OomError> for SamplerCreationError {
}
}
impl From<VulkanError> for SamplerCreationError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for SamplerCreationError {
fn from(err: RuntimeError) -> Self {
match err {
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ VulkanError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
VulkanError::TooManyObjects => Self::TooManyObjects,
err @ RuntimeError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ RuntimeError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
RuntimeError::TooManyObjects => Self::TooManyObjects,
_ => panic!("unexpected error: {:?}", err),
}
}

View File

@ -94,7 +94,7 @@ use crate::{
format::{ChromaSampling, Format, FormatFeatures, NumericType},
macros::{impl_id_counter, vulkan_enum},
sampler::{ComponentMapping, ComponentSwizzle, Filter},
OomError, RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
OomError, RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use std::{
error::Error,
@ -350,7 +350,7 @@ impl SamplerYcbcrConversion {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -620,13 +620,13 @@ impl From<OomError> for SamplerYcbcrConversionCreationError {
}
}
impl From<VulkanError> for SamplerYcbcrConversionCreationError {
fn from(err: VulkanError) -> SamplerYcbcrConversionCreationError {
impl From<RuntimeError> for SamplerYcbcrConversionCreationError {
fn from(err: RuntimeError) -> SamplerYcbcrConversionCreationError {
match err {
err @ VulkanError::OutOfHostMemory => {
err @ RuntimeError::OutOfHostMemory => {
SamplerYcbcrConversionCreationError::OomError(OomError::from(err))
}
err @ VulkanError::OutOfDeviceMemory => {
err @ RuntimeError::OutOfDeviceMemory => {
SamplerYcbcrConversionCreationError::OomError(OomError::from(err))
}
_ => panic!("unexpected error: {:?}", err),

View File

@ -140,7 +140,7 @@ use crate::{
pipeline::{graphics::input_assembly::PrimitiveTopology, layout::PushConstantRange},
shader::spirv::{Capability, Spirv, SpirvError},
sync::PipelineStages,
OomError, Version, VulkanError, VulkanObject,
OomError, RuntimeError, Version, VulkanObject,
};
use ahash::{HashMap, HashSet};
use std::{
@ -280,7 +280,7 @@ impl ShaderModule {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -1334,8 +1334,8 @@ impl Display for ShaderModuleCreationError {
}
}
impl From<VulkanError> for ShaderModuleCreationError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for ShaderModuleCreationError {
fn from(err: RuntimeError) -> Self {
Self::OomError(err.into())
}
}

View File

@ -29,7 +29,7 @@
#![allow(unused_variables)] // TODO: this module isn't finished
use crate::{
device::physical::PhysicalDevice, swapchain::SurfaceTransforms, OomError, VulkanError,
device::physical::PhysicalDevice, swapchain::SurfaceTransforms, OomError, RuntimeError,
VulkanObject,
};
use std::{
@ -71,7 +71,7 @@ impl DisplayPlane {
ptr::null_mut(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut properties = Vec::with_capacity(count as usize);
let result = (fns
@ -88,7 +88,7 @@ impl DisplayPlane {
break properties;
}
ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err).into()),
err => return Err(RuntimeError::from(err).into()),
}
}
};
@ -107,7 +107,7 @@ impl DisplayPlane {
ptr::null_mut(),
)
.result()
.map_err(VulkanError::from)
.map_err(RuntimeError::from)
.unwrap(); // TODO: shouldn't unwrap
let mut displays = Vec::with_capacity(count as usize);
@ -202,7 +202,7 @@ impl Display {
ptr::null_mut(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut properties = Vec::with_capacity(count as usize);
let result = (fns.khr_display.get_physical_device_display_properties_khr)(
@ -217,7 +217,7 @@ impl Display {
break properties;
}
ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err).into()),
err => return Err(RuntimeError::from(err).into()),
}
}
};
@ -308,7 +308,7 @@ impl Display {
ptr::null_mut(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut properties = Vec::with_capacity(count as usize);
let result = (fns.khr_display.get_display_mode_properties_khr)(
@ -324,7 +324,7 @@ impl Display {
break properties;
}
ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err).into()),
err => return Err(RuntimeError::from(err).into()),
}
}
};
@ -390,7 +390,7 @@ impl DisplayMode {
let mut output = mem::uninitialized();
(fns.v1_0.CreateDisplayModeKHR)(display.device.handle(),
display.display, &infos, ptr::null(),
&mut output).result().map_err(VulkanError::from)?;
&mut output).result().map_err(RuntimeError::from)?;
output
};

View File

@ -18,7 +18,7 @@ use crate::{
display::{DisplayMode, DisplayPlane},
SurfaceSwapchainLock,
},
OomError, RequiresOneOf, VulkanError, VulkanObject,
OomError, RequiresOneOf, RuntimeError, VulkanObject,
};
#[cfg(target_os = "ios")]
@ -119,7 +119,7 @@ impl Surface {
pub unsafe fn headless_unchecked(
instance: Arc<Instance>,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::HeadlessSurfaceCreateInfoEXT {
flags: ash::vk::HeadlessSurfaceCreateFlagsEXT::empty(),
..Default::default()
@ -135,7 +135,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -195,7 +195,7 @@ impl Surface {
pub unsafe fn from_display_plane_unchecked(
display_mode: &DisplayMode,
plane: &DisplayPlane,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let instance = display_mode.display().physical_device().instance();
let create_info = ash::vk::DisplaySurfaceCreateInfoKHR {
@ -224,7 +224,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -278,7 +278,7 @@ impl Surface {
instance: Arc<Instance>,
window: *const W,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::AndroidSurfaceCreateInfoKHR {
flags: ash::vk::AndroidSurfaceCreateFlagsKHR::empty(),
window: window as *mut _,
@ -295,7 +295,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -358,7 +358,7 @@ impl Surface {
dfb: *const D,
surface: *const S,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::DirectFBSurfaceCreateInfoEXT {
flags: ash::vk::DirectFBSurfaceCreateFlagsEXT::empty(),
dfb: dfb as *mut _,
@ -376,7 +376,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -434,7 +434,7 @@ impl Surface {
instance: Arc<Instance>,
image_pipe_handle: ash::vk::zx_handle_t,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::ImagePipeSurfaceCreateInfoFUCHSIA {
flags: ash::vk::ImagePipeSurfaceCreateFlagsFUCHSIA::empty(),
image_pipe_handle,
@ -452,7 +452,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -510,7 +510,7 @@ impl Surface {
instance: Arc<Instance>,
stream_descriptor: ash::vk::GgpStreamDescriptor,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::StreamDescriptorSurfaceCreateInfoGGP {
flags: ash::vk::StreamDescriptorSurfaceCreateFlagsGGP::empty(),
stream_descriptor,
@ -528,7 +528,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -589,7 +589,7 @@ impl Surface {
instance: Arc<Instance>,
metal_layer: IOSMetalLayer,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::IOSSurfaceCreateInfoMVK {
flags: ash::vk::IOSSurfaceCreateFlagsMVK::empty(),
p_view: metal_layer.render_layer.0 as *const _,
@ -606,7 +606,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -667,7 +667,7 @@ impl Surface {
instance: Arc<Instance>,
view: *const V,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::MacOSSurfaceCreateInfoMVK {
flags: ash::vk::MacOSSurfaceCreateFlagsMVK::empty(),
p_view: view as *const _,
@ -684,7 +684,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -735,7 +735,7 @@ impl Surface {
instance: Arc<Instance>,
layer: *const L,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::MetalSurfaceCreateInfoEXT {
flags: ash::vk::MetalSurfaceCreateFlagsEXT::empty(),
p_layer: layer as *const _,
@ -752,7 +752,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -815,7 +815,7 @@ impl Surface {
context: *const C,
window: *const W,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::ScreenSurfaceCreateInfoQNX {
flags: ash::vk::ScreenSurfaceCreateFlagsQNX::empty(),
context: context as *mut _,
@ -833,7 +833,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -887,7 +887,7 @@ impl Surface {
instance: Arc<Instance>,
window: *const W,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::ViSurfaceCreateInfoNN {
flags: ash::vk::ViSurfaceCreateFlagsNN::empty(),
window: window as *mut _,
@ -904,7 +904,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -969,7 +969,7 @@ impl Surface {
display: *const D,
surface: *const S,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::WaylandSurfaceCreateInfoKHR {
flags: ash::vk::WaylandSurfaceCreateFlagsKHR::empty(),
display: display as *mut _,
@ -987,7 +987,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -1052,7 +1052,7 @@ impl Surface {
hinstance: *const I,
hwnd: *const W,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::Win32SurfaceCreateInfoKHR {
flags: ash::vk::Win32SurfaceCreateFlagsKHR::empty(),
hinstance: hinstance as *mut _,
@ -1070,7 +1070,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -1135,7 +1135,7 @@ impl Surface {
connection: *const C,
window: ash::vk::xcb_window_t,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::XcbSurfaceCreateInfoKHR {
flags: ash::vk::XcbSurfaceCreateFlagsKHR::empty(),
connection: connection as *mut _,
@ -1153,7 +1153,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -1218,7 +1218,7 @@ impl Surface {
display: *const D,
window: ash::vk::Window,
object: Option<Arc<dyn Any + Send + Sync>>,
) -> Result<Arc<Self>, VulkanError> {
) -> Result<Arc<Self>, RuntimeError> {
let create_info = ash::vk::XlibSurfaceCreateInfoKHR {
flags: ash::vk::XlibSurfaceCreateFlagsKHR::empty(),
dpy: display as *mut _,
@ -1236,7 +1236,7 @@ impl Surface {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -1378,13 +1378,13 @@ impl From<OomError> for SurfaceCreationError {
}
}
impl From<VulkanError> for SurfaceCreationError {
fn from(err: VulkanError) -> SurfaceCreationError {
impl From<RuntimeError> for SurfaceCreationError {
fn from(err: RuntimeError) -> SurfaceCreationError {
match err {
err @ VulkanError::OutOfHostMemory => {
err @ RuntimeError::OutOfHostMemory => {
SurfaceCreationError::OomError(OomError::from(err))
}
err @ VulkanError::OutOfDeviceMemory => {
err @ RuntimeError::OutOfDeviceMemory => {
SurfaceCreationError::OomError(OomError::from(err))
}
_ => panic!("unexpected error: {:?}", err),

View File

@ -27,7 +27,7 @@ use crate::{
semaphore::{Semaphore, SemaphoreError},
Sharing,
},
DeviceSize, OomError, RequirementNotMet, RequiresOneOf, VulkanError, VulkanObject,
DeviceSize, OomError, RequirementNotMet, RequiresOneOf, RuntimeError, VulkanObject,
};
use parking_lot::Mutex;
use smallvec::{smallvec, SmallVec};
@ -654,7 +654,7 @@ impl Swapchain {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -667,7 +667,7 @@ impl Swapchain {
ptr::null_mut(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
let mut images = Vec::with_capacity(count as usize);
let result = (fns.khr_swapchain.get_swapchain_images_khr)(
@ -683,7 +683,7 @@ impl Swapchain {
break images;
}
ash::vk::Result::INCOMPLETE => (),
err => return Err(VulkanError::from(err).into()),
err => return Err(RuntimeError::from(err).into()),
}
};
@ -832,7 +832,7 @@ impl Swapchain {
self.device.handle(), self.handle
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
}
Ok(())
@ -862,7 +862,7 @@ impl Swapchain {
self.device.handle(), self.handle
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
}
Ok(())
@ -1314,14 +1314,14 @@ impl Display for SwapchainCreationError {
}
}
impl From<VulkanError> for SwapchainCreationError {
fn from(err: VulkanError) -> SwapchainCreationError {
impl From<RuntimeError> for SwapchainCreationError {
fn from(err: RuntimeError) -> SwapchainCreationError {
match err {
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ VulkanError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
VulkanError::DeviceLost => Self::DeviceLost,
VulkanError::SurfaceLost => Self::SurfaceLost,
VulkanError::NativeWindowInUse => Self::NativeWindowInUse,
err @ RuntimeError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ RuntimeError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
RuntimeError::DeviceLost => Self::DeviceLost,
RuntimeError::SurfaceLost => Self::SurfaceLost,
RuntimeError::NativeWindowInUse => Self::NativeWindowInUse,
_ => panic!("unexpected error: {:?}", err),
}
}
@ -1444,17 +1444,17 @@ impl Display for FullScreenExclusiveError {
}
}
impl From<VulkanError> for FullScreenExclusiveError {
fn from(err: VulkanError) -> FullScreenExclusiveError {
impl From<RuntimeError> for FullScreenExclusiveError {
fn from(err: RuntimeError) -> FullScreenExclusiveError {
match err {
err @ VulkanError::OutOfHostMemory => {
err @ RuntimeError::OutOfHostMemory => {
FullScreenExclusiveError::OomError(OomError::from(err))
}
err @ VulkanError::OutOfDeviceMemory => {
err @ RuntimeError::OutOfDeviceMemory => {
FullScreenExclusiveError::OomError(OomError::from(err))
}
VulkanError::SurfaceLost => FullScreenExclusiveError::SurfaceLost,
VulkanError::InitializationFailed => FullScreenExclusiveError::InitializationFailed,
RuntimeError::SurfaceLost => FullScreenExclusiveError::SurfaceLost,
RuntimeError::InitializationFailed => FullScreenExclusiveError::InitializationFailed,
_ => panic!("unexpected error: {:?}", err),
}
}
@ -1600,7 +1600,7 @@ pub fn wait_for_present(
ash::vk::Result::SUBOPTIMAL_KHR => Ok(true),
ash::vk::Result::TIMEOUT => Err(PresentWaitError::Timeout),
err => {
let err = VulkanError::from(err).into();
let err = RuntimeError::from(err).into();
if let PresentWaitError::FullScreenExclusiveModeLost = &err {
swapchain
@ -1843,15 +1843,15 @@ impl From<OomError> for AcquireError {
}
}
impl From<VulkanError> for AcquireError {
fn from(err: VulkanError) -> AcquireError {
impl From<RuntimeError> for AcquireError {
fn from(err: RuntimeError) -> AcquireError {
match err {
err @ VulkanError::OutOfHostMemory => AcquireError::OomError(OomError::from(err)),
err @ VulkanError::OutOfDeviceMemory => AcquireError::OomError(OomError::from(err)),
VulkanError::DeviceLost => AcquireError::DeviceLost,
VulkanError::SurfaceLost => AcquireError::SurfaceLost,
VulkanError::OutOfDate => AcquireError::OutOfDate,
VulkanError::FullScreenExclusiveModeLost => AcquireError::FullScreenExclusiveModeLost,
err @ RuntimeError::OutOfHostMemory => AcquireError::OomError(OomError::from(err)),
err @ RuntimeError::OutOfDeviceMemory => AcquireError::OomError(OomError::from(err)),
RuntimeError::DeviceLost => AcquireError::DeviceLost,
RuntimeError::SurfaceLost => AcquireError::SurfaceLost,
RuntimeError::OutOfDate => AcquireError::OutOfDate,
RuntimeError::FullScreenExclusiveModeLost => AcquireError::FullScreenExclusiveModeLost,
_ => panic!("unexpected error: {:?}", err),
}
}
@ -1938,15 +1938,15 @@ impl From<RequirementNotMet> for PresentWaitError {
}
}
impl From<VulkanError> for PresentWaitError {
fn from(err: VulkanError) -> PresentWaitError {
impl From<RuntimeError> for PresentWaitError {
fn from(err: RuntimeError) -> PresentWaitError {
match err {
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ VulkanError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
VulkanError::DeviceLost => Self::DeviceLost,
VulkanError::SurfaceLost => Self::SurfaceLost,
VulkanError::OutOfDate => Self::OutOfDate,
VulkanError::FullScreenExclusiveModeLost => Self::FullScreenExclusiveModeLost,
err @ RuntimeError::OutOfHostMemory => Self::OomError(OomError::from(err)),
err @ RuntimeError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
RuntimeError::DeviceLost => Self::DeviceLost,
RuntimeError::SurfaceLost => Self::SurfaceLost,
RuntimeError::OutOfDate => Self::OutOfDate,
RuntimeError::FullScreenExclusiveModeLost => Self::FullScreenExclusiveModeLost,
_ => panic!("unexpected error: {:?}", err),
}
}
@ -2255,7 +2255,7 @@ pub unsafe fn acquire_next_image_raw(
ash::vk::Result::SUBOPTIMAL_KHR => true,
ash::vk::Result::NOT_READY => return Err(AcquireError::Timeout),
ash::vk::Result::TIMEOUT => return Err(AcquireError::Timeout),
err => return Err(VulkanError::from(err).into()),
err => return Err(RuntimeError::from(err).into()),
};
if let Some(semaphore) = semaphore {

View File

@ -27,7 +27,7 @@
use crate::{
device::{Device, DeviceOwned},
macros::impl_id_counter,
OomError, RequiresOneOf, VulkanError, VulkanObject,
OomError, RequiresOneOf, RuntimeError, VulkanObject,
};
use std::{
error::Error,
@ -88,7 +88,7 @@ impl Event {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -116,7 +116,7 @@ impl Event {
let fns = device.fns();
(fns.v1_0.reset_event)(device.handle(), handle)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
}
Event {
handle,
@ -165,7 +165,7 @@ impl Event {
match result {
ash::vk::Result::EVENT_SET => Ok(true),
ash::vk::Result::EVENT_RESET => Ok(false),
err => Err(VulkanError::from(err).into()),
err => Err(RuntimeError::from(err).into()),
}
}
}
@ -177,7 +177,7 @@ impl Event {
let fns = self.device.fns();
(fns.v1_0.set_event)(self.device.handle(), self.handle)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Ok(())
}
}
@ -201,7 +201,7 @@ impl Event {
let fns = self.device.fns();
(fns.v1_0.reset_event)(self.device.handle(), self.handle)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
Ok(())
}
}
@ -301,10 +301,10 @@ impl Display for EventError {
}
}
impl From<VulkanError> for EventError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for EventError {
fn from(err: RuntimeError) -> Self {
match err {
e @ VulkanError::OutOfHostMemory | e @ VulkanError::OutOfDeviceMemory => {
e @ RuntimeError::OutOfHostMemory | e @ RuntimeError::OutOfDeviceMemory => {
Self::OomError(e.into())
}
_ => panic!("unexpected error: {:?}", err),

View File

@ -13,7 +13,7 @@
use crate::{
device::{Device, DeviceOwned, Queue},
macros::{impl_id_counter, vulkan_bitflags, vulkan_bitflags_enum},
OomError, RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
OomError, RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use parking_lot::{Mutex, MutexGuard};
use smallvec::SmallVec;
@ -131,7 +131,7 @@ impl Fence {
pub unsafe fn new_unchecked(
device: Arc<Device>,
create_info: FenceCreateInfo,
) -> Result<Fence, VulkanError> {
) -> Result<Fence, RuntimeError> {
let FenceCreateInfo {
signaled,
export_handle_types,
@ -172,7 +172,7 @@ impl Fence {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -206,7 +206,7 @@ impl Fence {
let fns = device.fns();
(fns.v1_0.reset_fences)(device.handle(), 1, &handle)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
}
Fence {
@ -281,7 +281,7 @@ impl Fence {
match result {
ash::vk::Result::SUCCESS => unsafe { state.set_signaled() },
ash::vk::Result::NOT_READY => return Ok(false),
err => return Err(VulkanError::from(err).into()),
err => return Err(RuntimeError::from(err).into()),
}
};
@ -331,7 +331,7 @@ impl Fence {
match result {
ash::vk::Result::SUCCESS => unsafe { state.set_signaled() },
ash::vk::Result::TIMEOUT => return Err(FenceError::Timeout),
err => return Err(VulkanError::from(err).into()),
err => return Err(RuntimeError::from(err).into()),
}
};
@ -433,7 +433,7 @@ impl Fence {
.filter_map(|(fence, state)| state.set_signaled().map(|state| (state, fence)))
.collect(),
ash::vk::Result::TIMEOUT => return Err(FenceError::Timeout),
err => return Err(VulkanError::from(err).into()),
err => return Err(RuntimeError::from(err).into()),
}
};
@ -468,17 +468,17 @@ impl Fence {
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
#[inline]
pub unsafe fn reset_unchecked(&self) -> Result<(), VulkanError> {
pub unsafe fn reset_unchecked(&self) -> Result<(), RuntimeError> {
let mut state = self.state.lock();
self.reset_unchecked_locked(&mut state)
}
unsafe fn reset_unchecked_locked(&self, state: &mut FenceState) -> Result<(), VulkanError> {
unsafe fn reset_unchecked_locked(&self, state: &mut FenceState) -> Result<(), RuntimeError> {
let fns = self.device.fns();
(fns.v1_0.reset_fences)(self.device.handle(), 1, &self.handle)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
state.reset();
@ -531,7 +531,7 @@ impl Fence {
#[cfg_attr(not(feature = "document_unchecked"), doc(hidden))]
pub unsafe fn multi_reset_unchecked<'a>(
fences: impl IntoIterator<Item = &'a Fence>,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
let (fences, mut states): (SmallVec<[_; 8]>, SmallVec<[_; 8]>) = fences
.into_iter()
.map(|fence| {
@ -546,7 +546,7 @@ impl Fence {
unsafe fn multi_reset_unchecked_locked(
fences: &[&Fence],
states: &mut [MutexGuard<'_, FenceState>],
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
if fences.is_empty() {
return Ok(());
}
@ -557,7 +557,7 @@ impl Fence {
let fns = device.fns();
(fns.v1_0.reset_fences)(device.handle(), fences_vk.len() as u32, fences_vk.as_ptr())
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
for state in states {
state.reset();
@ -654,7 +654,7 @@ impl Fence {
pub unsafe fn export_fd_unchecked(
&self,
handle_type: ExternalFenceHandleType,
) -> Result<File, VulkanError> {
) -> Result<File, RuntimeError> {
let mut state = self.state.lock();
self.export_fd_unchecked_locked(handle_type, &mut state)
}
@ -664,7 +664,7 @@ impl Fence {
&self,
handle_type: ExternalFenceHandleType,
state: &mut FenceState,
) -> Result<File, VulkanError> {
) -> Result<File, RuntimeError> {
use std::os::unix::io::FromRawFd;
let info_vk = ash::vk::FenceGetFdInfoKHR {
@ -681,7 +681,7 @@ impl Fence {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
state.export(handle_type);
@ -786,7 +786,7 @@ impl Fence {
pub unsafe fn export_win32_handle_unchecked(
&self,
handle_type: ExternalFenceHandleType,
) -> Result<*mut std::ffi::c_void, VulkanError> {
) -> Result<*mut std::ffi::c_void, RuntimeError> {
let mut state = self.state.lock();
self.export_win32_handle_unchecked_locked(handle_type, &mut state)
}
@ -796,7 +796,7 @@ impl Fence {
&self,
handle_type: ExternalFenceHandleType,
state: &mut FenceState,
) -> Result<*mut std::ffi::c_void, VulkanError> {
) -> Result<*mut std::ffi::c_void, RuntimeError> {
let info_vk = ash::vk::FenceGetWin32HandleInfoKHR {
fence: self.handle,
handle_type: handle_type.into(),
@ -811,7 +811,7 @@ impl Fence {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
state.export(handle_type);
@ -899,7 +899,7 @@ impl Fence {
pub unsafe fn import_fd_unchecked(
&self,
import_fence_fd_info: ImportFenceFdInfo,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
let mut state = self.state.lock();
self.import_fd_unchecked_locked(import_fence_fd_info, &mut state)
}
@ -909,7 +909,7 @@ impl Fence {
&self,
import_fence_fd_info: ImportFenceFdInfo,
state: &mut FenceState,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
use std::os::unix::io::IntoRawFd;
let ImportFenceFdInfo {
@ -930,7 +930,7 @@ impl Fence {
let fns = self.device.fns();
(fns.khr_external_fence_fd.import_fence_fd_khr)(self.device.handle(), &info_vk)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
state.import(handle_type, flags.intersects(FenceImportFlags::TEMPORARY));
@ -1018,7 +1018,7 @@ impl Fence {
pub unsafe fn import_win32_handle_unchecked(
&self,
import_fence_win32_handle_info: ImportFenceWin32HandleInfo,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
let mut state = self.state.lock();
self.import_win32_handle_unchecked_locked(import_fence_win32_handle_info, &mut state)
}
@ -1028,7 +1028,7 @@ impl Fence {
&self,
import_fence_win32_handle_info: ImportFenceWin32HandleInfo,
state: &mut FenceState,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
let ImportFenceWin32HandleInfo {
flags,
handle_type,
@ -1051,7 +1051,7 @@ impl Fence {
&info_vk,
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
state.import(handle_type, flags.intersects(FenceImportFlags::TEMPORARY));
@ -1581,13 +1581,13 @@ impl Display for FenceError {
}
}
impl From<VulkanError> for FenceError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for FenceError {
fn from(err: RuntimeError) -> Self {
match err {
e @ VulkanError::OutOfHostMemory | e @ VulkanError::OutOfDeviceMemory => {
e @ RuntimeError::OutOfHostMemory | e @ RuntimeError::OutOfDeviceMemory => {
Self::OomError(e.into())
}
VulkanError::DeviceLost => Self::DeviceLost,
RuntimeError::DeviceLost => Self::DeviceLost,
_ => panic!("unexpected error: {:?}", err),
}
}

View File

@ -110,7 +110,7 @@ use crate::{
image::{sys::Image, ImageLayout},
memory::BindSparseInfo,
swapchain::{self, PresentFuture, PresentInfo, Swapchain, SwapchainPresentInfo},
DeviceSize, OomError, VulkanError,
DeviceSize, OomError, RuntimeError,
};
use smallvec::SmallVec;
use std::{
@ -666,16 +666,16 @@ impl From<AccessError> for FlushError {
}
}
impl From<VulkanError> for FlushError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for FlushError {
fn from(err: RuntimeError) -> Self {
match err {
VulkanError::OutOfHostMemory | VulkanError::OutOfDeviceMemory => {
RuntimeError::OutOfHostMemory | RuntimeError::OutOfDeviceMemory => {
Self::OomError(err.into())
}
VulkanError::DeviceLost => Self::DeviceLost,
VulkanError::SurfaceLost => Self::SurfaceLost,
VulkanError::OutOfDate => Self::OutOfDate,
VulkanError::FullScreenExclusiveModeLost => Self::FullScreenExclusiveModeLost,
RuntimeError::DeviceLost => Self::DeviceLost,
RuntimeError::SurfaceLost => Self::SurfaceLost,
RuntimeError::OutOfDate => Self::OutOfDate,
RuntimeError::FullScreenExclusiveModeLost => Self::FullScreenExclusiveModeLost,
_ => panic!("unexpected error: {:?}", err),
}
}

View File

@ -13,7 +13,7 @@
use crate::{
device::{Device, DeviceOwned, Queue},
macros::{impl_id_counter, vulkan_bitflags, vulkan_bitflags_enum},
OomError, RequirementNotMet, RequiresOneOf, Version, VulkanError, VulkanObject,
OomError, RequirementNotMet, RequiresOneOf, RuntimeError, Version, VulkanObject,
};
use parking_lot::{Mutex, MutexGuard};
#[cfg(unix)]
@ -112,7 +112,7 @@ impl Semaphore {
pub unsafe fn new_unchecked(
device: Arc<Device>,
create_info: SemaphoreCreateInfo,
) -> Result<Semaphore, VulkanError> {
) -> Result<Semaphore, RuntimeError> {
let SemaphoreCreateInfo {
export_handle_types,
_ne: _,
@ -146,7 +146,7 @@ impl Semaphore {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
output.assume_init()
};
@ -310,7 +310,7 @@ impl Semaphore {
pub unsafe fn export_fd_unchecked(
&self,
handle_type: ExternalSemaphoreHandleType,
) -> Result<File, VulkanError> {
) -> Result<File, RuntimeError> {
let mut state = self.state.lock();
self.export_fd_unchecked_locked(handle_type, &mut state)
}
@ -320,7 +320,7 @@ impl Semaphore {
&self,
handle_type: ExternalSemaphoreHandleType,
state: &mut SemaphoreState,
) -> Result<File, VulkanError> {
) -> Result<File, RuntimeError> {
use std::os::unix::io::FromRawFd;
let info = ash::vk::SemaphoreGetFdInfoKHR {
@ -337,7 +337,7 @@ impl Semaphore {
output.as_mut_ptr(),
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
state.export(handle_type);
@ -455,7 +455,7 @@ impl Semaphore {
pub unsafe fn export_win32_handle_unchecked(
&self,
handle_type: ExternalSemaphoreHandleType,
) -> Result<*mut std::ffi::c_void, VulkanError> {
) -> Result<*mut std::ffi::c_void, RuntimeError> {
let mut state = self.state.lock();
self.export_win32_handle_unchecked_locked(handle_type, &mut state)
}
@ -465,7 +465,7 @@ impl Semaphore {
&self,
handle_type: ExternalSemaphoreHandleType,
state: &mut SemaphoreState,
) -> Result<*mut std::ffi::c_void, VulkanError> {
) -> Result<*mut std::ffi::c_void, RuntimeError> {
let info_vk = ash::vk::SemaphoreGetWin32HandleInfoKHR {
semaphore: self.handle,
handle_type: handle_type.into(),
@ -479,7 +479,7 @@ impl Semaphore {
self.device.handle(), &info_vk, output.as_mut_ptr()
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
state.export(handle_type);
@ -576,7 +576,7 @@ impl Semaphore {
pub unsafe fn export_zircon_handle_unchecked(
&self,
handle_type: ExternalSemaphoreHandleType,
) -> Result<ash::vk::zx_handle_t, VulkanError> {
) -> Result<ash::vk::zx_handle_t, RuntimeError> {
let mut state = self.state.lock();
self.export_zircon_handle_unchecked_locked(handle_type, &mut state)
}
@ -586,7 +586,7 @@ impl Semaphore {
&self,
handle_type: ExternalSemaphoreHandleType,
state: &mut SemaphoreState,
) -> Result<ash::vk::zx_handle_t, VulkanError> {
) -> Result<ash::vk::zx_handle_t, RuntimeError> {
let info = ash::vk::SemaphoreGetZirconHandleInfoFUCHSIA {
semaphore: self.handle,
handle_type: handle_type.into(),
@ -600,7 +600,7 @@ impl Semaphore {
self.device.handle(), &info, output.as_mut_ptr()
)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
state.export(handle_type);
@ -691,7 +691,7 @@ impl Semaphore {
pub unsafe fn import_fd_unchecked(
&self,
import_semaphore_fd_info: ImportSemaphoreFdInfo,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
let mut state = self.state.lock();
self.import_fd_unchecked_locked(import_semaphore_fd_info, &mut state)
}
@ -701,7 +701,7 @@ impl Semaphore {
&self,
import_semaphore_fd_info: ImportSemaphoreFdInfo,
state: &mut SemaphoreState,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
use std::os::unix::io::IntoRawFd;
let ImportSemaphoreFdInfo {
@ -722,7 +722,7 @@ impl Semaphore {
let fns = self.device.fns();
(fns.khr_external_semaphore_fd.import_semaphore_fd_khr)(self.device.handle(), &info_vk)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
state.import(
handle_type,
@ -821,7 +821,7 @@ impl Semaphore {
pub unsafe fn import_win32_handle_unchecked(
&self,
import_semaphore_win32_handle_info: ImportSemaphoreWin32HandleInfo,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
let mut state = self.state.lock();
self.import_win32_handle_unchecked_locked(import_semaphore_win32_handle_info, &mut state)
}
@ -831,7 +831,7 @@ impl Semaphore {
&self,
import_semaphore_win32_handle_info: ImportSemaphoreWin32HandleInfo,
state: &mut SemaphoreState,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
let ImportSemaphoreWin32HandleInfo {
flags,
handle_type,
@ -852,7 +852,7 @@ impl Semaphore {
(fns.khr_external_semaphore_win32
.import_semaphore_win32_handle_khr)(self.device.handle(), &info_vk)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
state.import(
handle_type,
@ -943,7 +943,7 @@ impl Semaphore {
pub unsafe fn import_zircon_handle_unchecked(
&self,
import_semaphore_zircon_handle_info: ImportSemaphoreZirconHandleInfo,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
let mut state = self.state.lock();
self.import_zircon_handle_unchecked_locked(import_semaphore_zircon_handle_info, &mut state)
}
@ -953,7 +953,7 @@ impl Semaphore {
&self,
import_semaphore_zircon_handle_info: ImportSemaphoreZirconHandleInfo,
state: &mut SemaphoreState,
) -> Result<(), VulkanError> {
) -> Result<(), RuntimeError> {
let ImportSemaphoreZirconHandleInfo {
flags,
handle_type,
@ -973,7 +973,7 @@ impl Semaphore {
(fns.fuchsia_external_semaphore
.import_semaphore_zircon_handle_fuchsia)(self.device.handle(), &info_vk)
.result()
.map_err(VulkanError::from)?;
.map_err(RuntimeError::from)?;
state.import(
handle_type,
@ -1543,10 +1543,10 @@ impl Display for SemaphoreError {
}
}
impl From<VulkanError> for SemaphoreError {
fn from(err: VulkanError) -> Self {
impl From<RuntimeError> for SemaphoreError {
fn from(err: RuntimeError) -> Self {
match err {
e @ VulkanError::OutOfHostMemory | e @ VulkanError::OutOfDeviceMemory => {
e @ RuntimeError::OutOfHostMemory | e @ RuntimeError::OutOfDeviceMemory => {
Self::OomError(e.into())
}
_ => panic!("unexpected error: {:?}", err),