opengl: use a passthru shader for final wlr copy

This commit is contained in:
vaxerski 2023-03-04 14:59:27 +00:00
parent f678789dfd
commit b69f40815f
3 changed files with 27 additions and 5 deletions

View file

@ -195,6 +195,13 @@ void CHyprOpenGLImpl::initShaders() {
m_RenderData.pCurrentMonData->m_shRGBA.applyTint = glGetUniformLocation(prog, "applyTint"); m_RenderData.pCurrentMonData->m_shRGBA.applyTint = glGetUniformLocation(prog, "applyTint");
m_RenderData.pCurrentMonData->m_shRGBA.tint = glGetUniformLocation(prog, "tint"); 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); prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBX);
m_RenderData.pCurrentMonData->m_shRGBX.program = prog; m_RenderData.pCurrentMonData->m_shRGBX.program = prog;
m_RenderData.pCurrentMonData->m_shRGBX.tex = glGetUniformLocation(prog, "tex"); m_RenderData.pCurrentMonData->m_shRGBX.tex = glGetUniformLocation(prog, "tex");
@ -488,6 +495,10 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
if (m_bApplyFinalShader && m_sFinalScreenShader.program) { if (m_bApplyFinalShader && m_sFinalScreenShader.program) {
shader = &m_sFinalScreenShader; shader = &m_sFinalScreenShader;
usingFinalShader = true; usingFinalShader = true;
} else {
if (m_bApplyFinalShader) {
shader = &m_RenderData.pCurrentMonData->m_shPASSTHRURGBA;
usingFinalShader = true;
} else { } else {
switch (tex.m_iType) { switch (tex.m_iType) {
case TEXTURE_RGBA: shader = &m_RenderData.pCurrentMonData->m_shRGBA; break; case TEXTURE_RGBA: shader = &m_RenderData.pCurrentMonData->m_shRGBA; break;
@ -496,6 +507,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
default: RASSERT(false, "tex.m_iTarget unsupported!"); default: RASSERT(false, "tex.m_iTarget unsupported!");
} }
} }
}
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(tex.m_iTarget, tex.m_iTexID); glBindTexture(tex.m_iTarget, tex.m_iTexID);

View file

@ -41,6 +41,7 @@ struct SMonitorRenderData {
bool m_bShadersInitialized = false; bool m_bShadersInitialized = false;
CShader m_shQUAD; CShader m_shQUAD;
CShader m_shRGBA; CShader m_shRGBA;
CShader m_shPASSTHRURGBA;
CShader m_shRGBX; CShader m_shRGBX;
CShader m_shEXT; CShader m_shEXT;
CShader m_shBLUR1; CShader m_shBLUR1;

View file

@ -122,6 +122,15 @@ void main() {
gl_FragColor = pixColor * alpha; 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"#( inline const std::string TEXFRAGSRCRGBX = R"#(
precision mediump float; precision mediump float;
varying vec2 v_texcoord; varying vec2 v_texcoord;