From 092dbda88acf08945d53f77fed61688088d0f2bb Mon Sep 17 00:00:00 2001 From: Felix Dick Date: Mon, 10 Oct 2022 01:32:04 +0200 Subject: [PATCH 1/2] Let openGL transpose the matrixes for us. --- src/render/OpenGL.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 1877a08e..77bf7d97 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -325,14 +325,12 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix); wlr_matrix_multiply(glMatrix, matrixFlip180, glMatrix); - wlr_matrix_transpose(glMatrix, glMatrix); - glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glUseProgram(m_RenderData.pCurrentMonData->m_shQUAD.program); - glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shQUAD.proj, 1, GL_FALSE, glMatrix); + glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shQUAD.proj, 1, GL_TRUE, glMatrix); glUniform4f(m_RenderData.pCurrentMonData->m_shQUAD.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f); wlr_box transformedBox; @@ -416,8 +414,6 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix); wlr_matrix_multiply(glMatrix, matrixFlip180, glMatrix); - wlr_matrix_transpose(glMatrix, glMatrix); - CShader* shader = nullptr; glEnable(GL_BLEND); @@ -444,7 +440,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b glUseProgram(shader->program); - glUniformMatrix3fv(shader->proj, 1, GL_FALSE, glMatrix); + glUniformMatrix3fv(shader->proj, 1, GL_TRUE, glMatrix); glUniform1i(shader->tex, 0); glUniform1f(shader->alpha, alpha / 255.f); glUniform1i(shader->discardOpaque, (int)discardOpaque); @@ -534,7 +530,6 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p float glMatrix[9]; wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix); - wlr_matrix_multiply(glMatrix, matrixFlip180, glMatrix); wlr_matrix_transpose(glMatrix, glMatrix); // get the config settings @@ -570,7 +565,7 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p glUseProgram(pShader->program); // prep two shaders - glUniformMatrix3fv(pShader->proj, 1, GL_FALSE, glMatrix); + glUniformMatrix3fv(pShader->proj, 1, GL_TRUE, glMatrix); glUniform1f(pShader->radius, *PBLURSIZE * (a / 255.f)); // this makes the blursize change with a if (pShader == &m_RenderData.pCurrentMonData->m_shBLUR1) glUniform2f(m_RenderData.pCurrentMonData->m_shBLUR1.halfpixel, 0.5f / (m_RenderData.pMonitor->vecPixelSize.x / 2.f), 0.5f / (m_RenderData.pMonitor->vecPixelSize.y / 2.f)); @@ -847,14 +842,12 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CColor& col, int round) { wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix); wlr_matrix_multiply(glMatrix, matrixFlip180, glMatrix); - wlr_matrix_transpose(glMatrix, glMatrix); - glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glUseProgram(m_RenderData.pCurrentMonData->m_shBORDER1.program); - glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBORDER1.proj, 1, GL_FALSE, glMatrix); + glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shBORDER1.proj, 1, GL_TRUE, glMatrix); glUniform4f(m_RenderData.pCurrentMonData->m_shBORDER1.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f); const auto TOPLEFT = Vector2D(round, round); @@ -1105,14 +1098,12 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix); wlr_matrix_multiply(glMatrix, matrixFlip180, glMatrix); - wlr_matrix_transpose(glMatrix, glMatrix); - glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glUseProgram(m_RenderData.pCurrentMonData->m_shSHADOW.program); - glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shSHADOW.proj, 1, GL_FALSE, glMatrix); + glUniformMatrix3fv(m_RenderData.pCurrentMonData->m_shSHADOW.proj, 1, GL_TRUE, glMatrix); glUniform4f(m_RenderData.pCurrentMonData->m_shSHADOW.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f * a); const auto TOPLEFT = Vector2D(range + round, range + round); From 3bf7c5aea1d20cc6a0fc95f920111548e7863af9 Mon Sep 17 00:00:00 2001 From: Felix Dick Date: Mon, 10 Oct 2022 01:35:42 +0200 Subject: [PATCH 2/2] Change matrixProjection function stop use matrixFlip180 everywhere. --- src/helpers/MiscFunctions.cpp | 10 +++++----- src/render/OpenGL.cpp | 4 ---- src/render/OpenGL.hpp | 5 ----- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 362e0675..6acd8b63 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -178,7 +178,7 @@ bool isNumber(const std::string& str, bool allowfloat) { std::string copy = str; if (*copy.begin() == '-') copy = copy.substr(1); - + if (copy.empty()) return false; @@ -331,7 +331,7 @@ void logSystemInfo() { Debug::log(LOG, "Node name: %s", unameInfo.nodename); Debug::log(LOG, "Release: %s", unameInfo.release); Debug::log(LOG, "Version: %s", unameInfo.version); - + Debug::log(NONE, "\n"); const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA"); @@ -357,8 +357,8 @@ void matrixProjection(float mat[9], int w, int h, wl_output_transform tr) { // Rotation + reflection mat[0] = x * t[0]; mat[1] = x * t[1]; - mat[3] = y * -t[3]; - mat[4] = y * -t[4]; + mat[3] = y * t[3]; + mat[4] = y * t[4]; // Translation mat[2] = -copysign(1.0f, mat[0] + mat[1]); @@ -401,4 +401,4 @@ int64_t getPPIDof(int64_t pid) { } catch (std::exception& e) { return 0; } -} \ No newline at end of file +} diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 77bf7d97..8a51a83a 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -323,7 +323,6 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm float glMatrix[9]; wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix); - wlr_matrix_multiply(glMatrix, matrixFlip180, glMatrix); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -412,7 +411,6 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b float glMatrix[9]; wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix); - wlr_matrix_multiply(glMatrix, matrixFlip180, glMatrix); CShader* shader = nullptr; @@ -840,7 +838,6 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CColor& col, int round) { float glMatrix[9]; wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix); - wlr_matrix_multiply(glMatrix, matrixFlip180, glMatrix); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1096,7 +1093,6 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl float glMatrix[9]; wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix); - wlr_matrix_multiply(glMatrix, matrixFlip180, glMatrix); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 33ebb964..b62732f6 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -12,11 +12,6 @@ #include "Texture.hpp" #include "Framebuffer.hpp" -inline const float matrixFlip180[] = { - 1.0f, 0.0f, 0.0f, - 0.0f, -1.0f, 0.0f, - 0.0f, 0.0f, 1.0f, -}; inline const float fullVerts[] = { 1, 0, // top right 0, 0, // top left