[*] change all std::unordered_map and std::unordered_set into ankerl::unordered_dense::map/set variants (#3442)

mainly doing this to reduce memory footprint; we all know how nice ankerl::unordered_dense is

in theory 4x faster - in practice these maps arent that "hot" anyways so not likely to have much perf gained

i just want to reduce mem fragmentation to ease my porting process, plus it helps other platforms as well (ahem weak Mediatek devices) :)

Signed-off-by: lizzie <lizzie@eden-emu.dev>

Co-authored-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3442
Reviewed-by: DraVee <dravee@eden-emu.dev>
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2026-02-10 03:34:07 +01:00 committed by crueter
parent 0f8b35c4cd
commit a8093c2a3c
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
87 changed files with 368 additions and 254 deletions

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
@ -14,7 +14,7 @@
#include <mutex>
#include <numeric>
#include <span>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/common_types.h"

View file

@ -11,7 +11,7 @@
#include <deque>
#include <limits>
#include <type_traits>
#include <unordered_set>
#include <ankerl/unordered_dense.h>
#include <utility>
#include "common/alignment.h"
@ -257,7 +257,7 @@ private:
std::array<Manager*, NUM_HIGH_PAGES> top_tier{};
std::deque<std::array<Manager, MANAGER_POOL_SIZE>> manager_pool;
std::deque<Manager*> free_managers;
std::unordered_set<u32> cached_pages;
ankerl::unordered_dense::set<u32> cached_pages;
DeviceTracker* device_tracker = nullptr;
};

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
@ -10,7 +10,7 @@
#include <limits>
#include <mutex>
#include <optional>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/common_types.h"
@ -88,14 +88,14 @@ protected:
std::deque<P> channel_storage;
std::deque<size_t> free_channel_ids;
std::unordered_map<s32, size_t> channel_map;
ankerl::unordered_dense::map<s32, size_t> channel_map;
std::vector<size_t> active_channel_ids;
struct AddressSpaceRef {
size_t ref_count;
size_t storage_id;
Tegra::MemoryManager* gpu_memory;
};
std::unordered_map<size_t, AddressSpaceRef> address_spaces;
ankerl::unordered_dense::map<size_t, AddressSpaceRef> address_spaces;
mutable std::mutex config_mutex;
virtual void OnGPUASRegister([[maybe_unused]] size_t map_id) {}

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
@ -5,7 +8,7 @@
#include <memory>
#include <mutex>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include "video_core/dma_pusher.h"
@ -27,7 +30,7 @@ public:
void DeclareChannel(std::shared_ptr<ChannelState> new_channel);
private:
std::unordered_map<s32, std::shared_ptr<ChannelState>> channels;
ankerl::unordered_dense::map<s32, std::shared_ptr<ChannelState>> channels;
std::mutex scheduling_guard;
GPU& gpu;
};

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
@ -3056,7 +3056,7 @@ public:
void SetHLEReplacementAttributeType(u32 bank, u32 offset, HLEReplacementAttributeType name);
std::unordered_map<u64, HLEReplacementAttributeType> replace_table;
ankerl::unordered_dense::map<u64, HLEReplacementAttributeType> replace_table;
static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size");
static_assert(std::is_trivially_copyable_v<Regs>, "Maxwell3D Regs must be trivially copyable");

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
@ -7,7 +7,7 @@
#include <array>
#include <cmath>
#include <span>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <bit>
#include <numeric>
#include "common/assert.h"
@ -924,7 +924,7 @@ public:
};
struct ConverterFactory::ConverterFactoryImpl {
std::unordered_map<RenderTargetFormat, std::unique_ptr<Converter>> converters_cache;
ankerl::unordered_dense::map<RenderTargetFormat, std::unique_ptr<Converter>> converters_cache;
};
ConverterFactory::ConverterFactory() {

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
@ -373,7 +373,7 @@ struct GPU::Impl {
std::unique_ptr<Core::Frontend::GraphicsContext> cpu_context;
std::unique_ptr<Tegra::Control::Scheduler> scheduler;
std::unordered_map<s32, std::shared_ptr<Tegra::Control::ChannelState>> channels;
ankerl::unordered_dense::map<s32, std::shared_ptr<Tegra::Control::ChannelState>> channels;
Tegra::Control::ChannelState* current_channel;
s32 bound_channel{-1};

View file

@ -10,7 +10,7 @@
#include <set>
#include <span>
#include <string>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/common_types.h"
@ -154,7 +154,7 @@ private:
mutable std::mutex ring_buffer_mutex;
// Memory tracking
std::unordered_map<uintptr_t, MemoryAllocationEntry> memory_allocations;
ankerl::unordered_dense::map<uintptr_t, MemoryAllocationEntry> memory_allocations;
mutable std::mutex memory_mutex;
// Statistics

5
src/video_core/host1x/codecs/decoder.h Executable file → Normal file
View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -7,7 +10,7 @@
#include <mutex>
#include <optional>
#include <string_view>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <queue>
#include "common/common_types.h"

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2021 yuzu Emulator Project
@ -6,8 +6,8 @@
#pragma once
#include <ankerl/unordered_dense.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include "common/common_types.h"
@ -134,15 +134,15 @@ private:
if (it == map->second.end()) {
return {};
}
// TODO: this "mapped" prevents us from fully embracing ankerl
return std::move(map->second.extract(it).mapped());
}
using FramePtr = std::shared_ptr<FFmpeg::Frame>;
std::mutex m_mutex{};
std::unordered_map<s32, std::deque<std::pair<u64, FramePtr>>> m_presentation_order;
std::unordered_map<s32, std::unordered_map<u64, FramePtr>> m_decode_order;
ankerl::unordered_dense::map<s32, std::deque<std::pair<u64, FramePtr>>> m_presentation_order;
ankerl::unordered_dense::map<s32, std::unordered_map<u64, FramePtr>> m_decode_order;
static constexpr size_t MAX_PRESENT_QUEUE = 100;
static constexpr size_t MAX_DECODE_MAP = 200;
@ -218,7 +218,7 @@ private:
Tegra::MemoryManager gmmu_manager;
std::unique_ptr<Common::FlatAllocator<u32, 0, 32>> allocator;
FrameQueue frame_queue;
std::unordered_map<s32, std::unique_ptr<CDmaPusher>> devices;
ankerl::unordered_dense::map<s32, std::unique_ptr<CDmaPusher>> devices;
#ifdef YUZU_LEGACY
std::once_flag nvdec_first_init;
std::once_flag vic_first_init;

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
@ -7,7 +7,7 @@
#pragma once
#include <memory>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/bit_field.h"
#include "common/common_types.h"
@ -147,8 +147,8 @@ private:
bool has_hle_program{};
};
std::unordered_map<u32, CacheInfo> macro_cache;
std::unordered_map<u32, std::vector<u32>> uploaded_macro_code;
ankerl::unordered_dense::map<u32, CacheInfo> macro_cache;
ankerl::unordered_dense::map<u32, std::vector<u32>> uploaded_macro_code;
std::optional<HLEMacro> hle_macros;
Engines::Maxwell3D& maxwell3d;
bool is_interpreted;

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -12,8 +15,7 @@
#include <memory>
#include <mutex>
#include <optional>
#include <unordered_map>
#include <unordered_set>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/assert.h"
@ -348,7 +350,7 @@ private:
mutable std::recursive_mutex mutex;
std::unordered_map<u64, std::vector<CachedQuery>> cached_queries;
ankerl::unordered_dense::map<u64, std::vector<CachedQuery>> cached_queries;
std::array<CounterStream, VideoCore::NumQueryTypes> streams;

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
@ -10,7 +10,7 @@
#include <deque>
#include <memory>
#include <mutex>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <utility>
#include "common/assert.h"

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
@ -7,7 +10,7 @@
#include <mutex>
#include <optional>
#include <span>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <utility>
#include "common/assert.h"
@ -157,7 +160,7 @@ protected:
}
}
using ContentCache = std::unordered_map<u64, std::unordered_map<u32, QueryLocation>>;
using ContentCache = ankerl::unordered_dense::map<u64, ankerl::unordered_dense::map<u32, QueryLocation>>;
void InvalidateQuery(QueryLocation location);
bool IsQueryDirty(QueryLocation location);
@ -165,7 +168,7 @@ protected:
void RequestGuestHostSync();
void UnregisterPending();
std::unordered_map<u64, std::unordered_map<u32, QueryLocation>> cached_queries;
ankerl::unordered_dense::map<u64, ankerl::unordered_dense::map<u32, QueryLocation>> cached_queries;
std::mutex cache_mutex;
struct QueryCacheBaseImpl;

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
@ -8,7 +8,7 @@
#include <array>
#include <span>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include "common/common_types.h"
#include "video_core/buffer_cache/buffer_cache_base.h"
@ -242,7 +242,7 @@ private:
u32 index_buffer_offset = 0;
u64 device_access_memory;
std::unordered_map<GPUVAddr, OGLTransformFeedback> tfb_objects;
ankerl::unordered_dense::map<GPUVAddr, OGLTransformFeedback> tfb_objects;
};
struct BufferCacheParams {

View file

@ -1,10 +1,13 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <filesystem>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include "common/common_types.h"
#include "common/thread_worker.h"
@ -79,8 +82,8 @@ private:
GraphicsPipeline* current_pipeline{};
ShaderContext::ShaderPools main_pools;
std::unordered_map<GraphicsPipelineKey, std::unique_ptr<GraphicsPipeline>> graphics_cache;
std::unordered_map<ComputePipelineKey, std::unique_ptr<ComputePipeline>> compute_cache;
ankerl::unordered_dense::map<GraphicsPipelineKey, std::unique_ptr<GraphicsPipeline>> graphics_cache;
ankerl::unordered_dense::map<ComputePipelineKey, std::unique_ptr<ComputePipeline>> compute_cache;
Shader::Profile profile;
Shader::HostTranslateInfo host_info;

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
@ -157,7 +157,7 @@ private:
UtilShaders util_shaders;
FormatConversionPass format_conversion_pass;
std::array<std::unordered_map<GLenum, FormatProperties>, 3> format_properties;
std::array<ankerl::unordered_dense::map<GLenum, FormatProperties>, 3> format_properties;
bool has_broken_texture_view_formats = false;
OGLTexture null_image_1d_array;

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -8,7 +11,7 @@
#include <filesystem>
#include <memory>
#include <type_traits>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/common_types.h"
@ -155,8 +158,8 @@ private:
GraphicsPipelineCacheKey graphics_key{};
GraphicsPipeline* current_pipeline{};
std::unordered_map<ComputePipelineCacheKey, std::unique_ptr<ComputePipeline>> compute_cache;
std::unordered_map<GraphicsPipelineCacheKey, std::unique_ptr<GraphicsPipeline>> graphics_cache;
ankerl::unordered_dense::map<ComputePipelineCacheKey, std::unique_ptr<ComputePipeline>> compute_cache;
ankerl::unordered_dense::map<GraphicsPipelineCacheKey, std::unique_ptr<GraphicsPipeline>> graphics_cache;
ShaderPools main_pools;

View file

@ -10,7 +10,7 @@
#include <memory>
#include <span>
#include <type_traits>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <utility>
#include <vector>
#include "video_core/renderer_vulkan/vk_texture_cache.h"
@ -230,7 +230,7 @@ public:
sync_values_stash.emplace_back();
std::vector<HostSyncValues>* sync_values = &sync_values_stash.back();
sync_values->reserve(num_slots_used);
std::unordered_map<size_t, std::pair<size_t, size_t>> offsets;
ankerl::unordered_dense::map<size_t, std::pair<size_t, size_t>> offsets;
resolve_buffers.clear();
size_t resolve_buffer_index = ObtainBuffer<true>(num_slots_used);
resolve_buffers.push_back(resolve_buffer_index);
@ -412,7 +412,7 @@ private:
template <bool is_ordered, typename Func>
void ApplyBanksWideOp(std::vector<size_t>& queries, Func&& func) {
std::conditional_t<is_ordered, std::map<size_t, std::pair<size_t, size_t>>,
std::unordered_map<size_t, std::pair<size_t, size_t>>>
ankerl::unordered_dense::map<size_t, std::pair<size_t, size_t>>>
indexer;
for (auto q : queries) {
auto* query = GetQuery(q);
@ -722,7 +722,7 @@ public:
void SyncWrites() override {
CloseCounter();
std::unordered_map<size_t, std::vector<HostSyncValues>> sync_values_stash;
ankerl::unordered_dense::map<size_t, std::vector<HostSyncValues>> sync_values_stash;
for (auto q : pending_sync) {
auto* query = GetQuery(q);
if (True(query->flags & VideoCommon::QueryFlagBits::IsRewritten)) {

View file

@ -4,7 +4,7 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <boost/container/static_vector.hpp>

View file

@ -1,10 +1,13 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <mutex>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include "video_core/surface.h"
#include "video_core/vulkan_common/vulkan_wrapper.h"
@ -47,7 +50,7 @@ public:
private:
const Device* device{};
std::unordered_map<RenderPassKey, vk::RenderPass> cache;
ankerl::unordered_dense::map<RenderPassKey, vk::RenderPass> cache;
std::mutex mutex;
};

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
@ -10,7 +10,7 @@
#include <memory>
#include <mutex>
#include <span>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <utility>
#include <vector>
@ -148,8 +148,8 @@ private:
mutable std::mutex lookup_mutex;
std::mutex invalidation_mutex;
std::unordered_map<u64, std::unique_ptr<Entry>> lookup_cache;
std::unordered_map<u64, std::vector<Entry*>> invalidation_cache;
ankerl::unordered_dense::map<u64, std::unique_ptr<Entry>> lookup_cache;
ankerl::unordered_dense::map<u64, std::vector<Entry*>> invalidation_cache;
std::vector<std::unique_ptr<ShaderInfo>> storage;
std::vector<Entry*> marked_for_removal;
};

View file

@ -14,7 +14,7 @@
#include <optional>
#include <span>
#include <type_traits>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/common_types.h"
@ -79,10 +79,10 @@ protected:
GPUVAddr program_base{};
std::vector<u64> code;
std::unordered_map<u32, Shader::TextureType> texture_types;
std::unordered_map<u32, Shader::TexturePixelFormat> texture_pixel_formats;
std::unordered_map<u64, u32> cbuf_values;
std::unordered_map<u64, Shader::ReplaceConstant> cbuf_replacements;
ankerl::unordered_dense::map<u32, Shader::TextureType> texture_types;
ankerl::unordered_dense::map<u32, Shader::TexturePixelFormat> texture_pixel_formats;
ankerl::unordered_dense::map<u64, u32> cbuf_values;
ankerl::unordered_dense::map<u64, Shader::ReplaceConstant> cbuf_replacements;
u32 local_memory_size{};
u32 texture_bound{};
@ -201,10 +201,10 @@ public:
private:
std::vector<u64> code;
std::unordered_map<u32, Shader::TextureType> texture_types;
std::unordered_map<u32, Shader::TexturePixelFormat> texture_pixel_formats;
std::unordered_map<u64, u32> cbuf_values;
std::unordered_map<u64, Shader::ReplaceConstant> cbuf_replacements;
ankerl::unordered_dense::map<u32, Shader::TextureType> texture_types;
ankerl::unordered_dense::map<u32, Shader::TexturePixelFormat> texture_pixel_formats;
ankerl::unordered_dense::map<u64, u32> cbuf_values;
ankerl::unordered_dense::map<u64, Shader::ReplaceConstant> cbuf_replacements;
std::array<u32, 3> workgroup_size{};
u32 local_memory_size{};
u32 shared_memory_size{};

View file

@ -9,7 +9,7 @@
#include <limits>
#include <optional>
#include <bit>
#include <unordered_set>
#include <ankerl/unordered_dense.h>
#include <boost/container/small_vector.hpp>
#include "common/alignment.h"
@ -1989,8 +1989,8 @@ SamplerId TextureCache<P>::FindSampler(const TSCEntry& config) {
}
const auto [pair, is_new] = channel_state->samplers.try_emplace(config);
if (is_new) {
EnforceSamplerBudget();
pair->second = slot_samplers.insert(runtime, config);
EnforceSamplerBudget();
}
return pair->second;
}
@ -2035,7 +2035,7 @@ void TextureCache<P>::TrimInactiveSamplers(size_t budget) {
}
set.insert(id);
};
std::unordered_set<SamplerId> active;
ankerl::unordered_dense::set<SamplerId> active;
active.reserve(channel_state->graphics_sampler_ids.size() +
channel_state->compute_sampler_ids.size());
for (const SamplerId id : channel_state->graphics_sampler_ids) {
@ -2363,9 +2363,7 @@ void TextureCache<P>::UnregisterImage(ImageId image_id) {
image.flags &= ~ImageFlagBits::BadOverlap;
lru_cache.Free(image.lru_index);
const auto& clear_page_table =
[image_id](u64 page,
std::unordered_map<u64, std::vector<ImageId>, Common::IdentityHash<u64>>&
selected_page_table) {
[image_id](u64 page, ankerl::unordered_dense::map<u64, std::vector<ImageId>, Common::IdentityHash<u64>>& selected_page_table) {
const auto page_it = selected_page_table.find(page);
if (page_it == selected_page_table.end()) {
ASSERT_MSG(false, "Unregistering unregistered page=0x{:x}", page << YUZU_PAGEBITS);

View file

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
@ -12,8 +12,9 @@
#include <mutex>
#include <span>
#include <type_traits>
// TODO: find out which don't require stable iters
#include <unordered_map>
#include <unordered_set>
#include <ankerl/unordered_dense.h>
#include <vector>
#include <boost/container/small_vector.hpp>
#include <queue>
@ -66,7 +67,7 @@ struct AsyncDecodeContext {
std::atomic_bool complete;
};
using TextureCacheGPUMap = std::unordered_map<u64, std::vector<ImageId>, Common::IdentityHash<u64>>;
using TextureCacheGPUMap = ankerl::unordered_dense::map<u64, std::vector<ImageId>, Common::IdentityHash<u64>>;
class TextureCacheChannelInfo : public ChannelInfo {
public:
@ -85,6 +86,7 @@ public:
std::vector<SamplerId> compute_sampler_ids;
std::vector<ImageViewId> compute_image_view_ids;
// TODO: still relies on bad iterators :(
std::unordered_map<TICEntry, ImageViewId> image_views;
std::unordered_map<TSCEntry, SamplerId> samplers;
@ -454,10 +456,9 @@ private:
RenderTargets render_targets;
std::unordered_map<RenderTargets, FramebufferId> framebuffers;
std::unordered_map<u64, std::vector<ImageMapId>, Common::IdentityHash<u64>> page_table;
std::unordered_map<ImageId, boost::container::small_vector<ImageViewId, 16>> sparse_views;
ankerl::unordered_dense::map<RenderTargets, FramebufferId> framebuffers;
ankerl::unordered_dense::map<u64, std::vector<ImageMapId>, Common::IdentityHash<u64>> page_table;
ankerl::unordered_dense::map<ImageId, boost::container::small_vector<ImageViewId, 16>> sparse_views;
DAddr virtual_invalid_space{};
@ -514,7 +515,7 @@ private:
DelayedDestructionRing<ImageView, TICKS_TO_DESTROY> sentenced_image_view;
DelayedDestructionRing<Framebuffer, TICKS_TO_DESTROY> sentenced_framebuffers;
std::unordered_map<GPUVAddr, ImageAllocId> image_allocs_table;
ankerl::unordered_dense::map<GPUVAddr, ImageAllocId> image_allocs_table;
Common::ScratchBuffer<u8> swizzle_data_buffer;
Common::ScratchBuffer<u8> unswizzle_data_buffer;
@ -531,17 +532,17 @@ private:
// Join caching
boost::container::small_vector<ImageId, 4> join_overlap_ids;
std::unordered_set<ImageId> join_overlaps_found;
ankerl::unordered_dense::set<ImageId> join_overlaps_found;
boost::container::small_vector<ImageId, 4> join_left_aliased_ids;
boost::container::small_vector<ImageId, 4> join_right_aliased_ids;
std::unordered_set<ImageId> join_ignore_textures;
ankerl::unordered_dense::set<ImageId> join_ignore_textures;
boost::container::small_vector<ImageId, 4> join_bad_overlap_ids;
struct JoinCopy {
bool is_alias;
ImageId id;
};
boost::container::small_vector<JoinCopy, 4> join_copies_to_do;
std::unordered_map<ImageId, size_t> join_alias_indices;
ankerl::unordered_dense::map<ImageId, size_t> join_alias_indices;
};
} // namespace VideoCommon

View file

@ -9,7 +9,7 @@
#include <chrono>
#include <optional>
#include <thread>
#include <unordered_set>
#include <ankerl/unordered_dense.h>
#include <utility>
#include <vector>
@ -145,7 +145,7 @@ VkFormatFeatureFlags GetFormatFeatures(VkFormatProperties properties, FormatType
}
}
std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(vk::PhysicalDevice physical) {
ankerl::unordered_dense::map<VkFormat, VkFormatProperties> GetFormatProperties(vk::PhysicalDevice physical) {
static constexpr std::array formats{
VK_FORMAT_A1R5G5B5_UNORM_PACK16,
VK_FORMAT_A2B10G10R10_SINT_PACK32,
@ -287,7 +287,7 @@ std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(vk::Physica
VK_FORMAT_R8_USCALED,
VK_FORMAT_S8_UINT,
};
std::unordered_map<VkFormat, VkFormatProperties> format_properties;
ankerl::unordered_dense::map<VkFormat, VkFormatProperties> format_properties;
for (const auto format : formats) {
format_properties.emplace(format, physical.GetFormatProperties(format));
}
@ -295,7 +295,7 @@ std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(vk::Physica
}
#if defined(ANDROID) && defined(ARCHITECTURE_arm64)
void OverrideBcnFormats(std::unordered_map<VkFormat, VkFormatProperties>& format_properties) {
void OverrideBcnFormats(ankerl::unordered_dense::map<VkFormat, VkFormatProperties>& format_properties) {
// These properties are extracted from Adreno driver 512.687.0
constexpr VkFormatFeatureFlags tiling_features{VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
VK_FORMAT_FEATURE_BLIT_SRC_BIT |
@ -1612,7 +1612,7 @@ void Device::CollectToolingInfo() {
std::vector<VkDeviceQueueCreateInfo> Device::GetDeviceQueueCreateInfos() const {
static constexpr float QUEUE_PRIORITY = 1.0f;
std::unordered_set<u32> unique_queue_families{graphics_family, present_family};
ankerl::unordered_dense::set<u32> unique_queue_families{graphics_family, present_family};
std::vector<VkDeviceQueueCreateInfo> queue_cis;
queue_cis.reserve(unique_queue_families.size());

View file

@ -10,7 +10,7 @@
#include <set>
#include <span>
#include <string>
#include <unordered_map>
#include <ankerl/unordered_dense.h>
#include <vector>
#include "common/common_types.h"
@ -1074,7 +1074,7 @@ private:
std::vector<size_t> valid_heap_memory; ///< Heaps used.
/// Format properties dictionary.
std::unordered_map<VkFormat, VkFormatProperties> format_properties;
ankerl::unordered_dense::map<VkFormat, VkFormatProperties> format_properties;
/// Nsight Aftermath GPU crash tracker
std::unique_ptr<NsightAftermathTracker> nsight_aftermath_tracker;