From 47c1d9513f6e236193385d9bcb0bd023df8b6c24 Mon Sep 17 00:00:00 2001 From: shadow cat Date: Sat, 22 Mar 2025 17:41:13 -0400 Subject: [PATCH] rustgpu!! --- .gitignore | 1 + Cargo.lock | 1216 +++++++++++------ Cargo.toml | 14 +- build.rs | 9 + rust-toolchain.toml | 7 + shader/Cargo.lock | 113 ++ shader/Cargo.toml | 10 + shader/src/compute.rs | 407 ++++++ shader/src/fns.rs | 94 ++ shader/src/lib.rs | 8 + shader/src/render.rs | 24 + src/client/mod.rs | 27 +- src/client/render/mod.rs | 3 +- src/client/render/voxel/ray_oct/layout.rs | 14 +- src/client/render/voxel/ray_oct/mod.rs | 67 +- .../render/voxel/ray_oct/shader/compute.wgsl | 303 ---- .../voxel/ray_oct/shader/compute_single.wgsl | 282 ---- .../render/voxel/ray_oct/shader/render.wgsl | 38 - src/client/render_vulkan/command.rs | 82 -- src/client/render_vulkan/mod.rs | 79 -- src/client/render_vulkan/voxel/mod.rs | 25 - src/common/component/chunk/mod.rs | 2 +- src/main.rs | 1 + src/util/oct_tree.rs | 18 + 24 files changed, 1570 insertions(+), 1274 deletions(-) create mode 100644 build.rs create mode 100644 rust-toolchain.toml create mode 100644 shader/Cargo.lock create mode 100644 shader/Cargo.toml create mode 100644 shader/src/compute.rs create mode 100644 shader/src/fns.rs create mode 100644 shader/src/lib.rs create mode 100644 shader/src/render.rs delete mode 100644 src/client/render/voxel/ray_oct/shader/compute.wgsl delete mode 100644 src/client/render/voxel/ray_oct/shader/compute_single.wgsl delete mode 100644 src/client/render/voxel/ray_oct/shader/render.wgsl delete mode 100644 src/client/render_vulkan/command.rs delete mode 100644 src/client/render_vulkan/mod.rs delete mode 100644 src/client/render_vulkan/voxel/mod.rs diff --git a/.gitignore b/.gitignore index 7fef46d..5425fd8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target +shader/target flamegraph.svg perf.data* diff --git a/Cargo.lock b/Cargo.lock index 30c0fdf..60b3091 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,12 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ab_glyph" -version = "0.2.28" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79faae4620f45232f599d9bc7b290f88247a0834162c4495ab2f02d60004adfb" +checksum = "ec3672c180e71eeaaac3a541fbbc5f5ad4def8b747c595ad30d674e43049f7b0" dependencies = [ "ab_glyph_rasterizer", "owned_ttf_parser", @@ -18,6 +18,12 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "ahash" version = "0.8.11" @@ -25,10 +31,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "getrandom", + "getrandom 0.2.15", "once_cell", "version_check", - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -42,9 +48,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "android-activity" @@ -53,7 +59,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046" dependencies = [ "android-properties", - "bitflags 2.6.0", + "bitflags 2.9.0", "cc", "cesu8", "jni", @@ -91,6 +97,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "ar" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d67af77d68a931ecd5cbd8a3b5987d63a1d1d1278f7f6a60ae33db485cdebb69" + [[package]] name = "arrayref" version = "0.3.9" @@ -109,22 +121,13 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" -[[package]] -name = "ash" -version = "0.37.3+1.3.251" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a" -dependencies = [ - "libloading 0.7.4", -] - [[package]] name = "ash" version = "0.38.0+1.3.281" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" dependencies = [ - "libloading 0.8.5", + "libloading", ] [[package]] @@ -166,9 +169,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bevy_derive" @@ -178,7 +181,7 @@ checksum = "f0e01f8343f391e2d6a63b368b82fb5b252ed43c8713fc87f9a8f2d59407dd00" dependencies = [ "bevy_macro_utils", "quote", - "syn 2.0.77", + "syn 2.0.100", ] [[package]] @@ -210,7 +213,7 @@ dependencies = [ "bevy_macro_utils", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", ] [[package]] @@ -222,7 +225,7 @@ dependencies = [ "proc-macro2", "quote", "rustc-hash 1.1.0", - "syn 2.0.77", + "syn 2.0.100", "toml_edit 0.21.1", ] @@ -256,7 +259,7 @@ dependencies = [ "bevy_macro_utils", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", "uuid", ] @@ -282,8 +285,8 @@ checksum = "5a9f845a985c00e0ee8dc2d8af3f417be925fb52aad4bda5b96e2e58a2b4d2eb" dependencies = [ "ahash", "bevy_utils_proc_macros", - "getrandom", - "hashbrown", + "getrandom 0.2.15", + "hashbrown 0.14.5", "nonmax", "petgraph", "smallvec", @@ -301,7 +304,7 @@ checksum = "bef158627f30503d5c18c20c60b444829f698d343516eeaf6eeee078c9a45163" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", ] [[package]] @@ -327,9 +330,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "block" @@ -359,41 +362,35 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "bytemuck" -version = "1.18.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.7.1" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc8b54b395f2fcfbb3d90c47b01c7f444d94d05bdeb775811dec868ac3bbc26" +checksum = "2ff22c2722516255d1823ce3cc4bc0b154dbc9364be5c905d6baa6eccbbc8774" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", ] -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "bytes" -version = "1.7.1" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "calloop" @@ -401,7 +398,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "log", "polling", "rustix", @@ -423,9 +420,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.19" +version = "1.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800" +checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" dependencies = [ "jobserver", "libc", @@ -516,6 +513,12 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "core-foundation" version = "0.9.4" @@ -557,25 +560,19 @@ dependencies = [ ] [[package]] -name = "crossbeam-queue" -version = "0.3.11" +name = "crc32fast" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ - "crossbeam-utils", + "cfg-if", ] [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "cursor-icon" @@ -592,11 +589,24 @@ version = "22.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdbd1f579714e3c809ebd822c81ef148b1ceaeb3d535352afc73fd0c4c6a0017" dependencies = [ - "bitflags 2.6.0", - "libloading 0.8.5", + "bitflags 2.9.0", + "libloading", "winapi", ] +[[package]] +name = "derive_more" +version = "0.99.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3da29a38df43d6f156149c9b43ded5e018ddff2a855cf2cfd62e8cd7d079c69f" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.100", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -609,14 +619,14 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" dependencies = [ - "libloading 0.8.5", + "libloading", ] [[package]] name = "document-features" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" +checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" dependencies = [ "litrs", ] @@ -637,16 +647,32 @@ dependencies = [ ] [[package]] -name = "equivalent" -version = "1.0.1" +name = "either" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "elsa" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9abf33c656a7256451ebb7d0082c5a471820c31269e49d807c538c252352186e" +dependencies = [ + "indexmap", + "stable_deref_trait", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "erased-serde" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24e2389d65ab4fab27dc2a5de7b191e1f6617d1f1c8855c0dc569c94a4cbb18d" +checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7" dependencies = [ "serde", "typeid", @@ -654,19 +680,19 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "event-listener" -version = "5.3.1" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" dependencies = [ "concurrent-queue", "parking", @@ -675,19 +701,25 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" +checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2" dependencies = [ "event-listener", "pin-project-lite", ] [[package]] -name = "fastrand" -version = "2.1.1" +name = "fallible-iterator" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fixedbitset" @@ -695,6 +727,22 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "foreign-types" version = "0.5.0" @@ -713,7 +761,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", ] [[package]] @@ -724,21 +772,21 @@ checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "2.3.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" +checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" dependencies = [ "fastrand", "futures-core", @@ -766,10 +814,33 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", +] + +[[package]] +name = "gimli" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e1d97fbe9722ba9bbd0c97051c2956e726562b61f86a25a4360398a40edfc9" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + [[package]] name = "gl_generator" version = "0.14.0" @@ -801,9 +872,9 @@ dependencies = [ [[package]] name = "glutin_wgl_sys" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e1951bbd9434a81aa496fe59ccc2235af3820d27b85f9314e279609211e2c" +checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e" dependencies = [ "gl_generator", ] @@ -814,7 +885,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "gpu-alloc-types", ] @@ -824,7 +895,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", ] [[package]] @@ -842,13 +913,13 @@ dependencies = [ [[package]] name = "gpu-descriptor" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c08c1f623a8d0b722b8b99f821eb0ba672a1618f0d3b16ddbee1cedd2dd8557" +checksum = "dcf29e94d6d243368b7a56caa16bc213e4f9f8ed38c4d9557069527b5d5281ca" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "gpu-descriptor-types", - "hashbrown", + "hashbrown 0.15.2", ] [[package]] @@ -857,18 +928,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" dependencies = [ - "bitflags 2.6.0", -] - -[[package]] -name = "half" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" -dependencies = [ - "bytemuck", - "cfg-if", - "crunchy", + "bitflags 2.9.0", ] [[package]] @@ -882,27 +942,30 @@ dependencies = [ "serde", ] +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +dependencies = [ + "foldhash", +] + [[package]] name = "hassle-rs" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "com", "libc", - "libloading 0.8.5", + "libloading", "thiserror", "widestring", "winapi", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "hermit-abi" version = "0.4.0" @@ -926,19 +989,34 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.2", +] + +[[package]] +name = "internal-iterator" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "969ee3fc68ec2e88eb21434ce4d9b7e1600d1ce92ff974560a6c4a304f5124b9" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", ] [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jni" @@ -973,10 +1051,11 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -987,7 +1066,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" dependencies = [ "libc", - "libloading 0.8.5", + "libloading", "pkg-config", ] @@ -997,27 +1076,23 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "libc" -version = "0.2.158" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libloading" -version = "0.7.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if", - "winapi", -] - -[[package]] -name = "libloading" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", "windows-targets 0.52.6", @@ -1025,20 +1100,20 @@ dependencies = [ [[package]] name = "libredox" -version = "0.0.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "libc", - "redox_syscall 0.4.1", + "redox_syscall 0.5.10", ] [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "litrs" @@ -1058,9 +1133,15 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" + +[[package]] +name = "longest-increasing-subsequence" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3bd0dd2cd90571056fdb71f6275fada10131182f84899f4b2a916e565d81d86" [[package]] name = "malloc_buf" @@ -1071,6 +1152,15 @@ dependencies = [ "libc", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "matrixmultiply" version = "0.3.9" @@ -1102,7 +1192,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ecfd3296f8c56b7c1f6fbac3c71cefa9d78ce009850c45000015f206dc7fa21" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "block", "core-graphics-types", "foreign-types", @@ -1111,6 +1201,15 @@ dependencies = [ "paste", ] +[[package]] +name = "miniz_oxide" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" +dependencies = [ + "adler2", +] + [[package]] name = "naga" version = "22.1.0" @@ -1119,12 +1218,13 @@ checksum = "8bd5a652b6faf21496f2cfd88fc49989c8db0825d1f6746b1a71a6ede24a63ad" dependencies = [ "arrayvec", "bit-set", - "bitflags 2.6.0", + "bitflags 2.9.0", "cfg_aliases 0.1.1", "codespan-reporting", "hexf-parse", "indexmap", "log", + "petgraph", "rustc-hash 1.1.0", "spirv", "termcolor", @@ -1134,9 +1234,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.33.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c4b5f057b303842cf3262c27e465f4c303572e7f6b0648f60e16248ac3397f4" +checksum = "26aecdf64b707efd1310e3544d709c5c0ac61c13756046aaaba41be5c4f66a3b" dependencies = [ "approx", "bytemuck", @@ -1157,7 +1257,7 @@ checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", ] [[package]] @@ -1188,12 +1288,12 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "jni-sys", "log", "ndk-sys 0.6.0+11769913", "num_enum", - "raw-window-handle 0.6.2", + "raw-window-handle", "thiserror", ] @@ -1236,6 +1336,25 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51" +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "num-bigint" version = "0.4.6" @@ -1299,10 +1418,10 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", ] [[package]] @@ -1336,7 +1455,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "block2", "libc", "objc2", @@ -1352,7 +1471,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "block2", "objc2", "objc2-core-location", @@ -1376,7 +1495,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "block2", "objc2", "objc2-foundation", @@ -1408,9 +1527,9 @@ dependencies = [ [[package]] name = "objc2-encode" -version = "4.0.3" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7891e71393cd1f227313c9379a26a584ff3d7e6e7159e988851f0934c993f0f8" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" [[package]] name = "objc2-foundation" @@ -1418,7 +1537,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "block2", "dispatch", "libc", @@ -1443,7 +1562,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "block2", "objc2", "objc2-foundation", @@ -1455,7 +1574,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "block2", "objc2", "objc2-foundation", @@ -1478,7 +1597,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "block2", "objc2", "objc2-cloud-kit", @@ -1510,7 +1629,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "block2", "objc2", "objc2-core-location", @@ -1518,25 +1637,46 @@ dependencies = [ ] [[package]] -name = "once_cell" -version = "1.19.0" +name = "object" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "crc32fast", + "flate2", + "hashbrown 0.15.2", + "indexmap", + "memchr", + "ruzstd", + "wasmparser", +] + +[[package]] +name = "once_cell" +version = "1.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" [[package]] name = "orbclient" -version = "0.3.47" +version = "0.3.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166" +checksum = "ba0b26cec2e24f08ed8bb31519a9333140a6599b867dac464bb150bdb796fd43" dependencies = [ "libredox", ] [[package]] -name = "owned_ttf_parser" -version = "0.24.0" +name = "overload" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "490d3a563d3122bf7c911a59b0add9389e5ec0f5f0c3ac6b91ff235a0e6a7f90" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "owned_ttf_parser" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec719bbf3b2a81c109a4e20b1f129b5566b7dce654bc3872f6a05abf82b2c4" dependencies = [ "ttf-parser", ] @@ -1565,7 +1705,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.4", + "redox_syscall 0.5.10", "smallvec", "windows-targets 0.52.6", ] @@ -1594,41 +1734,41 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", ] [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "polling" -version = "3.7.3" +version = "3.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" +checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" dependencies = [ "cfg-if", "concurrent-queue", @@ -1647,11 +1787,11 @@ checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" [[package]] name = "ppv-lite86" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ - "zerocopy", + "zerocopy 0.8.24", ] [[package]] @@ -1662,56 +1802,52 @@ checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" [[package]] name = "proc-macro-crate" -version = "1.3.1" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - -[[package]] -name = "proc-macro-crate" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" -dependencies = [ - "toml_edit 0.22.20", + "toml_edit 0.22.24", ] [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] [[package]] name = "profiling" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" +checksum = "afbdc74edc00b6f6a218ca6a5364d6226a259d4b8ea1af4a0ea063f27e179f4d" [[package]] name = "quick-xml" -version = "0.36.1" +version = "0.37.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc" +checksum = "165859e9e55f79d67b96c5d96f4e88b6f2695a1972849c15a6a3f5c59fc2c003" dependencies = [ "memchr", ] [[package]] name = "quote" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "rand" version = "0.8.5" @@ -1739,20 +1875,20 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.15", ] [[package]] name = "range-alloc" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" +checksum = "c3d6831663a5098ea164f89cff59c6284e95f4e3c76ce9848d4529f5ccca9bde" [[package]] -name = "raw-window-handle" -version = "0.5.2" +name = "raw-string" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" +checksum = "e0501e134c6905fee1f10fed25b0a7e1261bf676cffac9543a7d0730dec01af2" [[package]] name = "raw-window-handle" @@ -1777,41 +1913,56 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.4" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", ] [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.5", ] [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "renderdoc-sys" @@ -1819,6 +1970,22 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" +[[package]] +name = "rspirv" +version = "0.12.0+sdk-1.3.268.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cf3a93856b6e5946537278df0d3075596371b1950ccff012f02b0f7eafec8d" +dependencies = [ + "rustc-hash 1.1.0", + "spirv", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -1827,34 +1994,100 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rustc_codegen_spirv" +version = "0.9.0" +source = "git+https://github.com/Rust-GPU/rust-gpu?rev=9a533a3#9a533a364ac412a50a788361e35998ef85ddf7bd" +dependencies = [ + "ahash", + "ar", + "bytemuck", + "either", + "indexmap", + "itertools", + "lazy_static", + "libc", + "log", + "object", + "regex", + "rspirv", + "rustc-demangle", + "rustc_codegen_spirv-types", + "rustix", + "sanitize-filename", + "smallvec", + "spirt", + "spirv-tools", + "thorin-dwp", + "tracing", + "tracing-subscriber", + "tracing-tree", +] + +[[package]] +name = "rustc_codegen_spirv-types" +version = "0.9.0" +source = "git+https://github.com/Rust-GPU/rust-gpu?rev=9a533a3#9a533a364ac412a50a788361e35998ef85ddf7bd" +dependencies = [ + "rspirv", + "serde", + "serde_json", +] + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "errno", + "itoa", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "once_cell", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + +[[package]] +name = "ruzstd" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad02996bfc73da3e301efe90b1837be9ed8f4a462b6ed410aa35d00381de89f" +dependencies = [ + "twox-hash", ] [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "safe_arch" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3460605018fdc9612bce72735cba0d27efbcd9904780d44c7e3a9948f96148a" +checksum = "96b02de82ddbe1b636e6170c21be622223aea188ef2e139be0a5b219ec215323" dependencies = [ "bytemuck", ] @@ -1868,6 +2101,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "sanitize-filename" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c502bdb638f1396509467cb0580ef3b29aa2a45c5d43e5d84928241280296c" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -1894,30 +2137,36 @@ dependencies = [ ] [[package]] -name = "serde" -version = "1.0.210" +name = "semver" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -1925,6 +2174,15 @@ dependencies = [ "serde", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "1.3.0" @@ -1959,9 +2217,9 @@ dependencies = [ [[package]] name = "simdeez" -version = "2.0.0-dev3" +version = "2.0.0-dev5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f03e3cf4b84e534adb37350c2ad56fb27e58d10eb2fe8daffc26103b8ae39d3f" +checksum = "97e4567daf40a565ebc9058e929445e55eef4d254e3deeb936cd6ef586cc6ba9" dependencies = [ "cfg-if", "paste", @@ -1995,9 +2253,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" dependencies = [ "serde", ] @@ -2008,7 +2266,7 @@ version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "calloop", "calloop-wayland-source", "cursor-icon", @@ -2036,15 +2294,73 @@ dependencies = [ "serde", ] +[[package]] +name = "spirt" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2d5968bd2a36466468aac637b355776f080edfb0c6f769b2b99b9708260c42a" +dependencies = [ + "arrayvec", + "bytemuck", + "derive_more", + "elsa", + "indexmap", + "internal-iterator", + "itertools", + "lazy_static", + "longest-increasing-subsequence", + "rustc-hash 1.1.0", + "serde", + "serde_json", + "smallvec", +] + [[package]] name = "spirv" version = "0.3.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", ] +[[package]] +name = "spirv-builder" +version = "0.9.0" +source = "git+https://github.com/Rust-GPU/rust-gpu?rev=9a533a3#9a533a364ac412a50a788361e35998ef85ddf7bd" +dependencies = [ + "memchr", + "raw-string", + "rustc_codegen_spirv", + "rustc_codegen_spirv-types", + "serde", + "serde_json", +] + +[[package]] +name = "spirv-tools" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcb3b0832881834994b7ec82b709ec5491043ceb4bf8101e27da6b5234b24261" +dependencies = [ + "spirv-tools-sys", +] + +[[package]] +name = "spirv-tools-sys" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e68b55a97aa6856e010a6f2477425875a97873e147bb0232160e73c45bdae7" +dependencies = [ + "cc", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -2070,9 +2386,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -2090,22 +2406,34 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", +] + +[[package]] +name = "thorin-dwp" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "813ba76597db32dc4f6992fd8bf8f394715b88d352fd97401da67dab6283b4c6" +dependencies = [ + "gimli", + "hashbrown 0.14.5", + "object", + "tracing", ] [[package]] @@ -2149,17 +2477,6 @@ version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.21.1" @@ -2173,57 +2490,134 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "toml_datetime", - "winnow 0.6.18", + "winnow 0.7.4", ] [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", + "tracing-attributes", "tracing-core", ] [[package]] -name = "tracing-core" -version = "0.1.32" +name = "tracing-attributes" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704b1aeb7be0d0a84fc9828cae51dab5970fee5088f83d1dd7ee6f6246fc6ff1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +dependencies = [ + "matchers", + "nu-ansi-term 0.46.0", + "once_cell", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "tracing-tree" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b56c62d2c80033cb36fae448730a2f2ef99410fe3ecbffc916681a32f6807dbe" +dependencies = [ + "nu-ansi-term 0.50.1", + "tracing-core", + "tracing-log", + "tracing-subscriber", ] [[package]] name = "ttf-parser" -version = "0.24.1" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be21190ff5d38e8b4a2d3b6a3ae57f612cc39c96e83cedeaf7abc338a8bac4a" +checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" + +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "static_assertions", +] [[package]] name = "typeid" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e13db2e0ccd5e14a544e8a246ba2312cd25223f616442d7f2cb0e3db614236e" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-segmentation" @@ -2233,41 +2627,38 @@ checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "uuid" -version = "1.10.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" dependencies = [ - "getrandom", + "getrandom 0.3.2", "serde", ] +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "vk-parse" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81086c28be67a8759cd80cbb3c8f7b520e0874605fc5eb74d5a1c9c2d1878e79" -dependencies = [ - "xml-rs", -] - [[package]] name = "voxelgame" version = "0.1.0" @@ -2280,56 +2671,14 @@ dependencies = [ "ndarray", "pollster", "rand", - "rustc-hash 2.0.0", + "rustc-hash 2.1.1", "simba 0.8.1", "simdnoise", - "vulkano", + "spirv-builder", "wgpu", "winit", ] -[[package]] -name = "vulkano" -version = "0.34.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f4278f76307b3c388679234b397b4f90de29cdba53873c26b624ed82653d75" -dependencies = [ - "ahash", - "ash 0.37.3+1.3.251", - "bytemuck", - "core-graphics-types", - "crossbeam-queue", - "half", - "heck", - "indexmap", - "libloading 0.8.5", - "objc", - "once_cell", - "parking_lot", - "proc-macro2", - "quote", - "raw-window-handle 0.5.2", - "regex", - "serde", - "serde_json", - "smallvec", - "thread_local", - "vk-parse", - "vulkano-macros", -] - -[[package]] -name = "vulkano-macros" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52be622d364272fd77e298e7f68e8547ae66e7687cb86eb85335412cee7e3965" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "walkdir" version = "2.5.0" @@ -2347,48 +2696,58 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wasm-bindgen" -version = "0.2.93" +name = "wasi" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2396,28 +2755,40 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasmparser" +version = "0.222.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa210fd1788e6b37a1d1930f3389c48e1d6ebd1a013d34fa4b7f9e3e3bf03146" +dependencies = [ + "bitflags 2.9.0", +] [[package]] name = "wayland-backend" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "056535ced7a150d45159d3a8dc30f91a2e2d588ca0b23f70e56033622b8016f6" +checksum = "b7208998eaa3870dad37ec8836979581506e0c5c64c20c9e79e9d2a10d6f47bf" dependencies = [ "cc", "downcast-rs", @@ -2429,11 +2800,11 @@ dependencies = [ [[package]] name = "wayland-client" -version = "0.31.6" +version = "0.31.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3f45d1222915ef1fd2057220c1d9d9624b7654443ea35c3877f7a52bd0a5a2d" +checksum = "c2120de3d33638aaef5b9f4472bff75f07c56379cf76ea320bd3a3d65ecaf73f" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "rustix", "wayland-backend", "wayland-scanner", @@ -2445,16 +2816,16 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "cursor-icon", "wayland-backend", ] [[package]] name = "wayland-cursor" -version = "0.31.6" +version = "0.31.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a94697e66e76c85923b0d28a0c251e8f0666f58fc47d316c0f4da6da75d37cb" +checksum = "a93029cbb6650748881a00e4922b076092a6a08c11e7fbdb923f064b23968c5d" dependencies = [ "rustix", "wayland-client", @@ -2463,11 +2834,11 @@ dependencies = [ [[package]] name = "wayland-protocols" -version = "0.32.4" +version = "0.32.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5755d77ae9040bb872a25026555ce4cb0ae75fd923e90d25fba07d81057de0" +checksum = "0781cf46869b37e36928f7b432273c0995aa8aed9552c556fb18754420541efc" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "wayland-backend", "wayland-client", "wayland-scanner", @@ -2475,11 +2846,11 @@ dependencies = [ [[package]] name = "wayland-protocols-plasma" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0a41a6875e585172495f7a96dfa42ca7e0213868f4f15c313f7c33221a7eff" +checksum = "7ccaacc76703fefd6763022ac565b590fcade92202492381c95b2edfdf7d46b3" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "wayland-backend", "wayland-client", "wayland-protocols", @@ -2488,11 +2859,11 @@ dependencies = [ [[package]] name = "wayland-protocols-wlr" -version = "0.3.4" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dad87b5fd1b1d3ca2f792df8f686a2a11e3fe1077b71096f7a175ab699f89109" +checksum = "248a02e6f595aad796561fa82d25601bd2c8c3b145b1c7453fc8f94c1a58f8b2" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "wayland-backend", "wayland-client", "wayland-protocols", @@ -2501,9 +2872,9 @@ dependencies = [ [[package]] name = "wayland-scanner" -version = "0.31.5" +version = "0.31.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597f2001b2e5fc1121e3d5b9791d3e78f05ba6bfa4641053846248e3a13661c3" +checksum = "896fdafd5d28145fce7958917d69f2fd44469b1d4e861cb5961bcbeebc6d1484" dependencies = [ "proc-macro2", "quick-xml", @@ -2512,9 +2883,9 @@ dependencies = [ [[package]] name = "wayland-sys" -version = "0.31.5" +version = "0.31.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efa8ac0d8e8ed3e3b5c9fc92c7881406a268e11555abe36493efabe649a29e09" +checksum = "dbcebb399c77d5aa9fa5db874806ee7b4eba4e73650948e8f93963f128896615" dependencies = [ "dlib", "log", @@ -2524,9 +2895,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -2566,7 +2937,7 @@ dependencies = [ "naga", "parking_lot", "profiling", - "raw-window-handle 0.6.2", + "raw-window-handle", "smallvec", "static_assertions", "wasm-bindgen", @@ -2585,7 +2956,8 @@ checksum = "0348c840d1051b8e86c3bcd31206080c5e71e5933dabd79be1ce732b0b2f089a" dependencies = [ "arrayvec", "bit-vec", - "bitflags 2.6.0", + "bitflags 2.9.0", + "bytemuck", "cfg_aliases 0.1.1", "document-features", "indexmap", @@ -2594,7 +2966,7 @@ dependencies = [ "once_cell", "parking_lot", "profiling", - "raw-window-handle 0.6.2", + "raw-window-handle", "rustc-hash 1.1.0", "smallvec", "thiserror", @@ -2610,9 +2982,9 @@ checksum = "f6bbf4b4de8b2a83c0401d9e5ae0080a2792055f25859a02bf9be97952bbed4f" dependencies = [ "android_system_properties", "arrayvec", - "ash 0.38.0+1.3.281", + "ash", "bit-set", - "bitflags 2.6.0", + "bitflags 2.9.0", "block", "cfg_aliases 0.1.1", "core-graphics-types", @@ -2626,7 +2998,7 @@ dependencies = [ "js-sys", "khronos-egl", "libc", - "libloading 0.8.5", + "libloading", "log", "metal", "naga", @@ -2636,7 +3008,7 @@ dependencies = [ "parking_lot", "profiling", "range-alloc", - "raw-window-handle 0.6.2", + "raw-window-handle", "renderdoc-sys", "rustc-hash 1.1.0", "smallvec", @@ -2653,16 +3025,16 @@ version = "22.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc9d91f0e2c4b51434dfa6db77846f2793149d8e73f800fa2e41f52b8eac3c5d" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "js-sys", "web-sys", ] [[package]] name = "wide" -version = "0.7.28" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b828f995bf1e9622031f8009f8481a85406ce1f4d4588ff746d872043e855690" +checksum = "41b5576b9a81633f3e8df296ce0063042a73507636cbe956c61133dd7034ab22" dependencies = [ "bytemuck", "safe_arch", @@ -2670,9 +3042,9 @@ dependencies = [ [[package]] name = "widestring" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" +checksum = "dd7cf3379ca1aac9eea11fba24fd7e315d621f8dfe35c8d7d2be8b793726e07d" [[package]] name = "winapi" @@ -2931,14 +3303,14 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winit" -version = "0.30.5" +version = "0.30.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0be9e76a1f1077e04a411f0b989cbd3c93339e1771cb41e71ac4aee95bfd2c67" +checksum = "a809eacf18c8eca8b6635091543f02a5a06ddf3dad846398795460e6e0ae3cc0" dependencies = [ "ahash", "android-activity", "atomic-waker", - "bitflags 2.6.0", + "bitflags 2.9.0", "block2", "bytemuck", "calloop", @@ -2959,7 +3331,7 @@ dependencies = [ "orbclient", "percent-encoding", "pin-project", - "raw-window-handle 0.6.2", + "raw-window-handle", "redox_syscall 0.4.1", "rustix", "sctk-adwaita", @@ -2993,13 +3365,22 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.18" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" dependencies = [ "memchr", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.9.0", +] + [[package]] name = "x11-dl" version = "2.21.0" @@ -3020,7 +3401,7 @@ dependencies = [ "as-raw-xcb-connection", "gethostname", "libc", - "libloading 0.8.5", + "libloading", "once_cell", "rustix", "x11rb-protocol", @@ -3044,7 +3425,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.9.0", "dlib", "log", "once_cell", @@ -3059,9 +3440,9 @@ checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" [[package]] name = "xml-rs" -version = "0.8.22" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4e2e2f7cba5a093896c1e150fbfe177d1883e7448200efb81d40b9d339ef26" +checksum = "c5b940ebc25896e71dd073bad2dbaa2abfe97b0a391415e22ad1326d9c54e3c4" [[package]] name = "zerocopy" @@ -3069,8 +3450,16 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" +dependencies = [ + "zerocopy-derive 0.8.24", ] [[package]] @@ -3081,5 +3470,16 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.100", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", ] diff --git a/Cargo.toml b/Cargo.toml index aa71293..eec4cb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,11 +15,21 @@ ndarray = "0.15.6" pollster = "0.3" rand = "0.8.5" simba = "0.8.1" -wgpu = "22.0.0" +wgpu = { version = "22.0.0", features = ["spirv"] } bevy_ecs = "0.13.2" bevy_derive = "0.13.2" winit = {version="0.30.1", features=["serde"]} block-mesh = "0.2.0" rustc-hash = "2.0.0" -vulkano = "0.34.1" simdnoise = { git = "https://github.com/valadaptive/rust-simd-noise", rev = "965175f" } + +[build-dependencies] +spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "9a533a3" } + +# Compile build-dependencies in release mode with +# the same settings as regular dependencies. +[profile.release.build-override] +opt-level = 3 +codegen-units = 16 +[profile.dev.build-override] +opt-level = 3 diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..b9c0465 --- /dev/null +++ b/build.rs @@ -0,0 +1,9 @@ +use spirv_builder::{Capability, MetadataPrintout, SpirvBuilder}; + +fn main() -> Result<(), Box> { + SpirvBuilder::new("./shader", "spirv-unknown-spv1.5") + .capability(Capability::ImageQuery) + .print_metadata(MetadataPrintout::Full) + .build()?; + Ok(()) +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..551cee7 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,7 @@ +[toolchain] +channel = "nightly-2024-11-22" +components = ["rust-src", "rustc-dev", "llvm-tools"] +# commit_hash = b19329a37cedf2027517ae22c87cf201f93d776e + +# Whenever changing the nightly channel, update the commit hash above, and make +# sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. diff --git a/shader/Cargo.lock b/shader/Cargo.lock new file mode 100644 index 0000000..ebf54ab --- /dev/null +++ b/shader/Cargo.lock @@ -0,0 +1,113 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "glam" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5418c17512bdf42730f9032c74e1ae39afc408745ebb2acf72fbc4691c17945" +dependencies = [ + "libm", +] + +[[package]] +name = "libm" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "proc-macro2" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "shader" +version = "0.1.0" +dependencies = [ + "spirv-std", +] + +[[package]] +name = "spirv-std" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68c3c0972a2df79abe2c8af2fe7f7937a9aa558b6a1f78fc5edf93f4d480d757" +dependencies = [ + "bitflags", + "glam", + "num-traits", + "spirv-std-macros", + "spirv-std-types", +] + +[[package]] +name = "spirv-std-macros" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f776bf9f2897ea7acff15d7753711fdf1693592bd7459a01c394262b1df45c" +dependencies = [ + "proc-macro2", + "quote", + "spirv-std-types", + "syn", +] + +[[package]] +name = "spirv-std-types" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a73417b7d72d95b4995c840dceb4e3b4bcbad4ff7f35df9c1655b6826c18d3a9" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" diff --git a/shader/Cargo.toml b/shader/Cargo.toml new file mode 100644 index 0000000..894070a --- /dev/null +++ b/shader/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "shader" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["dylib"] + +[dependencies] +spirv-std = { version = "0.9" } diff --git a/shader/src/compute.rs b/shader/src/compute.rs new file mode 100644 index 0000000..edb89d1 --- /dev/null +++ b/shader/src/compute.rs @@ -0,0 +1,407 @@ +use core::mem::transmute; + +use super::fns::*; +use spirv_std::glam::{ + vec2, vec3, vec4, Mat3, Mat4, UVec2, UVec3, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles, +}; +use spirv_std::num_traits::{clamp, Pow}; +use spirv_std::{spirv, Image}; + +#[repr(C, align(16))] +#[derive(Copy, Clone)] +pub struct View { + transform: Mat4, + zoom: f32, + chunk_scale: u32, + chunk_dist: u32, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GlobalLight { + dir: Vec3, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct Chunk { + offset: u32, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct PushConstants { + time: u32, +} + +#[spirv(compute(threads(8, 8)))] +pub fn main( + #[spirv(uniform, descriptor_set = 0, binding = 0)] view: &View, + #[spirv(push_constant)] consts: &PushConstants, + #[spirv(storage_buffer, descriptor_set = 0, binding = 1)] chunks: &[Chunk], + #[spirv(storage_buffer, descriptor_set = 0, binding = 2)] voxel_data: &[u32], + #[spirv(storage_buffer, descriptor_set = 0, binding = 3)] global_lights: &[GlobalLight], + #[spirv(descriptor_set = 0, binding = 4)] output: &Image!(2D, format = rgba8, sampled = false), + #[spirv(global_invocation_id)] cell: UVec3, +) { + let view_dim: UVec2 = output.query_size(); + // get position of the pixel; eye at origin, pixel on plane z = 1 + if cell.x >= view_dim.x || cell.y >= view_dim.y { + return; + } + let view_dim_f = view_dim.as_vec2(); + let aspect = view_dim_f.y / view_dim_f.x; + let pixel_pos = (cell.xy().as_vec2() / view_dim_f - vec2(0.5, 0.5)) * vec2(2.0, -2.0 * aspect); + let offset = Vec3::from_array([(1 << (view.chunk_scale - 1)) as f32; 3]); + let pos = view.transform * vec4(pixel_pos.x, pixel_pos.y, 1.0, 1.0) + offset.extend(0.0); + let dir = view.transform * pixel_pos.extend(view.zoom).normalize().extend(0.0); + + let mut color = trace_full( + global_lights, + consts.time, + view, + voxel_data, + chunks, + pos, + dir, + ); + let light_mult = clamp( + (-dir.xyz().dot(global_lights[0].dir) - 0.99) * 200.0, + 0.0, + 1.0, + ); + let sun_color = light_mult * vec3(1.0, 1.0, 1.0); + let sky_bg = vec3(0.3, 0.6, 1.0); + let sky_color = sun_color + sky_bg * (1.0 - light_mult); + color += (sky_color * (1.0 - color.w)).extend(1.0 - color.w); + color.w = 1.0; + unsafe { + output.write(cell.xy(), color); + } +} + +const LEAF_BIT: u32 = 1u32 << 31; +const LEAF_MASK: u32 = !LEAF_BIT; +const MAX_HITS: u32 = 10; + +const FULL_ALPHA: f32 = 0.999; +const EPSILON: f32 = 0.0000000001; +const MAX_ITERS: u32 = 10000; +// NOTE: CANNOT GO HIGHER THAN 23 due to how floating point +// numbers are stored and the bit manipulation used +const MAX_SCALE: u32 = 23; + +fn trace_full( + global_lights: &[GlobalLight], + time: u32, + view: &View, + voxel_data: &[u32], + chunks: &[Chunk], + pos_view: Vec4, + dir_view: Vec4, +) -> Vec4 { + if voxel_data.len() == 1 { + return Vec4::ZERO; + } + let gi = 0; + let chunk = chunks[gi]; + let side_len = 1u32 << view.chunk_scale; + let dimensions = UVec3::from_array([side_len; 3]); + let dim_f = dimensions.as_vec3(); + + let pos_start = pos_view.xyz(); + let mut dir = dir_view.xyz(); + if dir.x == 0.0 { + dir.x = EPSILON; + } + if dir.y == 0.0 { + dir.y = EPSILON; + } + if dir.z == 0.0 { + dir.z = EPSILON; + } + + let dir_if = sign(dir); + let dir_uf = dir_if.max(Vec3::ZERO); + + // find where ray intersects with group + // closest (min) and furthest (max) corners of cube relative to direction + let pos_min = (Vec3::ONE - dir_uf) * dim_f; + let pos_max = dir_uf * dim_f; + // time of intersection; x = td + p, solve for t + let t_min = (pos_min - pos_start) / dir; + let t_max = (pos_max - pos_start) / dir; + // time of entrance and exit of the cube + let t_start = t_min.max_element(); + let t_end = t_max.min_element(); + if t_end < t_start { + return Vec4::ZERO; + } + // axis of intersection + let axis = if t_start == t_min.x { + 0 + } else if t_start == t_min.y { + 1 + } else { + 2 + }; + // time to move entire side length in each direction + let inc_t = (1.0 / dir).abs() * (side_len as f32); + let t = t_start.max(0.0); + + let inv_dir_bits = 7 - vec_to_dir(dir_uf.as_uvec3()); + let corner_adj = t_min - inc_t; + + // calculate normals + let normals = Mat3::from_diagonal(dir_if); + + let result = cast_ray( + voxel_data, + chunk.offset, + t, + axis, + inv_dir_bits, + inc_t, + corner_adj, + ); + + shade_ray( + global_lights, + time, + result, + pos_start, + dir_view.xyz(), + t_end, + normals, + ) +} + +fn shade_ray( + global_lights: &[GlobalLight], + time: u32, + result: RayResult, + pos_start: Vec3, + dir: Vec3, + t_end: f32, + normals: Mat3, +) -> Vec4 { + let hits = result.hits; + + let mut color = Vec4::ZERO; + for i in 0..result.len { + let hit = hits[i]; + let id = hit.id; + let t = hit.t; + let axis = hit.axis; + + let next_t = if i == result.len - 1 { + t_end + } else { + hits[i + 1].t + }; + + let mut pos = pos_start + dir * t; + let val = round(idx_vec(pos, axis)) - (idx_vec(dir, axis) < 0.0) as u32 as f32; + set_idx_vec(&mut pos, axis, val); + let normal = idx_mat(normals, axis); + let vcolor = shade(global_lights, time, id, pos, normal, dir, next_t - t); + color += vcolor * (1.0 - color.w); + if color.w > FULL_ALPHA { + break; + } + } + color +} + +const AMBIENT: f32 = 0.2; +const SPECULAR: f32 = 0.5; + +// returns premultiplied +fn shade( + global_lights: &[GlobalLight], + time: u32, + id: u32, + pos: Vec3, + normal: Vec3, + dir_view: Vec3, + dist: f32, +) -> Vec4 { + let mut color = Vec4::ZERO; + if id == 0 { + return color; + } + let random = randomf(pos.floor()); + let random2 = randomf(pos.floor() + vec3(0.0001, 0.0001, 0.0001)); + match id { + 0 => { + color = Vec4::ZERO; + } + 1 => { + color = (vec3(0.5, 0.5, 0.5 + random * 0.2) * (random2 * 0.4 + 0.8)).extend(1.0); + } + 2 => { + color = (vec3(0.4 + random * 0.2, 0.9, 0.4 + random * 0.2) * (random2 * 0.2 + 0.9)) + .extend(1.0); + } + 3 => { + let fog = (dist / 64.0).min(1.0); + let a = 0.5; + let rand = + (sin(((time as f32) / 2000.0 + random) * core::f32::consts::TAU) + 1.0) / 2.0; + let rgb = vec3(0.5, 0.5, 1.0) * (rand * 0.2 + 0.8); + color = (rgb * (1.0 - fog * a)).extend(a + fog * (1.0 - a)); + } + _ => (), + } + let light_color = Vec3::ONE; + let light_dir = global_lights[0].dir; + + let diffuse = light_dir.dot(normal).max(0.0) * light_color; + let ambient = AMBIENT * light_color; + let spec_val = dir_view + .xyz() + .dot(reflect(-light_dir, normal)) + .max(0.0) + .pow(32.0) + * SPECULAR; + let specular = spec_val * light_color; + let new_color = (ambient + diffuse + specular) * color.xyz(); + let new_a = (color.w + spec_val).min(1.0); + (new_color * new_a).extend(new_a) +} + +fn randomf(pos: Vec3) -> f32 { + fract(sin(pos.dot(vec3(12.9898, 78.233, 25.1279))) * 43758.545) +} + +#[repr(C)] +#[derive(Copy, Clone, Default)] +struct RayHit { + t: f32, + id: u32, + axis: u32, +} + +#[repr(C)] +#[derive(Copy, Clone)] +struct RayResult { + hits: [RayHit; MAX_HITS as usize], + len: usize, +} + +fn vec_to_dir(vec: UVec3) -> u32 { + vec.x * 4 + vec.y * 2 + vec.z +} + +fn cast_ray( + voxel_data: &[u32], + data_offset: u32, + t_start: f32, + axis_start: u32, + inv_dir_bits: u32, + inc_t: Vec3, + corner_adj: Vec3, +) -> RayResult { + let mut hits: [RayHit; MAX_HITS as usize] = Default::default(); + let mut depth = 0; + let mut min_alpha = 0.0; + + let mut t = t_start; + let mut axis = axis_start; + let mut node_start = 0; + let mut scale = MAX_SCALE; + let mut scale_exp2 = 1.0; + let mut parents = [0u32; MAX_SCALE as usize]; + let mut child = inv_dir_bits; + let mut vox_pos = Vec3::ONE; + let mut prev = 0; + + for _ in 0..MAX_ITERS { + let t_corner = vox_pos * inc_t + corner_adj; + let node = voxel_data[(data_offset + node_start + (child ^ inv_dir_bits)) as usize]; + if node >= LEAF_BIT { + // ignore consecutive identical leaves + if node != prev { + let id = node & LEAF_MASK; + hits[depth] = RayHit { t, id, axis }; + min_alpha += min_alpha_for(id) * (1.0 - min_alpha); + depth += 1; + prev = node; + if depth == 10 || min_alpha >= FULL_ALPHA { + break; + } + } + + // move to next time point and determine which axis to move along + let t_next = t_corner + scale_exp2 * inc_t; + t = t_next.min_element(); + axis = if t == t_next.x { + 0 + } else if t == t_next.y { + 1 + } else { + 2 + }; + let move_dir = 4 >> axis; + + // check if need to pop stack + if (child & move_dir) > 0 { + // calculate new scale; first differing bit after adding + let axis_pos = idx_vec(vox_pos, axis); + // AWARE + let differing = axis_pos.to_bits() ^ (axis_pos + scale_exp2).to_bits(); + scale = ((differing as f32).to_bits() >> 23) - 127 - (23 - MAX_SCALE); + scale_exp2 = f32::from_bits((scale + 127 - MAX_SCALE) << 23); + if scale >= MAX_SCALE { + break; + } + + // restore & recalculate parent + let parent_info = parents[scale as usize - 1]; + node_start = parent_info >> 3; + child = parent_info & 7; + let scale_vec = UVec3::from_array([scale + 23 - MAX_SCALE; 3]); + // remove bits lower than current scale + unsafe { + vox_pos = transmute::( + (transmute::(vox_pos) >> scale_vec) << scale_vec, + ); + } + } + // move to next child and voxel position + child += move_dir; + add_idx_vec(&mut vox_pos, axis, scale_exp2); + } else { + // push current node to stack + parents[scale as usize - 1] = (node_start << 3) + child; + scale -= 1; + + // calculate child node vars + scale_exp2 *= 0.5; + child = 0; + let t_center = t_corner + scale_exp2 * inc_t; + if t > t_center.x { + vox_pos.x += scale_exp2; + child |= 4; + } + if t > t_center.y { + vox_pos.y += scale_exp2; + child |= 2; + } + if t > t_center.z { + vox_pos.z += scale_exp2; + child |= 1; + } + node_start = node; + } + } + RayResult { hits, len: depth } +} + +fn min_alpha_for(id: u32) -> f32 { + match id { + 0 => 0.0, + 3 => 0.5, + _ => 1.0, + } +} diff --git a/shader/src/fns.rs b/shader/src/fns.rs new file mode 100644 index 0000000..2ebcf02 --- /dev/null +++ b/shader/src/fns.rs @@ -0,0 +1,94 @@ +#![allow(asm_sub_register)] + +use spirv_std::glam::{vec3, Mat3, Vec3}; + +pub fn sign(vec: Vec3) -> Vec3 { + vec3( + if vec.x > 0.0 { 1.0 } else { -1.0 }, + if vec.y > 0.0 { 1.0 } else { -1.0 }, + if vec.z > 0.0 { 1.0 } else { -1.0 }, + ) +} + +pub fn idx_vec(vec: Vec3, i: u32) -> f32 { + match i { + 0 => vec.x, + 1 => vec.y, + 2 => vec.z, + _ => 0.0, + } +} + +pub fn idx_mat(mat: Mat3, i: u32) -> Vec3 { + match i { + 0 => mat.x_axis, + 1 => mat.y_axis, + 2 => mat.z_axis, + _ => Vec3::ZERO, + } +} + +pub fn add_idx_vec(vec: &mut Vec3, i: u32, v: f32) { + match i { + 0 => vec.x += v, + 1 => vec.y += v, + 2 => vec.z += v, + _ => (), + } +} + +pub fn set_idx_vec(vec: &mut Vec3, i: u32, v: f32) { + match i { + 0 => vec.x = v, + 1 => vec.y = v, + 2 => vec.z = v, + _ => (), + } +} + +macro_rules! ext_import { + () => { + "%glsl = OpExtInstImport \"GLSL.std.450\"" + }; +} + +macro_rules! float_op { + ($name: ident, $id: expr) => { + pub fn $name(x: f32) -> f32 { + let mut res: f32; + unsafe { + core::arch::asm!( + ext_import!(), + "%float = OpTypeFloat 32", + concat!("{res} = OpExtInst %float %glsl ", $id, " {x}"), + x = in(reg) x, + res = out(reg) res, + ); + } + res + } + }; +} + +float_op!(fract, 10); +float_op!(sin, 13); +float_op!(round, 1); + +pub fn reflect(x: Vec3, y: Vec3) -> Vec3 { + let mut o: Vec3 = Default::default(); + unsafe { + core::arch::asm!( + ext_import!(), + "%float = OpTypeFloat 32", + "%vec = OpTypeVector %float 3", + "%x = OpLoad _ {x}", + "%y = OpLoad _ {y}", + "%o = OpExtInst %vec %glsl 71 %x %y", + "OpStore {o} %o", + x = in(reg) &x, + y = in(reg) &y, + o = in(reg) &mut o, + ); + } + o +} diff --git a/shader/src/lib.rs b/shader/src/lib.rs new file mode 100644 index 0000000..3bf5e68 --- /dev/null +++ b/shader/src/lib.rs @@ -0,0 +1,8 @@ +#![no_std] +#![allow(unexpected_cfgs)] +#![feature(asm_experimental_arch)] + +pub mod render; +pub mod compute; +pub mod fns; + diff --git a/shader/src/render.rs b/shader/src/render.rs new file mode 100644 index 0000000..f9d995b --- /dev/null +++ b/shader/src/render.rs @@ -0,0 +1,24 @@ +use spirv_std::glam::{vec2, Vec2, Vec4}; +use spirv_std::{spirv, Image, Sampler}; + +#[spirv(vertex)] +pub fn vs_main( + #[spirv(vertex_index)] vi: u32, + #[spirv(position)] clip_position: &mut Vec4, + tex_pos: &mut Vec2, +) { + let pos = vec2((vi % 2) as f32, (vi / 2) as f32); + *clip_position = (pos * 2.0 - 1.0).extend(0.0).extend(1.0); + *tex_pos = pos; + tex_pos.y = 1.0 - tex_pos.y; +} + +#[spirv(fragment)] +pub fn fs_main( + #[spirv(descriptor_set = 0, binding = 0)] texture: &Image!(2D, type=f32, sampled=true), + #[spirv(descriptor_set = 0, binding = 1)] sampler: &Sampler, + tex_pos: Vec2, + output: &mut Vec4, +) { + *output = texture.sample(*sampler, tex_pos); +} diff --git a/src/client/mod.rs b/src/client/mod.rs index 78bf819..194b74b 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -19,7 +19,8 @@ use system::render::add_grid; use crate::{ common::{ClientMessage, ServerHandle, ServerMessage}, - server::Server, util::timer::Timer, + server::Server, + util::timer::Timer, }; use self::{input::Input, render::Renderer, ClientState}; @@ -47,8 +48,6 @@ pub struct Client<'a> { server: ServerHandle, server_id_map: HashMap, systems: ClientSystems, - frame_target: Instant, - frame_time: Duration, second_target: Instant, the_thing: bool, } @@ -93,8 +92,6 @@ impl Client<'_> { world, server, server_id_map: HashMap::new(), - frame_target: Instant::now(), - frame_time: FRAME_TIME, second_target: Instant::now(), the_thing: false, } @@ -127,16 +124,6 @@ impl Client<'_> { } } - if now >= self.frame_target { - self.frame_target += self.frame_time; - let mut commands = std::mem::take(&mut self.render_commands); - let world_cmds = std::mem::take(&mut self.world.resource_mut::().0); - commands.extend(world_cmds); - self.renderer.handle_commands(commands); - self.renderer.draw(); - self.render_timer.add(self.renderer.timer().duration(0)); - } - if now >= self.second_target { self.second_target += Duration::from_secs(1); let timer = &self.render_timer; @@ -177,7 +164,15 @@ impl Client<'_> { match event { WindowEvent::CloseRequested => self.exit = true, WindowEvent::Resized(size) => self.renderer.resize(size), - // WindowEvent::RedrawRequested => self.renderer.draw(), + WindowEvent::RedrawRequested => { + let mut commands = std::mem::take(&mut self.render_commands); + let world_cmds = std::mem::take(&mut self.world.resource_mut::().0); + commands.extend(world_cmds); + self.renderer.handle_commands(commands); + self.renderer.draw(); + self.render_timer.add(self.renderer.timer().duration(0)); + self.window.request_redraw(); + } WindowEvent::CursorLeft { .. } => { self.input.clear(); } diff --git a/src/client/render/mod.rs b/src/client/render/mod.rs index ee8178a..edf0758 100644 --- a/src/client/render/mod.rs +++ b/src/client/render/mod.rs @@ -53,7 +53,8 @@ impl<'a> Renderer<'a> { required_features: wgpu::Features::PUSH_CONSTANTS | wgpu::Features::TIMESTAMP_QUERY | wgpu::Features::TIMESTAMP_QUERY_INSIDE_ENCODERS - | wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES, + | wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES + | wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES, required_limits: wgpu::Limits { max_storage_buffer_binding_size: buf_size, max_buffer_size: buf_size as u64, diff --git a/src/client/render/voxel/ray_oct/layout.rs b/src/client/render/voxel/ray_oct/layout.rs index 58d6fbd..cc6295b 100644 --- a/src/client/render/voxel/ray_oct/layout.rs +++ b/src/client/render/voxel/ray_oct/layout.rs @@ -105,7 +105,7 @@ impl Layout { binding: 4, visibility: ShaderStages::COMPUTE, ty: wgpu::BindingType::StorageTexture { - access: wgpu::StorageTextureAccess::WriteOnly, + access: wgpu::StorageTextureAccess::ReadWrite, format: texture.format(), view_dimension: wgpu::TextureViewDimension::D2, }, @@ -171,20 +171,20 @@ impl Layout { pub fn render_pipeline( &self, device: &wgpu::Device, - shader: wgpu::ShaderModule, + shader: &wgpu::ShaderModule, ) -> wgpu::RenderPipeline { device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("Voxel Pipeline"), layout: Some(&self.render_pipeline_layout), vertex: wgpu::VertexState { - module: &shader, - entry_point: "vs_main", + module: shader, + entry_point: "render::vs_main", buffers: &[], compilation_options: wgpu::PipelineCompilationOptions::default(), }, fragment: Some(wgpu::FragmentState { - module: &shader, - entry_point: "fs_main", + module: shader, + entry_point: "render::fs_main", targets: &[Some(wgpu::ColorTargetState { format: self.format, blend: Some(wgpu::BlendState::REPLACE), @@ -221,7 +221,7 @@ impl Layout { label: Some("voxel"), layout: Some(&self.compute_pipeline_layout), module: shader, - entry_point: "main", + entry_point: "compute::main", compilation_options: Default::default(), cache: None, }) diff --git a/src/client/render/voxel/ray_oct/mod.rs b/src/client/render/voxel/ray_oct/mod.rs index 303951b..e48709a 100644 --- a/src/client/render/voxel/ray_oct/mod.rs +++ b/src/client/render/voxel/ray_oct/mod.rs @@ -15,7 +15,6 @@ pub use color::*; use layout::Layout; use nalgebra::{Transform3, Translation3, Vector2}; use std::collections::HashMap; -use wgpu::include_wgsl; use {chunk::Chunk, view::View}; pub struct VoxelPipeline { @@ -27,21 +26,27 @@ pub struct VoxelPipeline { id_map: HashMap, } -const RENDER_SHADER: wgpu::ShaderModuleDescriptor<'_> = include_wgsl!("shader/render.wgsl"); -const COMPUTE_SHADER: wgpu::ShaderModuleDescriptor<'_> = include_wgsl!("shader/compute.wgsl"); - impl VoxelPipeline { pub fn new(device: &wgpu::Device, config: &wgpu::SurfaceConfiguration) -> Self { // shaders let layout = Layout::init(device, config); + let shader_source: Vec = include_bytes!(env!("shader.spv")) + .as_chunks::<4>() + .0 + .iter() + .map(|bytes: &[u8; 4]| u32::from_le_bytes(*bytes)) + .collect(); + let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor { + label: Some("shaders"), + source: wgpu::ShaderSource::SpirV(std::borrow::Cow::from(shader_source)), + }); + let render_bind_group = layout.render_bind_group(device); - let shader = device.create_shader_module(RENDER_SHADER); - let render_pipeline = layout.render_pipeline(device, shader); + let render_pipeline = layout.render_pipeline(device, &shader); let compute_bind_group = layout.compute_bind_group(device); - let shader = device.create_shader_module(COMPUTE_SHADER); let compute_pipeline = layout.compute_pipeline(device, &shader); Self { @@ -55,8 +60,9 @@ impl VoxelPipeline { } pub fn reset_shader(&mut self, device: &wgpu::Device) { - let shader = device.create_shader_module(COMPUTE_SHADER); - self.compute_pipeline = self.layout.compute_pipeline(device, &shader); + // let shader = device.create_shader_module(COMPUTE_SHADER); + // self.compute_pipeline = self.layout.compute_pipeline(device, &shader); + println!("removed for now cause of rustgpu!"); } pub fn add_group( @@ -75,27 +81,28 @@ impl VoxelPipeline { } pub fn update_shader(&mut self, device: &wgpu::Device) { - let Ok(shader) = std::fs::read_to_string( - env!("CARGO_MANIFEST_DIR").to_owned() - + "/src/client/render/voxel/ray_oct/shader/compute.wgsl", - ) else { - println!("Failed to reload shader!"); - return; - }; - device.push_error_scope(wgpu::ErrorFilter::Validation); - let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor { - label: Some("Shader"), - source: wgpu::ShaderSource::Wgsl(shader.into()), - }); - if pollster::block_on(device.pop_error_scope()).is_some() { - let comp_info = pollster::block_on(shader.get_compilation_info()); - println!("Failed to compile shaders:"); - for msg in comp_info.messages { - println!("{}", msg.message); - } - } else { - self.compute_pipeline = self.layout.compute_pipeline(device, &shader); - } + // let Ok(shader) = std::fs::read_to_string( + // env!("CARGO_MANIFEST_DIR").to_owned() + // + "/src/client/render/voxel/ray_oct/shader/compute.wgsl", + // ) else { + // println!("Failed to reload shader!"); + // return; + // }; + // device.push_error_scope(wgpu::ErrorFilter::Validation); + // let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor { + // label: Some("Shader"), + // source: wgpu::ShaderSource::Wgsl(shader.into()), + // }); + // if pollster::block_on(device.pop_error_scope()).is_some() { + // let comp_info = pollster::block_on(shader.get_compilation_info()); + // println!("Failed to compile shaders:"); + // for msg in comp_info.messages { + // println!("{}", msg.message); + // } + // } else { + // self.compute_pipeline = self.layout.compute_pipeline(device, &shader); + // } + println!("removed for now cause of rustgpu!"); } pub fn add_chunk( diff --git a/src/client/render/voxel/ray_oct/shader/compute.wgsl b/src/client/render/voxel/ray_oct/shader/compute.wgsl deleted file mode 100644 index e8a88ab..0000000 --- a/src/client/render/voxel/ray_oct/shader/compute.wgsl +++ /dev/null @@ -1,303 +0,0 @@ -@group(0) @binding(0) -var view: View; -@group(0) @binding(1) -var chunks: array; -@group(0) @binding(2) -var voxel_data: array; -@group(0) @binding(3) -var global_lights: array; -@group(0) @binding(4) -var output: texture_storage_2d; - -var time: u32; - -struct GlobalLight { - dir: vec3, -}; - -struct View { - transform: mat4x4, - zoom: f32, - chunk_scale: u32, - chunk_dist: u32, -}; - -struct Chunk { - offset: u32, -}; - -@compute -@workgroup_size(8, 8, 1) -fn main(@builtin(global_invocation_id) cell: vec3) { - let view_dim = textureDimensions(output); - // get position of the pixel; eye at origin, pixel on plane z = 1 - if cell.x >= view_dim.x || cell.y >= view_dim.y { - return; - } - let view_dim_f = vec2(view_dim); - let aspect = view_dim_f.y / view_dim_f.x; - let pixel_pos = vec2( - (vec2(cell.xy) / view_dim_f - vec2(0.5)) * vec2(2.0, -2.0 * aspect) - ); - let offset = vec3(f32(1u << (view.chunk_scale - 1))); - let pos = view.transform * vec4(pixel_pos, 1.0, 1.0) + vec4(offset, 0.0); - let dir = view.transform * vec4(normalize(vec3(pixel_pos, view.zoom)), 0.0); - - var color = trace_full(pos, dir); - let light_mult = clamp((-dot(dir.xyz, global_lights[0].dir) - 0.99) * 200.0, 0.0, 1.0); - let sun_color = light_mult * vec3(1.0, 1.0, 1.0); - let sky_bg = vec3(0.3, 0.6, 1.0); - let sky_color = sun_color + sky_bg * (1.0 - light_mult); - color += vec4(sky_color * (1.0 - color.a), 1.0 - color.a); - color.a = 1.0; - textureStore(output, cell.xy, color); -} - -const LEAF_BIT = 1u << 31u; -const LEAF_MASK = ~LEAF_BIT; -const MAX_HITS = 10; - -const ZERO3F = vec3(0.0); -const ZERO2F = vec2(0.0); -const FULL_ALPHA = 0.999; -const EPSILON = 0.00000000001; -const MAX_ITERS = 10000; -// NOTE: CANNOT GO HIGHER THAN 23 due to how floating point -// numbers are stored and the bit manipulation used -const MAX_SCALE: u32 = 13; -fn trace_full(pos_view: vec4, dir_view: vec4) -> vec4 { - if arrayLength(&voxel_data) == 1 { - return vec4(0.0); - } - let gi = 0; - let chunk = chunks[gi]; - let side_len = 1u << view.chunk_scale; - let dimensions = vec3(side_len); - let dim_f = vec3(dimensions); - - let pos_start = pos_view.xyz; - var dir = dir_view.xyz; - if dir.x == 0 { dir.x = EPSILON; } - if dir.y == 0 { dir.y = EPSILON; } - if dir.z == 0 { dir.z = EPSILON; } - - let dir_if = sign(dir); - let dir_uf = max(dir_if, vec3(0.0)); - - // find where ray intersects with group - // closest (min) and furthest (max) corners of cube relative to direction - let pos_min = (vec3(1.0) - dir_uf) * dim_f; - let pos_max = dir_uf * dim_f; - // time of intersection; x = td + p, solve for t - let t_min = (pos_min - pos_start) / dir; - let t_max = (pos_max - pos_start) / dir; - // time of entrance and exit of the cube - let t_start = max(max(t_min.x, t_min.y), t_min.z); - let t_end = min(min(t_max.x, t_max.y), t_max.z); - if t_end < t_start { return vec4(0.0); } - // axis of intersection - let axis = select(select(2u, 1u, t_start == t_min.y), 0u, t_start == t_min.x); - // time to move entire side length in each direction - let inc_t = abs(1.0 / dir) * f32(side_len); - let t = max(0.0, t_start); - - let inv_dir_bits = 7 - vec_to_dir(vec3(dir_uf)); - let corner_adj = t_min - inc_t; - - // calculate normals - var normals = mat3x3( - vec3(dir_if.x, 0.0, 0.0), - vec3(0.0, dir_if.y, 0.0), - vec3(0.0, 0.0, dir_if.z), - ); - - let result = cast_ray(chunk.offset, t, axis, inv_dir_bits, inc_t, corner_adj); - return shade_ray(result, pos_start, dir_view.xyz, t_end, normals); -} - -fn shade_ray(result: RayResult, pos_start: vec3, dir: vec3, t_end: f32, normals: mat3x3) -> vec4 { - var hits = result.hits; - - var color = vec4(0.0); - for (var i = 0u; i < result.len; i += 1u) { - let hit = hits[i]; - let id = hit.id; - let t = hit.t; - let axis = hit.axis; - - let next_t = select(hits[i + 1].t, t_end, i == result.len - 1); - - var pos = pos_start + dir * t; - pos[axis] = round(pos[axis]) - f32(dir[axis] < 0.0); - let normal = select(select(normals[0], normals[1], axis == 1), normals[2], axis == 2); - let vcolor = shade(id, pos, normal, dir, next_t - t); - color += vcolor * (1.0 - color.a); - if color.a > FULL_ALPHA { break; } - } - return color; -} - -struct RayHit { - t: f32, - id: u32, - axis: u32, -} - -struct RayResult { - hits: array, - len: u32, -} - -fn cast_ray( - data_offset: u32, t_start: f32, axis_start: u32, - inv_dir_bits: u32, inc_t: vec3, corner_adj: vec3 -) -> RayResult { - var hits = array(); - var depth = 0u; - var min_alpha = 0.0; - - var t = t_start; - var axis = axis_start; - var node_start = 0u; - var scale = MAX_SCALE; - var scale_exp2 = 1.0; - var parents = array(); - var child = inv_dir_bits; - var vox_pos = vec3(1.0); - var prev = 0u; - - var iters = 0; - loop { - if iters == MAX_ITERS { break; } - iters += 1; - let t_corner = vox_pos * inc_t + corner_adj; - let node = voxel_data[data_offset + node_start + (child ^ inv_dir_bits)]; - if node >= LEAF_BIT { - // ignore consecutive identical leaves - if node != prev { - let id = node & LEAF_MASK; - hits[depth] = RayHit(t, id, axis); - min_alpha += min_alpha(id) * (1.0 - min_alpha); - depth += 1u; - prev = node; - if depth == 10 || min_alpha >= FULL_ALPHA { break; } - } - - // move to next time point and determine which axis to move along - let t_next = t_corner + scale_exp2 * inc_t; - t = min(min(t_next.x, t_next.y), t_next.z); - axis = select(select(0u, 1u, t == t_next.y), 2u, t == t_next.z); - let move_dir = 4u >> axis; - - // check if need to pop stack - if (child & move_dir) > 0 { - // calculate new scale; first differing bit after adding - let axis_pos = vox_pos[axis]; - // AWARE - let differing = bitcast(axis_pos) ^ bitcast(axis_pos + scale_exp2); - scale = (bitcast(f32(differing)) >> 23) - 127 - (23 - MAX_SCALE); - scale_exp2 = bitcast((scale + 127 - MAX_SCALE) << 23); - if scale >= MAX_SCALE { break; } - - // restore & recalculate parent - let parent_info = parents[scale]; - node_start = parent_info >> 3; - child = parent_info & 7; - let scale_vec = vec3(scale + 23 - MAX_SCALE); - // remove bits lower than current scale - vox_pos = bitcast>((bitcast>(vox_pos) >> scale_vec) << scale_vec); - } - // move to next child and voxel position - child += move_dir; - vox_pos[axis] += scale_exp2; - } else { - // push current node to stack - parents[scale] = (node_start << 3) + child; - scale -= 1u; - - // calculate child node vars - scale_exp2 *= 0.5; - child = 0u; - let t_center = t_corner + scale_exp2 * inc_t; - if t > t_center.x { vox_pos.x += scale_exp2; child |= 4u; } - if t > t_center.y { vox_pos.y += scale_exp2; child |= 2u; } - if t > t_center.z { vox_pos.z += scale_exp2; child |= 1u; } - node_start = node; - } - } - return RayResult(hits, depth); -} - -fn min_alpha(id: u32) -> f32 { - switch id { - case 0u: {return 0.0;} - case 3u: {return 0.5;} - default: {return 1.0;} - } -} - -const AMBIENT: f32 = 0.2; -const SPECULAR: f32 = 0.5; - -// returns premultiplied -fn shade(id: u32, pos: vec3, normal: vec3, dir_view: vec3, dist: f32) -> vec4 { - var color = vec4(0.0); - if id == 0 { - return color; - } - let random = random(floor(pos)); - let random2 = random(floor(pos) + vec3(0.0001)); - switch id { - case 0u: { - color = vec4(0.0); - } - case 1u: { - color = vec4(vec3(0.5, 0.5, 0.5 + random * 0.2) * (random2 * 0.4 + 0.8), 1.0); - } - case 2u: { - color = vec4(vec3(0.4 + random * 0.2, 0.9, 0.4 + random * 0.2) * (random2 * 0.2 + 0.9), 1.0); - } - case 3u: { - let fog = min(dist / 64.0, 1.0); - let a = 0.5; - let rand = (sin((f32(time) / 2000.0 + random) * 6.28) + 1.0) / 2.0; - let rgb = vec3(0.5, 0.5, 1.0) * (rand * 0.2 + 0.8); - color = vec4(rgb * (1.0 - fog * a), a + fog * (1.0 - a)); - } - default: {} - } - let light_color = vec3(1.0); - let light_dir = global_lights[0].dir; - - let diffuse = max(dot(light_dir, normal), 0.0) * light_color; - let ambient = AMBIENT * light_color; - let spec_val = pow(max(dot(dir_view.xyz, reflect(-light_dir, normal)), 0.0), 32.0) * SPECULAR; - let specular = spec_val * light_color; - let new_color = (ambient + diffuse + specular) * color.xyz; - let new_a = min(color.a + spec_val, 1.0); - return vec4(new_color * new_a, new_a); -} - -fn dir_to_vec(bits: u32) -> vec3 { - return vec3(bits >> 2, (bits & 2) >> 1, bits & 1); -} - -fn vec_to_dir(vec: vec3) -> u32 { - return vec.x * 4 + vec.y * 2 + vec.z * 1; -} - -fn random(pos: vec3) -> f32 { - return fract(sin(dot(pos, vec3(12.9898, 78.233, 25.1279))) * 43758.5453123); -} - -fn outside3f(v: vec3, low: vec3, high: vec3) -> bool { - return any(v < low) || any(v > high); -} - -fn inside2f(v: vec2, low: vec2, high: vec2) -> bool { - return all(v >= low) && all(v <= high); -} - -fn inside3i(v: vec3, low: vec3, high: vec3) -> bool { - return all(v >= low) && all(v <= high); -} diff --git a/src/client/render/voxel/ray_oct/shader/compute_single.wgsl b/src/client/render/voxel/ray_oct/shader/compute_single.wgsl deleted file mode 100644 index 91e2890..0000000 --- a/src/client/render/voxel/ray_oct/shader/compute_single.wgsl +++ /dev/null @@ -1,282 +0,0 @@ -@group(0) @binding(0) -var view: View; -@group(0) @binding(1) -var voxels: array; -@group(0) @binding(2) -var voxel_groups: array; -@group(0) @binding(3) -var global_lights: array; -@group(0) @binding(4) -var output: texture_storage_2d; - -struct GlobalLight { - dir: vec3, -}; - -struct View { - transform: mat4x4, - zoom: f32, -}; - -struct VoxelGroup { - transform: mat4x4, - transform_inv: mat4x4, - scale: u32, - offset: u32, -}; - -@compute -@workgroup_size(8, 8, 1) -fn main(@builtin(global_invocation_id) cell: vec3) { - let view_dim = textureDimensions(output); - // get position of the pixel; eye at origin, pixel on plane z = 1 - if cell.x >= view_dim.x || cell.y >= view_dim.y { - return; - } - let view_dim_f = vec2(view_dim); - let aspect = view_dim_f.y / view_dim_f.x; - let pixel_pos = vec2( - (vec2(cell.xy) / view_dim_f - vec2(0.5)) * vec2(2.0, -2.0 * aspect) - ); - let pos = view.transform * vec4(pixel_pos, 1.0, 1.0); - let dir = view.transform * vec4(normalize(vec3(pixel_pos, view.zoom)), 0.0); - - var color = trace_full(pos, dir); - let light_mult = clamp((-dot(dir.xyz, global_lights[0].dir) - 0.99) * 200.0, 0.0, 1.0); - let sun_color = light_mult * vec3(1.0, 1.0, 1.0); - let sky_bg = vec3(0.3, 0.6, 1.0); - let sky_color = sun_color + sky_bg * (1.0 - light_mult); - color += vec4(sky_color * (1.0 - color.a), 1.0 - color.a); - color.a = 1.0; - textureStore(output, cell.xy, color); -} - -const LEAF_BIT = 1u << 31u; -const LEAF_MASK = ~LEAF_BIT; - -const ZERO3F = vec3(0.0); -const ZERO2F = vec2(0.0); -const FULL_ALPHA = 0.999; -const EPSILON = 0.00000000001; -const MAX_ITERS = 10000; -// NOTE: CANNOT GO HIGHER THAN 23 due to how floating point -// numbers are stored and the bit manipulation used -const MAX_SCALE: u32 = 13; -const AMBIENT: f32 = 0.2; -const SPECULAR: f32 = 0.5; - -fn trace_full(pos_view: vec4, dir_view: vec4) -> vec4 { - let gi = 0; - let group = voxel_groups[gi]; - if group.scale == 0 { - return vec4(0.0); - } - let dimensions = vec3(1u << group.scale); - let dim_f = vec3(dimensions); - let dim_i = vec3(dimensions); - - // transform so that group is at 0,0 - let pos_start = (group.transform_inv * pos_view).xyz; - var dir = (group.transform_inv * dir_view).xyz; - if dir.x == 0 {dir.x = EPSILON;} - if dir.y == 0 {dir.y = EPSILON;} - if dir.z == 0 {dir.z = EPSILON;} - - let dir_if = sign(dir); - let dir_uf = max(dir_if, vec3(0.0)); - - - - // calculate normals - var normals = mat3x3( - (group.transform * vec4(dir_if.x, 0.0, 0.0, 0.0)).xyz, - (group.transform * vec4(0.0, dir_if.y, 0.0, 0.0)).xyz, - (group.transform * vec4(0.0, 0.0, dir_if.z, 0.0)).xyz, - ); - var axis = 0u; - - // find where ray intersects with group - let pos_min = (vec3(1.0) - dir_uf) * dim_f; - // time of intersection; x = td + p, solve for t - var t_min = (pos_min - pos_start) / dir; - if outside3f(pos_start, ZERO3F, dim_f) { - // points of intersection - let px = pos_start + t_min.x * dir; - let py = pos_start + t_min.y * dir; - let pz = pos_start + t_min.z * dir; - - // check if point is in bounds - let hit = vec3( - inside2f(px.yz, ZERO2F, dim_f.yz), - inside2f(py.xz, ZERO2F, dim_f.xz), - inside2f(pz.xy, ZERO2F, dim_f.xy), - ) && (t_min > ZERO3F); - if !any(hit) { - return vec4(0.0); - } - axis = select(select(2u, 1u, hit.y), 0u, hit.x); - } - let t_mult = f32(1u << (MAX_SCALE - group.scale)); - t_min *= t_mult; - let full = f32(1u << MAX_SCALE); - // time to move entire side length in each direction - let inc_t = abs(1.0 / dir) * full; - let t_offset = max(max(t_min.x, t_min.y), t_min.z); - var t = max(0.0, t_offset); - - let dir_i = vec3(dir_if); - let dir_u = vec3(dir_uf); - let dir_bits = vec_to_dir(dir_u); - let inv_dir_bits = 7 - dir_bits; - - var node_start = 1u; - var scale = MAX_SCALE - 1; - var scale_exp2 = 0.5; - var color = vec4(0.0); - var parents = array(); - var prev = LEAF_BIT; - var old_t = t / t_mult; - - var child = 0u; - var vox_pos = vec3(1.0); - let t_center = t_min + scale_exp2 * inc_t; - if t > t_center.x { vox_pos.x = 1.5; child |= 4u; } - if t > t_center.y { vox_pos.y = 1.5; child |= 2u; } - if t > t_center.z { vox_pos.z = 1.5; child |= 1u; } - let min_adj = t_min - inc_t; - - var iters = 0; - loop { - if iters == MAX_ITERS { - return vec4(1.0, 0.0, 1.0, 1.0); - } - iters += 1; - let t_corner = vox_pos * inc_t + min_adj; - let node = voxels[group.offset + node_start + (child ^ inv_dir_bits)]; - if node >= LEAF_BIT { - if node != prev { - if node != LEAF_BIT { - let real_t = t / t_mult; - let dist = real_t - old_t; - old_t = real_t; - let filt = min(dist / 64.0, 1.0); - if prev == LEAF_BIT + 3 { - color.a += filt * (1.0 - color.a); - if color.a > FULL_ALPHA { break; } - } - var pos = (pos_view + dir_view * real_t).xyz; - pos[axis] = round(pos[axis]) - (1.0 - dir_uf[axis]); - let vcolor = get_color(node & LEAF_MASK, pos); - var normal = normals[axis]; - let light_color = vec3(1.0); - let light_dir = global_lights[0].dir; - - let diffuse = max(dot(light_dir, normal), 0.0) * light_color; - let ambient = AMBIENT * light_color; - let spec_val = pow(max(dot(dir_view.xyz, reflect(-light_dir, normal)), 0.0), 32.0) * SPECULAR; - let specular = spec_val * light_color; - let new_color = (ambient + diffuse + specular) * vcolor.xyz; - let new_a = min(vcolor.a + spec_val, 1.0); - - color += vec4(new_color.xyz * new_a, new_a) * (1.0 - color.a); - if color.a > FULL_ALPHA { break; } - } - prev = node; - } - - // move to next time point and determine which axis to move along - let t_next = t_corner + scale_exp2 * inc_t; - t = min(min(t_next.x, t_next.y), t_next.z); - axis = select(select(0u, 1u, t == t_next.y), 2u, t == t_next.z); - let move_dir = 4u >> axis; - - // check if need to pop stack - if (child & move_dir) > 0 { - // calculate new scale; first differing bit after adding - let axis_pos = vox_pos[axis]; - // AWARE - let differing = bitcast(axis_pos) ^ bitcast(axis_pos + scale_exp2); - scale = (bitcast(f32(differing)) >> 23) - 127 - (23 - MAX_SCALE); - scale_exp2 = bitcast((scale + 127 - MAX_SCALE) << 23); - if scale >= MAX_SCALE { break; } - - // restore & recalculate parent - let parent_info = parents[scale]; - node_start = parent_info >> 3; - child = parent_info & 7; - let scale_vec = vec3(scale + 23 - MAX_SCALE); - // remove bits lower than current scale - vox_pos = bitcast>((bitcast>(vox_pos) >> scale_vec) << scale_vec); - } - // move to next child and voxel position - child += move_dir; - vox_pos[axis] += scale_exp2; - } else { - // push current node to stack - parents[scale] = (node_start << 3) + child; - scale -= 1u; - - // calculate child node vars - scale_exp2 *= 0.5; - child = 0u; - let t_center = t_corner + scale_exp2 * inc_t; - if t > t_center.x { vox_pos.x += scale_exp2; child |= 4u; } - if t > t_center.y { vox_pos.y += scale_exp2; child |= 2u; } - if t > t_center.z { vox_pos.z += scale_exp2; child |= 1u; } - node_start = node; - } - } - // let fog = min(t / t_mult / 1000.0, 1.0); - // return vec4(color.xyz * (1.0 - fog) + vec3(fog), color.a * (1.0 - fog) + fog); - // return vec4(f32(iters) / f32(MAX_ITERS), 0.0, 0.0, 1.0); - return color; -} - -fn dir_to_vec(bits: u32) -> vec3 { - return vec3(bits >> 2, (bits & 2) >> 1, bits & 1); -} - -fn vec_to_dir(vec: vec3) -> u32 { - return vec.x * 4 + vec.y * 2 + vec.z * 1; -} - -fn get_color(id: u32, pos: vec3) -> vec4 { - let random = random(floor(pos)); - let random2 = random(floor(pos) + vec3(0.0001)); - switch id { - case 0u: { - return vec4(0.0); - } - case 1u: { - let color = vec3(0.5, 0.5, 0.5 + random * 0.2) * (random2 * 0.4 + 0.8); - return vec4(color, 1.0); - } - case 2u: { - let color = vec3(0.4 + random * 0.2, 0.9, 0.4 + random * 0.2) * (random2 * 0.2 + 0.9); - return vec4(color, 1.0); - } - case 3u: { - let color = vec3(0.5, 0.5, 1.0) * (random2 * 0.2 + 0.8); - return vec4(color, 0.5); - } - default: { - return vec4(1.0, 0.0, 0.0, 1.0); - } - } -} - -fn random(pos: vec3) -> f32 { - return fract(sin(dot(pos, vec3(12.9898, 78.233, 25.1279))) * 43758.5453123); -} - -fn outside3f(v: vec3, low: vec3, high: vec3) -> bool { - return any(v < low) || any(v > high); -} - -fn inside2f(v: vec2, low: vec2, high: vec2) -> bool { - return all(v >= low) && all(v <= high); -} - -fn inside3i(v: vec3, low: vec3, high: vec3) -> bool { - return all(v >= low) && all(v <= high); -} diff --git a/src/client/render/voxel/ray_oct/shader/render.wgsl b/src/client/render/voxel/ray_oct/shader/render.wgsl deleted file mode 100644 index f5ed64e..0000000 --- a/src/client/render/voxel/ray_oct/shader/render.wgsl +++ /dev/null @@ -1,38 +0,0 @@ -// Vertex shader - -struct VertexOutput { - @builtin(position) clip_position: vec4, - @location(0) tex_pos: vec2, -}; - -@group(0) @binding(0) -var tex: texture_2d; -@group(0) @binding(1) -var sample: sampler; - -@vertex -fn vs_main( - @builtin(vertex_index) vi: u32, - @builtin(instance_index) ii: u32, -) -> VertexOutput { - var out: VertexOutput; - - let pos = vec2( - f32(vi % 2u), - f32(vi / 2u), - ); - out.clip_position = vec4(pos * 2.0 - 1.0, 0.0, 1.0); - out.tex_pos = pos; - out.tex_pos.y = 1.0 - out.tex_pos.y; - return out; -} - -// Fragment shader - -@fragment -fn fs_main( - in: VertexOutput, -) -> @location(0) vec4 { - return textureSample(tex, sample, in.tex_pos); -} - diff --git a/src/client/render_vulkan/command.rs b/src/client/render_vulkan/command.rs deleted file mode 100644 index 4a91938..0000000 --- a/src/client/render_vulkan/command.rs +++ /dev/null @@ -1,82 +0,0 @@ -use crate::{ - client::camera::Camera, - common::component::{ChunkMesh, ChunkPos}, util::oct_tree::OctTree, -}; - -use super::{voxel::VoxelColor, Renderer}; -use bevy_ecs::entity::Entity; -use nalgebra::{Rotation3, Vector3}; -use ndarray::Array3; - -#[derive(Debug, Clone)] -pub enum RenderCommand { - CreateVoxelGrid(CreateVoxelGrid), - AddChunk(AddChunk), - UpdateGridTransform(UpdateGridTransform), - ViewUpdate(Camera), -} - -#[derive(Debug, Clone)] -pub struct CreateVoxelGrid { - pub id: Entity, - pub pos: Vector3, - pub orientation: Rotation3, - pub dimensions: Vector3, - pub grid: Array3, -} - -#[derive(Debug, Clone)] -pub struct AddChunk { - pub id: Entity, - pub pos: ChunkPos, - pub mesh: ChunkMesh, - pub tree: OctTree, -} - -#[derive(Debug, Clone)] -pub struct UpdateGridTransform { - pub id: Entity, - pub pos: Vector3, - pub orientation: Rotation3, -} - -impl Renderer { - pub fn handle_commands(&mut self, commands: Vec) { - let mut new_camera = false; - for cmd in commands { - match cmd { - RenderCommand::CreateVoxelGrid(desc) => self.voxel_pipeline.add_group( - &self.device, - &mut self.encoder, - &mut self.staging_belt, - desc, - ), - RenderCommand::ViewUpdate(camera) => { - new_camera = true; - self.camera = camera; - } - RenderCommand::UpdateGridTransform(update) => self.voxel_pipeline.update_transform( - &self.device, - &mut self.encoder, - &mut self.staging_belt, - update, - ), - RenderCommand::AddChunk(desc) => self.voxel_pipeline.add_chunk( - &self.device, - &mut self.encoder, - &mut self.staging_belt, - desc, - ), - } - } - if new_camera { - self.voxel_pipeline.update_view( - &self.device, - &mut self.encoder, - &mut self.staging_belt, - self.size, - &self.camera, - ); - } - } -} diff --git a/src/client/render_vulkan/mod.rs b/src/client/render_vulkan/mod.rs deleted file mode 100644 index 25c1e4b..0000000 --- a/src/client/render_vulkan/mod.rs +++ /dev/null @@ -1,79 +0,0 @@ -mod command; -pub mod voxel; -use std::sync::Arc; - -pub use command::*; -use vulkano::{ - device::{Device, DeviceCreateInfo, QueueCreateInfo, QueueFlags}, instance::{Instance, InstanceCreateInfo}, memory::allocator::StandardMemoryAllocator, VulkanLibrary -}; - -use super::camera::Camera; -use crate::client::rsc::CLEAR_COLOR; -use nalgebra::Vector2; -use voxel::VoxelPipeline; -use winit::{dpi::PhysicalSize, window::Window}; - -pub struct Renderer { - camera: Camera, -} - -impl Renderer { - pub fn new(window: Arc) -> Self { - let library = VulkanLibrary::new().expect("no local Vulkan library/DLL"); - let instance = Instance::new(library, InstanceCreateInfo::default()) - .expect("failed to create instance"); - let physical_device = instance - .enumerate_physical_devices() - .expect("could not enumerate devices") - .next() - .expect("no devices available"); - let queue_family_index = physical_device - .queue_family_properties() - .iter() - .enumerate() - .position(|(_queue_family_index, queue_family_properties)| { - queue_family_properties - .queue_flags - .contains(QueueFlags::GRAPHICS) - }) - .expect("couldn't find a graphical queue family") - as u32; - - let (device, mut queues) = Device::new( - physical_device, - DeviceCreateInfo { - // here we pass the desired queue family to use by index - queue_create_infos: vec![QueueCreateInfo { - queue_family_index, - ..Default::default() - }], - ..Default::default() - }, - ) - .expect("failed to create device"); - - let queue = queues.next().unwrap(); - let memory_allocator = Arc::new(StandardMemoryAllocator::new_default(device.clone())); - - Self { - camera: Camera::default(), - size: Vector2::new(size.width, size.height), - voxel_pipeline: VoxelPipeline::new(&device, &config), - } - } - - pub fn reset_shader(&mut self) { - todo!() - } - - pub fn update_shader(&mut self) { - todo!() - } - - pub fn draw(&mut self) {} - - pub fn resize(&mut self, size: PhysicalSize) { - self.size = Vector2::new(size.width, size.height); - todo!(); - } -} diff --git a/src/client/render_vulkan/voxel/mod.rs b/src/client/render_vulkan/voxel/mod.rs deleted file mode 100644 index b2b10da..0000000 --- a/src/client/render_vulkan/voxel/mod.rs +++ /dev/null @@ -1,25 +0,0 @@ -use std::sync::Arc; - -use vulkano::{buffer::{Buffer, BufferCreateInfo, BufferUsage}, memory::allocator::{AllocationCreateInfo, MemoryAllocator, MemoryTypeFilter}}; - -pub struct VoxelPipeline { - -} - -impl VoxelPipeline { - pub fn init(memory_allocator: Arc) { - let buffer = Buffer::from_data( - memory_allocator.clone(), - BufferCreateInfo { - usage: BufferUsage::UNIFORM_BUFFER, - ..Default::default() - }, - AllocationCreateInfo { - memory_type_filter: MemoryTypeFilter::PREFER_DEVICE - | MemoryTypeFilter::HOST_SEQUENTIAL_WRITE, - ..Default::default() - }, - data, - ); - } -} diff --git a/src/common/component/chunk/mod.rs b/src/common/component/chunk/mod.rs index 10a64c2..2db49b8 100644 --- a/src/common/component/chunk/mod.rs +++ b/src/common/component/chunk/mod.rs @@ -8,7 +8,7 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{bundle::Bundle, component::Component, entity::Entity, system::Resource}; use nalgebra::Vector3; -pub const SCALE: u32 = 9; +pub const SCALE: u32 = 10; pub const SIDE_LENGTH: usize = 2usize.pow(SCALE); pub const SHAPE: (usize, usize, usize) = (SIDE_LENGTH, SIDE_LENGTH, SIDE_LENGTH); pub const DIMENSIONS: Vector3 = Vector3::new(SIDE_LENGTH, SIDE_LENGTH, SIDE_LENGTH); diff --git a/src/main.rs b/src/main.rs index 8174069..bb5bf04 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ #![allow(clippy::type_complexity)] +#![feature(slice_as_chunks)] use client::ClientApp; use winit::event_loop::EventLoop; diff --git a/src/util/oct_tree.rs b/src/util/oct_tree.rs index fa57c9b..18c327c 100644 --- a/src/util/oct_tree.rs +++ b/src/util/oct_tree.rs @@ -14,18 +14,23 @@ impl OctNode { pub const fn new_node(addr: u32) -> Self { Self(addr) } + pub const fn new_leaf(data: u32) -> Self { Self(data | LEAF_BIT) } + pub const fn is_leaf(&self) -> bool { self.0 >= LEAF_BIT } + pub const fn is_node(&self) -> bool { self.0 < LEAF_BIT } + pub const fn node_data(&self) -> u32 { self.0 } + pub const fn leaf_data(&self) -> u32 { self.0 & !LEAF_BIT } @@ -67,9 +72,11 @@ impl OctTree { levels, } } + pub fn from_leaf_fn(f_leaf: &mut impl FnMut(Vector3) -> u32, levels: u32) -> OctTree { Self::from_fn(f_leaf, &mut |_, _| None, levels) } + pub fn from_fn( f_leaf: &mut impl FnMut(Vector3) -> u32, f_node: &mut impl FnMut(Vector3, u32) -> Option, @@ -77,6 +84,7 @@ impl OctTree { ) -> OctTree { Self::from_fn_offset(f_leaf, f_node, levels, Vector3::from_element(0)) } + pub fn from_fn_offset( f_leaf: &mut impl FnMut(Vector3) -> u32, f_node: &mut impl FnMut(Vector3, u32) -> Option, @@ -98,6 +106,7 @@ impl OctTree { levels, } } + fn from_fn_offset_inner( f_leaf: &mut impl FnMut(Vector3) -> u32, f_node: &mut impl FnMut(Vector3, u32) -> Option, @@ -157,9 +166,11 @@ impl OctTree { } } } + pub fn from_arr(arr: ArrayView3, levels: u32) -> Self { Self::from_fn(&mut |p| arr[(p.x, p.y, p.z)], &mut |_, _| None, levels) } + pub fn get(&self, mut pos: Vector3) -> u32 { let mut data_start = 1; let mut i = 0; @@ -175,9 +186,16 @@ impl OctTree { } self.data[i].leaf_data() } + pub fn raw(&self) -> &[OctNode] { &self.data } + + pub fn from_children(children: [OctTree; 8]) { + // Self { + // data: + // } + } } pub struct OctTreeIter<'a> {