From d33fb15ada0dbb3392ae257ba0ccea224944b6d8 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 8 May 2025 10:00:44 +0800 Subject: [PATCH] [Feat] using unordered_dense somewhere... --- MG/MG_GL/State/Common/CommonState.h | 6 ++++-- MG/MG_GL/State/Texture/TextureState.cpp | 2 +- MG/MG_GL/State/Texture/TextureState.h | 8 +++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/MG/MG_GL/State/Common/CommonState.h b/MG/MG_GL/State/Common/CommonState.h index b19417bb..0feccbe3 100644 --- a/MG/MG_GL/State/Common/CommonState.h +++ b/MG/MG_GL/State/Common/CommonState.h @@ -9,6 +9,8 @@ #include "../../../Includes.h" class CommonState { + template + using unordered_map = ankerl::unordered_dense::map; public: // Viewport GLint viewport[4] = {0, 0, 0, 0}; @@ -17,7 +19,7 @@ public: GLboolean colorMask[4] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}; // Pixel storage parameters - std::unordered_map pixelStoreParams; + unordered_map pixelStoreParams; // Blend state GLenum blendSrcRGB = GL_ONE; @@ -35,7 +37,7 @@ public: GLboolean depthMask = GL_TRUE; // Capability enables - std::unordered_map capabilities; + unordered_map capabilities; CommonState(); diff --git a/MG/MG_GL/State/Texture/TextureState.cpp b/MG/MG_GL/State/Texture/TextureState.cpp index 3a9c70ab..650ff4f7 100644 --- a/MG/MG_GL/State/Texture/TextureState.cpp +++ b/MG/MG_GL/State/Texture/TextureState.cpp @@ -630,7 +630,7 @@ GLenum TextureState::QueryLevelPropertyIntVector(GLenum target, GLint level, GLe return GL_NO_ERROR; } - std::unordered_map::iterator texIt; + unordered_map::iterator texIt; if (!isProxyTexture) { texIt = textures.find(boundTexture); diff --git a/MG/MG_GL/State/Texture/TextureState.h b/MG/MG_GL/State/Texture/TextureState.h index 804bc3a8..ad8ce8e1 100644 --- a/MG/MG_GL/State/Texture/TextureState.h +++ b/MG/MG_GL/State/Texture/TextureState.h @@ -54,13 +54,15 @@ public: }; class TextureState { + template + using unordered_map = ankerl::unordered_dense::map; private: GLuint activeTextureUnit_ = 0; GLuint lastUsedID_ = 0; - std::set freeIDs_; + std::unordered_set freeIDs_; - std::unordered_map proxyTextures_; + unordered_map proxyTextures_; static GLint GetUnpackParam_(GLenum pname); public: @@ -68,7 +70,7 @@ public: bool IsTextureGenerated(GLuint texture); bool IsTexture(GLuint texture); - std::unordered_map textures; + unordered_map textures; // Return: the validity of the operation, according to OpenGL 3 standard GLenum BindUnit(GLenum textureUnit);