summaryrefslogtreecommitdiff
path: root/src/render/OpenGL.hpp
diff options
context:
space:
mode:
authorUjinT34 <41110182+UjinT34@users.noreply.github.com>2026-01-21 18:54:14 +0300
committerGitHub <noreply@github.com>2026-01-21 15:54:14 +0000
commit6c3ebed76e7def7b853e21fbf93f6eeb176696f9 (patch)
treedea1b5a43291252a5cfc66895ba9bd77cbc04ec4 /src/render/OpenGL.hpp
parentf9fb24577a0891bc4a8e9591c63ace789fd466a1 (diff)
renderer: add surface shader variants with less branching and uniforms (#13030)
* shader variant features * getSurfaceShader variant with feats * split surface shaders by features * cleanup old shaders
Diffstat (limited to 'src/render/OpenGL.hpp')
-rw-r--r--src/render/OpenGL.hpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp
index 4189e32b..a538aa4b 100644
--- a/src/render/OpenGL.hpp
+++ b/src/render/OpenGL.hpp
@@ -89,10 +89,8 @@ enum eMonitorExtraRenderFBs : uint8_t {
enum ePreparedFragmentShader : uint8_t {
SH_FRAG_QUAD = 0,
- SH_FRAG_RGBA,
SH_FRAG_PASSTHRURGBA,
SH_FRAG_MATTE,
- SH_FRAG_RGBX,
SH_FRAG_EXT,
SH_FRAG_BLUR1,
SH_FRAG_BLUR2,
@@ -103,14 +101,24 @@ enum ePreparedFragmentShader : uint8_t {
SH_FRAG_CM_BORDER1,
SH_FRAG_BORDER1,
SH_FRAG_GLITCH,
- SH_FRAG_CM_RGBA,
- SH_FRAG_CM_RGBA_DISCARD,
- SH_FRAG_CM_RGBX,
- SH_FRAG_CM_RGBX_DISCARD,
SH_FRAG_LAST,
};
+enum ePreparedFragmentShaderFeature : uint8_t {
+ SH_FEAT_UNKNOWN = 0, // all features just in case
+
+ SH_FEAT_RGBA = (1 << 0), // RGBA/RGBX texture sampling
+ SH_FEAT_DISCARD = (1 << 1), // RGBA/RGBX texture sampling
+ SH_FEAT_TINT = (1 << 2), // uniforms: tint; condition: applyTint
+ SH_FEAT_ROUNDING = (1 << 3), // uniforms: radius, roundingPower, topLeft, fullSize; condition: radius > 0
+ SH_FEAT_CM = (1 << 4), // uniforms: srcTFRange, dstTFRange, srcRefLuminance, convertMatrix; condition: !skipCM
+ SH_FEAT_TONEMAP = (1 << 5), // uniforms: maxLuminance, dstMaxLuminance, dstRefLuminance; condition: maxLuminance < dstMaxLuminance * 1.01
+ SH_FEAT_SDR_MOD = (1 << 6), // uniforms: sdrSaturation, sdrBrightnessMultiplier; condition: SDR <-> HDR && (sdrSaturation != 1 || sdrBrightnessMultiplier != 1)
+
+ // uniforms: targetPrimariesXYZ; condition: SH_FEAT_TONEMAP || SH_FEAT_SDR_MOD
+};
+
struct SFragShaderDesc {
ePreparedFragmentShader id;
const char* file;
@@ -126,6 +134,7 @@ struct SPreparedShaders {
std::string TEXVERTSRC;
std::string TEXVERTSRC320;
std::array<SP<CShader>, SH_FRAG_LAST> frag;
+ std::map<uint8_t, SP<CShader>> fragVariants;
};
struct SMonitorRenderData {
@@ -307,9 +316,11 @@ class CHyprOpenGLImpl {
void ensureLockTexturesRendered(bool load);
bool explicitSyncSupported();
+ WP<CShader> getSurfaceShader(uint8_t features);
bool m_shadersInitialized = false;
SP<SPreparedShaders> m_shaders;
+ std::map<std::string, std::string> m_includes;
SCurrentRenderData m_renderData;