From da3fd6d1f9a24f881ef09a170f998b471d054742 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 31 Jan 2019 08:26:41 -0800 Subject: Improved handling unordered_maps --- RenderScript/include/BufferParser.h | 6 ----- RenderScript/include/BufferViewParser.h | 5 ---- RenderScript/include/DeviceContextFuncBindings.h | 5 ---- RenderScript/include/DrawAttribsParser.h | 5 ---- RenderScript/include/EnumMappings.h | 30 +++--------------------- RenderScript/include/InputLayoutDescParser.h | 5 ---- RenderScript/include/LuaBindings.h | 4 ++-- RenderScript/include/RasterizerStateDescParser.h | 6 ----- RenderScript/include/SamplerParser.h | 6 ----- RenderScript/include/ShaderParser.h | 5 ---- RenderScript/include/TextureParser.h | 5 ---- RenderScript/include/TextureViewParser.h | 6 ----- RenderScript/src/BlendStateDescParser.cpp | 8 ------- RenderScript/src/DepthStencilStateDescParser.cpp | 5 ---- RenderScript/src/PSODescParser.cpp | 5 ---- RenderScript/src/ShaderParser.cpp | 6 ----- 16 files changed, 5 insertions(+), 107 deletions(-) (limited to 'RenderScript') diff --git a/RenderScript/include/BufferParser.h b/RenderScript/include/BufferParser.h index 2ae0349..82a244b 100644 --- a/RenderScript/include/BufferParser.h +++ b/RenderScript/include/BufferParser.h @@ -28,12 +28,6 @@ #include "EngineObjectParserCommon.h" #include "ClassMethodBinding.h" -namespace std -{ - DEFINE_ENUM_HASH( Diligent::BUFFER_MODE ) - DEFINE_ENUM_HASH( Diligent::SET_VERTEX_BUFFERS_FLAGS ) -} - namespace Diligent { class BufferParser final : public EngineObjectParserCommon diff --git a/RenderScript/include/BufferViewParser.h b/RenderScript/include/BufferViewParser.h index e62a982..43bdd47 100644 --- a/RenderScript/include/BufferViewParser.h +++ b/RenderScript/include/BufferViewParser.h @@ -28,11 +28,6 @@ #include "EngineObjectParserCommon.h" #include "ClassMethodBinding.h" -namespace std -{ - DEFINE_ENUM_HASH( Diligent::BUFFER_VIEW_TYPE ) -} - namespace Diligent { class BufferViewParser final : public EngineObjectParserCommon diff --git a/RenderScript/include/DeviceContextFuncBindings.h b/RenderScript/include/DeviceContextFuncBindings.h index 3fce60a..d541023 100644 --- a/RenderScript/include/DeviceContextFuncBindings.h +++ b/RenderScript/include/DeviceContextFuncBindings.h @@ -28,11 +28,6 @@ #include "ClassMethodBinding.h" #include "EnumMappings.h" -namespace std -{ - DEFINE_ENUM_HASH( Diligent::CLEAR_DEPTH_STENCIL_FLAGS ) -} - namespace Diligent { class DeviceContextFuncBindings diff --git a/RenderScript/include/DrawAttribsParser.h b/RenderScript/include/DrawAttribsParser.h index b82ccbb..dff6161 100644 --- a/RenderScript/include/DrawAttribsParser.h +++ b/RenderScript/include/DrawAttribsParser.h @@ -28,11 +28,6 @@ #include "EngineObjectParserCommon.h" #include "ClassMethodBinding.h" -namespace std -{ - DEFINE_ENUM_HASH( Diligent::DRAW_FLAGS ) -} - namespace Diligent { class DrawAttribsParser final : public EngineObjectParserBase diff --git a/RenderScript/include/EnumMappings.h b/RenderScript/include/EnumMappings.h index 8bf71b3..7fae1c0 100644 --- a/RenderScript/include/EnumMappings.h +++ b/RenderScript/include/EnumMappings.h @@ -23,33 +23,9 @@ #pragma once +#include #include "HashUtils.h" -#define DEFINE_ENUM_HASH(Type)\ -template<>struct hash \ -{ \ - size_t operator()( const Type &x ) const \ - { \ - return hash()(x); \ - } \ -}; - -namespace std -{ - DEFINE_ENUM_HASH( Diligent::RESOURCE_DIMENSION ) - DEFINE_ENUM_HASH( Diligent::TEXTURE_FORMAT ) - DEFINE_ENUM_HASH( Diligent::VALUE_TYPE ) - DEFINE_ENUM_HASH( Diligent::USAGE ) - // Explicit namespace declaraion is necesseary to avoid - // name conflicts when building for windows store - DEFINE_ENUM_HASH( Diligent::BIND_FLAGS ) - DEFINE_ENUM_HASH( Diligent::CPU_ACCESS_FLAGS ) - DEFINE_ENUM_HASH( Diligent::COMPARISON_FUNCTION ) - DEFINE_ENUM_HASH( Diligent::BIND_SHADER_RESOURCES_FLAGS ) - DEFINE_ENUM_HASH( Diligent::SHADER_TYPE ) - DEFINE_ENUM_HASH( Diligent::RESOURCE_STATE_TRANSITION_MODE ) -} - namespace Diligent { template @@ -61,8 +37,8 @@ namespace Diligent m_Val2StrMap.insert( std::make_pair( Val, Str ) ); } - std::unordered_map< Diligent::HashMapStringKey, EnumType> m_Str2ValMap; - std::unordered_map m_Val2StrMap; + std::unordered_map m_Str2ValMap; + std::unordered_map::type>> m_Val2StrMap; }; #define DEFINE_ENUM_ELEMENT_MAPPING(EnumMapping, Elem) EnumMapping.AddMapping(#Elem, Elem) diff --git a/RenderScript/include/InputLayoutDescParser.h b/RenderScript/include/InputLayoutDescParser.h index 73b58ba..46d2c9b 100644 --- a/RenderScript/include/InputLayoutDescParser.h +++ b/RenderScript/include/InputLayoutDescParser.h @@ -26,11 +26,6 @@ #include "LuaWrappers.h" #include "LuaBindings.h" -namespace std -{ - DEFINE_ENUM_HASH( Diligent::LayoutElement::FREQUENCY ) -} - namespace Diligent { template<> diff --git a/RenderScript/include/LuaBindings.h b/RenderScript/include/LuaBindings.h index 67a3e8f..a93142e 100644 --- a/RenderScript/include/LuaBindings.h +++ b/RenderScript/include/LuaBindings.h @@ -120,7 +120,7 @@ namespace Diligent protected: const size_t m_MemberOffset; }; - typedef std::unordered_map > BindingsMapType; + typedef std::unordered_map, HashMapStringKey::Hasher> BindingsMapType; #define DEFINE_BINDER_EX(BindingsMap, Struct, Member, type, ValidationFunc) \ do{\ @@ -571,7 +571,7 @@ namespace Diligent EnumMapping m_ValueTypeEnumMapping; EnumMemberBinder m_ValueTypeBinder; typedef void (*ParseNumericArrayFuncType)(lua_State *L, int StackIndex, std::vector< Uint8 >& RawData); - std::unordered_map< VALUE_TYPE, ParseNumericArrayFuncType > m_ParseFuncJumpTbl; + std::unordered_map< VALUE_TYPE, ParseNumericArrayFuncType, std::hash::type> > m_ParseFuncJumpTbl; }; diff --git a/RenderScript/include/RasterizerStateDescParser.h b/RenderScript/include/RasterizerStateDescParser.h index f114fc5..f025610 100644 --- a/RenderScript/include/RasterizerStateDescParser.h +++ b/RenderScript/include/RasterizerStateDescParser.h @@ -26,12 +26,6 @@ #include "PipelineState.h" #include "LuaBindings.h" -namespace std -{ - DEFINE_ENUM_HASH( Diligent::FILL_MODE ) - DEFINE_ENUM_HASH( Diligent::CULL_MODE ) -} - namespace Diligent { template<> diff --git a/RenderScript/include/SamplerParser.h b/RenderScript/include/SamplerParser.h index 6d4203d..0172f04 100644 --- a/RenderScript/include/SamplerParser.h +++ b/RenderScript/include/SamplerParser.h @@ -29,12 +29,6 @@ #include "ClassMethodBinding.h" #include "EngineObjectParserCommon.h" -namespace std -{ - DEFINE_ENUM_HASH( Diligent::FILTER_TYPE ) - DEFINE_ENUM_HASH( Diligent::TEXTURE_ADDRESS_MODE ) -} - namespace Diligent { template diff --git a/RenderScript/include/ShaderParser.h b/RenderScript/include/ShaderParser.h index a0cf869..f3fae7e 100644 --- a/RenderScript/include/ShaderParser.h +++ b/RenderScript/include/ShaderParser.h @@ -29,11 +29,6 @@ #include "ClassMethodBinding.h" #include "EngineObjectParserCommon.h" -namespace std -{ - DEFINE_ENUM_HASH( Diligent::SHADER_SOURCE_LANGUAGE ) -} - namespace Diligent { class ShaderParser final : public EngineObjectParserCommon diff --git a/RenderScript/include/TextureParser.h b/RenderScript/include/TextureParser.h index 3c522c2..80eaef5 100644 --- a/RenderScript/include/TextureParser.h +++ b/RenderScript/include/TextureParser.h @@ -28,11 +28,6 @@ #include "EngineObjectParserCommon.h" #include "ClassMethodBinding.h" -namespace std -{ - DEFINE_ENUM_HASH( Diligent::MISC_TEXTURE_FLAGS ) -} - namespace Diligent { class TextureParser final : public EngineObjectParserCommon diff --git a/RenderScript/include/TextureViewParser.h b/RenderScript/include/TextureViewParser.h index b4f2fc5..e8b2bee 100644 --- a/RenderScript/include/TextureViewParser.h +++ b/RenderScript/include/TextureViewParser.h @@ -28,12 +28,6 @@ #include "EngineObjectParserCommon.h" #include "ClassMethodBinding.h" -namespace std -{ - DEFINE_ENUM_HASH( Diligent::TEXTURE_VIEW_TYPE ) - DEFINE_ENUM_HASH( Diligent::UAV_ACCESS_FLAG ) -} - namespace Diligent { class TextureViewParser final : public EngineObjectParserCommon diff --git a/RenderScript/src/BlendStateDescParser.cpp b/RenderScript/src/BlendStateDescParser.cpp index 3702628..dbc4529 100644 --- a/RenderScript/src/BlendStateDescParser.cpp +++ b/RenderScript/src/BlendStateDescParser.cpp @@ -26,14 +26,6 @@ #include "LuaWrappers.h" #include "ClassMethodBinding.h" - -namespace std -{ - DEFINE_ENUM_HASH( Diligent::BLEND_FACTOR ) - DEFINE_ENUM_HASH( Diligent::BLEND_OPERATION ) - DEFINE_ENUM_HASH( Diligent::COLOR_MASK ) -} - namespace Diligent { class RenderTargetBlendDescArrayParser; diff --git a/RenderScript/src/DepthStencilStateDescParser.cpp b/RenderScript/src/DepthStencilStateDescParser.cpp index 12a64f7..ef127d5 100644 --- a/RenderScript/src/DepthStencilStateDescParser.cpp +++ b/RenderScript/src/DepthStencilStateDescParser.cpp @@ -24,11 +24,6 @@ #include "pch.h" #include "DepthStencilStateDescParser.h" -namespace std -{ - DEFINE_ENUM_HASH( Diligent::STENCIL_OP ) -} - namespace Diligent { template<> diff --git a/RenderScript/src/PSODescParser.cpp b/RenderScript/src/PSODescParser.cpp index 3099140..b1da543 100644 --- a/RenderScript/src/PSODescParser.cpp +++ b/RenderScript/src/PSODescParser.cpp @@ -28,11 +28,6 @@ #include "DepthStencilStateDescParser.h" #include "InputLayoutDescParser.h" -namespace std -{ - DEFINE_ENUM_HASH( Diligent::PRIMITIVE_TOPOLOGY ) -} - namespace Diligent { class RTVFormatsParser; diff --git a/RenderScript/src/ShaderParser.cpp b/RenderScript/src/ShaderParser.cpp index 61218dd..761e1af 100644 --- a/RenderScript/src/ShaderParser.cpp +++ b/RenderScript/src/ShaderParser.cpp @@ -26,12 +26,6 @@ #include "BasicShaderSourceStreamFactory.h" #include "SamplerParser.h" - -namespace std -{ - DEFINE_ENUM_HASH( Diligent::SHADER_VARIABLE_TYPE ) -} - namespace Diligent { const Char* ShaderParser::ShaderLibName = "Shader"; -- cgit v1.2.3