diff --git a/Cargo.lock b/Cargo.lock index eb76c64..fb9d13c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,22 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ab_glyph" +version = "0.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e53b0a3d5760cd2ba9b787ae0c6440ad18ee294ff71b05e3381c900a7d16cfd" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" + [[package]] name = "addr2line" version = "0.21.0" @@ -17,6 +33,19 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "getrandom", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -26,6 +55,51 @@ dependencies = [ "memchr", ] +[[package]] +name = "android-activity" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046" +dependencies = [ + "android-properties", + "bitflags 2.5.0", + "cc", + "cesu8", + "jni", + "jni-sys", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "num_enum 0.7.2", + "thiserror", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + +[[package]] +name = "android_log-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ecc8056bf6ab9892dcd53216c83d1597487d7dacac16c8df6b877d127df9937" + +[[package]] +name = "android_logger" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f" +dependencies = [ + "android_log-sys", + "env_logger", + "log", + "once_cell", +] + [[package]] name = "angle" version = "0.5.0" @@ -126,6 +200,24 @@ dependencies = [ "num-traits", ] +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "as-raw-xcb-connection" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" + [[package]] name = "async-stream" version = "0.3.5" @@ -159,6 +251,12 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "atty" version = "0.2.14" @@ -242,28 +340,6 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" -[[package]] -name = "bindgen" -version = "0.64.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" -dependencies = [ - "bitflags 1.3.2", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 1.0.109", - "which", -] - [[package]] name = "bitflags" version = "1.3.2" @@ -276,6 +352,21 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +[[package]] +name = "block2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" +dependencies = [ + "objc2", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + [[package]] name = "bytemuck" version = "1.16.0" @@ -308,6 +399,20 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +[[package]] +name = "calloop" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298" +dependencies = [ + "bitflags 2.5.0", + "log", + "polling", + "rustix", + "slab", + "thiserror", +] + [[package]] name = "calloop" version = "0.13.0" @@ -322,20 +427,34 @@ dependencies = [ "thiserror", ] +[[package]] +name = "calloop-wayland-source" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" +dependencies = [ + "calloop 0.12.4", + "rustix", + "wayland-backend", + "wayland-client", +] + [[package]] name = "cc" version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +dependencies = [ + "jobserver", + "libc", + "once_cell", +] [[package]] -name = "cexpr" -version = "0.6.0" +name = "cesu8" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" [[package]] name = "cfg-if" @@ -365,17 +484,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "clang-sys" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a483f3cbf7cec2e153d424d0e92329d816becc6421389bd494375c6065921b9b" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" version = "4.5.4" @@ -467,13 +575,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] -name = "concat-idents" -version = "1.1.5" +name = "combine" +version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f76990911f2267d837d9d0ad060aa63aaad170af40904b29461734c339030d4d" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" dependencies = [ - "quote", - "syn 2.0.66", + "bytes", + "memchr", ] [[package]] @@ -531,6 +639,46 @@ dependencies = [ "unicode-segmentation", ] +[[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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "core-graphics" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[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 = "crc32fast" version = "1.4.2" @@ -565,6 +713,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "cty" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" + [[package]] name = "cursor-icon" version = "1.1.0" @@ -601,6 +755,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + [[package]] name = "dlib" version = "0.5.2" @@ -616,6 +776,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" +[[package]] +name = "dpi" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53" + [[package]] name = "drm" version = "0.11.1" @@ -670,6 +836,16 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "env_logger" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +dependencies = [ + "log", + "regex", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -741,6 +917,33 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + [[package]] name = "futures-channel" version = "0.3.30" @@ -834,20 +1037,14 @@ dependencies = [ [[package]] name = "glam" -version = "0.23.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e4afd9ad95555081e109fe1d21f2a30c691b5f0919c67dfa690a2e1eb6bd51c" +checksum = "9e05e7e6723e3455f4818c7b26e855439f7546cf617ef669d1adedb8669e5cb9" dependencies = [ "mint", "serde", ] -[[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" - [[package]] name = "global_counter" version = "0.2.2" @@ -929,15 +1126,6 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "http" version = "0.2.12" @@ -1082,6 +1270,46 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + +[[package]] +name = "jobserver" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "kdl" version = "4.6.0" @@ -1105,12 +1333,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" version = "0.2.155" @@ -1127,6 +1349,17 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "libredox" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607" +dependencies = [ + "bitflags 2.5.0", + "libc", + "redox_syscall 0.4.1", +] + [[package]] name = "libredox" version = "0.1.3" @@ -1178,6 +1411,11 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "macros" +version = "0.1.0" +source = "git+https://github.com/mvvvv/StereoKit-rust.git#348e8a458e0b329464fa292ec3635d3eaabd21d7" + [[package]] name = "manifest-dir-macros" version = "0.1.18" @@ -1220,6 +1458,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memmap2" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.9.1" @@ -1302,12 +1549,38 @@ dependencies = [ "rand", ] +[[package]] +name = "ndk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +dependencies = [ + "bitflags 2.5.0", + "jni-sys", + "log", + "ndk-sys", + "num_enum 0.7.2", + "raw-window-handle 0.4.3", + "raw-window-handle 0.5.2", + "raw-window-handle 0.6.2", + "thiserror", +] + [[package]] name = "ndk-context" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" +[[package]] +name = "ndk-sys" +version = "0.6.0+11769913" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" +dependencies = [ + "jni-sys", +] + [[package]] name = "nix" version = "0.27.1" @@ -1394,11 +1667,11 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.6.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" dependencies = [ - "num_enum_derive 0.6.1", + "num_enum_derive 0.7.2", ] [[package]] @@ -1415,9 +1688,9 @@ dependencies = [ [[package]] name = "num_enum_derive" -version = "0.6.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1425,6 +1698,106 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" + +[[package]] +name = "objc2" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" +dependencies = [ + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2-app-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" +dependencies = [ + "bitflags 2.5.0", + "block2", + "libc", + "objc2", + "objc2-core-data", + "objc2-core-image", + "objc2-foundation", + "objc2-quartz-core", +] + +[[package]] +name = "objc2-core-data" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" +dependencies = [ + "bitflags 2.5.0", + "block2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-image" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" +dependencies = [ + "block2", + "objc2", + "objc2-foundation", + "objc2-metal", +] + +[[package]] +name = "objc2-encode" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7891e71393cd1f227313c9379a26a584ff3d7e6e7159e988851f0934c993f0f8" + +[[package]] +name = "objc2-foundation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" +dependencies = [ + "bitflags 2.5.0", + "block2", + "dispatch", + "libc", + "objc2", +] + +[[package]] +name = "objc2-metal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" +dependencies = [ + "bitflags 2.5.0", + "block2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +dependencies = [ + "bitflags 2.5.0", + "block2", + "objc2", + "objc2-foundation", + "objc2-metal", +] + [[package]] name = "object" version = "0.32.2" @@ -1440,18 +1813,45 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openxr-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1534b2c14b56564e58b91f5015817e1d87bd43ca12a188eda6a9ea3859b0ec25" +dependencies = [ + "libc", +] + [[package]] name = "option-ext" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "orbclient" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166" +dependencies = [ + "libredox 0.0.2", +] + [[package]] name = "overload" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "owned_ttf_parser" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b41438d2fc63c46c74a2203bf5ccd82c41ba04347b2fcf5754f230b167067d5" +dependencies = [ + "ttf-parser", +] + [[package]] name = "owo-colors" version = "3.5.0" @@ -1506,12 +1906,6 @@ dependencies = [ "windows-targets 0.52.5", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "percent-encoding" version = "2.3.1" @@ -1712,6 +2106,27 @@ dependencies = [ "getrandom", ] +[[package]] +name = "raw-window-handle" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41" +dependencies = [ + "cty", +] + +[[package]] +name = "raw-window-handle" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + [[package]] name = "redox_syscall" version = "0.2.16" @@ -1721,6 +2136,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.5.1" @@ -1737,7 +2161,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", - "libredox", + "libredox 0.1.3", "thiserror", ] @@ -1831,6 +2255,15 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scan_fmt" version = "0.2.6" @@ -1849,6 +2282,19 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "sctk-adwaita" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7de61fa7334ee8ee1f5c3c58dcc414fb9361e7e8f5bff9d45f4d69eeb89a7169" +dependencies = [ + "ab_glyph", + "log", + "memmap2 0.9.4", + "smithay-client-toolkit", + "tiny-skia", +] + [[package]] name = "semver" version = "1.0.23" @@ -1921,12 +2367,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -1958,7 +2398,7 @@ source = "git+https://github.com/colinmarc/smithay.git#d176935e3223bea6ae4894621 dependencies = [ "appendlist", "bitflags 2.5.0", - "calloop", + "calloop 0.13.0", "cgmath", "cursor-icon", "downcast-rs", @@ -1990,6 +2430,40 @@ dependencies = [ "xkbcommon", ] +[[package]] +name = "smithay-client-toolkit" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a" +dependencies = [ + "bitflags 2.5.0", + "calloop 0.12.4", + "calloop-wayland-source", + "cursor-icon", + "libc", + "log", + "memmap2 0.9.4", + "rustix", + "thiserror", + "wayland-backend", + "wayland-client", + "wayland-csd-frame", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", +] + +[[package]] +name = "smol_str" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" +dependencies = [ + "serde", +] + [[package]] name = "socket2" version = "0.5.7" @@ -2069,7 +2543,7 @@ dependencies = [ "smithay", "stardust-xr", "stardust-xr-server-codegen", - "stereokit", + "stereokit-rust", "tokio", "toml", "tracing", @@ -2093,32 +2567,30 @@ dependencies = [ ] [[package]] -name = "stereokit" -version = "0.16.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e814a6b795ce9f02126e95a04ce5a5e80a07179e334da2e1545258799388e2" +name = "stereokit-rust" +version = "0.1.0" +source = "git+https://github.com/mvvvv/StereoKit-rust.git#348e8a458e0b329464fa292ec3635d3eaabd21d7" dependencies = [ - "bitflags 1.3.2", - "concat-idents", + "android_logger", + "bitflags 2.5.0", + "cmake", "glam", + "jni", + "log", + "macros", + "ndk", "ndk-context", - "num_enum 0.6.1", - "serde", - "serde_repr", - "stereokit-sys", + "ndk-sys", + "openxr-sys", "thiserror", + "winit", ] [[package]] -name = "stereokit-sys" -version = "2.5.6" +name = "strict-num" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ebf7419a56e4a6b1c361e8a7219172ad795ef4fc70e59136dc5ed2c4df4a78" -dependencies = [ - "bindgen", - "cmake", - "glam", -] +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" [[package]] name = "strsim" @@ -2196,6 +2668,31 @@ dependencies = [ "once_cell", ] +[[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", + "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 = "tokio" version = "1.37.0" @@ -2463,6 +2960,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "ttf-parser" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c591d83f69777866b9126b24c6dd9a18351f177e49d625920d19f989fd31cf8" + [[package]] name = "unicode-ident" version = "1.0.12" @@ -2493,6 +2996,22 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -2508,6 +3027,72 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.66", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + [[package]] name = "wayland-backend" version = "0.3.3" @@ -2522,6 +3107,40 @@ dependencies = [ "wayland-sys", ] +[[package]] +name = "wayland-client" +version = "0.31.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82fb96ee935c2cea6668ccb470fb7771f6215d1691746c2d896b447a00ad3f1f" +dependencies = [ + "bitflags 2.5.0", + "rustix", + "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.5.0", + "cursor-icon", + "wayland-backend", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71ce5fa868dd13d11a0d04c5e2e65726d0897be8de247c0c5a65886e283231ba" +dependencies = [ + "rustix", + "wayland-client", + "xcursor", +] + [[package]] name = "wayland-protocols" version = "0.31.2" @@ -2530,6 +3149,7 @@ checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" dependencies = [ "bitflags 2.5.0", "wayland-backend", + "wayland-client", "wayland-scanner", "wayland-server", ] @@ -2547,6 +3167,19 @@ dependencies = [ "wayland-server", ] +[[package]] +name = "wayland-protocols-plasma" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" +dependencies = [ + "bitflags 2.5.0", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + [[package]] name = "wayland-protocols-wlr" version = "0.2.0" @@ -2555,6 +3188,7 @@ checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" dependencies = [ "bitflags 2.5.0", "wayland-backend", + "wayland-client", "wayland-protocols", "wayland-scanner", "wayland-server", @@ -2593,19 +3227,28 @@ checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" dependencies = [ "dlib", "log", + "once_cell", "pkg-config", ] [[package]] -name = "which" -version = "4.4.2" +name = "web-sys" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ - "either", - "home", - "once_cell", - "rustix", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", ] [[package]] @@ -2624,6 +3267,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -2659,6 +3311,15 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -2677,6 +3338,21 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -2708,6 +3384,12 @@ dependencies = [ "windows_x86_64_msvc 0.52.5", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -2720,6 +3402,12 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -2732,6 +3420,12 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -2750,6 +3444,12 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -2762,6 +3462,12 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -2774,6 +3480,12 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -2786,6 +3498,12 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -2798,6 +3516,56 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +[[package]] +name = "winit" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea9e6d5d66cbf702e0dd820302144f51b69a95acdc495dd98ca280ff206562b1" +dependencies = [ + "ahash", + "android-activity", + "atomic-waker", + "bitflags 2.5.0", + "bytemuck", + "calloop 0.12.4", + "cfg_aliases 0.2.1", + "concurrent-queue", + "core-foundation", + "core-graphics", + "cursor-icon", + "dpi", + "js-sys", + "libc", + "memmap2 0.9.4", + "ndk", + "objc2", + "objc2-app-kit", + "objc2-foundation", + "orbclient", + "percent-encoding", + "pin-project", + "raw-window-handle 0.6.2", + "redox_syscall 0.4.1", + "rustix", + "sctk-adwaita", + "smithay-client-toolkit", + "smol_str", + "tracing", + "unicode-segmentation", + "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-plasma", + "web-sys", + "web-time", + "windows-sys 0.52.0", + "x11-dl", + "x11rb", + "xkbcommon-dl", +] + [[package]] name = "winnow" version = "0.5.40" @@ -2816,13 +3584,28 @@ dependencies = [ "memchr", ] +[[package]] +name = "x11-dl" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +dependencies = [ + "libc", + "once_cell", + "pkg-config", +] + [[package]] name = "x11rb" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d91ffca73ee7f68ce055750bf9f6eca0780b8c85eff9bc046a3b0da41755e12" dependencies = [ + "as-raw-xcb-connection", "gethostname", + "libc", + "libloading", + "once_cell", "rustix", "x11rb-protocol", ] @@ -2833,6 +3616,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d" +[[package]] +name = "xcursor" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a0ccd7b4a5345edfcd0c3535718a4e9ff7798ffc536bb5b5a0e26ff84732911" + [[package]] name = "xkbcommon" version = "0.7.0" @@ -2840,7 +3629,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13867d259930edc7091a6c41b4ce6eee464328c6ff9659b7e4c668ca20d4c91e" dependencies = [ "libc", - "memmap2", + "memmap2 0.8.0", + "xkeysym", +] + +[[package]] +name = "xkbcommon-dl" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" +dependencies = [ + "bitflags 2.5.0", + "dlib", + "log", + "once_cell", "xkeysym", ] @@ -2855,3 +3657,23 @@ name = "xml-rs" version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" + +[[package]] +name = "zerocopy" +version = "0.7.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] diff --git a/Cargo.toml b/Cargo.toml index 74f15c1..834228c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ lto = true [dependencies] color-eyre = { version = "0.6.2", default-features = false } clap = { version = "4.2.4", features = ["derive"] } -glam = { version = "0.23.0", features = ["mint"] } +glam = { version = "0.27.0", features = ["mint", "serde"] } lazy_static = "1.4.0" mint = "0.5.9" nanoid = "0.4.0" @@ -84,13 +84,10 @@ features = [ "renderer_gl", "wayland_frontend", ] -version = "*" optional = true -[dependencies.stereokit] -default-features = false -features = ["linux-egl"] -version = "0.16.9" +[dependencies.stereokit-rust] +git = "https://github.com/mvvvv/StereoKit-rust.git" [dependencies.console-subscriber] version = "0.2.0" diff --git a/src/main.rs b/src/main.rs index b6bead9..02e1da7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,11 +26,15 @@ use std::path::{Path, PathBuf}; use std::process::{Child, Command, Stdio}; use std::sync::Arc; use std::time::Duration; -use stereokit::{ - named_colors::BLACK, DepthMode, DisplayMode, Handed, LogLevel, StereoKitMultiThread, - TextureFormat, TextureType, +use stereokit_rust::material::Material; +use stereokit_rust::shader::Shader; +use stereokit_rust::sk::{ + sk_quit, AppMode, DepthMode, DisplayBlend, DisplayMode, QuitReason, SkClosures, SkSettings, }; -use stereokit::{DisplayBlend, Sk}; +use stereokit_rust::system::{Handed, LogLevel, Renderer, World}; +use stereokit_rust::tex::{SHCubemap, Tex, TexFormat, TexType}; +use stereokit_rust::ui::Ui; +use stereokit_rust::util::{Color128, Device, Time}; use tokio::sync::Notify; use tokio::task::LocalSet; use tokio::{runtime::Handle, sync::oneshot}; @@ -63,7 +67,6 @@ struct CliArgs { } static STARDUST_INSTANCE: OnceCell = OnceCell::new(); -static SK_MULTITHREAD: OnceCell = OnceCell::new(); static STOP_NOTIFIER: Notify = Notify::const_new(); struct EventLoopInfo { @@ -102,16 +105,16 @@ fn main() { } let cli_args = Arc::new(CliArgs::parse()); - let sk = stereokit::Settings { - app_name: "Stardust XR".to_string(), - display_preference: if cli_args.flatscreen { - DisplayMode::Flatscreen + let (sk, sk_event_loop) = SkSettings::default() + .app_name("Stardust XR") + .mode(if cli_args.flatscreen { + AppMode::Simulator } else { - DisplayMode::MixedReality - }, - blend_preference: DisplayBlend::AnyTransparent, - depth_mode: DepthMode::D32, - log_filter: match EnvFilter::from_default_env().max_level_hint() { + AppMode::XR + }) + .blend_preference(DisplayBlend::AnyTransparent) + .depth_mode(DepthMode::D32) + .log_filter(match EnvFilter::from_default_env().max_level_hint() { Some(LevelFilter::ERROR) => LogLevel::Error, Some(LevelFilter::WARN) => LogLevel::Warning, Some(LevelFilter::INFO) => LogLevel::Inform, @@ -119,46 +122,35 @@ fn main() { Some(LevelFilter::TRACE) => LogLevel::Diagnostic, Some(LevelFilter::OFF) => LogLevel::None, None => LogLevel::Warning, - }, - overlay_app: cli_args.overlay_priority.is_some(), - overlay_priority: cli_args.overlay_priority.unwrap_or(u32::MAX), - disable_desktop_input_window: true, - render_scaling: 2.0, - ..Default::default() - } - .init() - .expect("StereoKit failed to initialize"); - let _ = SK_MULTITHREAD.set(sk.multithreaded()); + }) + .overlay_app(cli_args.overlay_priority.is_some()) + .overlay_priority(cli_args.overlay_priority.unwrap_or(u32::MAX)) + .disable_desktop_input_window(true) + .render_scaling(2.0) + .init() + .expect("StereoKit failed to initialize"); info!("Init StereoKit"); - sk.render_set_multisample(0); - - sk.material_set_shader( - sk.material_find("default/material_pbr").unwrap(), - sk.shader_find("default/shader_pbr_clip").unwrap(), - ); + Renderer::multisample(0); + Material::default().shader(Shader::pbr_clip()); + Ui::enable_far_interact(false); // Skytex/light stuff { - if let Some((light, tex)) = project_dirs + if let Some(sky) = project_dirs .as_ref() - .and_then(|dirs| { - let skytex_path = dirs.config_dir().join("skytex.hdr"); - skytex_path - .exists() - .then(|| sk.tex_create_cubemap_file(&skytex_path, true, 100).ok()) - }) - .flatten() + .map(|dirs| dirs.config_dir().join("skytex.hdr")) + .filter(|f| f.exists()) + .and_then(|p| SHCubemap::from_cubemap_equirectangular(p, true, 100).ok()) { - sk.render_set_skytex(&tex); - sk.render_set_skylight(light); + sky.render_as_sky(); } else { - sk.render_set_skytex(sk.tex_gen_color( - BLACK, + Renderer::skytex(Tex::gen_color( + Color128::BLACK, 1, 1, - TextureType::CUBEMAP, - TextureFormat::RGBA32, + TexType::Cubemap, + TexFormat::RGBA32, )); } } @@ -170,33 +162,25 @@ fn main() { .unwrap(); let mut hands = (!cli_args.flatscreen) .then(|| { - let left = SkHand::new(Handed::Left, &sk).ok(); - let right = SkHand::new(Handed::Right, &sk).ok(); + let left = SkHand::new(Handed::Left).ok(); + let right = SkHand::new(Handed::Right).ok(); left.zip(right) }) .flatten(); let mut controllers = (!cli_args.flatscreen && !cli_args.disable_controller) .then(|| { - let left = SkController::new(&sk, Handed::Left).ok(); - let right = SkController::new(&sk, Handed::Right).ok(); + let left = SkController::new(Handed::Left).ok(); + let right = SkController::new(Handed::Right).ok(); left.zip(right) }) .flatten(); - let eye_pointer = (sk.active_display_mode() == DisplayMode::MixedReality - && sk.device_has_eye_gaze()) + let eye_pointer = (sk.get_active_display_mode() == DisplayMode::MixedReality + && Device::has_eye_gaze()) .then(EyePointer::new) .transpose() .unwrap(); - if hands.is_none() { - sk.input_hand_visible(Handed::Left, false); - sk.input_hand_visible(Handed::Right, false); - } - - let play_space = sk - .world_has_bounds() - .then(|| PlaySpace::new().ok()) - .flatten(); + let play_space = World::has_bounds().then(|| PlaySpace::new().ok()).flatten(); let (info_sender, info_receiver) = oneshot::channel::(); let event_thread = std::thread::Builder::new() @@ -229,47 +213,48 @@ fn main() { let mut last_frame_delta = Duration::ZERO; let mut sleep_duration = Duration::ZERO; debug_span!("StereoKit").in_scope(|| { - sk.run( - |sk| { + SkClosures::run_app( + sk, + sk_event_loop, + |_sk, token| { let _span = debug_span!("StereoKit step"); let _span = _span.enter(); - hmd::frame(sk); - camera::update(sk); + hmd::frame(); + camera::update(token); #[cfg(feature = "wayland")] - wayland.frame_event(sk); + wayland.frame_event(); destroy_queue::clear(); if let Some(mouse_pointer) = &mut mouse_pointer { - mouse_pointer.update(sk); + mouse_pointer.update(); } if let Some((left_hand, right_hand)) = &mut hands { - left_hand.update(!cli_args.disable_controller, sk); - right_hand.update(!cli_args.disable_controller, sk); + left_hand.update(!cli_args.disable_controller, token); + right_hand.update(!cli_args.disable_controller, token); } if let Some((left_controller, right_controller)) = &mut controllers { - left_controller.update(sk); - right_controller.update(sk); + left_controller.update(token); + right_controller.update(token); } if let Some(eye_pointer) = &eye_pointer { - eye_pointer.update(sk); + eye_pointer.update(); } if let Some(play_space) = &play_space { - play_space.update(sk); + play_space.update(); } input::process_input(); - nodes::root::Root::send_frame_events(sk.time_elapsed_unscaled()); + nodes::root::Root::send_frame_events(Time::get_step_unscaled()); adaptive_sleep( - sk, &mut last_frame_delta, &mut sleep_duration, Duration::from_micros(250), ); #[cfg(feature = "wayland")] - wayland.update(sk); - drawable::draw(sk); - audio::update(sk); + wayland.update(); + drawable::draw(token); + audio::update(); #[cfg(feature = "wayland")] wayland.make_context_current(); }, @@ -295,12 +280,11 @@ fn main() { } fn adaptive_sleep( - sk: &impl StereoKitMultiThread, last_frame_delta: &mut Duration, sleep_duration: &mut Duration, sleep_duration_increase: Duration, ) { - let frame_delta = Duration::from_secs_f64(sk.time_elapsed_unscaled()); + let frame_delta = Duration::from_secs_f64(Time::get_step_unscaled()); if *last_frame_delta < frame_delta { if let Some(frame_delta_delta) = frame_delta.checked_sub(*last_frame_delta) { if let Some(new_sleep_duration) = sleep_duration.checked_sub(frame_delta_delta) { @@ -346,7 +330,7 @@ async fn event_loop( info!("Cleanly shut down event loop"); unsafe { - stereokit::sys::sk_quit(); + sk_quit(QuitReason::SystemClose); } Ok(()) diff --git a/src/nodes/audio.rs b/src/nodes/audio.rs index 8d017a7..cb71d19 100644 --- a/src/nodes/audio.rs +++ b/src/nodes/audio.rs @@ -15,7 +15,7 @@ use stardust_xr::values::ResourceID; use std::ops::DerefMut; use std::sync::Arc; use std::{ffi::OsStr, path::PathBuf}; -use stereokit::{Sound as SkSound, SoundInstance, StereoKitDraw}; +use stereokit_rust::sound::{Sound as SkSound, SoundInst}; static SOUND_REGISTRY: Registry = Registry::new(); @@ -26,7 +26,7 @@ pub struct Sound { volume: f32, pending_audio_path: PathBuf, sk_sound: OnceCell>, - instance: Mutex>, + instance: Mutex>, stop: Mutex>, play: Mutex>, } @@ -53,24 +53,21 @@ impl Sound { Ok(sound_arc) } - fn update(&self, sk: &impl StereoKitDraw) { + fn update(&self) { let sound = self.sk_sound.get_or_init(|| { - SendWrapper::new(sk.sound_create(self.pending_audio_path.clone()).unwrap()) + SendWrapper::new(SkSound::from_file(self.pending_audio_path.clone()).unwrap()) }); if self.stop.lock().take().is_some() { if let Some(instance) = self.instance.lock().take() { - sk.sound_inst_stop(instance); + instance.stop(); } } if self.instance.lock().is_none() && self.play.lock().take().is_some() { - self.instance.lock().replace(sk.sound_play( - sound.as_ref(), - vec3(0.0, 0.0, 0.0), - self.volume, - )); + let instance = sound.play(vec3(0.0, 0.0, 0.0), Some(self.volume)); + self.instance.lock().replace(instance); } if let Some(instance) = self.instance.lock().deref_mut() { - sk.sound_inst_set_pos(*instance, self.space.global_transform().w_axis.xyz()); + instance.position(self.space.global_transform().w_axis.xyz()); } } } @@ -98,9 +95,9 @@ impl Drop for Sound { } } -pub fn update(sk: &impl StereoKitDraw) { +pub fn update() { for sound in SOUND_REGISTRY.get_valid_contents() { - sound.update(sk) + sound.update() } } diff --git a/src/nodes/drawable/assets/shaders/shader_unlit_gamma.hlsl.sks b/src/nodes/drawable/assets/shaders/shader_unlit_gamma.hlsl.sks new file mode 100644 index 0000000..a38499d Binary files /dev/null and b/src/nodes/drawable/assets/shaders/shader_unlit_gamma.hlsl.sks differ diff --git a/src/nodes/drawable/assets/shaders/shader_unlit_simula.hlsl.sks b/src/nodes/drawable/assets/shaders/shader_unlit_simula.hlsl.sks new file mode 100644 index 0000000..707dfed Binary files /dev/null and b/src/nodes/drawable/assets/shaders/shader_unlit_simula.hlsl.sks differ diff --git a/src/nodes/drawable/lines.rs b/src/nodes/drawable/lines.rs index 38a7196..33b5a32 100644 --- a/src/nodes/drawable/lines.rs +++ b/src/nodes/drawable/lines.rs @@ -4,12 +4,14 @@ use crate::{ nodes::{spatial::Spatial, Aspect, Node}, }; use color_eyre::eyre::Result; -use glam::Vec3A; +use glam::Vec3; use parking_lot::Mutex; use portable_atomic::{AtomicBool, Ordering}; use prisma::Lerp; use std::{collections::VecDeque, sync::Arc}; -use stereokit::{bounds_grow_to_fit_pt, Bounds, Color128, LinePoint as SkLinePoint, StereoKitDraw}; +use stereokit_rust::{ + maths::Bounds, sk::MainThreadToken, system::LinePoint as SkLinePoint, util::Color128, +}; static LINES_REGISTRY: Registry = Registry::new(); @@ -29,7 +31,7 @@ impl Lines { if let Ok(lines) = node.get_aspect::() { for line in &*lines.data.lock() { for point in &line.points { - bounds = bounds_grow_to_fit_pt(bounds, point.point); + bounds.grown_point(Vec3::from(point.point)); } } } @@ -47,7 +49,7 @@ impl Lines { Ok(lines) } - fn draw(&self, draw_ctx: &impl StereoKitDraw) { + fn draw(&self, token: &MainThreadToken) { let transform_mat = self.space.global_transform(); let data = self.data.lock().clone(); for line in &data { @@ -55,15 +57,9 @@ impl Lines { .points .iter() .map(|p| SkLinePoint { - pt: transform_mat.transform_point3a(Vec3A::from(p.point)).into(), + pt: transform_mat.transform_point3(Vec3::from(p.point)).into(), thickness: p.thickness, - color: stereokit::sys::color128::from([ - p.color.c.r, - p.color.c.g, - p.color.c.b, - p.color.a, - ]) - .into(), + color: Color128::new(p.color.c.r, p.color.c.g, p.color.c.b, p.color.a).into(), }) .collect(); if line.cyclic && !points.is_empty() { @@ -78,9 +74,7 @@ impl Lines { }; let connect_point = SkLinePoint { pt: transform_mat - .transform_point3a( - Vec3A::from(first.point).lerp(Vec3A::from(last.point), 0.5), - ) + .transform_point3(Vec3::from(first.point).lerp(Vec3::from(last.point), 0.5)) .into(), thickness: (first.thickness + last.thickness) * 0.5, color: color.into(), @@ -88,7 +82,7 @@ impl Lines { points.push_front(connect_point.clone()); points.push_back(connect_point); } - draw_ctx.line_add_listv(points.make_contiguous()); + stereokit_rust::system::Lines::add_list(token, points.make_contiguous()); } } } @@ -108,10 +102,10 @@ impl Drop for Lines { } } -pub fn draw_all(draw_ctx: &impl StereoKitDraw) { +pub fn draw_all(token: &MainThreadToken) { for lines in LINES_REGISTRY.get_valid_contents() { if lines.enabled.load(Ordering::Relaxed) { - lines.draw(draw_ctx); + lines.draw(token); } } } diff --git a/src/nodes/drawable/mod.rs b/src/nodes/drawable/mod.rs index 1f9a4d7..b9ae802 100644 --- a/src/nodes/drawable/mod.rs +++ b/src/nodes/drawable/mod.rs @@ -16,22 +16,22 @@ use color_eyre::eyre::{self, Result}; use parking_lot::Mutex; use stardust_xr::values::ResourceID; use std::{ffi::OsStr, path::PathBuf, sync::Arc}; -use stereokit::StereoKitDraw; +use stereokit_rust::{sk::MainThreadToken, system::Renderer, tex::SHCubemap}; // #[instrument(level = "debug", skip(sk))] -pub fn draw(sk: &impl StereoKitDraw) { - lines::draw_all(sk); - model::draw_all(sk); - text::draw_all(sk); +pub fn draw(token: &MainThreadToken) { + lines::draw_all(token); + model::draw_all(token); + text::draw_all(token); if let Some(skytex) = QUEUED_SKYTEX.lock().take() { - if let Ok((_skylight, skytex)) = sk.tex_create_cubemap_file(&skytex, true, i32::MAX) { - sk.render_set_skytex(&skytex); + if let Ok(skytex) = SHCubemap::from_cubemap_equirectangular(&skytex, true, 100) { + Renderer::skytex(skytex.tex); } } if let Some(skylight) = QUEUED_SKYLIGHT.lock().take() { - if let Ok((skylight, _)) = sk.tex_create_cubemap_file(&skylight, true, i32::MAX) { - sk.render_set_skylight(skylight); + if let Ok(skylight) = SHCubemap::from_cubemap_equirectangular(&skylight, true, 100) { + Renderer::skylight(skylight.sh); } } } diff --git a/src/nodes/drawable/model.rs b/src/nodes/drawable/model.rs index 855e377..cec4313 100644 --- a/src/nodes/drawable/model.rs +++ b/src/nodes/drawable/model.rs @@ -1,61 +1,54 @@ use super::{MaterialParameter, ModelAspect, ModelPartAspect, Node}; use crate::core::client::Client; -use crate::core::destroy_queue; use crate::core::node_collections::LifeLinkedNodeMap; use crate::core::registry::Registry; use crate::core::resource::get_resource_file; use crate::nodes::spatial::Spatial; use crate::nodes::Aspect; -use crate::SK_MULTITHREAD; use color_eyre::eyre::{eyre, Result}; +use glam::{Mat4, Vec2, Vec3}; use once_cell::sync::OnceCell; use parking_lot::Mutex; use portable_atomic::{AtomicBool, Ordering}; use rustc_hash::FxHashMap; +use send_wrapper::SendWrapper; use stardust_xr::values::ResourceID; +use stereokit_rust::material::Transparency; +use stereokit_rust::maths::Bounds; +use stereokit_rust::sk::MainThreadToken; +use stereokit_rust::{material::Material, model::Model as SKModel, tex::Tex, util::Color128}; use std::ffi::OsStr; use std::path::PathBuf; use std::sync::{Arc, Weak}; -use stereokit::named_colors::WHITE; -use stereokit::{ - Bounds, Color128, Material, Model as SKModel, RenderLayer, Shader, StereoKitDraw, - StereoKitMultiThread, Transparency, -}; static MODEL_REGISTRY: Registry = Registry::new(); -static HOLDOUT_MATERIAL: OnceCell> = OnceCell::new(); +static HOLDOUT_MATERIAL: OnceCell>> = OnceCell::new(); impl MaterialParameter { - fn apply_to_material( - &self, - client: &Client, - sk: &impl StereoKitMultiThread, - material: &Material, - parameter_name: &str, - ) { + fn apply_to_material(&self, client: &Client, material: &Material, parameter_name: &str) { + let mut params = material.get_all_param_info(); match self { MaterialParameter::Bool(val) => { - sk.material_set_bool(material, parameter_name, *val); + params.set_bool(parameter_name, *val); } MaterialParameter::Int(val) => { - sk.material_set_int(material, parameter_name, *val); + params.set_int(parameter_name, &[*val]); } MaterialParameter::UInt(val) => { - sk.material_set_uint(material, parameter_name, *val); + params.set_uint(parameter_name, &[*val]); } MaterialParameter::Float(val) => { - sk.material_set_float(material, parameter_name, *val); + params.set_float(parameter_name, *val); } MaterialParameter::Vec2(val) => { - sk.material_set_vector2(material, parameter_name, *val); + params.set_vec2(parameter_name, Vec2::from(*val)); } MaterialParameter::Vec3(val) => { - sk.material_set_vector3(material, parameter_name, *val); + params.set_vec3(parameter_name, Vec3::from(*val)); } MaterialParameter::Color(val) => { - sk.material_set_color( - material, + params.set_color( parameter_name, Color128::new(val.c.r, val.c.g, val.c.b, val.a), ); @@ -66,8 +59,8 @@ impl MaterialParameter { else { return; }; - if let Ok(tex) = sk.tex_create_file(texture_path, true, 0) { - sk.material_set_texture(material, parameter_name, &tex); + if let Ok(tex) = Tex::from_file(texture_path, true, None) { + params.set_texture(parameter_name, &tex); } } } @@ -80,57 +73,27 @@ pub struct ModelPart { space: Arc, model: Weak, pending_material_parameters: Mutex>, - pending_material_replacement: Mutex>>, + pending_material_replacement: Mutex>>>, } impl ModelPart { - fn create_for_model(sk: &impl StereoKitMultiThread, model: &Arc, sk_model: &SKModel) { + fn create_for_model(model: &Arc, sk_model: &SKModel) { HOLDOUT_MATERIAL.get_or_init(|| { - let mat = sk.material_copy(Material::UNLIT); - sk.material_set_transparency(&mat, Transparency::None); - sk.material_set_color( - &mat, - "color", - stereokit::sys::color128 { - r: 0.0, - g: 0.0, - b: 0.0, - a: 0.0, - }, - ); - Arc::new(mat) + let mut mat = Material::copy(Material::unlit()); + mat.transparency(Transparency::None); + mat.color_tint(Color128::BLACK_TRANSPARENT); + Arc::new(SendWrapper::new(mat)) }); - let first_root_part = sk.model_node_get_root(sk_model); - let mut current_option_part = Some(first_root_part); - - while let Some(current_part) = &mut current_option_part { - ModelPart::create(sk, model, sk_model, *current_part); - - if let Some(child) = sk.model_node_child(sk_model, *current_part) { - *current_part = child; - } else if let Some(sibling) = sk.model_node_sibling(sk_model, *current_part) { - *current_part = sibling; - } else { - while let Some(current_part) = &mut current_option_part { - if let Some(sibling) = sk.model_node_sibling(sk_model, *current_part) { - *current_part = sibling; - break; - } - current_option_part = sk.model_node_parent(sk_model, *current_part); - } - } + let nodes = sk_model.get_nodes(); + for part in nodes.all() { + ModelPart::create(model, &part); } } - fn create( - sk: &impl StereoKitMultiThread, - model: &Arc, - sk_model: &SKModel, - id: i32, - ) -> Option> { - let parent_node = sk - .model_node_parent(sk_model, id) - .and_then(|id| model.parts.get(&id)); + fn create(model: &Arc, part: &stereokit_rust::model::ModelNode) -> Option> { + let parent_node = part + .get_parent() + .and_then(|part| model.parts.get(part.get_id())); let parent_part = parent_node .as_ref() .and_then(|node| node.get_aspect::().ok()); @@ -138,7 +101,8 @@ impl ModelPart { let stardust_model_part = model.space.node()?; let client = stardust_model_part.get_client()?; let mut part_path = parent_part.map(|n| n.path.clone()).unwrap_or_default(); - part_path.push(sk.model_node_get_name(sk_model, id)?); + part_path.push(part.get_name().unwrap()); + let node = client.scenegraph.add_node(Node::create_parent_name( &client, stardust_model_part.get_path(), @@ -148,10 +112,12 @@ impl ModelPart { let spatial_parent = parent_node .and_then(|n| n.get_aspect::().ok()) .unwrap_or_else(|| model.space.clone()); + + let local_transform = unsafe { part.get_local_transform().m }; let space = Spatial::add_to( &node, Some(spatial_parent), - sk.model_node_get_transform_local(sk_model, id), + Mat4::from_cols_array(&local_transform), false, ); @@ -163,23 +129,24 @@ impl ModelPart { let Ok(model_part) = node.get_aspect::() else { return Bounds::default(); }; - let Some(sk) = SK_MULTITHREAD.get() else { - return Bounds::default(); - }; let Some(model) = model_part.model.upgrade() else { return Bounds::default(); }; let Some(sk_model) = model.sk_model.get() else { return Bounds::default(); }; - let Some(sk_mesh) = sk.model_node_get_mesh(sk_model, model_part.id) else { + let nodes = sk_model.get_nodes(); + let Some(model_node) = nodes.get_index(model_part.id) else { return Bounds::default(); }; - sk.mesh_get_bounds(sk_mesh) + let Some(sk_mesh) = model_node.get_mesh() else { + return Bounds::default(); + }; + sk_mesh.get_bounds() }); let model_part = Arc::new(ModelPart { - id, + id: *part.get_id(), path: part_path, space, model: Arc::downgrade(model), @@ -188,17 +155,31 @@ impl ModelPart { }); ::add_node_members(&node); node.add_aspect_raw(model_part.clone()); - model.parts.add(id, &node); + model.parts.add(*part.get_id(), &node); Some(model_part) } - pub fn replace_material(&self, replacement: Arc) { + pub fn replace_material(&self, replacement: Arc>) { self.pending_material_replacement .lock() .replace(replacement); } + /// only to be run on the main thread + pub fn replace_material_now(&self, replacement: &Material) { + let Some(model) = self.model.upgrade() else { + return; + }; + let Some(sk_model) = model.sk_model.get() else { + return; + }; + let nodes = sk_model.get_nodes(); + let Some(mut part) = nodes.get_index(self.id) else { + return; + }; + part.material(replacement); + } - fn update(&self, sk: &impl StereoKitDraw) { + fn update(&self) { let Some(model) = self.model.upgrade() else { return; }; @@ -208,28 +189,37 @@ impl ModelPart { let Some(node) = model.space.node() else { return; }; + let nodes = sk_model.get_nodes(); + let Some(mut part) = nodes.get_index(self.id) else { + return; + }; + part.model_transform(Spatial::space_to_space_matrix( + Some(&self.space), + Some(&model.space), + )); + let Some(client) = node.get_client() else { return; }; + if let Some(material_replacement) = self.pending_material_replacement.lock().take() { - sk.model_node_set_material(sk_model, self.id, material_replacement.as_ref().as_ref()); + part.material(&**material_replacement); } - let mut material_parameters = self.pending_material_parameters.lock(); - for (parameter_name, parameter_value) in material_parameters.drain() { - let Some(material) = sk.model_node_get_material(sk_model, self.id) else { - continue; - }; - let new_material = sk.material_copy(material); - parameter_value.apply_to_material(&client, sk, &new_material, parameter_name.as_str()); - sk.model_node_set_material(sk_model, self.id, &new_material); + // todo: find all materials with identical parameters and batch them into 1 material again + 'mat_params: { + let mut material_parameters = self.pending_material_parameters.lock(); + if !material_parameters.is_empty() { + let Some(material) = part.get_material() else { + break 'mat_params; + }; + let new_material = Material::copy(&material); + part.material(&new_material); + for (parameter_name, parameter_value) in material_parameters.drain() { + parameter_value.apply_to_material(&client, &new_material, ¶meter_name); + } + } } - - sk.model_node_set_transform_model( - sk_model, - self.id, - Spatial::space_to_space_matrix(Some(&self.space), Some(&model.space)), - ); } } impl Aspect for ModelPart { @@ -261,15 +251,12 @@ impl ModelPartAspect for ModelPart { } pub struct Model { - self_ref: Weak, enabled: Arc, space: Arc, _resource_id: ResourceID, sk_model: OnceCell, parts: LifeLinkedNodeMap, } -unsafe impl Send for Model {} -unsafe impl Sync for Model {} impl Model { pub fn add_to(node: &Arc, resource_id: ResourceID) -> Result> { @@ -280,8 +267,7 @@ impl Model { ) .ok_or_else(|| eyre!("Resource not found"))?; - let model = Arc::new_cyclic(|self_ref| Model { - self_ref: self_ref.clone(), + let model = Arc::new(Model { enabled: node.enabled.clone(), space: node.get_aspect::().unwrap().clone(), _resource_id: resource_id, @@ -290,51 +276,50 @@ impl Model { }); MODEL_REGISTRY.add_raw(&model); - let sk = SK_MULTITHREAD.get().unwrap(); - let sk_model = sk.model_copy( - sk.model_create_file(pending_model_path.to_str().unwrap(), None::)?, - ); - ModelPart::create_for_model(sk, &model.self_ref.upgrade().unwrap(), &sk_model); + // technically doing this in anything but the main thread isn't a good idea but dangit we need those model nodes ASAP + let sk_model = SKModel::copy(SKModel::from_file( + pending_model_path.to_str().unwrap(), + None, + )?); + ModelPart::create_for_model(&model, &sk_model); let _ = model.sk_model.set(sk_model); node.add_aspect_raw(model.clone()); Ok(model) } - fn draw(&self, sk: &impl StereoKitDraw) { + fn draw(&self, token: &MainThreadToken) { let Some(sk_model) = self.sk_model.get() else { return; }; for model_node_node in self.parts.nodes() { if let Ok(model_node) = model_node_node.get_aspect::() { - model_node.update(sk); + model_node.update(); }; } - sk.model_draw( - sk_model, - self.space.global_transform(), - WHITE, - RenderLayer::LAYER0, - ); + if self.enabled.load(Ordering::Relaxed) { + sk_model.draw(token, self.space.global_transform(), None, None); + } } } +// TODO: proper hread safety in stereokit_rust (probably just bind stereokit directly) +unsafe impl Send for Model {} +unsafe impl Sync for Model {} impl Aspect for Model { const NAME: &'static str = "Model"; } impl ModelAspect for Model {} impl Drop for Model { fn drop(&mut self) { - if let Some(sk_model) = self.sk_model.take() { - destroy_queue::add(sk_model); - } + // if let Some(sk_model) = self.sk_model.take() { + // destroy_queue::add(sk_model); + // } MODEL_REGISTRY.remove(self); } } -pub fn draw_all(sk: &impl StereoKitDraw) { +pub fn draw_all(token: &MainThreadToken) { for model in MODEL_REGISTRY.get_valid_contents() { - if model.enabled.load(Ordering::Relaxed) { - model.draw(sk); - } + model.draw(token); } } diff --git a/src/nodes/drawable/shaders/mod.rs b/src/nodes/drawable/shaders.rs similarity index 93% rename from src/nodes/drawable/shaders/mod.rs rename to src/nodes/drawable/shaders.rs index 016884a..db89bd3 100644 --- a/src/nodes/drawable/shaders/mod.rs +++ b/src/nodes/drawable/shaders.rs @@ -4,14 +4,14 @@ use smithay::backend::renderer::gles::{ GlesError, }; use std::mem::transmute; -use stereokit::Shader; +use stereokit_rust::shader::Shader; use tracing::error; // Simula shader with fancy lanzcos sampling -pub const UNLIT_SHADER_BYTES: &[u8] = include_bytes!("shader_unlit_gamma.sks"); +pub const UNLIT_SHADER_BYTES: &[u8] = include_bytes!("assets/shaders/shader_unlit_gamma.hlsl.sks"); // Simula shader with fancy lanzcos sampling -pub const PANEL_SHADER_BYTES: &[u8] = include_bytes!("shader_unlit_simula.sks"); +pub const PANEL_SHADER_BYTES: &[u8] = include_bytes!("assets/shaders/shader_unlit_simula.hlsl.sks"); struct FfiAssetHeader { asset_type: i32, diff --git a/src/nodes/drawable/shaders/shader_unlit_gamma.sks b/src/nodes/drawable/shaders/shader_unlit_gamma.sks deleted file mode 100644 index 96bec3e..0000000 Binary files a/src/nodes/drawable/shaders/shader_unlit_gamma.sks and /dev/null differ diff --git a/src/nodes/drawable/shaders/shader_unlit_simula.sks b/src/nodes/drawable/shaders/shader_unlit_simula.sks deleted file mode 100644 index 736b617..0000000 Binary files a/src/nodes/drawable/shaders/shader_unlit_simula.sks and /dev/null differ diff --git a/src/nodes/drawable/shaders/shader_unlit_gamma.hlsl b/src/nodes/drawable/shaders_src/shader_unlit_gamma.hlsl similarity index 100% rename from src/nodes/drawable/shaders/shader_unlit_gamma.hlsl rename to src/nodes/drawable/shaders_src/shader_unlit_gamma.hlsl diff --git a/src/nodes/drawable/shaders/shader_unlit_simula.hlsl b/src/nodes/drawable/shaders_src/shader_unlit_simula.hlsl similarity index 100% rename from src/nodes/drawable/shaders/shader_unlit_simula.hlsl rename to src/nodes/drawable/shaders_src/shader_unlit_simula.hlsl diff --git a/src/nodes/drawable/text.rs b/src/nodes/drawable/text.rs index 2b5a64c..d525afd 100644 --- a/src/nodes/drawable/text.rs +++ b/src/nodes/drawable/text.rs @@ -8,8 +8,11 @@ use once_cell::sync::OnceCell; use parking_lot::Mutex; use portable_atomic::{AtomicBool, Ordering}; use std::{ffi::OsStr, path::PathBuf, sync::Arc}; -use stereokit::{ - named_colors::WHITE, Color128, StereoKitDraw, TextAlign, TextFit, TextStyle as SkTextStyle, +use stereokit_rust::{ + font::Font, + sk::MainThreadToken, + system::{TextAlign, TextFit, TextStyle as SkTextStyle}, + util::{Color128, Color32}, }; use super::{TextAspect, TextStyle}; @@ -18,13 +21,13 @@ static TEXT_REGISTRY: Registry = Registry::new(); fn convert_align(x_align: super::XAlign, y_align: super::YAlign) -> TextAlign { match (x_align, y_align) { - (super::XAlign::Left, super::YAlign::Top) => TextAlign::Left, + (super::XAlign::Left, super::YAlign::Top) => TextAlign::TopLeft, (super::XAlign::Left, super::YAlign::Center) => TextAlign::CenterLeft, (super::XAlign::Left, super::YAlign::Bottom) => TextAlign::BottomLeft, (super::XAlign::Center, super::YAlign::Top) => TextAlign::Center, (super::XAlign::Center, super::YAlign::Center) => TextAlign::Center, (super::XAlign::Center, super::YAlign::Bottom) => TextAlign::BottomCenter, - (super::XAlign::Right, super::YAlign::Top) => TextAlign::Right, + (super::XAlign::Right, super::YAlign::Top) => TextAlign::TopRight, (super::XAlign::Right, super::YAlign::Center) => TextAlign::CenterRight, (super::XAlign::Right, super::YAlign::Bottom) => TextAlign::BottomRight, } @@ -59,16 +62,16 @@ impl Text { Ok(text) } - fn draw(&self, sk: &impl StereoKitDraw) { + fn draw(&self, token: &MainThreadToken) { let style = self.style .get_or_try_init(|| -> Result { let font = self .font_path .as_deref() - .and_then(|path| sk.font_create(path).ok()) - .unwrap_or_else(|| sk.font_find("default/font").unwrap()); - Ok(unsafe { sk.text_make_style(font, 1.0, WHITE) }) + .and_then(|path| Font::from_file(path).ok()) + .unwrap_or_default(); + Ok(SkTextStyle::from_font(font, 1.0, Color32::WHITE)) }); if let Ok(style) = style { @@ -81,7 +84,8 @@ impl Text { data.character_height, )); if let Some(bounds) = &data.bounds { - sk.text_add_in( + stereokit_rust::system::Text::add_in( + token, &*text, transform, Vec2::from(bounds.bounds) / data.character_height, @@ -92,21 +96,40 @@ impl Text { super::TextFit::Exact => TextFit::Exact, super::TextFit::Overflow => TextFit::Overflow, }, - *style, - convert_align(bounds.anchor_align_x, bounds.anchor_align_y), - convert_align(data.text_align_x, data.text_align_y), - vec3(0.0, 0.0, 0.0), - Color128::from([data.color.c.r, data.color.c.g, data.color.c.b, data.color.a]), + Some(style.clone()), + Some(Color128::new( + data.color.c.r, + data.color.c.g, + data.color.c.b, + data.color.a, + )), + data.bounds + .as_ref() + .map(|b| convert_align(b.anchor_align_x, b.anchor_align_y)), + Some(convert_align(data.text_align_x, data.text_align_y)), + None, + None, + None, ); } else { - sk.text_add_at( + stereokit_rust::system::Text::add_at( + token, &*text, transform, - *style, - TextAlign::Center, - convert_align(data.text_align_x, data.text_align_y), - vec3(0.0, 0.0, 0.0), - Color128::from([data.color.c.r, data.color.c.g, data.color.c.b, data.color.a]), + Some(*style), + Some(Color128::new( + data.color.c.r, + data.color.c.g, + data.color.c.b, + data.color.a, + )), + data.bounds + .as_ref() + .map(|b| convert_align(b.anchor_align_x, b.anchor_align_y)), + Some(convert_align(data.text_align_x, data.text_align_y)), + None, + None, + None, ); } } @@ -141,10 +164,10 @@ impl Drop for Text { } } -pub fn draw_all(sk: &impl StereoKitDraw) { +pub fn draw_all(token: &MainThreadToken) { for text in TEXT_REGISTRY.get_valid_contents() { if text.enabled.load(Ordering::Relaxed) { - text.draw(sk); + text.draw(token); } } } diff --git a/src/nodes/hmd.rs b/src/nodes/hmd.rs index 7d4f153..c7490e1 100644 --- a/src/nodes/hmd.rs +++ b/src/nodes/hmd.rs @@ -6,7 +6,7 @@ use crate::{ use color_eyre::eyre::Result; use glam::{vec3, Mat4}; use std::sync::Arc; -use stereokit::StereoKitMultiThread; +use stereokit_rust::system::Input; lazy_static::lazy_static! { static ref HMD: Arc = create(); @@ -19,9 +19,9 @@ fn create() -> Arc { node } -pub fn frame(sk: &impl StereoKitMultiThread) { +pub fn frame() { let spatial = HMD.get_aspect::().unwrap(); - let hmd_pose = sk.input_head(); + let hmd_pose = Input::get_head(); *spatial.transform.lock() = Mat4::from_scale_rotation_translation( vec3(1.0, 1.0, 1.0), hmd_pose.orientation.into(), diff --git a/src/nodes/input/method.rs b/src/nodes/input/method.rs index 304b60a..6c45976 100644 --- a/src/nodes/input/method.rs +++ b/src/nodes/input/method.rs @@ -25,6 +25,7 @@ pub struct InputMethod { pub data: Mutex, pub datamap: Mutex, + pub capture_requests: Registry, pub captures: Registry, pub(super) handler_aliases: LifeLinkedNodeMap, pub(super) handler_order: Mutex>>, @@ -41,6 +42,7 @@ impl InputMethod { enabled: Mutex::new(true), spatial: node.get_aspect::().unwrap().clone(), data: Mutex::new(data), + capture_requests: Registry::new(), captures: Registry::new(), datamap: Mutex::new(datamap), handler_aliases: LifeLinkedNodeMap::default(), @@ -166,9 +168,7 @@ impl InputMethodRefAspect for InputMethod { let input_method = node.get_aspect::()?; let input_handler = handler.get_aspect::()?; - input_method.captures.add_raw(&input_handler); - // input_method_client:: - // node.send_remote_signal("capture", message) + input_method.capture_requests.add_raw(&input_handler); Ok(()) } } diff --git a/src/nodes/input/mod.rs b/src/nodes/input/mod.rs index f91f2a6..93eac5c 100644 --- a/src/nodes/input/mod.rs +++ b/src/nodes/input/mod.rs @@ -154,7 +154,6 @@ pub fn process_input() { .collect() }); - method.captures.clear(); // Iterate over the distance links and send input to them for (i, input_link) in input_links.into_iter().enumerate() { if let Some(method_alias) = input_link @@ -165,8 +164,13 @@ pub fn process_input() { { method_alias.enabled.store(true, Ordering::Release); } - input_link.send_input(i as u32, true, method.datamap.lock().clone()); + input_link.send_input( + i as u32, + method.captures.contains(&input_link.handler), + method.datamap.lock().clone(), + ); } + method.capture_requests.clear(); }); } } diff --git a/src/nodes/items/camera.rs b/src/nodes/items/camera.rs index 5a6f4bb..5399721 100644 --- a/src/nodes/items/camera.rs +++ b/src/nodes/items/camera.rs @@ -19,12 +19,19 @@ use mint::{RowMatrix4, Vector2}; use nanoid::nanoid; use once_cell::sync::OnceCell; use parking_lot::Mutex; +use send_wrapper::SendWrapper; use serde::Deserialize; use stardust_xr::schemas::flex::{deserialize, serialize}; use std::sync::Arc; -use stereokit::{ - Color128, Material, Rect, RenderLayer, StereoKitDraw, Tex, TextureType, Transparency, +use stereokit_rust::{ + material::{Material, Transparency}, + shader::Shader, + sk::MainThreadToken, + system::Renderer, + tex::{Tex, TexFormat, TexType}, + util::Color128, }; +use tracing::error; lazy_static! { pub(super) static ref ITEM_TYPE_INFO_CAMERA: TypeInfo = TypeInfo { @@ -46,8 +53,8 @@ struct FrameInfo { pub struct CameraItem { space: Arc, frame_info: Mutex, - sk_tex: OnceCell, - sk_mat: OnceCell>, + sk_tex: OnceCell>, + sk_mat: OnceCell>>, applied_to: Registry, apply_to: Registry, } @@ -111,52 +118,54 @@ impl CameraItem { Ok(serialize(id)?.into()) } - pub fn update(&self, sk: &impl StereoKitDraw) { + pub fn update(&self, token: &MainThreadToken) { let frame_info = self.frame_info.lock(); let sk_tex = self.sk_tex.get_or_init(|| { - sk.tex_gen_color( + SendWrapper::new(Tex::gen_color( Color128::default(), frame_info.px_size.x as i32, frame_info.px_size.y as i32, - TextureType::RENDER_TARGET, - stereokit::TextureFormat::RGBA32Linear, - ) - }); - let sk_mat = self.sk_mat.get_or_init(|| { - let shader = sk.shader_create_mem(&UNLIT_SHADER_BYTES).unwrap(); - let mat = sk.material_create(&shader); - sk.material_set_texture(&mat, "diffuse", sk_tex.as_ref()); - sk.material_set_transparency(&mat, Transparency::Blend); - Arc::new(mat) + TexType::Rendertarget, + TexFormat::RGBA32Linear, + )) }); + let sk_mat = self + .sk_mat + .get_or_try_init(|| -> Result>> { + let shader = Shader::from_memory(&UNLIT_SHADER_BYTES)?; + let mut mat = Material::new(&shader, None); + mat.get_all_param_info().set_texture("diffuse", &**sk_tex); + mat.transparency(Transparency::Blend); + Ok(Arc::new(SendWrapper::new(mat))) + }); + let Ok(sk_mat) = sk_mat else { + error!("unable to make camera item stereokit texture"); + return; + }; for model_part in self.apply_to.take_valid_contents() { model_part.replace_material(sk_mat.clone()) } if !self.applied_to.is_empty() { - sk.render_to( - sk_tex, - frame_info.proj_matrix, + Renderer::render_to( + token, + &**sk_tex, self.space.global_transform(), - RenderLayer::all(), - stereokit::RenderClear::All, - Rect { - x: 0.0, - y: 0.0, - w: 0.0, - h: 0.0, - }, - ); + frame_info.proj_matrix, + None, + None, + None, + ) } } } -pub fn update(sk: &impl StereoKitDraw) { +pub fn update(token: &MainThreadToken) { for camera in ITEM_TYPE_INFO_CAMERA.items.get_valid_contents() { let ItemType::Camera(camera) = &camera.specialization else { continue; }; - camera.update(sk); + camera.update(token); } } diff --git a/src/nodes/spatial/mod.rs b/src/nodes/spatial/mod.rs index 333424c..1cd51ff 100644 --- a/src/nodes/spatial/mod.rs +++ b/src/nodes/spatial/mod.rs @@ -7,7 +7,7 @@ use crate::core::client::Client; use crate::core::registry::Registry; use crate::create_interface; use color_eyre::eyre::{eyre, Result}; -use glam::{vec3a, Mat4, Quat}; +use glam::{vec3a, Mat4, Quat, Vec3}; use mint::Vector3; use nanoid::nanoid; use once_cell::sync::OnceCell; @@ -15,7 +15,7 @@ use parking_lot::Mutex; use std::fmt::Debug; use std::ptr; use std::sync::{Arc, Weak}; -use stereokit::{bounds_grow_to_fit_box, Bounds}; +use stereokit_rust::maths::Bounds; stardust_xr_server_codegen::codegen_spatial_protocol!(); impl Transform { @@ -104,11 +104,7 @@ impl Spatial { .map(|b| (b)(&node)) .unwrap_or_default(); for child in self.children.get_valid_contents() { - bounds = bounds_grow_to_fit_box( - bounds, - child.get_bounding_box(), - Some(child.local_transform()), - ); + bounds.grown_box(child.get_bounding_box(), child.local_transform()); } bounds } @@ -253,8 +249,8 @@ impl SpatialRefAspect for Spatial { let bounds = this_spatial.get_bounding_box(); Ok(BoundingBox { - center: mint::Vector3::from(bounds.center), - size: mint::Vector3::from(bounds.dimensions), + center: Vec3::from(bounds.center).into(), + size: Vec3::from(bounds.dimensions).into(), }) } @@ -267,21 +263,18 @@ impl SpatialRefAspect for Spatial { let relative_spatial = relative_to.get_aspect::()?; let center = Spatial::space_to_space_matrix(Some(&this_spatial), Some(&relative_spatial)) .transform_point3([0.0; 3].into()); - let bounds = bounds_grow_to_fit_box( - Bounds { - center, - dimensions: [0.0; 3].into(), - }, + let mut bounds = Bounds { + center: center.into(), + dimensions: [0.0; 3].into(), + }; + bounds.grown_box( this_spatial.get_bounding_box(), - Some(Spatial::space_to_space_matrix( - Some(&this_spatial), - Some(&relative_spatial), - )), + Spatial::space_to_space_matrix(Some(&this_spatial), Some(&relative_spatial)), ); Ok(BoundingBox { - center: mint::Vector3::from(bounds.center), - size: mint::Vector3::from(bounds.dimensions), + center: Vec3::from(bounds.center).into(), + size: Vec3::from(bounds.dimensions).into(), }) } diff --git a/src/objects/input/eye_pointer.rs b/src/objects/input/eye_pointer.rs index cec98e5..e3db7ca 100644 --- a/src/objects/input/eye_pointer.rs +++ b/src/objects/input/eye_pointer.rs @@ -13,7 +13,7 @@ use nanoid::nanoid; use serde::{Deserialize, Serialize}; use stardust_xr::values::Datamap; use std::sync::Arc; -use stereokit::StereoKitMultiThread; +use stereokit_rust::system::Input; #[derive(Default, Deserialize, Serialize)] pub struct EyeDatamap { @@ -46,13 +46,11 @@ impl EyePointer { Ok(EyePointer { spatial, pointer }) } - pub fn update(&self, sk: &impl StereoKitMultiThread) { - let ray = sk.input_eyes(); - self.spatial - .set_local_transform(Mat4::from_rotation_translation( - ray.orientation, - ray.position, - )); + pub fn update(&self) { + let ray = Input::get_eyes(); + self.spatial.set_local_transform( + Mat4::from_rotation_translation(ray.orientation.into(), ray.position.into()).into(), + ); { // Set pointer input datamap *self.pointer.datamap.lock() = Datamap::from_typed(EyeDatamap { eye: 2 }).unwrap(); diff --git a/src/objects/input/mouse_pointer.rs b/src/objects/input/mouse_pointer.rs index 7259ca3..9aa3e59 100644 --- a/src/objects/input/mouse_pointer.rs +++ b/src/objects/input/mouse_pointer.rs @@ -11,24 +11,38 @@ use crate::{ }, }; use color_eyre::eyre::Result; -use glam::{vec2, vec3, Mat4, Vec2, Vec3}; +use glam::{vec3, Mat4, Vec3}; +use mint::Vector2; use nanoid::nanoid; use serde::{Deserialize, Serialize}; use stardust_xr::values::Datamap; -use std::{convert::TryFrom, sync::Arc}; -use stereokit::{ray_from_mouse, ButtonState, Key, StereoKitMultiThread}; +use std::sync::Arc; +use stereokit_rust::system::{Input, Key}; use xkbcommon::xkb::{Context, Keymap, FORMAT_TEXT_V1}; -#[derive(Default, Deserialize, Serialize)] +#[derive(Deserialize, Serialize)] struct MouseEvent { select: f32, middle: f32, context: f32, grab: f32, - scroll_continuous: Vec2, - scroll_discrete: Vec2, + scroll_continuous: Vector2, + scroll_discrete: Vector2, raw_input_events: Vec, } +impl Default for MouseEvent { + fn default() -> Self { + MouseEvent { + select: 0.0, + middle: 0.0, + context: 0.0, + grab: 0.0, + scroll_continuous: [0.0; 2].into(), + scroll_discrete: [0.0; 2].into(), + raw_input_events: vec![], + } + } +} #[derive(Debug, Clone, Deserialize, Serialize)] pub struct KeyboardEvent { @@ -91,53 +105,48 @@ impl MousePointer { keyboard_sender, }) } - pub fn update(&mut self, sk: &impl StereoKitMultiThread) { - let mouse = sk.input_mouse(); + pub fn update(&mut self) { + let mouse = Input::get_mouse(); - let ray = ray_from_mouse(mouse.pos).unwrap(); + let ray = mouse.get_ray(); self.spatial.set_local_transform( Mat4::look_to_rh( - Vec3::from(ray.pos), - Vec3::from(ray.dir), + Vec3::from(ray.position), + Vec3::from(ray.direction), vec3(0.0, 1.0, 0.0), ) .inverse(), ); { // Set pointer input datamap - self.mouse_datamap.select = - if sk.input_key(Key::MouseLeft).contains(ButtonState::ACTIVE) { - 1.0f32 - } else { - 0.0f32 - }; - self.mouse_datamap.middle = - if sk.input_key(Key::MouseCenter).contains(ButtonState::ACTIVE) { - 1.0f32 - } else { - 0.0f32 - }; - self.mouse_datamap.context = - if sk.input_key(Key::MouseRight).contains(ButtonState::ACTIVE) { - 1.0f32 - } else { - 0.0f32 - }; - self.mouse_datamap.grab = if sk.input_key(Key::MouseBack).contains(ButtonState::ACTIVE) - || sk - .input_key(Key::MouseForward) - .contains(ButtonState::ACTIVE) + self.mouse_datamap.select = if Input::key(Key::MouseLeft).is_active() { + 1.0f32 + } else { + 0.0f32 + }; + self.mouse_datamap.middle = if Input::key(Key::MouseCenter).is_active() { + 1.0f32 + } else { + 0.0f32 + }; + self.mouse_datamap.context = if Input::key(Key::MouseRight).is_active() { + 1.0f32 + } else { + 0.0f32 + }; + self.mouse_datamap.grab = if Input::key(Key::MouseBack).is_active() + || Input::key(Key::MouseForward).is_active() { 1.0f32 } else { 0.0f32 }; - self.mouse_datamap.scroll_continuous = vec2(0.0, mouse.scroll_change / 120.0); - self.mouse_datamap.scroll_discrete = vec2(0.0, mouse.scroll_change / 120.0); + self.mouse_datamap.scroll_continuous = [0.0, mouse.scroll_change / 120.0].into(); + self.mouse_datamap.scroll_discrete = [0.0, mouse.scroll_change / 120.0].into(); *self.pointer.datamap.lock() = Datamap::from_typed(&self.mouse_datamap).unwrap(); } self.target_pointer_input(); - self.send_keyboard_input(sk); + self.send_keyboard_input(); } fn target_pointer_input(&mut self) { @@ -145,7 +154,7 @@ impl MousePointer { if let Some(capture) = &self.capture { if !self .pointer - .captures + .capture_requests .get_valid_contents() .contains(&capture) { @@ -156,7 +165,7 @@ impl MousePointer { if self.capture.is_none() { if let Some(new_capture) = self .pointer - .captures + .capture_requests .get_valid_contents() .into_iter() .map(|h| { @@ -183,8 +192,10 @@ impl MousePointer { } // make sure that if something is captured only send input to it + self.pointer.captures.clear(); if let Some(capture) = &self.capture { self.pointer.set_handler_order([capture].into_iter()); + self.pointer.captures.add_raw(capture); return; } @@ -236,7 +247,7 @@ impl MousePointer { ); } - fn send_keyboard_input(&mut self, sk: &impl StereoKitMultiThread) { + fn send_keyboard_input(&mut self) { let rx = PULSE_RECEIVER_REGISTRY .get_valid_contents() .into_iter() @@ -263,12 +274,12 @@ impl MousePointer { if let Some(rx) = rx { let keys = (8_u32..254) - .filter_map(|i| Key::try_from(i).ok()) - .filter_map(|k| Some((map_key(k)?, sk.input_key(k)))) + .map(|i| unsafe { std::mem::transmute(i) }) + .filter_map(|k| Some((map_key(k)?, Input::key(k)))) .filter_map(|(i, k)| { - if k.contains(ButtonState::JUST_ACTIVE) { + if k.is_just_active() { Some(i as i32) - } else if k.contains(ButtonState::JUST_INACTIVE) { + } else if k.is_just_inactive() { Some(-(i as i32)) } else { None diff --git a/src/objects/input/sk_controller.rs b/src/objects/input/sk_controller.rs index 740e809..72e9092 100644 --- a/src/objects/input/sk_controller.rs +++ b/src/objects/input/sk_controller.rs @@ -11,9 +11,10 @@ use glam::{Mat4, Vec2, Vec3}; use serde::{Deserialize, Serialize}; use stardust_xr::values::Datamap; use std::sync::Arc; -use stereokit::{ - named_colors::WHITE, ButtonState, Handed, Model, RenderLayer, StereoKitDraw, - StereoKitMultiThread, +use stereokit_rust::{ + model::Model, + sk::MainThreadToken, + system::{Handed, Input}, }; #[derive(Default, Deserialize, Serialize)] @@ -32,7 +33,7 @@ pub struct SkController { datamap: ControllerDatamap, } impl SkController { - pub fn new(sk: &impl StereoKitMultiThread, handed: Handed) -> Result { + pub fn new(handed: Handed) -> Result { let _node = Node::create_parent_name( &INTERNAL_CLIENT, "", @@ -45,7 +46,7 @@ impl SkController { ) .add_to_scenegraph()?; Spatial::add_to(&_node, None, Mat4::IDENTITY, false); - let model = sk.model_create_mem("cursor.glb", include_bytes!("cursor.glb"), None)?; + let model = Model::from_memory("cursor.glb", include_bytes!("cursor.glb"), None)?; let tip = InputDataType::Tip(Tip::default()); let input = InputMethod::add_to( &_node, @@ -61,30 +62,35 @@ impl SkController { datamap: Default::default(), }) } - pub fn update(&mut self, sk: &impl StereoKitDraw) { - let controller = sk.input_controller(self.handed); - *self.input.enabled.lock() = controller.tracked.contains(ButtonState::ACTIVE); + pub fn update(&mut self, token: &MainThreadToken) { + let controller = Input::controller(self.handed); + *self.input.enabled.lock() = controller.tracked.is_active(); if *self.input.enabled.lock() { let world_transform = Mat4::from_rotation_translation( - controller.aim.orientation, - controller.aim.position, + controller.aim.orientation.into(), + controller.aim.position.into(), ); - sk.model_draw( - &self.model, + self.model.draw( + token, world_transform * Mat4::from_scale(Vec3::ONE * 0.02), - WHITE, - RenderLayer::LAYER0, + None, + None, ); self.input.spatial.set_local_transform(world_transform); } self.datamap.select = controller.trigger; self.datamap.grab = controller.grip; - self.datamap.scroll = controller.stick; + self.datamap.scroll = controller.stick.into(); *self.input.datamap.lock() = Datamap::from_typed(&self.datamap).unwrap(); // remove the capture when it's removed from captures list if let Some(capture) = &self.capture { - if !self.input.captures.get_valid_contents().contains(&capture) { + if !self + .input + .capture_requests + .get_valid_contents() + .contains(&capture) + { self.capture.take(); } } @@ -92,7 +98,7 @@ impl SkController { if self.capture.is_none() { self.capture = self .input - .captures + .capture_requests .get_valid_contents() .into_iter() .map(|handler| { @@ -115,8 +121,10 @@ impl SkController { } // make sure that if something is captured only send input to it + self.input.captures.clear(); if let Some(capture) = &self.capture { self.input.set_handler_order([capture].into_iter()); + self.input.captures.add_raw(capture); return; } diff --git a/src/objects/input/sk_hand.rs b/src/objects/input/sk_hand.rs index da8c389..6da789f 100644 --- a/src/objects/input/sk_hand.rs +++ b/src/objects/input/sk_hand.rs @@ -7,18 +7,20 @@ use crate::nodes::{ Node, }; use color_eyre::eyre::Result; -use glam::Mat4; +use glam::{Mat4, Quat, Vec3}; use nanoid::nanoid; use serde::{Deserialize, Serialize}; use stardust_xr::values::Datamap; use std::f32::INFINITY; use std::sync::Arc; -use stereokit::{ButtonState, Color128, HandJoint, Handed, Material, StereoKitMultiThread}; +use stereokit_rust::sk::MainThreadToken; +use stereokit_rust::system::{HandJoint, Handed, Input, LinePoint, Lines}; +use stereokit_rust::util::Color128; fn convert_joint(joint: HandJoint) -> Joint { Joint { - position: joint.position.into(), - rotation: joint.orientation.into(), + position: Vec3::from(joint.position).into(), + rotation: Quat::from(joint.orientation).into(), radius: joint.radius, distance: 0.0, } @@ -33,13 +35,12 @@ struct HandDatamap { pub struct SkHand { _node: Arc, handed: Handed, - material: Material, input: Arc, capture: Option>, datamap: HandDatamap, } impl SkHand { - pub fn new(handed: Handed, sk: &impl StereoKitMultiThread) -> Result { + pub fn new(handed: Handed) -> Result { let _node = Node::create_parent_name(&INTERNAL_CLIENT, "", &nanoid!(), false) .add_to_scenegraph()?; Spatial::add_to(&_node, None, Mat4::IDENTITY, false); @@ -50,29 +51,21 @@ impl SkHand { let datamap = Datamap::from_typed(HandDatamap::default())?; let input = InputMethod::add_to(&_node, hand, datamap)?; - let material = sk.material_copy(Material::HAND); - unsafe { sk.material_addref(&material); } - sk.input_hand_material(handed, Material(material.0)); + Input::hand_visible(handed, false); Ok(SkHand { _node, handed, - material, input, capture: None, datamap: Default::default(), }) } - pub fn update(&mut self, controller_enabled: bool, sk: &impl StereoKitMultiThread) { - let sk_hand = sk.input_hand(self.handed); + pub fn update(&mut self, controller_enabled: bool, token: &MainThreadToken) { + let sk_hand = Input::hand(self.handed); if let InputDataType::Hand(hand) = &mut *self.input.data.lock() { - let controller_active = controller_enabled - && sk - .input_controller(self.handed) - .tracked - .contains(ButtonState::ACTIVE); - *self.input.enabled.lock() = - !controller_active && sk_hand.tracked_state.contains(ButtonState::ACTIVE); - sk.input_hand_visible(self.handed, *self.input.enabled.lock()); + let controller_active = + controller_enabled && Input::controller(self.handed).is_tracked(); + *self.input.enabled.lock() = !controller_active && sk_hand.tracked.is_active(); if *self.input.enabled.lock() { hand.thumb.tip = convert_joint(sk_hand.fingers[0][4]); hand.thumb.distal = convert_joint(sk_hand.fingers[0][3]); @@ -92,17 +85,27 @@ impl SkHand { finger.metacarpal = convert_joint(sk_finger[0]); } - hand.palm.position = sk_hand.palm.position.into(); - hand.palm.rotation = sk_hand.palm.orientation.into(); + hand.palm.position = Vec3::from(sk_hand.palm.position).into(); + hand.palm.rotation = Quat::from(sk_hand.palm.orientation).into(); hand.palm.radius = (sk_hand.fingers[2][0].radius + sk_hand.fingers[2][1].radius) * 0.5; - hand.wrist.position = sk_hand.wrist.position.into(); - hand.wrist.rotation = sk_hand.wrist.orientation.into(); + hand.wrist.position = Vec3::from(sk_hand.wrist.position).into(); + hand.wrist.rotation = Quat::from(sk_hand.wrist.orientation).into(); hand.wrist.radius = (sk_hand.fingers[0][0].radius + sk_hand.fingers[4][0].radius) * 0.5; hand.elbow = None; + + self.draw( + token, + if self.capture.is_none() { + Color128::new_rgb(1.0, 1.0, 1.0) + } else { + Color128::new_rgb(0.0, 1.0, 0.75) + }, + hand, + ); } } self.datamap.pinch_strength = sk_hand.pinch_activation; @@ -111,16 +114,20 @@ impl SkHand { // remove the capture when it's removed from captures list if let Some(capture) = &self.capture { - if !self.input.captures.get_valid_contents().contains(&capture) { + if !self + .input + .capture_requests + .get_valid_contents() + .contains(&capture) + { self.capture.take(); - sk.material_set_color(&self.material, "color", Color128::new_rgb(1.0, 1.0, 1.0)); } } // add the capture that's the closest if we don't have one if self.capture.is_none() { self.capture = self .input - .captures + .capture_requests .get_valid_contents() .into_iter() .map(|handler| (handler.clone(), self.compare_distance(&handler.field).abs())) @@ -132,14 +139,13 @@ impl SkHand { } }) .map(|(rx, _)| rx); - if self.capture.is_some() { - sk.material_set_color(&self.material, "color", Color128::new_rgb(0.0, 1.0, 0.75)); - } } // make sure that if something is captured only send input to it + self.input.captures.clear(); if let Some(capture) = &self.capture { self.input.set_handler_order([capture].into_iter()); + self.input.captures.add_raw(capture); return; } @@ -183,6 +189,77 @@ impl SkHand { ); } + fn draw(&self, token: &MainThreadToken, color: Color128, hand: &Hand) { + // thumb + Lines::add_list( + token, + &[ + joint_to_line_point(&hand.thumb.tip, color), + joint_to_line_point(&hand.thumb.distal, color), + joint_to_line_point(&hand.thumb.proximal, color), + joint_to_line_point(&hand.thumb.metacarpal, color), + ], + ); + // index + Lines::add_list( + token, + &[ + joint_to_line_point(&hand.index.tip, color), + joint_to_line_point(&hand.index.distal, color), + joint_to_line_point(&hand.index.intermediate, color), + joint_to_line_point(&hand.index.proximal, color), + joint_to_line_point(&hand.index.metacarpal, color), + ], + ); + // middle + Lines::add_list( + token, + &[ + joint_to_line_point(&hand.middle.tip, color), + joint_to_line_point(&hand.middle.distal, color), + joint_to_line_point(&hand.middle.intermediate, color), + joint_to_line_point(&hand.middle.proximal, color), + joint_to_line_point(&hand.middle.metacarpal, color), + ], + ); + // ring + Lines::add_list( + token, + &[ + joint_to_line_point(&hand.ring.tip, color), + joint_to_line_point(&hand.ring.distal, color), + joint_to_line_point(&hand.ring.intermediate, color), + joint_to_line_point(&hand.ring.proximal, color), + joint_to_line_point(&hand.ring.metacarpal, color), + ], + ); + // little + Lines::add_list( + token, + &[ + joint_to_line_point(&hand.little.tip, color), + joint_to_line_point(&hand.little.distal, color), + joint_to_line_point(&hand.little.intermediate, color), + joint_to_line_point(&hand.little.proximal, color), + joint_to_line_point(&hand.little.metacarpal, color), + ], + ); + + // palm + Lines::add_list( + token, + &[ + joint_to_line_point(&hand.wrist, color), + joint_to_line_point(&hand.thumb.metacarpal, color), + joint_to_line_point(&hand.index.metacarpal, color), + joint_to_line_point(&hand.middle.metacarpal, color), + joint_to_line_point(&hand.ring.metacarpal, color), + joint_to_line_point(&hand.little.metacarpal, color), + joint_to_line_point(&hand.wrist, color), + ], + ); + } + fn compare_distance(&self, field: &Field) -> f32 { let InputDataType::Hand(hand) = &*self.input.data.lock() else { return INFINITY; @@ -199,3 +276,11 @@ impl SkHand { + (ring_tip_distance * 0.15) } } + +fn joint_to_line_point(joint: &Joint, color: Color128) -> LinePoint { + LinePoint { + pt: Vec3::from(joint.position).into(), + thickness: joint.radius * 2.0, + color: color.into(), + } +} diff --git a/src/objects/play_space.rs b/src/objects/play_space.rs index ca7b521..aa69654 100644 --- a/src/objects/play_space.rs +++ b/src/objects/play_space.rs @@ -6,7 +6,7 @@ use mint::Vector2; use nanoid::nanoid; use serde::{Deserialize, Serialize}; use stardust_xr::values::Datamap; -use stereokit::StereoKitMultiThread; +use stereokit_rust::system::World; use crate::{ core::client::INTERNAL_CLIENT, @@ -59,23 +59,14 @@ impl PlaySpace { _pulse_rx: pulse_rx, }) } - pub fn update(&self, sk: &impl StereoKitMultiThread) { - let pose = sk.world_get_bounds_pose(); - self.spatial - .set_local_transform(Mat4::from_rotation_translation( - pose.orientation, - pose.position, - )); + pub fn update(&self) { + let pose = World::get_bounds_pose(); + self.spatial.set_local_transform( + Mat4::from_rotation_translation(pose.orientation.into(), pose.position.into()).into(), + ); let Field::Box(box_field) = self.field.as_ref() else { return; }; - box_field.set_size( - [ - sk.world_get_bounds_size().x, - 0.0, - sk.world_get_bounds_size().y, - ] - .into(), - ); + box_field.set_size([World::get_bounds_size().x, 0.0, World::get_bounds_size().y].into()); } } diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index ff37bf4..dd7ae09 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -24,7 +24,6 @@ use crate::{core::task, wayland::state::ClientState}; use color_eyre::eyre::{ensure, Result}; use once_cell::sync::OnceCell; use parking_lot::Mutex; -use sk::StereoKitDraw; use smithay::backend::allocator::dmabuf::Dmabuf; use smithay::backend::egl::EGLContext; use smithay::backend::renderer::gles::GlesRenderer; @@ -42,7 +41,7 @@ use std::{ os::unix::{net::UnixListener, prelude::FromRawFd}, sync::Arc, }; -use stereokit as sk; +use stereokit_rust::system::{Backend, BackendGraphics}; use tokio::sync::mpsc::UnboundedReceiver; use tokio::{ io::unix::AsyncFd, net::UnixListener as AsyncUnixListener, sync::mpsc, task::JoinHandle, @@ -59,16 +58,15 @@ struct EGLRawHandles { } fn get_sk_egl() -> Result { ensure!( - unsafe { sk::sys::backend_graphics_get() } - == sk::sys::backend_graphics__backend_graphics_opengles_egl, + Backend::graphics() == BackendGraphics::OpenGLESEGL, "StereoKit is not running using EGL!" ); Ok(unsafe { EGLRawHandles { - display: sk::sys::backend_opengl_egl_get_display() as *const c_void, - config: sk::sys::backend_opengl_egl_get_config() as *const c_void, - context: sk::sys::backend_opengl_egl_get_context() as *const c_void, + display: stereokit_rust::system::backend_opengl_egl_get_display() as *const c_void, + config: stereokit_rust::system::backend_opengl_egl_get_config() as *const c_void, + context: stereokit_rust::system::backend_opengl_egl_get_context() as *const c_void, } }) } @@ -196,8 +194,8 @@ impl Wayland { })?) } - #[instrument(level = "debug", name = "Wayland frame", skip(self, sk))] - pub fn update(&mut self, sk: &impl StereoKitDraw) { + #[instrument(level = "debug", name = "Wayland frame", skip(self))] + pub fn update(&mut self) { while let Ok((dmabuf, notifier)) = self.dmabuf_rx.try_recv() { if self.renderer.import_dmabuf(&dmabuf, None).is_err() { if let Some(notifier) = notifier { @@ -206,15 +204,15 @@ impl Wayland { } } for core_surface in CORE_SURFACES.get_valid_contents() { - core_surface.process(sk, &mut self.renderer); + core_surface.process(&mut self.renderer); } self.display.flush_clients(None); } - pub fn frame_event(&self, sk: &impl StereoKitDraw) { + pub fn frame_event(&self) { for core_surface in CORE_SURFACES.get_valid_contents() { - core_surface.frame(sk, self.output.clone()); + core_surface.frame(self.output.clone()); } } diff --git a/src/wayland/surface.rs b/src/wayland/surface.rs index 4d93f47..5552068 100644 --- a/src/wayland/surface.rs +++ b/src/wayland/surface.rs @@ -19,9 +19,11 @@ use smithay::{ wayland::compositor::{self, SurfaceData}, }; use std::{cell::RefCell, ffi::c_void, sync::Arc, time::Duration}; -use stereokit::{ - Material, Shader, StereoKitDraw, Tex, TextureAddress, TextureFormat, TextureSample, - TextureType, Transparency, +use stereokit_rust::{ + material::{Material, Transparency}, + shader::Shader, + tex::{Tex, TexAddress, TexFormat, TexSample, TexType}, + util::Time, }; pub static CORE_SURFACES: Registry = Registry::new(); @@ -40,8 +42,8 @@ pub struct CoreSurface { pub dh: DisplayHandle, pub weak_surface: wayland_server::Weak, mapped_data: Mutex>, - sk_tex: OnceCell, - sk_mat: OnceCell>, + sk_tex: OnceCell>>, + sk_mat: OnceCell>>, material_offset: Mutex>, on_mapped: Mutex>, on_commit: Mutex>, @@ -85,24 +87,28 @@ impl CoreSurface { *self.on_commit.lock() = Box::new(|_| {}); } - pub fn process(&self, sk: &impl StereoKitDraw, renderer: &mut GlesRenderer) { + pub fn process(&self, renderer: &mut GlesRenderer) { let Some(wl_surface) = self.wl_surface() else { return; }; - let sk_tex = self - .sk_tex - .get_or_init(|| sk.tex_create(TextureType::IMAGE_NO_MIPS, TextureFormat::RGBA32)); + let sk_tex = self.sk_tex.get_or_init(|| { + SendWrapper::new(Mutex::new(Tex::new( + TexType::ImageNomips, + TexFormat::RGBA32Linear, + nanoid::nanoid!(), + ))) + }); self.sk_mat.get_or_init(|| { - let shader = sk.shader_create_mem(&PANEL_SHADER_BYTES); + let shader = Shader::from_memory(&PANEL_SHADER_BYTES).unwrap(); // let _ = renderer.with_context(|c| unsafe { // shader_inject(c, &mut shader, SIMULA_VERT_STR, SIMULA_FRAG_STR) // }); - let mat = sk.material_create(shader.as_ref().unwrap_or(Shader::UI.as_ref())); - sk.material_set_texture(&mat, "diffuse", sk_tex.as_ref()); - sk.material_set_transparency(&mat, Transparency::Blend); - Arc::new(mat) + let mut mat = Material::new(shader, None); + mat.diffuse_tex(sk_tex.lock().as_ref()); + mat.transparency(Transparency::Blend); + SendWrapper::new(Mutex::new(mat)) }); // Let smithay handle buffer management (has to be done here as RendererSurfaceStates is not thread safe) @@ -146,22 +152,22 @@ impl CoreSurface { let Some(sk_mat) = self.sk_mat.get() else { return; }; - unsafe { - sk.tex_set_surface( - sk_tex.as_ref(), + sk_tex + .lock() + .set_native_surface( smithay_tex.tex_id() as usize as *mut c_void, - TextureType::IMAGE_NO_MIPS, + TexType::ImageNomips, smithay::backend::renderer::gles::ffi::RGBA8.into(), smithay_tex.width() as i32, smithay_tex.height() as i32, 1, false, - ); - sk.tex_set_sample(sk_tex.as_ref(), TextureSample::Point); - sk.tex_set_address(sk_tex.as_ref(), TextureAddress::Clamp); - } + ) + .sample_mode(TexSample::Point) + .address_mode(TexAddress::Clamp); + if let Some(material_offset) = self.material_offset.lock().delta() { - sk.material_set_queue_offset(sk_mat.as_ref().as_ref(), *material_offset as i32); + sk_mat.lock().queue_offset(*material_offset as i32); } let Some(surface_size) = renderer_surface_state.surface_size() else { @@ -180,7 +186,7 @@ impl CoreSurface { self.apply_surface_materials(); } - pub fn frame(&self, sk: &impl StereoKitDraw, output: Output) { + pub fn frame(&self, output: Output) { let Some(wl_surface) = self.wl_surface() else { return; }; @@ -188,7 +194,7 @@ impl CoreSurface { send_frames_surface_tree( &wl_surface, &output, - Duration::from_secs_f64(sk.time_get()), + Duration::from_secs_f64(Time::get_total_unscaled()), None, |_, _| Some(output.clone()), ); @@ -204,8 +210,9 @@ impl CoreSurface { fn apply_surface_materials(&self) { if let Some(sk_mat) = self.sk_mat.get() { + let sk_mat = sk_mat.lock(); for model_node in self.pending_material_applications.get_valid_contents() { - model_node.replace_material(sk_mat.clone()); + model_node.replace_material_now(sk_mat.as_ref()); } self.pending_material_applications.clear(); }