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

PhysicalDevice::surface_present_modes should return Vec result #2496

Merged
merged 3 commits into from
Mar 13, 2024
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
22 changes: 11 additions & 11 deletions vulkano/src/device/physical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,7 @@ impl PhysicalDevice {
} = surface_info;

if let Some(present_mode) = present_mode {
let mut present_modes = unsafe {
let present_modes = unsafe {
self.surface_present_modes_unchecked(
surface,
SurfaceInfo {
Expand All @@ -1999,7 +1999,7 @@ impl PhysicalDevice {
})?
};

if !present_modes.any(|mode| mode == present_mode) {
if !present_modes.into_iter().any(|mode| mode == present_mode) {
return Err(Box::new(ValidationError {
problem: "`surface_info.present_mode` is not supported for `surface`".into(),
vuids: &["VUID-VkSurfacePresentModeEXT-presentMode-07780"],
Expand Down Expand Up @@ -2355,7 +2355,7 @@ impl PhysicalDevice {
} = surface_info;

if let Some(present_mode) = present_mode {
let mut present_modes = unsafe {
let present_modes = unsafe {
self.surface_present_modes_unchecked(
surface,
SurfaceInfo {
Expand All @@ -2373,7 +2373,7 @@ impl PhysicalDevice {
})?
};

if !present_modes.any(|mode| mode == present_mode) {
if !present_modes.into_iter().any(|mode| mode == present_mode) {
return Err(Box::new(ValidationError {
problem: "`surface_info.present_mode` is not supported for `surface`".into(),
vuids: &["VUID-VkSurfacePresentModeEXT-presentMode-07780"],
Expand Down Expand Up @@ -2601,7 +2601,7 @@ impl PhysicalDevice {
&self,
surface: &Surface,
surface_info: SurfaceInfo,
) -> Result<impl Iterator<Item = PresentMode>, Validated<VulkanError>> {
) -> Result<Vec<PresentMode>, Validated<VulkanError>> {
self.validate_surface_present_modes(surface, &surface_info)?;

unsafe { Ok(self.surface_present_modes_unchecked(surface, surface_info)?) }
Expand Down Expand Up @@ -2718,10 +2718,10 @@ impl PhysicalDevice {
&self,
surface: &Surface,
surface_info: SurfaceInfo,
) -> Result<impl Iterator<Item = PresentMode>, VulkanError> {
surface
.surface_present_modes
.get_or_try_insert((self.handle, surface_info), |(_, surface_info)| {
) -> Result<Vec<PresentMode>, VulkanError> {
surface.surface_present_modes.get_or_try_insert(
(self.handle, surface_info),
|(_, surface_info)| {
let &SurfaceInfo {
present_mode: _,
full_screen_exclusive,
Expand Down Expand Up @@ -2837,8 +2837,8 @@ impl PhysicalDevice {
.filter_map(|mode_vk| mode_vk.try_into().ok())
.collect())
}
})
.map(IntoIterator::into_iter)
},
)
}

/// Returns whether queues of the given queue family can draw on the given surface.
Expand Down
3 changes: 1 addition & 2 deletions vulkano/src/swapchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ impl Swapchain {
})
})?
};
let surface_present_modes: SmallVec<[_; PresentMode::COUNT]> = unsafe {
let surface_present_modes = unsafe {
device
.physical_device()
.surface_present_modes_unchecked(
Expand All @@ -644,7 +644,6 @@ impl Swapchain {
..Default::default()
})
})?
.collect()
};

if surface_capabilities
Expand Down
Loading