mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 12:45:59 +01:00
Optionally expose time to screen shaders (#1700)
* Optionally expose time to screen shaders Since that collides with damage tracking, it will only be done, when damage tracking is disabled, meaning this comes at no cost for everyone not using time. * Rename m_Timer to m_tGlobalTimer
This commit is contained in:
parent
dc7d783d14
commit
de5f1b2a83
3 changed files with 23 additions and 2 deletions
|
@ -31,6 +31,8 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() {
|
||||||
pixman_region32_init(&m_rOriginalDamageRegion);
|
pixman_region32_init(&m_rOriginalDamageRegion);
|
||||||
|
|
||||||
RASSERT(eglMakeCurrent(wlr_egl_get_display(g_pCompositor->m_sWLREGL), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT), "Couldn't unset current EGL!");
|
RASSERT(eglMakeCurrent(wlr_egl_get_display(g_pCompositor->m_sWLREGL), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT), "Couldn't unset current EGL!");
|
||||||
|
|
||||||
|
m_tGlobalTimer.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint CHyprOpenGLImpl::createProgram(const std::string& vert, const std::string& frag, bool dynamic) {
|
GLuint CHyprOpenGLImpl::createProgram(const std::string& vert, const std::string& frag, bool dynamic) {
|
||||||
|
@ -310,8 +312,15 @@ void CHyprOpenGLImpl::applyScreenShader(const std::string& path) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sFinalScreenShader.proj = glGetUniformLocation(m_sFinalScreenShader.program, "proj");
|
m_sFinalScreenShader.proj = glGetUniformLocation(m_sFinalScreenShader.program, "proj");
|
||||||
m_sFinalScreenShader.tex = glGetUniformLocation(m_sFinalScreenShader.program, "tex");
|
m_sFinalScreenShader.tex = glGetUniformLocation(m_sFinalScreenShader.program, "tex");
|
||||||
|
m_sFinalScreenShader.time = glGetUniformLocation(m_sFinalScreenShader.program, "time");
|
||||||
|
if (m_sFinalScreenShader.time != -1 && g_pConfigManager->getInt("debug:damage_tracking") != 0) {
|
||||||
|
// The screen shader uses the "time" uniform
|
||||||
|
// Since the screen shader could change every frame, damage tracking *needs* to be disabled
|
||||||
|
g_pConfigManager->addParseError("Screen shader: Screen shader uses uniform 'time', which requires debug:damage_tracking to be switched off.\n"
|
||||||
|
"WARNING: Disabling damage tracking will *massively* increase GPU utilization!");
|
||||||
|
}
|
||||||
m_sFinalScreenShader.texAttrib = glGetAttribLocation(m_sFinalScreenShader.program, "texcoord");
|
m_sFinalScreenShader.texAttrib = glGetAttribLocation(m_sFinalScreenShader.program, "texcoord");
|
||||||
m_sFinalScreenShader.posAttrib = glGetAttribLocation(m_sFinalScreenShader.program, "pos");
|
m_sFinalScreenShader.posAttrib = glGetAttribLocation(m_sFinalScreenShader.program, "pos");
|
||||||
}
|
}
|
||||||
|
@ -523,6 +532,14 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
|
||||||
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, glMatrix);
|
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, glMatrix);
|
||||||
#endif
|
#endif
|
||||||
glUniform1i(shader->tex, 0);
|
glUniform1i(shader->tex, 0);
|
||||||
|
|
||||||
|
if (usingFinalShader && g_pConfigManager->getInt("debug:damage_tracking") == 0) {
|
||||||
|
glUniform1f(shader->time, m_tGlobalTimer.getSeconds());
|
||||||
|
} else if (usingFinalShader) {
|
||||||
|
// Don't let time be unitialised
|
||||||
|
glUniform1f(shader->time, 0.f);
|
||||||
|
}
|
||||||
|
|
||||||
if (!usingFinalShader) {
|
if (!usingFinalShader) {
|
||||||
glUniform1f(shader->alpha, alpha);
|
glUniform1f(shader->alpha, alpha);
|
||||||
glUniform1i(shader->discardOpaque, (int)discardOpaque);
|
glUniform1i(shader->discardOpaque, (int)discardOpaque);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
#include "../helpers/Monitor.hpp"
|
#include "../helpers/Monitor.hpp"
|
||||||
#include "../helpers/Color.hpp"
|
#include "../helpers/Color.hpp"
|
||||||
|
#include "../helpers/Timer.hpp"
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
@ -134,6 +135,7 @@ class CHyprOpenGLImpl {
|
||||||
bool m_bApplyFinalShader = false;
|
bool m_bApplyFinalShader = false;
|
||||||
|
|
||||||
CShader m_sFinalScreenShader;
|
CShader m_sFinalScreenShader;
|
||||||
|
CTimer m_tGlobalTimer;
|
||||||
|
|
||||||
GLuint createProgram(const std::string&, const std::string&, bool dynamic = false);
|
GLuint createProgram(const std::string&, const std::string&, bool dynamic = false);
|
||||||
GLuint compileShader(const GLuint&, std::string, bool dynamic = false);
|
GLuint compileShader(const GLuint&, std::string, bool dynamic = false);
|
||||||
|
|
|
@ -37,6 +37,8 @@ class CShader {
|
||||||
GLint gradientLength;
|
GLint gradientLength;
|
||||||
GLint angle;
|
GLint angle;
|
||||||
|
|
||||||
|
GLint time;
|
||||||
|
|
||||||
GLint getUniformLocation(const std::string&);
|
GLint getUniformLocation(const std::string&);
|
||||||
|
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
Loading…
Reference in a new issue