Repository navigation
refactor(liquidglass): share one WGSL optics source with the Qt module - #23
Merged
Merged
Conversation
The glass optics lived twice, hand-synced: liquidglass.wgsl for the KWin effect and liquidglass_core.glsl for the Kogical.LiquidGlass Qt module. - shaders/optics.wgsl is now the single source. build.rs splices it (and kawase_common.wgsl) into the entry shaders and lowers everything with naga. - naga also lowers optics.wgsl to the GLSL core the Qt module inlines. The module commits that file so it still builds without Rust; a cargo test fails while it is stale (`just liquidglass qt-core` regenerates it). - GL uniform block and sampler names come from naga's reflection instead of hardcoded mangled names. - Drop the unused SPIR-V, MSL and HLSL outputs and their naga features. - Add a LiquidGlassQsbReflection CTest for the names Qt Quick binds. Also: - glass: `debug fluctusglass stats` reports glass repaints by cause. - `just glass update` no longer claims to reload new code: KWin never unloads a plugin, so a new build runs only after logging out and back in (noted in AGENTS.md and the READMEs). - docs: record the 2026-11-30 3 x 40 s benchmark as the official resource usage, and explain the idle cost (an animating window touching the dock). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
crates/liquidglass/shaders/optics.wgslnow holds the only copy of the Liquid Glass math (SDF, Snell bezel, dome, two-zone refraction, Cauchy dispersion, rim lighting, borders, shadow).build.rssplices it intoliquidglass.wgsl(andkawase_common.wgslinto both Kawase passes) at// #include "…"lines, then naga emits WGSL, GLSL 330 core and GLSL ES 3.00.optics.wgslto the GLSL core thatlibs/liquidglass/shaders/liquidglass.fraginlines. The generatedliquidglass_core.glslis committed so the Qt module still builds without Rust;shaders::tests::qt_core_glsl_is_up_to_datefails while it is stale, andjust liquidglass qt-coreregenerates it.liquidglass.fragstays hand-written GLSL 440, so Qt'sqt_TexCoord0/ UBO names are untouched.gl_backend.rsbinds uniform blocks and samplers by names taken from naga'sReflectionInfo(gl_reflection.rs, generated) instead of hardcoded mangled strings; the build asserts GL 330 and GLES 300 agree.spv-out/msl-out/hlsl-out) are dropped: nothing used them, andwgpulowers WGSL itself. This removes the publicshaders::{spirv,msl,hlsl}modules.LiquidGlassQsbReflection: checks that the baked.qsbstill exposesqt_TexCoord0,source,qt_Matrix,qt_Opacity,itemSize,glassRect,edgeBend.qdbus6 org.kde.KWin /Effects org.kde.kwin.Effects.debug fluctusglass statsreports frames, glass passes and repaints by cause (pointer, fade, margin, backdrop, stale, update).just glass updateno longer says it "reloaded" new code. KWin never unloads a plugin, so a new effect build runs only after logging out and back in. Noted inAGENTS.md(invariant 9), the rootjustfileandglass/README.md.glass/docs/performance.md, summarized inglass/README.mdanddock/README.md; raw data inglass/tools/bench/results/2026-11-30/.Why
The optics were maintained twice in two languages, kept in step by hand. A Slang rewrite was evaluated first, but
slangccannot emit GLSL 330 core / GLES 300 (what KWin uses), so naga stays either way. Slang would only add a third compiler plus a build dependency in CI, the PKGBUILD and the flake. WGSL + naga removes the duplication with no new tools.Investigating the benchmark's idle cost (+2.6% kwin CPU) with the new
statshook showed it is not the glass idling. A maximized window ending at the dock's top edge animated during the run, and the refraction samples into it, so each change redrew the glass. Shortening that window cut glass redraws from ~21/s to ~6/s. The same investigation exposed thatjust glass updatenever actually loaded new effect code.How verified
just test: crate tests 7/7 (incl. GL reflection and the stale-core check, which was confirmed to fail on an editedoptics.wgsland on a missing core file), all CTest suites 7/7 incl.LiquidGlassQsbReflection.just liquidglass test-gpu: headless wgpu optics invariants + Apple Tahoe parity pass.just liquidglass lint: clippy clean.just test-san: 7/7 under ASan + UBSan, no reports.statscommand answers); dock and glass render as before.🤖 Generated with Claude Code