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") {
angle_source_set("includes") {
sources = libangle_includes
public_configs = [ ":includes_config" ]
public_configs = [
":angle_abseil_config",
":includes_config",
]
}
angle_static_library("preprocessor") {
......@@ -457,6 +460,7 @@ angle_static_library("translator") {
public_configs += [ ":external_config" ]
deps = [
":angle_abseil",
":includes",
":preprocessor",
]
......@@ -588,6 +592,7 @@ config("libANGLE_config") {
angle_source_set("libANGLE_headers") {
sources = libangle_headers
deps = [ ":angle_abseil" ]
public_deps = [
":angle_common",
":angle_translator_headers",
......@@ -603,6 +608,7 @@ if (angle_enable_vulkan || angle_enable_metal) {
"src/libANGLE/renderer/glslang_wrapper_utils.h",
]
deps = [
":angle_abseil",
":libANGLE_headers",
"${angle_glslang_dir}:glslang_default_resource_limits_sources",
"${angle_glslang_dir}:glslang_lib_sources",
......@@ -630,6 +636,7 @@ angle_source_set("libANGLE_base") {
":translator",
]
deps = [
":angle_abseil",
":angle_compression",
":angle_image_util",
":includes",
......@@ -775,7 +782,7 @@ angle_source_set("libANGLE") {
sources = [ "src/libANGLE/FrameCapture_mock.cpp" ]
# gl_enum_utils defaults included in with_capture build
deps = []
deps = [ ":angle_abseil" ]
if (angle_enable_trace || is_debug) {
deps += [ ":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") {
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',
......@@ -224,6 +225,7 @@ IGNORED_INCLUDE_PREFIXES = {
}
IGNORED_DIRECTORIES = {
'//third_party/abseil-cpp',
'//third_party/SwiftShader',
'//third_party/vulkan-headers',
'//third_party/vulkan-loader',
......
......@@ -8,6 +8,8 @@
#include "compiler/translator/tree_ops/RewriteRowMajorMatrices.h"
#include "absl/container/flat_hash_map.h"
#include "compiler/translator/Compiler.h"
#include "compiler/translator/ImmutableStringBuilder.h"
#include "compiler/translator/StaticType.h"
......@@ -185,7 +187,7 @@ TOperator GetIndexOp(TIntermNode *node)
}
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();
if (asBinary == nullptr)
......@@ -532,9 +534,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;
using StructMap = absl::flat_hash_map<const TStructure *, StructConversionData>;
using InterfaceBlockMap = absl::flat_hash_map<const TVariable *, TVariable *>;
using InterfaceBlockFieldConverted = absl::flat_hash_map<const TField *, bool>;
RewriteRowMajorMatricesTraverser(
TSymbolTable *symbolTable,
......
......@@ -20,6 +20,8 @@
#include <string>
#include <vector>
#include "absl/container/flat_hash_map.h"
#include "common/Optional.h"
#include "common/angleutils.h"
#include "common/mathutil.h"
......@@ -172,12 +174,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 = absl::flat_hash_map<std::string, GLuint>::const_iterator;
const_iterator begin() const;
const_iterator end() const;
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]")
......
......@@ -13,6 +13,8 @@
#include <cstddef>
#include <ostream>
#include "absl/container/flat_hash_map.h"
#include "angle_gl.h"
#include "common/android_util.h"
#include "libANGLE/Caps.h"
......@@ -273,7 +275,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>>
typedef absl::flat_hash_map<GLenum, absl::flat_hash_map<GLenum, InternalFormat>>
InternalFormatInfoMap;
const InternalFormatInfoMap &GetInternalFormatMap();
......
......@@ -195,6 +195,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,8 @@
#ifndef 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/RenderTargetCache.h"
#include "libANGLE/renderer/vulkan/BufferVk.h"
......@@ -255,7 +257,7 @@ class FramebufferVk : public FramebufferImpl
gl::DrawBufferMask mEmulatedAlphaAttachmentMask;
vk::FramebufferDesc mCurrentFramebufferDesc;
std::unordered_map<vk::FramebufferDesc, vk::FramebufferHelper> mFramebufferCache;
absl::flat_hash_map<vk::FramebufferDesc, vk::FramebufferHelper> mFramebufferCache;
vk::ClearValuesArray mDeferredClears;
};
......
......@@ -10,6 +10,8 @@
#ifndef 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/utilities.h"
#include "libANGLE/Context.h"
......@@ -224,8 +226,8 @@ class ProgramExecutableVk
size_t mNumDefaultUniformDescriptors;
vk::BufferSerial mCurrentDefaultUniformBufferSerial;
std::unordered_map<vk::UniformsAndXfbDesc, VkDescriptorSet> mUniformsAndXfbDescriptorSetCache;
std::unordered_map<vk::TextureDescriptorDesc, VkDescriptorSet> mTextureDescriptorsCache;
absl::flat_hash_map<vk::UniformsAndXfbDesc, VkDescriptorSet> mUniformsAndXfbDescriptorSetCache;
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
// 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