mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-15 21:58:56 +02:00
[*] 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:
parent
0f8b35c4cd
commit
a8093c2a3c
87 changed files with 368 additions and 254 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue