Skip to content

Commit

Permalink
vulkan: Report only missing format feature flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
squidbus committed Oct 20, 2024
1 parent 8e08756 commit d202dee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/video_core/renderer_vulkan/vk_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,23 @@ Instance::Instance(Frontend::WindowSDL& window, s32 physical_device_index,

// Check and log format support details.
for (const auto& format : LiverpoolToVK::SurfaceFormats()) {
if (!IsFormatSupported(GetSupportedFormat(format.vk_format, format.flags), format.flags)) {
if (!IsFormatSupported(format.vk_format, format.flags)) {
LOG_WARNING(Render_Vulkan,
"Surface format data_format={}, number_format={} is not fully supported "
"(vk_format={}, requested flags={})",
"(vk_format={}, missing features={})",
static_cast<u32>(format.data_format),
static_cast<u32>(format.number_format), vk::to_string(format.vk_format),
vk::to_string(format.flags));
vk::to_string(format.flags & ~GetFormatFeatureFlags(format.vk_format)));
}
}
for (const auto& format : LiverpoolToVK::DepthFormats()) {
if (!IsFormatSupported(GetSupportedFormat(format.vk_format, format.flags), format.flags)) {
if (!IsFormatSupported(format.vk_format, format.flags)) {
LOG_WARNING(Render_Vulkan,
"Depth format z_format={}, stencil_format={} is not fully supported "
"(vk_format={}, requested flags={})",
"(vk_format={}, missing features={})",
static_cast<u32>(format.z_format), static_cast<u32>(format.stencil_format),
vk::to_string(format.vk_format), vk::to_string(format.flags));
vk::to_string(format.vk_format),
vk::to_string(format.flags & ~GetFormatFeatureFlags(format.vk_format)));
}
}
}
Expand Down Expand Up @@ -546,18 +547,21 @@ void Instance::CollectToolingInfo() {
}
}

bool Instance::IsFormatSupported(const vk::Format format,
const vk::FormatFeatureFlags2 flags) const {
if (format == vk::Format::eUndefined) [[unlikely]] {
return true;
}

vk::FormatFeatureFlags2 Instance::GetFormatFeatureFlags(vk::Format format) const {
const auto it = format_properties.find(format);
if (it == format_properties.end()) {
UNIMPLEMENTED_MSG("Properties of format {} have not been queried.", vk::to_string(format));
}

return ((it->second.optimalTilingFeatures | it->second.bufferFeatures) & flags) == flags;
return it->second.optimalTilingFeatures | it->second.bufferFeatures;
}

bool Instance::IsFormatSupported(const vk::Format format,
const vk::FormatFeatureFlags2 flags) const {
if (format == vk::Format::eUndefined) [[unlikely]] {
return true;
}
return (GetFormatFeatureFlags(format) & flags) == flags;
}

static vk::Format GetAlternativeFormat(const vk::Format format) {
Expand Down
3 changes: 3 additions & 0 deletions src/video_core/renderer_vulkan/vk_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ class Instance {
void CollectDeviceParameters();
void CollectToolingInfo();

/// Gets the supported feature flags for a format.
[[nodiscard]] vk::FormatFeatureFlags2 GetFormatFeatureFlags(vk::Format format) const;

/// Determines if a format is supported for a set of feature flags.
[[nodiscard]] bool IsFormatSupported(vk::Format format, vk::FormatFeatureFlags2 flags) const;

Expand Down

0 comments on commit d202dee

Please sign in to comment.