vk_instance: Add additional fallback for missing D16UnormS8Uint. (#1810)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions

This commit is contained in:
squidbus 2024-12-17 21:56:08 -08:00 committed by GitHub
parent 87773a417b
commit ccfb1bbfa8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -583,23 +583,20 @@ bool Instance::IsFormatSupported(const vk::Format format,
return (GetFormatFeatureFlags(format) & flags) == flags;
}
static vk::Format GetAlternativeFormat(const vk::Format format) {
switch (format) {
case vk::Format::eD16UnormS8Uint:
return vk::Format::eD24UnormS8Uint;
default:
return format;
}
}
vk::Format Instance::GetSupportedFormat(const vk::Format format,
const vk::FormatFeatureFlags2 flags) const {
if (IsFormatSupported(format, flags)) [[likely]] {
return format;
}
const vk::Format alternative = GetAlternativeFormat(format);
if (IsFormatSupported(alternative, flags)) [[likely]] {
return alternative;
if (!IsFormatSupported(format, flags)) [[unlikely]] {
switch (format) {
case vk::Format::eD16UnormS8Uint:
if (IsFormatSupported(vk::Format::eD24UnormS8Uint, flags)) {
return vk::Format::eD24UnormS8Uint;
}
if (IsFormatSupported(vk::Format::eD32SfloatS8Uint, flags)) {
return vk::Format::eD32SfloatS8Uint;
}
default:
break;
}
}
return format;
}