mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-07-25 17:21:54 -07:00
renderer: Added a pointer position uniform to the screen shader. (#10821)
This commit is contained in:
@@ -107,7 +107,7 @@ find_package(OpenGL REQUIRED COMPONENTS ${GLES_VERSION})
|
||||
pkg_check_modules(aquamarine_dep REQUIRED IMPORTED_TARGET aquamarine>=0.9.0)
|
||||
pkg_check_modules(hyprlang_dep REQUIRED IMPORTED_TARGET hyprlang>=0.3.2)
|
||||
pkg_check_modules(hyprcursor_dep REQUIRED IMPORTED_TARGET hyprcursor>=0.1.7)
|
||||
pkg_check_modules(hyprutils_dep REQUIRED IMPORTED_TARGET hyprutils>=0.7.0)
|
||||
pkg_check_modules(hyprutils_dep REQUIRED IMPORTED_TARGET hyprutils>=0.8.1)
|
||||
pkg_check_modules(hyprgraphics_dep REQUIRED IMPORTED_TARGET hyprgraphics>=0.1.3)
|
||||
|
||||
string(REPLACE "." ";" AQ_VERSION_LIST ${aquamarine_dep_VERSION})
|
||||
|
@@ -35,7 +35,7 @@ aquamarine = dependency('aquamarine', version: '>=0.9.0')
|
||||
hyprcursor = dependency('hyprcursor', version: '>=0.1.7')
|
||||
hyprgraphics = dependency('hyprgraphics', version: '>= 0.1.3')
|
||||
hyprlang = dependency('hyprlang', version: '>= 0.3.2')
|
||||
hyprutils = dependency('hyprutils', version: '>= 0.7.0')
|
||||
hyprutils = dependency('hyprutils', version: '>= 0.8.1')
|
||||
aquamarine_version_list = aquamarine.version().split('.')
|
||||
add_project_arguments(['-DAQUAMARINE_VERSION="@0@"'.format(aquamarine.version())], language: 'cpp')
|
||||
add_project_arguments(['-DAQUAMARINE_VERSION_MAJOR=@0@'.format(aquamarine_version_list.get(0))], language: 'cpp')
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include "../helpers/MiscFunctions.hpp"
|
||||
#include "../config/ConfigValue.hpp"
|
||||
#include "../config/ConfigManager.hpp"
|
||||
#include "../managers/PointerManager.hpp"
|
||||
#include "../desktop/LayerSurface.hpp"
|
||||
#include "../protocols/LayerShell.hpp"
|
||||
#include "../protocols/core/Compositor.hpp"
|
||||
@@ -1224,9 +1225,10 @@ void CHyprOpenGLImpl::applyScreenShader(const std::string& path) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_finalScreenShader.uniformLocations[SHADER_PROJ] = glGetUniformLocation(m_finalScreenShader.program, "proj");
|
||||
m_finalScreenShader.uniformLocations[SHADER_TEX] = glGetUniformLocation(m_finalScreenShader.program, "tex");
|
||||
m_finalScreenShader.uniformLocations[SHADER_TIME] = glGetUniformLocation(m_finalScreenShader.program, "time");
|
||||
m_finalScreenShader.uniformLocations[SHADER_POINTER] = glGetUniformLocation(m_finalScreenShader.program, "pointer_position");
|
||||
m_finalScreenShader.uniformLocations[SHADER_PROJ] = glGetUniformLocation(m_finalScreenShader.program, "proj");
|
||||
m_finalScreenShader.uniformLocations[SHADER_TEX] = glGetUniformLocation(m_finalScreenShader.program, "tex");
|
||||
m_finalScreenShader.uniformLocations[SHADER_TIME] = glGetUniformLocation(m_finalScreenShader.program, "time");
|
||||
if (m_finalScreenShader.uniformLocations[SHADER_TIME] != -1)
|
||||
m_finalScreenShader.initialTime = m_globalTimer.getSeconds();
|
||||
m_finalScreenShader.uniformLocations[SHADER_WL_OUTPUT] = glGetUniformLocation(m_finalScreenShader.program, "wl_output");
|
||||
@@ -1241,6 +1243,12 @@ void CHyprOpenGLImpl::applyScreenShader(const std::string& path) {
|
||||
}
|
||||
m_finalScreenShader.uniformLocations[SHADER_TEX_ATTRIB] = glGetAttribLocation(m_finalScreenShader.program, "texcoord");
|
||||
m_finalScreenShader.uniformLocations[SHADER_POS_ATTRIB] = glGetAttribLocation(m_finalScreenShader.program, "pos");
|
||||
if (m_finalScreenShader.uniformLocations[SHADER_POINTER] != -1 && *PDT != 0 && !g_pHyprRenderer->m_crashingInProgress) {
|
||||
// The screen shader uses the "pointer_position" uniform
|
||||
// Since the screen shader could change every frame, damage tracking *needs* to be disabled
|
||||
g_pConfigManager->addParseError("Screen shader: Screen shader uses uniform 'pointerPosition', which requires debug:damage_tracking to be switched off.\n"
|
||||
"WARNING: Disabling damage tracking will *massively* increase GPU utilization!");
|
||||
}
|
||||
m_finalScreenShader.createVao();
|
||||
}
|
||||
|
||||
@@ -1600,6 +1608,14 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, const CB
|
||||
shader->setUniformFloat2(SHADER_FULL_SIZE, m_renderData.pMonitor->m_pixelSize.x, m_renderData.pMonitor->m_pixelSize.y);
|
||||
}
|
||||
|
||||
if (usingFinalShader && *PDT == 0) {
|
||||
PHLMONITORREF pMonitor = m_renderData.pMonitor;
|
||||
Vector2D p = ((g_pInputManager->getMouseCoordsInternal() - pMonitor->m_position) * pMonitor->m_scale);
|
||||
p = p.transform(wlTransformToHyprutils(pMonitor->m_transform), pMonitor->m_pixelSize);
|
||||
shader->setUniformFloat2(SHADER_POINTER, p.x / pMonitor->m_pixelSize.x, p.y / pMonitor->m_pixelSize.y);
|
||||
} else if (usingFinalShader)
|
||||
shader->setUniformFloat2(SHADER_POINTER, 0.f, 0.f);
|
||||
|
||||
if (CRASHING) {
|
||||
shader->setUniformFloat(SHADER_DISTORT, g_pHyprRenderer->m_crashingDistort);
|
||||
shader->setUniformFloat2(SHADER_FULL_SIZE, m_renderData.pMonitor->m_pixelSize.x, m_renderData.pMonitor->m_pixelSize.y);
|
||||
|
@@ -62,6 +62,7 @@ enum eShaderUniform : uint8_t {
|
||||
SHADER_VIBRANCY_DARKNESS,
|
||||
SHADER_BRIGHTNESS,
|
||||
SHADER_NOISE,
|
||||
SHADER_POINTER,
|
||||
|
||||
SHADER_LAST,
|
||||
};
|
||||
|
Reference in New Issue
Block a user