Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ValidationError-ify sync primitives #2267

Merged
merged 4 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions vulkano/autogen/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ fn errors_members(errors: &[&str]) -> Vec<ErrorsMember> {

let mut parts = ffi_name.split('_').collect::<Vec<_>>();

assert!(parts[0] == "ERROR");
parts.remove(0);
if parts[0] == "ERROR" {
parts.remove(0);
}

if ["EXT", "KHR", "NV"].contains(parts.last().unwrap()) {
parts.pop();
Expand Down
5 changes: 4 additions & 1 deletion vulkano/autogen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ impl<'r> VkRegistryData<'r> {
}) 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('-') {
// Treat NotReady and Timeout as error conditions
if value.starts_with('-')
|| matches!(en.name.as_str(), "VK_NOT_READY" | "VK_TIMEOUT")
{
return Some(en.name.as_str());
}
}
Expand Down
2 changes: 2 additions & 0 deletions vulkano/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ impl Error for VulkanError {}
impl Display for VulkanError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
let msg = match self {
VulkanError::NotReady => "a resource is not yet ready",
VulkanError::Timeout => "an operation has not completed in the specified time",
VulkanError::OutOfHostMemory => "a host memory allocation has failed",
VulkanError::OutOfDeviceMemory => "a device memory allocation has failed",
VulkanError::InitializationFailed => {
Expand Down
26 changes: 3 additions & 23 deletions vulkano/src/swapchain/acquire_present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use crate::{
device::{Device, DeviceOwned, Queue},
image::{Image, ImageLayout},
sync::{
fence::{Fence, FenceError},
fence::Fence,
future::{AccessCheckError, AccessError, FlushError, GpuFuture, SubmitAnyBuilder},
semaphore::{Semaphore, SemaphoreError},
semaphore::Semaphore,
},
DeviceSize, OomError, RequirementNotMet, Requires, RequiresAllOf, RequiresOneOf, VulkanError,
VulkanObject,
Expand Down Expand Up @@ -186,7 +186,7 @@ impl SwapchainAcquireFuture {
/// If timeout is `None`, will potentially block forever
///
/// You still need to join with this future for present to work
pub fn wait(&self, timeout: Option<Duration>) -> Result<(), FenceError> {
pub fn wait(&self, timeout: Option<Duration>) -> Result<(), VulkanError> {
match &self.fence {
Some(fence) => fence.wait(timeout),
None => Ok(()),
Expand Down Expand Up @@ -330,12 +330,6 @@ pub enum AcquireError {
/// 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,

/// Error during fence creation.
FenceError(FenceError),

/// Error during semaphore creation.
SemaphoreError(SemaphoreError),
}

impl Error for AcquireError {
Expand All @@ -361,25 +355,11 @@ impl Display for AcquireError {
AcquireError::FullScreenExclusiveModeLost => {
"the swapchain no longer has full-screen exclusivity"
}
AcquireError::FenceError(_) => "error creating fence",
AcquireError::SemaphoreError(_) => "error creating semaphore",
}
)
}
}

impl From<FenceError> for AcquireError {
fn from(err: FenceError) -> Self {
AcquireError::FenceError(err)
}
}

impl From<SemaphoreError> for AcquireError {
fn from(err: SemaphoreError) -> Self {
AcquireError::SemaphoreError(err)
}
}

impl From<OomError> for AcquireError {
fn from(err: OomError) -> AcquireError {
AcquireError::OomError(err)
Expand Down
Loading