Skip to content

Commit

Permalink
Fix bug introduced by vulkano-rs#2410 (vulkano-rs#2411)
Browse files Browse the repository at this point in the history
* Fix bug introduced by vulkano-rs#2410

* Doc fix
  • Loading branch information
Rua authored and hakolao committed Feb 20, 2024
1 parent 4e66394 commit c09175e
Showing 1 changed file with 32 additions and 34 deletions.
66 changes: 32 additions & 34 deletions vulkano/src/swapchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ impl Swapchain {
present_mode: (device.enabled_extensions().ext_swapchain_maintenance1)
.then_some(present_mode),
full_screen_exclusive,
win32_monitor,
win32_monitor: win32_monitor
.filter(|_| full_screen_exclusive != FullScreenExclusive::Default),
..Default::default()
},
)
Expand All @@ -597,7 +598,11 @@ impl Swapchain {
present_mode: (device.enabled_extensions().ext_swapchain_maintenance1)
.then_some(present_mode),
full_screen_exclusive,
win32_monitor,
win32_monitor: win32_monitor.filter(|_| {
surface.api() == SurfaceApi::Win32
&& full_screen_exclusive
== FullScreenExclusive::ApplicationControlled
}),
..Default::default()
},
)
Expand All @@ -617,7 +622,11 @@ impl Swapchain {
surface,
SurfaceInfo {
full_screen_exclusive,
win32_monitor,
win32_monitor: win32_monitor.filter(|_| {
surface.api() == SurfaceApi::Win32
&& full_screen_exclusive
== FullScreenExclusive::ApplicationControlled
}),
..Default::default()
},
)
Expand Down Expand Up @@ -953,33 +962,6 @@ impl Swapchain {
*/
}

if surface.api() == SurfaceApi::Win32
&& full_screen_exclusive == FullScreenExclusive::ApplicationControlled
{
if win32_monitor.is_none() {
return Err(Box::new(ValidationError {
problem: "`surface` is a Win32 surface, and \
`create_info.full_screen_exclusive` is \
`FullScreenExclusive::ApplicationControlled`, but \
`create_info.win32_monitor` is `None`"
.into(),
vuids: &["VUID-VkSwapchainCreateInfoKHR-pNext-02679"],
..Default::default()
}));
}
} else {
if win32_monitor.is_some() {
return Err(Box::new(ValidationError {
problem: "`surface` is not a Win32 surface, or \
`create_info.full_screen_exclusive` is not \
`FullScreenExclusive::ApplicationControlled`, but \
`create_info.win32_monitor` is `Some`"
.into(),
..Default::default()
}));
}
}

Ok(())
}

Expand Down Expand Up @@ -1952,9 +1934,8 @@ pub struct SwapchainCreateInfo {
/// The default value is [`FullScreenExclusive::Default`].
pub full_screen_exclusive: FullScreenExclusive,

/// For Win32 surfaces, if `full_screen_exclusive` is
/// [`FullScreenExclusive::ApplicationControlled`], this specifies the monitor on which
/// full-screen exclusivity should be used.
/// If `full_screen_exclusive` is not [`FullScreenExclusive::Default`], this specifies the
/// monitor on which full-screen exclusivity should be used.
///
/// For this case, the value must be `Some`, and for all others it must be `None`.
///
Expand Down Expand Up @@ -2011,7 +1992,7 @@ impl SwapchainCreateInfo {
scaling_behavior,
present_gravity,
full_screen_exclusive,
win32_monitor: _,
win32_monitor,
_ne: _,
} = self;

Expand Down Expand Up @@ -2315,6 +2296,23 @@ impl SwapchainCreateInfo {
"VUID-VkSurfaceFullScreenExclusiveInfoEXT-fullScreenExclusive-parameter",
])
})?;

if win32_monitor.is_none() {
return Err(Box::new(ValidationError {
problem: "`full_screen_exclusive` is not `FullScreenExclusive::Default`, but \
`win32_monitor` is `None`"
.into(),
vuids: &["VUID-VkSwapchainCreateInfoKHR-pNext-02679"],
..Default::default()
}));
}
} else if win32_monitor.is_some() {
return Err(Box::new(ValidationError {
problem: "`full_screen_exclusive` is `FullScreenExclusive::Default`, but \
`win32_monitor` is `Some`"
.into(),
..Default::default()
}));
}

Ok(())
Expand Down

0 comments on commit c09175e

Please sign in to comment.