|
|
|
@ -9,6 +9,7 @@ |
|
|
|
#include <mutex> |
|
|
|
#include <ankerl/unordered_dense.h> |
|
|
|
|
|
|
|
#include "common/container_hash.h" |
|
|
|
#include "video_core/surface.h" |
|
|
|
#include "video_core/vulkan_common/vulkan_wrapper.h" |
|
|
|
|
|
|
|
@ -31,17 +32,26 @@ struct RenderPassKey { |
|
|
|
namespace std { |
|
|
|
template <> |
|
|
|
struct hash<Vulkan::RenderPassKey> { |
|
|
|
static_assert(std::tuple_size_v<decltype(Vulkan::RenderPassKey::color_formats)> <= 8); |
|
|
|
static_assert(static_cast<u32>(VideoCore::Surface::PixelFormat::Invalid) <= 0xFF); |
|
|
|
static_assert(static_cast<u32>(VideoCore::Surface::PixelFormat::Max) <= 0xFF); |
|
|
|
static_assert(VK_SAMPLE_COUNT_64_BIT <= 0xFF); |
|
|
|
|
|
|
|
[[nodiscard]] size_t operator()(const Vulkan::RenderPassKey& key) const noexcept { |
|
|
|
size_t value = static_cast<size_t>(key.depth_format) << 48; |
|
|
|
value ^= static_cast<size_t>(key.samples) << 52; |
|
|
|
value ^= static_cast<size_t>(key.resolve_color) << 63; |
|
|
|
value ^= static_cast<size_t>(key.color_clear_mask) << 54; |
|
|
|
value ^= static_cast<size_t>(key.depth_stencil_clear) << 62; |
|
|
|
value ^= static_cast<size_t>(key.color_discard_mask) << 24; |
|
|
|
for (size_t i = 0; i < key.color_formats.size(); ++i) { |
|
|
|
value ^= static_cast<size_t>(key.color_formats[i]) << (i * 6); |
|
|
|
u64 formats = 0; |
|
|
|
for (size_t index = 0; index < key.color_formats.size(); ++index) { |
|
|
|
formats |= static_cast<u64>(key.color_formats[index]) << (index * 8); |
|
|
|
} |
|
|
|
return value; |
|
|
|
const u64 state = static_cast<u64>(key.depth_format) | |
|
|
|
(static_cast<u64>(key.samples) << 8) | |
|
|
|
(static_cast<u64>(key.color_clear_mask) << 16) | |
|
|
|
(static_cast<u64>(key.color_discard_mask) << 24) | |
|
|
|
(static_cast<u64>(key.resolve_color) << 32) | |
|
|
|
(static_cast<u64>(key.depth_stencil_clear) << 33); |
|
|
|
size_t seed = 0; |
|
|
|
Common::HashCombine(seed, formats); |
|
|
|
Common::HashCombine(seed, state); |
|
|
|
return seed; |
|
|
|
} |
|
|
|
}; |
|
|
|
} // namespace std |
|
|
|
|