mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-21 22:34:43 +00:00
Refactor internal error handling (#1952)
* Refactor internal error handling * Fix docs
This commit is contained in:
parent
6f634830e5
commit
604c154d63
@ -1,4 +1,4 @@
|
||||
use std::{borrow::Borrow, error, fmt, rc::Rc, sync::Arc};
|
||||
use std::{borrow::Borrow, error::Error, fmt, rc::Rc, sync::Arc};
|
||||
use vulkano::{
|
||||
instance::{Instance, InstanceExtensions},
|
||||
swapchain::{Surface, SurfaceCreationError},
|
||||
@ -70,9 +70,9 @@ pub enum CreationError {
|
||||
WindowCreationError(WindowCreationError),
|
||||
}
|
||||
|
||||
impl error::Error for CreationError {
|
||||
impl Error for CreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
CreationError::SurfaceCreationError(ref err) => Some(err),
|
||||
CreationError::WindowCreationError(ref err) => Some(err),
|
||||
|
84
vulkano/autogen/errors.rs
Normal file
84
vulkano/autogen/errors.rs
Normal file
@ -0,0 +1,84 @@
|
||||
// Copyright (c) 2022 The Vulkano developers
|
||||
// Licensed under the Apache License, Version 2.0
|
||||
// <LICENSE-APACHE or
|
||||
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT
|
||||
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>,
|
||||
// at your option. All files in the project carrying such
|
||||
// notice may not be copied, modified, or distributed except
|
||||
// according to those terms.
|
||||
|
||||
use super::{write_file, VkRegistryData};
|
||||
use heck::ToUpperCamelCase;
|
||||
use proc_macro2::{Ident, TokenStream};
|
||||
use quote::{format_ident, quote};
|
||||
|
||||
pub fn write(vk_data: &VkRegistryData) {
|
||||
write_file(
|
||||
"errors.rs",
|
||||
format!(
|
||||
"vk.xml header version {}.{}.{}",
|
||||
vk_data.header_version.0, vk_data.header_version.1, vk_data.header_version.2
|
||||
),
|
||||
errors_output(&errors_members(&vk_data.errors)),
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct ErrorsMember {
|
||||
name: Ident,
|
||||
ffi_name: Ident,
|
||||
}
|
||||
|
||||
fn errors_output(members: &[ErrorsMember]) -> TokenStream {
|
||||
let enum_items = members.iter().map(|ErrorsMember { name, .. }| {
|
||||
quote! { #name, }
|
||||
});
|
||||
let try_from_items = members.iter().map(|ErrorsMember { name, ffi_name }| {
|
||||
quote! { ash::vk::Result::#ffi_name => Self::#name, }
|
||||
});
|
||||
|
||||
quote! {
|
||||
/// An enumeration of runtime errors that can be returned by Vulkan.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[repr(i32)]
|
||||
#[non_exhaustive]
|
||||
pub enum VulkanError {
|
||||
#(#enum_items)*
|
||||
Unnamed(ash::vk::Result),
|
||||
}
|
||||
|
||||
impl From<ash::vk::Result> for VulkanError {
|
||||
fn from(val: ash::vk::Result) -> VulkanError {
|
||||
match val {
|
||||
#(#try_from_items)*
|
||||
x => Self::Unnamed(x),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn errors_members(errors: &[&str]) -> Vec<ErrorsMember> {
|
||||
errors
|
||||
.iter()
|
||||
.map(|error| {
|
||||
let ffi_name = error.strip_prefix("VK_").unwrap();
|
||||
|
||||
let mut parts = ffi_name.split('_').collect::<Vec<_>>();
|
||||
|
||||
assert!(parts[0] == "ERROR");
|
||||
parts.remove(0);
|
||||
|
||||
if ["EXT", "KHR", "NV"].contains(parts.last().unwrap()) {
|
||||
parts.pop();
|
||||
}
|
||||
|
||||
let name = parts.join("_").to_upper_camel_case();
|
||||
|
||||
ErrorsMember {
|
||||
name: format_ident!("{}", name),
|
||||
ffi_name: format_ident!("{}", ffi_name),
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
@ -21,10 +21,11 @@ use std::{
|
||||
process::Command,
|
||||
};
|
||||
use vk_parse::{
|
||||
Extension, ExtensionChild, Feature, Format, InterfaceItem, Registry, RegistryChild,
|
||||
SpirvExtOrCap, Type, TypeSpec, TypesChild,
|
||||
Enum, EnumSpec, Enums, EnumsChild, Extension, ExtensionChild, Feature, Format, InterfaceItem,
|
||||
Registry, RegistryChild, SpirvExtOrCap, Type, TypeSpec, TypesChild,
|
||||
};
|
||||
|
||||
mod errors;
|
||||
mod extensions;
|
||||
mod features;
|
||||
mod fns;
|
||||
@ -40,6 +41,7 @@ pub fn autogen() {
|
||||
let vk_data = VkRegistryData::new(®istry);
|
||||
let spirv_grammar = get_spirv_grammar("spirv.core.grammar.json");
|
||||
|
||||
errors::write(&vk_data);
|
||||
extensions::write(&vk_data);
|
||||
features::write(&vk_data);
|
||||
formats::write(&vk_data);
|
||||
@ -85,6 +87,7 @@ fn get_vk_registry<P: AsRef<Path> + ?Sized>(path: &P) -> Registry {
|
||||
|
||||
pub struct VkRegistryData<'r> {
|
||||
pub header_version: (u16, u16, u16),
|
||||
pub errors: Vec<&'r str>,
|
||||
pub extensions: IndexMap<&'r str, &'r Extension>,
|
||||
pub features: IndexMap<&'r str, &'r Feature>,
|
||||
pub formats: Vec<&'r Format>,
|
||||
@ -101,11 +104,13 @@ impl<'r> VkRegistryData<'r> {
|
||||
let formats = Self::get_formats(®istry);
|
||||
let spirv_capabilities = Self::get_spirv_capabilities(registry);
|
||||
let spirv_extensions = Self::get_spirv_extensions(registry);
|
||||
let errors = Self::get_errors(®istry, &features, &extensions);
|
||||
let types = Self::get_types(®istry, &aliases, &features, &extensions);
|
||||
let header_version = Self::get_header_version(®istry);
|
||||
|
||||
VkRegistryData {
|
||||
header_version,
|
||||
errors,
|
||||
extensions,
|
||||
features,
|
||||
formats,
|
||||
@ -170,6 +175,63 @@ impl<'r> VkRegistryData<'r> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn get_errors<'a>(
|
||||
registry: &'a Registry,
|
||||
features: &IndexMap<&'a str, &'a Feature>,
|
||||
extensions: &IndexMap<&'a str, &'a Extension>,
|
||||
) -> Vec<&'a str> {
|
||||
(registry
|
||||
.0
|
||||
.iter()
|
||||
.filter_map(|child| match child {
|
||||
RegistryChild::Enums(Enums {
|
||||
name: Some(name),
|
||||
children,
|
||||
..
|
||||
}) if name == "VkResult" => Some(children.iter().filter_map(|en| {
|
||||
if let EnumsChild::Enum(en) = en {
|
||||
if let EnumSpec::Value { value, .. } = &en.spec {
|
||||
if value.starts_with("-") {
|
||||
return Some(en.name.as_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
})),
|
||||
_ => None,
|
||||
})
|
||||
.flatten())
|
||||
.chain(
|
||||
(features.values().map(|feature| feature.children.iter()))
|
||||
.chain(
|
||||
extensions
|
||||
.values()
|
||||
.map(|extension| extension.children.iter()),
|
||||
)
|
||||
.flatten()
|
||||
.filter_map(|child| {
|
||||
if let ExtensionChild::Require { items, .. } = child {
|
||||
return Some(items.iter().filter_map(|item| match item {
|
||||
InterfaceItem::Enum(Enum {
|
||||
name,
|
||||
spec:
|
||||
EnumSpec::Offset {
|
||||
extends,
|
||||
dir: false,
|
||||
..
|
||||
},
|
||||
..
|
||||
}) if extends == "VkResult" => Some(name.as_str()),
|
||||
_ => None,
|
||||
}));
|
||||
}
|
||||
None
|
||||
})
|
||||
.flatten(),
|
||||
)
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn get_extensions(registry: &Registry) -> IndexMap<&str, &Extension> {
|
||||
let iter = registry
|
||||
.0
|
||||
|
@ -34,7 +34,8 @@ use crate::{
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
marker::PhantomData,
|
||||
mem::size_of,
|
||||
@ -583,7 +584,7 @@ pub enum ReadLockError {
|
||||
GpuWriteLocked,
|
||||
}
|
||||
|
||||
impl error::Error for ReadLockError {}
|
||||
impl Error for ReadLockError {}
|
||||
|
||||
impl fmt::Display for ReadLockError {
|
||||
#[inline]
|
||||
@ -612,7 +613,7 @@ pub enum WriteLockError {
|
||||
GpuLocked,
|
||||
}
|
||||
|
||||
impl error::Error for WriteLockError {}
|
||||
impl Error for WriteLockError {}
|
||||
|
||||
impl fmt::Display for WriteLockError {
|
||||
#[inline]
|
||||
|
@ -40,7 +40,7 @@ use crate::{
|
||||
use core::fmt;
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
error,
|
||||
error::Error,
|
||||
fs::File,
|
||||
hash::{Hash, Hasher},
|
||||
marker::PhantomData,
|
||||
@ -577,9 +577,9 @@ pub enum DeviceLocalBufferCreationError {
|
||||
CommandBufferBeginError(CommandBufferBeginError),
|
||||
}
|
||||
|
||||
impl error::Error for DeviceLocalBufferCreationError {
|
||||
impl Error for DeviceLocalBufferCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
Self::DeviceMemoryAllocationError(err) => Some(err),
|
||||
Self::CommandBufferBeginError(err) => Some(err),
|
||||
|
@ -29,18 +29,18 @@ use super::{
|
||||
BufferUsage,
|
||||
};
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
memory::{DeviceMemory, DeviceMemoryAllocationError, MemoryRequirements},
|
||||
range_map::RangeMap,
|
||||
sync::{AccessError, CurrentAccess, Sharing},
|
||||
DeviceSize, Error, OomError, Version, VulkanObject,
|
||||
DeviceSize, OomError, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use ash::vk::Handle;
|
||||
use parking_lot::{Mutex, MutexGuard};
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
ops::Range,
|
||||
@ -160,12 +160,14 @@ impl UnsafeBuffer {
|
||||
let handle = unsafe {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_buffer)(
|
||||
(fns.v1_0.create_buffer)(
|
||||
device.internal_object(),
|
||||
&create_info.build(),
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -334,12 +336,14 @@ impl UnsafeBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
check_errors((fns.v1_0.bind_buffer_memory)(
|
||||
(fns.v1_0.bind_buffer_memory)(
|
||||
self.device.internal_object(),
|
||||
self.handle,
|
||||
memory.internal_object(),
|
||||
offset,
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -471,9 +475,9 @@ pub enum BufferCreationError {
|
||||
SharingInvalidQueueFamilyId { id: u32 },
|
||||
}
|
||||
|
||||
impl error::Error for BufferCreationError {
|
||||
impl Error for BufferCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
BufferCreationError::AllocError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -512,14 +516,14 @@ impl From<OomError> for BufferCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for BufferCreationError {
|
||||
impl From<VulkanError> for BufferCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> BufferCreationError {
|
||||
fn from(err: VulkanError) -> BufferCreationError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => {
|
||||
err @ VulkanError::OutOfHostMemory => {
|
||||
BufferCreationError::AllocError(DeviceMemoryAllocationError::from(err))
|
||||
}
|
||||
err @ Error::OutOfDeviceMemory => {
|
||||
err @ VulkanError::OutOfDeviceMemory => {
|
||||
BufferCreationError::AllocError(DeviceMemoryAllocationError::from(err))
|
||||
}
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
|
@ -10,7 +10,8 @@
|
||||
use super::{sys::UnsafeBuffer, BufferContents, BufferSlice, BufferUsage};
|
||||
use crate::{device::DeviceOwned, DeviceSize, SafeDeref, VulkanObject};
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
num::NonZeroU64,
|
||||
ops::Range,
|
||||
@ -199,7 +200,7 @@ pub enum BufferDeviceAddressError {
|
||||
FeatureNotEnabled,
|
||||
}
|
||||
|
||||
impl error::Error for BufferDeviceAddressError {}
|
||||
impl Error for BufferDeviceAddressError {}
|
||||
|
||||
impl fmt::Display for BufferDeviceAddressError {
|
||||
#[inline]
|
||||
|
@ -44,13 +44,13 @@
|
||||
|
||||
use super::{BufferAccess, BufferAccessObject, BufferInner};
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
format::{Format, FormatFeatures},
|
||||
DeviceSize, Error, OomError, Version, VulkanObject,
|
||||
DeviceSize, OomError, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
ops::Range,
|
||||
@ -207,12 +207,14 @@ where
|
||||
let handle = unsafe {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_buffer_view)(
|
||||
(fns.v1_0.create_buffer_view)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -345,9 +347,9 @@ pub enum BufferViewCreationError {
|
||||
MaxTexelBufferElementsExceeded,
|
||||
}
|
||||
|
||||
impl error::Error for BufferViewCreationError {
|
||||
impl Error for BufferViewCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
BufferViewCreationError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -394,9 +396,9 @@ impl From<OomError> for BufferViewCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for BufferViewCreationError {
|
||||
impl From<VulkanError> for BufferViewCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> BufferViewCreationError {
|
||||
fn from(err: VulkanError) -> BufferViewCreationError {
|
||||
OomError::from(err).into()
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ use crate::{
|
||||
};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
marker::PhantomData,
|
||||
ops::Range,
|
||||
sync::{
|
||||
@ -481,9 +482,9 @@ pub enum CommandBufferBeginError {
|
||||
StencilAttachmentFormatUsageNotSupported,
|
||||
}
|
||||
|
||||
impl error::Error for CommandBufferBeginError {
|
||||
impl Error for CommandBufferBeginError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -972,9 +973,9 @@ macro_rules! err_gen {
|
||||
)+
|
||||
}
|
||||
|
||||
impl error::Error for $name {
|
||||
impl Error for $name {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
$(
|
||||
$name::$err(ref err) => Some(err),
|
||||
@ -1111,7 +1112,7 @@ pub enum AutoCommandBufferBuilderContextError {
|
||||
WrongSubpassType,
|
||||
}
|
||||
|
||||
impl error::Error for AutoCommandBufferBuilderContextError {}
|
||||
impl Error for AutoCommandBufferBuilderContextError {}
|
||||
|
||||
impl fmt::Display for AutoCommandBufferBuilderContextError {
|
||||
#[inline]
|
||||
|
@ -16,7 +16,7 @@ use crate::{
|
||||
device::DeviceOwned,
|
||||
instance::debug::DebugUtilsLabel,
|
||||
};
|
||||
use std::{error, ffi::CString, fmt};
|
||||
use std::{error::Error, ffi::CString, fmt};
|
||||
|
||||
/// # Commands for debugging.
|
||||
///
|
||||
@ -293,7 +293,7 @@ pub enum DebugUtilsError {
|
||||
NotSupportedByQueueFamily,
|
||||
}
|
||||
|
||||
impl error::Error for DebugUtilsError {}
|
||||
impl Error for DebugUtilsError {}
|
||||
|
||||
impl fmt::Display for DebugUtilsError {
|
||||
#[inline]
|
||||
|
@ -28,7 +28,7 @@ use crate::{
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use smallvec::SmallVec;
|
||||
use std::{error, fmt, ops::RangeInclusive};
|
||||
use std::{error::Error, fmt, ops::RangeInclusive};
|
||||
|
||||
/// # Commands to set dynamic state for pipelines.
|
||||
///
|
||||
@ -2727,7 +2727,7 @@ enum SetDynamicStateError {
|
||||
PipelineHasFixedState,
|
||||
}
|
||||
|
||||
impl error::Error for SetDynamicStateError {}
|
||||
impl Error for SetDynamicStateError {}
|
||||
|
||||
impl fmt::Display for SetDynamicStateError {
|
||||
#[inline]
|
||||
|
@ -24,7 +24,7 @@ use crate::{
|
||||
image::{ImageAspects, ImageLayout, SampleCount, SampleCounts},
|
||||
DeviceSize,
|
||||
};
|
||||
use std::{error, fmt};
|
||||
use std::{error::Error, fmt};
|
||||
|
||||
/// Error that can happen when recording a copy command.
|
||||
#[derive(Clone, Debug)]
|
||||
@ -271,9 +271,9 @@ pub enum CopyError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for CopyError {
|
||||
impl Error for CopyError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
Self::SyncCommandBufferBuilderError(err) => Some(err),
|
||||
_ => None,
|
||||
|
@ -40,7 +40,7 @@ use crate::{
|
||||
sync::{AccessFlags, PipelineMemoryAccess, PipelineStages},
|
||||
DeviceSize, VulkanObject,
|
||||
};
|
||||
use std::{borrow::Cow, error, fmt, mem::size_of, ops::Range, sync::Arc};
|
||||
use std::{borrow::Cow, error::Error, fmt, mem::size_of, ops::Range, sync::Arc};
|
||||
|
||||
/// # Commands to execute a bound pipeline.
|
||||
///
|
||||
@ -348,7 +348,7 @@ pub enum CheckPipelineError {
|
||||
PipelineNotBound,
|
||||
}
|
||||
|
||||
impl error::Error for CheckPipelineError {}
|
||||
impl Error for CheckPipelineError {}
|
||||
|
||||
impl fmt::Display for CheckPipelineError {
|
||||
#[inline]
|
||||
@ -661,9 +661,9 @@ pub enum CheckDescriptorSetsValidityError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for CheckDescriptorSetsValidityError {
|
||||
impl Error for CheckDescriptorSetsValidityError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
Self::InvalidDescriptorResource { error, .. } => Some(error),
|
||||
_ => None,
|
||||
@ -776,8 +776,8 @@ pub enum InvalidDescriptorResource {
|
||||
StorageWriteWithoutFormatNotSupported,
|
||||
}
|
||||
|
||||
impl error::Error for InvalidDescriptorResource {
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
impl Error for InvalidDescriptorResource {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
Self::SamplerImageViewIncompatible { error, .. } => Some(error),
|
||||
_ => None,
|
||||
@ -889,7 +889,7 @@ pub enum CheckPushConstantsValidityError {
|
||||
MissingPushConstants,
|
||||
}
|
||||
|
||||
impl error::Error for CheckPushConstantsValidityError {}
|
||||
impl Error for CheckPushConstantsValidityError {}
|
||||
|
||||
impl fmt::Display for CheckPushConstantsValidityError {
|
||||
#[inline]
|
||||
@ -1274,7 +1274,7 @@ pub enum CheckDynamicStateValidityError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for CheckDynamicStateValidityError {}
|
||||
impl Error for CheckDynamicStateValidityError {}
|
||||
|
||||
impl fmt::Display for CheckDynamicStateValidityError {
|
||||
#[inline]
|
||||
@ -1359,7 +1359,7 @@ pub enum CheckIndexBufferError {
|
||||
UnsupportIndexType,
|
||||
}
|
||||
|
||||
impl error::Error for CheckIndexBufferError {}
|
||||
impl Error for CheckIndexBufferError {}
|
||||
|
||||
impl fmt::Display for CheckIndexBufferError {
|
||||
#[inline]
|
||||
@ -1420,7 +1420,7 @@ pub enum CheckIndirectBufferError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for CheckIndirectBufferError {}
|
||||
impl Error for CheckIndirectBufferError {}
|
||||
|
||||
impl fmt::Display for CheckIndirectBufferError {
|
||||
#[inline]
|
||||
@ -1577,7 +1577,7 @@ pub enum CheckVertexBufferError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for CheckVertexBufferError {}
|
||||
impl Error for CheckVertexBufferError {}
|
||||
|
||||
impl fmt::Display for CheckVertexBufferError {
|
||||
#[inline]
|
||||
@ -1639,7 +1639,7 @@ pub enum CheckDispatchError {
|
||||
ZeroLengthDimensions,
|
||||
}
|
||||
|
||||
impl error::Error for CheckDispatchError {}
|
||||
impl Error for CheckDispatchError {}
|
||||
|
||||
impl fmt::Display for CheckDispatchError {
|
||||
#[inline]
|
||||
|
@ -23,7 +23,7 @@ use crate::{
|
||||
sync::{AccessFlags, PipelineMemoryAccess, PipelineStage, PipelineStages},
|
||||
DeviceSize, VulkanObject,
|
||||
};
|
||||
use std::{error, fmt, mem::size_of, ops::Range, sync::Arc};
|
||||
use std::{error::Error, fmt, mem::size_of, ops::Range, sync::Arc};
|
||||
|
||||
/// # Commands related to queries.
|
||||
impl<L, P> AutoCommandBufferBuilder<L, P> {
|
||||
@ -827,7 +827,7 @@ pub enum QueryError {
|
||||
StageNotSupported,
|
||||
}
|
||||
|
||||
impl error::Error for QueryError {}
|
||||
impl Error for QueryError {}
|
||||
|
||||
impl fmt::Display for QueryError {
|
||||
#[inline]
|
||||
|
@ -27,7 +27,7 @@ use crate::{
|
||||
Version, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{cmp::min, error, fmt, ops::Range, sync::Arc};
|
||||
use std::{cmp::min, error::Error, fmt, ops::Range, sync::Arc};
|
||||
|
||||
/// # Commands for render passes.
|
||||
///
|
||||
@ -2811,9 +2811,9 @@ pub enum RenderPassError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for RenderPassError {
|
||||
impl Error for RenderPassError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
Self::SyncCommandBufferBuilderError(err) => Some(err),
|
||||
_ => None,
|
||||
|
@ -23,7 +23,7 @@ use crate::{
|
||||
SafeDeref, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{error, fmt};
|
||||
use std::{error::Error, fmt};
|
||||
|
||||
/// # Commands to execute a secondary command buffer inside a primary command buffer.
|
||||
///
|
||||
@ -689,9 +689,9 @@ pub enum ExecuteCommandsError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for ExecuteCommandsError {
|
||||
impl Error for ExecuteCommandsError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
Self::SyncCommandBufferBuilderError(err) => Some(err),
|
||||
_ => None,
|
||||
|
@ -8,14 +8,14 @@
|
||||
// according to those terms.
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
command_buffer::CommandBufferLevel,
|
||||
device::{physical::QueueFamily, Device, DeviceOwned},
|
||||
Error, OomError, Version, VulkanObject,
|
||||
OomError, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
marker::PhantomData,
|
||||
mem::MaybeUninit,
|
||||
@ -155,12 +155,14 @@ impl UnsafeCommandPool {
|
||||
let handle = {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_command_pool)(
|
||||
(fns.v1_0.create_command_pool)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -183,11 +185,9 @@ impl UnsafeCommandPool {
|
||||
};
|
||||
|
||||
let fns = self.device.fns();
|
||||
check_errors((fns.v1_0.reset_command_pool)(
|
||||
self.device.internal_object(),
|
||||
self.handle,
|
||||
flags,
|
||||
))?;
|
||||
(fns.v1_0.reset_command_pool)(self.device.internal_object(), self.handle, flags)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -216,11 +216,13 @@ impl UnsafeCommandPool {
|
||||
unsafe {
|
||||
let fns = self.device.fns();
|
||||
let mut out = Vec::with_capacity(command_buffer_count as usize);
|
||||
check_errors((fns.v1_0.allocate_command_buffers)(
|
||||
(fns.v1_0.allocate_command_buffers)(
|
||||
self.device.internal_object(),
|
||||
&allocate_info,
|
||||
out.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
out.set_len(command_buffer_count as usize);
|
||||
out
|
||||
}
|
||||
@ -368,9 +370,9 @@ pub enum UnsafeCommandPoolCreationError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for UnsafeCommandPoolCreationError {
|
||||
impl Error for UnsafeCommandPoolCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -395,11 +397,11 @@ impl fmt::Display for UnsafeCommandPoolCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for UnsafeCommandPoolCreationError {
|
||||
impl From<VulkanError> for UnsafeCommandPoolCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
@ -523,7 +525,7 @@ pub enum CommandPoolTrimError {
|
||||
Maintenance1ExtensionNotEnabled,
|
||||
}
|
||||
|
||||
impl error::Error for CommandPoolTrimError {}
|
||||
impl Error for CommandPoolTrimError {}
|
||||
|
||||
impl fmt::Display for CommandPoolTrimError {
|
||||
#[inline]
|
||||
@ -540,9 +542,9 @@ impl fmt::Display for CommandPoolTrimError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for CommandPoolTrimError {
|
||||
impl From<VulkanError> for CommandPoolTrimError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> CommandPoolTrimError {
|
||||
fn from(err: VulkanError) -> CommandPoolTrimError {
|
||||
panic!("unexpected error: {:?}", err)
|
||||
}
|
||||
}
|
||||
|
@ -9,15 +9,14 @@
|
||||
|
||||
use crate::{
|
||||
buffer::sys::UnsafeBuffer,
|
||||
check_errors,
|
||||
device::Queue,
|
||||
image::sys::UnsafeImage,
|
||||
memory::DeviceMemory,
|
||||
sync::{Fence, Semaphore},
|
||||
DeviceSize, Error, OomError, SynchronizedVulkanObject, VulkanObject,
|
||||
DeviceSize, OomError, SynchronizedVulkanObject, VulkanError, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{error, fmt, marker::PhantomData};
|
||||
use std::{error::Error, fmt, marker::PhantomData};
|
||||
|
||||
// TODO: correctly implement Debug on all the structs of this module
|
||||
|
||||
@ -234,12 +233,14 @@ impl<'a> SubmitBindSparseBuilder<'a> {
|
||||
};
|
||||
|
||||
// Finally executing the command.
|
||||
check_errors((fns.v1_0.queue_bind_sparse)(
|
||||
(fns.v1_0.queue_bind_sparse)(
|
||||
*queue,
|
||||
bs_infos.len() as u32,
|
||||
bs_infos.as_ptr(),
|
||||
self.fence,
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@ -469,9 +470,9 @@ pub enum SubmitBindSparseError {
|
||||
DeviceLost,
|
||||
}
|
||||
|
||||
impl error::Error for SubmitBindSparseError {
|
||||
impl Error for SubmitBindSparseError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
SubmitBindSparseError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -493,13 +494,17 @@ impl fmt::Display for SubmitBindSparseError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for SubmitBindSparseError {
|
||||
impl From<VulkanError> for SubmitBindSparseError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> SubmitBindSparseError {
|
||||
fn from(err: VulkanError) -> SubmitBindSparseError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => SubmitBindSparseError::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => SubmitBindSparseError::OomError(OomError::from(err)),
|
||||
Error::DeviceLost => SubmitBindSparseError::DeviceLost,
|
||||
err @ VulkanError::OutOfHostMemory => {
|
||||
SubmitBindSparseError::OomError(OomError::from(err))
|
||||
}
|
||||
err @ VulkanError::OutOfDeviceMemory => {
|
||||
SubmitBindSparseError::OomError(OomError::from(err))
|
||||
}
|
||||
VulkanError::DeviceLost => SubmitBindSparseError::DeviceLost,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,13 @@
|
||||
// according to those terms.
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{DeviceOwned, Queue},
|
||||
swapchain::{PresentRegion, Swapchain},
|
||||
sync::Semaphore,
|
||||
Error, OomError, SynchronizedVulkanObject, VulkanObject,
|
||||
OomError, SynchronizedVulkanObject, VulkanError, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{error, fmt, marker::PhantomData, ptr};
|
||||
use std::{error::Error, fmt, marker::PhantomData, ptr};
|
||||
|
||||
/// Prototype for a submission that presents a swapchain on the screen.
|
||||
// TODO: example here
|
||||
@ -169,10 +168,12 @@ impl<'a> SubmitPresentBuilder<'a> {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
check_errors((fns.khr_swapchain.queue_present_khr)(*queue, &infos))?;
|
||||
(fns.khr_swapchain.queue_present_khr)(*queue, &infos)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
for result in results {
|
||||
check_errors(result)?;
|
||||
result.result().map_err(VulkanError::from)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -205,16 +206,16 @@ pub enum SubmitPresentError {
|
||||
|
||||
/// The swapchain has lost or doesn't have full-screen exclusivity possibly for
|
||||
/// implementation-specific reasons outside of the application’s control.
|
||||
FullScreenExclusiveLost,
|
||||
FullScreenExclusiveModeLost,
|
||||
|
||||
/// The surface has changed in a way that makes the swapchain unusable. You must query the
|
||||
/// surface's new properties and recreate a new swapchain if you want to continue drawing.
|
||||
OutOfDate,
|
||||
}
|
||||
|
||||
impl error::Error for SubmitPresentError {
|
||||
impl Error for SubmitPresentError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
SubmitPresentError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -234,7 +235,7 @@ impl fmt::Display for SubmitPresentError {
|
||||
SubmitPresentError::SurfaceLost =>
|
||||
"the surface of this swapchain is no longer valid",
|
||||
SubmitPresentError::OutOfDate => "the swapchain needs to be recreated",
|
||||
SubmitPresentError::FullScreenExclusiveLost => {
|
||||
SubmitPresentError::FullScreenExclusiveModeLost => {
|
||||
"the swapchain no longer has full-screen exclusivity"
|
||||
}
|
||||
}
|
||||
@ -242,16 +243,20 @@ impl fmt::Display for SubmitPresentError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for SubmitPresentError {
|
||||
impl From<VulkanError> for SubmitPresentError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> SubmitPresentError {
|
||||
fn from(err: VulkanError) -> SubmitPresentError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => SubmitPresentError::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => SubmitPresentError::OomError(OomError::from(err)),
|
||||
Error::DeviceLost => SubmitPresentError::DeviceLost,
|
||||
Error::SurfaceLost => SubmitPresentError::SurfaceLost,
|
||||
Error::OutOfDate => SubmitPresentError::OutOfDate,
|
||||
Error::FullScreenExclusiveLost => SubmitPresentError::FullScreenExclusiveLost,
|
||||
err @ VulkanError::OutOfHostMemory => SubmitPresentError::OomError(OomError::from(err)),
|
||||
err @ VulkanError::OutOfDeviceMemory => {
|
||||
SubmitPresentError::OomError(OomError::from(err))
|
||||
}
|
||||
VulkanError::DeviceLost => SubmitPresentError::DeviceLost,
|
||||
VulkanError::SurfaceLost => SubmitPresentError::SurfaceLost,
|
||||
VulkanError::OutOfDate => SubmitPresentError::OutOfDate,
|
||||
VulkanError::FullScreenExclusiveModeLost => {
|
||||
SubmitPresentError::FullScreenExclusiveModeLost
|
||||
}
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,13 @@
|
||||
// according to those terms.
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
command_buffer::sys::UnsafeCommandBuffer,
|
||||
device::Queue,
|
||||
sync::{Fence, PipelineStages, Semaphore},
|
||||
Error, OomError, SynchronizedVulkanObject, VulkanObject,
|
||||
OomError, SynchronizedVulkanObject, VulkanError, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{error, fmt, marker::PhantomData};
|
||||
use std::{error::Error, fmt, marker::PhantomData};
|
||||
|
||||
/// Prototype for a submission that executes command buffers.
|
||||
// TODO: example here
|
||||
@ -209,7 +208,9 @@ impl<'a> SubmitCommandBufferBuilder<'a> {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
check_errors((fns.v1_0.queue_submit)(*queue, 1, &batch, self.fence))?;
|
||||
(fns.v1_0.queue_submit)(*queue, 1, &batch, self.fence)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@ -250,9 +251,9 @@ pub enum SubmitCommandBufferError {
|
||||
DeviceLost,
|
||||
}
|
||||
|
||||
impl error::Error for SubmitCommandBufferError {
|
||||
impl Error for SubmitCommandBufferError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
SubmitCommandBufferError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -275,15 +276,17 @@ impl fmt::Display for SubmitCommandBufferError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for SubmitCommandBufferError {
|
||||
impl From<VulkanError> for SubmitCommandBufferError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> SubmitCommandBufferError {
|
||||
fn from(err: VulkanError) -> SubmitCommandBufferError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => SubmitCommandBufferError::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => {
|
||||
err @ VulkanError::OutOfHostMemory => {
|
||||
SubmitCommandBufferError::OomError(OomError::from(err))
|
||||
}
|
||||
Error::DeviceLost => SubmitCommandBufferError::DeviceLost,
|
||||
err @ VulkanError::OutOfDeviceMemory => {
|
||||
SubmitCommandBufferError::OomError(OomError::from(err))
|
||||
}
|
||||
VulkanError::DeviceLost => SubmitCommandBufferError::DeviceLost,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,8 @@ use smallvec::SmallVec;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::{hash_map::Entry, HashMap},
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
ops::{Range, RangeInclusive},
|
||||
sync::Arc,
|
||||
};
|
||||
@ -883,7 +884,7 @@ pub enum SyncCommandBufferBuilderError {
|
||||
ExecError(CommandBufferExecError),
|
||||
}
|
||||
|
||||
impl error::Error for SyncCommandBufferBuilderError {}
|
||||
impl Error for SyncCommandBufferBuilderError {}
|
||||
|
||||
impl fmt::Display for SyncCommandBufferBuilderError {
|
||||
#[inline]
|
||||
|
@ -16,13 +16,12 @@ use super::{
|
||||
CommandBufferUsage,
|
||||
};
|
||||
use crate::{
|
||||
check_errors,
|
||||
command_buffer::{
|
||||
CommandBufferInheritanceRenderPassInfo, CommandBufferInheritanceRenderPassType,
|
||||
CommandBufferInheritanceRenderingInfo,
|
||||
},
|
||||
device::{Device, DeviceOwned},
|
||||
OomError, VulkanObject,
|
||||
OomError, VulkanError, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{ptr, sync::Arc};
|
||||
@ -178,10 +177,9 @@ impl UnsafeCommandBufferBuilder {
|
||||
|
||||
let fns = device.fns();
|
||||
|
||||
check_errors((fns.v1_0.begin_command_buffer)(
|
||||
pool_alloc.internal_object(),
|
||||
&begin_info_vk,
|
||||
))?;
|
||||
(fns.v1_0.begin_command_buffer)(pool_alloc.internal_object(), &begin_info_vk)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
}
|
||||
|
||||
Ok(UnsafeCommandBufferBuilder {
|
||||
@ -196,7 +194,9 @@ impl UnsafeCommandBufferBuilder {
|
||||
pub fn build(self) -> Result<UnsafeCommandBuffer, OomError> {
|
||||
unsafe {
|
||||
let fns = self.device.fns();
|
||||
check_errors((fns.v1_0.end_command_buffer)(self.handle))?;
|
||||
(fns.v1_0.end_command_buffer)(self.handle)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
Ok(UnsafeCommandBuffer {
|
||||
command_buffer: self.handle,
|
||||
|
@ -25,7 +25,8 @@ use crate::{
|
||||
use parking_lot::Mutex;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
ops::Range,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
@ -529,9 +530,9 @@ pub enum CommandBufferExecError {
|
||||
// TODO: missing entries (eg. wrong queue family, secondary command buffer)
|
||||
}
|
||||
|
||||
impl error::Error for CommandBufferExecError {
|
||||
impl Error for CommandBufferExecError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
CommandBufferExecError::AccessError { ref error, .. } => Some(error),
|
||||
_ => None,
|
||||
|
@ -12,15 +12,15 @@
|
||||
//! When creating a new descriptor set, you must provide a *layout* object to create it from.
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
sampler::Sampler,
|
||||
shader::{DescriptorRequirements, ShaderStages},
|
||||
OomError, Version, VulkanObject,
|
||||
OomError, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap},
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
ptr,
|
||||
@ -338,13 +338,14 @@ impl DescriptorSetLayout {
|
||||
let handle = {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_descriptor_set_layout)(
|
||||
(fns.v1_0.create_descriptor_set_layout)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))
|
||||
.map_err(|e| OomError::from(e))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -495,13 +496,13 @@ pub enum DescriptorSetLayoutCreationError {
|
||||
VariableDescriptorCountDescriptorTypeIncompatible { binding_num: u32 },
|
||||
}
|
||||
|
||||
impl From<OomError> for DescriptorSetLayoutCreationError {
|
||||
fn from(error: OomError) -> Self {
|
||||
Self::OomError(error)
|
||||
impl From<VulkanError> for DescriptorSetLayoutCreationError {
|
||||
fn from(error: VulkanError) -> Self {
|
||||
Self::OomError(error.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for DescriptorSetLayoutCreationError {}
|
||||
impl Error for DescriptorSetLayoutCreationError {}
|
||||
|
||||
impl std::fmt::Display for DescriptorSetLayoutCreationError {
|
||||
#[inline]
|
||||
@ -769,7 +770,7 @@ pub enum DescriptorRequirementsNotMet {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for DescriptorRequirementsNotMet {}
|
||||
impl Error for DescriptorRequirementsNotMet {}
|
||||
|
||||
impl fmt::Display for DescriptorRequirementsNotMet {
|
||||
#[inline]
|
||||
|
@ -92,6 +92,7 @@ use crate::{
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
error::Error,
|
||||
hash::{Hash, Hasher},
|
||||
ptr,
|
||||
sync::Arc,
|
||||
@ -504,9 +505,9 @@ pub enum DescriptorSetCreationError {
|
||||
OomError(OomError),
|
||||
}
|
||||
|
||||
impl std::error::Error for DescriptorSetCreationError {
|
||||
impl Error for DescriptorSetCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
Self::DescriptorSetUpdateError(err) => Some(err),
|
||||
Self::OomError(err) => Some(err),
|
||||
|
@ -8,18 +8,18 @@
|
||||
// according to those terms.
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
descriptor_set::{
|
||||
layout::{DescriptorSetLayout, DescriptorType},
|
||||
sys::UnsafeDescriptorSet,
|
||||
},
|
||||
device::{Device, DeviceOwned},
|
||||
OomError, Version, VulkanObject,
|
||||
OomError, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
ptr,
|
||||
@ -96,12 +96,14 @@ impl UnsafeDescriptorPool {
|
||||
unsafe {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_descriptor_pool)(
|
||||
(fns.v1_0.create_descriptor_pool)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
}
|
||||
};
|
||||
@ -290,12 +292,14 @@ impl UnsafeDescriptorPool {
|
||||
.collect();
|
||||
if !sets.is_empty() {
|
||||
let fns = self.device.fns();
|
||||
check_errors((fns.v1_0.free_descriptor_sets)(
|
||||
(fns.v1_0.free_descriptor_sets)(
|
||||
self.device.internal_object(),
|
||||
self.handle,
|
||||
sets.len() as u32,
|
||||
sets.as_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -306,11 +310,13 @@ impl UnsafeDescriptorPool {
|
||||
/// This destroys all descriptor sets and empties the pool.
|
||||
pub unsafe fn reset(&mut self) -> Result<(), OomError> {
|
||||
let fns = self.device.fns();
|
||||
check_errors((fns.v1_0.reset_descriptor_pool)(
|
||||
(fns.v1_0.reset_descriptor_pool)(
|
||||
self.device.internal_object(),
|
||||
self.handle,
|
||||
ash::vk::DescriptorPoolResetFlags::empty(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@ -420,7 +426,7 @@ pub enum DescriptorPoolAllocError {
|
||||
OutOfPoolMemory,
|
||||
}
|
||||
|
||||
impl error::Error for DescriptorPoolAllocError {}
|
||||
impl Error for DescriptorPoolAllocError {}
|
||||
|
||||
impl fmt::Display for DescriptorPoolAllocError {
|
||||
#[inline]
|
||||
|
@ -16,7 +16,7 @@ use crate::{
|
||||
DeviceSize, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{ptr, sync::Arc};
|
||||
use std::{error::Error, ptr, sync::Arc};
|
||||
|
||||
/// Represents a single write operation to the binding of a descriptor set.
|
||||
///
|
||||
@ -955,8 +955,8 @@ pub enum DescriptorSetUpdateError {
|
||||
SamplerIsImmutable { binding: u32 },
|
||||
}
|
||||
|
||||
impl std::error::Error for DescriptorSetUpdateError {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
impl Error for DescriptorSetUpdateError {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
Self::ImageViewIncompatibleSampler { error, .. } => Some(error),
|
||||
_ => None,
|
||||
|
@ -8,7 +8,7 @@
|
||||
// according to those terms.
|
||||
|
||||
use crate::{device::DeviceExtensions, instance::InstanceExtensions, Version};
|
||||
use std::{error, fmt};
|
||||
use std::{error::Error, fmt};
|
||||
|
||||
// Generated by build.rs
|
||||
include!(concat!(env!("OUT_DIR"), "/features.rs"));
|
||||
@ -22,7 +22,7 @@ pub struct FeatureRestrictionError {
|
||||
pub restriction: FeatureRestriction,
|
||||
}
|
||||
|
||||
impl error::Error for FeatureRestrictionError {}
|
||||
impl Error for FeatureRestrictionError {}
|
||||
|
||||
impl fmt::Display for FeatureRestrictionError {
|
||||
#[inline]
|
||||
|
@ -103,12 +103,11 @@ pub use self::{
|
||||
properties::Properties,
|
||||
};
|
||||
use crate::{
|
||||
check_errors,
|
||||
command_buffer::pool::StandardCommandPool,
|
||||
descriptor_set::pool::StandardDescriptorPool,
|
||||
instance::{debug::DebugUtilsLabel, Instance},
|
||||
memory::{pool::StandardMemoryPool, ExternalMemoryHandleType},
|
||||
Error, OomError, SynchronizedVulkanObject, Version, VulkanObject,
|
||||
OomError, SynchronizedVulkanObject, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
pub use crate::{
|
||||
device::extensions::DeviceExtensions,
|
||||
@ -122,7 +121,7 @@ use smallvec::SmallVec;
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
collections::{hash_map::Entry, HashMap},
|
||||
error,
|
||||
error::Error,
|
||||
ffi::CString,
|
||||
fmt,
|
||||
fs::File,
|
||||
@ -385,12 +384,14 @@ impl Device {
|
||||
|
||||
let handle = unsafe {
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns_i.v1_0.create_device)(
|
||||
(fns_i.v1_0.create_device)(
|
||||
physical_device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -467,7 +468,9 @@ impl Device {
|
||||
///
|
||||
pub unsafe fn wait(&self) -> Result<(), OomError> {
|
||||
let fns = self.fns();
|
||||
check_errors((fns.v1_0.device_wait_idle)(self.handle))?;
|
||||
(fns.v1_0.device_wait_idle)(self.handle)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -636,12 +639,14 @@ impl Device {
|
||||
let mut memory_fd_properties = ash::vk::MemoryFdPropertiesKHR::default();
|
||||
|
||||
let fns = self.fns();
|
||||
check_errors((fns.khr_external_memory_fd.get_memory_fd_properties_khr)(
|
||||
(fns.khr_external_memory_fd.get_memory_fd_properties_khr)(
|
||||
self.handle,
|
||||
handle_type.into(),
|
||||
file.into_raw_fd(),
|
||||
&mut memory_fd_properties,
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
Ok(MemoryFdProperties {
|
||||
memory_type_bits: memory_fd_properties.memory_type_bits,
|
||||
@ -672,10 +677,9 @@ impl Device {
|
||||
|
||||
unsafe {
|
||||
let fns = self.instance.fns();
|
||||
check_errors((fns.ext_debug_utils.set_debug_utils_object_name_ext)(
|
||||
self.handle,
|
||||
&info,
|
||||
))?;
|
||||
(fns.ext_debug_utils.set_debug_utils_object_name_ext)(self.handle, &info)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -756,7 +760,7 @@ pub enum DeviceCreationError {
|
||||
FeatureRestrictionNotMet(FeatureRestrictionError),
|
||||
}
|
||||
|
||||
impl error::Error for DeviceCreationError {}
|
||||
impl Error for DeviceCreationError {}
|
||||
|
||||
impl fmt::Display for DeviceCreationError {
|
||||
#[inline]
|
||||
@ -800,18 +804,18 @@ impl fmt::Display for DeviceCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for DeviceCreationError {
|
||||
impl From<VulkanError> for DeviceCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
Error::InitializationFailed => Self::InitializationFailed,
|
||||
Error::OutOfHostMemory => Self::OutOfHostMemory,
|
||||
Error::OutOfDeviceMemory => Self::OutOfDeviceMemory,
|
||||
Error::DeviceLost => Self::DeviceLost,
|
||||
Error::ExtensionNotPresent => Self::ExtensionNotPresent,
|
||||
Error::FeatureNotPresent => Self::FeatureNotPresent,
|
||||
Error::TooManyObjects => Self::TooManyObjects,
|
||||
_ => panic!("Unexpected error value: {}", err as i32),
|
||||
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,
|
||||
_ => panic!("Unexpected error value"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -940,7 +944,7 @@ pub enum MemoryFdPropertiesError {
|
||||
NotSupported,
|
||||
}
|
||||
|
||||
impl error::Error for MemoryFdPropertiesError {}
|
||||
impl Error for MemoryFdPropertiesError {}
|
||||
|
||||
impl fmt::Display for MemoryFdPropertiesError {
|
||||
#[inline]
|
||||
@ -961,13 +965,13 @@ impl fmt::Display for MemoryFdPropertiesError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for MemoryFdPropertiesError {
|
||||
impl From<VulkanError> for MemoryFdPropertiesError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
Error::OutOfHostMemory => Self::OutOfHostMemory,
|
||||
Error::InvalidExternalHandle => Self::InvalidExternalHandle,
|
||||
_ => panic!("Unexpected error value: {}", err as i32),
|
||||
VulkanError::OutOfHostMemory => Self::OutOfHostMemory,
|
||||
VulkanError::InvalidExternalHandle => Self::InvalidExternalHandle,
|
||||
_ => panic!("Unexpected error value"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1012,7 +1016,9 @@ impl Queue {
|
||||
unsafe {
|
||||
let fns = self.device.fns();
|
||||
let handle = self.handle.lock();
|
||||
check_errors((fns.v1_0.queue_wait_idle)(*handle))?;
|
||||
(fns.v1_0.queue_wait_idle)(*handle)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@ -1204,7 +1210,7 @@ pub enum DebugUtilsError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for DebugUtilsError {}
|
||||
impl Error for DebugUtilsError {}
|
||||
|
||||
impl fmt::Display for DebugUtilsError {
|
||||
#[inline]
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
use crate::{
|
||||
buffer::{BufferUsage, ExternalBufferInfo, ExternalBufferProperties},
|
||||
check_errors,
|
||||
device::{DeviceExtensions, Features, FeaturesFfi, Properties, PropertiesFfi},
|
||||
format::{Format, FormatProperties},
|
||||
image::{ImageCreateFlags, ImageFormatInfo, ImageFormatProperties, ImageUsage},
|
||||
@ -19,9 +18,9 @@ use crate::{
|
||||
SurfaceApi, SurfaceCapabilities, SurfaceInfo,
|
||||
},
|
||||
sync::{ExternalSemaphoreInfo, ExternalSemaphoreProperties, PipelineStage},
|
||||
DeviceSize, Error, OomError, Success, Version, VulkanObject,
|
||||
DeviceSize, OomError, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use std::{error, ffi::CStr, fmt, hash::Hash, mem::MaybeUninit, ptr, sync::Arc};
|
||||
use std::{error::Error, ffi::CStr, fmt, hash::Hash, mem::MaybeUninit, ptr, sync::Arc};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct PhysicalDeviceInfo {
|
||||
@ -43,22 +42,28 @@ pub(crate) fn init_physical_devices(
|
||||
let handles = unsafe {
|
||||
loop {
|
||||
let mut count = 0;
|
||||
check_errors((fns.v1_0.enumerate_physical_devices)(
|
||||
(fns.v1_0.enumerate_physical_devices)(
|
||||
instance.internal_object(),
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
let mut handles = Vec::with_capacity(count as usize);
|
||||
let result = check_errors((fns.v1_0.enumerate_physical_devices)(
|
||||
let result = (fns.v1_0.enumerate_physical_devices)(
|
||||
instance.internal_object(),
|
||||
&mut count,
|
||||
handles.as_mut_ptr(),
|
||||
))?;
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
handles.set_len(count as usize);
|
||||
break handles;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
handles.set_len(count as usize);
|
||||
break handles;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => return Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -77,24 +82,30 @@ pub(crate) fn init_physical_devices(
|
||||
let extension_properties = unsafe {
|
||||
loop {
|
||||
let mut count = 0;
|
||||
check_errors((fns.v1_0.enumerate_device_extension_properties)(
|
||||
(fns.v1_0.enumerate_device_extension_properties)(
|
||||
handle,
|
||||
ptr::null(),
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
let mut properties = Vec::with_capacity(count as usize);
|
||||
let result = check_errors((fns.v1_0.enumerate_device_extension_properties)(
|
||||
let result = (fns.v1_0.enumerate_device_extension_properties)(
|
||||
handle,
|
||||
ptr::null(),
|
||||
&mut count,
|
||||
properties.as_mut_ptr(),
|
||||
))?;
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
properties.set_len(count as usize);
|
||||
break properties;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
properties.set_len(count as usize);
|
||||
break properties;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => return Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -741,7 +752,7 @@ impl<'a> PhysicalDevice<'a> {
|
||||
let result = unsafe {
|
||||
let fns = self.instance.fns();
|
||||
|
||||
check_errors(if self.api_version() >= Version::V1_1 {
|
||||
if self.api_version() >= Version::V1_1 {
|
||||
(fns.v1_1.get_physical_device_image_format_properties2)(
|
||||
self.info.handle,
|
||||
&format_info2.build(),
|
||||
@ -773,7 +784,9 @@ impl<'a> PhysicalDevice<'a> {
|
||||
format_info2.flags,
|
||||
&mut image_format_properties2.image_format_properties,
|
||||
)
|
||||
})
|
||||
}
|
||||
.result()
|
||||
.map_err(VulkanError::from)
|
||||
};
|
||||
|
||||
match result {
|
||||
@ -791,7 +804,7 @@ impl<'a> PhysicalDevice<'a> {
|
||||
}),
|
||||
..image_format_properties2.image_format_properties.into()
|
||||
})),
|
||||
Err(Error::FormatNotSupported) => Ok(None),
|
||||
Err(VulkanError::FormatNotSupported) => Ok(None),
|
||||
Err(err) => Err(err.into()),
|
||||
}
|
||||
}
|
||||
@ -986,21 +999,22 @@ impl<'a> PhysicalDevice<'a> {
|
||||
.enabled_extensions()
|
||||
.khr_get_surface_capabilities2
|
||||
{
|
||||
check_errors((fns
|
||||
.khr_get_surface_capabilities2
|
||||
(fns.khr_get_surface_capabilities2
|
||||
.get_physical_device_surface_capabilities2_khr)(
|
||||
self.internal_object(),
|
||||
&surface_info2,
|
||||
&mut surface_capabilities2,
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
} else {
|
||||
check_errors((fns
|
||||
.khr_surface
|
||||
.get_physical_device_surface_capabilities_khr)(
|
||||
(fns.khr_surface.get_physical_device_surface_capabilities_khr)(
|
||||
self.internal_object(),
|
||||
surface_info2.surface,
|
||||
&mut surface_capabilities2.surface_capabilities,
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
};
|
||||
}
|
||||
|
||||
@ -1173,29 +1187,34 @@ impl<'a> PhysicalDevice<'a> {
|
||||
let surface_format2s = unsafe {
|
||||
loop {
|
||||
let mut count = 0;
|
||||
check_errors((fns
|
||||
.khr_get_surface_capabilities2
|
||||
(fns.khr_get_surface_capabilities2
|
||||
.get_physical_device_surface_formats2_khr)(
|
||||
self.internal_object(),
|
||||
&surface_info2,
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
let mut surface_format2s =
|
||||
vec![ash::vk::SurfaceFormat2KHR::default(); count as usize];
|
||||
let result = check_errors((fns
|
||||
let result = (fns
|
||||
.khr_get_surface_capabilities2
|
||||
.get_physical_device_surface_formats2_khr)(
|
||||
self.internal_object(),
|
||||
&surface_info2,
|
||||
&mut count,
|
||||
surface_format2s.as_mut_ptr(),
|
||||
))?;
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
surface_format2s.set_len(count as usize);
|
||||
break surface_format2s;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
surface_format2s.set_len(count as usize);
|
||||
break surface_format2s;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => return Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1217,25 +1236,30 @@ impl<'a> PhysicalDevice<'a> {
|
||||
let surface_formats = unsafe {
|
||||
loop {
|
||||
let mut count = 0;
|
||||
check_errors((fns.khr_surface.get_physical_device_surface_formats_khr)(
|
||||
(fns.khr_surface.get_physical_device_surface_formats_khr)(
|
||||
self.internal_object(),
|
||||
surface.internal_object(),
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
let mut surface_formats = Vec::with_capacity(count as usize);
|
||||
let result =
|
||||
check_errors((fns.khr_surface.get_physical_device_surface_formats_khr)(
|
||||
self.internal_object(),
|
||||
surface.internal_object(),
|
||||
&mut count,
|
||||
surface_formats.as_mut_ptr(),
|
||||
))?;
|
||||
let result = (fns.khr_surface.get_physical_device_surface_formats_khr)(
|
||||
self.internal_object(),
|
||||
surface.internal_object(),
|
||||
&mut count,
|
||||
surface_formats.as_mut_ptr(),
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
surface_formats.set_len(count as usize);
|
||||
break surface_formats;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
surface_formats.set_len(count as usize);
|
||||
break surface_formats;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => return Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1269,28 +1293,33 @@ impl<'a> PhysicalDevice<'a> {
|
||||
let modes = unsafe {
|
||||
loop {
|
||||
let mut count = 0;
|
||||
check_errors((fns
|
||||
.khr_surface
|
||||
(fns.khr_surface
|
||||
.get_physical_device_surface_present_modes_khr)(
|
||||
self.internal_object(),
|
||||
surface.internal_object(),
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
let mut modes = Vec::with_capacity(count as usize);
|
||||
let result = check_errors((fns
|
||||
let result = (fns
|
||||
.khr_surface
|
||||
.get_physical_device_surface_present_modes_khr)(
|
||||
self.internal_object(),
|
||||
surface.internal_object(),
|
||||
&mut count,
|
||||
modes.as_mut_ptr(),
|
||||
))?;
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
modes.set_len(count as usize);
|
||||
break modes;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
modes.set_len(count as usize);
|
||||
break modes;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => return Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1592,12 +1621,14 @@ impl<'a> QueueFamily<'a> {
|
||||
let fns = self.physical_device.instance.fns();
|
||||
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.khr_surface.get_physical_device_surface_support_khr)(
|
||||
(fns.khr_surface.get_physical_device_surface_support_khr)(
|
||||
self.physical_device.internal_object(),
|
||||
self.id,
|
||||
surface.internal_object(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
Ok(output.assume_init() != 0)
|
||||
}
|
||||
}
|
||||
@ -1797,9 +1828,9 @@ pub enum SurfacePropertiesError {
|
||||
NotSupported,
|
||||
}
|
||||
|
||||
impl error::Error for SurfacePropertiesError {
|
||||
impl Error for SurfacePropertiesError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -1829,13 +1860,13 @@ impl From<OomError> for SurfacePropertiesError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for SurfacePropertiesError {
|
||||
impl From<VulkanError> for SurfacePropertiesError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> SurfacePropertiesError {
|
||||
fn from(err: VulkanError) -> SurfacePropertiesError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
|
||||
Error::SurfaceLost => Self::SurfaceLost,
|
||||
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ VulkanError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
|
||||
VulkanError::SurfaceLost => Self::SurfaceLost,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
use crate::Version;
|
||||
use std::{
|
||||
error,
|
||||
error::Error,
|
||||
fmt::{Display, Error as FmtError, Formatter},
|
||||
};
|
||||
|
||||
@ -22,7 +22,7 @@ pub struct ExtensionRestrictionError {
|
||||
pub restriction: ExtensionRestriction,
|
||||
}
|
||||
|
||||
impl error::Error for ExtensionRestrictionError {}
|
||||
impl Error for ExtensionRestrictionError {}
|
||||
|
||||
impl Display for ExtensionRestrictionError {
|
||||
#[inline]
|
||||
|
@ -35,7 +35,8 @@ use crate::{
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
ops::Range,
|
||||
sync::Arc,
|
||||
@ -477,9 +478,9 @@ pub enum ImmutableImageCreationError {
|
||||
CommandBufferBeginError(CommandBufferBeginError),
|
||||
}
|
||||
|
||||
impl error::Error for ImmutableImageCreationError {
|
||||
impl Error for ImmutableImageCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
Self::ImageCreationError(err) => Some(err),
|
||||
Self::DeviceMemoryAllocationError(err) => Some(err),
|
||||
|
@ -20,7 +20,6 @@ use super::{
|
||||
};
|
||||
use crate::{
|
||||
buffer::cpu_access::{ReadLockError, WriteLockError},
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
format::{ChromaSampling, Format, FormatFeatures, NumericType},
|
||||
image::{view::ImageViewCreationError, ImageFormatInfo, ImageFormatProperties, ImageType},
|
||||
@ -30,13 +29,14 @@ use crate::{
|
||||
},
|
||||
range_map::RangeMap,
|
||||
sync::{AccessError, CurrentAccess, Sharing},
|
||||
DeviceSize, Error, OomError, Version, VulkanObject,
|
||||
DeviceSize, OomError, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use ash::vk::Handle;
|
||||
use parking_lot::{Mutex, MutexGuard};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
iter::{FusedIterator, Peekable},
|
||||
mem::MaybeUninit,
|
||||
@ -839,12 +839,14 @@ impl UnsafeImage {
|
||||
let handle = {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_image)(
|
||||
(fns.v1_0.create_image)(
|
||||
device.internal_object(),
|
||||
&create_info.build(),
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -1000,12 +1002,14 @@ impl UnsafeImage {
|
||||
&& mem_reqs.memory_type_bits & (1 << memory.memory_type().id()) != 0
|
||||
});
|
||||
|
||||
check_errors((fns.v1_0.bind_image_memory)(
|
||||
(fns.v1_0.bind_image_memory)(
|
||||
self.device.internal_object(),
|
||||
self.handle,
|
||||
memory.internal_object(),
|
||||
offset,
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -1625,9 +1629,9 @@ pub enum ImageCreationError {
|
||||
DirectImageViewCreationFailed(ImageViewCreationError),
|
||||
}
|
||||
|
||||
impl error::Error for ImageCreationError {
|
||||
impl Error for ImageCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
ImageCreationError::AllocError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -1777,12 +1781,12 @@ impl From<DeviceMemoryAllocationError> for ImageCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for ImageCreationError {
|
||||
impl From<VulkanError> for ImageCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => Self::AllocError(err.into()),
|
||||
err @ Error::OutOfDeviceMemory => Self::AllocError(err.into()),
|
||||
err @ VulkanError::OutOfHostMemory => Self::AllocError(err.into()),
|
||||
err @ VulkanError::OutOfDeviceMemory => Self::AllocError(err.into()),
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -15,15 +15,15 @@
|
||||
|
||||
use super::{ImageAccess, ImageDimensions, ImageFormatInfo, ImageSubresourceRange, ImageUsage};
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
format::{ChromaSampling, Format, FormatFeatures},
|
||||
image::{ImageAspects, ImageTiling, ImageType, SampleCount},
|
||||
sampler::{ycbcr::SamplerYcbcrConversion, ComponentMapping},
|
||||
Error, OomError, VulkanObject,
|
||||
OomError, VulkanError, VulkanObject,
|
||||
};
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
ptr,
|
||||
@ -525,12 +525,14 @@ where
|
||||
let handle = {
|
||||
let fns = image_inner.device().fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_image_view)(
|
||||
(fns.v1_0.create_image_view)(
|
||||
image_inner.device().internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -795,9 +797,9 @@ pub enum ImageViewCreationError {
|
||||
TypeNonArrayedMultipleArrayLayers,
|
||||
}
|
||||
|
||||
impl error::Error for ImageViewCreationError {
|
||||
impl Error for ImageViewCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
ImageViewCreationError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -915,12 +917,12 @@ impl From<OomError> for ImageViewCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for ImageViewCreationError {
|
||||
impl From<VulkanError> for ImageViewCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> ImageViewCreationError {
|
||||
fn from(err: VulkanError) -> ImageViewCreationError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => OomError::from(err).into(),
|
||||
err @ Error::OutOfDeviceMemory => OomError::from(err).into(),
|
||||
err @ VulkanError::OutOfHostMemory => OomError::from(err).into(),
|
||||
err @ VulkanError::OutOfDeviceMemory => OomError::from(err).into(),
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -43,9 +43,9 @@
|
||||
//!
|
||||
|
||||
use super::Instance;
|
||||
use crate::{check_errors, Error, VulkanObject};
|
||||
use crate::{VulkanError, VulkanObject};
|
||||
use std::{
|
||||
error,
|
||||
error::Error,
|
||||
ffi::{c_void, CStr},
|
||||
fmt,
|
||||
mem::MaybeUninit,
|
||||
@ -151,12 +151,14 @@ impl DebugUtilsMessenger {
|
||||
|
||||
let handle = {
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.ext_debug_utils.create_debug_utils_messenger_ext)(
|
||||
(fns.ext_debug_utils.create_debug_utils_messenger_ext)(
|
||||
instance.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -240,7 +242,7 @@ pub enum DebugUtilsMessengerCreationError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for DebugUtilsMessengerCreationError {}
|
||||
impl Error for DebugUtilsMessengerCreationError {}
|
||||
|
||||
impl fmt::Display for DebugUtilsMessengerCreationError {
|
||||
#[inline]
|
||||
@ -253,9 +255,9 @@ impl fmt::Display for DebugUtilsMessengerCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for DebugUtilsMessengerCreationError {
|
||||
impl From<VulkanError> for DebugUtilsMessengerCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> DebugUtilsMessengerCreationError {
|
||||
fn from(err: VulkanError) -> DebugUtilsMessengerCreationError {
|
||||
panic!("unexpected error: {:?}", err)
|
||||
}
|
||||
}
|
||||
|
@ -57,10 +57,9 @@
|
||||
use self::debug::{DebugUtilsMessengerCreateInfo, UserCallback};
|
||||
pub use self::{extensions::InstanceExtensions, layers::LayerProperties};
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::physical::{init_physical_devices, PhysicalDeviceInfo},
|
||||
instance::debug::{trampoline, DebugUtilsMessageSeverity, DebugUtilsMessageType},
|
||||
Error, OomError, VulkanLibrary, VulkanObject,
|
||||
OomError, VulkanError, VulkanLibrary, VulkanObject,
|
||||
};
|
||||
pub use crate::{
|
||||
extensions::{ExtensionRestriction, ExtensionRestrictionError},
|
||||
@ -69,7 +68,7 @@ pub use crate::{
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
error,
|
||||
error::Error,
|
||||
ffi::{c_void, CString},
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
@ -429,11 +428,9 @@ impl Instance {
|
||||
let handle = {
|
||||
let mut output = MaybeUninit::uninit();
|
||||
let fns = library.fns();
|
||||
check_errors((fns.v1_0.create_instance)(
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
(fns.v1_0.create_instance)(&create_info, ptr::null(), output.as_mut_ptr())
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -693,9 +690,9 @@ pub enum InstanceCreationError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for InstanceCreationError {
|
||||
impl Error for InstanceCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -736,16 +733,16 @@ impl From<ExtensionRestrictionError> for InstanceCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for InstanceCreationError {
|
||||
impl From<VulkanError> for InstanceCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
|
||||
Error::InitializationFailed => Self::InitializationFailed,
|
||||
Error::LayerNotPresent => Self::LayerNotPresent,
|
||||
Error::ExtensionNotPresent => Self::ExtensionNotPresent,
|
||||
Error::IncompatibleDriver => Self::IncompatibleDriver,
|
||||
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,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ pub use ash::vk::Handle;
|
||||
pub use half;
|
||||
pub use library::VulkanLibrary;
|
||||
use parking_lot::MutexGuard;
|
||||
use std::{error, fmt, ops::Deref, sync::Arc};
|
||||
use std::{error::Error, fmt, ops::Deref, sync::Arc};
|
||||
pub use version::Version;
|
||||
|
||||
#[macro_use]
|
||||
@ -136,7 +136,7 @@ pub enum OomError {
|
||||
OutOfDeviceMemory,
|
||||
}
|
||||
|
||||
impl error::Error for OomError {}
|
||||
impl Error for OomError {}
|
||||
|
||||
impl fmt::Display for OomError {
|
||||
#[inline]
|
||||
@ -152,95 +152,135 @@ impl fmt::Display for OomError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for OomError {
|
||||
impl From<VulkanError> for OomError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> OomError {
|
||||
fn from(err: VulkanError) -> OomError {
|
||||
match err {
|
||||
Error::OutOfHostMemory => OomError::OutOfHostMemory,
|
||||
Error::OutOfDeviceMemory => OomError::OutOfDeviceMemory,
|
||||
VulkanError::OutOfHostMemory => OomError::OutOfHostMemory,
|
||||
VulkanError::OutOfDeviceMemory => OomError::OutOfDeviceMemory,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// All possible success codes returned by any Vulkan function.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[repr(i32)]
|
||||
enum Success {
|
||||
Success = ash::vk::Result::SUCCESS.as_raw(),
|
||||
NotReady = ash::vk::Result::NOT_READY.as_raw(),
|
||||
Timeout = ash::vk::Result::TIMEOUT.as_raw(),
|
||||
EventSet = ash::vk::Result::EVENT_SET.as_raw(),
|
||||
EventReset = ash::vk::Result::EVENT_RESET.as_raw(),
|
||||
Incomplete = ash::vk::Result::INCOMPLETE.as_raw(),
|
||||
Suboptimal = ash::vk::Result::SUBOPTIMAL_KHR.as_raw(),
|
||||
}
|
||||
// Generated by build.rs
|
||||
include!(concat!(env!("OUT_DIR"), "/errors.rs"));
|
||||
|
||||
/// All possible errors returned by any Vulkan function.
|
||||
///
|
||||
/// This type is not public. Instead all public error types should implement `From<Error>` and
|
||||
/// panic for error code that aren't supposed to happen.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[repr(i32)]
|
||||
// TODO: being pub is necessary because of the weird visibility rules in rustc
|
||||
pub(crate) enum Error {
|
||||
OutOfHostMemory = ash::vk::Result::ERROR_OUT_OF_HOST_MEMORY.as_raw(),
|
||||
OutOfDeviceMemory = ash::vk::Result::ERROR_OUT_OF_DEVICE_MEMORY.as_raw(),
|
||||
InitializationFailed = ash::vk::Result::ERROR_INITIALIZATION_FAILED.as_raw(),
|
||||
DeviceLost = ash::vk::Result::ERROR_DEVICE_LOST.as_raw(),
|
||||
MemoryMapFailed = ash::vk::Result::ERROR_MEMORY_MAP_FAILED.as_raw(),
|
||||
LayerNotPresent = ash::vk::Result::ERROR_LAYER_NOT_PRESENT.as_raw(),
|
||||
ExtensionNotPresent = ash::vk::Result::ERROR_EXTENSION_NOT_PRESENT.as_raw(),
|
||||
FeatureNotPresent = ash::vk::Result::ERROR_FEATURE_NOT_PRESENT.as_raw(),
|
||||
IncompatibleDriver = ash::vk::Result::ERROR_INCOMPATIBLE_DRIVER.as_raw(),
|
||||
TooManyObjects = ash::vk::Result::ERROR_TOO_MANY_OBJECTS.as_raw(),
|
||||
FormatNotSupported = ash::vk::Result::ERROR_FORMAT_NOT_SUPPORTED.as_raw(),
|
||||
SurfaceLost = ash::vk::Result::ERROR_SURFACE_LOST_KHR.as_raw(),
|
||||
NativeWindowInUse = ash::vk::Result::ERROR_NATIVE_WINDOW_IN_USE_KHR.as_raw(),
|
||||
OutOfDate = ash::vk::Result::ERROR_OUT_OF_DATE_KHR.as_raw(),
|
||||
IncompatibleDisplay = ash::vk::Result::ERROR_INCOMPATIBLE_DISPLAY_KHR.as_raw(),
|
||||
ValidationFailed = ash::vk::Result::ERROR_VALIDATION_FAILED_EXT.as_raw(),
|
||||
OutOfPoolMemory = ash::vk::Result::ERROR_OUT_OF_POOL_MEMORY_KHR.as_raw(),
|
||||
InvalidExternalHandle = ash::vk::Result::ERROR_INVALID_EXTERNAL_HANDLE.as_raw(),
|
||||
FullScreenExclusiveLost = ash::vk::Result::ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT.as_raw(),
|
||||
}
|
||||
impl Error for VulkanError {}
|
||||
|
||||
/// Checks whether the result returned correctly.
|
||||
fn check_errors(result: ash::vk::Result) -> Result<Success, Error> {
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => Ok(Success::Success),
|
||||
ash::vk::Result::NOT_READY => Ok(Success::NotReady),
|
||||
ash::vk::Result::TIMEOUT => Ok(Success::Timeout),
|
||||
ash::vk::Result::EVENT_SET => Ok(Success::EventSet),
|
||||
ash::vk::Result::EVENT_RESET => Ok(Success::EventReset),
|
||||
ash::vk::Result::INCOMPLETE => Ok(Success::Incomplete),
|
||||
ash::vk::Result::ERROR_OUT_OF_HOST_MEMORY => Err(Error::OutOfHostMemory),
|
||||
ash::vk::Result::ERROR_OUT_OF_DEVICE_MEMORY => Err(Error::OutOfDeviceMemory),
|
||||
ash::vk::Result::ERROR_INITIALIZATION_FAILED => Err(Error::InitializationFailed),
|
||||
ash::vk::Result::ERROR_DEVICE_LOST => Err(Error::DeviceLost),
|
||||
ash::vk::Result::ERROR_MEMORY_MAP_FAILED => Err(Error::MemoryMapFailed),
|
||||
ash::vk::Result::ERROR_LAYER_NOT_PRESENT => Err(Error::LayerNotPresent),
|
||||
ash::vk::Result::ERROR_EXTENSION_NOT_PRESENT => Err(Error::ExtensionNotPresent),
|
||||
ash::vk::Result::ERROR_FEATURE_NOT_PRESENT => Err(Error::FeatureNotPresent),
|
||||
ash::vk::Result::ERROR_INCOMPATIBLE_DRIVER => Err(Error::IncompatibleDriver),
|
||||
ash::vk::Result::ERROR_TOO_MANY_OBJECTS => Err(Error::TooManyObjects),
|
||||
ash::vk::Result::ERROR_FORMAT_NOT_SUPPORTED => Err(Error::FormatNotSupported),
|
||||
ash::vk::Result::ERROR_SURFACE_LOST_KHR => Err(Error::SurfaceLost),
|
||||
ash::vk::Result::ERROR_NATIVE_WINDOW_IN_USE_KHR => Err(Error::NativeWindowInUse),
|
||||
ash::vk::Result::SUBOPTIMAL_KHR => Ok(Success::Suboptimal),
|
||||
ash::vk::Result::ERROR_OUT_OF_DATE_KHR => Err(Error::OutOfDate),
|
||||
ash::vk::Result::ERROR_INCOMPATIBLE_DISPLAY_KHR => Err(Error::IncompatibleDisplay),
|
||||
ash::vk::Result::ERROR_VALIDATION_FAILED_EXT => Err(Error::ValidationFailed),
|
||||
ash::vk::Result::ERROR_OUT_OF_POOL_MEMORY_KHR => Err(Error::OutOfPoolMemory),
|
||||
ash::vk::Result::ERROR_INVALID_EXTERNAL_HANDLE => Err(Error::InvalidExternalHandle),
|
||||
ash::vk::Result::ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT => {
|
||||
Err(Error::FullScreenExclusiveLost)
|
||||
impl fmt::Display for VulkanError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
VulkanError::OutOfHostMemory => write!(
|
||||
f,
|
||||
"A host memory allocation has failed.",
|
||||
),
|
||||
VulkanError::OutOfDeviceMemory => write!(
|
||||
f,
|
||||
"A device memory allocation has failed.",
|
||||
),
|
||||
VulkanError::InitializationFailed => write!(
|
||||
f,
|
||||
"Initialization of an object could not be completed for implementation-specific reasons.",
|
||||
),
|
||||
VulkanError::DeviceLost => write!(
|
||||
f,
|
||||
"The logical or physical device has been lost.",
|
||||
),
|
||||
VulkanError::MemoryMapFailed => write!(
|
||||
f,
|
||||
"Mapping of a memory object has failed.",
|
||||
),
|
||||
VulkanError::LayerNotPresent => write!(
|
||||
f,
|
||||
"A requested layer is not present or could not be loaded.",
|
||||
),
|
||||
VulkanError::ExtensionNotPresent => write!(
|
||||
f,
|
||||
"A requested extension is not supported.",
|
||||
),
|
||||
VulkanError::FeatureNotPresent => write!(
|
||||
f,
|
||||
"A requested feature is not supported.",
|
||||
),
|
||||
VulkanError::IncompatibleDriver => write!(
|
||||
f,
|
||||
"The requested version of Vulkan is not supported by the driver or is otherwise incompatible for implementation-specific reasons.",
|
||||
),
|
||||
VulkanError::TooManyObjects => write!(
|
||||
f,
|
||||
"Too many objects of the type have already been created.",
|
||||
),
|
||||
VulkanError::FormatNotSupported => write!(
|
||||
f,
|
||||
"A requested format is not supported on this device.",
|
||||
),
|
||||
VulkanError::FragmentedPool => write!(
|
||||
f,
|
||||
"A pool allocation has failed due to fragmentation of the pool's memory.",
|
||||
),
|
||||
VulkanError::Unknown => write!(
|
||||
f,
|
||||
"An unknown error has occurred; either the application has provided invalid input, or an implementation failure has occurred.",
|
||||
),
|
||||
VulkanError::OutOfPoolMemory => write!(
|
||||
f,
|
||||
"A pool memory allocation has failed.",
|
||||
),
|
||||
VulkanError::InvalidExternalHandle => write!(
|
||||
f,
|
||||
"An external handle is not a valid handle of the specified type.",
|
||||
),
|
||||
VulkanError::Fragmentation => write!(
|
||||
f,
|
||||
"A descriptor pool creation has failed due to fragmentation.",
|
||||
),
|
||||
VulkanError::InvalidOpaqueCaptureAddress => write!(
|
||||
f,
|
||||
"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 => write!(
|
||||
f,
|
||||
"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 => write!(
|
||||
f,
|
||||
"A requested operation was not permitted.",
|
||||
),
|
||||
VulkanError::SurfaceLost => write!(
|
||||
f,
|
||||
"A surface is no longer available.",
|
||||
),
|
||||
VulkanError::NativeWindowInUse => write!(
|
||||
f,
|
||||
"The requested window is already in use by Vulkan or another API in a manner which prevents it from being used again.",
|
||||
),
|
||||
VulkanError::OutOfDate => write!(
|
||||
f,
|
||||
"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 => write!(
|
||||
f,
|
||||
"Validation failed.",
|
||||
),
|
||||
VulkanError::FullScreenExclusiveModeLost => write!(
|
||||
f,
|
||||
"An operation on a swapchain created with application controlled full-screen access failed as it did not have exclusive full-screen access.",
|
||||
),
|
||||
VulkanError::InvalidDrmFormatModifierPlaneLayout => write!(
|
||||
f,
|
||||
"The requested DRM format modifier plane layout is invalid.",
|
||||
),
|
||||
VulkanError::InvalidShader => write!(
|
||||
f,
|
||||
"One or more shaders failed to compile or link.",
|
||||
),
|
||||
VulkanError::Unnamed(result) => write!(
|
||||
f,
|
||||
"Unnamed error, VkResult value {}",
|
||||
result.as_raw(),
|
||||
),
|
||||
}
|
||||
ash::vk::Result::ERROR_INVALID_SHADER_NV => panic!(
|
||||
"Vulkan function returned \
|
||||
VK_ERROR_INVALID_SHADER_NV"
|
||||
),
|
||||
c => unreachable!("Unexpected error code returned by Vulkan: {}", c),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,13 @@
|
||||
|
||||
pub use crate::fns::EntryFunctions;
|
||||
use crate::{
|
||||
check_errors,
|
||||
instance::{InstanceExtensions, LayerProperties},
|
||||
Error, OomError, SafeDeref, Success, Version,
|
||||
OomError, SafeDeref, Version, VulkanError,
|
||||
};
|
||||
use libloading::{Error as LibloadingError, Library};
|
||||
use std::{error, ffi::CStr, fmt, mem::transmute, os::raw::c_char, path::Path, ptr, sync::Arc};
|
||||
use std::{
|
||||
error::Error, ffi::CStr, fmt, mem::transmute, os::raw::c_char, path::Path, ptr, sync::Arc,
|
||||
};
|
||||
|
||||
/// A loaded library containing a valid Vulkan implementation.
|
||||
#[derive(Debug)]
|
||||
@ -95,7 +96,7 @@ impl VulkanLibrary {
|
||||
if let Some(func) = func {
|
||||
let func: ash::vk::PFN_vkEnumerateInstanceVersion = transmute(func);
|
||||
let mut api_version = 0;
|
||||
check_errors(func(&mut api_version))?;
|
||||
func(&mut api_version).result().map_err(VulkanError::from)?;
|
||||
Version::from(api_version)
|
||||
} else {
|
||||
Version {
|
||||
@ -109,22 +110,28 @@ impl VulkanLibrary {
|
||||
let supported_extensions = unsafe {
|
||||
let extension_properties = loop {
|
||||
let mut count = 0;
|
||||
check_errors((fns.v1_0.enumerate_instance_extension_properties)(
|
||||
(fns.v1_0.enumerate_instance_extension_properties)(
|
||||
ptr::null(),
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
let mut properties = Vec::with_capacity(count as usize);
|
||||
let result = check_errors((fns.v1_0.enumerate_instance_extension_properties)(
|
||||
let result = (fns.v1_0.enumerate_instance_extension_properties)(
|
||||
ptr::null(),
|
||||
&mut count,
|
||||
properties.as_mut_ptr(),
|
||||
))?;
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
properties.set_len(count as usize);
|
||||
break properties;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
properties.set_len(count as usize);
|
||||
break properties;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => return Err(VulkanError::from(err).into()),
|
||||
}
|
||||
};
|
||||
|
||||
@ -191,22 +198,23 @@ impl VulkanLibrary {
|
||||
let layer_properties = unsafe {
|
||||
loop {
|
||||
let mut count = 0;
|
||||
check_errors((fns.v1_0.enumerate_instance_layer_properties)(
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
))?;
|
||||
(fns.v1_0.enumerate_instance_layer_properties)(&mut count, ptr::null_mut())
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
let mut properties = Vec::with_capacity(count as usize);
|
||||
let result = check_errors({
|
||||
(fns.v1_0.enumerate_instance_layer_properties)(
|
||||
&mut count,
|
||||
properties.as_mut_ptr(),
|
||||
)
|
||||
})?;
|
||||
let result = (fns.v1_0.enumerate_instance_layer_properties)(
|
||||
&mut count,
|
||||
properties.as_mut_ptr(),
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
properties.set_len(count as usize);
|
||||
break properties;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
properties.set_len(count as usize);
|
||||
break properties;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => return Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -347,9 +355,9 @@ pub enum LoadingError {
|
||||
OomError(OomError),
|
||||
}
|
||||
|
||||
impl error::Error for LoadingError {
|
||||
impl Error for LoadingError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
//Self::LibraryLoadFailure(ref err) => Some(err),
|
||||
Self::OomError(ref err) => Some(err),
|
||||
@ -372,12 +380,12 @@ impl fmt::Display for LoadingError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for LoadingError {
|
||||
impl From<VulkanError> for LoadingError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
|
||||
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ VulkanError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -9,13 +9,12 @@
|
||||
|
||||
use super::DedicatedAllocation;
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{physical::MemoryType, Device, DeviceOwned},
|
||||
DeviceSize, Error, OomError, Version, VulkanObject,
|
||||
DeviceSize, OomError, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use std::{
|
||||
error,
|
||||
error::Error,
|
||||
ffi::c_void,
|
||||
fmt,
|
||||
fs::File,
|
||||
@ -387,12 +386,14 @@ impl DeviceMemory {
|
||||
let handle = {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.allocate_memory)(
|
||||
(fns.v1_0.allocate_memory)(
|
||||
device.internal_object(),
|
||||
&allocate_info.build(),
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -459,11 +460,13 @@ impl DeviceMemory {
|
||||
};
|
||||
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.khr_external_memory_fd.get_memory_fd_khr)(
|
||||
(fns.khr_external_memory_fd.get_memory_fd_khr)(
|
||||
self.device.internal_object(),
|
||||
&info,
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -573,9 +576,9 @@ pub enum DeviceMemoryAllocationError {
|
||||
ImplicitSpecViolation(&'static str),
|
||||
}
|
||||
|
||||
impl error::Error for DeviceMemoryAllocationError {
|
||||
impl Error for DeviceMemoryAllocationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
Self::MemoryMapError(ref err) => Some(err),
|
||||
@ -632,12 +635,14 @@ impl fmt::Display for DeviceMemoryAllocationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for DeviceMemoryAllocationError {
|
||||
impl From<VulkanError> for DeviceMemoryAllocationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
e @ Error::OutOfHostMemory | e @ Error::OutOfDeviceMemory => Self::OomError(e.into()),
|
||||
Error::TooManyObjects => Self::TooManyObjects,
|
||||
e @ VulkanError::OutOfHostMemory | e @ VulkanError::OutOfDeviceMemory => {
|
||||
Self::OomError(e.into())
|
||||
}
|
||||
VulkanError::TooManyObjects => Self::TooManyObjects,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
@ -1004,9 +1009,9 @@ pub enum DeviceMemoryExportError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for DeviceMemoryExportError {
|
||||
impl Error for DeviceMemoryExportError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -1033,12 +1038,14 @@ impl fmt::Display for DeviceMemoryExportError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for DeviceMemoryExportError {
|
||||
impl From<VulkanError> for DeviceMemoryExportError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
e @ Error::OutOfHostMemory | e @ Error::OutOfDeviceMemory => Self::OomError(e.into()),
|
||||
Error::TooManyObjects => Self::TooManyObjects,
|
||||
e @ VulkanError::OutOfHostMemory | e @ VulkanError::OutOfDeviceMemory => {
|
||||
Self::OomError(e.into())
|
||||
}
|
||||
VulkanError::TooManyObjects => Self::TooManyObjects,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
@ -1154,14 +1161,16 @@ impl MappedDeviceMemory {
|
||||
let pointer = unsafe {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.map_memory)(
|
||||
(fns.v1_0.map_memory)(
|
||||
device.internal_object(),
|
||||
memory.handle,
|
||||
range.start,
|
||||
range.end - range.start,
|
||||
ash::vk::MemoryMapFlags::empty(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -1224,11 +1233,13 @@ impl MappedDeviceMemory {
|
||||
};
|
||||
|
||||
let fns = self.memory.device().fns();
|
||||
check_errors((fns.v1_0.invalidate_mapped_memory_ranges)(
|
||||
(fns.v1_0.invalidate_mapped_memory_ranges)(
|
||||
self.memory.device().internal_object(),
|
||||
1,
|
||||
&range,
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -1271,11 +1282,9 @@ impl MappedDeviceMemory {
|
||||
};
|
||||
|
||||
let fns = self.device().fns();
|
||||
check_errors((fns.v1_0.flush_mapped_memory_ranges)(
|
||||
self.memory.device().internal_object(),
|
||||
1,
|
||||
&range,
|
||||
))?;
|
||||
(fns.v1_0.flush_mapped_memory_ranges)(self.memory.device().internal_object(), 1, &range)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -1418,9 +1427,9 @@ pub enum MemoryMapError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for MemoryMapError {
|
||||
impl Error for MemoryMapError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -1452,12 +1461,14 @@ impl fmt::Display for MemoryMapError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for MemoryMapError {
|
||||
impl From<VulkanError> for MemoryMapError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
e @ Error::OutOfHostMemory | e @ Error::OutOfDeviceMemory => Self::OomError(e.into()),
|
||||
Error::MemoryMapFailed => Self::MemoryMapFailed,
|
||||
e @ VulkanError::OutOfHostMemory | e @ VulkanError::OutOfDeviceMemory => {
|
||||
Self::OomError(e.into())
|
||||
}
|
||||
VulkanError::MemoryMapFailed => Self::MemoryMapFailed,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
//! of [`get_data`](crate::pipeline::cache::PipelineCache::get_data) for example of how to store the data
|
||||
//! on the disk, and [`with_data`](crate::pipeline::cache::PipelineCache::with_data) for how to reload it.
|
||||
|
||||
use crate::{check_errors, device::Device, OomError, Success, VulkanObject};
|
||||
use crate::{device::Device, OomError, VulkanError, VulkanObject};
|
||||
use std::{mem::MaybeUninit, ptr, sync::Arc};
|
||||
|
||||
/// Opaque cache that contains pipeline objects.
|
||||
@ -114,12 +114,14 @@ impl PipelineCache {
|
||||
};
|
||||
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_pipeline_cache)(
|
||||
(fns.v1_0.create_pipeline_cache)(
|
||||
device.internal_object(),
|
||||
&infos,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -154,12 +156,14 @@ impl PipelineCache {
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
check_errors((fns.v1_0.merge_pipeline_caches)(
|
||||
(fns.v1_0.merge_pipeline_caches)(
|
||||
self.device.internal_object(),
|
||||
self.cache,
|
||||
pipelines.len() as u32,
|
||||
pipelines.as_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -199,24 +203,30 @@ impl PipelineCache {
|
||||
let data = unsafe {
|
||||
loop {
|
||||
let mut count = 0;
|
||||
check_errors((fns.v1_0.get_pipeline_cache_data)(
|
||||
(fns.v1_0.get_pipeline_cache_data)(
|
||||
self.device.internal_object(),
|
||||
self.cache,
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
let mut data: Vec<u8> = Vec::with_capacity(count as usize);
|
||||
let result = check_errors((fns.v1_0.get_pipeline_cache_data)(
|
||||
let result = (fns.v1_0.get_pipeline_cache_data)(
|
||||
self.device.internal_object(),
|
||||
self.cache,
|
||||
&mut count,
|
||||
data.as_mut_ptr() as *mut _,
|
||||
))?;
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
data.set_len(count as usize);
|
||||
break data;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
data.set_len(count as usize);
|
||||
break data;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => return Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
use super::layout::PipelineLayoutCreateInfo;
|
||||
use crate::{
|
||||
check_errors,
|
||||
descriptor_set::layout::{
|
||||
DescriptorSetLayout, DescriptorSetLayoutCreateInfo, DescriptorSetLayoutCreationError,
|
||||
},
|
||||
@ -35,9 +34,9 @@ use crate::{
|
||||
Pipeline, PipelineBindPoint,
|
||||
},
|
||||
shader::{DescriptorRequirements, EntryPoint, SpecializationConstants},
|
||||
DeviceSize, Error, OomError, VulkanObject,
|
||||
DeviceSize, OomError, VulkanError, VulkanObject,
|
||||
};
|
||||
use std::{collections::HashMap, error, fmt, mem, mem::MaybeUninit, ptr, sync::Arc};
|
||||
use std::{collections::HashMap, error::Error, fmt, mem, mem::MaybeUninit, ptr, sync::Arc};
|
||||
|
||||
/// A pipeline object that describes to the Vulkan implementation how it should perform compute
|
||||
/// operations.
|
||||
@ -198,14 +197,16 @@ impl ComputePipeline {
|
||||
};
|
||||
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_compute_pipelines)(
|
||||
(fns.v1_0.create_compute_pipelines)(
|
||||
device.internal_object(),
|
||||
cache_handle,
|
||||
1,
|
||||
&infos,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -320,9 +321,9 @@ pub enum ComputePipelineCreationError {
|
||||
IncompatibleSpecializationConstants,
|
||||
}
|
||||
|
||||
impl error::Error for ComputePipelineCreationError {
|
||||
impl Error for ComputePipelineCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
Self::DescriptorSetLayoutCreationError(ref err) => Some(err),
|
||||
@ -386,12 +387,12 @@ impl From<PipelineLayoutSupersetError> for ComputePipelineCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for ComputePipelineCreationError {
|
||||
impl From<VulkanError> for ComputePipelineCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> ComputePipelineCreationError {
|
||||
fn from(err: VulkanError) -> ComputePipelineCreationError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
|
||||
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ VulkanError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ use super::{
|
||||
GraphicsPipeline, GraphicsPipelineCreationError,
|
||||
};
|
||||
use crate::{
|
||||
check_errors,
|
||||
descriptor_set::layout::{DescriptorSetLayout, DescriptorSetLayoutCreateInfo},
|
||||
device::{Device, DeviceOwned},
|
||||
format::NumericType,
|
||||
@ -47,7 +46,7 @@ use crate::{
|
||||
DescriptorRequirements, EntryPoint, ShaderExecution, ShaderStage, SpecializationConstants,
|
||||
SpecializationMapEntry,
|
||||
},
|
||||
DeviceSize, Version, VulkanObject,
|
||||
DeviceSize, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
@ -3195,14 +3194,16 @@ where
|
||||
let handle = {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_graphics_pipelines)(
|
||||
(fns.v1_0.create_graphics_pipelines)(
|
||||
device.internal_object(),
|
||||
cache_handle,
|
||||
1,
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
|
@ -13,9 +13,9 @@ use crate::{
|
||||
format::{Format, NumericType},
|
||||
pipeline::layout::{PipelineLayoutCreationError, PipelineLayoutSupersetError},
|
||||
shader::ShaderInterfaceMismatchError,
|
||||
Error, OomError,
|
||||
OomError, VulkanError,
|
||||
};
|
||||
use std::{error, fmt};
|
||||
use std::{error::Error, fmt};
|
||||
|
||||
/// Error that can happen when creating a graphics pipeline.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
@ -200,9 +200,9 @@ pub enum GraphicsPipelineCreationError {
|
||||
WrongStencilState,
|
||||
}
|
||||
|
||||
impl error::Error for GraphicsPipelineCreationError {
|
||||
impl Error for GraphicsPipelineCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
Self::PipelineLayoutCreationError(ref err) => Some(err),
|
||||
@ -424,12 +424,12 @@ impl From<IncompatibleVertexDefinitionError> for GraphicsPipelineCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for GraphicsPipelineCreationError {
|
||||
impl From<VulkanError> for GraphicsPipelineCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
|
||||
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ VulkanError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ use crate::{
|
||||
pipeline::graphics::vertex_input::{VertexInputState, VertexMemberTy},
|
||||
shader::ShaderInterface,
|
||||
};
|
||||
use std::{error, fmt};
|
||||
use std::{error::Error, fmt};
|
||||
|
||||
/// Trait for types that can create a [`VertexInputState`] from a [`ShaderInterface`].
|
||||
pub unsafe trait VertexDefinition {
|
||||
@ -97,7 +97,7 @@ pub enum IncompatibleVertexDefinitionError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for IncompatibleVertexDefinitionError {}
|
||||
impl Error for IncompatibleVertexDefinitionError {}
|
||||
|
||||
impl fmt::Display for IncompatibleVertexDefinitionError {
|
||||
#[inline]
|
||||
|
@ -64,15 +64,15 @@
|
||||
//! type. Each pipeline that you create holds a pipeline layout object.
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
descriptor_set::layout::{DescriptorRequirementsNotMet, DescriptorSetLayout, DescriptorType},
|
||||
device::{Device, DeviceOwned},
|
||||
shader::{DescriptorRequirements, ShaderStages},
|
||||
Error, OomError, VulkanObject,
|
||||
OomError, VulkanError, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
ptr,
|
||||
@ -531,12 +531,14 @@ impl PipelineLayout {
|
||||
let handle = {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_pipeline_layout)(
|
||||
(fns.v1_0.create_pipeline_layout)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -805,9 +807,9 @@ pub enum PipelineLayoutCreationError {
|
||||
SetLayoutsPushDescriptorMultiple,
|
||||
}
|
||||
|
||||
impl error::Error for PipelineLayoutCreationError {
|
||||
impl Error for PipelineLayoutCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -924,14 +926,14 @@ impl From<OomError> for PipelineLayoutCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for PipelineLayoutCreationError {
|
||||
impl From<VulkanError> for PipelineLayoutCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> PipelineLayoutCreationError {
|
||||
fn from(err: VulkanError) -> PipelineLayoutCreationError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => {
|
||||
err @ VulkanError::OutOfHostMemory => {
|
||||
PipelineLayoutCreationError::OomError(OomError::from(err))
|
||||
}
|
||||
err @ Error::OutOfDeviceMemory => {
|
||||
err @ VulkanError::OutOfDeviceMemory => {
|
||||
PipelineLayoutCreationError::OomError(OomError::from(err))
|
||||
}
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
@ -957,9 +959,9 @@ pub enum PipelineLayoutSupersetError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for PipelineLayoutSupersetError {
|
||||
impl Error for PipelineLayoutSupersetError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
PipelineLayoutSupersetError::DescriptorRequirementsNotMet { ref error, .. } => {
|
||||
Some(error)
|
||||
|
@ -14,12 +14,11 @@
|
||||
//! pool and the slot id within that query pool.
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
DeviceSize, Error, OomError, Success, VulkanObject,
|
||||
DeviceSize, OomError, VulkanError, VulkanObject,
|
||||
};
|
||||
use std::{
|
||||
error,
|
||||
error::Error,
|
||||
ffi::c_void,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
@ -84,12 +83,14 @@ impl QueryPool {
|
||||
let handle = unsafe {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_query_pool)(
|
||||
(fns.v1_0.create_query_pool)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -243,9 +244,9 @@ pub enum QueryPoolCreationError {
|
||||
PipelineStatisticsQueryFeatureNotEnabled,
|
||||
}
|
||||
|
||||
impl error::Error for QueryPoolCreationError {
|
||||
impl Error for QueryPoolCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
QueryPoolCreationError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -277,12 +278,16 @@ impl From<OomError> for QueryPoolCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for QueryPoolCreationError {
|
||||
impl From<VulkanError> for QueryPoolCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> QueryPoolCreationError {
|
||||
fn from(err: VulkanError) -> QueryPoolCreationError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => QueryPoolCreationError::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => QueryPoolCreationError::OomError(OomError::from(err)),
|
||||
err @ VulkanError::OutOfHostMemory => {
|
||||
QueryPoolCreationError::OomError(OomError::from(err))
|
||||
}
|
||||
err @ VulkanError::OutOfDeviceMemory => {
|
||||
QueryPoolCreationError::OomError(OomError::from(err))
|
||||
}
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
@ -360,7 +365,7 @@ impl<'a> QueriesRange<'a> {
|
||||
|
||||
let result = unsafe {
|
||||
let fns = self.pool.device.fns();
|
||||
check_errors((fns.v1_0.get_query_pool_results)(
|
||||
(fns.v1_0.get_query_pool_results)(
|
||||
self.pool.device.internal_object(),
|
||||
self.pool.internal_object(),
|
||||
self.range.start,
|
||||
@ -369,14 +374,14 @@ impl<'a> QueriesRange<'a> {
|
||||
destination.as_mut_ptr() as *mut c_void,
|
||||
stride,
|
||||
ash::vk::QueryResultFlags::from(flags) | T::FLAG,
|
||||
))?
|
||||
)
|
||||
};
|
||||
|
||||
Ok(match result {
|
||||
Success::Success => true,
|
||||
Success::NotReady => false,
|
||||
s => panic!("unexpected success value: {:?}", s),
|
||||
})
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => Ok(true),
|
||||
ash::vk::Result::NOT_READY => Ok(false),
|
||||
err => Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn check_query_pool_results<T>(
|
||||
@ -440,14 +445,14 @@ pub enum GetResultsError {
|
||||
OomError(OomError),
|
||||
}
|
||||
|
||||
impl From<Error> for GetResultsError {
|
||||
impl From<VulkanError> for GetResultsError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
Error::OutOfHostMemory | Error::OutOfDeviceMemory => {
|
||||
VulkanError::OutOfHostMemory | VulkanError::OutOfDeviceMemory => {
|
||||
Self::OomError(OomError::from(err))
|
||||
}
|
||||
Error::DeviceLost => Self::DeviceLost,
|
||||
VulkanError::DeviceLost => Self::DeviceLost,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
@ -480,9 +485,9 @@ impl fmt::Display for GetResultsError {
|
||||
}
|
||||
}
|
||||
|
||||
impl error::Error for GetResultsError {
|
||||
impl Error for GetResultsError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
|
@ -12,14 +12,13 @@ use super::{
|
||||
SubpassDependency, SubpassDescription,
|
||||
};
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::Device,
|
||||
image::{ImageAspects, ImageLayout, SampleCount},
|
||||
sync::PipelineStages,
|
||||
Error, OomError, Version, VulkanObject,
|
||||
OomError, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{error, fmt, mem::MaybeUninit, ptr};
|
||||
use std::{error::Error, fmt, mem::MaybeUninit, ptr};
|
||||
|
||||
impl RenderPass {
|
||||
pub(super) fn validate(
|
||||
@ -1051,7 +1050,7 @@ impl RenderPass {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
|
||||
check_errors(if device.api_version() >= Version::V1_2 {
|
||||
if device.api_version() >= Version::V1_2 {
|
||||
(fns.v1_2.create_render_pass2)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
@ -1065,7 +1064,9 @@ impl RenderPass {
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
)
|
||||
})?;
|
||||
}
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
output.assume_init()
|
||||
})
|
||||
@ -1318,12 +1319,14 @@ impl RenderPass {
|
||||
Ok({
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_render_pass)(
|
||||
(fns.v1_0.create_render_pass)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
})
|
||||
}
|
||||
@ -1499,9 +1502,9 @@ pub enum RenderPassCreationError {
|
||||
SubpassResolveAttachmentWithoutColorAttachment { subpass: u32 },
|
||||
}
|
||||
|
||||
impl error::Error for RenderPassCreationError {
|
||||
impl Error for RenderPassCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
RenderPassCreationError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -1707,12 +1710,14 @@ impl From<OomError> for RenderPassCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for RenderPassCreationError {
|
||||
impl From<VulkanError> for RenderPassCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> RenderPassCreationError {
|
||||
fn from(err: VulkanError) -> RenderPassCreationError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => RenderPassCreationError::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => {
|
||||
err @ VulkanError::OutOfHostMemory => {
|
||||
RenderPassCreationError::OomError(OomError::from(err))
|
||||
}
|
||||
err @ VulkanError::OutOfDeviceMemory => {
|
||||
RenderPassCreationError::OomError(OomError::from(err))
|
||||
}
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
|
@ -9,15 +9,15 @@
|
||||
|
||||
use super::RenderPass;
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
format::Format,
|
||||
image::{view::ImageViewType, ImageDimensions, ImageViewAbstract, SampleCount},
|
||||
Error, OomError, VulkanObject,
|
||||
OomError, VulkanError, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
ops::Range,
|
||||
@ -309,12 +309,14 @@ impl Framebuffer {
|
||||
let handle = unsafe {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_framebuffer)(
|
||||
(fns.v1_0.create_framebuffer)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -590,9 +592,9 @@ impl From<OomError> for FramebufferCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl error::Error for FramebufferCreationError {
|
||||
impl Error for FramebufferCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -715,9 +717,9 @@ impl fmt::Display for FramebufferCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for FramebufferCreationError {
|
||||
impl From<VulkanError> for FramebufferCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
Self::from(OomError::from(err))
|
||||
}
|
||||
}
|
||||
|
@ -48,15 +48,15 @@ pub mod ycbcr;
|
||||
|
||||
use self::ycbcr::SamplerYcbcrConversion;
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
image::{view::ImageViewType, ImageViewAbstract},
|
||||
pipeline::graphics::depth_stencil::CompareOp,
|
||||
shader::ShaderScalarType,
|
||||
Error, OomError, VulkanObject,
|
||||
OomError, VulkanError, VulkanObject,
|
||||
};
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
ops::RangeInclusive,
|
||||
@ -393,12 +393,14 @@ impl Sampler {
|
||||
let handle = unsafe {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_sampler)(
|
||||
(fns.v1_0.create_sampler)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -840,9 +842,9 @@ pub enum SamplerCreationError {
|
||||
UnnormalizedCoordinatesNonzeroLod { lod: RangeInclusive<f32> },
|
||||
}
|
||||
|
||||
impl error::Error for SamplerCreationError {
|
||||
impl Error for SamplerCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
SamplerCreationError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -916,13 +918,13 @@ impl From<OomError> for SamplerCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for SamplerCreationError {
|
||||
impl From<VulkanError> for SamplerCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
|
||||
Error::TooManyObjects => Self::TooManyObjects,
|
||||
err @ VulkanError::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ VulkanError::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
|
||||
VulkanError::TooManyObjects => Self::TooManyObjects,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
@ -1458,7 +1460,7 @@ pub enum SamplerImageViewIncompatibleError {
|
||||
UnnormalizedCoordinatesViewTypeNotCompatible,
|
||||
}
|
||||
|
||||
impl error::Error for SamplerImageViewIncompatibleError {}
|
||||
impl Error for SamplerImageViewIncompatibleError {}
|
||||
|
||||
impl fmt::Display for SamplerImageViewIncompatibleError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
|
@ -85,14 +85,14 @@
|
||||
//! ```
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
format::{ChromaSampling, Format, NumericType},
|
||||
sampler::{ComponentMapping, ComponentSwizzle, Filter},
|
||||
Error, OomError, Version, VulkanObject,
|
||||
OomError, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
ptr,
|
||||
@ -294,12 +294,14 @@ impl SamplerYcbcrConversion {
|
||||
};
|
||||
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors(create_sampler_ycbcr_conversion(
|
||||
create_sampler_ycbcr_conversion(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -515,9 +517,9 @@ pub enum SamplerYcbcrConversionCreationError {
|
||||
YcbcrRangeFormatNotEnoughBits,
|
||||
}
|
||||
|
||||
impl error::Error for SamplerYcbcrConversionCreationError {
|
||||
impl Error for SamplerYcbcrConversionCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
SamplerYcbcrConversionCreationError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -583,14 +585,14 @@ impl From<OomError> for SamplerYcbcrConversionCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for SamplerYcbcrConversionCreationError {
|
||||
impl From<VulkanError> for SamplerYcbcrConversionCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> SamplerYcbcrConversionCreationError {
|
||||
fn from(err: VulkanError) -> SamplerYcbcrConversionCreationError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => {
|
||||
err @ VulkanError::OutOfHostMemory => {
|
||||
SamplerYcbcrConversionCreationError::OomError(OomError::from(err))
|
||||
}
|
||||
err @ Error::OutOfDeviceMemory => {
|
||||
err @ VulkanError::OutOfDeviceMemory => {
|
||||
SamplerYcbcrConversionCreationError::OomError(OomError::from(err))
|
||||
}
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
|
@ -18,7 +18,6 @@
|
||||
//! wraps around vulkano's shaders API.
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
descriptor_set::layout::DescriptorType,
|
||||
device::Device,
|
||||
format::{Format, NumericType},
|
||||
@ -26,12 +25,11 @@ use crate::{
|
||||
pipeline::{graphics::input_assembly::PrimitiveTopology, layout::PushConstantRange},
|
||||
shader::spirv::{Capability, Spirv, SpirvError},
|
||||
sync::PipelineStages,
|
||||
DeviceSize, OomError, Version, VulkanObject,
|
||||
DeviceSize, OomError, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::{HashMap, HashSet},
|
||||
error,
|
||||
error::Error,
|
||||
ffi::{CStr, CString},
|
||||
fmt,
|
||||
@ -152,12 +150,14 @@ impl ShaderModule {
|
||||
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_shader_module)(
|
||||
(fns.v1_0.create_shader_module)(
|
||||
device.internal_object(),
|
||||
&infos,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -296,7 +296,7 @@ pub enum ShaderCreationError {
|
||||
|
||||
impl Error for ShaderCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
Self::OomError(err) => Some(err),
|
||||
Self::SpirvCapabilityNotSupported { reason, .. } => Some(reason),
|
||||
@ -331,8 +331,8 @@ impl Display for ShaderCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::Error> for ShaderCreationError {
|
||||
fn from(err: crate::Error) -> Self {
|
||||
impl From<VulkanError> for ShaderCreationError {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
Self::OomError(err.into())
|
||||
}
|
||||
}
|
||||
@ -1018,7 +1018,7 @@ pub enum ShaderInterfaceMismatchError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for ShaderInterfaceMismatchError {}
|
||||
impl Error for ShaderInterfaceMismatchError {}
|
||||
|
||||
impl fmt::Display for ShaderInterfaceMismatchError {
|
||||
#[inline]
|
||||
|
@ -29,8 +29,8 @@
|
||||
#![allow(unused_variables)] // TODO: this module isn't finished
|
||||
|
||||
use crate::{
|
||||
check_errors, device::physical::PhysicalDevice, instance::Instance,
|
||||
swapchain::SupportedSurfaceTransforms, OomError, Success, VulkanObject,
|
||||
device::physical::PhysicalDevice, instance::Instance, swapchain::SupportedSurfaceTransforms,
|
||||
OomError, VulkanError, VulkanObject,
|
||||
};
|
||||
use std::{ffi::CStr, fmt, fmt::Formatter, ptr, sync::Arc, vec::IntoIter};
|
||||
|
||||
@ -57,26 +57,31 @@ impl DisplayPlane {
|
||||
let display_plane_properties = unsafe {
|
||||
loop {
|
||||
let mut count = 0;
|
||||
check_errors((fns
|
||||
.khr_display
|
||||
(fns.khr_display
|
||||
.get_physical_device_display_plane_properties_khr)(
|
||||
device.internal_object(),
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
let mut properties = Vec::with_capacity(count as usize);
|
||||
let result = check_errors((fns
|
||||
let result = (fns
|
||||
.khr_display
|
||||
.get_physical_device_display_plane_properties_khr)(
|
||||
device.internal_object(),
|
||||
&mut count,
|
||||
properties.as_mut_ptr(),
|
||||
))?;
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
properties.set_len(count as usize);
|
||||
break properties;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
properties.set_len(count as usize);
|
||||
break properties;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => return Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -88,28 +93,31 @@ impl DisplayPlane {
|
||||
let supported_displays = unsafe {
|
||||
loop {
|
||||
let mut count = 0;
|
||||
check_errors((fns.khr_display.get_display_plane_supported_displays_khr)(
|
||||
(fns.khr_display.get_display_plane_supported_displays_khr)(
|
||||
device.internal_object(),
|
||||
index as u32,
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
))
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)
|
||||
.unwrap(); // TODO: shouldn't unwrap
|
||||
|
||||
let mut displays = Vec::with_capacity(count as usize);
|
||||
let result = check_errors((fns
|
||||
.khr_display
|
||||
.get_display_plane_supported_displays_khr)(
|
||||
let result = (fns.khr_display.get_display_plane_supported_displays_khr)(
|
||||
device.internal_object(),
|
||||
index as u32,
|
||||
&mut count,
|
||||
displays.as_mut_ptr(),
|
||||
))
|
||||
.unwrap(); // TODO: shouldn't unwrap
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
displays.set_len(count as usize);
|
||||
break displays;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
displays.set_len(count as usize);
|
||||
break displays;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => todo!(), // TODO: shouldn't panic
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -183,26 +191,28 @@ impl Display {
|
||||
let display_properties = unsafe {
|
||||
loop {
|
||||
let mut count = 0;
|
||||
check_errors(
|
||||
(fns.khr_display.get_physical_device_display_properties_khr)(
|
||||
device.internal_object(),
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
),
|
||||
)?;
|
||||
(fns.khr_display.get_physical_device_display_properties_khr)(
|
||||
device.internal_object(),
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
let mut properties = Vec::with_capacity(count as usize);
|
||||
let result = check_errors((fns
|
||||
.khr_display
|
||||
.get_physical_device_display_properties_khr)(
|
||||
let result = (fns.khr_display.get_physical_device_display_properties_khr)(
|
||||
device.internal_object(),
|
||||
&mut count,
|
||||
properties.as_mut_ptr(),
|
||||
))?;
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
properties.set_len(count as usize);
|
||||
break properties;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
properties.set_len(count as usize);
|
||||
break properties;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => return Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -288,24 +298,30 @@ impl Display {
|
||||
let mode_properties = unsafe {
|
||||
loop {
|
||||
let mut count = 0;
|
||||
check_errors((fns.khr_display.get_display_mode_properties_khr)(
|
||||
(fns.khr_display.get_display_mode_properties_khr)(
|
||||
self.physical_device().internal_object(),
|
||||
self.properties.display,
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
let mut properties = Vec::with_capacity(count as usize);
|
||||
let result = check_errors((fns.khr_display.get_display_mode_properties_khr)(
|
||||
let result = (fns.khr_display.get_display_mode_properties_khr)(
|
||||
self.physical_device().internal_object(),
|
||||
self.properties.display,
|
||||
&mut count,
|
||||
properties.as_mut_ptr(),
|
||||
))?;
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
properties.set_len(count as usize);
|
||||
break properties;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
properties.set_len(count as usize);
|
||||
break properties;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => return Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -370,9 +386,9 @@ impl DisplayMode {
|
||||
};
|
||||
|
||||
let mut output = mem::uninitialized();
|
||||
check_errors((fns.v1_0.CreateDisplayModeKHR)(display.device.internal_object(),
|
||||
(fns.v1_0.CreateDisplayModeKHR)(display.device.internal_object(),
|
||||
display.display, &infos, ptr::null(),
|
||||
&mut output))?;
|
||||
&mut output).result().map_err(VulkanError::from)?;
|
||||
output
|
||||
};
|
||||
|
||||
|
@ -142,11 +142,11 @@
|
||||
//! and choose which values you are going to use.
|
||||
//!
|
||||
//! ```no_run
|
||||
//! # use std::sync::Arc;
|
||||
//! # use std::{error::Error, sync::Arc};
|
||||
//! # use vulkano::device::Device;
|
||||
//! # use vulkano::swapchain::Surface;
|
||||
//! # use std::cmp::{max, min};
|
||||
//! # fn choose_caps(device: Arc<Device>, surface: Arc<Surface<()>>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
//! # fn choose_caps(device: Arc<Device>, surface: Arc<Surface<()>>) -> Result<(), Box<dyn Error>> {
|
||||
//! let surface_capabilities = device
|
||||
//! .physical_device()
|
||||
//! .surface_capabilities(&surface, Default::default())?;
|
||||
@ -174,7 +174,7 @@
|
||||
//! Then, call [`Swapchain::new`](crate::swapchain::Swapchain::new).
|
||||
//!
|
||||
//! ```no_run
|
||||
//! # use std::sync::Arc;
|
||||
//! # use std::{error::Error, sync::Arc};
|
||||
//! # use vulkano::device::{Device, Queue};
|
||||
//! # use vulkano::image::ImageUsage;
|
||||
//! # use vulkano::sync::SharingMode;
|
||||
@ -185,7 +185,7 @@
|
||||
//! # min_image_count: u32, image_format: Format, image_extent: [u32; 2],
|
||||
//! # pre_transform: SurfaceTransform, composite_alpha: CompositeAlpha,
|
||||
//! # present_mode: PresentMode, full_screen_exclusive: FullScreenExclusive
|
||||
//! # ) -> Result<(), Box<dyn std::error::Error>> {
|
||||
//! # ) -> Result<(), Box<dyn Error>> {
|
||||
//! // The created swapchain will be used as a color attachment for rendering.
|
||||
//! let image_usage = ImageUsage {
|
||||
//! color_attachment: true,
|
||||
|
@ -9,21 +9,21 @@
|
||||
|
||||
use super::{FullScreenExclusive, Win32Monitor};
|
||||
use crate::{
|
||||
check_errors,
|
||||
image::ImageUsage,
|
||||
instance::Instance,
|
||||
swapchain::{
|
||||
display::{DisplayMode, DisplayPlane},
|
||||
SurfaceSwapchainLock,
|
||||
},
|
||||
Error, OomError, VulkanObject,
|
||||
OomError, VulkanError, VulkanObject,
|
||||
};
|
||||
|
||||
#[cfg(target_os = "ios")]
|
||||
use objc::{class, msg_send, runtime::Object, sel, sel_impl};
|
||||
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
os::raw::c_ulong,
|
||||
@ -122,12 +122,14 @@ impl<W> Surface<W> {
|
||||
let handle = unsafe {
|
||||
let fns = instance.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.khr_display.create_display_plane_surface_khr)(
|
||||
(fns.khr_display.create_display_plane_surface_khr)(
|
||||
instance.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -170,12 +172,14 @@ impl<W> Surface<W> {
|
||||
let handle = {
|
||||
let fns = instance.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.khr_android_surface.create_android_surface_khr)(
|
||||
(fns.khr_android_surface.create_android_surface_khr)(
|
||||
instance.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -220,12 +224,14 @@ impl<W> Surface<W> {
|
||||
let handle = {
|
||||
let fns = instance.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.mvk_ios_surface.create_ios_surface_mvk)(
|
||||
(fns.mvk_ios_surface.create_ios_surface_mvk)(
|
||||
instance.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -269,12 +275,14 @@ impl<W> Surface<W> {
|
||||
let handle = {
|
||||
let fns = instance.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.mvk_macos_surface.create_mac_os_surface_mvk)(
|
||||
(fns.mvk_macos_surface.create_mac_os_surface_mvk)(
|
||||
instance.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -317,12 +325,14 @@ impl<W> Surface<W> {
|
||||
let handle = {
|
||||
let fns = instance.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.ext_metal_surface.create_metal_surface_ext)(
|
||||
(fns.ext_metal_surface.create_metal_surface_ext)(
|
||||
instance.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -365,12 +375,14 @@ impl<W> Surface<W> {
|
||||
let handle = {
|
||||
let fns = instance.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.nn_vi_surface.create_vi_surface_nn)(
|
||||
(fns.nn_vi_surface.create_vi_surface_nn)(
|
||||
instance.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -417,12 +429,14 @@ impl<W> Surface<W> {
|
||||
let handle = {
|
||||
let fns = instance.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.khr_wayland_surface.create_wayland_surface_khr)(
|
||||
(fns.khr_wayland_surface.create_wayland_surface_khr)(
|
||||
instance.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -469,12 +483,14 @@ impl<W> Surface<W> {
|
||||
let handle = {
|
||||
let fns = instance.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.khr_win32_surface.create_win32_surface_khr)(
|
||||
(fns.khr_win32_surface.create_win32_surface_khr)(
|
||||
instance.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -521,12 +537,14 @@ impl<W> Surface<W> {
|
||||
let handle = {
|
||||
let fns = instance.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.khr_xcb_surface.create_xcb_surface_khr)(
|
||||
(fns.khr_xcb_surface.create_xcb_surface_khr)(
|
||||
instance.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -573,12 +591,14 @@ impl<W> Surface<W> {
|
||||
let handle = {
|
||||
let fns = instance.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.khr_xlib_surface.create_xlib_surface_khr)(
|
||||
(fns.khr_xlib_surface.create_xlib_surface_khr)(
|
||||
instance.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -713,9 +733,9 @@ pub enum SurfaceCreationError {
|
||||
},
|
||||
}
|
||||
|
||||
impl error::Error for SurfaceCreationError {
|
||||
impl Error for SurfaceCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
SurfaceCreationError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -746,12 +766,16 @@ impl From<OomError> for SurfaceCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for SurfaceCreationError {
|
||||
impl From<VulkanError> for SurfaceCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> SurfaceCreationError {
|
||||
fn from(err: VulkanError) -> SurfaceCreationError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => SurfaceCreationError::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => SurfaceCreationError::OomError(OomError::from(err)),
|
||||
err @ VulkanError::OutOfHostMemory => {
|
||||
SurfaceCreationError::OomError(OomError::from(err))
|
||||
}
|
||||
err @ VulkanError::OutOfDeviceMemory => {
|
||||
SurfaceCreationError::OomError(OomError::from(err))
|
||||
}
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ use super::{
|
||||
};
|
||||
use crate::{
|
||||
buffer::sys::UnsafeBuffer,
|
||||
check_errors,
|
||||
command_buffer::submit::{
|
||||
SubmitAnyBuilder, SubmitPresentBuilder, SubmitPresentError, SubmitSemaphoresWaitBuilder,
|
||||
},
|
||||
@ -28,12 +27,13 @@ use crate::{
|
||||
AccessCheckError, AccessError, AccessFlags, Fence, FlushError, GpuFuture, PipelineStages,
|
||||
Semaphore, SemaphoreCreationError, Sharing,
|
||||
},
|
||||
DeviceSize, Error, OomError, Success, VulkanObject,
|
||||
DeviceSize, OomError, VulkanError, VulkanObject,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
ops::Range,
|
||||
@ -581,35 +581,43 @@ impl<W> Swapchain<W> {
|
||||
|
||||
let handle = {
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.khr_swapchain.create_swapchain_khr)(
|
||||
(fns.khr_swapchain.create_swapchain_khr)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
let image_handles = loop {
|
||||
let mut count = 0;
|
||||
check_errors((fns.khr_swapchain.get_swapchain_images_khr)(
|
||||
(fns.khr_swapchain.get_swapchain_images_khr)(
|
||||
device.internal_object(),
|
||||
handle,
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
|
||||
let mut images = Vec::with_capacity(count as usize);
|
||||
let result = check_errors((fns.khr_swapchain.get_swapchain_images_khr)(
|
||||
let result = (fns.khr_swapchain.get_swapchain_images_khr)(
|
||||
device.internal_object(),
|
||||
handle,
|
||||
&mut count,
|
||||
images.as_mut_ptr(),
|
||||
))?;
|
||||
);
|
||||
|
||||
if !matches!(result, Success::Incomplete) {
|
||||
images.set_len(count as usize);
|
||||
break images;
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
images.set_len(count as usize);
|
||||
break images;
|
||||
}
|
||||
ash::vk::Result::INCOMPLETE => (),
|
||||
err => return Err(VulkanError::from(err).into()),
|
||||
}
|
||||
};
|
||||
|
||||
@ -776,12 +784,13 @@ impl<W> Swapchain<W> {
|
||||
|
||||
unsafe {
|
||||
let fns = self.device.fns();
|
||||
check_errors((fns
|
||||
.ext_full_screen_exclusive
|
||||
(fns.ext_full_screen_exclusive
|
||||
.acquire_full_screen_exclusive_mode_ext)(
|
||||
self.device.internal_object(),
|
||||
self.handle,
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -805,12 +814,13 @@ impl<W> Swapchain<W> {
|
||||
|
||||
unsafe {
|
||||
let fns = self.device.fns();
|
||||
check_errors((fns
|
||||
.ext_full_screen_exclusive
|
||||
(fns.ext_full_screen_exclusive
|
||||
.release_full_screen_exclusive_mode_ext)(
|
||||
self.device.internal_object(),
|
||||
self.handle,
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -1103,9 +1113,9 @@ pub enum SwapchainCreationError {
|
||||
Win32MonitorInvalid,
|
||||
}
|
||||
|
||||
impl error::Error for SwapchainCreationError {
|
||||
impl Error for SwapchainCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -1193,15 +1203,15 @@ impl fmt::Display for SwapchainCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for SwapchainCreationError {
|
||||
impl From<VulkanError> for SwapchainCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> SwapchainCreationError {
|
||||
fn from(err: VulkanError) -> SwapchainCreationError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => Self::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => Self::OomError(OomError::from(err)),
|
||||
Error::DeviceLost => Self::DeviceLost,
|
||||
Error::SurfaceLost => Self::SurfaceLost,
|
||||
Error::NativeWindowInUse => Self::NativeWindowInUse,
|
||||
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,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
@ -1300,9 +1310,9 @@ pub enum FullScreenExclusiveError {
|
||||
NotApplicationControlled,
|
||||
}
|
||||
|
||||
impl error::Error for FullScreenExclusiveError {
|
||||
impl Error for FullScreenExclusiveError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
FullScreenExclusiveError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -1336,16 +1346,18 @@ impl fmt::Display for FullScreenExclusiveError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for FullScreenExclusiveError {
|
||||
impl From<VulkanError> for FullScreenExclusiveError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> FullScreenExclusiveError {
|
||||
fn from(err: VulkanError) -> FullScreenExclusiveError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => FullScreenExclusiveError::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => {
|
||||
err @ VulkanError::OutOfHostMemory => {
|
||||
FullScreenExclusiveError::OomError(OomError::from(err))
|
||||
}
|
||||
Error::SurfaceLost => FullScreenExclusiveError::SurfaceLost,
|
||||
Error::InitializationFailed => FullScreenExclusiveError::InitializationFailed,
|
||||
err @ VulkanError::OutOfDeviceMemory => {
|
||||
FullScreenExclusiveError::OomError(OomError::from(err))
|
||||
}
|
||||
VulkanError::SurfaceLost => FullScreenExclusiveError::SurfaceLost,
|
||||
VulkanError::InitializationFailed => FullScreenExclusiveError::InitializationFailed,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
@ -1389,7 +1401,7 @@ pub fn acquire_next_image<W>(
|
||||
let acquire_result =
|
||||
unsafe { acquire_next_image_raw(&swapchain, timeout, Some(&semaphore), Some(&fence)) };
|
||||
|
||||
if let &Err(AcquireError::FullScreenExclusiveLost) = &acquire_result {
|
||||
if let &Err(AcquireError::FullScreenExclusiveModeLost) = &acquire_result {
|
||||
swapchain
|
||||
.full_screen_exclusive_held
|
||||
.store(false, Ordering::SeqCst);
|
||||
@ -1631,7 +1643,7 @@ pub enum AcquireError {
|
||||
|
||||
/// The swapchain has lost or doesn't have full-screen exclusivity possibly for
|
||||
/// implementation-specific reasons outside of the application’s control.
|
||||
FullScreenExclusiveLost,
|
||||
FullScreenExclusiveModeLost,
|
||||
|
||||
/// The surface has changed in a way that makes the swapchain unusable. You must query the
|
||||
/// surface's new properties and recreate a new swapchain if you want to continue drawing.
|
||||
@ -1641,9 +1653,9 @@ pub enum AcquireError {
|
||||
SemaphoreError(SemaphoreCreationError),
|
||||
}
|
||||
|
||||
impl error::Error for AcquireError {
|
||||
impl Error for AcquireError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
AcquireError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -1663,7 +1675,7 @@ impl fmt::Display for AcquireError {
|
||||
AcquireError::Timeout => "no image is available for acquiring yet",
|
||||
AcquireError::SurfaceLost => "the surface of this swapchain is no longer valid",
|
||||
AcquireError::OutOfDate => "the swapchain needs to be recreated",
|
||||
AcquireError::FullScreenExclusiveLost => {
|
||||
AcquireError::FullScreenExclusiveModeLost => {
|
||||
"the swapchain no longer has full-screen exclusivity"
|
||||
}
|
||||
AcquireError::SemaphoreError(_) => "error creating semaphore",
|
||||
@ -1685,16 +1697,16 @@ impl From<OomError> for AcquireError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for AcquireError {
|
||||
impl From<VulkanError> for AcquireError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> AcquireError {
|
||||
fn from(err: VulkanError) -> AcquireError {
|
||||
match err {
|
||||
err @ Error::OutOfHostMemory => AcquireError::OomError(OomError::from(err)),
|
||||
err @ Error::OutOfDeviceMemory => AcquireError::OomError(OomError::from(err)),
|
||||
Error::DeviceLost => AcquireError::DeviceLost,
|
||||
Error::SurfaceLost => AcquireError::SurfaceLost,
|
||||
Error::OutOfDate => AcquireError::OutOfDate,
|
||||
Error::FullScreenExclusiveLost => AcquireError::FullScreenExclusiveLost,
|
||||
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,
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
@ -1819,7 +1831,7 @@ where
|
||||
let build_submission_result = self.build_submission();
|
||||
self.flushed.store(true, Ordering::SeqCst);
|
||||
|
||||
if let &Err(FlushError::FullScreenExclusiveLost) = &build_submission_result {
|
||||
if let &Err(FlushError::FullScreenExclusiveModeLost) = &build_submission_result {
|
||||
self.swapchain
|
||||
.full_screen_exclusive_held
|
||||
.store(false, Ordering::SeqCst);
|
||||
@ -1830,7 +1842,7 @@ where
|
||||
SubmitAnyBuilder::QueuePresent(present) => {
|
||||
let present_result = present.submit(&self.queue);
|
||||
|
||||
if let &Err(SubmitPresentError::FullScreenExclusiveLost) = &present_result {
|
||||
if let &Err(SubmitPresentError::FullScreenExclusiveModeLost) = &present_result {
|
||||
self.swapchain
|
||||
.full_screen_exclusive_held
|
||||
.store(false, Ordering::SeqCst);
|
||||
@ -1963,7 +1975,7 @@ pub unsafe fn acquire_next_image_raw<W>(
|
||||
};
|
||||
|
||||
let mut out = MaybeUninit::uninit();
|
||||
let r = check_errors((fns.khr_swapchain.acquire_next_image_khr)(
|
||||
let result = (fns.khr_swapchain.acquire_next_image_khr)(
|
||||
swapchain.device.internal_object(),
|
||||
swapchain.handle,
|
||||
timeout_ns,
|
||||
@ -1974,16 +1986,18 @@ pub unsafe fn acquire_next_image_raw<W>(
|
||||
.map(|f| f.internal_object())
|
||||
.unwrap_or(ash::vk::Fence::null()),
|
||||
out.as_mut_ptr(),
|
||||
))?;
|
||||
);
|
||||
|
||||
let out = out.assume_init();
|
||||
let (id, suboptimal) = match r {
|
||||
Success::Success => (out as usize, false),
|
||||
Success::Suboptimal => (out as usize, true),
|
||||
Success::NotReady => return Err(AcquireError::Timeout),
|
||||
Success::Timeout => return Err(AcquireError::Timeout),
|
||||
s => panic!("unexpected success value: {:?}", s),
|
||||
let suboptimal = match result {
|
||||
ash::vk::Result::SUCCESS => false,
|
||||
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()),
|
||||
};
|
||||
|
||||
Ok(AcquiredImage { id, suboptimal })
|
||||
Ok(AcquiredImage {
|
||||
id: out.assume_init() as usize,
|
||||
suboptimal,
|
||||
})
|
||||
}
|
||||
|
@ -8,9 +8,8 @@
|
||||
// according to those terms.
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
OomError, Success, VulkanObject,
|
||||
OomError, VulkanError, VulkanObject,
|
||||
};
|
||||
use std::{
|
||||
hash::{Hash, Hasher},
|
||||
@ -43,12 +42,14 @@ impl Event {
|
||||
let handle = unsafe {
|
||||
let mut output = MaybeUninit::uninit();
|
||||
let fns = device.fns();
|
||||
check_errors((fns.v1_0.create_event)(
|
||||
(fns.v1_0.create_event)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -72,7 +73,9 @@ impl Event {
|
||||
unsafe {
|
||||
// Make sure the event isn't signaled
|
||||
let fns = device.fns();
|
||||
check_errors((fns.v1_0.reset_event)(device.internal_object(), handle))?;
|
||||
(fns.v1_0.reset_event)(device.internal_object(), handle)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
}
|
||||
Event {
|
||||
handle,
|
||||
@ -112,14 +115,11 @@ impl Event {
|
||||
pub fn signaled(&self) -> Result<bool, OomError> {
|
||||
unsafe {
|
||||
let fns = self.device.fns();
|
||||
let result = check_errors((fns.v1_0.get_event_status)(
|
||||
self.device.internal_object(),
|
||||
self.handle,
|
||||
))?;
|
||||
let result = (fns.v1_0.get_event_status)(self.device.internal_object(), self.handle);
|
||||
match result {
|
||||
Success::EventSet => Ok(true),
|
||||
Success::EventReset => Ok(false),
|
||||
_ => unreachable!(),
|
||||
ash::vk::Result::EVENT_SET => Ok(true),
|
||||
ash::vk::Result::EVENT_RESET => Ok(false),
|
||||
err => Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,10 +129,9 @@ impl Event {
|
||||
pub fn set_raw(&mut self) -> Result<(), OomError> {
|
||||
unsafe {
|
||||
let fns = self.device.fns();
|
||||
check_errors((fns.v1_0.set_event)(
|
||||
self.device.internal_object(),
|
||||
self.handle,
|
||||
))?;
|
||||
(fns.v1_0.set_event)(self.device.internal_object(), self.handle)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@ -155,10 +154,9 @@ impl Event {
|
||||
pub fn reset_raw(&mut self) -> Result<(), OomError> {
|
||||
unsafe {
|
||||
let fns = self.device.fns();
|
||||
check_errors((fns.v1_0.reset_event)(
|
||||
self.device.internal_object(),
|
||||
self.handle,
|
||||
))?;
|
||||
(fns.v1_0.reset_event)(self.device.internal_object(), self.handle)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,13 @@
|
||||
// according to those terms.
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
Error, OomError, Success, VulkanObject,
|
||||
OomError, VulkanError, VulkanObject,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
use std::{
|
||||
error, fmt,
|
||||
error::Error,
|
||||
fmt,
|
||||
hash::{Hash, Hasher},
|
||||
mem::MaybeUninit,
|
||||
ptr,
|
||||
@ -64,12 +64,14 @@ impl Fence {
|
||||
let handle = unsafe {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_fence)(
|
||||
(fns.v1_0.create_fence)(
|
||||
device.internal_object(),
|
||||
&create_info,
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -94,11 +96,9 @@ impl Fence {
|
||||
unsafe {
|
||||
// Make sure the fence isn't signaled
|
||||
let fns = device.fns();
|
||||
check_errors((fns.v1_0.reset_fences)(
|
||||
device.internal_object(),
|
||||
1,
|
||||
&handle,
|
||||
))?;
|
||||
(fns.v1_0.reset_fences)(device.internal_object(), 1, &handle)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
}
|
||||
|
||||
Fence {
|
||||
@ -147,17 +147,14 @@ impl Fence {
|
||||
}
|
||||
|
||||
let fns = self.device.fns();
|
||||
let result = check_errors((fns.v1_0.get_fence_status)(
|
||||
self.device.internal_object(),
|
||||
self.handle,
|
||||
))?;
|
||||
let result = (fns.v1_0.get_fence_status)(self.device.internal_object(), self.handle);
|
||||
match result {
|
||||
Success::Success => {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
self.is_signaled.store(true, Ordering::Relaxed);
|
||||
Ok(true)
|
||||
}
|
||||
Success::NotReady => Ok(false),
|
||||
_ => unreachable!(),
|
||||
ash::vk::Result::NOT_READY => Ok(false),
|
||||
err => Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -183,21 +180,21 @@ impl Fence {
|
||||
};
|
||||
|
||||
let fns = self.device.fns();
|
||||
let r = check_errors((fns.v1_0.wait_for_fences)(
|
||||
let result = (fns.v1_0.wait_for_fences)(
|
||||
self.device.internal_object(),
|
||||
1,
|
||||
&self.handle,
|
||||
ash::vk::TRUE,
|
||||
timeout_ns,
|
||||
))?;
|
||||
);
|
||||
|
||||
match r {
|
||||
Success::Success => {
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => {
|
||||
self.is_signaled.store(true, Ordering::Relaxed);
|
||||
Ok(())
|
||||
}
|
||||
Success::Timeout => Err(FenceWaitError::Timeout),
|
||||
_ => unreachable!(),
|
||||
ash::vk::Result::TIMEOUT => Err(FenceWaitError::Timeout),
|
||||
err => Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -243,25 +240,25 @@ impl Fence {
|
||||
u64::MAX
|
||||
};
|
||||
|
||||
let r = if let Some(device) = device {
|
||||
let result = if let Some(device) = device {
|
||||
unsafe {
|
||||
let fns = device.fns();
|
||||
check_errors((fns.v1_0.wait_for_fences)(
|
||||
(fns.v1_0.wait_for_fences)(
|
||||
device.internal_object(),
|
||||
fences.len() as u32,
|
||||
fences.as_ptr(),
|
||||
ash::vk::TRUE,
|
||||
timeout_ns,
|
||||
))?
|
||||
)
|
||||
}
|
||||
} else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
match r {
|
||||
Success::Success => Ok(()),
|
||||
Success::Timeout => Err(FenceWaitError::Timeout),
|
||||
_ => unreachable!(),
|
||||
match result {
|
||||
ash::vk::Result::SUCCESS => Ok(()),
|
||||
ash::vk::Result::TIMEOUT => Err(FenceWaitError::Timeout),
|
||||
err => Err(VulkanError::from(err).into()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,11 +269,9 @@ impl Fence {
|
||||
pub fn reset(&mut self) -> Result<(), OomError> {
|
||||
unsafe {
|
||||
let fns = self.device.fns();
|
||||
check_errors((fns.v1_0.reset_fences)(
|
||||
self.device.internal_object(),
|
||||
1,
|
||||
&self.handle,
|
||||
))?;
|
||||
(fns.v1_0.reset_fences)(self.device.internal_object(), 1, &self.handle)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
self.is_signaled.store(false, Ordering::Relaxed);
|
||||
Ok(())
|
||||
}
|
||||
@ -315,11 +310,13 @@ impl Fence {
|
||||
if let Some(device) = device {
|
||||
unsafe {
|
||||
let fns = device.fns();
|
||||
check_errors((fns.v1_0.reset_fences)(
|
||||
(fns.v1_0.reset_fences)(
|
||||
device.internal_object(),
|
||||
fences.len() as u32,
|
||||
fences.as_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@ -408,9 +405,9 @@ pub enum FenceWaitError {
|
||||
DeviceLostError,
|
||||
}
|
||||
|
||||
impl error::Error for FenceWaitError {
|
||||
impl Error for FenceWaitError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
FenceWaitError::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -433,14 +430,14 @@ impl fmt::Display for FenceWaitError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for FenceWaitError {
|
||||
impl From<VulkanError> for FenceWaitError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> FenceWaitError {
|
||||
fn from(err: VulkanError) -> FenceWaitError {
|
||||
match err {
|
||||
Error::OutOfHostMemory => FenceWaitError::OomError(From::from(err)),
|
||||
Error::OutOfDeviceMemory => FenceWaitError::OomError(From::from(err)),
|
||||
Error::DeviceLost => FenceWaitError::DeviceLostError,
|
||||
_ => panic!("Unexpected error value: {}", err as i32),
|
||||
VulkanError::OutOfHostMemory => FenceWaitError::OomError(From::from(err)),
|
||||
VulkanError::OutOfDeviceMemory => FenceWaitError::OomError(From::from(err)),
|
||||
VulkanError::DeviceLost => FenceWaitError::DeviceLostError,
|
||||
_ => panic!("Unexpected error value"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ use crate::{
|
||||
swapchain::{self, PresentFuture, PresentRegion, Swapchain},
|
||||
DeviceSize, OomError,
|
||||
};
|
||||
use std::{error, fmt, ops::Range, sync::Arc};
|
||||
use std::{error::Error, fmt, ops::Range, sync::Arc};
|
||||
|
||||
mod fence_signal;
|
||||
mod join;
|
||||
@ -405,7 +405,7 @@ pub enum AccessError {
|
||||
SwapchainImageAcquireOnly,
|
||||
}
|
||||
|
||||
impl error::Error for AccessError {}
|
||||
impl Error for AccessError {}
|
||||
|
||||
impl fmt::Display for AccessError {
|
||||
#[inline]
|
||||
@ -446,7 +446,7 @@ pub enum AccessCheckError {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
impl error::Error for AccessCheckError {}
|
||||
impl Error for AccessCheckError {}
|
||||
|
||||
impl fmt::Display for AccessCheckError {
|
||||
#[inline]
|
||||
@ -490,15 +490,15 @@ pub enum FlushError {
|
||||
|
||||
/// The swapchain has lost or doesn't have full screen exclusivity possibly for
|
||||
/// implementation-specific reasons outside of the application’s control.
|
||||
FullScreenExclusiveLost,
|
||||
FullScreenExclusiveModeLost,
|
||||
|
||||
/// The flush operation needed to block, but the timeout has elapsed.
|
||||
Timeout,
|
||||
}
|
||||
|
||||
impl error::Error for FlushError {
|
||||
impl Error for FlushError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
FlushError::AccessError(ref err) => Some(err),
|
||||
FlushError::OomError(ref err) => Some(err),
|
||||
@ -519,7 +519,7 @@ impl fmt::Display for FlushError {
|
||||
FlushError::DeviceLost => "the connection to the device has been lost",
|
||||
FlushError::SurfaceLost => "the surface of this swapchain is no longer valid",
|
||||
FlushError::OutOfDate => "the swapchain needs to be recreated",
|
||||
FlushError::FullScreenExclusiveLost => {
|
||||
FlushError::FullScreenExclusiveModeLost => {
|
||||
"the swapchain no longer has full screen exclusivity"
|
||||
}
|
||||
FlushError::Timeout => {
|
||||
@ -546,7 +546,9 @@ impl From<SubmitPresentError> for FlushError {
|
||||
SubmitPresentError::DeviceLost => FlushError::DeviceLost,
|
||||
SubmitPresentError::SurfaceLost => FlushError::SurfaceLost,
|
||||
SubmitPresentError::OutOfDate => FlushError::OutOfDate,
|
||||
SubmitPresentError::FullScreenExclusiveLost => FlushError::FullScreenExclusiveLost,
|
||||
SubmitPresentError::FullScreenExclusiveModeLost => {
|
||||
FlushError::FullScreenExclusiveModeLost
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,11 @@
|
||||
// according to those terms.
|
||||
|
||||
use crate::{
|
||||
check_errors,
|
||||
device::{Device, DeviceOwned},
|
||||
Error, OomError, Version, VulkanObject,
|
||||
OomError, Version, VulkanError, VulkanObject,
|
||||
};
|
||||
use std::{
|
||||
error::Error,
|
||||
fmt,
|
||||
fs::File,
|
||||
hash::{Hash, Hasher},
|
||||
@ -95,12 +95,14 @@ impl Semaphore {
|
||||
let handle = unsafe {
|
||||
let fns = device.fns();
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.v1_0.create_semaphore)(
|
||||
(fns.v1_0.create_semaphore)(
|
||||
device.internal_object(),
|
||||
&create_info.build(),
|
||||
ptr::null(),
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
|
||||
@ -197,11 +199,13 @@ impl Semaphore {
|
||||
};
|
||||
|
||||
let mut output = MaybeUninit::uninit();
|
||||
check_errors((fns.khr_external_semaphore_fd.get_semaphore_fd_khr)(
|
||||
(fns.khr_external_semaphore_fd.get_semaphore_fd_khr)(
|
||||
self.device.internal_object(),
|
||||
&info,
|
||||
output.as_mut_ptr(),
|
||||
))?;
|
||||
)
|
||||
.result()
|
||||
.map_err(VulkanError::from)?;
|
||||
output.assume_init()
|
||||
};
|
||||
let file = File::from_raw_fd(fd);
|
||||
@ -282,19 +286,21 @@ impl fmt::Display for SemaphoreCreationError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for SemaphoreCreationError {
|
||||
impl From<VulkanError> for SemaphoreCreationError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
e @ Error::OutOfHostMemory | e @ Error::OutOfDeviceMemory => Self::OomError(e.into()),
|
||||
e @ VulkanError::OutOfHostMemory | e @ VulkanError::OutOfDeviceMemory => {
|
||||
Self::OomError(e.into())
|
||||
}
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for SemaphoreCreationError {
|
||||
impl Error for SemaphoreCreationError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@ -518,19 +524,21 @@ impl fmt::Display for SemaphoreExportError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for SemaphoreExportError {
|
||||
impl From<VulkanError> for SemaphoreExportError {
|
||||
#[inline]
|
||||
fn from(err: Error) -> Self {
|
||||
fn from(err: VulkanError) -> Self {
|
||||
match err {
|
||||
e @ Error::OutOfHostMemory | e @ Error::OutOfDeviceMemory => Self::OomError(e.into()),
|
||||
e @ VulkanError::OutOfHostMemory | e @ VulkanError::OutOfDeviceMemory => {
|
||||
Self::OomError(e.into())
|
||||
}
|
||||
_ => panic!("unexpected error: {:?}", err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for SemaphoreExportError {
|
||||
impl Error for SemaphoreExportError {
|
||||
#[inline]
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match *self {
|
||||
Self::OomError(ref err) => Some(err),
|
||||
_ => None,
|
||||
|
Loading…
Reference in New Issue
Block a user