Commit 1acaf4ec 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: I68c7d067b6912b0cc0ecde231501dbed92f0b189 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2321735 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 330c8673
...@@ -220,7 +220,10 @@ config("includes_config") { ...@@ -220,7 +220,10 @@ config("includes_config") {
angle_source_set("includes") { angle_source_set("includes") {
sources = libangle_includes sources = libangle_includes
public_configs = [ ":includes_config" ] public_configs = [
":angle_abseil_config",
":includes_config",
]
} }
angle_static_library("preprocessor") { angle_static_library("preprocessor") {
...@@ -457,6 +460,7 @@ angle_static_library("translator") { ...@@ -457,6 +460,7 @@ angle_static_library("translator") {
public_configs += [ ":external_config" ] public_configs += [ ":external_config" ]
deps = [ deps = [
":angle_abseil",
":includes", ":includes",
":preprocessor", ":preprocessor",
] ]
...@@ -588,6 +592,7 @@ config("libANGLE_config") { ...@@ -588,6 +592,7 @@ config("libANGLE_config") {
angle_source_set("libANGLE_headers") { angle_source_set("libANGLE_headers") {
sources = libangle_headers sources = libangle_headers
deps = [ ":angle_abseil" ]
public_deps = [ public_deps = [
":angle_common", ":angle_common",
":angle_translator_headers", ":angle_translator_headers",
...@@ -603,6 +608,7 @@ if (angle_enable_vulkan || angle_enable_metal) { ...@@ -603,6 +608,7 @@ if (angle_enable_vulkan || angle_enable_metal) {
"src/libANGLE/renderer/glslang_wrapper_utils.h", "src/libANGLE/renderer/glslang_wrapper_utils.h",
] ]
deps = [ deps = [
":angle_abseil",
":libANGLE_headers", ":libANGLE_headers",
"${angle_glslang_dir}:glslang_default_resource_limits_sources", "${angle_glslang_dir}:glslang_default_resource_limits_sources",
"${angle_glslang_dir}:glslang_lib_sources", "${angle_glslang_dir}:glslang_lib_sources",
...@@ -630,6 +636,7 @@ angle_source_set("libANGLE_base") { ...@@ -630,6 +636,7 @@ angle_source_set("libANGLE_base") {
":translator", ":translator",
] ]
deps = [ deps = [
":angle_abseil",
":angle_compression", ":angle_compression",
":angle_image_util", ":angle_image_util",
":includes", ":includes",
...@@ -775,7 +782,7 @@ angle_source_set("libANGLE") { ...@@ -775,7 +782,7 @@ angle_source_set("libANGLE") {
sources = [ "src/libANGLE/FrameCapture_mock.cpp" ] sources = [ "src/libANGLE/FrameCapture_mock.cpp" ]
# gl_enum_utils defaults included in with_capture build # gl_enum_utils defaults included in with_capture build
deps = [] deps = [ ":angle_abseil" ]
if (angle_enable_trace || is_debug) { if (angle_enable_trace || is_debug) {
deps += [ ":angle_gl_enum_utils" ] deps += [ ":angle_gl_enum_utils" ]
} }
...@@ -789,6 +796,25 @@ angle_source_set("angle_gl_enum_utils") { ...@@ -789,6 +796,25 @@ angle_source_set("angle_gl_enum_utils") {
] ]
} }
config("angle_abseil_config") {
configs = [
"//third_party/abseil-cpp:absl_define_config",
"//third_party/abseil-cpp: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 = [ "//third_party/abseil-cpp:absl" ]
} else {
public_deps = [ "//third_party/abseil-cpp/absl/container:flat_hash_map" ]
}
public_configs = [ ":angle_abseil_config" ]
}
config("angle_compression_config") { config("angle_compression_config") {
include_dirs = [ "//third_party/zlib/google" ] include_dirs = [ "//third_party/zlib/google" ]
} }
......
...@@ -180,6 +180,7 @@ assert INCLUDE_REGEX.match(b'\n#include "foo"') ...@@ -180,6 +180,7 @@ assert INCLUDE_REGEX.match(b'\n#include "foo"')
# #includes in #ifdefs properly, so they will erroneously be marked as being # #includes in #ifdefs properly, so they will erroneously be marked as being
# included, but not part of the source list. # included, but not part of the source list.
IGNORED_INCLUDES = { IGNORED_INCLUDES = {
b'absl/container/flat_hash_map.h',
b'compiler/translator/TranslatorESSL.h', b'compiler/translator/TranslatorESSL.h',
b'compiler/translator/TranslatorGLSL.h', b'compiler/translator/TranslatorGLSL.h',
b'compiler/translator/TranslatorHLSL.h', b'compiler/translator/TranslatorHLSL.h',
...@@ -224,6 +225,7 @@ IGNORED_INCLUDE_PREFIXES = { ...@@ -224,6 +225,7 @@ IGNORED_INCLUDE_PREFIXES = {
} }
IGNORED_DIRECTORIES = { IGNORED_DIRECTORIES = {
'//third_party/abseil-cpp',
'//third_party/SwiftShader', '//third_party/SwiftShader',
'//third_party/vulkan-headers', '//third_party/vulkan-headers',
'//third_party/vulkan-loader', '//third_party/vulkan-loader',
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include "compiler/translator/tree_ops/RewriteRowMajorMatrices.h" #include "compiler/translator/tree_ops/RewriteRowMajorMatrices.h"
#include "absl/container/flat_hash_map.h"
#include "compiler/translator/Compiler.h" #include "compiler/translator/Compiler.h"
#include "compiler/translator/ImmutableStringBuilder.h" #include "compiler/translator/ImmutableStringBuilder.h"
#include "compiler/translator/StaticType.h" #include "compiler/translator/StaticType.h"
...@@ -185,7 +187,7 @@ TOperator GetIndexOp(TIntermNode *node) ...@@ -185,7 +187,7 @@ TOperator GetIndexOp(TIntermNode *node)
} }
bool IsConvertedField(TIntermTyped *indexNode, bool IsConvertedField(TIntermTyped *indexNode,
const std::unordered_map<const TField *, bool> &convertedFields) const absl::flat_hash_map<const TField *, bool> &convertedFields)
{ {
TIntermBinary *asBinary = indexNode->getAsBinaryNode(); TIntermBinary *asBinary = indexNode->getAsBinaryNode();
if (asBinary == nullptr) if (asBinary == nullptr)
...@@ -532,9 +534,9 @@ class RewriteRowMajorMatricesTraverser : public TIntermTraverser ...@@ -532,9 +534,9 @@ class RewriteRowMajorMatricesTraverser : public TIntermTraverser
TIntermSequence *getStructCopyFunctions() { return &mOuterPass.copyFunctionDefinitions; } TIntermSequence *getStructCopyFunctions() { return &mOuterPass.copyFunctionDefinitions; }
private: private:
typedef std::unordered_map<const TStructure *, StructConversionData> StructMap; using StructMap = absl::flat_hash_map<const TStructure *, StructConversionData>;
typedef std::unordered_map<const TVariable *, TVariable *> InterfaceBlockMap; using InterfaceBlockMap = absl::flat_hash_map<const TVariable *, TVariable *>;
typedef std::unordered_map<const TField *, bool> InterfaceBlockFieldConverted; using InterfaceBlockFieldConverted = absl::flat_hash_map<const TField *, bool>;
RewriteRowMajorMatricesTraverser( RewriteRowMajorMatricesTraverser(
TSymbolTable *symbolTable, TSymbolTable *symbolTable,
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "absl/container/flat_hash_map.h"
#include "common/Optional.h" #include "common/Optional.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/mathutil.h" #include "common/mathutil.h"
...@@ -172,12 +174,12 @@ class ProgramBindings final : angle::NonCopyable ...@@ -172,12 +174,12 @@ class ProgramBindings final : angle::NonCopyable
int getBindingByName(const std::string &name) const; int getBindingByName(const std::string &name) const;
int getBinding(const sh::ShaderVariable &variable) const; int getBinding(const sh::ShaderVariable &variable) const;
using const_iterator = std::unordered_map<std::string, GLuint>::const_iterator; using const_iterator = absl::flat_hash_map<std::string, GLuint>::const_iterator;
const_iterator begin() const; const_iterator begin() const;
const_iterator end() const; const_iterator end() const;
private: private:
std::unordered_map<std::string, GLuint> mBindings; absl::flat_hash_map<std::string, GLuint> mBindings;
}; };
// Uniforms and Fragment Outputs require special treatment due to array notation (e.g., "[0]") // Uniforms and Fragment Outputs require special treatment due to array notation (e.g., "[0]")
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include <cstddef> #include <cstddef>
#include <ostream> #include <ostream>
#include "absl/container/flat_hash_map.h"
#include "angle_gl.h" #include "angle_gl.h"
#include "common/android_util.h" #include "common/android_util.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
...@@ -273,7 +275,7 @@ void MaybeOverrideLuminance(GLenum &format, GLenum &type, GLenum actualFormat, G ...@@ -273,7 +275,7 @@ void MaybeOverrideLuminance(GLenum &format, GLenum &type, GLenum actualFormat, G
typedef std::set<GLenum> FormatSet; typedef std::set<GLenum> FormatSet;
const FormatSet &GetAllSizedInternalFormats(); const FormatSet &GetAllSizedInternalFormats();
typedef std::unordered_map<GLenum, std::unordered_map<GLenum, InternalFormat>> typedef absl::flat_hash_map<GLenum, absl::flat_hash_map<GLenum, InternalFormat>>
InternalFormatInfoMap; InternalFormatInfoMap;
const InternalFormatInfoMap &GetInternalFormatMap(); const InternalFormatInfoMap &GetInternalFormatMap();
......
...@@ -195,6 +195,7 @@ angle_source_set("angle_vulkan_backend") { ...@@ -195,6 +195,7 @@ angle_source_set("angle_vulkan_backend") {
libs = [] libs = []
deps = [ deps = [
":angle_vk_mem_alloc_wrapper", ":angle_vk_mem_alloc_wrapper",
"$angle_root:angle_abseil",
"$angle_root:angle_compression", "$angle_root:angle_compression",
"$angle_root:angle_gpu_info_util", "$angle_root:angle_gpu_info_util",
"$angle_root:angle_image_util", "$angle_root:angle_image_util",
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#ifndef LIBANGLE_RENDERER_VULKAN_FRAMEBUFFERVK_H_ #ifndef LIBANGLE_RENDERER_VULKAN_FRAMEBUFFERVK_H_
#define LIBANGLE_RENDERER_VULKAN_FRAMEBUFFERVK_H_ #define LIBANGLE_RENDERER_VULKAN_FRAMEBUFFERVK_H_
#include "absl/container/flat_hash_map.h"
#include "libANGLE/renderer/FramebufferImpl.h" #include "libANGLE/renderer/FramebufferImpl.h"
#include "libANGLE/renderer/RenderTargetCache.h" #include "libANGLE/renderer/RenderTargetCache.h"
#include "libANGLE/renderer/vulkan/BufferVk.h" #include "libANGLE/renderer/vulkan/BufferVk.h"
...@@ -255,7 +257,7 @@ class FramebufferVk : public FramebufferImpl ...@@ -255,7 +257,7 @@ class FramebufferVk : public FramebufferImpl
gl::DrawBufferMask mEmulatedAlphaAttachmentMask; gl::DrawBufferMask mEmulatedAlphaAttachmentMask;
vk::FramebufferDesc mCurrentFramebufferDesc; vk::FramebufferDesc mCurrentFramebufferDesc;
std::unordered_map<vk::FramebufferDesc, vk::FramebufferHelper> mFramebufferCache; absl::flat_hash_map<vk::FramebufferDesc, vk::FramebufferHelper> mFramebufferCache;
vk::ClearValuesArray mDeferredClears; vk::ClearValuesArray mDeferredClears;
}; };
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#ifndef LIBANGLE_RENDERER_VULKAN_PROGRAMEXECUTABLEVK_H_ #ifndef LIBANGLE_RENDERER_VULKAN_PROGRAMEXECUTABLEVK_H_
#define LIBANGLE_RENDERER_VULKAN_PROGRAMEXECUTABLEVK_H_ #define LIBANGLE_RENDERER_VULKAN_PROGRAMEXECUTABLEVK_H_
#include "absl/container/flat_hash_map.h"
#include "common/bitset_utils.h" #include "common/bitset_utils.h"
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
...@@ -224,8 +226,8 @@ class ProgramExecutableVk ...@@ -224,8 +226,8 @@ class ProgramExecutableVk
size_t mNumDefaultUniformDescriptors; size_t mNumDefaultUniformDescriptors;
vk::BufferSerial mCurrentDefaultUniformBufferSerial; vk::BufferSerial mCurrentDefaultUniformBufferSerial;
std::unordered_map<vk::UniformsAndXfbDesc, VkDescriptorSet> mUniformsAndXfbDescriptorSetCache; absl::flat_hash_map<vk::UniformsAndXfbDesc, VkDescriptorSet> mUniformsAndXfbDescriptorSetCache;
std::unordered_map<vk::TextureDescriptorDesc, VkDescriptorSet> mTextureDescriptorsCache; absl::flat_hash_map<vk::TextureDescriptorDesc, VkDescriptorSet> mTextureDescriptorsCache;
// We keep a reference to the pipeline and descriptor set layouts. This ensures they don't get // We keep a reference to the pipeline and descriptor set layouts. This ensures they don't get
// deleted while this program is in use. // deleted while this program is in use.
......
...@@ -238,13 +238,9 @@ libangle_headers = [ ...@@ -238,13 +238,9 @@ libangle_headers = [
"src/libANGLE/MemoryObject.h", "src/libANGLE/MemoryObject.h",
"src/libANGLE/MemoryProgramCache.h", "src/libANGLE/MemoryProgramCache.h",
"src/libANGLE/Observer.h", "src/libANGLE/Observer.h",
"src/libANGLE/Overlay.cpp",
"src/libANGLE/Overlay.h", "src/libANGLE/Overlay.h",
"src/libANGLE/OverlayWidgets.cpp",
"src/libANGLE/OverlayWidgets.h", "src/libANGLE/OverlayWidgets.h",
"src/libANGLE/Overlay_autogen.cpp",
"src/libANGLE/Overlay_autogen.h", "src/libANGLE/Overlay_autogen.h",
"src/libANGLE/Overlay_font_autogen.cpp",
"src/libANGLE/Overlay_font_autogen.h", "src/libANGLE/Overlay_font_autogen.h",
"src/libANGLE/Program.h", "src/libANGLE/Program.h",
"src/libANGLE/ProgramExecutable.h", "src/libANGLE/ProgramExecutable.h",
...@@ -383,6 +379,10 @@ libangle_sources = [ ...@@ -383,6 +379,10 @@ libangle_sources = [
"src/libANGLE/MemoryObject.cpp", "src/libANGLE/MemoryObject.cpp",
"src/libANGLE/MemoryProgramCache.cpp", "src/libANGLE/MemoryProgramCache.cpp",
"src/libANGLE/Observer.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/Platform.cpp",
"src/libANGLE/Program.cpp", "src/libANGLE/Program.cpp",
"src/libANGLE/ProgramExecutable.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