Skip to content

Commit 8f380c9

Browse files
authored
Merge pull request #21 from aaaapai/ankerl
Update AstcDecompressor.cpp
2 parents 7bbe5d2 + a7b2a3e commit 8f380c9

10 files changed

Lines changed: 41 additions & 13 deletions

File tree

include/ankerl/stl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#ifndef ANKERL_STL_H
3030
#define ANKERL_STL_H
3131

32+
#include <cstdlib>
3233
#include <array> // for array
3334
#include <cstdint> // for uint64_t, uint32_t, std::uint8_t, UINT64_C
3435
#include <cstring> // for size_t, memcpy, memset

out/Android-arm64/args.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use_lto = true
4040
angle_build_tests = false
4141

4242
cflags_c = [
43+
"-Wno-unsafe-buffer-usage",
4344
"-Wno-unused-variable",
4445
"-Wno-error=unused-variable",
4546
"-Wno-error",
@@ -81,6 +82,7 @@ cflags_c = [
8182
]
8283

8384
cflags_cc = [
85+
"-Wno-unsafe-buffer-usage",
8486
"-Wno-unused-variable",
8587
"-Wno-error=unused-variable",
8688
"-Wno-error",

src/common/base/anglebase/containers/mru_cache.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#include "anglebase/logging.h"
2929
#include "anglebase/macros.h"
3030

31+
#include <ankerl/stl.h>
32+
#include <ankerl/unordered_dense.h>
33+
3134
namespace angle
3235
{
3336

@@ -247,7 +250,7 @@ class MRUCache : public MRUCacheBase<KeyType, PayloadType, CompareType>
247250
template <class KeyType, class ValueType, class HashType>
248251
struct MRUCacheHashMap
249252
{
250-
typedef std::unordered_map<KeyType, ValueType, HashType> Type;
253+
typedef ankerl::unordered_dense::map<KeyType, ValueType, HashType> Type;
251254
};
252255

253256
// This class is similar to MRUCache, except that it uses std::unordered_map as

src/common/hash_containers.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@
99
#ifndef COMMON_HASH_CONTAINERS_H_
1010
#define COMMON_HASH_CONTAINERS_H_
1111

12+
//#undef ANGLE_USE_ABSEIL // Is ABSEIL faster?
13+
1214
#if defined(ANGLE_USE_ABSEIL)
1315
# include "absl/container/flat_hash_map.h"
1416
# include "absl/container/flat_hash_set.h"
1517
#else
1618
# include <unordered_map>
1719
# include <unordered_set>
20+
# include <ankerl/stl.h>
21+
# include <ankerl/unordered_dense.h>
1822
#endif // defined(ANGLE_USE_ABSEIL)
1923

2024
namespace angle
@@ -38,9 +42,9 @@ template <typename Key,
3842
typename T,
3943
class Hash = std::hash<Key>,
4044
class KeyEqual = std::equal_to<Key>>
41-
using HashMap = std::unordered_map<Key, T, Hash, KeyEqual>;
45+
using HashMap = ankerl::unordered_dense::map<Key, T, Hash, KeyEqual>;
4246
template <typename Key, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
43-
using HashSet = std::unordered_set<Key, Hash, KeyEqual>;
47+
using HashSet = ankerl::unordered_dense::set<Key, Hash, KeyEqual>;
4448
# if __cpp_lib_generic_unordered_lookup >= 201811L
4549
# define ANGLE_HAS_HASH_MAP_GENERIC_LOOKUP 1
4650
# else

src/image_util/AstcDecompressor.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include "common/WorkerThread.h"
1616
#include "image_util/AstcDecompressor.h"
1717

18+
#include <ankerl/stl.h>
19+
#include <ankerl/unordered_dense.h>
20+
1821
namespace angle
1922
{
2023
namespace
@@ -135,7 +138,7 @@ class AstcDecompressorContextCache
135138
}
136139
};
137140

138-
std::unordered_map<Key, Value, KeyHash> mContexts;
141+
ankerl::unordered_dense::map<Key, Value, KeyHash> mContexts;
139142
};
140143

141144
struct DecompressTask : public Closure

src/image_util/storeimage_paletted.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
#include "image_util/imageformats.h"
2121

22+
#include <ankerl/stl.h>
23+
#include <ankerl/unordered_dense.h>
24+
2225
namespace angle
2326
{
2427

@@ -115,7 +118,7 @@ void StoreRGBA8ToPalettedImpl(size_t width,
115118
size_t outputRowPitch,
116119
size_t outputDepthPitch)
117120
{
118-
std::unordered_map<uint32_t, size_t> invPalette;
121+
ankerl::unordered_dense::map<uint32_t, size_t> invPalette;
119122

120123
ASSERT((redBlueBits + greenBits + redBlueBits + alphaBits) % 8 == 0);
121124

src/libANGLE/renderer/vulkan/MemoryTracking.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#include "common/hash_containers.h"
2020
#include "common/vulkan/vk_headers.h"
2121

22+
#include <ankerl/stl.h>
23+
#include <ankerl/unordered_dense.h>
24+
2225
namespace rx
2326
{
2427
namespace vk
@@ -224,7 +227,7 @@ class MemoryAllocationTracker : angle::NonCopyable
224227
// allocation ID and a record of all active allocations.
225228
uint64_t mMemoryAllocationID;
226229
using MemoryAllocInfoMap = angle::HashMap<vk::MemoryAllocInfoMapKey, vk::MemoryAllocationInfo>;
227-
std::unordered_map<angle::BacktraceInfo, MemoryAllocInfoMap> mMemoryAllocationRecord;
230+
ankerl::unordered_dense::map<angle::BacktraceInfo, MemoryAllocInfoMap> mMemoryAllocationRecord;
228231
};
229232
} // namespace rx
230233

src/libANGLE/renderer/vulkan/UtilsVk.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#include "libANGLE/renderer/vulkan/vk_helpers.h"
3434
#include "libANGLE/renderer/vulkan/vk_internal_shaders_autogen.h"
3535

36+
#include <ankerl/stl.h>
37+
#include <ankerl/unordered_dense.h>
38+
3639
namespace rx
3740
{
3841
class UtilsVk : angle::NonCopyable

src/libANGLE/renderer/vulkan/vk_cache_utils.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#include "libANGLE/renderer/vulkan/vk_resource.h"
2727
#include "libANGLE/renderer/vulkan/vk_utils.h"
2828

29+
#include <ankerl/stl.h>
30+
#include <ankerl/unordered_dense.h>
31+
2932
namespace gl
3033
{
3134
class ProgramExecutable;
@@ -2668,8 +2671,8 @@ class RenderPassCache final : angle::NonCopyable
26682671
// Use a two-layer caching scheme. The top level matches the "compatible" RenderPass elements.
26692672
// The second layer caches the attachment load/store ops and initial/final layout.
26702673
// Switch to `std::unordered_map` to retain pointer stability.
2671-
using InnerCache = std::unordered_map<vk::AttachmentOpsArray, vk::RenderPassHelper>;
2672-
using OuterCache = std::unordered_map<vk::RenderPassDesc, InnerCache>;
2674+
using InnerCache = ankerl::unordered_dense::map<vk::AttachmentOpsArray, vk::RenderPassHelper>;
2675+
using OuterCache = ankerl::unordered_dense::map<vk::RenderPassDesc, InnerCache>;
26732676

26742677
OuterCache mPayload;
26752678
CacheStats mCompatibleRenderPassCacheStats;
@@ -2870,7 +2873,7 @@ class DescriptorSetLayoutCache final : angle::NonCopyable
28702873

28712874
private:
28722875
mutable angle::SimpleMutex mMutex;
2873-
std::unordered_map<vk::DescriptorSetLayoutDesc, vk::DescriptorSetLayoutPtr> mPayload;
2876+
ankerl::unordered_dense::map<vk::DescriptorSetLayoutDesc, vk::DescriptorSetLayoutPtr> mPayload;
28742877
CacheStats mCacheStats;
28752878
};
28762879

@@ -2889,7 +2892,7 @@ class PipelineLayoutCache final : public HasCacheStats<VulkanCacheType::Pipeline
28892892

28902893
private:
28912894
mutable angle::SimpleMutex mMutex;
2892-
std::unordered_map<vk::PipelineLayoutDesc, vk::PipelineLayoutPtr> mPayload;
2895+
ankerl::unordered_dense::map<vk::PipelineLayoutDesc, vk::PipelineLayoutPtr> mPayload;
28932896
};
28942897

28952898
class SamplerCache final : public HasCacheStats<VulkanCacheType::Sampler>
@@ -2905,7 +2908,7 @@ class SamplerCache final : public HasCacheStats<VulkanCacheType::Sampler>
29052908
vk::SharedSamplerPtr *samplerOut);
29062909

29072910
private:
2908-
std::unordered_map<vk::SamplerDesc, vk::SharedSamplerPtr> mPayload;
2911+
ankerl::unordered_dense::map<vk::SamplerDesc, vk::SharedSamplerPtr> mPayload;
29092912
};
29102913

29112914
// YuvConversion Cache
@@ -2924,7 +2927,7 @@ class SamplerYcbcrConversionCache final
29242927

29252928
private:
29262929
using SamplerYcbcrConversionMap =
2927-
std::unordered_map<vk::YcbcrConversionDesc, vk::SamplerYcbcrConversion>;
2930+
ankerl::unordered_dense::map<vk::YcbcrConversionDesc, vk::SamplerYcbcrConversion>;
29282931
SamplerYcbcrConversionMap mExternalFormatPayload;
29292932
SamplerYcbcrConversionMap mVkFormatPayload;
29302933
};

src/libANGLE/renderer/vulkan/vk_helpers.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424

2525
#include <functional>
2626

27+
#include <ankerl/stl.h>
28+
#include <ankerl/unordered_dense.h>
29+
2730
namespace gl
2831
{
2932
class ImageIndex;
@@ -476,7 +479,7 @@ class MetaDescriptorPool final : angle::NonCopyable
476479
}
477480

478481
private:
479-
std::unordered_map<DescriptorSetLayoutDesc, DynamicDescriptorPoolPointer> mPayload;
482+
ankerl::unordered_dense::map<DescriptorSetLayoutDesc, DynamicDescriptorPoolPointer> mPayload;
480483
};
481484

482485
template <typename Pool>

0 commit comments

Comments
 (0)