Commit e78d9a61 by Tim Van Patten Committed by Commit Bot

Convert unordered_map to absl::flat_hash_map for select files

This is the initial CL to start migrating to abseil in various places: - formatutils.h - FramebufferVk.h - Program.h - ProgramExecutableVk.h - RewriteRowMajorMatrices.cpp This intentionally hits a couple different places in the code to make sure the abseil dependencies are added to the required targets. Bug: angleproject:4873 Change-Id: Idd6084dff2ebce47833f304c605bbf3151b97414 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2402382 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCharlie Lao <cclao@google.com>
parent b6c17996
......@@ -36,6 +36,10 @@ declare_args() {
# Enable generating current commit information using git
angle_enable_commit_id = true
# Abseil has trouble supporting MSVC, particularly regarding component builds.
# http://crbug.com/1126524
angle_enable_abseil = angle_has_build && is_clang
}
if (angle_build_all) {
......@@ -298,6 +302,7 @@ angle_static_library("angle_common") {
deps = [ ":xxhash" ]
public_deps = [
":angle_abseil",
":angle_system_utils",
":angle_version",
":includes",
......@@ -739,6 +744,31 @@ angle_source_set("angle_gl_enum_utils") {
]
}
if (!defined(angle_abseil_cpp_dir)) {
angle_abseil_cpp_dir = "//third_party/abseil-cpp"
}
config("angle_abseil_config") {
defines = [ "ANGLE_USE_ABSEIL" ]
configs = [
"$angle_abseil_cpp_dir:absl_define_config",
"$angle_abseil_cpp_dir:absl_include_config",
]
}
group("angle_abseil") {
# When build_with_chromium=true we need to include "//third_party/abseil-cpp:absl" while
# we can be more specific when building standalone ANGLE.
if (build_with_chromium) {
public_deps = [ "$angle_abseil_cpp_dir:absl" ]
} else {
public_deps = [ "$angle_abseil_cpp_dir/absl/container:flat_hash_map" ]
}
public_configs = [ ":angle_abseil_config" ]
}
config("angle_compression_config") {
include_dirs = [ "//third_party/zlib/google" ]
}
......
......@@ -180,6 +180,7 @@ assert INCLUDE_REGEX.match(b'\n#include "foo"')
# #includes in #ifdefs properly, so they will erroneously be marked as being
# included, but not part of the source list.
IGNORED_INCLUDES = {
b'absl/container/flat_hash_map.h',
b'compiler/translator/TranslatorESSL.h',
b'compiler/translator/TranslatorGLSL.h',
b'compiler/translator/TranslatorHLSL.h',
......@@ -244,6 +245,7 @@ IGNORED_INCLUDE_PREFIXES = {
IGNORED_DIRECTORIES = {
'//buildtools/third_party/libc++',
'//third_party/abseil-cpp',
'//third_party/SwiftShader',
}
......
......@@ -11,12 +11,17 @@
#include "common/platform.h"
#if defined(ANGLE_USE_ABSEIL)
# include "absl/container/flat_hash_map.h"
#endif // defined(ANGLE_USE_ABSEIL)
#include <climits>
#include <cstdarg>
#include <cstddef>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>
// A helper class to disallow copy and assignment operators
......@@ -27,6 +32,14 @@ namespace angle
using Microsoft::WRL::ComPtr;
#endif // defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_D3D11)
#if defined(ANGLE_USE_ABSEIL)
template <typename Key, typename T>
using HashMap = absl::flat_hash_map<Key, T>;
#else
template <typename Key, typename T>
using HashMap = std::unordered_map<Key, T>;
#endif // defined(ANGLE_USE_ABSEIL)
class NonCopyable
{
protected:
......
......@@ -185,7 +185,7 @@ TOperator GetIndexOp(TIntermNode *node)
}
bool IsConvertedField(TIntermTyped *indexNode,
const std::unordered_map<const TField *, bool> &convertedFields)
const angle::HashMap<const TField *, bool> &convertedFields)
{
TIntermBinary *asBinary = indexNode->getAsBinaryNode();
if (asBinary == nullptr)
......@@ -532,9 +532,9 @@ class RewriteRowMajorMatricesTraverser : public TIntermTraverser
TIntermSequence *getStructCopyFunctions() { return &mOuterPass.copyFunctionDefinitions; }
private:
typedef std::unordered_map<const TStructure *, StructConversionData> StructMap;
typedef std::unordered_map<const TVariable *, TVariable *> InterfaceBlockMap;
typedef std::unordered_map<const TField *, bool> InterfaceBlockFieldConverted;
typedef angle::HashMap<const TStructure *, StructConversionData> StructMap;
typedef angle::HashMap<const TVariable *, TVariable *> InterfaceBlockMap;
typedef angle::HashMap<const TField *, bool> InterfaceBlockFieldConverted;
RewriteRowMajorMatricesTraverser(
TSymbolTable *symbolTable,
......
......@@ -172,12 +172,12 @@ class ProgramBindings final : angle::NonCopyable
int getBindingByName(const std::string &name) const;
int getBinding(const sh::ShaderVariable &variable) const;
using const_iterator = std::unordered_map<std::string, GLuint>::const_iterator;
using const_iterator = angle::HashMap<std::string, GLuint>::const_iterator;
const_iterator begin() const;
const_iterator end() const;
private:
std::unordered_map<std::string, GLuint> mBindings;
angle::HashMap<std::string, GLuint> mBindings;
};
// Uniforms and Fragment Outputs require special treatment due to array notation (e.g., "[0]")
......
......@@ -287,8 +287,7 @@ void MaybeOverrideLuminance(GLenum &format, GLenum &type, GLenum actualFormat, G
typedef std::set<GLenum> FormatSet;
const FormatSet &GetAllSizedInternalFormats();
typedef std::unordered_map<GLenum, std::unordered_map<GLenum, InternalFormat>>
InternalFormatInfoMap;
typedef angle::HashMap<GLenum, angle::HashMap<GLenum, InternalFormat>> InternalFormatInfoMap;
const InternalFormatInfoMap &GetInternalFormatMap();
int GetAndroidHardwareBufferFormatFromChannelSizes(const egl::AttributeMap &attribMap);
......
......@@ -199,6 +199,7 @@ angle_source_set("angle_vulkan_backend") {
libs = []
deps = [
":angle_vk_mem_alloc_wrapper",
"$angle_root:angle_abseil",
"$angle_root:angle_compression",
"$angle_root:angle_gpu_info_util",
"$angle_root:angle_image_util",
......
......@@ -10,6 +10,7 @@
#ifndef LIBANGLE_RENDERER_VULKAN_FRAMEBUFFERVK_H_
#define LIBANGLE_RENDERER_VULKAN_FRAMEBUFFERVK_H_
#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/FramebufferImpl.h"
#include "libANGLE/renderer/RenderTargetCache.h"
#include "libANGLE/renderer/vulkan/BufferVk.h"
......@@ -244,7 +245,7 @@ class FramebufferVk : public FramebufferImpl
gl::DrawBufferMask mEmulatedAlphaAttachmentMask;
vk::FramebufferDesc mCurrentFramebufferDesc;
std::unordered_map<vk::FramebufferDesc, vk::FramebufferHelper> mFramebufferCache;
angle::HashMap<vk::FramebufferDesc, vk::FramebufferHelper> mFramebufferCache;
vk::ClearValuesArray mDeferredClears;
};
......
......@@ -229,8 +229,8 @@ class ProgramExecutableVk
size_t mNumDefaultUniformDescriptors;
vk::BufferSerial mCurrentDefaultUniformBufferSerial;
std::unordered_map<vk::UniformsAndXfbDesc, VkDescriptorSet> mUniformsAndXfbDescriptorSetCache;
std::unordered_map<vk::TextureDescriptorDesc, VkDescriptorSet> mTextureDescriptorsCache;
angle::HashMap<vk::UniformsAndXfbDesc, VkDescriptorSet> mUniformsAndXfbDescriptorSetCache;
angle::HashMap<vk::TextureDescriptorDesc, VkDescriptorSet> mTextureDescriptorsCache;
// We keep a reference to the pipeline and descriptor set layouts. This ensures they don't get
// deleted while this program is in use.
......
......@@ -238,13 +238,9 @@ libangle_headers = [
"src/libANGLE/MemoryObject.h",
"src/libANGLE/MemoryProgramCache.h",
"src/libANGLE/Observer.h",
"src/libANGLE/Overlay.cpp",
"src/libANGLE/Overlay.h",
"src/libANGLE/OverlayWidgets.cpp",
"src/libANGLE/OverlayWidgets.h",
"src/libANGLE/Overlay_autogen.cpp",
"src/libANGLE/Overlay_autogen.h",
"src/libANGLE/Overlay_font_autogen.cpp",
"src/libANGLE/Overlay_font_autogen.h",
"src/libANGLE/Program.h",
"src/libANGLE/ProgramExecutable.h",
......@@ -383,6 +379,10 @@ libangle_sources = [
"src/libANGLE/MemoryObject.cpp",
"src/libANGLE/MemoryProgramCache.cpp",
"src/libANGLE/Observer.cpp",
"src/libANGLE/Overlay.cpp",
"src/libANGLE/OverlayWidgets.cpp",
"src/libANGLE/Overlay_autogen.cpp",
"src/libANGLE/Overlay_font_autogen.cpp",
"src/libANGLE/Platform.cpp",
"src/libANGLE/Program.cpp",
"src/libANGLE/ProgramExecutable.cpp",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment