Skip to content

Commit

Permalink
Replace pmr maps with unordered_maps
Browse files Browse the repository at this point in the history
  • Loading branch information
guusw committed Feb 21, 2023
1 parent 17d7028 commit ca9389e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/gfx/drawable_processors/mesh_drawable_processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../texture_placeholder.hpp"
#include "drawable_processor_helpers.hpp"
#include "pmr/list.hpp"
#include "pmr/unordered_map.hpp"
#include "texture_cache.hpp"
#include "worker_memory.hpp"
#include <tracy/Tracy.hpp>
Expand Down Expand Up @@ -417,9 +418,9 @@ struct MeshDrawableProcessor final : public IDrawableProcessor {
PreparedGroupData &preparedGroupData = prepareData->groups.value();
WGPUBindGroupLayout drawBindGroupLayout = cachedPipeline.bindGroupLayouts[PipelineBuilder::getDrawBindGroupIndex()];

auto cachedBindGroups = allocator->new_object<shards::pmr::map<Hash128, WGPUBindGroup>>();
auto cachedBindGroups = allocator->new_object<shards::pmr::unordered_map<Hash128, WGPUBindGroup>>();
for (size_t index = 0; index < preparedGroupData.groups.size(); ++index) {
shards::pmr::map<Hash128, WGPUBindGroup> &cache = *cachedBindGroups;
shards::pmr::unordered_map<Hash128, WGPUBindGroup> &cache = *cachedBindGroups;

auto &group = preparedGroupData.groups[index];
auto &groupData = preparedGroupData.groupData[index];
Expand Down
17 changes: 12 additions & 5 deletions src/gfx/renderer_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
#include "sized_item_pool.hpp"
#include "worker_memory.hpp"
#include "pmr/wrapper.hpp"
#include "pmr/map.hpp"
#include "pmr/unordered_map.hpp"
#include "pmr/string.hpp"
#include <cassert>
#include <functional>
#include <memory>
#include <string_view>
#include <vector>
#include <map>
#include <compare>
Expand Down Expand Up @@ -119,15 +121,20 @@ struct RenderTargetLayout {
struct ParameterStorage final : public IParameterCollector {
using allocator_type = shards::pmr::PolymorphicAllocator<>;

struct KeyLess {
struct KeyEqual {
using is_transparent = std::true_type;
template <typename T, typename U> bool operator()(const T &a, const U &b) const {
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end());
return std::string_view(a) == std::string_view(b);
}
};

shards::pmr::map<shards::pmr::string, ParamVariant, KeyLess> basic;
shards::pmr::map<shards::pmr::string, TextureParameter, KeyLess> textures;
struct KeyHash {
using is_transparent = std::true_type;
template <typename U> size_t operator()(const U &b) const { return std::hash<U>{}(b); }
};

shards::pmr::unordered_map<shards::pmr::string, ParamVariant, KeyHash, KeyEqual> basic;
shards::pmr::unordered_map<shards::pmr::string, TextureParameter, KeyHash, KeyEqual> textures;

using IParameterCollector::setParam;
using IParameterCollector::setTexture;
Expand Down

0 comments on commit ca9389e

Please sign in to comment.