mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-06-05 17:57:14 +02:00
[vk] Ordering UnsupportedFormatKey
This commit is contained in:
parent
3dee74854a
commit
8f41711ea9
1 changed files with 39 additions and 8 deletions
|
|
@ -7,6 +7,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <mutex>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <ankerl/unordered_dense.h>
|
#include <ankerl/unordered_dense.h>
|
||||||
|
|
@ -116,6 +117,32 @@ constexpr std::array R16G16B16A16_UNORM{
|
||||||
|
|
||||||
} // namespace Alternatives
|
} // namespace Alternatives
|
||||||
|
|
||||||
|
struct UnsupportedFormatKey {
|
||||||
|
VkFormat format;
|
||||||
|
VkFormatFeatureFlags usage;
|
||||||
|
FormatType type;
|
||||||
|
|
||||||
|
bool operator==(const UnsupportedFormatKey&) const noexcept = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UnsupportedFormatKeyHash {
|
||||||
|
size_t operator()(const UnsupportedFormatKey& key) const noexcept {
|
||||||
|
size_t seed = std::hash<int>{}(static_cast<int>(key.format));
|
||||||
|
seed ^= static_cast<size_t>(key.usage) + 0x9e3779b97f4a7c15ULL + (seed << 6) + (seed >> 2);
|
||||||
|
seed ^= static_cast<size_t>(key.type) + 0x9e3779b97f4a7c15ULL + (seed << 6) + (seed >> 2);
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool ShouldLogUnsupportedFormat(VkFormat format, VkFormatFeatureFlags usage, FormatType type) {
|
||||||
|
static std::mutex mutex;
|
||||||
|
static std::unordered_set<UnsupportedFormatKey, UnsupportedFormatKeyHash> logged_keys;
|
||||||
|
const UnsupportedFormatKey key{format, usage, type};
|
||||||
|
std::scoped_lock lock{mutex};
|
||||||
|
const auto [it, inserted] = logged_keys.insert(key);
|
||||||
|
return inserted;
|
||||||
|
}
|
||||||
|
|
||||||
[[maybe_unused]] constexpr VkShaderStageFlags GraphicsStageMask =
|
[[maybe_unused]] constexpr VkShaderStageFlags GraphicsStageMask =
|
||||||
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT |
|
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT |
|
||||||
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT | VK_SHADER_STAGE_GEOMETRY_BIT |
|
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT | VK_SHADER_STAGE_GEOMETRY_BIT |
|
||||||
|
|
@ -818,10 +845,12 @@ VkFormat Device::GetSupportedFormat(VkFormat wanted_format, VkFormatFeatureFlags
|
||||||
|
|
||||||
const VkFormat* alternatives = GetFormatAlternatives(wanted_format);
|
const VkFormat* alternatives = GetFormatAlternatives(wanted_format);
|
||||||
if (alternatives == nullptr) {
|
if (alternatives == nullptr) {
|
||||||
LOG_ERROR(Render_Vulkan,
|
if (ShouldLogUnsupportedFormat(wanted_format, wanted_usage, format_type)) {
|
||||||
"Format={} with usage={} and type={} has no defined alternatives and host "
|
LOG_ERROR(Render_Vulkan,
|
||||||
"hardware does not support it",
|
"Format={} with usage={} and type={} has no defined alternatives and host "
|
||||||
wanted_format, wanted_usage, format_type);
|
"hardware does not support it",
|
||||||
|
wanted_format, wanted_usage, format_type);
|
||||||
|
}
|
||||||
return wanted_format;
|
return wanted_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -864,10 +893,12 @@ VkFormat Device::GetSupportedFormat(VkFormat wanted_format, VkFormatFeatureFlags
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_ERROR(Render_Vulkan,
|
if (ShouldLogUnsupportedFormat(wanted_format, wanted_usage, format_type)) {
|
||||||
"Format={} with usage={} and type={} is not supported by the host hardware and "
|
LOG_ERROR(Render_Vulkan,
|
||||||
"doesn't support any of the alternatives",
|
"Format={} with usage={} and type={} is not supported by the host hardware and "
|
||||||
wanted_format, wanted_usage, format_type);
|
"doesn't support any of the alternatives",
|
||||||
|
wanted_format, wanted_usage, format_type);
|
||||||
|
}
|
||||||
return wanted_format;
|
return wanted_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue