Skip to content

Commit 2c1ff1b

Browse files
committed
Fix warnings for unrecognized Vulkan present mode
1 parent 995efdd commit 2c1ff1b

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Bottom level categories:
8989
#### Vulkan
9090

9191
- Fix OpenBSD compilation of `wgpu_hal::vulkan::drm`. By @ErichDonGubler in [#7810](https://github.com/gfx-rs/wgpu/pull/7810).
92+
- Fix warnings for unrecognized present mode. By @Wumpf in [#TODO](https://github.com/gfx-rs/wgpu/pull/TODO).
9293

9394
#### Metal
9495

wgpu-hal/src/vulkan/conv.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -468,17 +468,25 @@ pub fn map_present_mode(mode: wgt::PresentMode) -> vk::PresentModeKHR {
468468
}
469469

470470
pub fn map_vk_present_mode(mode: vk::PresentModeKHR) -> Option<wgt::PresentMode> {
471-
if mode == vk::PresentModeKHR::IMMEDIATE {
472-
Some(wgt::PresentMode::Immediate)
473-
} else if mode == vk::PresentModeKHR::MAILBOX {
474-
Some(wgt::PresentMode::Mailbox)
475-
} else if mode == vk::PresentModeKHR::FIFO {
476-
Some(wgt::PresentMode::Fifo)
477-
} else if mode == vk::PresentModeKHR::FIFO_RELAXED {
478-
Some(wgt::PresentMode::FifoRelaxed)
479-
} else {
480-
log::warn!("Unrecognized present mode {:?}", mode);
481-
None
471+
// Not exposed in Ash yet.
472+
const FIFO_LATEST_READY: vk::PresentModeKHR = vk::PresentModeKHR::from_raw(1_000_361_000);
473+
474+
// See https://registry.khronos.org/vulkan/specs/latest/man/html/VkPresentModeKHR.html
475+
match mode {
476+
vk::PresentModeKHR::IMMEDIATE => Some(wgt::PresentMode::Immediate),
477+
vk::PresentModeKHR::MAILBOX => Some(wgt::PresentMode::Mailbox),
478+
vk::PresentModeKHR::FIFO => Some(wgt::PresentMode::Fifo),
479+
vk::PresentModeKHR::FIFO_RELAXED => Some(wgt::PresentMode::FifoRelaxed),
480+
481+
// Modes that aren't exposed yet.
482+
vk::PresentModeKHR::SHARED_DEMAND_REFRESH => None,
483+
vk::PresentModeKHR::SHARED_CONTINUOUS_REFRESH => None,
484+
FIFO_LATEST_READY => None,
485+
486+
_ => {
487+
log::debug!("Unrecognized present mode {:?}", mode);
488+
None
489+
}
482490
}
483491
}
484492

0 commit comments

Comments
 (0)