summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-06-19 13:46:42 +0200
committerVaxry <vaxry@vaxry.net>2025-06-19 13:46:42 +0200
commit54ccf9c6b37a8aadde7b8e1fc737668f4966db61 (patch)
tree5faa751d0317d1f294005a791426003db5216cea /src/render
parente999ad664da97d066e30e1d2749061eb57b0e19a (diff)
renderer: make lock fail textures dynamically loaded
this should reduce idle vram usage by a whopping 16MB, but also might fix the tty unknown issue.
Diffstat (limited to 'src/render')
-rw-r--r--src/render/OpenGL.cpp34
-rw-r--r--src/render/OpenGL.hpp4
-rw-r--r--src/render/Renderer.cpp16
3 files changed, 41 insertions, 13 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index 659bc1da..a253e3ff 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -17,6 +17,7 @@
#include "../protocols/types/ColorManagement.hpp"
#include "../managers/HookSystemManager.hpp"
#include "../managers/input/InputManager.hpp"
+#include "../managers/eventLoop/EventLoopManager.hpp"
#include "../helpers/fs/FsUtils.hpp"
#include "debug/HyprNotificationOverlay.hpp"
#include "hyprerror/HyprError.hpp"
@@ -2752,19 +2753,36 @@ void CHyprOpenGLImpl::useProgram(GLuint prog) {
void CHyprOpenGLImpl::initAssets() {
initMissingAssetTexture();
- m_lockDeadTexture = loadAsset("lockdead.png");
- m_lockDead2Texture = loadAsset("lockdead2.png");
-
- m_lockTtyTextTexture = renderText(
- std::format("Running on tty {}",
- g_pCompositor->m_aqBackend->hasSession() && g_pCompositor->m_aqBackend->session->vt > 0 ? std::to_string(g_pCompositor->m_aqBackend->session->vt) : "unknown"),
- CHyprColor{0.9F, 0.9F, 0.9F, 0.7F}, 20, true);
-
m_screencopyDeniedTexture = renderText("Permission denied to share screen", Colors::WHITE, 20);
ensureBackgroundTexturePresence();
}
+void CHyprOpenGLImpl::ensureLockTexturesRendered(bool load) {
+ static bool loaded = false;
+
+ if (loaded == load)
+ return;
+
+ loaded = load;
+
+ if (load) {
+ // this will cause a small hitch. I don't think we can do much, other than wasting VRAM and having this loaded all the time.
+ m_lockDeadTexture = loadAsset("lockdead.png");
+ m_lockDead2Texture = loadAsset("lockdead2.png");
+
+ m_lockTtyTextTexture = renderText(std::format("Running on tty {}",
+ g_pCompositor->m_aqBackend->hasSession() && g_pCompositor->m_aqBackend->session->vt > 0 ?
+ std::to_string(g_pCompositor->m_aqBackend->session->vt) :
+ "unknown"),
+ CHyprColor{0.9F, 0.9F, 0.9F, 0.7F}, 20, true);
+ } else {
+ m_lockDeadTexture.reset();
+ m_lockDead2Texture.reset();
+ m_lockTtyTextTexture.reset();
+ }
+}
+
void CHyprOpenGLImpl::ensureBackgroundTexturePresence() {
static auto PNOWALLPAPER = CConfigValue<Hyprlang::INT>("misc:disable_hyprland_logo");
static auto PFORCEWALLPAPER = CConfigValue<Hyprlang::INT>("misc:force_default_wallpaper");
diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp
index 92d9b7d3..fc091f36 100644
--- a/src/render/OpenGL.hpp
+++ b/src/render/OpenGL.hpp
@@ -249,6 +249,8 @@ class CHyprOpenGLImpl {
GLuint compileShader(const GLuint&, std::string, bool dynamic = false, bool silent = false);
void useProgram(GLuint prog);
+ void ensureLockTexturesRendered(bool load);
+
bool m_shadersInitialized = false;
SP<SPreparedShaders> m_shaders;
@@ -329,7 +331,7 @@ class CHyprOpenGLImpl {
SP<CTexture> m_backgroundTexture;
SP<CTexture> m_lockDeadTexture;
SP<CTexture> m_lockDead2Texture;
- SP<CTexture> m_lockTtyTextTexture; // TODO: don't always load lock
+ SP<CTexture> m_lockTtyTextTexture;
void logShaderError(const GLuint&, bool program = false, bool silent = false);
void createBGTextureForMonitor(PHLMONITOR);
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 43d4ece5..f828deb4 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -835,8 +835,7 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA
return;
if (g_pSessionLockManager->isSessionLocked() && !g_pSessionLockManager->isSessionLockPresent()) {
- // locked with no exclusive, draw only red
- renderSessionLockMissing(pMonitor);
+ // do not render anything. We will render a lockscreen anyways later.
return;
}
@@ -989,12 +988,21 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA
void CHyprRenderer::renderLockscreen(PHLMONITOR pMonitor, const Time::steady_tp& now, const CBox& geometry) {
TRACY_GPU_ZONE("RenderLockscreen");
- if (g_pSessionLockManager->isSessionLocked()) {
+ const bool LOCKED = g_pSessionLockManager->isSessionLocked();
+
+ g_pHyprOpenGL->ensureLockTexturesRendered( //
+ LOCKED && // session is locked AND
+ !g_pSessionLockManager->getSessionLockSurfaceForMonitor(pMonitor->m_id) && // no session lock surface AND
+ (g_pSessionLockManager->shallConsiderLockMissing() ||
+ !g_pSessionLockManager->isSessionLockPresent()) // we can consider rendering the lockMissing texture OR there is no client altogether
+ );
+
+ if (LOCKED) {
Vector2D translate = {geometry.x, geometry.y};
const auto PSLS = g_pSessionLockManager->getSessionLockSurfaceForMonitor(pMonitor->m_id);
if (!PSLS) {
- if (g_pSessionLockManager->shallConsiderLockMissing())
+ if (g_pSessionLockManager->shallConsiderLockMissing() || !g_pSessionLockManager->isSessionLockPresent())
renderSessionLockMissing(pMonitor);
} else {
renderSessionLockSurface(PSLS, pMonitor, now);