mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-05-13 07:10:35 +01:00
refactor: cshader class to sshader struct (#10324)
Some checks are pending
Build Hyprland / Build Hyprland (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland with Meson (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland without precompiled headers (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland in pure Wayland (Arch) (push) Waiting to run
Build Hyprland / Code Style (Arch) (push) Waiting to run
Nix (CI) / update-inputs (push) Waiting to run
Nix (CI) / build (push) Waiting to run
Security Checks / Flawfinder Checks (push) Waiting to run
Some checks are pending
Build Hyprland / Build Hyprland (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland with Meson (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland without precompiled headers (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland in pure Wayland (Arch) (push) Waiting to run
Build Hyprland / Code Style (Arch) (push) Waiting to run
Nix (CI) / update-inputs (push) Waiting to run
Nix (CI) / build (push) Waiting to run
Security Checks / Flawfinder Checks (push) Waiting to run
This commit is contained in:
parent
7a971735af
commit
22b12e3013
4 changed files with 29 additions and 30 deletions
|
@ -906,7 +906,7 @@ static std::string processShader(const std::string& filename, const std::map<std
|
||||||
}
|
}
|
||||||
|
|
||||||
// shader has #include "CM.glsl"
|
// shader has #include "CM.glsl"
|
||||||
static void getCMShaderUniforms(CShader& shader) {
|
static void getCMShaderUniforms(SShader& shader) {
|
||||||
shader.skipCM = glGetUniformLocation(shader.program, "skipCM");
|
shader.skipCM = glGetUniformLocation(shader.program, "skipCM");
|
||||||
shader.sourceTF = glGetUniformLocation(shader.program, "sourceTF");
|
shader.sourceTF = glGetUniformLocation(shader.program, "sourceTF");
|
||||||
shader.targetTF = glGetUniformLocation(shader.program, "targetTF");
|
shader.targetTF = glGetUniformLocation(shader.program, "targetTF");
|
||||||
|
@ -922,7 +922,7 @@ static void getCMShaderUniforms(CShader& shader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// shader has #include "rounding.glsl"
|
// shader has #include "rounding.glsl"
|
||||||
static void getRoundingShaderUniforms(CShader& shader) {
|
static void getRoundingShaderUniforms(SShader& shader) {
|
||||||
shader.topLeft = glGetUniformLocation(shader.program, "topLeft");
|
shader.topLeft = glGetUniformLocation(shader.program, "topLeft");
|
||||||
shader.fullSize = glGetUniformLocation(shader.program, "fullSize");
|
shader.fullSize = glGetUniformLocation(shader.program, "fullSize");
|
||||||
shader.radius = glGetUniformLocation(shader.program, "radius");
|
shader.radius = glGetUniformLocation(shader.program, "radius");
|
||||||
|
@ -1443,7 +1443,7 @@ void CHyprOpenGLImpl::renderTextureWithDamage(SP<CTexture> tex, const CBox& box,
|
||||||
|
|
||||||
static std::map<std::pair<uint32_t, uint32_t>, std::array<GLfloat, 9>> primariesConversionCache;
|
static std::map<std::pair<uint32_t, uint32_t>, std::array<GLfloat, 9>> primariesConversionCache;
|
||||||
|
|
||||||
void CHyprOpenGLImpl::passCMUniforms(const CShader& shader, const NColorManagement::SImageDescription& imageDescription,
|
void CHyprOpenGLImpl::passCMUniforms(const SShader& shader, const NColorManagement::SImageDescription& imageDescription,
|
||||||
const NColorManagement::SImageDescription& targetImageDescription, bool modifySDR) {
|
const NColorManagement::SImageDescription& targetImageDescription, bool modifySDR) {
|
||||||
glUniform1i(shader.sourceTF, imageDescription.transferFunction);
|
glUniform1i(shader.sourceTF, imageDescription.transferFunction);
|
||||||
glUniform1i(shader.targetTF, targetImageDescription.transferFunction);
|
glUniform1i(shader.targetTF, targetImageDescription.transferFunction);
|
||||||
|
@ -1487,7 +1487,7 @@ void CHyprOpenGLImpl::passCMUniforms(const CShader& shader, const NColorManageme
|
||||||
glUniformMatrix3fv(shader.convertMatrix, 1, false, &primariesConversionCache[cacheKey][0]);
|
glUniformMatrix3fv(shader.convertMatrix, 1, false, &primariesConversionCache[cacheKey][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::passCMUniforms(const CShader& shader, const SImageDescription& imageDescription) {
|
void CHyprOpenGLImpl::passCMUniforms(const SShader& shader, const SImageDescription& imageDescription) {
|
||||||
passCMUniforms(shader, imageDescription, m_renderData.pMonitor->m_imageDescription, true);
|
passCMUniforms(shader, imageDescription, m_renderData.pMonitor->m_imageDescription, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1519,7 +1519,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, const CB
|
||||||
Mat3x3 matrix = m_renderData.monitorProjection.projectBox(newBox, TRANSFORM, newBox.rot);
|
Mat3x3 matrix = m_renderData.monitorProjection.projectBox(newBox, TRANSFORM, newBox.rot);
|
||||||
Mat3x3 glMatrix = m_renderData.projection.copy().multiply(matrix);
|
Mat3x3 glMatrix = m_renderData.projection.copy().multiply(matrix);
|
||||||
|
|
||||||
CShader* shader = nullptr;
|
SShader* shader = nullptr;
|
||||||
|
|
||||||
bool usingFinalShader = false;
|
bool usingFinalShader = false;
|
||||||
|
|
||||||
|
@ -1716,7 +1716,7 @@ void CHyprOpenGLImpl::renderTexturePrimitive(SP<CTexture> tex, const CBox& box)
|
||||||
Mat3x3 matrix = m_renderData.monitorProjection.projectBox(newBox, TRANSFORM, newBox.rot);
|
Mat3x3 matrix = m_renderData.monitorProjection.projectBox(newBox, TRANSFORM, newBox.rot);
|
||||||
Mat3x3 glMatrix = m_renderData.projection.copy().multiply(matrix);
|
Mat3x3 glMatrix = m_renderData.projection.copy().multiply(matrix);
|
||||||
|
|
||||||
CShader* shader = &m_shaders->m_shPASSTHRURGBA;
|
SShader* shader = &m_shaders->m_shPASSTHRURGBA;
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(tex->m_target, tex->m_texID);
|
glBindTexture(tex->m_target, tex->m_texID);
|
||||||
|
@ -1767,7 +1767,7 @@ void CHyprOpenGLImpl::renderTextureMatte(SP<CTexture> tex, const CBox& box, CFra
|
||||||
Mat3x3 matrix = m_renderData.monitorProjection.projectBox(newBox, TRANSFORM, newBox.rot);
|
Mat3x3 matrix = m_renderData.monitorProjection.projectBox(newBox, TRANSFORM, newBox.rot);
|
||||||
Mat3x3 glMatrix = m_renderData.projection.copy().multiply(matrix);
|
Mat3x3 glMatrix = m_renderData.projection.copy().multiply(matrix);
|
||||||
|
|
||||||
CShader* shader = &m_shaders->m_shMATTE;
|
SShader* shader = &m_shaders->m_shMATTE;
|
||||||
|
|
||||||
glUseProgram(shader->program);
|
glUseProgram(shader->program);
|
||||||
|
|
||||||
|
@ -1912,7 +1912,7 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, CRegion* o
|
||||||
}
|
}
|
||||||
|
|
||||||
// declare the draw func
|
// declare the draw func
|
||||||
auto drawPass = [&](CShader* pShader, CRegion* pDamage) {
|
auto drawPass = [&](SShader* pShader, CRegion* pDamage) {
|
||||||
if (currentRenderToFB == PMIRRORFB)
|
if (currentRenderToFB == PMIRRORFB)
|
||||||
PMIRRORSWAPFB->bind();
|
PMIRRORSWAPFB->bind();
|
||||||
else
|
else
|
||||||
|
|
|
@ -83,20 +83,20 @@ struct SPreparedShaders {
|
||||||
std::string TEXVERTSRC;
|
std::string TEXVERTSRC;
|
||||||
std::string TEXVERTSRC300;
|
std::string TEXVERTSRC300;
|
||||||
std::string TEXVERTSRC320;
|
std::string TEXVERTSRC320;
|
||||||
CShader m_shQUAD;
|
SShader m_shQUAD;
|
||||||
CShader m_shRGBA;
|
SShader m_shRGBA;
|
||||||
CShader m_shPASSTHRURGBA;
|
SShader m_shPASSTHRURGBA;
|
||||||
CShader m_shMATTE;
|
SShader m_shMATTE;
|
||||||
CShader m_shRGBX;
|
SShader m_shRGBX;
|
||||||
CShader m_shEXT;
|
SShader m_shEXT;
|
||||||
CShader m_shBLUR1;
|
SShader m_shBLUR1;
|
||||||
CShader m_shBLUR2;
|
SShader m_shBLUR2;
|
||||||
CShader m_shBLURPREPARE;
|
SShader m_shBLURPREPARE;
|
||||||
CShader m_shBLURFINISH;
|
SShader m_shBLURFINISH;
|
||||||
CShader m_shSHADOW;
|
SShader m_shSHADOW;
|
||||||
CShader m_shBORDER1;
|
SShader m_shBORDER1;
|
||||||
CShader m_shGLITCH;
|
SShader m_shGLITCH;
|
||||||
CShader m_shCM;
|
SShader m_shCM;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMonitorRenderData {
|
struct SMonitorRenderData {
|
||||||
|
@ -309,7 +309,7 @@ class CHyprOpenGLImpl {
|
||||||
bool m_offloadedFramebuffer = false;
|
bool m_offloadedFramebuffer = false;
|
||||||
bool m_cmSupported = true;
|
bool m_cmSupported = true;
|
||||||
|
|
||||||
CShader m_finalScreenShader;
|
SShader m_finalScreenShader;
|
||||||
CTimer m_globalTimer;
|
CTimer m_globalTimer;
|
||||||
|
|
||||||
SP<CTexture> m_missingAssetTexture;
|
SP<CTexture> m_missingAssetTexture;
|
||||||
|
@ -334,9 +334,9 @@ class CHyprOpenGLImpl {
|
||||||
// returns the out FB, can be either Mirror or MirrorSwap
|
// returns the out FB, can be either Mirror or MirrorSwap
|
||||||
CFramebuffer* blurMainFramebufferWithDamage(float a, CRegion* damage);
|
CFramebuffer* blurMainFramebufferWithDamage(float a, CRegion* damage);
|
||||||
|
|
||||||
void passCMUniforms(const CShader&, const NColorManagement::SImageDescription& imageDescription, const NColorManagement::SImageDescription& targetImageDescription,
|
void passCMUniforms(const SShader&, const NColorManagement::SImageDescription& imageDescription, const NColorManagement::SImageDescription& targetImageDescription,
|
||||||
bool modifySDR = false);
|
bool modifySDR = false);
|
||||||
void passCMUniforms(const CShader&, const NColorManagement::SImageDescription& imageDescription);
|
void passCMUniforms(const SShader&, const NColorManagement::SImageDescription& imageDescription);
|
||||||
void renderTextureInternalWithDamage(SP<CTexture>, const CBox& box, float a, const CRegion& damage, int round = 0, float roundingPower = 2.0f, bool discardOpaque = false,
|
void renderTextureInternalWithDamage(SP<CTexture>, const CBox& box, float a, const CRegion& damage, int round = 0, float roundingPower = 2.0f, bool discardOpaque = false,
|
||||||
bool noAA = false, bool allowCustomUV = false, bool allowDim = false);
|
bool noAA = false, bool allowCustomUV = false, bool allowDim = false);
|
||||||
void renderTexturePrimitive(SP<CTexture> tex, const CBox& box);
|
void renderTexturePrimitive(SP<CTexture> tex, const CBox& box);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "Shader.hpp"
|
#include "Shader.hpp"
|
||||||
|
|
||||||
CShader::~CShader() {
|
SShader::~SShader() {
|
||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CShader::destroy() {
|
void SShader::destroy() {
|
||||||
if (program == 0)
|
if (program == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
class CShader {
|
struct SShader {
|
||||||
public:
|
~SShader();
|
||||||
~CShader();
|
|
||||||
|
|
||||||
GLuint program = 0;
|
GLuint program = 0;
|
||||||
GLint proj = -1;
|
GLint proj = -1;
|
||||||
|
|
Loading…
Reference in a new issue