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 Surface and Swapchain #2236

Merged
merged 10 commits into from
Jun 26, 2023
26 changes: 12 additions & 14 deletions examples/src/bin/async-update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ use vulkano::{
shader::PipelineShaderStageCreateInfo,
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainCreationError, SwapchainPresentInfo,
SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
Expand Down Expand Up @@ -545,21 +545,19 @@ fn main() {
channel.send(()).unwrap();
}
Event::RedrawEventsCleared => {
let dimensions = window.inner_size();
if dimensions.width == 0 || dimensions.height == 0 {
return;
}

Rua marked this conversation as resolved.
Show resolved Hide resolved
if recreate_swapchain {
let (new_swapchain, new_images) =
match swapchain.recreate(SwapchainCreateInfo {
image_extent: dimensions.into(),
let image_extent: [u32; 2] = window.inner_size().into();

if image_extent.contains(&0) {
return;
}

let (new_swapchain, new_images) = swapchain
.recreate(SwapchainCreateInfo {
image_extent,
..swapchain.create_info()
}) {
Ok(r) => r,
Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return,
Err(e) => panic!("failed to recreate swapchain: {e}"),
};
})
.expect("failed to recreate swapchain");

swapchain = new_swapchain;
framebuffers = window_size_dependent_setup(
Expand Down
26 changes: 12 additions & 14 deletions examples/src/bin/buffer-allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use vulkano::{
shader::PipelineShaderStageCreateInfo,
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainCreationError, SwapchainPresentInfo,
SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
Expand Down Expand Up @@ -293,23 +293,21 @@ fn main() {
recreate_swapchain = true;
}
Event::RedrawEventsCleared => {
let dimensions = window.inner_size();
if dimensions.width == 0 || dimensions.height == 0 {
return;
}

Rua marked this conversation as resolved.
Show resolved Hide resolved
previous_frame_end.as_mut().unwrap().cleanup_finished();

if recreate_swapchain {
let (new_swapchain, new_images) =
match swapchain.recreate(SwapchainCreateInfo {
image_extent: dimensions.into(),
let image_extent: [u32; 2] = window.inner_size().into();

if image_extent.contains(&0) {
return;
}

let (new_swapchain, new_images) = swapchain
.recreate(SwapchainCreateInfo {
image_extent,
..swapchain.create_info()
}) {
Ok(r) => r,
Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return,
Err(e) => panic!("failed to recreate swapchain: {e}"),
};
})
.expect("failed to recreate swapchain");

swapchain = new_swapchain;
framebuffers = window_size_dependent_setup(
Expand Down
27 changes: 13 additions & 14 deletions examples/src/bin/clear_attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use vulkano::{
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass},
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainCreationError, SwapchainPresentInfo,
SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
Expand Down Expand Up @@ -175,22 +175,21 @@ fn main() {
recreate_swapchain = true;
}
Event::RedrawEventsCleared => {
let dimensions = window.inner_size();
if dimensions.width == 0 || dimensions.height == 0 {
return;
}

Rua marked this conversation as resolved.
Show resolved Hide resolved
previous_frame_end.as_mut().unwrap().cleanup_finished();

if recreate_swapchain {
let (new_swapchain, new_images) = match swapchain.recreate(SwapchainCreateInfo {
image_extent: dimensions.into(),
..swapchain.create_info()
}) {
Ok(r) => r,
Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return,
Err(e) => panic!("failed to recreate swapchain: {e}"),
};
let image_extent: [u32; 2] = window.inner_size().into();

if image_extent.contains(&0) {
return;
}

let (new_swapchain, new_images) = swapchain
.recreate(SwapchainCreateInfo {
image_extent,
..swapchain.create_info()
})
.expect("failed to recreate swapchain");

swapchain = new_swapchain;
width = swapchain.image_extent()[0];
Expand Down
27 changes: 13 additions & 14 deletions examples/src/bin/deferred/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use vulkano::{
memory::allocator::StandardMemoryAllocator,
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainCreationError, SwapchainPresentInfo,
SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
Expand Down Expand Up @@ -199,22 +199,21 @@ fn main() {
recreate_swapchain = true;
}
Event::RedrawEventsCleared => {
let dimensions = window.inner_size();
if dimensions.width == 0 || dimensions.height == 0 {
return;
}

Rua marked this conversation as resolved.
Show resolved Hide resolved
previous_frame_end.as_mut().unwrap().cleanup_finished();

if recreate_swapchain {
let (new_swapchain, new_images) = match swapchain.recreate(SwapchainCreateInfo {
image_extent: dimensions.into(),
..swapchain.create_info()
}) {
Ok(r) => r,
Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return,
Err(e) => panic!("failed to recreate swapchain: {e}"),
};
let image_extent: [u32; 2] = window.inner_size().into();

if image_extent.contains(&0) {
return;
}

let (new_swapchain, new_images) = swapchain
.recreate(SwapchainCreateInfo {
image_extent,
..swapchain.create_info()
})
.expect("failed to recreate swapchain");
let new_images = new_images
.into_iter()
.map(|image| ImageView::new_default(image).unwrap())
Expand Down
26 changes: 12 additions & 14 deletions examples/src/bin/gl-interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ mod linux {
render_pass::{Framebuffer, RenderPass, Subpass},
sampler::{Filter, Sampler, SamplerAddressMode, SamplerCreateInfo},
shader::PipelineShaderStageCreateInfo,
swapchain::{
AcquireError, Surface, Swapchain, SwapchainCreateInfo, SwapchainCreationError,
SwapchainPresentInfo,
},
swapchain::{AcquireError, Surface, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo},
sync::{
now,
semaphore::{
Expand Down Expand Up @@ -290,17 +287,18 @@ mod linux {
previous_frame_end.as_mut().unwrap().cleanup_finished();

if recreate_swapchain {
let (new_swapchain, new_images) =
match swapchain.recreate(SwapchainCreateInfo {
image_extent: window.inner_size().into(),
let image_extent: [u32; 2] = window.inner_size().into();

if image_extent.contains(&0) {
return;
}

let (new_swapchain, new_images) = swapchain
.recreate(SwapchainCreateInfo {
image_extent,
..swapchain.create_info()
}) {
Ok(r) => r,
Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => {
return
}
Err(e) => panic!("failed to recreate swapchain: {e}"),
};
})
.expect("failed to recreate swapchain");

swapchain = new_swapchain;
framebuffers = window_size_dependent_setup(
Expand Down
27 changes: 13 additions & 14 deletions examples/src/bin/image-self-copy-blit/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use vulkano::{
shader::PipelineShaderStageCreateInfo,
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainCreationError, SwapchainPresentInfo,
SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
Expand Down Expand Up @@ -421,22 +421,21 @@ fn main() {
recreate_swapchain = true;
}
Event::RedrawEventsCleared => {
let dimensions = window.inner_size();
if dimensions.width == 0 || dimensions.height == 0 {
return;
}

Rua marked this conversation as resolved.
Show resolved Hide resolved
previous_frame_end.as_mut().unwrap().cleanup_finished();

if recreate_swapchain {
let (new_swapchain, new_images) = match swapchain.recreate(SwapchainCreateInfo {
image_extent: dimensions.into(),
..swapchain.create_info()
}) {
Ok(r) => r,
Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return,
Err(e) => panic!("failed to recreate swapchain: {e}"),
};
let image_extent: [u32; 2] = window.inner_size().into();

if image_extent.contains(&0) {
return;
}

let (new_swapchain, new_images) = swapchain
.recreate(SwapchainCreateInfo {
image_extent,
..swapchain.create_info()
})
.expect("failed to recreate swapchain");

swapchain = new_swapchain;
framebuffers =
Expand Down
27 changes: 13 additions & 14 deletions examples/src/bin/image/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use vulkano::{
shader::PipelineShaderStageCreateInfo,
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainCreationError, SwapchainPresentInfo,
SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
Expand Down Expand Up @@ -347,22 +347,21 @@ fn main() {
recreate_swapchain = true;
}
Event::RedrawEventsCleared => {
let dimensions = window.inner_size();
if dimensions.width == 0 || dimensions.height == 0 {
return;
}

Rua marked this conversation as resolved.
Show resolved Hide resolved
previous_frame_end.as_mut().unwrap().cleanup_finished();

if recreate_swapchain {
let (new_swapchain, new_images) = match swapchain.recreate(SwapchainCreateInfo {
image_extent: dimensions.into(),
..swapchain.create_info()
}) {
Ok(r) => r,
Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return,
Err(e) => panic!("failed to recreate swapchain: {e}"),
};
let image_extent: [u32; 2] = window.inner_size().into();

if image_extent.contains(&0) {
return;
}

let (new_swapchain, new_images) = swapchain
.recreate(SwapchainCreateInfo {
image_extent,
..swapchain.create_info()
})
.expect("failed to recreate swapchain");

swapchain = new_swapchain;
framebuffers =
Expand Down
21 changes: 10 additions & 11 deletions examples/src/bin/immutable-sampler/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use vulkano::{
shader::PipelineShaderStageCreateInfo,
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainCreationError, SwapchainPresentInfo,
SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
Expand Down Expand Up @@ -368,22 +368,21 @@ fn main() {
recreate_swapchain = true;
}
Event::RedrawEventsCleared => {
let dimensions = window.inner_size();
if dimensions.width == 0 || dimensions.height == 0 {
let image_extent: [u32; 2] = window.inner_size().into();

if image_extent.contains(&0) {
return;
}

previous_frame_end.as_mut().unwrap().cleanup_finished();

if recreate_swapchain {
let (new_swapchain, new_images) = match swapchain.recreate(SwapchainCreateInfo {
image_extent: dimensions.into(),
..swapchain.create_info()
}) {
Ok(r) => r,
Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return,
Err(e) => panic!("failed to recreate swapchain: {e}"),
};
let (new_swapchain, new_images) = swapchain
.recreate(SwapchainCreateInfo {
image_extent,
..swapchain.create_info()
})
.expect("failed to recreate swapchain");

swapchain = new_swapchain;
framebuffers =
Expand Down
26 changes: 12 additions & 14 deletions examples/src/bin/indirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ use vulkano::{
single_pass_renderpass,
swapchain::{
acquire_next_image, AcquireError, Surface, Swapchain, SwapchainCreateInfo,
SwapchainCreationError, SwapchainPresentInfo,
SwapchainPresentInfo,
},
sync::{self, FlushError, GpuFuture},
VulkanLibrary,
Expand Down Expand Up @@ -384,23 +384,21 @@ fn main() {
recreate_swapchain = true;
}
Event::RedrawEventsCleared => {
let dimensions = window.inner_size();
if dimensions.width == 0 || dimensions.height == 0 {
return;
}

Rua marked this conversation as resolved.
Show resolved Hide resolved
previous_frame_end.as_mut().unwrap().cleanup_finished();

if recreate_swapchain {
let (new_swapchain, new_images) =
match swapchain.recreate(SwapchainCreateInfo {
image_extent: dimensions.into(),
let image_extent: [u32; 2] = window.inner_size().into();

if image_extent.contains(&0) {
return;
}

let (new_swapchain, new_images) = swapchain
.recreate(SwapchainCreateInfo {
image_extent,
..swapchain.create_info()
}) {
Ok(r) => r,
Err(SwapchainCreationError::ImageExtentNotSupported { .. }) => return,
Err(e) => panic!("failed to recreate swapchain: {e}"),
};
})
.expect("failed to recreate swapchain");

swapchain = new_swapchain;
framebuffers = window_size_dependent_setup(
Expand Down
Loading