aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-03-04 14:59:27 +0000
committervaxerski <[email protected]>2023-03-04 14:59:27 +0000
commitb69f40815fb9302526858bbf699bc6942f8bbd3e (patch)
treee4e8abd22e3e47cabd4914bd34b6e3df5de74c84
parentf678789dfd4936f3b3420352f0d0b6fd5af9bdb5 (diff)
downloadHyprland-b69f40815fb9302526858bbf699bc6942f8bbd3e.tar.gz
Hyprland-b69f40815fb9302526858bbf699bc6942f8bbd3e.zip
opengl: use a passthru shader for final wlr copy
-rw-r--r--src/render/OpenGL.cpp22
-rw-r--r--src/render/OpenGL.hpp1
-rw-r--r--src/render/shaders/Textures.hpp9
3 files changed, 27 insertions, 5 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index 1d13037b..6a9baedf 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -195,6 +195,13 @@ void CHyprOpenGLImpl::initShaders() {
m_RenderData.pCurrentMonData->m_shRGBA.applyTint = glGetUniformLocation(prog, "applyTint");
m_RenderData.pCurrentMonData->m_shRGBA.tint = glGetUniformLocation(prog, "tint");
+ prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBAPASSTHRU);
+ m_RenderData.pCurrentMonData->m_shPASSTHRURGBA.program = prog;
+ m_RenderData.pCurrentMonData->m_shPASSTHRURGBA.proj = glGetUniformLocation(prog, "proj");
+ m_RenderData.pCurrentMonData->m_shPASSTHRURGBA.tex = glGetUniformLocation(prog, "tex");
+ m_RenderData.pCurrentMonData->m_shPASSTHRURGBA.texAttrib = glGetAttribLocation(prog, "texcoord");
+ m_RenderData.pCurrentMonData->m_shPASSTHRURGBA.posAttrib = glGetAttribLocation(prog, "pos");
+
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBX);
m_RenderData.pCurrentMonData->m_shRGBX.program = prog;
m_RenderData.pCurrentMonData->m_shRGBX.tex = glGetUniformLocation(prog, "tex");
@@ -489,11 +496,16 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
shader = &m_sFinalScreenShader;
usingFinalShader = true;
} else {
- switch (tex.m_iType) {
- case TEXTURE_RGBA: shader = &m_RenderData.pCurrentMonData->m_shRGBA; break;
- case TEXTURE_RGBX: shader = &m_RenderData.pCurrentMonData->m_shRGBX; break;
- case TEXTURE_EXTERNAL: shader = &m_RenderData.pCurrentMonData->m_shEXT; break;
- default: RASSERT(false, "tex.m_iTarget unsupported!");
+ if (m_bApplyFinalShader) {
+ shader = &m_RenderData.pCurrentMonData->m_shPASSTHRURGBA;
+ usingFinalShader = true;
+ } else {
+ switch (tex.m_iType) {
+ case TEXTURE_RGBA: shader = &m_RenderData.pCurrentMonData->m_shRGBA; break;
+ case TEXTURE_RGBX: shader = &m_RenderData.pCurrentMonData->m_shRGBX; break;
+ case TEXTURE_EXTERNAL: shader = &m_RenderData.pCurrentMonData->m_shEXT; break;
+ default: RASSERT(false, "tex.m_iTarget unsupported!");
+ }
}
}
diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp
index 537d7143..d2dd5ce6 100644
--- a/src/render/OpenGL.hpp
+++ b/src/render/OpenGL.hpp
@@ -41,6 +41,7 @@ struct SMonitorRenderData {
bool m_bShadersInitialized = false;
CShader m_shQUAD;
CShader m_shRGBA;
+ CShader m_shPASSTHRURGBA;
CShader m_shRGBX;
CShader m_shEXT;
CShader m_shBLUR1;
diff --git a/src/render/shaders/Textures.hpp b/src/render/shaders/Textures.hpp
index 42ff8063..0bf168a4 100644
--- a/src/render/shaders/Textures.hpp
+++ b/src/render/shaders/Textures.hpp
@@ -122,6 +122,15 @@ void main() {
gl_FragColor = pixColor * alpha;
})#";
+inline const std::string TEXFRAGSRCRGBAPASSTHRU = R"#(
+precision mediump float;
+varying vec2 v_texcoord; // is in 0-1
+uniform sampler2D tex;
+
+void main() {
+ gl_FragColor = texture2D(tex, v_texcoord);
+})#";
+
inline const std::string TEXFRAGSRCRGBX = R"#(
precision mediump float;
varying vec2 v_texcoord;