Skip to content

Extract shaders from source#9600

Merged
vaxerski merged 35 commits into
hyprwm:mainfrom
UjinT34:extract-shaders
Mar 29, 2025
Merged

Extract shaders from source#9600
vaxerski merged 35 commits into
hyprwm:mainfrom
UjinT34:extract-shaders

Conversation

@UjinT34

@UjinT34 UjinT34 commented Mar 11, 2025

Copy link
Copy Markdown
Contributor

Describe your PR, what does it fix/add?

Extracts shaders from source code to reloadable and overridable assets. Shader assets can be overridden in ~/.config/hypr/shaders.
Adds a simple shader #include processor.
Adds hyprctl reloadshaders to reload shaders.
Fixes CM for some effects.
Adds render:use_color_management to disable proto and use old shaders. Requires restart.
Lowers es version requirement #9655
Fixes render:cm_fs_passthrough and changes the default to 2 - passthrough only HDR content. #9680

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

GL_ARB_shading_language_include is not used, it's enabled for ide shader linting.
#include supports only predefined set of filenames.
Some other shaders might need a CM support.
When testing a local build without installation shaders should be copied/linked to ~/.config/hypr/shaders (any installed shaders will have higher priority than builtin ones)
Might need meson install fix. Plugins relying on in-source shader constants will be broken #9619
preBlurForCurrentMonitor isn't called when CM settings change.

Is it ready for merging, or does it need work?

Ready

  • CM for borders
  • CM for shadows
  • CM for blur
  • Extract all shaders
  • Fix assets subfolders

@UjinT34 UjinT34 marked this pull request as draft March 11, 2025 20:27
@UjinT34 UjinT34 mentioned this pull request Mar 11, 2025
17 tasks
@UjinT34 UjinT34 marked this pull request as ready for review March 13, 2025 07:51
@lkcv

lkcv commented Mar 13, 2025

Copy link
Copy Markdown

Thanks! This works as expected for me.

@UjinT34 UjinT34 mentioned this pull request Mar 4, 2025
68 tasks
@UjinT34 UjinT34 force-pushed the extract-shaders branch 3 times, most recently from 7b04931 to 48b4ff3 Compare March 14, 2025 18:22
@vaxerski

Copy link
Copy Markdown
Member

wat da hail is "cm for blur" and shadow

@UjinT34

UjinT34 commented Mar 14, 2025

Copy link
Copy Markdown
Contributor Author

Blur uses a main fb which can be in HDR and modifies it like it is sRGB. So main fb -> sRGB. Without it you get a gray smudge in HDR mode.
Shadows and borders are defined in sRGB. So sRGB -> main. Without it you get oversaturated shadows and borders.
Probably need to have 3 image descriptions: source, main fb and output. And keep main at something simple and precise like linear fp16. But main fb -> output will require a second draw pass if decoration:screen_shader is used.

Basically everything that has some color should go through CM before going to main fb.

@abihf

abihf commented Mar 15, 2025

Copy link
Copy Markdown

error at https://github.com/hyprwm/Hyprland/pull/9600/files#diff-90a04c13f5ee4e0258fd226a879957a956751d2906c1e5b13ccf47f7dc8a7dc5R1577

should be

- if (shader == &m_RenderData.pCurrentMonData->m_shCM && !usingFinalShader && (texType == TEXTURE_RGBA || texType == TEXTURE_RGBX)) {
+ if (shader == &m_RenderData.pCurrentMonData->m_shaders->m_shCM && !usingFinalShader && (texType == TEXTURE_RGBA || texType == TEXTURE_RGBX)) {

@Honkazel Honkazel mentioned this pull request Mar 16, 2025
6 tasks
@UjinT34 UjinT34 force-pushed the extract-shaders branch 2 times, most recently from 26c31c2 to 1d485e6 Compare March 19, 2025 07:57
@vaxerski

Copy link
Copy Markdown
Member

this is not really what I envisioned for extracting shaders from source. My idea was more along the lines of:

CShader({
   .vertex = false,
   .type = TEXTURE,
   .cm = true,
   .rounding = true
 });

which would build the string. But this is fine too, however:

  • I'd move the version to the source. When you create a shader, pass the string and version, and the shader class should append it.
  • the 320 ES vertex is still needed. We allow screen shaders to be 320 ES and some people use it. (Another reason for the above)

When testing a local build without installation shaders should be copied/linked to ~/.config/hypr/shaders

Oi oi, does that mean hyprland will not launch without shaders installed to the system? That is not acceptable.

@UjinT34

UjinT34 commented Mar 22, 2025

Copy link
Copy Markdown
Contributor Author
* I'd move the `version` to the source. When you create a shader, pass the string and version, and the shader class should append it.

One of the reasons to extract shaders was syntax highlighting and static checking.

* the 320 ES vertex is still needed. We allow screen shaders to be 320 ES and some people use it. (Another reason for the above)

It's there and supported (both 300 and 320).

When testing a local build without installation shaders should be copied/linked to ~/.config/hypr/shaders

Oi oi, does that mean hyprland will not launch without shaders installed to the system? That is not acceptable.

I'll think of something. Probably won't be as clean as I'd like it to be.

@vaxerski

Copy link
Copy Markdown
Member

One of the reasons to extract shaders was syntax highlighting and static checking.

hm, fair, tho syntax highlighting for shaders aint that important

Dregu pushed a commit to Dregu/Hyprland that referenced this pull request Mar 28, 2025
* simplify and fix hdr metadata setting

* keep incorrect(?) cm skip till hyprwm#9600
vaxerski pushed a commit that referenced this pull request Mar 28, 2025
* simplify and fix hdr metadata setting

* keep incorrect(?) cm skip till #9600

@vaxerski vaxerski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@vaxerski vaxerski merged commit 7374a02 into hyprwm:main Mar 29, 2025
@PlasmaPower PlasmaPower mentioned this pull request Mar 30, 2025
6 tasks
@PlasmaPower

Copy link
Copy Markdown
Contributor

This seems to cause a regression in #9795 for me according to a bisect. Not a huge deal but hopefully fixable

WhySoBad pushed a commit to WhySoBad/Hyprland that referenced this pull request Apr 3, 2025
---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
crthpl pushed a commit to crthpl/Hyprland that referenced this pull request Jun 3, 2026
* simplify and fix hdr metadata setting

* keep incorrect(?) cm skip till hyprwm#9600
crthpl pushed a commit to crthpl/Hyprland that referenced this pull request Jun 3, 2026
---------

Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants