summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2026-04-04 19:11:58 +0100
committerVaxry <43317083+vaxerski@users.noreply.github.com>2026-04-04 14:42:04 -0400
commit97ee042757d07dad38b98546ddfb005354840c46 (patch)
tree50794c7959ef6f4779dbaf2abe8fba3596159b8a /src/render
parent9b05dc1b4c44849a3c23e67381dd7c2f311b4ee3 (diff)
render/opengl: optimize getShaderVariant's map access
Diffstat (limited to 'src/render')
-rw-r--r--src/render/OpenGL.cpp13
-rw-r--r--src/render/decorations/DecorationPositioner.hpp14
2 files changed, 15 insertions, 12 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index cfc3dc4e..bf12ac8d 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -2458,7 +2458,10 @@ bool CHyprOpenGLImpl::explicitSyncSupported() {
}
WP<CShader> CHyprOpenGLImpl::getShaderVariant(ePreparedFragmentShader frag, ShaderFeatureFlags features) {
- if (!m_shaders->fragVariants[frag].contains(features)) {
+ auto& variants = m_shaders->fragVariants[frag];
+ auto it = variants.find(features);
+
+ if (it == variants.end()) {
auto shader = makeShared<CShader>();
Log::logger->log(Log::INFO, "compiling feature set {} for {}", features, FRAG_SHADERS[frag]);
@@ -2468,12 +2471,12 @@ WP<CShader> CHyprOpenGLImpl::getShaderVariant(ePreparedFragmentShader frag, Shad
if (!shader->createProgram(m_shaders->TEXVERTSRC, fragSrc, true, true))
Log::logger->log(Log::ERR, "shader features {} failed for {}", features, FRAG_SHADERS[frag]);
- m_shaders->fragVariants[frag][features] = shader;
- return shader;
+ it = variants.emplace(features, std::move(shader)).first;
+ return it->second;
}
- ASSERT(m_shaders->fragVariants[frag][features]);
- return m_shaders->fragVariants[frag][features];
+ ASSERT(it->second);
+ return it->second;
}
std::vector<SDRMFormat> CHyprOpenGLImpl::getDRMFormats() {
diff --git a/src/render/decorations/DecorationPositioner.hpp b/src/render/decorations/DecorationPositioner.hpp
index 99168c10..3010824f 100644
--- a/src/render/decorations/DecorationPositioner.hpp
+++ b/src/render/decorations/DecorationPositioner.hpp
@@ -80,13 +80,13 @@ class CDecorationPositioner {
};
struct SWindowData {
- Vector2D lastWindowSize = {};
- SBoxExtents reserved = {};
- SBoxExtents extents = {};
- SBoxExtents decorationExtents = {};
- SBoxExtents decorationInputExtents = {};
- bool needsRecalc = false;
- bool needsDamageExtents = true;
+ Vector2D lastWindowSize = {};
+ SBoxExtents reserved = {};
+ SBoxExtents extents = {};
+ SBoxExtents decorationExtents = {};
+ SBoxExtents decorationInputExtents = {};
+ bool needsRecalc = false;
+ bool needsDamageExtents = true;
};
std::map<PHLWINDOWREF, SWindowData> m_windowDatas;