From 7374a023eff964817c9e5fbe75a661540516f798 Mon Sep 17 00:00:00 2001 From: UjinT34 <41110182+UjinT34@users.noreply.github.com> Date: Sat, 29 Mar 2025 03:19:35 +0300 Subject: renderer/opengl: Extract shaders from source (#9600) --------- Co-authored-by: Mihai Fufezan --- src/render/OpenGL.hpp | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'src/render/OpenGL.hpp') diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 34bb7e9c..c3091f15 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -9,6 +9,7 @@ #include "../helpers/sync/SyncTimeline.hpp" #include #include +#include #include #include @@ -78,6 +79,26 @@ enum eMonitorExtraRenderFBs : uint8_t { FB_MONITOR_RENDER_EXTRA_BLUR, }; +struct SPreparedShaders { + std::string TEXVERTSRC; + std::string TEXVERTSRC300; + std::string TEXVERTSRC320; + CShader m_shQUAD; + CShader m_shRGBA; + CShader m_shPASSTHRURGBA; + CShader m_shMATTE; + CShader m_shRGBX; + CShader m_shEXT; + CShader m_shBLUR1; + CShader m_shBLUR2; + CShader m_shBLURPREPARE; + CShader m_shBLURFINISH; + CShader m_shSHADOW; + CShader m_shBORDER1; + CShader m_shGLITCH; + CShader m_shCM; +}; + struct SMonitorRenderData { CFramebuffer offloadFB; CFramebuffer mirrorFB; // these are used for some effects, @@ -90,23 +111,6 @@ struct SMonitorRenderData { bool blurFBDirty = true; bool blurFBShouldRender = false; - - // Shaders - bool m_bShadersInitialized = false; - CShader m_shQUAD; - CShader m_shRGBA; - CShader m_shPASSTHRURGBA; - CShader m_shMATTE; - CShader m_shRGBX; - CShader m_shEXT; - CShader m_shBLUR1; - CShader m_shBLUR2; - CShader m_shBLURPREPARE; - CShader m_shBLURFINISH; - CShader m_shSHADOW; - CShader m_shBORDER1; - CShader m_shGLITCH; - CShader m_shCM; }; struct SCurrentRenderData { @@ -232,6 +236,10 @@ class CHyprOpenGLImpl { EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs); SP createEGLSync(int fence = -1); + bool initShaders(); + bool m_bShadersInitialized = false; + SP m_shaders; + SCurrentRenderData m_RenderData; Hyprutils::OS::CFileDescriptor m_iGBMFD; @@ -309,7 +317,6 @@ class CHyprOpenGLImpl { GLuint createProgram(const std::string&, const std::string&, bool dynamic = false, bool silent = false); GLuint compileShader(const GLuint&, std::string, bool dynamic = false, bool silent = false); void createBGTextureForMonitor(PHLMONITOR); - void initShaders(); void initDRMFormats(); void initEGL(bool gbm); EGLDeviceEXT eglDeviceFromDRMFD(int drmFD); @@ -322,6 +329,9 @@ class CHyprOpenGLImpl { // returns the out FB, can be either Mirror or MirrorSwap CFramebuffer* blurMainFramebufferWithDamage(float a, CRegion* damage); + void passCMUniforms(const CShader&, const NColorManagement::SImageDescription& imageDescription, const NColorManagement::SImageDescription& targetImageDescription, + bool modifySDR = false); + void passCMUniforms(const CShader&, const NColorManagement::SImageDescription& imageDescription); void renderTextureInternalWithDamage(SP, 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); void renderTexturePrimitive(SP tex, const CBox& box); -- cgit v1.2.3