From c99eb23869da2b80e3613a886aa1b99851367a3c Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Sat, 17 Jan 2026 15:31:19 +0100 Subject: renderer: optimise shader usage further, split shaders and add more caching (#12992) * shader: split CM rgba/rgbx into discard ones make it branchless if we have no discards. * shader: ensure we dont stall on vbo uv buffer if we render a new texture before the previous was done gpu wise its going to stall until done, call glBufferData to orphan the data. this allows the driver to return a new memory block immediately if the GPU is still reading from the previous one * protocols: ensure we reset GL_PACK_ALIGNMENT reset GL_PACK_ALIGNMENT back to the default initial value of 4 * shader: use unsigned short in VAO loose a tiny bit of precision but gain massive bandwidth reductions. use GL_UNSIGNED_SHORT and set it as normalized. clamp and round the UV for uint16_t in customUv. * shader: interleave vertex buffers use std::array for fullverts, use a single interleaved buffer for position and uv, should in theory improve cache locality. and also remove the need to have two buffers around. * shader: revert precision drop we need the float precision because we might have 1.01 or similiar floats entering CM shader maths, and rounding/clamping those means the maths turns out wrong. so revert back to float, sadly higher bandwidth usage. * update doColorManagement api * convert primaries to XYZ on cpu * remove unused primaries uniform --------- Co-authored-by: UjinT34 --- src/render/OpenGL.hpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/render/OpenGL.hpp') diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 857cb891..4189e32b 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -35,13 +35,19 @@ struct gbm_device; class CHyprRenderer; -inline const float fullVerts[] = { - 1, 0, // top right - 0, 0, // top left - 1, 1, // bottom right - 0, 1, // bottom left +struct SVertex { + float x, y; // position + float u, v; // uv }; -inline const float fanVertsFull[] = {-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f}; + +constexpr std::array fullVerts = {{ + {0.0f, 0.0f, 0.0f, 0.0f}, // top-left + {0.0f, 1.0f, 0.0f, 1.0f}, // bottom-left + {1.0f, 0.0f, 1.0f, 0.0f}, // top-right + {1.0f, 1.0f, 1.0f, 1.0f}, // bottom-right +}}; + +inline const float fanVertsFull[] = {-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f}; enum eDiscardMode : uint8_t { DISCARD_OPAQUE = 1, @@ -98,7 +104,9 @@ enum ePreparedFragmentShader : uint8_t { 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, }; -- cgit v1.2.3