Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ValidationError-ify futures #2271

Merged
merged 10 commits into from
Aug 4, 2023
15 changes: 7 additions & 8 deletions examples/src/bin/async-update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ use vulkano::{
},
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainPresentInfo,
acquire_next_image, Surface, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
sync::{self, GpuFuture},
Validated, VulkanError, VulkanLibrary,
};
use winit::{
event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
Expand Down Expand Up @@ -570,9 +569,9 @@ fn main() {
}

let (image_index, suboptimal, acquire_future) =
match acquire_next_image(swapchain.clone(), None) {
match acquire_next_image(swapchain.clone(), None).map_err(Validated::unwrap) {
Ok(r) => r,
Err(AcquireError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
return;
}
Expand Down Expand Up @@ -666,11 +665,11 @@ fn main() {
)
.then_signal_fence_and_flush();

match future {
match future.map_err(Validated::unwrap) {
Ok(future) => {
previous_frame_end = Some(future.boxed());
}
Err(FlushError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
previous_frame_end = Some(sync::now(device.clone()).boxed());
}
Expand Down
15 changes: 7 additions & 8 deletions examples/src/bin/buffer-allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ use vulkano::{
},
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainPresentInfo,
acquire_next_image, Surface, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
sync::{self, GpuFuture},
Validated, VulkanError, VulkanLibrary,
};
use winit::{
event::{Event, WindowEvent},
Expand Down Expand Up @@ -318,9 +317,9 @@ fn main() {
}

let (image_index, suboptimal, acquire_future) =
match acquire_next_image(swapchain.clone(), None) {
match acquire_next_image(swapchain.clone(), None).map_err(Validated::unwrap) {
Ok(r) => r,
Err(AcquireError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
return;
}
Expand Down Expand Up @@ -409,11 +408,11 @@ fn main() {
)
.then_signal_fence_and_flush();

match future {
match future.map_err(Validated::unwrap) {
Ok(future) => {
previous_frame_end = Some(Box::new(future) as Box<_>);
}
Err(FlushError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
previous_frame_end = Some(Box::new(sync::now(device.clone())) as Box<_>);
}
Expand Down
15 changes: 7 additions & 8 deletions examples/src/bin/clear_attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ use vulkano::{
instance::{Instance, InstanceCreateFlags, InstanceCreateInfo},
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass},
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainPresentInfo,
acquire_next_image, Surface, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
sync::{self, GpuFuture},
Validated, VulkanError, VulkanLibrary,
};
use winit::{
event::{Event, WindowEvent},
Expand Down Expand Up @@ -196,9 +195,9 @@ fn main() {
}

let (image_index, suboptimal, acquire_future) =
match acquire_next_image(swapchain.clone(), None) {
match acquire_next_image(swapchain.clone(), None).map_err(Validated::unwrap) {
Ok(r) => r,
Err(AcquireError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
return;
}
Expand Down Expand Up @@ -276,11 +275,11 @@ fn main() {
)
.then_signal_fence_and_flush();

match future {
match future.map_err(Validated::unwrap) {
Ok(future) => {
previous_frame_end = Some(future.boxed());
}
Err(FlushError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
previous_frame_end = Some(sync::now(device.clone()).boxed());
}
Expand Down
15 changes: 7 additions & 8 deletions examples/src/bin/deferred/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ use vulkano::{
instance::{Instance, InstanceCreateFlags, InstanceCreateInfo},
memory::allocator::StandardMemoryAllocator,
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainPresentInfo,
acquire_next_image, Surface, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
sync::{self, GpuFuture},
Validated, VulkanError, VulkanLibrary,
};
use winit::{
event::{Event, WindowEvent},
Expand Down Expand Up @@ -222,9 +221,9 @@ fn main() {
}

let (image_index, suboptimal, acquire_future) =
match acquire_next_image(swapchain.clone(), None) {
match acquire_next_image(swapchain.clone(), None).map_err(Validated::unwrap) {
Ok(r) => r,
Err(AcquireError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
return;
}
Expand Down Expand Up @@ -269,11 +268,11 @@ fn main() {
)
.then_signal_fence_and_flush();

match future {
match future.map_err(Validated::unwrap) {
Ok(future) => {
previous_frame_end = Some(future.boxed());
}
Err(FlushError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
previous_frame_end = Some(sync::now(device.clone()).boxed());
}
Expand Down
34 changes: 20 additions & 14 deletions examples/src/bin/gl-interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,18 @@ mod linux {
PipelineShaderStageCreateInfo,
},
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
swapchain::{AcquireError, Surface, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo},
swapchain::{
acquire_next_image, Surface, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
},
sync::{
now,
semaphore::{
ExternalSemaphoreHandleType, ExternalSemaphoreHandleTypes, Semaphore,
SemaphoreCreateInfo,
},
FlushError, GpuFuture,
GpuFuture,
},
VulkanLibrary,
Validated, VulkanError, VulkanLibrary,
};
use winit::{
event::{Event, WindowEvent},
Expand Down Expand Up @@ -349,15 +351,19 @@ mod linux {
recreate_swapchain = false;
}

let (image_index, suboptimal, acquire_future) =
match vulkano::swapchain::acquire_next_image(swapchain.clone(), None) {
Ok(r) => r,
Err(AcquireError::OutOfDate) => {
recreate_swapchain = true;
return;
}
Err(e) => panic!("failed to acquire next image: {e}"),
};
let (image_index, suboptimal, acquire_future) = match acquire_next_image(
swapchain.clone(),
None,
)
.map_err(Validated::unwrap)
{
Ok(r) => r,
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
return;
}
Err(e) => panic!("failed to acquire next image: {e}"),
};

if suboptimal {
recreate_swapchain = true;
Expand Down Expand Up @@ -413,12 +419,12 @@ mod linux {
)
.then_signal_fence_and_flush();

match future {
match future.map_err(Validated::unwrap) {
Ok(future) => {
future.wait(None).unwrap();
previous_frame_end = Some(future.boxed());
}
Err(FlushError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
previous_frame_end = Some(vulkano::sync::now(device.clone()).boxed());
}
Expand Down
15 changes: 7 additions & 8 deletions examples/src/bin/image-self-copy-blit/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ use vulkano::{
},
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainPresentInfo,
acquire_next_image, Surface, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
DeviceSize, VulkanLibrary,
sync::{self, GpuFuture},
DeviceSize, Validated, VulkanError, VulkanLibrary,
};
use winit::{
event::{Event, WindowEvent},
Expand Down Expand Up @@ -443,9 +442,9 @@ fn main() {
}

let (image_index, suboptimal, acquire_future) =
match acquire_next_image(swapchain.clone(), None) {
match acquire_next_image(swapchain.clone(), None).map_err(Validated::unwrap) {
Ok(r) => r,
Err(AcquireError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
return;
}
Expand Down Expand Up @@ -504,11 +503,11 @@ fn main() {
)
.then_signal_fence_and_flush();

match future {
match future.map_err(Validated::unwrap) {
Ok(future) => {
previous_frame_end = Some(future.boxed());
}
Err(FlushError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
previous_frame_end = Some(sync::now(device.clone()).boxed());
}
Expand Down
15 changes: 7 additions & 8 deletions examples/src/bin/image/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ use vulkano::{
},
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainPresentInfo,
acquire_next_image, Surface, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
DeviceSize, VulkanLibrary,
sync::{self, GpuFuture},
DeviceSize, Validated, VulkanError, VulkanLibrary,
};
use winit::{
event::{Event, WindowEvent},
Expand Down Expand Up @@ -391,9 +390,9 @@ fn main() {
}

let (image_index, suboptimal, acquire_future) =
match acquire_next_image(swapchain.clone(), None) {
match acquire_next_image(swapchain.clone(), None).map_err(Validated::unwrap) {
Ok(r) => r,
Err(AcquireError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
return;
}
Expand Down Expand Up @@ -452,11 +451,11 @@ fn main() {
)
.then_signal_fence_and_flush();

match future {
match future.map_err(Validated::unwrap) {
Ok(future) => {
previous_frame_end = Some(future.boxed());
}
Err(FlushError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
previous_frame_end = Some(sync::now(device.clone()).boxed());
}
Expand Down
15 changes: 7 additions & 8 deletions examples/src/bin/immutable-sampler/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ use vulkano::{
},
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainPresentInfo,
acquire_next_image, Surface, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
DeviceSize, VulkanLibrary,
sync::{self, GpuFuture},
DeviceSize, Validated, VulkanError, VulkanLibrary,
};
use winit::{
event::{Event, WindowEvent},
Expand Down Expand Up @@ -412,9 +411,9 @@ fn main() {
}

let (image_index, suboptimal, acquire_future) =
match acquire_next_image(swapchain.clone(), None) {
match acquire_next_image(swapchain.clone(), None).map_err(Validated::unwrap) {
Ok(r) => r,
Err(AcquireError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
return;
}
Expand Down Expand Up @@ -473,11 +472,11 @@ fn main() {
)
.then_signal_fence_and_flush();

match future {
match future.map_err(Validated::unwrap) {
Ok(future) => {
previous_frame_end = Some(future.boxed());
}
Err(FlushError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
previous_frame_end = Some(sync::now(device.clone()).boxed());
}
Expand Down
15 changes: 7 additions & 8 deletions examples/src/bin/indirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ use vulkano::{
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
single_pass_renderpass,
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainPresentInfo,
acquire_next_image, Surface, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
sync::{self, GpuFuture},
Validated, VulkanError, VulkanLibrary,
};
use winit::{
event::{Event, WindowEvent},
Expand Down Expand Up @@ -412,9 +411,9 @@ fn main() {
}

let (image_index, suboptimal, acquire_future) =
match acquire_next_image(swapchain.clone(), None) {
match acquire_next_image(swapchain.clone(), None).map_err(Validated::unwrap) {
Ok(r) => r,
Err(AcquireError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
return;
}
Expand Down Expand Up @@ -520,11 +519,11 @@ fn main() {
)
.then_signal_fence_and_flush();

match future {
match future.map_err(Validated::unwrap) {
Ok(future) => {
previous_frame_end = Some(future.boxed());
}
Err(FlushError::OutOfDate) => {
Err(VulkanError::OutOfDate) => {
recreate_swapchain = true;
previous_frame_end = Some(sync::now(device.clone()).boxed());
}
Expand Down
Loading