Skip to content

The native runtime for three.js: three.js, down to the metal. 45× smaller than Electron, on a Sony PS3, and path-traced at 60 fps on ray-tracing GPUs.

feat(webgpu): Omarchy Wayland layer-shell 3D wallpaper host, from doodlewind/ThreeRT-dev#8 (#300)

Evan (Yifeng) Wang80636a618fe2
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7dbd7a0..0e19d1a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -252,15 +252,18 @@ jobs:
with:
node-version: 24
cache: npm
- - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libjavascriptcoregtk-4.1-dev pkg-config libssl-dev
+ - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libjavascriptcoregtk-4.1-dev pkg-config libssl-dev libwayland-dev
- run: npm ci
- uses: ./.github/actions/cargo-cache
with:
workspaces: |
runtime
webgpu
+ webgpu/wallpaper
- run: cd runtime && cargo test --release --locked
- run: cd webgpu && cargo test --release --locked
+ # The Omarchy wallpaper host (webgpu/wallpaper, its own workspace; Wayland, so Linux only): it compiles.
+ - run: cd webgpu/wallpaper && cargo check --locked
- run: node tools/build.ts --renderer webgpu
- run: node tools/check-webgpu-gate.ts --render
diff --git a/webgpu/src/gpu.rs b/webgpu/src/gpu.rs
index dfc0faf..715ebe5 100644
--- a/webgpu/src/gpu.rs
+++ b/webgpu/src/gpu.rs
@@ -16,12 +16,27 @@ pub struct Gpu {
}
/// Options for [`crate::init`].
-#[derive(Clone, Debug, Default)]
+#[derive(Clone, Debug)]
pub struct GpuOptions {
/// Extra wgpu features the host's own renderers need (requested only if the adapter has them).
pub extra_features: wgpu::Features,
/// `wgpu::InstanceFlags` debug/validation (default: off; `THREERT_WGPU_DEBUG=1` turns it on).
pub debug: bool,
+ /// Adapter power preference (`HighPerformance` by default; `LowPower` for ambient/wallpaper hosts).
+ pub power_preference: wgpu::PowerPreference,
+ /// Memory allocation hint (`Performance` by default; `MemoryUsage` for low-footprint hosts).
+ pub memory_hints: wgpu::MemoryHints,
+}
+
+impl Default for GpuOptions {
+ fn default() -> Self {
+ Self {
+ extra_features: wgpu::Features::empty(),
+ debug: false,
+ power_preference: wgpu::PowerPreference::HighPerformance,
+ memory_hints: wgpu::MemoryHints::Performance,
+ }
+ }
}
static GPU: OnceLock<Gpu> = OnceLock::new();
@@ -39,7 +54,7 @@ pub fn init(opts: &GpuOptions) -> Result<&'static Gpu, String> {
..Default::default()
});
let adapter = pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions {
- power_preference: wgpu::PowerPreference::HighPerformance,
+ power_preference: opts.power_preference,
force_fallback_adapter: false,
compatible_surface: None,
}))
@@ -57,7 +72,7 @@ pub fn init(opts: &GpuOptions) -> Result<&'static Gpu, String> {
label: Some("threert-webgpu"),
required_features: want,
required_limits: adapter.limits(),
- memory_hints: wgpu::MemoryHints::Performance,
+ memory_hints: opts.memory_hints.clone(),
trace: wgpu::Trace::Off,
}))
.map_err(|e| format!("request_device: {e}"))?;
diff --git a/webgpu/wallpaper/.gitignore b/webgpu/wallpaper/.gitignore
new file mode 100644
index 0000000..08eba4f
--- /dev/null
+++ b/webgpu/wallpaper/.gitignore
@@ -0,0 +1,2 @@
+/target
+/demo/assets/
diff --git a/webgpu/wallpaper/Cargo.lock b/webgpu/wallpaper/Cargo.lock
new file mode 100644
index 0000000..74d6d63
--- /dev/null
+++ b/webgpu/wallpaper/Cargo.lock
@@ -0,0 +1,2196 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "adler2"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
+
+[[package]]
+name = "android_system_properties"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "arrayref"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
+
+[[package]]
+name = "arrayvec"
+version = "0.7.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "47a64a0fd06e123e9e3cf3ad01432af17dcab8185e8023edcf184fe696f9675d"
+
+[[package]]
+name = "ash"
+version = "0.38.0+1.3.281"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f"
+dependencies = [
+ "libloading",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
+
+[[package]]
+name = "bit-set"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
+dependencies = [
+ "bit-vec",
+]
+
+[[package]]
+name = "bit-vec"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
+
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
+[[package]]
+name = "bitflags"
+version = "2.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
+dependencies = [
+ "serde_core",
+]
+
+[[package]]
+name = "block"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
+
+[[package]]
+name = "bumpalo"
+version = "3.20.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"
+
+[[package]]
+name = "bytemuck"
+version = "1.25.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797"
+dependencies = [
+ "bytemuck_derive",
+]
+
+[[package]]
+name = "bytemuck_derive"
+version = "1.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "byteorder-lite"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
+
+[[package]]
+name = "cc"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95e45cf2980b2d467be49a9ed942c9179b701063a7ca3d037de7ee9bd67f8d66"
+dependencies = [
+ "find-msvc-tools",
+ "shlex",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
+
+[[package]]
+name = "cfg_aliases"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
+
+[[package]]
+name = "codespan-reporting"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81"
+dependencies = [
+ "serde",
+ "termcolor",
+ "unicode-width",
+]
+
+[[package]]
+name = "color_quant"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
+
+[[package]]
+name = "core-foundation"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.8.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
+
+[[package]]
+name = "core-graphics-types"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf"
+dependencies = [
+ "bitflags 1.3.2",
+ "core-foundation",
+ "libc",
+]
+
+[[package]]
+name = "cosmic-text"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59fd57d82eb4bfe7ffa9b1cec0c05e2fd378155b47f255a67983cb4afe0e80c2"
+dependencies = [
+ "bitflags 2.13.2",
+ "fontdb",
+ "log",
+ "rangemap",
+ "rayon",
+ "rustc-hash",
+ "rustybuzz",
+ "self_cell",
+ "swash",
+ "sys-locale",
+ "ttf-parser 0.21.1",
+ "unicode-bidi",
+ "unicode-linebreak",
+ "unicode-script",
+ "unicode-segmentation",
+]
+
+[[package]]
+name = "crc32fast"
+version = "1.5.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd9ae8fcb3ea71b0b26338b4ffb13006bb175de8fd07921089a906ce7e5e6945"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "crossbeam-deque"
+version = "0.8.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
+dependencies = [
+ "crossbeam-epoch",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-epoch"
+version = "0.9.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"
+dependencies = [
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-utils"
+version = "0.8.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
+
+[[package]]
+name = "crunchy"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
+
+[[package]]
+name = "cursor-icon"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f"
+
+[[package]]
+name = "dlib"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a"
+dependencies = [
+ "libloading",
+]
+
+[[package]]
+name = "document-features"
+version = "0.2.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61"
+dependencies = [
+ "litrs",
+]
+
+[[package]]
+name = "downcast-rs"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
+
+[[package]]
+name = "either"
+version = "1.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
+
+[[package]]
+name = "equivalent"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
+
+[[package]]
+name = "errno"
+version = "0.3.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776"
+dependencies = [
+ "libc",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "fdeflate"
+version = "0.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c"
+dependencies = [
+ "simd-adler32",
+]
+
+[[package]]
+name = "find-msvc-tools"
+version = "0.1.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3e44f110d1777dc6559a51e7d45083945ded4f1bf3305494350f693b6d20b9c8"
+
+[[package]]
+name = "flate2"
+version = "1.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4"
+dependencies = [
+ "crc32fast",
+ "miniz_oxide 0.9.1",
+ "zlib-rs",
+]
+
+[[package]]
+name = "foldhash"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
+
+[[package]]
+name = "font-types"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b3971f9a5ca983419cdc386941ba3b9e1feba01a0ab888adf78739feb2798492"
+dependencies = [
+ "bytemuck",
+]
+
+[[package]]
+name = "fontconfig-parser"
+version = "0.5.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbc773e24e02d4ddd8395fd30dc147524273a83e54e0f312d986ea30de5f5646"
+dependencies = [
+ "roxmltree",
+]
+
+[[package]]
+name = "fontdb"
+version = "0.16.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b0299020c3ef3f60f526a4f64ab4a3d4ce116b1acbf24cdd22da0068e5d81dc3"
+dependencies = [
+ "fontconfig-parser",
+ "log",
+ "memmap2",
+ "slotmap",
+ "tinyvec",
+ "ttf-parser 0.20.0",
+]
+
+[[package]]
+name = "foreign-types"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
+dependencies = [
+ "foreign-types-macros",
+ "foreign-types-shared",
+]
+
+[[package]]
+name = "foreign-types-macros"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ea5190182e6915eb873ddbc16e23b711b6eb1f9c00a0d0a3a91b5f6228475225"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "foreign-types-shared"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
+
+[[package]]
+name = "futures-core"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
+
+[[package]]
+name = "futures-task"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
+
+[[package]]
+name = "futures-util"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "pin-project-lite",
+ "slab",
+]
+
+[[package]]
+name = "gif"
+version = "0.14.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee8cfcc411d9adbbaba82fb72661cc1bcca13e8bba98b364e62b2dba8f960159"
+dependencies = [
+ "color_quant",
+ "weezl",
+]
+
+[[package]]
+name = "gl_generator"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
+dependencies = [
+ "khronos_api",
+ "log",
+ "xml-rs",
+]
+
+[[package]]
+name = "glow"
+version = "0.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c5e5ea60d70410161c8bf5da3fdfeaa1c72ed2c15f8bbb9d19fe3a4fad085f08"
+dependencies = [
+ "js-sys",
+ "slotmap",
+ "wasm-bindgen",
+ "web-sys",
+]
+
+[[package]]
+name = "glutin_wgl_sys"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e"
+dependencies = [
+ "gl_generator",
+]
+
+[[package]]
+name = "gpu-alloc"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "45cf04b2726f02df5508c6de726acdc90cdf97ac771a9a0ffd8ba10a6e696bf9"
+dependencies = [
+ "bitflags 2.13.2",
+ "gpu-alloc-types",
+]
+
+[[package]]
+name = "gpu-alloc-types"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b2bbed164dd10ed526c2e4fe3e721ca4a71c61730e5aafac6844b417b3227058"
+dependencies = [
+ "bitflags 2.13.2",
+]
+
+[[package]]
+name = "gpu-allocator"
+version = "0.27.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c151a2a5ef800297b4e79efa4f4bec035c5f51d5ae587287c9b952bdf734cacd"
+dependencies = [
+ "log",
+ "presser",
+ "thiserror 1.0.69",
+ "windows",
+]
+
+[[package]]
+name = "gpu-descriptor"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b89c83349105e3732062a895becfc71a8f921bb71ecbbdd8ff99263e3b53a0ca"
+dependencies = [
+ "bitflags 2.13.2",
+ "gpu-descriptor-types",
+ "hashbrown 0.15.5",
+]
+
+[[package]]
+name = "gpu-descriptor-types"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91"
+dependencies = [
+ "bitflags 2.13.2",
+]
+
+[[package]]
+name = "half"
+version = "2.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
+dependencies = [
+ "cfg-if",
+ "crunchy",
+ "num-traits",
+ "zerocopy",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.15.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
+dependencies = [
+ "foldhash",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.17.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc"
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "hexf-parse"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
+
+[[package]]
+name = "image"
+version = "0.25.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104"
+dependencies = [
+ "bytemuck",
+ "byteorder-lite",
+ "color_quant",
+ "gif",
+ "image-webp",
+ "moxcms",
+ "num-traits",
+ "png 0.18.1",
+ "zune-core",
+ "zune-jpeg",
+]
+
+[[package]]
+name = "image-webp"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3"
+dependencies = [
+ "byteorder-lite",
+ "quick-error",
+]
+
+[[package]]
+name = "indexmap"
+version = "2.14.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
+dependencies = [
+ "equivalent",
+ "hashbrown 0.17.2",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
+
+[[package]]
+name = "jni-sys"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258"
+dependencies = [
+ "jni-sys 0.4.1",
+]
+
+[[package]]
+name = "jni-sys"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2"
+dependencies = [
+ "jni-sys-macros",
+]
+
+[[package]]
+name = "jni-sys-macros"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264"
+dependencies = [
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "js-sys"
+version = "0.3.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a"
+dependencies = [
+ "cfg-if",
+ "futures-util",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "khronos-egl"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76"
+dependencies = [
+ "libc",
+ "libloading",
+ "pkg-config",
+]
+
+[[package]]
+name = "khronos_api"
+version = "3.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
+
+[[package]]
+name = "libc"
+version = "0.2.191"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
+
+[[package]]
+name = "libloading"
+version = "0.8.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
+dependencies = [
+ "cfg-if",
+ "windows-link",
+]
+
+[[package]]
+name = "libm"
+version = "0.2.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.4.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
+
+[[package]]
+name = "litrs"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "02b614978e47ce529faee66579f2b2fe19c94aa96d910a6a9a8043b2b02d8175"
+
+[[package]]
+name = "lock_api"
+version = "0.4.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
+dependencies = [
+ "scopeguard",
+]
+
+[[package]]
+name = "log"
+version = "0.4.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
+
+[[package]]
+name = "malloc_buf"
+version = "0.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "memchr"
+version = "2.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
+
+[[package]]
+name = "memmap2"
+version = "0.9.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "metal"
+version = "0.31.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f569fb946490b5743ad69813cb19629130ce9374034abe31614a36402d18f99e"
+dependencies = [
+ "bitflags 2.13.2",
+ "block",
+ "core-graphics-types",
+ "foreign-types",
+ "log",
+ "objc",
+ "paste",
+]
+
+[[package]]
+name = "miniz_oxide"
+version = "0.8.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
+dependencies = [
+ "adler2",
+ "simd-adler32",
+]
+
+[[package]]
+name = "miniz_oxide"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c"
+dependencies = [
+ "adler2",
+ "simd-adler32",
+]
+
+[[package]]
+name = "moxcms"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b"
+dependencies = [
+ "num-traits",
+ "pxfm",
+]
+
+[[package]]
+name = "naga"
+version = "25.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b977c445f26e49757f9aca3631c3b8b836942cb278d69a92e7b80d3b24da632"
+dependencies = [
+ "arrayvec",
+ "bit-set",
+ "bitflags 2.13.2",
+ "cfg_aliases",
+ "codespan-reporting",
+ "half",
+ "hashbrown 0.15.5",
+ "hexf-parse",
+ "indexmap",
+ "log",
+ "num-traits",
+ "once_cell",
+ "rustc-hash",
+ "spirv",
+ "strum",
+ "thiserror 2.0.21",
+ "unicode-ident",
+]
+
+[[package]]
+name = "ndk-sys"
+version = "0.5.0+25.2.9519653"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691"
+dependencies = [
+ "jni-sys 0.3.1",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+dependencies = [
+ "autocfg",
+ "libm",
+]
+
+[[package]]
+name = "objc"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
+dependencies = [
+ "malloc_buf",
+]
+
+[[package]]
+name = "objc2-core-foundation"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
+dependencies = [
+ "bitflags 2.13.2",
+]
+
+[[package]]
+name = "objc2-core-graphics"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807"
+dependencies = [
+ "bitflags 2.13.2",
+ "objc2-core-foundation",
+]
+
+[[package]]
+name = "objc2-core-text"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d"
+dependencies = [
+ "bitflags 2.13.2",
+ "objc2-core-foundation",
+ "objc2-core-graphics",
+]
+
+[[package]]
+name = "objc2-image-io"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32b0446e98cf4a784cc7a0177715ff317eeaa8463841c616cfc78aa4f953c4ea"
+dependencies = [
+ "objc2-core-foundation",
+ "objc2-core-graphics",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+
+[[package]]
+name = "ordered-float"
+version = "4.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951"
+dependencies = [
+ "num-traits",
+]
+
+[[package]]
+name = "parking_lot"
+version = "0.12.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
+dependencies = [
+ "lock_api",
+ "parking_lot_core",
+]
+
+[[package]]
+name = "parking_lot_core"
+version = "0.9.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall",
+ "smallvec",
+ "windows-link",
+]
+
+[[package]]
+name = "paste"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c938015719552d665fd0553b90d96cd7ff58e83e4c061ca99e6bb78865a72752"
+
+[[package]]
+name = "pkg-config"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
+
+[[package]]
+name = "png"
+version = "0.17.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526"
+dependencies = [
+ "bitflags 1.3.2",
+ "crc32fast",
+ "fdeflate",
+ "flate2",
+ "miniz_oxide 0.8.9",
+]
+
+[[package]]
+name = "png"
+version = "0.18.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61"
+dependencies = [
+ "bitflags 2.13.2",
+ "crc32fast",
+ "fdeflate",
+ "flate2",
+ "miniz_oxide 0.8.9",
+]
+
+[[package]]
+name = "pocket-drivers"
+version = "0.17.0"
+source = "git+https://github.com/pocket-nexus/pocketjs?rev=72b7d9a8521b7e1aac55c9f1358853ded2076bce#72b7d9a8521b7e1aac55c9f1358853ded2076bce"
+dependencies = [
+ "pocket-spec",
+]
+
+[[package]]
+name = "pocket-guest-jsc"
+version = "0.17.0"
+source = "git+https://github.com/pocket-nexus/pocketjs?rev=72b7d9a8521b7e1aac55c9f1358853ded2076bce#72b7d9a8521b7e1aac55c9f1358853ded2076bce"
+dependencies = [
+ "log",
+ "pocket-drivers",
+ "pocket-runtime",
+]
+
+[[package]]
+name = "pocket-media"
+version = "0.17.0"
+source = "git+https://github.com/pocket-nexus/pocketjs?rev=72b7d9a8521b7e1aac55c9f1358853ded2076bce#72b7d9a8521b7e1aac55c9f1358853ded2076bce"
+dependencies = [
+ "pocket-spec",
+]
+
+[[package]]
+name = "pocket-package"
+version = "0.17.0"
+source = "git+https://github.com/pocket-nexus/pocketjs?rev=72b7d9a8521b7e1aac55c9f1358853ded2076bce#72b7d9a8521b7e1aac55c9f1358853ded2076bce"
+dependencies = [
+ "pocket-drivers",
+ "pocket-spec",
+]
+
+[[package]]
+name = "pocket-render"
+version = "0.17.0"
+source = "git+https://github.com/pocket-nexus/pocketjs?rev=72b7d9a8521b7e1aac55c9f1358853ded2076bce#72b7d9a8521b7e1aac55c9f1358853ded2076bce"
+dependencies = [
+ "pocket-drivers",
+ "pocket-spec",
+]
+
+[[package]]
+name = "pocket-runtime"
+version = "0.17.0"
+source = "git+https://github.com/pocket-nexus/pocketjs?rev=72b7d9a8521b7e1aac55c9f1358853ded2076bce#72b7d9a8521b7e1aac55c9f1358853ded2076bce"
+dependencies = [
+ "pocket-drivers",
+ "pocket-package",
+ "pocket-render",
+ "pocket-spec",
+ "pocketjs-core",
+]
+
+[[package]]
+name = "pocket-spec"
+version = "0.17.0"
+source = "git+https://github.com/pocket-nexus/pocketjs?rev=72b7d9a8521b7e1aac55c9f1358853ded2076bce#72b7d9a8521b7e1aac55c9f1358853ded2076bce"
+
+[[package]]
+name = "pocketjs-core"
+version = "0.17.0"
+source = "git+https://github.com/pocket-nexus/pocketjs?rev=72b7d9a8521b7e1aac55c9f1358853ded2076bce#72b7d9a8521b7e1aac55c9f1358853ded2076bce"
+dependencies = [
+ "pocket-drivers",
+ "pocket-media",
+ "pocket-package",
+ "pocket-render",
+ "pocket-spec",
+ "taffy",
+]
+
+[[package]]
+name = "pollster"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3"
+
+[[package]]
+name = "portable-atomic"
+version = "1.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
+
+[[package]]
+name = "presser"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "profiling"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5"
+
+[[package]]
+name = "pxfm"
+version = "0.1.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea"
+
+[[package]]
+name = "quick-error"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
+
+[[package]]
+name = "quick-xml"
+version = "0.41.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "range-alloc"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08"
+
+[[package]]
+name = "rangemap"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2d43a8c8c74056248124068fde0df374d1ddf9039e747d190f01c36faeaab08"
+
+[[package]]
+name = "raw-window-handle"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539"
+
+[[package]]
+name = "rayon"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
+dependencies = [
+ "either",
+ "rayon-core",
+]
+
+[[package]]
+name = "rayon-core"
+version = "1.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
+dependencies = [
+ "crossbeam-deque",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "read-fonts"
+version = "0.22.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "69aacb76b5c29acfb7f90155d39759a29496aebb49395830e928a9703d2eec2f"
+dependencies = [
+ "bytemuck",
+ "font-types",
+]
+
+[[package]]
+name = "redox_syscall"
+version = "0.5.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
+dependencies = [
+ "bitflags 2.13.2",
+]
+
+[[package]]
+name = "renderdoc-sys"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832"
+
+[[package]]
+name = "roxmltree"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97"
+
+[[package]]
+name = "rustc-hash"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
+
+[[package]]
+name = "rustix"
+version = "0.38.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
+dependencies = [
+ "bitflags 2.13.2",
+ "errno",
+ "libc",
+ "linux-raw-sys 0.4.15",
+ "windows-sys 0.59.0",
+]
+
+[[package]]
+name = "rustix"
+version = "1.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa"
+dependencies = [
+ "bitflags 2.13.2",
+ "errno",
+ "libc",
+ "linux-raw-sys 0.12.1",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
+
+[[package]]
+name = "rustybuzz"
+version = "0.14.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cfb9cf8877777222e4a3bc7eb247e398b56baba500c38c1c46842431adc8b55c"
+dependencies = [
+ "bitflags 2.13.2",
+ "bytemuck",
+ "libm",
+ "smallvec",
+ "ttf-parser 0.21.1",
+ "unicode-bidi-mirroring",
+ "unicode-ccc",
+ "unicode-properties",
+ "unicode-script",
+]
+
+[[package]]
+name = "scoped-tls"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
+
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
+[[package]]
+name = "self_cell"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813"
+
+[[package]]
+name = "serde"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
+dependencies = [
+ "serde_core",
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.154"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
+dependencies = [
+ "itoa",
+ "memchr",
+ "serde",
+ "serde_core",
+ "zmij",
+]
+
+[[package]]
+name = "shlex"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
+
+[[package]]
+name = "simd-adler32"
+version = "0.3.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
+
+[[package]]
+name = "skrifa"
+version = "0.22.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e1c44ad1f6c5bdd4eefed8326711b7dbda9ea45dfd36068c427d332aa382cbe"
+dependencies = [
+ "bytemuck",
+ "read-fonts",
+]
+
+[[package]]
+name = "slab"
+version = "0.4.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
+
+[[package]]
+name = "slotmap"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038"
+dependencies = [
+ "version_check",
+]
+
+[[package]]
+name = "smallvec"
+version = "1.16.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59"
+
+[[package]]
+name = "smithay-client-toolkit"
+version = "0.19.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016"
+dependencies = [
+ "bitflags 2.13.2",
+ "cursor-icon",
+ "libc",
+ "log",
+ "memmap2",
+ "rustix 0.38.44",
+ "thiserror 1.0.69",
+ "wayland-backend",
+ "wayland-client",
+ "wayland-csd-frame",
+ "wayland-cursor",
+ "wayland-protocols",
+ "wayland-protocols-wlr",
+ "wayland-scanner",
+ "xkeysym",
+]
+
+[[package]]
+name = "spirv"
+version = "0.3.0+sdk-1.3.268.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844"
+dependencies = [
+ "bitflags 2.13.2",
+]
+
+[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
+[[package]]
+name = "strict-num"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
+
+[[package]]
+name = "strum"
+version = "0.26.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
+dependencies = [
+ "strum_macros",
+]
+
+[[package]]
+name = "strum_macros"
+version = "0.26.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "rustversion",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "swash"
+version = "0.1.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cbd59f3f359ddd2c95af4758c18270eddd9c730dde98598023cdabff472c2ca2"
+dependencies = [
+ "skrifa",
+ "yazi",
+ "zeno",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.119"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "3.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "sys-locale"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8eab9a99a024a169fe8a903cf9d4a3b3601109bcc13bd9e3c6fff259138626c4"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "taffy"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dfde4e2f8595f222ceaae1fb16b4963952e9b33e358869dc4cd6316b0e0790cd"
+dependencies = [
+ "arrayvec",
+ "serde",
+ "slotmap",
+]
+
+[[package]]
+name = "termcolor"
+version = "1.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
+dependencies = [
+ "thiserror-impl 1.0.69",
+]
+
+[[package]]
+name = "thiserror"
+version = "2.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
+dependencies = [
+ "thiserror-impl 2.0.21",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "2.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "threert-canvas2d"
+version = "0.1.0"
+dependencies = [
+ "cosmic-text",
+ "image",
+ "objc2-core-foundation",
+ "objc2-core-graphics",
+ "objc2-core-text",
+ "objc2-image-io",
+ "threert-jsc",
+ "threert-rt",
+ "tiny-skia",
+]
+
+[[package]]
+name = "threert-jsc"
+version = "0.1.0"
+dependencies = [
+ "pocket-guest-jsc",
+]
+
+[[package]]
+name = "threert-rt"
+version = "0.1.0"
+dependencies = [
+ "threert-jsc",
+]
+
+[[package]]
+name = "threert-wallpaper"
+version = "0.1.0"
+dependencies = [
+ "libc",
+ "raw-window-handle",
+ "serde_json",
+ "smithay-client-toolkit",
+ "threert-canvas2d",
+ "threert-jsc",
+ "threert-rt",
+ "threert-webgpu",
+ "wayland-backend",
+ "wayland-client",
+ "wayland-protocols",
+ "wgpu",
+]
+
+[[package]]
+name = "threert-webgpu"
+version = "0.1.0"
+dependencies = [
+ "pollster",
+ "serde_json",
+ "threert-canvas2d",
+ "threert-jsc",
+ "threert-rt",
+ "wgpu",
+]
+
+[[package]]
+name = "tiny-skia"
+version = "0.11.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab"
+dependencies = [
+ "arrayref",
+ "arrayvec",
+ "bytemuck",
+ "cfg-if",
+ "log",
+ "png 0.17.16",
+ "tiny-skia-path",
+]
+
+[[package]]
+name = "tiny-skia-path"
+version = "0.11.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93"
+dependencies = [
+ "arrayref",
+ "bytemuck",
+ "strict-num",
+]
+
+[[package]]
+name = "tinyvec"
+version = "1.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee"
+
+[[package]]
+name = "tokio"
+version = "1.54.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3"
+dependencies = [
+ "pin-project-lite",
+]
+
+[[package]]
+name = "ttf-parser"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4"
+
+[[package]]
+name = "ttf-parser"
+version = "0.21.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c591d83f69777866b9126b24c6dd9a18351f177e49d625920d19f989fd31cf8"
+
+[[package]]
+name = "unicode-bidi"
+version = "0.3.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5"
+
+[[package]]
+name = "unicode-bidi-mirroring"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23cb788ffebc92c5948d0e997106233eeb1d8b9512f93f41651f52b6c5f5af86"
+
+[[package]]
+name = "unicode-ccc"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1df77b101bcc4ea3d78dafc5ad7e4f58ceffe0b2b16bf446aeb50b6cb4157656"
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
+
+[[package]]
+name = "unicode-linebreak"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
+
+[[package]]
+name = "unicode-properties"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "993ad287eb20e8ba755312801cfe1413e0f25d604075863acaddca10b04c1833"
+
+[[package]]
+name = "unicode-script"
+version = "0.5.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa04c955db05429d464c74d495c1ee677e1866e783a4c3747f9c0cef7756cabf"
+
+[[package]]
+name = "unicode-segmentation"
+version = "1.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
+
+[[package]]
+name = "unicode-width"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557"
+
+[[package]]
+name = "version_check"
+version = "0.9.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c"
+dependencies = [
+ "cfg-if",
+ "rustversion",
+ "wasm-bindgen-macro",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-futures"
+version = "0.4.80"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501"
+dependencies = [
+ "js-sys",
+ "tokio",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a"
+dependencies = [
+ "bumpalo",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "wayland-backend"
+version = "0.3.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078"
+dependencies = [
+ "cc",
+ "downcast-rs",
+ "rustix 1.1.6",
+ "scoped-tls",
+ "smallvec",
+ "wayland-sys",
+]
+
+[[package]]
+name = "wayland-client"
+version = "0.31.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073"
+dependencies = [
+ "bitflags 2.13.2",
+ "rustix 1.1.6",
+ "wayland-backend",
+ "wayland-scanner",
+]
+
+[[package]]
+name = "wayland-csd-frame"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e"
+dependencies = [
+ "bitflags 2.13.2",
+ "cursor-icon",
+ "wayland-backend",
+]
+
+[[package]]
+name = "wayland-cursor"
+version = "0.31.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d"
+dependencies = [
+ "rustix 1.1.6",
+ "wayland-client",
+ "xcursor",
+]
+
+[[package]]
+name = "wayland-protocols"
+version = "0.32.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6"
+dependencies = [
+ "bitflags 2.13.2",
+ "wayland-backend",
+ "wayland-client",
+ "wayland-scanner",
+]
+
+[[package]]
+name = "wayland-protocols-wlr"
+version = "0.3.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234"
+dependencies = [
+ "bitflags 2.13.2",
+ "wayland-backend",
+ "wayland-client",
+ "wayland-protocols",
+ "wayland-scanner",
+]
+
+[[package]]
+name = "wayland-scanner"
+version = "0.31.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0"
+dependencies = [
+ "proc-macro2",
+ "quick-xml",
+ "quote",
+]
+
+[[package]]
+name = "wayland-sys"
+version = "0.31.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be"
+dependencies = [
+ "dlib",
+ "log",
+ "pkg-config",
+]
+
+[[package]]
+name = "web-sys"
+version = "0.3.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88"
+dependencies = [
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "weezl"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
+
+[[package]]
+name = "wgpu"
+version = "25.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec8fb398f119472be4d80bc3647339f56eb63b2a331f6a3d16e25d8144197dd9"
+dependencies = [
+ "arrayvec",
+ "bitflags 2.13.2",
+ "cfg_aliases",
+ "document-features",
+ "hashbrown 0.15.5",
+ "js-sys",
+ "log",
+ "naga",
+ "parking_lot",
+ "portable-atomic",
+ "profiling",
+ "raw-window-handle",
+ "smallvec",
+ "static_assertions",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "web-sys",
+ "wgpu-core",
+ "wgpu-hal",
+ "wgpu-types",
+]
+
+[[package]]
+name = "wgpu-core"
+version = "25.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f7b882196f8368511d613c6aeec80655160db6646aebddf8328879a88d54e500"
+dependencies = [
+ "arrayvec",
+ "bit-set",
+ "bit-vec",
+ "bitflags 2.13.2",
+ "cfg_aliases",
+ "document-features",
+ "hashbrown 0.15.5",
+ "indexmap",
+ "log",
+ "naga",
+ "once_cell",
+ "parking_lot",
+ "portable-atomic",
+ "profiling",
+ "raw-window-handle",
+ "rustc-hash",
+ "smallvec",
+ "thiserror 2.0.21",
+ "wgpu-core-deps-apple",
+ "wgpu-core-deps-emscripten",
+ "wgpu-core-deps-windows-linux-android",
+ "wgpu-hal",
+ "wgpu-types",
+]
+
+[[package]]
+name = "wgpu-core-deps-apple"
+version = "25.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cfd488b3239b6b7b185c3b045c39ca6bf8af34467a4c5de4e0b1a564135d093d"
+dependencies = [
+ "wgpu-hal",
+]
+
+[[package]]
+name = "wgpu-core-deps-emscripten"
+version = "25.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f09ad7aceb3818e52539acc679f049d3475775586f3f4e311c30165cf2c00445"
+dependencies = [
+ "wgpu-hal",
+]
+
+[[package]]
+name = "wgpu-core-deps-windows-linux-android"
+version = "25.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cba5fb5f7f9c98baa7c889d444f63ace25574833df56f5b817985f641af58e46"
+dependencies = [
+ "wgpu-hal",
+]
+
+[[package]]
+name = "wgpu-hal"
+version = "25.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f968767fe4d3d33747bbd1473ccd55bf0f6451f55d733b5597e67b5deab4ad17"
+dependencies = [
+ "android_system_properties",
+ "arrayvec",
+ "ash",
+ "bit-set",
+ "bitflags 2.13.2",
+ "block",
+ "bytemuck",
+ "cfg-if",
+ "cfg_aliases",
+ "core-graphics-types",
+ "glow",
+ "glutin_wgl_sys",
+ "gpu-alloc",
+ "gpu-allocator",
+ "gpu-descriptor",
+ "hashbrown 0.15.5",
+ "js-sys",
+ "khronos-egl",
+ "libc",
+ "libloading",
+ "log",
+ "metal",
+ "naga",
+ "ndk-sys",
+ "objc",
+ "ordered-float",
+ "parking_lot",
+ "portable-atomic",
+ "profiling",
+ "range-alloc",
+ "raw-window-handle",
+ "renderdoc-sys",
+ "smallvec",
+ "thiserror 2.0.21",
+ "wasm-bindgen",
+ "web-sys",
+ "wgpu-types",
+ "windows",
+ "windows-core",
+]
+
+[[package]]
+name = "wgpu-types"
+version = "25.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2aa49460c2a8ee8edba3fca54325540d904dd85b2e086ada762767e17d06e8bc"
+dependencies = [
+ "bitflags 2.13.2",
+ "bytemuck",
+ "js-sys",
+ "log",
+ "thiserror 2.0.21",
+ "web-sys",
+]
+
+[[package]]
+name = "winapi-util"
+version = "0.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
+dependencies = [
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "windows"
+version = "0.58.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
+dependencies = [
+ "windows-core",
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-core"
+version = "0.58.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
+dependencies = [
+ "windows-implement",
+ "windows-interface",
+ "windows-result",
+ "windows-strings",
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-implement"
+version = "0.58.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "windows-interface"
+version = "0.58.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[package]]
+name = "windows-result"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-strings"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
+dependencies = [
+ "windows-result",
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.59.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.61.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "xcursor"
+version = "0.3.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23"
+
+[[package]]
+name = "xkeysym"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56"
+
+[[package]]
+name = "xml-rs"
+version = "0.8.29"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7"
+
+[[package]]
+name = "yazi"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c94451ac9513335b5e23d7a8a2b61a7102398b8cca5160829d313e84c9d98be1"
+
+[[package]]
+name = "zeno"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd15f8e0dbb966fd9245e7498c7e9e5055d9e5c8b676b95bd67091cd11a1e697"
+
+[[package]]
+name = "zerocopy"
+version = "0.8.66"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cba8a86aee14fc8cc6c208af60854b3d4ab7185a9a369a12c648faa2716ff42a"
+dependencies = [
+ "zerocopy-derive",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.8.66"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f89bca3b96ceb3cfcb4572790402f977442270d252b9a8504ebc258760c55f94"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "zlib-rs"
+version = "0.6.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa76918995d776d9dd34d371030be228d021137449771493d56e29f77e4148ac"
+
+[[package]]
+name = "zmij"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
+
+[[package]]
+name = "zune-core"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b"
+
+[[package]]
+name = "zune-jpeg"
+version = "0.5.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296"
+dependencies = [
+ "zune-core",
+]
diff --git a/webgpu/wallpaper/Cargo.toml b/webgpu/wallpaper/Cargo.toml
new file mode 100644
index 0000000..6a1020a
--- /dev/null
+++ b/webgpu/wallpaper/Cargo.toml
@@ -0,0 +1,35 @@
+[workspace]
+
+[package]
+name = "threert-wallpaper"
+description = "Low-power Wayland wlr-layer-shell live 3D wallpaper host for Omarchy on ThreeRT WebGPU"
+version = "0.1.0"
+edition = "2024"
+license = "MIT"
+
+[[bin]]
+name = "threert-wallpaper"
+path = "src/main.rs"
+
+[dependencies]
+jsc = { package = "threert-jsc", path = "../../runtime/crates/jsc" }
+rt = { package = "threert-rt", path = "../../runtime/crates/rt" }
+canvas2d = { package = "threert-canvas2d", path = "../../runtime/crates/canvas2d" }
+threert-webgpu = { path = ".." }
+wgpu = "25"
+serde_json = "1"
+libc = "0.2"
+
+[target.'cfg(target_os = "linux")'.dependencies]
+smithay-client-toolkit = { version = "0.19", default-features = false }
+wayland-backend = { version = "0.3", features = ["client_system"] }
+wayland-client = "0.31"
+wayland-protocols = { version = "0.32", features = ["client", "staging"] }
+raw-window-handle = "0.6"
+
+[profile.release]
+opt-level = 3
+lto = "fat"
+codegen-units = 1
+panic = "abort"
+strip = true
diff --git a/webgpu/wallpaper/README.md b/webgpu/wallpaper/README.md
new file mode 100644
index 0000000..89bddb1
--- /dev/null
+++ b/webgpu/wallpaper/README.md
@@ -0,0 +1,37 @@
+# ThreeRT Live 3D Wallpaper Host for Omarchy (`threert-wallpaper`)
+
+A single-process, low-power Wayland `wlr-layer-shell` (`Layer::Background`) host that runs standard **three.js `WebGPURenderer` + TSL** scenes natively on `threert-jsc` + `threert-webgpu` (`wgpu` over Vulkan) — with zero Chromium/WebView/DOM overhead and native Omarchy integration.
+
+See [**REPORT.md**](REPORT.md) for the full design overview and apples-to-apples **ThreeRT vs Chromium 155 WebGPU** benchmark on *Omarchy Orbital — Living Earth*.
+
+## Features
+
+- **Native Wayland `wlr-layer-shell` (`Layer::Background`) + `wp_viewporter`**: Direct zero-blit swapchain rendering with fractional HiDPI (`1.5×`, `1.25×`, etc.) and dynamic render scaling.
+- **Omarchy Shell Seamless Handoff (`--omarchy`)**: Suspends `omarchy-shell`'s static background after the first frame is presented (`omarchy-shell -q background setSuspended true`) and cleanly restores it on `SIGINT`/`SIGTERM`/exit.
+- **Zero-Overhead Hyprland Occlusion Auto-Pause**: Event-driven listener on `$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock`; halts JS `rAF` + GPU submission completely (**0.00% CPU, 2.1 wakeups/s, 97% iGPU RC6 sleep**) whenever windows cover the desktop or DPMS turns off.
+- **AC / Battery Power Profiles**: Initializes `wgpu` with `PowerPreference::LowPower` and `MemoryHints::MemoryUsage`; adapts FPS and render scale automatically on battery (`--fps 60 --battery-fps 24 --render-scale 1.0 --battery-scale 0.75`).
+- **Live Omarchy Theme Sync**: Watches `~/.local/state/omarchy/current/theme/colors.toml` and pushes palette updates into `globalThis.__wallpaper.onThemeChange(...)`.
+- **Zero-Copy Local Resource Loader**: Exposes `__native.sys.resource(path)` backed by `--assets <dir>` (default `<script_dir>/assets`) so high-res textures decode offline via `createImageBitmap`.
+
+## Build & Run
+
+```bash
+# 1. Build the release binary (~7.4 MiB stripped)
+cargo build --release --manifest-path webgpu/wallpaper/Cargo.toml
+
+# 2. Bundle the 4K Earth demo ("Omarchy Orbital — Living Earth") + stage textures (see Assets below)
+bun webgpu/wallpaper/demo/build.mjs
+
+# 3. Run live as your Omarchy desktop wallpaper (Ctrl-C cleanly restores static wallpaper)
+./webgpu/wallpaper/target/release/threert-wallpaper \
+ --runtime out/webgpu/runtime.js \
+ --script out/webgpu/wallpaper-demo.js \
+ --omarchy --fps 60 --battery-fps 24
+
+# 4. Run the apples-to-apples ThreeRT vs Chromium WebGPU benchmark
+node webgpu/wallpaper/bench/bench.mjs --duration 12
+```
+
+## Assets
+
+The demo's three 4K textures (`earth_day_4096.jpg`, `earth_night_4096.jpg`, `earth_bump_roughness_clouds_4096.jpg`, made from NASA imagery) are not committed. They are in [doodlewind/ThreeRT-dev#8](https://github.com/doodlewind/ThreeRT-dev/pull/8) ([`demo/assets/`](https://github.com/doodlewind/ThreeRT-dev/tree/195b05e0ccc3db3002974a5a8be063e27efc6746/webgpu/wallpaper/demo/assets)); put them in `webgpu/wallpaper/demo/assets/` (ignored by git) before step 2.
diff --git a/webgpu/wallpaper/REPORT.md b/webgpu/wallpaper/REPORT.md
new file mode 100644
index 0000000..517990d
--- /dev/null
+++ b/webgpu/wallpaper/REPORT.md
@@ -0,0 +1,61 @@
+# ThreeRT Live 3D Wallpaper for Omarchy — Benchmark & Design Report
+
+> **Scene**: *Omarchy Orbital — Living Earth* (4K NASA Blue Marble / Black Marble / Elevation+Roughness+Cloud maps, two-layer drifting cloud deck with surface shadows, Rayleigh/twilight atmospheric scattering, multi-spectral starfield, Omarchy `colors.toml` theme harmonization)
+> **Hardware**: ThinkPad X1 Nano (`x1nano-omarchy`), Intel Iris Xe Graphics (TGL GT2, Vulkan), `2160×1350 @ 60Hz` (`1440×900` logical, `1.5×` scale), Hyprland Wayland
+> **Raw dataset**: [`docs/benchmark-results.json`](docs/benchmark-results.json)
+> **Reproduce**: `node webgpu/wallpaper/bench/bench.mjs --duration 12`
+
+> **Screenshots** (not committed): [`earth-preview.png`](https://github.com/doodlewind/ThreeRT-dev/blob/195b05e0ccc3db3002974a5a8be063e27efc6746/webgpu/wallpaper/docs/earth-preview.png) (2160×1350 native WebGPU) and [`earth-americas.png`](https://github.com/doodlewind/ThreeRT-dev/blob/195b05e0ccc3db3002974a5a8be063e27efc6746/webgpu/wallpaper/docs/earth-americas.png), in [doodlewind/ThreeRT-dev#8](https://github.com/doodlewind/ThreeRT-dev/pull/8)
+
+## 1. Architecture & Omarchy Integration
+
+Omarchy ships a native video wallpaper engine (`omarchy/owe`, `libmpv` over `wlr-layer-shell`) and exposes `omarchy-shell background setSuspended true|false` in `Background.qml` so external wallpaper engines can seamlessly take over Wayland's `Layer::Background`. OWE only decodes video/GIF/stills, whereas real-time 3D/Three.js wallpapers on Linux have typically required embedding a full Chromium/WebView stack.
+
+`threert-wallpaper` runs standard **three.js `WebGPURenderer` + TSL** scenes directly on `threert-jsc` + `threert-webgpu` (`wgpu` over Vulkan) in a single `7.4 MiB` native process:
+
+- **Low-power GPU profile** (`webgpu/src/gpu.rs`): `PowerPreference::LowPower` + `MemoryHints::MemoryUsage`.
+- **Zero-blit Wayland `wlr-layer-shell` swapchain** (`src/wayland.rs`): Direct swapchain rendering (`blitted_frames = 0`) with `wp_viewporter` fractional HiDPI and `floor()` physical sizing matching `three.js`.
+- **Event-driven Hyprland occlusion auto-pause** (`src/hypr.rs`): Blocks on `$XDG_RUNTIME_DIR/hypr/.../.socket2.sock` with zero polling; pauses JS `rAF` + GPU submission on a `Condvar` whenever a fullscreen/tiled window covers the workspace or DPMS turns off.
+- **Omarchy lifecycle & live theme sync** (`src/omarchy.rs`): RAII `omarchy-shell background setSuspended` guard + live `colors.toml` watcher (`globalThis.__wallpaper.onThemeChange`).
+
+## 2. Apples-to-Apples Methodology
+
+- **Identical scene & bundle**: Both `threert-wallpaper` and `Chromium 155.0.8059.84` execute the exact same minified `854 KiB` `wallpaper-demo.js` bundle and decode the same three 4K NASA JPEG assets (`earth_day_4096.jpg`, `earth_night_4096.jpg`, `earth_bump_roughness_clouds_4096.jpg`).
+- **Identical hardware backend**: Both verified `backend=WebGPU` over Vulkan (`Intel Iris Xe`).
+- **Identical physical resolution & FPS**: Both locked to `2160×1350` at 60fps (`58.1 vs 59.7 fps`) and `1620×1012` at 30fps (`28.1 vs 29.9 fps`).
+- **Leanest Chromium baseline**: `--app`, fresh `--user-data-dir`, `--disable-extensions`, `--disable-sync`, `--disable-background-networking`, `--ozone-platform=wayland --enable-unsafe-webgpu --enable-features=Vulkan`.
+- **Objective OS/hardware metrics**: Full process-tree PSS/RSS from `/proc/<pid>/smaps_rollup`, CPU% from `/proc/<pid>/stat`, context switches (wakeups/s) from `/proc/<pid>/status`, and Intel DRM hardware counters (`rc6_residency_ms` & `rps_act_freq_mhz`).
+
+## 3. Benchmark Results (4K Living Earth)
+
+Idle desktop baseline prior to run: Intel iGPU `12.75%` active, `23.4 MHz` avg clock.
+
+| Metric | **ThreeRT (`threert-wallpaper`)** | **Chromium 155 WebGPU** | **ThreeRT Advantage** |
+|---|---:|---:|---:|
+| **Binary Size** | **7.4 MiB** | 317 MiB | **42.8× smaller** |
+| **OS Processes / Threads** | **1 / 19** | 10 / 107 | **10× fewer procs / 5.6× fewer threads** |
+| **Cold-Start TTFF** *(median of 3, incl. 3× 4K JPEG decode)* | **574.8 ms** (`562–575 ms`) | 704.9 ms (`695–762 ms`) | **1.23× faster (-18%)** |
+| **Active 60 FPS (`2160×1350`, Vulkan WebGPU)** | | | |
+| ↳ Process-Tree CPU % | **15.56%** *(P50 frame **2.16 ms**)* | 39.87% | **2.56× lower CPU (-61%)** |
+| ↳ Wakeups / sec *(ctxt switches)* | **95.8 / s** | 909.3 / s | **9.49× fewer wakeups (-89.5%)** |
+| ↳ Memory PSS / RSS | **232.2 MiB** / **247.7 MiB** | 483.7 MiB / 1,266.8 MiB | **2.08× lower PSS / 5.11× lower RSS** |
+| ↳ Intel iGPU Active (`100% − RC6`) | **55.68%** | 69.17% | **-13.5 pp (-19.5% GPU active)** |
+| ↳ Intel iGPU Avg Clock | **444.8 MHz** | 522.3 MHz | **-77.5 MHz (-15% GPU clock)** |
+| ↳ Direct Swapchain Blits | **0 / 934 frames** | Multi-process compositor copy | **100% zero-blit** |
+| **Battery 30 FPS (`1620×1012`, Vulkan WebGPU)** | | | |
+| ↳ Process-Tree CPU % | **7.10%** *(P50 frame **1.61 ms**)* | 21.03% | **2.96× lower CPU (-66%)** |
+| ↳ Wakeups / sec *(ctxt switches)* | **36.5 / s** | 654.4 / s | **17.9× fewer wakeups (-94.4%)** |
+| ↳ Memory PSS / RSS | **218.9 MiB** / **234.3 MiB** | 481.2 MiB / 1,253.5 MiB | **2.20× lower PSS / 5.35× lower RSS** |
+| ↳ Direct Swapchain Blits | **0 / 450 frames** | Multi-process compositor copy | **100% zero-blit** |
+| **Occluded Desktop (Window Covering Workspace)** | | | |
+| ↳ Process-Tree CPU % | **0.00%** | *(keeps running w/o WM hooks)* | **Zero CPU** |
+| ↳ Wakeups / sec | **2.1 / s** | *(654–909 / s unpaused)* | **~310–430× fewer wakeups** |
+| ↳ Intel iGPU Active (`100% − RC6`) | **3.04%** *(97.0% RC6 deep sleep)* | *(54–69% active)* | **Near-zero GPU** |
+| ↳ Intel iGPU Avg Clock | **2.1 MHz** | *(256–522 MHz)* | **Idle GPU** |
+| ↳ Memory PSS | **207.9 MiB** | 481.2 MiB | **2.31× lower PSS (-57%)** |
+
+## 4. Key Takeaways
+
+1. **Zero browser IPC & compositor tax**: At full native `2160×1350 @ 60fps` on a 4K-textured Earth, ThreeRT spends only **2.16 ms P50 CPU/frame** (`15.56%` total CPU vs Chromium's `39.87%`) with **0 intermediate blits** (`934/934` direct frames), cutting PSS memory in half (`232` vs `484 MiB`) and RSS by over 5× (`248` vs `1,267 MiB`).
+2. **Dramatically better battery pacing at 30 FPS**: Chromium's 10-process compositor still wakes at 60Hz VSync (`654.4 wakeups/s`, `21.0%` CPU) even when JS throttles to 30fps. ThreeRT's host pacer genuinely sleeps between frames (`36.5 wakeups/s`, `7.1%` CPU — **17.9× fewer wakeups** and **2.96× lower CPU**).
+3. **True zero-cost occluded state**: During normal coding when tiled/fullscreen windows cover the desktop, Hyprland occlusion auto-pause drops ThreeRT to **`0.00%` CPU, `2.1 wakeups/s`, `3.04%` iGPU active (`2.1 MHz`, 97% RC6 sleep)**.
diff --git a/webgpu/wallpaper/bench/bench.mjs b/webgpu/wallpaper/bench/bench.mjs
new file mode 100644
index 0000000..ac6ae6b
--- /dev/null
+++ b/webgpu/wallpaper/bench/bench.mjs
@@ -0,0 +1,540 @@
+// Reproducible apples-to-apples benchmark: ThreeRT (`threert-wallpaper`) vs Chromium WebView
+// running the EXACT same three.js WebGPURenderer + TSL wallpaper bundle (`out/webgpu/wallpaper-demo.js`).
+//
+// Measures:
+// - Binary & runtime footprint
+// - Process-tree PSS & RSS memory (MiB) via /proc/<pid>/smaps_rollup
+// - Process-tree CPU% via /proc/<pid>/stat
+// - Voluntary + involuntary context switches / sec (wakeups/s)
+// - Intel iGPU active residency % (100 - Δrc6_residency_ms / Δwall_ms) & avg MHz (rps_act_freq_mhz)
+// - Cold-start Time-To-First-Frame (TTFF ms)
+// - Occluded-desktop idle power / CPU / wakeups (ThreeRT auto-pause vs Chromium)
+//
+// Usage: node webgpu/wallpaper/bench/bench.mjs [--out <dir>] [--duration 15]
+import { spawn, spawnSync } from "node:child_process";
+import { createServer } from "node:http";
+import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+
+const benchDir = import.meta.dirname;
+const root = join(benchDir, "..", "..", "..");
+const outArgIdx = process.argv.indexOf("--out");
+const outDir = outArgIdx >= 0 ? process.argv[outArgIdx + 1] : join(root, "out", "webgpu", "wallpaper-bench");
+const durArgIdx = process.argv.indexOf("--duration");
+const MEASURE_SEC = durArgIdx >= 0 ? Math.max(5, parseFloat(process.argv[durArgIdx + 1])) : 15;
+const WARMUP_SEC = 4;
+
+mkdirSync(outDir, { recursive: true });
+
+const wallpaperBin = join(root, "webgpu", "wallpaper", "target", "release", "threert-wallpaper");
+const runtimeJs = join(root, "out", "webgpu", "runtime.js");
+const demoJs = join(root, "out", "webgpu", "wallpaper-demo.js");
+const demoHtml = join(root, "out", "webgpu", "wallpaper-demo.html");
+const CLK_TCK = 100; // Linux x86_64 USER_HZ
+
+const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
+
+function findDrmGtPath() {
+ try {
+ for (const card of readdirSync("/sys/class/drm")) {
+ const p = `/sys/class/drm/${card}/gt/gt0`;
+ if (existsSync(join(p, "rc6_residency_ms"))) return p;
+ }
+ } catch {}
+ return null;
+}
+
+const DRM_GT = findDrmGtPath();
+
+function readRc6Ms() {
+ if (!DRM_GT) return null;
+ try {
+ return parseInt(readFileSync(join(DRM_GT, "rc6_residency_ms"), "utf8").trim(), 10);
+ } catch {
+ return null;
+ }
+}
+
+function readGpuFreqMhz() {
+ if (!DRM_GT) return null;
+ try {
+ return parseInt(readFileSync(join(DRM_GT, "rps_act_freq_mhz"), "utf8").trim(), 10);
+ } catch {
+ return null;
+ }
+}
+
+function readBatteryPowerW() {
+ try {
+ const status = readFileSync("/sys/class/power_supply/BAT0/status", "utf8").trim();
+ const uw = parseInt(readFileSync("/sys/class/power_supply/BAT0/power_now", "utf8").trim(), 10);
+ return { status, watts: Number.isFinite(uw) ? uw / 1e6 : null };
+ } catch {
+ return { status: "unknown", watts: null };
+ }
+}
+
+/** Collect all PIDs belonging to `rootPid`'s process tree (plus any Chromium helpers matching `tag`). */
+function collectTreePids(rootPid, cmdTag = null) {
+ const children = new Map();
+ const tagged = new Set();
+ for (const name of readdirSync("/proc")) {
+ if (!/^\d+$/.test(name)) continue;
+ const pid = parseInt(name, 10);
+ try {
+ const stat = readFileSync(`/proc/${pid}/stat`, "utf8");
+ const rparen = stat.lastIndexOf(")");
+ if (rparen < 0) continue;
+ const fields = stat.slice(rparen + 2).split(" ");
+ const ppid = parseInt(fields[1], 10);
+ if (!children.has(ppid)) children.set(ppid, []);
+ children.get(ppid).push(pid);
+ if (cmdTag) {
+ const cmdline = readFileSync(`/proc/${pid}/cmdline`, "utf8");
+ if (cmdline.includes(cmdTag)) tagged.add(pid);
+ }
+ } catch {}
+ }
+ const visited = new Set();
+ const queue = [rootPid, ...tagged];
+ while (queue.length > 0) {
+ const p = queue.shift();
+ if (visited.has(p)) continue;
+ if (!existsSync(`/proc/${p}`)) continue;
+ visited.add(p);
+ for (const c of children.get(p) || []) queue.push(c);
+ }
+ return [...visited];
+}
+
+function sampleProcTree(rootPid, cmdTag = null) {
+ const pids = collectTreePids(rootPid, cmdTag);
+ let pssKb = 0;
+ let rssKb = 0;
+ let cpuTicks = 0;
+ let ctxtSwitches = 0;
+ let threads = 0;
+ for (const pid of pids) {
+ try {
+ const smaps = readFileSync(`/proc/${pid}/smaps_rollup`, "utf8");
+ const mPss = /^Pss:\s+(\d+)/m.exec(smaps);
+ const mRss = /^Rss:\s+(\d+)/m.exec(smaps);
+ if (mPss) pssKb += parseInt(mPss[1], 10);
+ if (mRss) rssKb += parseInt(mRss[1], 10);
+ } catch {}
+ try {
+ const stat = readFileSync(`/proc/${pid}/stat`, "utf8");
+ const rparen = stat.lastIndexOf(")");
+ if (rparen >= 0) {
+ const fields = stat.slice(rparen + 2).split(" ");
+ cpuTicks += parseInt(fields[11], 10) + parseInt(fields[12], 10); // utime + stime
+ threads += parseInt(fields[17], 10);
+ }
+ } catch {}
+ try {
+ const status = readFileSync(`/proc/${pid}/status`, "utf8");
+ const v = /^voluntary_ctxt_switches:\s+(\d+)/m.exec(status);
+ const nv = /^nonvoluntary_ctxt_switches:\s+(\d+)/m.exec(status);
+ if (v) ctxtSwitches += parseInt(v[1], 10);
+ if (nv) ctxtSwitches += parseInt(nv[1], 10);
+ } catch {}
+ }
+ return {
+ procCount: pids.length,
+ threads,
+ pssMiB: pssKb / 1024,
+ rssMiB: rssKb / 1024,
+ cpuTicks,
+ ctxtSwitches,
+ };
+}
+
+function median(arr) {
+ if (!arr.length) return 0;
+ const s = [...arr].sort((a, b) => a - b);
+ return s[Math.floor(s.length / 2)];
+}
+
+function avg(arr) {
+ return arr.length ? arr.reduce((a, b) => a + b, 0) / arr.length : 0;
+}
+
+async function measureBaseline(sec = 8) {
+ console.log(`\n[bench] Measuring idle desktop baseline (${sec}s)...`);
+ const rc6Start = readRc6Ms();
+ const t0 = performance.now();
+ const freqs = [];
+ const endAt = t0 + sec * 1000;
+ while (performance.now() < endAt) {
+ const f = readGpuFreqMhz();
+ if (f !== null) freqs.push(f);
+ await sleep(250);
+ }
+ const wallMs = performance.now() - t0;
+ const rc6End = readRc6Ms();
+ const gpuActivePct =
+ rc6Start !== null && rc6End !== null
+ ? Math.max(0, Math.min(100, 100 * (1 - (rc6End - rc6Start) / wallMs)))
+ : null;
+ const res = {
+ wallMs,
+ gpuActivePct: gpuActivePct !== null ? +gpuActivePct.toFixed(2) : null,
+ gpuAvgMhz: +avg(freqs).toFixed(1),
+ battery: readBatteryPowerW(),
+ };
+ console.log("[bench] Baseline:", JSON.stringify(res));
+ return res;
+}
+
+async function measureProcess(label, spawnFn, { warmupSec = WARMUP_SEC, measureSec = MEASURE_SEC, cmdTag = null } = {}) {
+ console.log(`\n[bench] Running: ${label} (warmup ${warmupSec}s + measure ${measureSec}s)...`);
+ const { proc, cleanup, extra } = spawnFn();
+ let exited = false;
+ let stderrBuf = "";
+ proc.stderr?.on("data", (d) => {
+ stderrBuf += d.toString();
+ });
+ proc.on("exit", () => {
+ exited = true;
+ });
+
+ await sleep(warmupSec * 1000);
+ if (exited) {
+ cleanup?.();
+ throw new Error(`${label} exited during warmup:\n${stderrBuf}`);
+ }
+
+ const s0 = sampleProcTree(proc.pid, cmdTag);
+ const rc6Start = readRc6Ms();
+ const t0 = performance.now();
+
+ const pssSamples = [];
+ const rssSamples = [];
+ const procCountSamples = [];
+ const threadSamples = [];
+ const freqSamples = [];
+ let prevTicks = s0.cpuTicks;
+ let prevCtxt = s0.ctxtSwitches;
+ let totalDeltaTicks = 0;
+ let totalDeltaCtxt = 0;
+
+ const endAt = t0 + measureSec * 1000;
+ let step = 0;
+ while (performance.now() < endAt && !exited) {
+ await sleep(250);
+ step++;
+ const f = readGpuFreqMhz();
+ if (f !== null) freqSamples.push(f);
+ if (step % 4 === 0) {
+ const s = sampleProcTree(proc.pid, cmdTag);
+ pssSamples.push(s.pssMiB);
+ rssSamples.push(s.rssMiB);
+ procCountSamples.push(s.procCount);
+ threadSamples.push(s.threads);
+ if (s.cpuTicks >= prevTicks) totalDeltaTicks += s.cpuTicks - prevTicks;
+ if (s.ctxtSwitches >= prevCtxt) totalDeltaCtxt += s.ctxtSwitches - prevCtxt;
+ prevTicks = s.cpuTicks;
+ prevCtxt = s.ctxtSwitches;
+ }
+ }
+
+ const wallMs = performance.now() - t0;
+ const rc6End = readRc6Ms();
+ const sEnd = sampleProcTree(proc.pid, cmdTag);
+ if (sEnd.cpuTicks >= prevTicks) totalDeltaTicks += sEnd.cpuTicks - prevTicks;
+ if (sEnd.ctxtSwitches >= prevCtxt) totalDeltaCtxt += sEnd.ctxtSwitches - prevCtxt;
+
+ // Terminate cleanly and wait for exit
+ try {
+ proc.kill("SIGTERM");
+ } catch {}
+ for (let i = 0; i < 30 && !exited; i++) await sleep(100);
+ if (!exited) {
+ try {
+ proc.kill("SIGKILL");
+ } catch {}
+ await sleep(300);
+ }
+ cleanup?.();
+
+ const cpuPct = ((totalDeltaTicks / CLK_TCK) / (wallMs / 1000)) * 100;
+ const wakeupsPerSec = totalDeltaCtxt / (wallMs / 1000);
+ const gpuActivePct =
+ rc6Start !== null && rc6End !== null
+ ? Math.max(0, Math.min(100, 100 * (1 - (rc6End - rc6Start) / wallMs)))
+ : null;
+
+ const result = {
+ label,
+ wallSec: +(wallMs / 1000).toFixed(2),
+ procCount: Math.round(median(procCountSamples)),
+ threads: Math.round(median(threadSamples)),
+ pssMiB: +median(pssSamples).toFixed(1),
+ pssPeakMiB: +(pssSamples.length ? Math.max(...pssSamples) : 0).toFixed(1),
+ rssMiB: +median(rssSamples).toFixed(1),
+ cpuPct: +cpuPct.toFixed(2),
+ wakeupsPerSec: +wakeupsPerSec.toFixed(1),
+ gpuActivePct: gpuActivePct !== null ? +gpuActivePct.toFixed(2) : null,
+ gpuAvgMhz: +avg(freqSamples).toFixed(1),
+ extra: extra?.(stderrBuf) ?? {},
+ };
+ console.log(`[bench] ${label}:`, JSON.stringify(result));
+ return result;
+}
+
+async function startStaticServer() {
+ const mime = { ".html": "text/html", ".js": "application/javascript", ".jpg": "image/jpeg", ".png": "image/png" };
+ const assetsDir = join(root, "out", "webgpu", "assets");
+ const server = createServer((req, res) => {
+ const urlPath = (req.url || "/").split("?")[0];
+ let target = demoHtml;
+ if (urlPath === "/wallpaper-demo.js") {
+ target = demoJs;
+ } else if (urlPath.startsWith("/assets/")) {
+ const rel = urlPath.slice("/assets/".length);
+ if (rel && !rel.includes("..") && !rel.includes("/")) {
+ target = join(assetsDir, rel);
+ }
+ }
+ try {
+ const body = readFileSync(target);
+ const ext = target.slice(target.lastIndexOf("."));
+ res.writeHead(200, { "Content-Type": mime[ext] || "application/octet-stream" });
+ res.end(body);
+ } catch {
+ res.writeHead(404);
+ res.end("not found");
+ }
+ });
+ await new Promise((r) => server.listen(0, "127.0.0.1", r));
+ const port = server.address().port;
+ return { server, port };
+}
+
+function spawnThreeRT(extraArgs, statsFile) {
+ const args = [
+ "--runtime", runtimeJs,
+ "--script", demoJs,
+ "--layer", "background",
+ "--omarchy",
+ "--stats-json", statsFile,
+ ...extraArgs,
+ ];
+ const proc = spawn(wallpaperBin, args, { stdio: ["ignore", "pipe", "pipe"] });
+ return {
+ proc,
+ cleanup: () => {},
+ extra: () => {
+ try {
+ return JSON.parse(readFileSync(statsFile, "utf8"));
+ } catch {
+ return {};
+ }
+ },
+ };
+}
+
+function spawnChromium(port, query, { extraFlags = [] } = {}) {
+ const prof = mkdtempSync(join(tmpdir(), "threert-bench-chr-"));
+ const tag = prof.split("/").pop();
+ const url = `http://127.0.0.1:${port}/wallpaper-demo.html?${query}`;
+ const args = [
+ `--user-data-dir=${prof}`,
+ "--ozone-platform=wayland",
+ "--enable-unsafe-webgpu",
+ "--enable-features=Vulkan",
+ "--no-first-run",
+ "--no-default-browser-check",
+ "--disable-extensions",
+ "--disable-background-networking",
+ "--disable-sync",
+ "--disable-component-update",
+ "--disable-features=TranslateUI",
+ "--window-size=1440,900",
+ `--app=${url}`,
+ ...extraFlags,
+ ];
+ const proc = spawn("chromium", args, { stdio: ["ignore", "pipe", "pipe"] });
+ return {
+ proc,
+ cmdTag: tag,
+ cleanup: () => {
+ try {
+ rmSync(prof, { recursive: true, force: true });
+ } catch {}
+ },
+ extra: (stderr) => {
+ const m = /WALLPAPER_READY backend=(\S+) ttff_ms=([\d.]+)(?: canvas=(\S+))?/.exec(stderr);
+ const fpsMatches = [...stderr.matchAll(/WALLPAPER_FPS fps=([\d.]+) frames=(\d+) canvas=(\S+)/g)];
+ const fpsVals = fpsMatches.map((x) => parseFloat(x[1]));
+ const lastCanvas = fpsMatches.length ? fpsMatches[fpsMatches.length - 1][3] : (m?.[3] ?? null);
+ return {
+ backend: m?.[1] ?? null,
+ pageTtffMs: m ? parseFloat(m[2]) : null,
+ canvas: lastCanvas,
+ achievedFps: fpsVals.length ? +median(fpsVals).toFixed(1) : null,
+ };
+ },
+ };
+}
+
+async function measureColdStartTTFF(port, runs = 3) {
+ console.log(`\n[bench] Measuring Cold-Start TTFF (${runs} runs each)...`);
+ const trtRuns = [];
+ for (let i = 0; i < runs; i++) {
+ const sf = join(outDir, `ttff-trt-${i}.json`);
+ const res = spawnSync(
+ wallpaperBin,
+ ["--runtime", runtimeJs, "--script", demoJs, "--layer", "background", "--omarchy", "--no-occlusion-pause", "--duration", "2.0", "--stats-json", sf],
+ { encoding: "utf8" },
+ );
+ try {
+ const j = JSON.parse(readFileSync(sf, "utf8"));
+ if (typeof j.ttff_ms === "number") trtRuns.push(+j.ttff_ms.toFixed(1));
+ } catch {
+ console.error("TTFF parse failed:", res.stderr);
+ }
+ await sleep(400);
+ }
+
+ const chrRuns = [];
+ for (let i = 0; i < runs; i++) {
+ const prof = mkdtempSync(join(tmpdir(), "threert-ttff-chr-"));
+ const t0 = performance.now();
+ const proc = spawn(
+ "chromium",
+ [
+ `--user-data-dir=${prof}`,
+ "--ozone-platform=wayland",
+ "--enable-unsafe-webgpu",
+ "--enable-features=Vulkan",
+ "--no-first-run",
+ "--disable-extensions",
+ "--disable-background-networking",
+ "--disable-sync",
+ "--enable-logging=stderr",
+ "--v=0",
+ "--window-size=1440,900",
+ `--app=http://127.0.0.1:${port}/wallpaper-demo.html?fps=60&dpr=1.5`,
+ ],
+ { stdio: ["ignore", "pipe", "pipe"] },
+ );
+ const ttff = await new Promise((resolve) => {
+ let done = false;
+ const timer = setTimeout(() => {
+ if (!done) {
+ done = true;
+ resolve(null);
+ }
+ }, 15000);
+ proc.stderr.on("data", (d) => {
+ const s = d.toString();
+ if (!done && s.includes("WALLPAPER_READY")) {
+ done = true;
+ clearTimeout(timer);
+ resolve(+(performance.now() - t0).toFixed(1));
+ }
+ });
+ proc.on("exit", () => {
+ if (!done) {
+ done = true;
+ clearTimeout(timer);
+ resolve(null);
+ }
+ });
+ });
+ try {
+ proc.kill("SIGTERM");
+ } catch {}
+ await sleep(600);
+ try {
+ proc.kill("SIGKILL");
+ } catch {}
+ rmSync(prof, { recursive: true, force: true });
+ if (ttff !== null) chrRuns.push(ttff);
+ await sleep(500);
+ }
+ const out = {
+ threertRunsMs: trtRuns,
+ threertMedianMs: +median(trtRuns).toFixed(1),
+ chromiumRunsMs: chrRuns,
+ chromiumMedianMs: +median(chrRuns).toFixed(1),
+ };
+ console.log("[bench] Cold-Start TTFF:", JSON.stringify(out));
+ return out;
+}
+
+async function main() {
+ if (!existsSync(wallpaperBin)) {
+ throw new Error(`Missing ${wallpaperBin}; build threert-wallpaper first.`);
+ }
+ const binSizeMiB = +(statSync(wallpaperBin).size / (1024 * 1024)).toFixed(2);
+ let chromiumBinMiB = null;
+ try {
+ chromiumBinMiB = +(statSync("/usr/lib/chromium/chromium").size / (1024 * 1024)).toFixed(1);
+ } catch {}
+
+ const { server, port } = await startStaticServer();
+ try {
+ const baseline = await measureBaseline(8);
+ const ttff = await measureColdStartTTFF(port, 3);
+
+ // 1. Active Desktop 60 FPS (AC profile, exact 2160x1350)
+ const trt60 = await measureProcess(
+ "ThreeRT 60fps (2160x1350)",
+ () => spawnThreeRT(["--no-occlusion-pause", "--fps", "60", "--render-scale", "1.0"], join(outDir, "trt-60.json")),
+ );
+ await sleep(1500);
+ const chr60 = await measureProcess(
+ "Chromium 60fps (2160x1350)",
+ () => spawnChromium(port, "fps=60&w=1440&h=900&dpr=1.5", { extraFlags: ["--enable-logging=stderr", "--v=0"] }),
+ { cmdTag: "threert-bench-chr-" },
+ );
+ await sleep(1500);
+
+ // 2. Battery 30 FPS (exact 1620x1012 on BOTH ThreeRT and Chromium)
+ const trt30 = await measureProcess(
+ "ThreeRT 30fps Battery (1620x1012)",
+ () => spawnThreeRT(["--no-occlusion-pause", "--fps", "30", "--render-scale", "0.75"], join(outDir, "trt-30.json")),
+ );
+ await sleep(1500);
+ const chr30 = await measureProcess(
+ "Chromium 30fps (1620x1012)",
+ () => spawnChromium(port, "fps=30&w=1440&h=900&dpr=1.125", { extraFlags: ["--enable-logging=stderr", "--v=0"] }),
+ { cmdTag: "threert-bench-chr-" },
+ );
+ await sleep(1500);
+
+ // 3. Occluded Desktop (ThreeRT auto-paused by Hyprland vs Chromium background)
+ const trtPaused = await measureProcess(
+ "ThreeRT Occluded (Auto-Paused 0fps)",
+ () => spawnThreeRT(["--force-paused", "--fps", "60"], join(outDir, "trt-paused.json")),
+ );
+
+ const summary = {
+ timestamp: new Date().toISOString(),
+ host: {
+ display: "2160x1350 @ 60Hz (logical 1440x900, scale 1.5)",
+ threertBinaryMiB: binSizeMiB,
+ chromiumBinaryMiB: chromiumBinMiB,
+ demoBundleKiB: +(statSync(demoJs).size / 1024).toFixed(1),
+ runtimeBundleKiB: +(statSync(runtimeJs).size / 1024).toFixed(1),
+ },
+ baseline,
+ ttff,
+ scenarios: { trt60, chr60, trt30, chr30, trtPaused },
+ };
+
+ const jsonPath = join(outDir, "results.json");
+ writeFileSync(jsonPath, JSON.stringify(summary, null, 2));
+ console.log(`\n[bench] Wrote full results to ${jsonPath}`);
+ } finally {
+ server.close();
+ }
+}
+
+main().catch((e) => {
+ console.error("[bench] FAILED:", e);
+ process.exit(1);
+});
diff --git a/webgpu/wallpaper/demo/build.mjs b/webgpu/wallpaper/demo/build.mjs
new file mode 100644
index 0000000..2413d0f
--- /dev/null
+++ b/webgpu/wallpaper/demo/build.mjs
@@ -0,0 +1,55 @@
+// Bundle the shared Three.js WebGPU Earth wallpaper demo into `out/webgpu/wallpaper-demo.js`
+// and stage 4K planet textures into `out/webgpu/assets/` (used identically by ThreeRT & Chromium).
+// Run with: bun webgpu/wallpaper/demo/build.mjs
+import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from "node:fs";
+import { join } from "node:path";
+
+const demoDir = import.meta.dirname;
+const root = join(demoDir, "..", "..", "..");
+const outDir = join(root, "out", "webgpu");
+const outAssets = join(outDir, "assets");
+mkdirSync(outAssets, { recursive: true });
+
+const threeDir = join(root, "node_modules", "three");
+
+const result = await Bun.build({
+ entrypoints: [join(demoDir, "scene.ts")],
+ outdir: outDir,
+ naming: "wallpaper-demo.js",
+ target: "browser",
+ format: "iife",
+ minify: true,
+ plugins: [
+ {
+ name: "resolve-three",
+ setup(build) {
+ build.onResolve({ filter: /^three(\/.*)?$/ }, (args) => {
+ if (args.path === "three/webgpu") return { path: join(threeDir, "build", "three.webgpu.js") };
+ if (args.path === "three/tsl") return { path: join(threeDir, "build", "three.tsl.js") };
+ if (args.path === "three/core") return { path: join(threeDir, "build", "three.core.js") };
+ if (args.path === "three") return { path: join(threeDir, "build", "three.module.js") };
+ return { path: join(threeDir, args.path.slice("three/".length)) };
+ });
+ },
+ },
+ ],
+});
+
+if (!result.success) {
+ for (const log of result.logs) console.error(log);
+ process.exit(1);
+}
+
+copyFileSync(join(demoDir, "index.html"), join(outDir, "wallpaper-demo.html"));
+const srcAssets = join(demoDir, "assets");
+if (existsSync(srcAssets)) {
+ for (const f of readdirSync(srcAssets)) {
+ copyFileSync(join(srcAssets, f), join(outAssets, f));
+ }
+} else {
+ console.warn(`[wallpaper-demo] ${srcAssets} is missing: the 4K textures are not committed (README.md, Assets)`);
+}
+
+const outJs = join(outDir, "wallpaper-demo.js");
+const kb = (statSync(outJs).size / 1024).toFixed(1);
+console.log(`[wallpaper-demo] built ${outJs} (${kb} KiB) + wallpaper-demo.html + assets/`);
diff --git a/webgpu/wallpaper/demo/index.html b/webgpu/wallpaper/demo/index.html
new file mode 100644
index 0000000..2301879
--- /dev/null
+++ b/webgpu/wallpaper/demo/index.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8" />
+ <title>Omarchy Drift — Three.js WebGPU Wallpaper</title>
+ <style>
+ html, body {
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ height: 100%;
+ overflow: hidden;
+ background: #0e0e14;
+ }
+ #canvas {
+ display: block;
+ width: 100vw;
+ height: 100vh;
+ }
+ </style>
+</head>
+<body>
+ <canvas id="canvas"></canvas>
+ <script src="./wallpaper-demo.js"></script>
+</body>
+</html>
diff --git a/webgpu/wallpaper/demo/scene.ts b/webgpu/wallpaper/demo/scene.ts
new file mode 100644
index 0000000..ba62160
--- /dev/null
+++ b/webgpu/wallpaper/demo/scene.ts
@@ -0,0 +1,465 @@
+// "Omarchy Orbital — Living Earth"
+// Cinema-grade real-time 3D Earth desktop wallpaper in standard three.js WebGPURenderer + TSL.
+// Uses real 4K NASA Blue Marble / Black Marble / Elevation+Roughness+Cloud maps, two-layer cloud
+// drift with surface shadows, Rayleigh/twilight atmospheric scattering, and subtle Omarchy theme
+// harmony. Runs identically in BOTH ThreeRT (`threert-wallpaper`) and Chromium WebGPU.
+import * as THREE from "three/webgpu";
+import {
+ bumpMap,
+ cameraPosition,
+ clamp,
+ dot,
+ float,
+ mix,
+ normalize,
+ normalWorld,
+ positionWorld,
+ pow,
+ smoothstep,
+ texture,
+ uniform,
+ uv,
+ vec2,
+ vec3,
+} from "three/tsl";
+
+interface ThemePalette {
+ mode?: string;
+ accent?: string;
+ background?: string;
+ dark_background?: string;
+ darker_background?: string;
+ lighter_background?: string;
+ blue?: string;
+ cyan?: string;
+ magenta?: string;
+ orange?: string;
+ yellow?: string;
+}
+
+interface WallpaperBridge {
+ theme?: ThemePalette;
+ fixedTime?: number | null;
+ fps?: number;
+ onThemeChange?: (fn: (t: ThemePalette) => void) => void;
+}
+
+declare global {
+ var __threertGpuCanvas: HTMLCanvasElement | undefined;
+ var __wallpaper: WallpaperBridge | undefined;
+ var __WALLPAPER_THEME: ThemePalette | undefined;
+ var __native: { sys?: { resource?: (path: string) => ArrayBuffer | null } } | undefined;
+ var __ttffMs: number | undefined;
+ var __frameCount: number | undefined;
+ var __rendererBackend: string | undefined;
+}
+
+const DEFAULT_THEME: Required<ThemePalette> = {
+ mode: "dark",
+ accent: "#7aa2f7",
+ background: "#1a1b26",
+ dark_background: "#13141c",
+ darker_background: "#0e0e14",
+ lighter_background: "#24283b",
+ blue: "#7aa2f7",
+ cyan: "#449dab",
+ magenta: "#ad8ee6",
+ orange: "#eb927b",
+ yellow: "#e0af68",
+};
+
+function resolveTheme(raw?: ThemePalette): Required<ThemePalette> {
+ return { ...DEFAULT_THEME, ...(raw || {}) };
+}
+
+function getQueryParam(name: string): string | null {
+ try {
+ const loc = globalThis.location;
+ if (!loc || !loc.search) return null;
+ return new URLSearchParams(loc.search).get(name);
+ } catch {
+ return null;
+ }
+}
+
+function mulberry32(seed: number) {
+ let a = seed >>> 0;
+ return () => {
+ a = (a + 0x6d2b79f5) | 0;
+ let t = Math.imul(a ^ (a >>> 15), 1 | a);
+ t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
+ };
+}
+
+/** Load an equirectangular 4K JPEG asset identically in ThreeRT (native resource) and Chromium (fetch). */
+async function loadPlanetTexture(
+ filename: string,
+ srgb: boolean,
+ maxAnisotropy: number,
+): Promise<THREE.Texture> {
+ let source: Blob | { arrayBuffer: () => Promise<ArrayBuffer> };
+ const nativeRes = globalThis.__native?.sys?.resource;
+ if (typeof nativeRes === "function") {
+ const buf = nativeRes(filename);
+ if (!buf) throw new Error(`Missing local planet texture: ${filename}`);
+ source = { arrayBuffer: () => Promise.resolve(buf) };
+ } else {
+ const res = await fetch(`./assets/${filename}`);
+ if (!res.ok) throw new Error(`Failed to fetch ./assets/${filename}: ${res.status}`);
+ source = await res.blob();
+ }
+ const bitmap = await createImageBitmap(source as Blob);
+ const tex = new THREE.Texture(bitmap);
+ tex.colorSpace = srgb ? THREE.SRGBColorSpace : THREE.NoColorSpace;
+ tex.wrapS = THREE.RepeatWrapping;
+ tex.wrapT = THREE.ClampToEdgeWrapping;
+ tex.anisotropy = maxAnisotropy;
+ tex.generateMipmaps = true;
+ tex.minFilter = THREE.LinearMipmapLinearFilter;
+ tex.magFilter = THREE.LinearFilter;
+ tex.needsUpdate = true;
+ return tex;
+}
+
+/** Compute harmonized planetary atmosphere & deep-space tint from an Omarchy theme palette. */
+function computeThemeHarmonics(p: Required<ThemePalette>) {
+ // Keep space authentically deep dark with a subtle nod to the Omarchy background
+ const spaceBg = new THREE.Color(0x02040a).lerp(
+ new THREE.Color(p.darker_background),
+ p.mode === "light" ? 0.12 : 0.28,
+ );
+ // Natural Rayleigh sky blue gently harmonized (20%) with Omarchy's accent/cyan
+ const atmoDay = new THREE.Color(0x4cb4ff).lerp(new THREE.Color(p.accent), 0.22);
+ // Natural fiery sunset scattering gently harmonized (18%) with Omarchy's orange/yellow
+ const atmoTwilight = new THREE.Color(0xff6b35).lerp(new THREE.Color(p.orange), 0.20);
+ // Subtle night-side ambient starlight tint
+ const nightAmb = new THREE.Color(0x0e182a).lerp(new THREE.Color(p.blue), 0.15);
+ return { spaceBg, atmoDay, atmoTwilight, nightAmb };
+}
+
+async function main() {
+ const bootT0 = performance.now();
+ const canvas: HTMLCanvasElement =
+ globalThis.__threertGpuCanvas ??
+ (document.getElementById("canvas") as HTMLCanvasElement);
+
+ const queryFixedT = getQueryParam("t");
+ const fixedTime: number | null =
+ typeof globalThis.__wallpaper?.fixedTime === "number"
+ ? globalThis.__wallpaper.fixedTime
+ : queryFixedT !== null && Number.isFinite(parseFloat(queryFixedT))
+ ? parseFloat(queryFixedT)
+ : null;
+
+ const queryFps = getQueryParam("fps");
+ const maxBrowserFps =
+ !globalThis.__threertGpuCanvas && queryFps !== null && Number.isFinite(parseFloat(queryFps))
+ ? Math.max(1, parseFloat(queryFps))
+ : null;
+
+ const queryDpr = getQueryParam("dpr");
+ const dpr =
+ queryDpr !== null && Number.isFinite(parseFloat(queryDpr))
+ ? parseFloat(queryDpr)
+ : window.devicePixelRatio || 1;
+
+ const queryW = getQueryParam("w");
+ const queryH = getQueryParam("h");
+ const targetW =
+ queryW !== null && Number.isFinite(parseInt(queryW, 10))
+ ? parseInt(queryW, 10)
+ : window.innerWidth;
+ const targetH =
+ queryH !== null && Number.isFinite(parseInt(queryH, 10))
+ ? parseInt(queryH, 10)
+ : window.innerHeight;
+
+ const renderer = new THREE.WebGPURenderer({
+ canvas,
+ antialias: true,
+ powerPreference: "low-power",
+ });
+ renderer.setPixelRatio(dpr);
+ renderer.setSize(targetW, targetH, false);
+ renderer.toneMapping = THREE.ACESFilmicToneMapping;
+ renderer.toneMappingExposure = 1.12;
+ await renderer.init();
+
+ const backendName =
+ (renderer.backend as { isWebGPUBackend?: boolean })?.isWebGPUBackend
+ ? "WebGPU"
+ : "WebGL2";
+ globalThis.__rendererBackend = backendName;
+
+ // Decode all three 4K NASA planet maps in parallel
+ const [dayTex, nightTex, brcTex] = await Promise.all([
+ loadPlanetTexture("earth_day_4096.jpg", true, 8),
+ loadPlanetTexture("earth_night_4096.jpg", true, 8),
+ loadPlanetTexture("earth_bump_roughness_clouds_4096.jpg", false, 8),
+ ]);
+
+ const scene = new THREE.Scene();
+ const initialPalette = resolveTheme(
+ globalThis.__wallpaper?.theme ?? globalThis.__WALLPAPER_THEME,
+ );
+ let targetHarmonics = computeThemeHarmonics(initialPalette);
+ scene.background = targetHarmonics.spaceBg.clone();
+
+ // Telephoto orbital camera for dignified, low-distortion planetary perspective
+ const camera = new THREE.PerspectiveCamera(27, targetW / targetH, 0.1, 200);
+ camera.position.set(0, 0.16, 4.95);
+ camera.lookAt(0, -0.02, 0);
+
+ // ---- Solar Lighting (crisp three-quarter crescent lighting) ----
+ const sunDirVec = new THREE.Vector3(6.8, 2.3, 3.6).normalize();
+ const uSunDir = uniform(sunDirVec.clone());
+ const uAtmoDay = uniform(targetHarmonics.atmoDay.clone());
+ const uAtmoTwilight = uniform(targetHarmonics.atmoTwilight.clone());
+
+ const sunLight = new THREE.DirectionalLight(0xfff6ea, 3.25);
+ sunLight.position.copy(sunDirVec).multiplyScalar(20);
+ scene.add(sunLight);
+
+ // Very faint cosmic bounce so the dark limb retains subtle silhouette without washing out city lights
+ const cosmicAmbient = new THREE.AmbientLight(targetHarmonics.nightAmb, 0.12);
+ scene.add(cosmicAmbient);
+
+ // ---- Earth Axial Tilt Group (23.44° obliquity) ----
+ const earthTilt = new THREE.Group();
+ earthTilt.rotation.z = THREE.MathUtils.degToRad(-23.44);
+ earthTilt.rotation.x = THREE.MathUtils.degToRad(11.5);
+ scene.add(earthTilt);
+
+ // ---- 1. Earth Surface Sphere (4K Albedo + Night Cities + Relief Bump + Ocean Specular + Cloud Shadow) ----
+ const earthGeo = new THREE.SphereGeometry(1.0, 96, 96);
+ const earthMat = new THREE.MeshStandardNodeMaterial({
+ metalness: 0.04,
+ });
+
+ const baseUv = uv();
+ const dayColor = texture(dayTex, baseUv).rgb;
+ const nightColor = texture(nightTex, baseUv).rgb;
+ const brcSample = texture(brcTex, baseUv);
+ const elevMap = brcSample.r;
+ const roughMap = brcSample.g;
+ const cloudDensity = brcSample.b;
+
+ // Soft cloud shadow projected slightly opposite the sun onto oceans/land below
+ const shadowCloud = texture(brcTex, baseUv.add(vec2(-0.0022, 0.0010))).b;
+ const cloudShadowFactor = float(1.0).sub(smoothstep(float(0.18), float(0.85), shadowCloud).mul(0.32));
+
+ // Physically-motivated ocean/continent roughness (glossy ocean sun-glint, matte continents)
+ earthMat.roughnessNode = mix(float(0.16), float(0.86), roughMap);
+ earthMat.bumpMap = null;
+ earthMat.normalNode = bumpMap(elevMap, float(0.032));
+
+ // Sun angle & view-dependent atmospheric limb Fresnel
+ const sunDot = dot(normalWorld, uSunDir);
+ const viewDir = normalize(cameraPosition.sub(positionWorld));
+ const fresnel = pow(float(1.0).sub(clamp(dot(viewDir, normalWorld), 0.0, 1.0)), float(3.2));
+
+ const dayFactor = smoothstep(float(-0.18), float(0.28), sunDot);
+ const nightFactor = smoothstep(float(0.10), float(-0.24), sunDot);
+ const twilightFactor = smoothstep(float(-0.26), float(0.01), sunDot).mul(
+ smoothstep(float(0.34), float(0.01), sunDot),
+ );
+
+ // Subtle surface atmospheric aerial perspective + sunset reddening at the terminator
+ const atmoColor = mix(uAtmoDay, uAtmoTwilight, twilightFactor.mul(0.85));
+ const surfaceAtmoMix = fresnel.mul(smoothstep(float(-0.22), float(0.35), sunDot)).mul(0.68);
+ const litSurface = dayColor.mul(cloudShadowFactor);
+ // Subtle warm sunset grazing tint right on the terminator
+ const terminatorWarmth = litSurface.mul(mix(vec3(1.0, 1.0, 1.0), vec3(1.18, 0.86, 0.72), twilightFactor.mul(0.65)));
+ earthMat.colorNode = mix(terminatorWarmth, atmoColor, surfaceAtmoMix);
+
+ // Warm golden city lights on the night hemisphere (softly attenuated by dense cloud cover)
+ const cloudAttenuation = float(1.0).sub(smoothstep(float(0.25), float(0.92), cloudDensity).mul(0.50));
+ const cityGlow = nightColor.mul(vec3(2.4, 1.68, 0.96)).mul(nightFactor).mul(cloudAttenuation);
+ // Emissive atmospheric limb scattering glow
+ const limbGlow = atmoColor.mul(fresnel).mul(smoothstep(float(-0.22), float(0.45), sunDot)).mul(0.72);
+ earthMat.emissiveNode = cityGlow.add(limbGlow);
+
+ const earthMesh = new THREE.Mesh(earthGeo, earthMat);
+ earthTilt.add(earthMesh);
+
+ // ---- 2. Elevated Drifting Cloud Deck (subtle parallax & independent wind rotation) ----
+ const cloudGeo = new THREE.SphereGeometry(1.0085, 96, 96);
+ const cloudMat = new THREE.MeshStandardNodeMaterial({
+ transparent: true,
+ depthWrite: false,
+ roughness: 0.92,
+ metalness: 0.0,
+ });
+ const cloudSample = texture(brcTex, uv()).b;
+ const cloudAlpha = smoothstep(float(0.14), float(0.82), cloudSample).mul(0.92);
+ const cloudSunDot = dot(normalWorld, uSunDir);
+ const cloudTwilight = smoothstep(float(-0.20), float(0.03), cloudSunDot).mul(
+ smoothstep(float(0.32), float(0.03), cloudSunDot),
+ );
+ // Sunlit clouds pure bright white, terminator clouds warm coral/gold, night clouds dark silhouette
+ const cloudTint = mix(vec3(0.97, 0.98, 1.0), vec3(1.0, 0.72, 0.54), cloudTwilight.mul(0.75));
+ cloudMat.colorNode = cloudTint;
+ cloudMat.emissiveNode = uAtmoTwilight.mul(cloudTwilight.mul(0.16));
+ cloudMat.opacityNode = cloudAlpha.mul(mix(float(0.22), float(1.0), smoothstep(float(-0.25), float(0.15), cloudSunDot)));
+
+ const cloudMesh = new THREE.Mesh(cloudGeo, cloudMat);
+ earthTilt.add(cloudMesh);
+
+ // ---- 3. Outer Volumetric Rayleigh/Mie Atmosphere Halo Shell ----
+ const atmoGeo = new THREE.SphereGeometry(1.072, 96, 96);
+ const atmoMat = new THREE.MeshBasicNodeMaterial({
+ side: THREE.BackSide,
+ transparent: true,
+ depthWrite: false,
+ blending: THREE.AdditiveBlending,
+ });
+ const atmoViewDir = normalize(cameraPosition.sub(positionWorld));
+ // Use explicit geometric outward normal (Earth is centered at origin) so BackSide normal flipping
+ // never cancels the limb profile. Peaks at Earth's horizon (~0.36) and feathers smoothly to 0 at r=1.072.
+ const geoNormal = normalize(positionWorld);
+ const rimDot = clamp(dot(atmoViewDir, geoNormal.negate()), 0.0, 1.0);
+ const haloFalloff = pow(clamp(rimDot.mul(2.55), 0.0, 1.0), float(3.2));
+ const atmoSunDot = dot(geoNormal, uSunDir);
+ const haloSunMask = smoothstep(float(-0.32), float(0.45), atmoSunDot);
+ const haloTwilight = smoothstep(float(-0.28), float(0.02), atmoSunDot).mul(
+ smoothstep(float(0.36), float(0.02), atmoSunDot),
+ );
+ const haloCol = mix(uAtmoDay, uAtmoTwilight, haloTwilight.mul(0.58));
+ atmoMat.colorNode = haloCol.mul(haloFalloff).mul(haloSunMask).mul(1.15);
+ atmoMat.opacityNode = clamp(haloFalloff.mul(haloSunMask).mul(0.95), 0.0, 1.0);
+
+ const atmoMesh = new THREE.Mesh(atmoGeo, atmoMat);
+ earthTilt.add(atmoMesh);
+
+ // ---- 4. Deep-Space Multi-Spectral Starfield (1 InstancedMesh draw call) ----
+ const rng = mulberry32(20261130);
+ const starCount = 1400;
+ const starGeo = new THREE.IcosahedronGeometry(0.068, 0);
+ const starMat = new THREE.MeshBasicMaterial({ color: 0xffffff });
+ const stars = new THREE.InstancedMesh(starGeo, starMat, starCount);
+ const dummy = new THREE.Object3D();
+ const starCol = new THREE.Color();
+ // Realistic stellar color temperatures (O/B blue-white, A/F white, G pale gold, K warm amber)
+ const starPalette = [0xcad8ff, 0xe8efff, 0xffffff, 0xfff4e0, 0xffd7a8, 0xa8c8ff];
+ for (let i = 0; i < starCount; i++) {
+ // Uniform spherical distribution on deep sky dome
+ const u = rng();
+ const v = rng();
+ const theta = u * Math.PI * 2;
+ const phi = Math.acos(2 * v - 1);
+ const rad = 48 + rng() * 36;
+ dummy.position.set(
+ rad * Math.sin(phi) * Math.cos(theta),
+ rad * Math.cos(phi),
+ rad * Math.sin(phi) * Math.sin(theta),
+ );
+ // Power-law star size distribution: mostly crisp faint pinpoints, a few brighter stars
+ const mag = Math.pow(rng(), 2.8);
+ const s = 0.32 + mag * 1.45;
+ dummy.scale.setScalar(s);
+ dummy.updateMatrix();
+ stars.setMatrixAt(i, dummy.matrix);
+
+ starCol.setHex(starPalette[Math.floor(rng() * starPalette.length)]);
+ starCol.multiplyScalar(0.38 + mag * 0.62);
+ stars.setColorAt(i, starCol);
+ }
+ stars.instanceMatrix.needsUpdate = true;
+ if (stars.instanceColor) stars.instanceColor.needsUpdate = true;
+ scene.add(stars);
+
+ // ---- 5. Subtle Off-Axis Solar Corona Glow ----
+ const sunGlowGeo = new THREE.PlaneGeometry(18, 18);
+ const sunGlowMat = new THREE.MeshBasicNodeMaterial({
+ transparent: true,
+ depthWrite: false,
+ blending: THREE.AdditiveBlending,
+ });
+ const gUv = uv().sub(vec2(0.5, 0.5)).mul(2.0);
+ const gDist = clamp(gUv.length(), 0.0, 1.0);
+ const corona = pow(float(1.0).sub(gDist), float(5.5));
+ sunGlowMat.colorNode = mix(uAtmoDay, vec3(1.0, 0.94, 0.84), pow(float(1.0).sub(gDist), float(2.0))).mul(corona).mul(0.55);
+ sunGlowMat.opacityNode = corona.mul(0.45);
+ const sunGlow = new THREE.Mesh(sunGlowGeo, sunGlowMat);
+ sunGlow.position.copy(sunDirVec).multiplyScalar(42);
+ sunGlow.lookAt(camera.position);
+ scene.add(sunGlow);
+
+ // ---- Live Omarchy Theme Sync ----
+ globalThis.__wallpaper?.onThemeChange?.((next) => {
+ targetHarmonics = computeThemeHarmonics(resolveTheme(next));
+ });
+
+ window.addEventListener("resize", () => {
+ if (queryW !== null && queryH !== null) return;
+ const w = Math.max(1, window.innerWidth);
+ const h = Math.max(1, window.innerHeight);
+ camera.aspect = w / h;
+ camera.updateProjectionMatrix();
+ renderer.setSize(w, h, false);
+ });
+
+ // ---- Main Orbital Loop ----
+ // Start longitude so golden Europe / Nile / Middle East city lights glow on the night hemisphere
+ // while East Asia / Indian Ocean / Pacific catch dramatic sunlit clouds & ocean glint.
+ const START_LON = -2.85;
+ let frameCount = 0;
+ let lastRenderWall = 0;
+ let lastLogWall = performance.now();
+ let lastLogFrames = 0;
+ const simStart = performance.now();
+
+ const animate = (now: number) => {
+ requestAnimationFrame(animate);
+
+ if (maxBrowserFps !== null && frameCount > 0) {
+ const minInterval = 1000 / maxBrowserFps;
+ if (now - lastRenderWall < minInterval - 0.5) {
+ return;
+ }
+ }
+ lastRenderWall = now;
+
+ const t = fixedTime !== null ? fixedTime : (now - simStart) * 0.001;
+
+ // Smoothly harmonize colors on Omarchy theme changes
+ const k = 0.05;
+ (scene.background as THREE.Color).lerp(targetHarmonics.spaceBg, k);
+ uAtmoDay.value.lerp(targetHarmonics.atmoDay, k);
+ uAtmoTwilight.value.lerp(targetHarmonics.atmoTwilight, k);
+ cosmicAmbient.color.lerp(targetHarmonics.nightAmb, k);
+
+ // Slow, dignified planetary rotation (~3.7 min per full revolution) + independent cloud drift
+ earthMesh.rotation.y = START_LON + t * 0.028;
+ cloudMesh.rotation.y = START_LON + t * 0.034;
+ stars.rotation.y = t * 0.002;
+
+ // Subtle, serene orbital camera breathing
+ camera.position.x = Math.sin(t * 0.055) * 0.18;
+ camera.position.y = 0.16 + Math.sin(t * 0.04) * 0.08;
+ camera.position.z = 4.92 + Math.cos(t * 0.055) * 0.06;
+ camera.lookAt(0, -0.02, 0);
+
+ renderer.render(scene, camera);
+ frameCount++;
+ globalThis.__frameCount = frameCount;
+
+ if (frameCount === 1) {
+ const ttff = performance.now() - bootT0;
+ globalThis.__ttffMs = ttff;
+ console.log(`WALLPAPER_READY backend=${backendName} ttff_ms=${ttff.toFixed(1)} canvas=${canvas.width}x${canvas.height}`);
+ } else if (now - lastLogWall >= 3000) {
+ const fps = ((frameCount - lastLogFrames) * 1000) / (now - lastLogWall);
+ console.log(`WALLPAPER_FPS fps=${fps.toFixed(1)} frames=${frameCount} canvas=${canvas.width}x${canvas.height} backend=${backendName}`);
+ lastLogWall = now;
+ lastLogFrames = frameCount;
+ }
+ };
+
+ requestAnimationFrame(animate);
+}
+
+main().catch((err) => {
+ console.error("earth wallpaper failed:", err);
+});
diff --git a/webgpu/wallpaper/docs/benchmark-results.json b/webgpu/wallpaper/docs/benchmark-results.json
new file mode 100644
index 0000000..d8e8c8e
--- /dev/null
+++ b/webgpu/wallpaper/docs/benchmark-results.json
@@ -0,0 +1,202 @@
+{
+ "timestamp": "2026-11-30T11:15:56.126Z",
+ "host": {
+ "display": "2160x1350 @ 60Hz (logical 1440x900, scale 1.5)",
+ "threertBinaryMiB": 7.35,
+ "chromiumBinaryMiB": 316.6,
+ "demoBundleKiB": 854.1,
+ "runtimeBundleKiB": 112.4
+ },
+ "baseline": {
+ "wallMs": 8023.826027,
+ "gpuActivePct": 12.75,
+ "gpuAvgMhz": 23.4,
+ "battery": {
+ "status": "Not charging",
+ "watts": 0
+ }
+ },
+ "ttff": {
+ "threertRunsMs": [
+ 562.1,
+ 575.4,
+ 574.8
+ ],
+ "threertMedianMs": 574.8,
+ "chromiumRunsMs": [
+ 695,
+ 704.9,
+ 761.6
+ ],
+ "chromiumMedianMs": 704.9
+ },
+ "scenarios": {
+ "trt60": {
+ "label": "ThreeRT 60fps (2160x1350)",
+ "wallSec": 12.15,
+ "procCount": 1,
+ "threads": 19,
+ "pssMiB": 232.2,
+ "pssPeakMiB": 234.6,
+ "rssMiB": 247.7,
+ "cpuPct": 15.56,
+ "wakeupsPerSec": 95.8,
+ "gpuActivePct": 55.68,
+ "gpuAvgMhz": 444.8,
+ "extra": {
+ "achieved_fps": 58.068912115349555,
+ "active_ms": 16084.337832,
+ "backend": "Vulkan",
+ "blitted_frames": 0,
+ "direct_frames": 934,
+ "elapsed_ms": 16084.337832,
+ "frame_cpu_p50_ms": 2.164674,
+ "frame_cpu_p95_ms": 2.964893,
+ "frame_cpu_p99_ms": 3.608184,
+ "frames": 934,
+ "gpu": "Intel(R) Iris(R) Xe Graphics (TGL GT2)",
+ "logical": [
+ 1440,
+ 900
+ ],
+ "paused_ms": 0,
+ "physical": [
+ 2160,
+ 1350
+ ],
+ "scale": 1.5,
+ "target_fps": 60,
+ "ttff_ms": 588.1147410000001,
+ "webgpu_draws": 4706,
+ "webgpu_finish_ms": 3.31854,
+ "webgpu_submit_ms": 954.257328,
+ "webgpu_submits": 937,
+ "webgpu_write_ms": 246.957495
+ }
+ },
+ "chr60": {
+ "label": "Chromium 60fps (2160x1350)",
+ "wallSec": 12.12,
+ "procCount": 10,
+ "threads": 107,
+ "pssMiB": 483.7,
+ "pssPeakMiB": 485.1,
+ "rssMiB": 1266.8,
+ "cpuPct": 39.87,
+ "wakeupsPerSec": 909.3,
+ "gpuActivePct": 69.17,
+ "gpuAvgMhz": 522.3,
+ "extra": {
+ "backend": "WebGPU",
+ "pageTtffMs": 271.1,
+ "canvas": "2160x1350",
+ "achievedFps": 59.7
+ }
+ },
+ "trt30": {
+ "label": "ThreeRT 30fps Battery (1620x1012)",
+ "wallSec": 12.12,
+ "procCount": 1,
+ "threads": 19,
+ "pssMiB": 218.9,
+ "pssPeakMiB": 222.4,
+ "rssMiB": 234.3,
+ "cpuPct": 7.1,
+ "wakeupsPerSec": 36.5,
+ "gpuActivePct": 57.91,
+ "gpuAvgMhz": 438.5,
+ "extra": {
+ "achieved_fps": 28.14775141756919,
+ "active_ms": 15987.067433,
+ "backend": "Vulkan",
+ "blitted_frames": 0,
+ "direct_frames": 450,
+ "elapsed_ms": 15987.067433,
+ "frame_cpu_p50_ms": 1.6074119999999998,
+ "frame_cpu_p95_ms": 2.95158,
+ "frame_cpu_p99_ms": 4.903514,
+ "frames": 450,
+ "gpu": "Intel(R) Iris(R) Xe Graphics (TGL GT2)",
+ "logical": [
+ 1440,
+ 900
+ ],
+ "paused_ms": 0,
+ "physical": [
+ 1620,
+ 1012
+ ],
+ "scale": 1.125,
+ "target_fps": 30,
+ "ttff_ms": 1196.311436,
+ "webgpu_draws": 2286,
+ "webgpu_finish_ms": 1.21153,
+ "webgpu_submit_ms": 377.657113,
+ "webgpu_submits": 453,
+ "webgpu_write_ms": 89.720594
+ }
+ },
+ "chr30": {
+ "label": "Chromium 30fps (1620x1012)",
+ "wallSec": 12.03,
+ "procCount": 10,
+ "threads": 107,
+ "pssMiB": 481.2,
+ "pssPeakMiB": 482.4,
+ "rssMiB": 1253.5,
+ "cpuPct": 21.03,
+ "wakeupsPerSec": 654.4,
+ "gpuActivePct": 54.39,
+ "gpuAvgMhz": 256.4,
+ "extra": {
+ "backend": "WebGPU",
+ "pageTtffMs": 492.4,
+ "canvas": "1620x1012",
+ "achievedFps": 29.9
+ }
+ },
+ "trtPaused": {
+ "label": "ThreeRT Occluded (Auto-Paused 0fps)",
+ "wallSec": 12.14,
+ "procCount": 1,
+ "threads": 18,
+ "pssMiB": 207.9,
+ "pssPeakMiB": 207.9,
+ "rssMiB": 223.4,
+ "cpuPct": 0,
+ "wakeupsPerSec": 2.1,
+ "gpuActivePct": 3.04,
+ "gpuAvgMhz": 2.1,
+ "extra": {
+ "achieved_fps": 1.9038440452290417,
+ "active_ms": 525.2531069999986,
+ "backend": "Vulkan",
+ "blitted_frames": 0,
+ "direct_frames": 1,
+ "elapsed_ms": 16529.466722999998,
+ "frame_cpu_p50_ms": 383.68636200000003,
+ "frame_cpu_p95_ms": 383.68636200000003,
+ "frame_cpu_p99_ms": 383.68636200000003,
+ "frames": 1,
+ "gpu": "Intel(R) Iris(R) Xe Graphics (TGL GT2)",
+ "logical": [
+ 1440,
+ 900
+ ],
+ "paused_ms": 16004.213616,
+ "physical": [
+ 2160,
+ 1350
+ ],
+ "scale": 1.5,
+ "target_fps": 60,
+ "ttff_ms": 618.185353,
+ "webgpu_draws": 41,
+ "webgpu_finish_ms": 0.006431,
+ "webgpu_submit_ms": 22.033201,
+ "webgpu_submits": 4,
+ "webgpu_write_ms": 0.445906
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/webgpu/wallpaper/src/hypr.rs b/webgpu/wallpaper/src/hypr.rs
new file mode 100644
index 0000000..82103b3
--- /dev/null
+++ b/webgpu/wallpaper/src/hypr.rs
@@ -0,0 +1,212 @@
+//! Event-driven Hyprland occlusion & DPMS watcher.
+//!
+//! Listens on `$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock` (zero polling
+//! while idle) and pauses rendering whenever the wallpaper on the target output is fully covered
+//! by a fullscreen or tiled opaque window, or when DPMS turns the display off.
+use std::io::{BufRead, BufReader};
+use std::os::unix::net::UnixStream;
+use std::path::PathBuf;
+use std::process::Command;
+use std::sync::atomic::{AtomicBool, Ordering};
+use std::sync::{Arc, Condvar, Mutex};
+use std::thread;
+
+use serde_json::Value;
+
+pub struct OcclusionState {
+ pub occluded: AtomicBool,
+ pub stop: AtomicBool,
+ pub wake_lock: Mutex<u64>,
+ pub wake_cv: Condvar,
+}
+
+impl OcclusionState {
+ pub fn new(initial_occluded: bool) -> Arc<Self> {
+ Arc::new(Self {
+ occluded: AtomicBool::new(initial_occluded),
+ stop: AtomicBool::new(false),
+ wake_lock: Mutex::new(0),
+ wake_cv: Condvar::new(),
+ })
+ }
+
+ pub fn set_occluded(&self, v: bool) {
+ let prev = self.occluded.swap(v, Ordering::SeqCst);
+ if prev != v {
+ let mut g = self.wake_lock.lock().unwrap_or_else(|e| e.into_inner());
+ *g = g.wrapping_add(1);
+ self.wake_cv.notify_all();
+ }
+ }
+
+ pub fn request_stop(&self) {
+ self.stop.store(true, Ordering::SeqCst);
+ let mut g = self.wake_lock.lock().unwrap_or_else(|e| e.into_inner());
+ *g = g.wrapping_add(1);
+ self.wake_cv.notify_all();
+ }
+
+ pub fn is_occluded(&self) -> bool {
+ self.occluded.load(Ordering::SeqCst)
+ }
+
+ pub fn is_stopped(&self) -> bool {
+ self.stop.load(Ordering::SeqCst)
+ }
+
+ /// Block with zero CPU wakeups while occluded (until uncovered, stopped, or `max_wait` elapses).
+ pub fn wait_while_occluded(&self, max_wait: std::time::Duration) {
+ let mut g = self.wake_lock.lock().unwrap_or_else(|e| e.into_inner());
+ if self.is_occluded() && !self.is_stopped() {
+ let (guard, _) = self.wake_cv.wait_timeout(g, max_wait).unwrap_or_else(|e| e.into_inner());
+ g = guard;
+ }
+ drop(g);
+ }
+}
+
+fn hypr_socket2_path() -> Option<PathBuf> {
+ let runtime = std::env::var("XDG_RUNTIME_DIR").ok()?;
+ let sig = std::env::var("HYPRLAND_INSTANCE_SIGNATURE").ok()?;
+ if runtime.is_empty() || sig.is_empty() {
+ return None;
+ }
+ let p = PathBuf::from(runtime).join("hypr").join(sig).join(".socket2.sock");
+ p.exists().then_some(p)
+}
+
+fn hyprctl_json(args: &[&str]) -> Option<Value> {
+ let out = Command::new("hyprctl").args(args).output().ok()?;
+ if !out.status.success() {
+ return None;
+ }
+ serde_json::from_slice(&out.stdout).ok()
+}
+
+/// Query the target monitor's fractional scale factor from Hyprland (defaults to `1.0`).
+pub fn monitor_scale(target_output: Option<&str>) -> f64 {
+ let Some(mons) = hyprctl_json(&["monitors", "-j"]).and_then(|v| v.as_array().cloned()) else {
+ return 1.0;
+ };
+ let picked = target_output
+ .and_then(|name| mons.iter().find(|m| m.get("name").and_then(|v| v.as_str()) == Some(name)))
+ .or_else(|| mons.iter().find(|m| m.get("focused").and_then(|v| v.as_bool()) == Some(true)))
+ .or_else(|| mons.first());
+ picked
+ .and_then(|m| m.get("scale").and_then(|v| v.as_f64()))
+ .filter(|s| s.is_finite() && *s > 0.0)
+ .unwrap_or(1.0)
+}
+
+/// Determine if the wallpaper on `target_output` (or the focused monitor) is currently obscured
+/// by a fullscreen window, a tiled window covering the workspace, or DPMS-off.
+pub fn compute_occluded(target_output: Option<&str>) -> bool {
+ let Some(mons) = hyprctl_json(&["monitors", "-j"]).and_then(|v| v.as_array().cloned()) else {
+ return false;
+ };
+ let Some(mon) = target_output
+ .and_then(|name| mons.iter().find(|m| m.get("name").and_then(|v| v.as_str()) == Some(name)))
+ .or_else(|| mons.iter().find(|m| m.get("focused").and_then(|v| v.as_bool()) == Some(true)))
+ .or_else(|| mons.first())
+ else {
+ return false;
+ };
+
+ if mon.get("dpmsStatus").and_then(|v| v.as_bool()) == Some(false) {
+ return true;
+ }
+ let Some(ws_id) = mon.pointer("/activeWorkspace/id").and_then(|v| v.as_i64()) else {
+ return false;
+ };
+ let scale = mon.get("scale").and_then(|v| v.as_f64()).unwrap_or(1.0).max(0.1);
+ let mon_w = mon.get("width").and_then(|v| v.as_f64()).unwrap_or(0.0) / scale;
+ let mon_h = mon.get("height").and_then(|v| v.as_f64()).unwrap_or(0.0) / scale;
+ let mon_area = (mon_w * mon_h).max(1.0);
+
+ let Some(clients) = hyprctl_json(&["clients", "-j"]).and_then(|v| v.as_array().cloned()) else {
+ return false;
+ };
+ let mut covered_area = 0.0f64;
+ for c in &clients {
+ if c.get("mapped").and_then(|v| v.as_bool()) != Some(true) {
+ continue;
+ }
+ if c.get("hidden").and_then(|v| v.as_bool()) == Some(true) {
+ continue;
+ }
+ if c.pointer("/workspace/id").and_then(|v| v.as_i64()) != Some(ws_id) {
+ continue;
+ }
+ let fs = c.get("fullscreen").and_then(|v| v.as_i64()).unwrap_or(0);
+ if fs > 0 {
+ return true;
+ }
+ let floating = c.get("floating").and_then(|v| v.as_bool()).unwrap_or(false);
+ if !floating {
+ if let Some(sz) = c.get("size").and_then(|v| v.as_array()) {
+ let w = sz.first().and_then(|v| v.as_f64()).unwrap_or(0.0);
+ let h = sz.get(1).and_then(|v| v.as_f64()).unwrap_or(0.0);
+ covered_area += (w * h).max(0.0);
+ }
+ }
+ }
+ // Tiled windows on Hyprland leave small gaps/bar reservation (~85-92% of total monitor area).
+ covered_area / mon_area >= 0.80
+}
+
+fn is_occlusion_event(line: &str) -> bool {
+ let prefix = line.split(">>").next().unwrap_or("");
+ matches!(
+ prefix,
+ "workspace"
+ | "workspacev2"
+ | "focusedmon"
+ | "focusedmonv2"
+ | "fullscreen"
+ | "openwindow"
+ | "closewindow"
+ | "movewindow"
+ | "movewindowv2"
+ | "changefloatingmode"
+ | "activewindowv2"
+ | "activespecial"
+ | "activespecialv2"
+ | "monitoraddedv2"
+ | "monitorremovedv2"
+ )
+}
+
+/// Spawn the event-driven Hyprland IPC watcher thread. Returns `false` if Hyprland is not running.
+pub fn spawn_watcher(state: Arc<OcclusionState>, target_output: Option<String>) -> bool {
+ let Some(sock_path) = hypr_socket2_path() else {
+ return false;
+ };
+ state.set_occluded(compute_occluded(target_output.as_deref()));
+ let _ = thread::Builder::new().name("hypr-occlusion".into()).spawn(move || {
+ while !state.is_stopped() {
+ let Ok(stream) = UnixStream::connect(&sock_path) else {
+ thread::sleep(std::time::Duration::from_secs(2));
+ continue;
+ };
+ let mut reader = BufReader::new(stream);
+ let mut line = String::new();
+ loop {
+ if state.is_stopped() {
+ return;
+ }
+ line.clear();
+ match reader.read_line(&mut line) {
+ Ok(0) => break,
+ Ok(_) => {
+ if is_occlusion_event(&line) {
+ let occ = compute_occluded(target_output.as_deref());
+ state.set_occluded(occ);
+ }
+ }
+ Err(_) => break,
+ }
+ }
+ }
+ });
+ true
+}
diff --git a/webgpu/wallpaper/src/main.rs b/webgpu/wallpaper/src/main.rs
new file mode 100644
index 0000000..ffe6bdf
--- /dev/null
+++ b/webgpu/wallpaper/src/main.rs
@@ -0,0 +1,642 @@
+//! ThreeRT Live 3D Wallpaper Host for Omarchy / Hyprland (`wlr-layer-shell` + `threert-webgpu`).
+//!
+//! Renders standard `three/webgpu` + TSL scenes directly into a Wayland `Layer::Background`
+//! swapchain in a single native process (zero browser/Chromium/DOM overhead), with:
+//! - Automatic `omarchy-shell background setSuspended` handoff & clean restore on exit
+//! - Event-driven Hyprland occlusion pause (0 FPS, 0% CPU/GPU when covered or DPMS off)
+//! - AC/battery adaptive FPS and render-scale profiles
+//! - Live Omarchy `colors.toml` theme palette injection (`globalThis.__wallpaper.theme`)
+//! - Built-in headless mode & JSON telemetry for apples-to-apples benchmarking
+use std::cell::{Cell, RefCell};
+use std::sync::atomic::{AtomicBool, Ordering};
+use std::sync::Arc;
+use std::time::{Duration, Instant};
+
+use jsc::{Ctx, Value};
+use smithay_client_toolkit::shell::wlr_layer::Layer;
+use threert_webgpu as webgpu;
+
+mod hypr;
+mod omarchy;
+mod wayland;
+
+use hypr::OcclusionState;
+use omarchy::{OmarchySuspendGuard, ThemeWatcher};
+use wayland::WaylandWallpaper;
+
+static SIG_STOP: AtomicBool = AtomicBool::new(false);
+
+extern "C" fn handle_signal(_sig: libc::c_int) {
+ SIG_STOP.store(true, Ordering::SeqCst);
+}
+
+thread_local! {
+ static WAKE_AT: Cell<f64> = const { Cell::new(f64::INFINITY) };
+ static WANT_FRAME: Cell<bool> = const { Cell::new(false) };
+ static EXIT: Cell<Option<i32>> = const { Cell::new(None) };
+ static SHOT: RefCell<Option<String>> = const { RefCell::new(None) };
+ static RNG: Cell<u64> = const { Cell::new(0x9e37_79b9_7f4a_7c15) };
+}
+
+struct Opts {
+ runtime: String,
+ script: String,
+ fps: f64,
+ battery_fps: f64,
+ render_scale: f64,
+ battery_scale: f64,
+ headless: Option<(u32, u32, f64)>,
+ shot: Option<String>,
+ shot_frame: u32,
+ duration: Option<f64>,
+ fixed_time: Option<f64>,
+ omarchy: bool,
+ occlusion_pause: bool,
+ force_paused: bool,
+ stats_json: Option<String>,
+ output: Option<String>,
+ layer: Layer,
+ colors_path: Option<String>,
+ assets_dir: Option<String>,
+ scale_override: Option<f64>,
+}
+
+fn parse_opts() -> Opts {
+ let args: Vec<String> = std::env::args().collect();
+ let get = |k: &str| args.iter().position(|x| x == k).and_then(|i| args.get(i + 1)).cloned();
+ let has = |k: &str| args.iter().any(|x| x == k);
+
+ let headless = get("--headless").map(|s| {
+ let (wh, dpr) = s.split_once('@').unwrap_or((&s, "1"));
+ let (w, h) = wh.split_once('x').unwrap_or(("1440", "900"));
+ (w.parse().unwrap_or(1440), h.parse().unwrap_or(900), dpr.parse().unwrap_or(1.0))
+ });
+ let layer = match get("--layer").as_deref() {
+ Some("top") => Layer::Top,
+ Some("bottom") => Layer::Bottom,
+ _ => Layer::Background,
+ };
+ Opts {
+ runtime: get("--runtime").unwrap_or_else(|| "out/webgpu/runtime.js".into()),
+ script: get("--script").unwrap_or_else(|| "out/webgpu/wallpaper-demo.js".into()),
+ fps: get("--fps").and_then(|s| s.parse().ok()).unwrap_or(60.0),
+ battery_fps: get("--battery-fps").and_then(|s| s.parse().ok()).unwrap_or(24.0),
+ render_scale: get("--render-scale").and_then(|s| s.parse().ok()).unwrap_or(1.0),
+ battery_scale: get("--battery-scale").and_then(|s| s.parse().ok()).unwrap_or(0.75),
+ headless,
+ shot: get("--shot"),
+ shot_frame: get("--shot-frame").and_then(|s| s.parse().ok()).unwrap_or(4),
+ duration: get("--duration").and_then(|s| s.parse().ok()),
+ fixed_time: get("--fixed-time").and_then(|s| s.parse().ok()),
+ omarchy: has("--omarchy"),
+ occlusion_pause: !has("--no-occlusion-pause"),
+ force_paused: has("--force-paused"),
+ stats_json: get("--stats-json"),
+ output: get("--output"),
+ layer,
+ colors_path: get("--colors"),
+ assets_dir: get("--assets"),
+ scale_override: get("--scale").and_then(|s| s.parse().ok()),
+ }
+}
+
+fn install_sys(c: Ctx, sys: Value, assets_dir: std::path::PathBuf) {
+ let def = |name: &str, f: Value| sys.set(c, name, f);
+ def("now", c.function(|c, _, _| Ok(c.num(rt::page_now()))));
+ def("wakeAt", c.function(|c, _, a| {
+ let t = a.first().map(|v| v.to_num(c)).unwrap_or(f64::INFINITY);
+ WAKE_AT.with(|w| w.set(if t.is_nan() { f64::INFINITY } else { t }));
+ Ok(c.undefined())
+ }));
+ def("requestFrame", c.function(|c, _, _| {
+ WANT_FRAME.with(|w| w.set(true));
+ Ok(c.undefined())
+ }));
+ def("log", c.function(|c, _, a| {
+ let level = a.first().map(|v| v.to_string(c)).unwrap_or_default();
+ let msg = a.get(1).map(|v| v.to_string(c)).unwrap_or_default();
+ eprintln!("[{level}] {msg}");
+ Ok(c.undefined())
+ }));
+ def("exit", c.function(|c, _, a| {
+ EXIT.with(|e| e.set(Some(a.first().map(|v| v.to_i32(c)).unwrap_or(0))));
+ Ok(c.undefined())
+ }));
+ def("shot", c.function(|c, _, a| {
+ let path = a.first().map(|v| v.to_string(c)).unwrap_or_else(|| "wallpaper.png".into());
+ SHOT.with(|s| *s.borrow_mut() = Some(path));
+ Ok(c.undefined())
+ }));
+ def("randomBytes", c.function(|c, _, a| {
+ let v = a.first().copied().unwrap_or(c.undefined());
+ if let Some(b) = v.bytes(c) {
+ RNG.with(|r| {
+ let mut x = r.get();
+ for byte in b.iter_mut() {
+ x ^= x << 13;
+ x ^= x >> 7;
+ x ^= x << 17;
+ *byte = x as u8;
+ }
+ r.set(x);
+ });
+ }
+ Ok(v)
+ }));
+ def("locale", c.function(|c, _, _| Ok(c.str("en-US"))));
+ def("storageGet", c.function(|c, _, _| Ok(c.null())));
+ def("storageSet", c.function(|c, _, _| Ok(c.undefined())));
+ def("resource", c.function(move |c, _, a| {
+ let rel = a.first().map(|v| v.to_string(c)).unwrap_or_default();
+ let rel = rel.trim_start_matches("./");
+ if rel.is_empty() || rel.contains("..") || rel.starts_with('/') {
+ return Ok(c.null());
+ }
+ let path = assets_dir.join(rel);
+ match std::fs::read(&path) {
+ Ok(bytes) => Ok(c.array_buffer(bytes)),
+ Err(e) => {
+ eprintln!("[threert-wallpaper] resource miss {}: {e}", path.display());
+ Ok(c.null())
+ }
+ }
+ }));
+ for name in ["navigate", "shell", "closeWindow"] {
+ def(name, c.function(|c, _, _| Ok(c.undefined())));
+ }
+}
+
+fn call_rt(c: Ctx, name: &str, now: f64) {
+ let rtv = c.global().get(c, "__rt");
+ if !rtv.is_object(c) {
+ return;
+ }
+ let f = rtv.get(c, name);
+ if f.is_function(c) {
+ if let Err(e) = c.call(f, Some(rtv), &[c.num(now)]) {
+ eprintln!("[js] __rt.{name}: {e}");
+ }
+ }
+}
+
+fn install_wallpaper_bridge(c: Ctx, theme_json: &str, fixed_time: Option<f64>, fps: f64, battery: bool, render_scale: f64) {
+ let ft = match fixed_time {
+ Some(t) => format!("{t}"),
+ None => "null".into(),
+ };
+ let script = format!(
+ r#"globalThis.__wallpaper = {{
+ theme: {theme_json},
+ fixedTime: {ft},
+ fps: {fps},
+ battery: {battery},
+ renderScale: {render_scale},
+ _listeners: [],
+ onThemeChange(fn) {{ if (typeof fn === "function") this._listeners.push(fn); }},
+ _emitTheme(next) {{
+ this.theme = next;
+ for (const fn of this._listeners) {{
+ try {{ fn(next); }} catch (e) {{ console.error("theme listener:", e); }}
+ }}
+ }}
+ }};"#
+ );
+ let _ = c.eval(&script, "<wallpaper-bridge>");
+}
+
+fn push_theme_to_js(c: Ctx, theme_json: &str) {
+ let script = format!("globalThis.__wallpaper && globalThis.__wallpaper._emitTheme({theme_json});");
+ let _ = c.eval(&script, "<wallpaper-theme>");
+}
+
+fn write_shot_tex(tex: &wgpu::Texture, path: &str, opaque: bool) -> bool {
+ let size = tex.size();
+ match webgpu::image::read_rgba(webgpu::device(), webgpu::queue(), tex, opaque, !opaque) {
+ Ok((w, h, px)) => {
+ let png = canvas2d::encode_png(w, h, &px);
+ if let Some(dir) = std::path::Path::new(path).parent() {
+ if !dir.as_os_str().is_empty() {
+ let _ = std::fs::create_dir_all(dir);
+ }
+ }
+ match std::fs::write(path, png) {
+ Ok(()) => {
+ eprintln!("[threert-wallpaper] wrote {path} ({w}x{h}, tex={}x{})", size.width, size.height);
+ true
+ }
+ Err(e) => {
+ eprintln!("[threert-wallpaper] write {path}: {e}");
+ false
+ }
+ }
+ }
+ Err(e) => {
+ eprintln!("[threert-wallpaper] readback failed: {e}");
+ false
+ }
+ }
+}
+
+fn percentile(sorted: &[f64], p: f64) -> f64 {
+ if sorted.is_empty() {
+ return 0.0;
+ }
+ let idx = ((sorted.len() - 1) as f64 * p).round() as usize;
+ sorted[idx.min(sorted.len() - 1)]
+}
+
+fn main() {
+ let proc_start = Instant::now();
+ let o = parse_opts();
+
+ unsafe {
+ libc::signal(libc::SIGINT, handle_signal as *const () as libc::sighandler_t);
+ libc::signal(libc::SIGTERM, handle_signal as *const () as libc::sighandler_t);
+ }
+
+ // Wallpaper-optimized GPU initialization: prefer LowPower (iGPU) & compact MemoryUsage.
+ let gpu = match webgpu::init(&webgpu::GpuOptions {
+ power_preference: wgpu::PowerPreference::LowPower,
+ memory_hints: wgpu::MemoryHints::MemoryUsage,
+ ..Default::default()
+ }) {
+ Ok(g) => g,
+ Err(e) => {
+ eprintln!("[threert-wallpaper] GPU unavailable: {e}");
+ std::process::exit(2);
+ }
+ };
+ let adapter_info = gpu.adapter.get_info();
+ eprintln!(
+ "[threert-wallpaper] GPU: {} ({:?}, {:?})",
+ adapter_info.name, adapter_info.device_type, adapter_info.backend
+ );
+
+ let runtime_js = std::fs::read_to_string(&o.runtime).unwrap_or_else(|e| panic!("read {}: {e}", o.runtime));
+ let script_js = std::fs::read_to_string(&o.script).unwrap_or_else(|e| panic!("read {}: {e}", o.script));
+
+ let mut theme_watcher = ThemeWatcher::new(o.colors_path.as_ref().map(Into::into));
+ let mut battery = omarchy::on_battery();
+ let mut last_battery_check = Instant::now();
+ let mut omarchy_guard = OmarchySuspendGuard::new(o.omarchy && o.headless.is_none());
+
+ let output_scale = o.scale_override.unwrap_or_else(|| {
+ if o.headless.is_some() {
+ 1.0
+ } else {
+ hypr::monitor_scale(o.output.as_deref())
+ }
+ });
+ let current_render_scale = |bat: bool| if bat { o.battery_scale } else { o.render_scale };
+ let current_fps = |bat: bool| (if bat { o.battery_fps } else { o.fps }).max(1.0);
+
+ // Initialize either Wayland wlr-layer-shell surface or offscreen headless target.
+ let mut wl: Option<WaylandWallpaper> = None;
+ let mut offscreen: Option<webgpu::Offscreen> = None;
+ let (boot_w, boot_h, boot_dpr) = if let Some((w, h, dpr)) = o.headless {
+ let eff = (dpr * current_render_scale(battery)).clamp(0.25, 4.0);
+ let pw = ((w as f64 * eff).floor() as u32).max(1);
+ let ph = ((h as f64 * eff).floor() as u32).max(1);
+ offscreen = Some(webgpu::Offscreen::new(pw, ph, wgpu::TextureFormat::Bgra8Unorm));
+ (w, h, eff)
+ } else {
+ let w = WaylandWallpaper::new(
+ &gpu.instance,
+ &gpu.adapter,
+ &gpu.device,
+ o.layer,
+ o.output.as_deref(),
+ output_scale,
+ current_render_scale(battery),
+ )
+ .unwrap_or_else(|e| {
+ eprintln!("[threert-wallpaper] Wayland layer-shell failed: {e}");
+ std::process::exit(2);
+ });
+ let (lw, lh) = w.logical_size();
+ let eff = w.scale;
+ eprintln!(
+ "[threert-wallpaper] Wayland layer-shell ready: logical={}x{} physical={}x{} scale={:.2}",
+ lw, lh, w.phys_w, w.phys_h, eff
+ );
+ wl = Some(w);
+ (lw, lh, eff)
+ };
+
+ // Setup event-driven Hyprland occlusion watcher (live mode only).
+ let occlusion = OcclusionState::new(o.force_paused);
+ if o.headless.is_none() && o.occlusion_pause && !o.force_paused {
+ if hypr::spawn_watcher(Arc::clone(&occlusion), o.output.clone()) {
+ eprintln!("[threert-wallpaper] Hyprland occlusion auto-pause active (initial occluded={})", occlusion.is_occluded());
+ }
+ }
+
+ // Boot JavaScriptCore realm + ThreeRT runtime + WebGPU.
+ let cx = jsc::Context::new("threert-wallpaper");
+ let c = cx.ctx();
+ rt::begin_page(c);
+ let native = c.object();
+ c.global().set(c, "__native", native);
+ let assets_dir = o.assets_dir.as_ref().map(std::path::PathBuf::from).unwrap_or_else(|| {
+ std::path::Path::new(&o.script)
+ .parent()
+ .map(|p| p.join("assets"))
+ .unwrap_or_else(|| std::path::PathBuf::from("assets"))
+ });
+ let sys = c.object();
+ native.set(c, "sys", sys);
+ install_sys(c, sys, assets_dir);
+ canvas2d::install(c, native);
+ webgpu::install(c, native);
+ c.global().set(
+ c,
+ "__boot",
+ c.json(&format!(
+ r#"{{"url":"http://localhost/","width":{},"height":{},"dpr":{},"lang":"en-US","title":"ThreeRT Wallpaper"}}"#,
+ boot_w, boot_h, boot_dpr
+ )),
+ );
+ install_wallpaper_bridge(
+ c,
+ theme_watcher.current_json(),
+ o.fixed_time,
+ current_fps(battery),
+ battery,
+ current_render_scale(battery),
+ );
+
+ // Evaluate runtime & scene script.
+ let mut eval_failed = false;
+ if let Some(off) = &offscreen {
+ webgpu::set_window_target(off.texture(), boot_w as f64, boot_h as f64);
+ }
+ if let Err(e) = c.eval(&runtime_js, &o.runtime) {
+ eprintln!("[js] runtime: {e}");
+ eval_failed = true;
+ }
+ if !eval_failed {
+ if let Err(e) = c.eval(&script_js, &o.script) {
+ eprintln!("[js] script: {e}");
+ eval_failed = true;
+ }
+ }
+ let _ = webgpu::end_window_frame();
+ if eval_failed {
+ omarchy_guard.restore_now();
+ rt::reset_page();
+ drop(cx);
+ std::process::exit(1);
+ }
+
+ let loop_start = Instant::now();
+ let mut ttff_ms: Option<f64> = None;
+ let mut frames: u64 = 0;
+ let mut direct_frames: u64 = 0;
+ let mut blitted_frames: u64 = 0;
+ let mut paused_ms: f64 = 0.0;
+ let mut frame_cpu_ms: Vec<f64> = Vec::with_capacity(4096);
+ let mut shot_written = false;
+ let mut next_frame = rt::page_now();
+
+ let exit_code = loop {
+ if SIG_STOP.load(Ordering::SeqCst) {
+ break 0;
+ }
+ if let Some(code) = EXIT.with(|e| e.get()) {
+ break code;
+ }
+ if let Some(dur) = o.duration {
+ if loop_start.elapsed().as_secs_f64() >= dur {
+ break 0;
+ }
+ }
+ if let Some(w) = wl.as_mut() {
+ w.poll_events();
+ if w.state.closed {
+ break 0;
+ }
+ }
+
+ // Occlusion / force-pause sleep: completely halt JS + GPU until uncovered!
+ // Always render at least 1 frame first so TTFF & initial wallpaper frame are ready.
+ if (o.force_paused || (o.occlusion_pause && occlusion.is_occluded())) && frames >= 1 {
+ let p0 = Instant::now();
+ let remain = o
+ .duration
+ .map(|d| Duration::from_secs_f64((d - loop_start.elapsed().as_secs_f64()).max(0.0)))
+ .unwrap_or(Duration::from_millis(500));
+ let wait = remain.min(Duration::from_millis(500));
+ if !wait.is_zero() {
+ occlusion.wait_while_occluded(wait);
+ }
+ paused_ms += p0.elapsed().as_secs_f64() * 1000.0;
+ next_frame = rt::page_now();
+ continue;
+ }
+
+ // Periodic AC/battery & Omarchy theme checks (only while awake, low frequency).
+ if last_battery_check.elapsed() >= Duration::from_secs(5) {
+ last_battery_check = Instant::now();
+ let new_bat = omarchy::on_battery();
+ if new_bat != battery {
+ battery = new_bat;
+ if let Some(w) = wl.as_mut() {
+ w.reconfigure(&gpu.device, output_scale * current_render_scale(battery));
+ }
+ }
+ }
+ if let Some(new_theme) = theme_watcher.poll_changed() {
+ push_theme_to_js(c, &new_theme);
+ }
+
+ rt::drain();
+ let now = rt::page_now();
+ if WAKE_AT.with(|w| w.get()) <= now + 0.5 {
+ WAKE_AT.with(|w| w.set(f64::INFINITY));
+ if let Some(off) = &offscreen {
+ webgpu::set_window_target(off.texture(), boot_w as f64, boot_h as f64);
+ }
+ call_rt(c, "timers", now);
+ let _ = webgpu::end_window_frame();
+ }
+
+ let target_fps = current_fps(battery);
+ let frame_ms = 1000.0 / target_fps;
+
+ if WANT_FRAME.with(|w| w.get()) && now >= next_frame {
+ WANT_FRAME.with(|w| w.set(false));
+ next_frame = (next_frame + frame_ms).max(now);
+
+ if let Some(off) = &offscreen {
+ let f0 = Instant::now();
+ webgpu::set_window_target(off.texture(), boot_w as f64, boot_h as f64);
+ call_rt(c, "frame", now);
+ let fr = webgpu::end_window_frame();
+ frame_cpu_ms.push(f0.elapsed().as_secs_f64() * 1000.0);
+ if fr.drew {
+ frames += 1;
+ if fr.blitted {
+ blitted_frames += 1;
+ } else {
+ direct_frames += 1;
+ }
+ if ttff_ms.is_none() {
+ ttff_ms = Some(proc_start.elapsed().as_secs_f64() * 1000.0);
+ eprintln!("[threert-wallpaper] TTFF={:.1}ms", ttff_ms.unwrap());
+ }
+ if let Some(path) = SHOT.with(|s| s.borrow_mut().take()) {
+ shot_written = write_shot_tex(off.texture(), &path, fr.opaque);
+ } else if let Some(path) = &o.shot {
+ if !shot_written && frames >= o.shot_frame as u64 {
+ shot_written = write_shot_tex(off.texture(), path, fr.opaque);
+ if o.duration.is_none() {
+ break 0;
+ }
+ }
+ }
+ }
+ webgpu::wait_idle();
+ } else if let Some(w) = wl.as_mut() {
+ if w.state.resized {
+ w.reconfigure(&gpu.device, output_scale * current_render_scale(battery));
+ }
+ match w.surface.get_current_texture() {
+ Ok(surface_tex) => {
+ let f0 = Instant::now();
+ let (lw, lh) = w.logical_size();
+ webgpu::set_window_target(&surface_tex.texture, lw as f64, lh as f64);
+ call_rt(c, "frame", now);
+ let fr = webgpu::end_window_frame();
+ if fr.drew {
+ if let Some(path) = &o.shot {
+ if !shot_written && frames + 1 >= o.shot_frame as u64 {
+ shot_written = write_shot_tex(&surface_tex.texture, path, fr.opaque);
+ }
+ }
+ surface_tex.present();
+ frame_cpu_ms.push(f0.elapsed().as_secs_f64() * 1000.0);
+ frames += 1;
+ if fr.blitted {
+ blitted_frames += 1;
+ } else {
+ direct_frames += 1;
+ }
+ if ttff_ms.is_none() {
+ ttff_ms = Some(proc_start.elapsed().as_secs_f64() * 1000.0);
+ eprintln!("[threert-wallpaper] TTFF={:.1}ms (direct={})", ttff_ms.unwrap(), !fr.blitted);
+ omarchy_guard.suspend_now();
+ }
+ } else {
+ // Never discard an acquired Vulkan swapchain texture on Wayland (wgpu-hal can wedge
+ // subsequent acquires with Timeout). Submit a minimal clear and present cleanly.
+ let view = surface_tex.texture.create_view(&Default::default());
+ let mut enc = gpu.device.create_command_encoder(&Default::default());
+ {
+ let _pass = enc.begin_render_pass(&wgpu::RenderPassDescriptor {
+ label: Some("wallpaper-idle-clear"),
+ color_attachments: &[Some(wgpu::RenderPassColorAttachment {
+ view: &view,
+ resolve_target: None,
+ ops: wgpu::Operations {
+ load: wgpu::LoadOp::Clear(wgpu::Color { r: 0.008, g: 0.015, b: 0.03, a: 1.0 }),
+ store: wgpu::StoreOp::Store,
+ },
+ })],
+ ..Default::default()
+ });
+ }
+ gpu.queue.submit([enc.finish()]);
+ surface_tex.present();
+ }
+ }
+ Err(e @ (wgpu::SurfaceError::Lost | wgpu::SurfaceError::Outdated)) => {
+ eprintln!("[threert-wallpaper] surface {e:?}, reconfiguring...");
+ WANT_FRAME.with(|wf| wf.set(true));
+ w.state.resized = true;
+ w.reconfigure(&gpu.device, output_scale * current_render_scale(battery));
+ }
+ Err(wgpu::SurfaceError::Timeout) => {
+ WANT_FRAME.with(|wf| wf.set(true));
+ std::thread::sleep(Duration::from_millis(8));
+ }
+ Err(wgpu::SurfaceError::OutOfMemory) => {
+ eprintln!("[threert-wallpaper] surface OOM");
+ break 1;
+ }
+ Err(wgpu::SurfaceError::Other) => {
+ eprintln!("[threert-wallpaper] surface Other error");
+ WANT_FRAME.with(|wf| wf.set(true));
+ }
+ }
+ }
+
+ continue;
+ }
+
+ webgpu::poll();
+ let wake = WAKE_AT
+ .with(|w| w.get())
+ .min(if WANT_FRAME.with(|w| w.get()) { next_frame } else { f64::INFINITY });
+ let sleep_ms = (wake - rt::page_now()).clamp(0.0, 50.0);
+ if sleep_ms > 0.25 {
+ std::thread::sleep(Duration::from_secs_f64(sleep_ms / 1000.0));
+ }
+ };
+
+ occlusion.request_stop();
+ omarchy_guard.restore_now();
+
+ let elapsed_ms = loop_start.elapsed().as_secs_f64() * 1000.0;
+ let active_ms = (elapsed_ms - paused_ms).max(1.0);
+ let achieved_fps = frames as f64 / (active_ms / 1000.0);
+ frame_cpu_ms.sort_by(|a, b| a.total_cmp(b));
+ let (pw, ph) = if let Some(w) = &wl {
+ (w.phys_w, w.phys_h)
+ } else if let Some(off) = &offscreen {
+ let s = off.texture().size();
+ (s.width, s.height)
+ } else {
+ (0, 0)
+ };
+
+ let wg = webgpu::take_stats();
+ let stats = serde_json::json!({
+ "gpu": adapter_info.name,
+ "backend": format!("{:?}", adapter_info.backend),
+ "logical": [boot_w, boot_h],
+ "physical": [pw, ph],
+ "scale": boot_dpr,
+ "target_fps": current_fps(battery),
+ "frames": frames,
+ "direct_frames": direct_frames,
+ "blitted_frames": blitted_frames,
+ "ttff_ms": ttff_ms,
+ "elapsed_ms": elapsed_ms,
+ "paused_ms": paused_ms,
+ "active_ms": active_ms,
+ "achieved_fps": achieved_fps,
+ "frame_cpu_p50_ms": percentile(&frame_cpu_ms, 0.50),
+ "frame_cpu_p95_ms": percentile(&frame_cpu_ms, 0.95),
+ "frame_cpu_p99_ms": percentile(&frame_cpu_ms, 0.99),
+ "webgpu_draws": wg.draws,
+ "webgpu_submits": wg.submits,
+ "webgpu_finish_ms": wg.finish_ns as f64 / 1e6,
+ "webgpu_submit_ms": wg.submit_ns as f64 / 1e6,
+ "webgpu_write_ms": wg.write_ns as f64 / 1e6,
+ });
+ eprintln!("[threert-wallpaper] stats: {stats}");
+ if let Some(path) = &o.stats_json {
+ if let Some(dir) = std::path::Path::new(path).parent() {
+ if !dir.as_os_str().is_empty() {
+ let _ = std::fs::create_dir_all(dir);
+ }
+ }
+ let _ = std::fs::write(path, serde_json::to_string_pretty(&stats).unwrap_or_default());
+ }
+
+ rt::reset_page();
+ drop(wl);
+ drop(offscreen);
+ drop(cx);
+ std::process::exit(exit_code);
+}
diff --git a/webgpu/wallpaper/src/omarchy.rs b/webgpu/wallpaper/src/omarchy.rs
new file mode 100644
index 0000000..ba370d7
--- /dev/null
+++ b/webgpu/wallpaper/src/omarchy.rs
@@ -0,0 +1,205 @@
+//! Omarchy integration: theme palette (`colors.toml`) live watcher, AC/battery power detection,
+//! and `omarchy-shell background setSuspended` RAII lifecycle guard.
+use std::collections::BTreeMap;
+use std::fs;
+use std::path::{Path, PathBuf};
+use std::process::{Command, Stdio};
+use std::time::{Instant, SystemTime};
+
+/// Default Tokyo Night fallback palette when Omarchy's `colors.toml` is not present.
+fn default_palette() -> BTreeMap<String, String> {
+ let pairs = [
+ ("mode", "dark"),
+ ("accent", "#7aa2f7"),
+ ("background", "#1a1b26"),
+ ("dark_background", "#13141c"),
+ ("darker_background", "#0e0e14"),
+ ("lighter_background", "#24283b"),
+ ("foreground", "#a9b1d6"),
+ ("bright_foreground", "#c0caf5"),
+ ("blue", "#7aa2f7"),
+ ("cyan", "#449dab"),
+ ("magenta", "#ad8ee6"),
+ ("orange", "#eb927b"),
+ ("yellow", "#e0af68"),
+ ("green", "#9ece6a"),
+ ("red", "#f7768e"),
+ ("bright_cyan", "#0db9d7"),
+ ("bright_blue", "#7da6ff"),
+ ];
+ pairs.into_iter().map(|(k, v)| (k.to_string(), v.to_string())).collect()
+}
+
+pub fn default_colors_path() -> PathBuf {
+ if let Ok(state) = std::env::var("XDG_STATE_HOME") {
+ if !state.is_empty() {
+ return PathBuf::from(state).join("omarchy/current/theme/colors.toml");
+ }
+ }
+ let home = std::env::var("HOME").unwrap_or_default();
+ PathBuf::from(home).join(".local/state/omarchy/current/theme/colors.toml")
+}
+
+/// Parse Omarchy's flat `key = "value"` `colors.toml` without pulling in a TOML crate.
+pub fn parse_colors_toml(src: &str) -> BTreeMap<String, String> {
+ let mut map = default_palette();
+ for raw_line in src.lines() {
+ let line = raw_line.split('#').next().unwrap_or("").trim();
+ // Wait: color values contain `#` inside quotes! Parse `key = "val"` before stripping comments.
+ let _ = line;
+ let trimmed = raw_line.trim();
+ if trimmed.is_empty() || trimmed.starts_with('#') || trimmed.starts_with('[') {
+ continue;
+ }
+ let Some((k, v)) = trimmed.split_once('=') else { continue };
+ let key = k.trim();
+ let val_part = v.trim();
+ let val = if let Some(rest) = val_part.strip_prefix('"') {
+ rest.split('"').next().unwrap_or("")
+ } else if let Some(rest) = val_part.strip_prefix('\'') {
+ rest.split('\'').next().unwrap_or("")
+ } else {
+ val_part.split('#').next().unwrap_or("").trim()
+ };
+ if !key.is_empty() && !val.is_empty() {
+ map.insert(key.to_string(), val.to_string());
+ }
+ }
+ map
+}
+
+pub fn palette_to_json(map: &BTreeMap<String, String>) -> String {
+ serde_json::to_string(map).unwrap_or_else(|_| "{}".into())
+}
+
+pub struct ThemeWatcher {
+ path: PathBuf,
+ last_mtime: Option<SystemTime>,
+ last_check: Instant,
+ current_json: String,
+}
+
+impl ThemeWatcher {
+ pub fn new(path: Option<PathBuf>) -> Self {
+ let path = path.unwrap_or_else(default_colors_path);
+ let (mtime, json) = Self::read_file(&path);
+ Self {
+ path,
+ last_mtime: mtime,
+ last_check: Instant::now(),
+ current_json: json,
+ }
+ }
+
+ fn read_file(path: &Path) -> (Option<SystemTime>, String) {
+ let mtime = fs::metadata(path).and_then(|m| m.modified()).ok();
+ let map = fs::read_to_string(path)
+ .map(|s| parse_colors_toml(&s))
+ .unwrap_or_else(|_| default_palette());
+ (mtime, palette_to_json(&map))
+ }
+
+ pub fn current_json(&self) -> &str {
+ &self.current_json
+ }
+
+ /// Check at most once per second for theme changes; returns `Some(new_json)` on change.
+ pub fn poll_changed(&mut self) -> Option<String> {
+ if self.last_check.elapsed().as_millis() < 1000 {
+ return None;
+ }
+ self.last_check = Instant::now();
+ let mtime = fs::metadata(&self.path).and_then(|m| m.modified()).ok();
+ if mtime == self.last_mtime {
+ return None;
+ }
+ let (new_mtime, new_json) = Self::read_file(&self.path);
+ self.last_mtime = new_mtime;
+ if new_json != self.current_json {
+ self.current_json = new_json.clone();
+ Some(new_json)
+ } else {
+ None
+ }
+ }
+}
+
+/// Detect whether the laptop is currently running on battery power (`Discharging`).
+pub fn on_battery() -> bool {
+ let Ok(entries) = fs::read_dir("/sys/class/power_supply") else { return false };
+ let mut saw_ac = false;
+ let mut ac_online = false;
+ for entry in entries.flatten() {
+ let p = entry.path();
+ let kind = fs::read_to_string(p.join("type")).unwrap_or_default();
+ match kind.trim() {
+ "Battery" => {
+ if let Ok(st) = fs::read_to_string(p.join("status")) {
+ if st.trim().eq_ignore_ascii_case("Discharging") {
+ return true;
+ }
+ }
+ }
+ "Mains" => {
+ saw_ac = true;
+ if let Ok(on) = fs::read_to_string(p.join("online")) {
+ if on.trim() == "1" {
+ ac_online = true;
+ }
+ }
+ }
+ _ => {}
+ }
+ }
+ saw_ac && !ac_online
+}
+
+/// Suspends `omarchy-shell`'s static background layer once ThreeRT has presented its first frame,
+/// and restores it cleanly when dropped.
+pub struct OmarchySuspendGuard {
+ enabled: bool,
+ suspended: bool,
+}
+
+impl OmarchySuspendGuard {
+ pub fn new(enabled: bool) -> Self {
+ Self { enabled, suspended: false }
+ }
+
+ pub fn suspend_now(&mut self) {
+ if !self.enabled || self.suspended {
+ return;
+ }
+ let ok = Command::new("omarchy-shell")
+ .args(["-q", "background", "setSuspended", "true"])
+ .stdin(Stdio::null())
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .status()
+ .is_ok_and(|s| s.success());
+ if ok {
+ self.suspended = true;
+ eprintln!("[threert-wallpaper] suspended omarchy-shell static background");
+ }
+ }
+
+ pub fn restore_now(&mut self) {
+ if !self.suspended {
+ return;
+ }
+ let _ = Command::new("omarchy-shell")
+ .args(["-q", "background", "setSuspended", "false"])
+ .stdin(Stdio::null())
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .status();
+ self.suspended = false;
+ eprintln!("[threert-wallpaper] restored omarchy-shell static background");
+ }
+}
+
+impl Drop for OmarchySuspendGuard {
+ fn drop(&mut self) {
+ self.restore_now();
+ }
+}
diff --git a/webgpu/wallpaper/src/wayland.rs b/webgpu/wallpaper/src/wayland.rs
new file mode 100644
index 0000000..871ed53
--- /dev/null
+++ b/webgpu/wallpaper/src/wayland.rs
@@ -0,0 +1,296 @@
+//! Native Wayland `wlr-layer-shell` (`Layer::Background` or `Layer::Top`) surface backed directly
+//! by a `wgpu::Surface` and `wp_viewporter` for fractional HiDPI + dynamic render scaling.
+use std::ptr::NonNull;
+
+use raw_window_handle::{RawDisplayHandle, RawWindowHandle, WaylandDisplayHandle, WaylandWindowHandle};
+use smithay_client_toolkit::{
+ compositor::{CompositorHandler, CompositorState},
+ delegate_compositor, delegate_layer, delegate_output, delegate_registry, delegate_simple,
+ output::{OutputHandler, OutputState},
+ registry::{ProvidesRegistryState, RegistryState, SimpleGlobal},
+ registry_handlers,
+ shell::{
+ wlr_layer::{Anchor, KeyboardInteractivity, Layer, LayerShell, LayerShellHandler, LayerSurface, LayerSurfaceConfigure},
+ WaylandSurface,
+ },
+};
+use wayland_client::{
+ globals::registry_queue_init,
+ protocol::{wl_output, wl_surface},
+ Connection, Dispatch, EventQueue, Proxy, QueueHandle,
+};
+use wayland_protocols::wp::viewporter::client::{
+ wp_viewport::{self, WpViewport},
+ wp_viewporter::WpViewporter,
+};
+
+pub struct LayerApp {
+ registry_state: RegistryState,
+ output_state: OutputState,
+ wp_viewporter: Option<SimpleGlobal<WpViewporter, 1>>,
+ viewport: Option<WpViewport>,
+ pub layer: LayerSurface,
+ pub logical_w: u32,
+ pub logical_h: u32,
+ pub configured: bool,
+ pub resized: bool,
+ pub closed: bool,
+}
+
+impl CompositorHandler for LayerApp {
+ fn scale_factor_changed(&mut self, _: &Connection, _: &QueueHandle<Self>, _: &wl_surface::WlSurface, _: i32) {}
+ fn transform_changed(&mut self, _: &Connection, _: &QueueHandle<Self>, _: &wl_surface::WlSurface, _: wl_output::Transform) {}
+ fn frame(&mut self, _: &Connection, _: &QueueHandle<Self>, _: &wl_surface::WlSurface, _: u32) {}
+ fn surface_enter(&mut self, _: &Connection, _: &QueueHandle<Self>, _: &wl_surface::WlSurface, _: &wl_output::WlOutput) {}
+ fn surface_leave(&mut self, _: &Connection, _: &QueueHandle<Self>, _: &wl_surface::WlSurface, _: &wl_output::WlOutput) {}
+}
+
+impl OutputHandler for LayerApp {
+ fn output_state(&mut self) -> &mut OutputState {
+ &mut self.output_state
+ }
+ fn new_output(&mut self, _: &Connection, _: &QueueHandle<Self>, _: wl_output::WlOutput) {}
+ fn update_output(&mut self, _: &Connection, _: &QueueHandle<Self>, _: wl_output::WlOutput) {}
+ fn output_destroyed(&mut self, _: &Connection, _: &QueueHandle<Self>, _: wl_output::WlOutput) {}
+}
+
+impl LayerShellHandler for LayerApp {
+ fn closed(&mut self, _: &Connection, _: &QueueHandle<Self>, _: &LayerSurface) {
+ self.closed = true;
+ }
+
+ fn configure(&mut self, _: &Connection, _: &QueueHandle<Self>, _: &LayerSurface, configure: LayerSurfaceConfigure, _: u32) {
+ let w = configure.new_size.0.max(1);
+ let h = configure.new_size.1.max(1);
+ if !self.configured || w != self.logical_w || h != self.logical_h {
+ self.logical_w = w;
+ self.logical_h = h;
+ self.resized = true;
+ }
+ self.configured = true;
+ if let Some(vp) = &self.viewport {
+ vp.set_destination(self.logical_w as i32, self.logical_h as i32);
+ }
+ }
+}
+
+delegate_compositor!(LayerApp);
+delegate_output!(LayerApp);
+delegate_layer!(LayerApp);
+delegate_registry!(LayerApp);
+delegate_simple!(LayerApp, WpViewporter, 1);
+
+impl Dispatch<WpViewport, ()> for LayerApp {
+ fn event(_: &mut Self, _: &WpViewport, _: wp_viewport::Event, _: &(), _: &Connection, _: &QueueHandle<Self>) {}
+}
+
+impl ProvidesRegistryState for LayerApp {
+ fn registry(&mut self) -> &mut RegistryState {
+ &mut self.registry_state
+ }
+ registry_handlers![OutputState];
+}
+
+pub struct WaylandWallpaper {
+ // Field order matters: `wgpu::Surface` must drop before `LayerApp` (`wl_surface`) and `Connection` (`wl_display`).
+ pub surface: wgpu::Surface<'static>,
+ pub state: LayerApp,
+ queue: EventQueue<LayerApp>,
+ conn: Connection,
+ pub config: wgpu::SurfaceConfiguration,
+ pub phys_w: u32,
+ pub phys_h: u32,
+ pub scale: f64,
+}
+
+impl WaylandWallpaper {
+ pub fn new(
+ instance: &wgpu::Instance,
+ adapter: &wgpu::Adapter,
+ device: &wgpu::Device,
+ layer_kind: Layer,
+ target_output: Option<&str>,
+ output_scale: f64,
+ render_scale: f64,
+ ) -> Result<Self, String> {
+ let conn = Connection::connect_to_env().map_err(|e| format!("Wayland connect: {e}"))?;
+ let (globals, mut queue) = registry_queue_init::<LayerApp>(&conn).map_err(|e| format!("Wayland registry: {e}"))?;
+ let qh = queue.handle();
+
+ let compositor = CompositorState::bind(&globals, &qh).map_err(|e| format!("wl_compositor: {e}"))?;
+ let layer_shell = LayerShell::bind(&globals, &qh).map_err(|e| format!("zwlr_layer_shell_v1: {e}"))?;
+ let wp_viewporter = SimpleGlobal::<WpViewporter, 1>::bind(&globals, &qh).ok();
+ let output_state = OutputState::new(&globals, &qh);
+ let registry_state = RegistryState::new(&globals);
+
+ // Pick requested wl_output if named, else let compositor pick default/focused output.
+ let wl_surface = compositor.create_surface(&qh);
+ let viewport = wp_viewporter
+ .as_ref()
+ .and_then(|vp| vp.get().ok())
+ .map(|vp| vp.get_viewport(&wl_surface, &qh, ()));
+
+ let mut chosen_output: Option<wl_output::WlOutput> = None;
+ if let Some(name) = target_output {
+ // Do one roundtrip after constructing LayerApp? We can pick by name if already advertised.
+ for out in output_state.outputs() {
+ if output_state.info(&out).and_then(|i| i.name).as_deref() == Some(name) {
+ chosen_output = Some(out);
+ break;
+ }
+ }
+ }
+
+ let layer = layer_shell.create_layer_surface(&qh, wl_surface, layer_kind, Some("threert-wallpaper"), chosen_output.as_ref());
+ layer.set_anchor(Anchor::TOP | Anchor::BOTTOM | Anchor::LEFT | Anchor::RIGHT);
+ layer.set_exclusive_zone(-1);
+ layer.set_keyboard_interactivity(KeyboardInteractivity::None);
+ layer.set_size(0, 0);
+ layer.commit();
+
+ let mut state = LayerApp {
+ registry_state,
+ output_state,
+ wp_viewporter,
+ viewport,
+ layer,
+ logical_w: 1280,
+ logical_h: 800,
+ configured: false,
+ resized: false,
+ closed: false,
+ };
+
+ // Wait for compositor's initial configure so we know the exact logical display dimensions.
+ for _ in 0..32 {
+ queue.roundtrip(&mut state).map_err(|e| format!("Wayland roundtrip: {e}"))?;
+ if state.configured {
+ break;
+ }
+ }
+ if !state.configured {
+ return Err("timed out waiting for wlr-layer-shell configure".into());
+ }
+ let _ = &state.wp_viewporter;
+
+ let raw_display_handle = RawDisplayHandle::Wayland(WaylandDisplayHandle::new(
+ NonNull::new(conn.backend().display_ptr() as *mut _).ok_or("null wl_display")?,
+ ));
+ let raw_window_handle = RawWindowHandle::Wayland(WaylandWindowHandle::new(
+ NonNull::new(state.layer.wl_surface().id().as_ptr() as *mut _).ok_or("null wl_surface")?,
+ ));
+ let surface = unsafe {
+ instance
+ .create_surface_unsafe(wgpu::SurfaceTargetUnsafe::RawHandle {
+ raw_display_handle,
+ raw_window_handle,
+ })
+ .map_err(|e| format!("create_surface: {e}"))?
+ };
+
+ let caps = surface.get_capabilities(adapter);
+ let format = if caps.formats.contains(&wgpu::TextureFormat::Bgra8Unorm) {
+ wgpu::TextureFormat::Bgra8Unorm
+ } else if caps.formats.contains(&wgpu::TextureFormat::Rgba8Unorm) {
+ wgpu::TextureFormat::Rgba8Unorm
+ } else {
+ *caps.formats.first().ok_or("surface has no supported formats")?
+ };
+ let alpha_mode = if caps.alpha_modes.contains(&wgpu::CompositeAlphaMode::Opaque) {
+ wgpu::CompositeAlphaMode::Opaque
+ } else {
+ caps.alpha_modes[0]
+ };
+
+ let effective_scale = (output_scale * render_scale).clamp(0.25, 4.0);
+ // Match three.js `Math.floor(width * pixelRatio)` so direct swapchain rendering never triggers a blit.
+ let phys_w = ((state.logical_w as f64 * effective_scale).floor() as u32).max(1);
+ let phys_h = ((state.logical_h as f64 * effective_scale).floor() as u32).max(1);
+ if let Some(vp) = &state.viewport {
+ vp.set_destination(state.logical_w as i32, state.logical_h as i32);
+ }
+
+ let usage = wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC | wgpu::TextureUsages::TEXTURE_BINDING;
+ let supported_usage = caps.usages;
+ let cfg_usage = if supported_usage.contains(usage) {
+ usage
+ } else {
+ (usage & supported_usage) | wgpu::TextureUsages::RENDER_ATTACHMENT
+ };
+
+ let config = wgpu::SurfaceConfiguration {
+ usage: cfg_usage,
+ format,
+ width: phys_w,
+ height: phys_h,
+ present_mode: wgpu::PresentMode::Fifo,
+ desired_maximum_frame_latency: 2,
+ alpha_mode,
+ view_formats: vec![],
+ };
+ surface.configure(device, &config);
+ state.resized = false;
+
+ Ok(Self {
+ conn,
+ queue,
+ state,
+ surface,
+ config,
+ phys_w,
+ phys_h,
+ scale: effective_scale,
+ })
+ }
+
+ pub fn reconfigure(&mut self, device: &wgpu::Device, effective_scale: f64) {
+ let s = effective_scale.clamp(0.25, 4.0);
+ let pw = ((self.state.logical_w as f64 * s).floor() as u32).max(1);
+ let ph = ((self.state.logical_h as f64 * s).floor() as u32).max(1);
+ if pw == self.phys_w && ph == self.phys_h && !self.state.resized {
+ return;
+ }
+ self.scale = s;
+ self.phys_w = pw;
+ self.phys_h = ph;
+ self.config.width = pw;
+ self.config.height = ph;
+ if let Some(vp) = &self.state.viewport {
+ vp.set_destination(self.state.logical_w as i32, self.state.logical_h as i32);
+ }
+ self.surface.configure(device, &self.config);
+ self.state.resized = false;
+ }
+
+ /// Non-blocking Wayland event pump (drains compositor configure/close events without blocking).
+ pub fn poll_events(&mut self) {
+ use std::os::fd::AsRawFd;
+ let _ = self.conn.flush();
+ if let Some(guard) = self.conn.prepare_read() {
+ let mut pfd = libc::pollfd {
+ fd: guard.connection_fd().as_raw_fd(),
+ events: libc::POLLIN,
+ revents: 0,
+ };
+ let ready = unsafe { libc::poll(&mut pfd, 1, 0) };
+ if ready > 0 && (pfd.revents & libc::POLLIN) != 0 {
+ let _ = guard.read();
+ } else {
+ drop(guard);
+ }
+ }
+ let _ = self.queue.dispatch_pending(&mut self.state);
+ }
+
+ pub fn logical_size(&self) -> (u32, u32) {
+ (self.state.logical_w, self.state.logical_h)
+ }
+}
+
+impl Drop for WaylandWallpaper {
+ fn drop(&mut self) {
+ if let Some(vp) = self.state.viewport.take() {
+ vp.destroy();
+ }
+ }
+}