diff --git a/.gitignore b/.gitignore index 6b007f9..a6d88a6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ log.log *.out.spv *.spv-dis shaders_out +shader_debug diff --git a/Cargo.lock b/Cargo.lock index 1f33633..615bdc2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,22 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "ab_glyph" -version = "0.2.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c0457472c38ea5bd1c3b5ada5e368271cb550be7a4ca4a0b4634e9913f6cc2" -dependencies = [ - "ab_glyph_rasterizer", - "owned_ttf_parser", -] - -[[package]] -name = "ab_glyph_rasterizer" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" - [[package]] name = "accesskit" version = "0.25.1" @@ -61,7 +45,7 @@ dependencies = [ "accesskit_consumer", "hashbrown 0.17.1", "objc2 0.5.2", - "objc2-app-kit 0.2.2", + "objc2-app-kit", "objc2-foundation 0.2.2", ] @@ -99,19 +83,6 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" -[[package]] -name = "ahash" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" -dependencies = [ - "cfg-if", - "getrandom 0.3.4", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "aho-corasick" version = "1.1.5" @@ -265,24 +236,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "arboard" -version = "3.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0348a1c054491f4bfe6ab86a7b6ab1e44e45d899005de92f58b3df180b36ddaf" -dependencies = [ - "clipboard-win", - "log", - "objc2 0.6.4", - "objc2-app-kit 0.3.2", - "objc2-foundation 0.3.2", - "parking_lot", - "percent-encoding", - "windows-sys 0.52.0", - "wl-clipboard-rs", - "x11rb", -] - [[package]] name = "argh" version = "0.1.19" @@ -314,12 +267,6 @@ dependencies = [ "serde", ] -[[package]] -name = "arrayref" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" - [[package]] name = "arrayvec" version = "0.7.8" @@ -535,7 +482,7 @@ dependencies = [ "bitvec", "blake3", "derive_more", - "downcast-rs 2.0.2", + "downcast-rs", "either", "petgraph", "ron", @@ -594,7 +541,7 @@ dependencies = [ "bevy_utils", "console_error_panic_hook", "ctrlc", - "downcast-rs 2.0.2", + "downcast-rs", "log", "thiserror 2.0.21", "variadics_please", @@ -628,7 +575,7 @@ dependencies = [ "crossbeam-channel", "derive_more", "disqualified", - "downcast-rs 2.0.2", + "downcast-rs", "either", "futures-io", "futures-lite", @@ -692,7 +639,7 @@ dependencies = [ "bevy_utils", "bevy_window", "derive_more", - "downcast-rs 2.0.2", + "downcast-rs", "serde", "smallvec", "thiserror 2.0.21", @@ -727,7 +674,6 @@ name = "bevy_clipboard" version = "0.20.0-dev" source = "git+https://github.com/bevyengine/bevy.git?rev=0f38358f573a7dc6ea961076f6151be662142010#0f38358f573a7dc6ea961076f6151be662142010" dependencies = [ - "arboard", "bevy_app", "bevy_ecs", "bevy_log", @@ -1170,7 +1116,6 @@ dependencies = [ "bevy_anti_alias", "bevy_app", "bevy_asset", - "bevy_audio", "bevy_camera", "bevy_camera_controller", "bevy_clipboard", @@ -1491,7 +1436,7 @@ dependencies = [ "bevy_utils", "derive_more", "disqualified", - "downcast-rs 2.0.2", + "downcast-rs", "erased-serde", "foldhash 0.2.0", "glam", @@ -1555,7 +1500,7 @@ dependencies = [ "bitflags 2.13.2", "bytemuck", "derive_more", - "downcast-rs 2.0.2", + "downcast-rs", "encase", "glam", "image", @@ -1814,7 +1759,6 @@ dependencies = [ "bevy_derive", "bevy_diagnostic", "bevy_ecs", - "bevy_image", "bevy_light", "bevy_log", "bevy_math", @@ -2282,18 +2226,6 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "calloop-wayland-source" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" -dependencies = [ - "calloop", - "rustix 0.38.44", - "wayland-backend", - "wayland-client", -] - [[package]] name = "cc" version = "1.5.1" @@ -2318,7 +2250,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ - "nom 7.1.3", + "nom", ] [[package]] @@ -2355,15 +2287,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "clipboard-win" -version = "5.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde03770d3df201d4fb868f2c9c59e66a3e4e2bd06692a0fe701e7103c7e84d4" -dependencies = [ - "error-code", -] - [[package]] name = "codespan-reporting" version = "0.13.1" @@ -2782,12 +2705,6 @@ dependencies = [ "litrs", ] -[[package]] -name = "downcast-rs" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" - [[package]] name = "downcast-rs" version = "2.0.2" @@ -2870,15 +2787,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] -[[package]] -name = "error-code" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b5343afd4a8365a643ac588dab4cf234a190c7f6c88c9f6dd6ffe00837661b7" - [[package]] name = "euclid" version = "0.22.14" @@ -3152,18 +3063,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "libc", - "r-efi 5.3.0", - "wasip2", -] - [[package]] name = "getrandom" version = "0.4.3" @@ -3173,7 +3072,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "r-efi 6.0.0", + "r-efi", "rand_core", "wasm-bindgen", ] @@ -3882,17 +3781,6 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" -[[package]] -name = "lewton" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777b48df9aaab155475a83a7df3070395ea1ac6902f5cd062b8f2b028075c030" -dependencies = [ - "byteorder", - "ogg", - "tinyvec", -] - [[package]] name = "lexical" version = "7.0.5" @@ -4265,15 +4153,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "nom" -version = "8.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" -dependencies = [ - "memchr", -] - [[package]] name = "nonmax" version = "0.5.5" @@ -4458,18 +4337,6 @@ dependencies = [ "objc2-quartz-core 0.2.2", ] -[[package]] -name = "objc2-app-kit" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" -dependencies = [ - "bitflags 2.13.2", - "objc2 0.6.4", - "objc2-core-graphics", - "objc2-foundation 0.3.2", -] - [[package]] name = "objc2-audio-toolbox" version = "0.3.2" @@ -4573,7 +4440,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ - "bitflags 2.13.2", "dispatch2", "objc2 0.6.4", "objc2-core-foundation", @@ -4666,7 +4532,7 @@ checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" dependencies = [ "block2 0.5.1", "objc2 0.5.2", - "objc2-app-kit 0.2.2", + "objc2-app-kit", "objc2-foundation 0.2.2", ] @@ -4786,15 +4652,6 @@ dependencies = [ "nonmax", ] -[[package]] -name = "ogg" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6951b4e8bf21c8193da321bcce9c9dd2e13c858fe078bf9054a288b419ae5d6e" -dependencies = [ - "byteorder", -] - [[package]] name = "once_cell" version = "1.21.4" @@ -4832,25 +4689,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "os_pipe" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "owned_ttf_parser" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b" -dependencies = [ - "ttf-parser", -] - [[package]] name = "parking" version = "2.2.1" @@ -5101,15 +4939,6 @@ version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" -[[package]] -name = "quick-xml" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" -dependencies = [ - "memchr", -] - [[package]] name = "quote" version = "1.0.47" @@ -5119,12 +4948,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - [[package]] name = "r-efi" version = "6.0.0" @@ -5295,7 +5118,6 @@ checksum = "d0a536bb79db59098ef71a4dd4246c02eb87b316deceb1b68e0cde7167ec01eb" dependencies = [ "cpal", "dasp_sample", - "lewton", "num-rational", "thiserror 2.0.21", "tracing", @@ -5369,7 +5191,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -5479,31 +5301,12 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sctk-adwaita" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6277f0217056f77f1d8f49f2950ac6c278c0d607c45f5ee99328d792ede24ec" -dependencies = [ - "ab_glyph", - "log", - "memmap2", - "smithay-client-toolkit", - "tiny-skia", -] - [[package]] name = "security-framework" version = "3.7.0" @@ -5666,31 +5469,6 @@ version = "1.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e" -[[package]] -name = "smithay-client-toolkit" -version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" -dependencies = [ - "bitflags 2.13.2", - "calloop", - "calloop-wayland-source", - "cursor-icon", - "libc", - "log", - "memmap2", - "rustix 0.38.44", - "thiserror 1.0.69", - "wayland-backend", - "wayland-client", - "wayland-csd-frame", - "wayland-cursor", - "wayland-protocols", - "wayland-protocols-wlr", - "wayland-scanner", - "xkeysym", -] - [[package]] name = "smol_str" version = "0.2.2" @@ -5739,12 +5517,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strict-num" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" - [[package]] name = "string_cache" version = "0.9.0" @@ -5842,7 +5614,7 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tape-load" version = "0.1.0" -source = "git+https://git.stargaze.group/molive/tape-drive.git?rev=19b241637be770db5ee6201951138f41b1f9f467#19b241637be770db5ee6201951138f41b1f9f467" +source = "git+https://git.stargaze.group/molive/tape-drive.git?rev=b7f83169e28105693203ec97cbe26d3b29b60cec#b7f83169e28105693203ec97cbe26d3b29b60cec" dependencies = [ "bevy_reflect", "foldhash 0.1.5", @@ -5948,31 +5720,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "tiny-skia" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" -dependencies = [ - "arrayref", - "arrayvec", - "bytemuck", - "cfg-if", - "log", - "tiny-skia-path", -] - -[[package]] -name = "tiny-skia-path" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" -dependencies = [ - "arrayref", - "bytemuck", - "strict-num", -] - [[package]] name = "tinystr" version = "0.8.4" @@ -6113,23 +5860,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "tree_magic_mini" -version = "3.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" -dependencies = [ - "memchr", - "nom 8.0.0", - "petgraph", -] - -[[package]] -name = "ttf-parser" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" - [[package]] name = "twox-hash" version = "2.1.4" @@ -6320,15 +6050,6 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" -[[package]] -name = "wasip2" -version = "1.0.4+wasi-0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" -dependencies = [ - "wit-bindgen", -] - [[package]] name = "wasm-bindgen" version = "0.2.129" @@ -6385,103 +6106,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "wayland-backend" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" -dependencies = [ - "cc", - "downcast-rs 1.2.1", - "rustix 1.1.5", - "scoped-tls", - "smallvec", - "wayland-sys", -] - -[[package]] -name = "wayland-client" -version = "0.31.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073" -dependencies = [ - "bitflags 2.13.2", - "rustix 1.1.5", - "wayland-backend", - "wayland-scanner", -] - -[[package]] -name = "wayland-csd-frame" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" -dependencies = [ - "bitflags 2.13.2", - "cursor-icon", - "wayland-backend", -] - -[[package]] -name = "wayland-cursor" -version = "0.31.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d" -dependencies = [ - "rustix 1.1.5", - "wayland-client", - "xcursor", -] - -[[package]] -name = "wayland-protocols" -version = "0.32.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6" -dependencies = [ - "bitflags 2.13.2", - "wayland-backend", - "wayland-client", - "wayland-scanner", -] - -[[package]] -name = "wayland-protocols-plasma" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b6d8cf1eb2c1c31ed1f5643c88a6e53538129d4af80030c8cabd1f9fa884d91" -dependencies = [ - "bitflags 2.13.2", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-scanner", -] - -[[package]] -name = "wayland-protocols-wlr" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" -dependencies = [ - "bitflags 2.13.2", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-scanner", -] - -[[package]] -name = "wayland-scanner" -version = "0.31.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0" -dependencies = [ - "proc-macro2", - "quick-xml", - "quote", -] - [[package]] name = "wayland-sys" version = "0.31.11" @@ -6806,7 +6430,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -7153,7 +6777,6 @@ version = "0.30.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6755fa58a9f8350bd1e472d4c3fcc25f824ec358933bba33306d0b63df5978d" dependencies = [ - "ahash", "android-activity", "atomic-waker", "bitflags 2.13.2", @@ -7168,10 +6791,9 @@ dependencies = [ "dpi", "js-sys", "libc", - "memmap2", "ndk", "objc2 0.5.2", - "objc2-app-kit 0.2.2", + "objc2-app-kit", "objc2-foundation 0.2.2", "objc2-ui-kit", "orbclient", @@ -7180,17 +6802,11 @@ dependencies = [ "raw-window-handle", "redox_syscall 0.4.1", "rustix 0.38.44", - "sctk-adwaita", - "smithay-client-toolkit", "smol_str", "tracing", "unicode-segmentation", "wasm-bindgen", "wasm-bindgen-futures", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-protocols-plasma", "web-sys", "web-time", "windows-sys 0.52.0", @@ -7208,30 +6824,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "wit-bindgen" -version = "0.57.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" - -[[package]] -name = "wl-clipboard-rs" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d7888ccd4896447b2d14d3a9350a85df2aeb6f181e2e7a31349d104ac46cac1" -dependencies = [ - "libc", - "log", - "os_pipe", - "rustix 1.1.5", - "thiserror 2.0.21", - "tree_magic_mini", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-protocols-wlr", -] - [[package]] name = "writeable" version = "0.6.4" @@ -7279,12 +6871,6 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" -[[package]] -name = "xcursor" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23" - [[package]] name = "xkbcommon-dl" version = "0.4.2" diff --git a/Cargo.toml b/Cargo.toml index 02a3d7d..e87cba3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -114,13 +114,29 @@ bevy_tape_drive_solari = { path = "crates/bevy_tape_drive_solari" } bevy_tape_load = { path = "crates/bevy_tape_load" } [dev-dependencies] -# Bevy -bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", features = [ +bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", default-features = false, features = [ + "default_app", + "3d_bevy_render", + "scene", + "picking", + "ui_api", + "ui_bevy_render", + "bevy_ui_widgets", "default_font", "https", "free_camera", "dev", -] } + "std", + "bevy_gilrs", + "bevy_winit", + "bevy_clipboard", + "multi_threaded", + "webgl2", + "x11", + #"wayland", + "custom_cursor", + "sysinfo_plugin", +] } # Bevy # Others rand = "0.10.0" chacha20 = { version = "0.10.0", default-features = false, features = ["rng"] } diff --git a/crates/bevy_tape_drive_solari/Cargo.toml b/crates/bevy_tape_drive_solari/Cargo.toml index 413882f..ccb6b80 100644 --- a/crates/bevy_tape_drive_solari/Cargo.toml +++ b/crates/bevy_tape_drive_solari/Cargo.toml @@ -17,7 +17,9 @@ bevy_core_pipeline = { git = "https://github.com/bevyengine/bevy.git", rev = "0f bevy_derive = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_diagnostic = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_ecs = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } -bevy_image = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } +bevy_image = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", features = [ + "zstd_rust", +] } bevy_light = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_log = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_math = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } @@ -30,7 +32,8 @@ bevy_platform = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358 ] } bevy_reflect = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_render = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", features = [ - "spirv_shader_passthrough", + "shader_format_spirv", + #"spirv_shader_passthrough", ] } bevy_shader = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_shape = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } diff --git a/crates/bevy_tape_drive_solari/src/scene/binder/bind_group.rs b/crates/bevy_tape_drive_solari/src/scene/binder/bind_group.rs index 5efacbf..4e66af5 100644 --- a/crates/bevy_tape_drive_solari/src/scene/binder/bind_group.rs +++ b/crates/bevy_tape_drive_solari/src/scene/binder/bind_group.rs @@ -103,6 +103,7 @@ impl RaytracingSceneBindings { &mut self.instances.vertex_buffers.dirty, &mut self.instances.index_buffers.dirty, &mut self.instances.aabb_buffers.dirty, + &mut self.instances.tape_metadata_buffers.dirty, &mut self.assets.textures.dirty, ] { invalid |= core::mem::replace(dirty, false); @@ -150,6 +151,7 @@ impl RaytracingSceneBindings { let vertex_buffers = buffer_bindings(&self.instances.vertex_buffers, dummy); let index_buffers = buffer_bindings(&self.instances.index_buffers, dummy); let aabb_buffers = buffer_bindings(&self.instances.aabb_buffers, dummy); + let tape_metadata_buffers = buffer_bindings(&self.instances.tape_metadata_buffers, dummy); let (mut textures, mut samplers): (Vec<_>, Vec<_>) = self .assets @@ -238,6 +240,7 @@ impl RaytracingSceneBindings { vertex_buffers.as_slice(), index_buffers.as_slice(), aabb_buffers.as_slice(), + tape_metadata_buffers.as_slice(), textures.as_slice(), samplers.as_slice(), materials, diff --git a/crates/bevy_tape_drive_solari/src/scene/binder/instances.rs b/crates/bevy_tape_drive_solari/src/scene/binder/instances.rs index ee4a767..a48270f 100644 --- a/crates/bevy_tape_drive_solari/src/scene/binder/instances.rs +++ b/crates/bevy_tape_drive_solari/src/scene/binder/instances.rs @@ -44,9 +44,11 @@ pub struct GpuInstanceGeometryIds { #[derive(Clone, Copy, Default, PartialEq, Pod, Zeroable)] #[repr(C)] pub struct GpuInstanceTapeIds { - aabb_buffer_id: u32, - aabb_buffer_offset: u32, - aabb_count: u32, + aabb_buffer_id: u32, + aabb_buffer_offset: u32, + aabb_count: u32, + metadata_buffer_id: u32, + metadata_buffer_offset: u32, } /// A world-from-local affine transform, stored transposed as three rows. @@ -103,6 +105,7 @@ pub struct InstanceState { pub vertex_buffers: RetainedBindingArray, pub index_buffers: RetainedBindingArray, pub aabb_buffers: RetainedBindingArray, + pub tape_metadata_buffers: RetainedBindingArray, pub transforms: AtomicSparseBufferVec, pub previous_frame_transforms: AtomicSparseBufferVec, pub geometry_ids: AtomicSparseBufferVec, @@ -123,6 +126,7 @@ impl InstanceState { vertex_buffers: RetainedBindingArray::new(), index_buffers: RetainedBindingArray::new(), aabb_buffers: RetainedBindingArray::new(), + tape_metadata_buffers: RetainedBindingArray::new(), transforms: storage_buffer("solari_transforms"), previous_frame_transforms: storage_buffer("solari_previous_frame_transforms"), geometry_ids: storage_buffer("solari_geometry_ids"), @@ -467,20 +471,32 @@ impl InstanceState { tape_id: AssetId, instance: &mut Instance, ) -> bool { - bevy_log::debug!("Resolving tape instance {tape_id}"); + bevy_log::info!("Resolving tape instance {tape_id}"); let slot = instance.slot; - let (Some(aabb_slice), Some(material_slot), Some(blas_address)) = ( + let (Some(aabb_slice), Some(metadata_slice), Some(material_slot), Some(blas_address)) = ( inputs.tape_allocator.tape_aabb_slice(&tape_id), + inputs.tape_allocator.tape_metadata_slice(&tape_id), inputs.assets.material_slots.get(&instance.material), inputs.tape_blas_manager.device_address(&tape_id), ) else { + bevy_log::info!("Deactivating tape instance {tape_id}"); self.deactivate_instance(lights, entity, instance); return false; }; + bevy_log::info!("Tape {tape_id} aabb_slice: {:?}", aabb_slice.range); + bevy_log::info!("Tape {tape_id} metadata_slice: {:?}", metadata_slice.range); + bevy_log::info!("Tape {tape_id} material_slot: {material_slot}"); + bevy_log::info!("Tape {tape_id} blas_address: {blas_address}"); + let aabb_buffer_key = aabb_slice.buffer.id(); + let metadata_buffer_key = metadata_slice.buffer.id(); let capacity = MAX_TAPE_SLAB_COUNT.get(); - if !self.aabb_buffers.has_room(&aabb_buffer_key, capacity) { + if !self.aabb_buffers.has_room(&aabb_buffer_key, capacity) + || !self + .tape_metadata_buffers + .has_room(&metadata_buffer_key, capacity) + { once!(warn!( "Solari scene needs more than {} tape slabs. Instances past that limit will not \ be rendered.", @@ -495,7 +511,13 @@ impl InstanceState { .aabb_buffers .acquire(aabb_buffer_key, capacity, || aabb_slice.buffer.clone()) .expect("aabb slab binding array had room but handed out no slot"); - instance.buffers = Some((aabb_buffer_key, aabb_buffer_key)); + let metadata_buffer_id = self + .tape_metadata_buffers + .acquire(metadata_buffer_key, capacity, || { + metadata_slice.buffer.clone() + }) + .expect("tape metadata slab binding array had room but handed out no slot"); + instance.buffers = Some((aabb_buffer_key, metadata_buffer_key)); self.release_tape_buffers(previous_buffers); let aabb_count = (aabb_slice.range.len()) as u32; @@ -505,6 +527,8 @@ impl InstanceState { aabb_buffer_id, aabb_buffer_offset: aabb_slice.range.start, aabb_count, + metadata_buffer_id, + metadata_buffer_offset: metadata_slice.range.start, }, ); self.material_ids.grow_and_set(slot, material_slot); @@ -525,6 +549,8 @@ impl InstanceState { } */ + bevy_log::info!("Tape {tape_id} resolved"); + true } @@ -583,8 +609,9 @@ impl InstanceState { } fn release_tape_buffers(&mut self, buffers: Option<(BufferId, BufferId)>) { - if let Some((aabb_key, _)) = buffers { + if let Some((aabb_key, metadata_key)) = buffers { self.aabb_buffers.release(&aabb_key); + self.tape_metadata_buffers.release(&metadata_key); } } diff --git a/crates/bevy_tape_drive_solari/src/scene/binder/mod.rs b/crates/bevy_tape_drive_solari/src/scene/binder/mod.rs index 7035049..efde13b 100644 --- a/crates/bevy_tape_drive_solari/src/scene/binder/mod.rs +++ b/crates/bevy_tape_drive_solari/src/scene/binder/mod.rs @@ -42,6 +42,7 @@ use super::{ RaytracingMesh3d, Tape3d, extract::StandardMaterialAssets, meshes::blas::BlasManager as MeshBlasManager, tapes::blas::BlasManager as TapeBlasManager, }; +use crate::scene::binder::instances::MAX_TAPE_SLAB_COUNT; /// Insert this resource into the render world to make the raytracing scene /// retain the previous frame's TLAS and the light id translation table that @@ -86,7 +87,8 @@ impl FromWorld for RaytracingSceneBindings { ( storage_buffer_read_only_sized(false, None).count(MAX_MESH_SLAB_COUNT), storage_buffer_read_only_sized(false, None).count(MAX_MESH_SLAB_COUNT), - storage_buffer_read_only_sized(false, None).count(MAX_MESH_SLAB_COUNT), + storage_buffer_read_only_sized(false, None).count(MAX_TAPE_SLAB_COUNT), + storage_buffer_read_only_sized(false, None).count(MAX_TAPE_SLAB_COUNT), texture_2d(TextureSampleType::Float { filterable: true }) .count(MAX_TEXTURE_COUNT), sampler(SamplerBindingType::Filtering).count(MAX_TEXTURE_COUNT), diff --git a/crates/bevy_tape_drive_solari/src/scene/bindings.wesl b/crates/bevy_tape_drive_solari/src/scene/bindings.wesl index 684d55c..a92c1f4 100644 --- a/crates/bevy_tape_drive_solari/src/scene/bindings.wesl +++ b/crates/bevy_tape_drive_solari/src/scene/bindings.wesl @@ -1,5 +1,7 @@ import bevy_pbr::render::pbr_functions::calculate_tbn_mikktspace; import bevy_render::maths::affine3_to_square; +import bevy_tape_load::render::metadata_types::TapeMetadata; +import bevy_tape_load::render::aabb::PackedAabb; enable wgpu_ray_query; enable wgpu_binding_array; @@ -16,13 +18,25 @@ struct InstanceTapeIds { aabb_buffer_id: u32, aabb_buffer_offset: u32, aabb_count: u32, + metadata_buffer_id: u32, + metadata_buffer_offset: u32, } -struct VertexBuffer { vertices: array } +struct VertexBuffer { + vertices: array, +} -struct IndexBuffer { indices: array } +struct IndexBuffer { + indices: array, +} -struct AabbBuffer { indices: array } +struct AabbBuffer { + indices: array, +} + +struct TapeMetadataBuffer { + indices: array, +} struct PackedVertex { a: vec4, @@ -30,11 +44,6 @@ struct PackedVertex { tangent: vec4, } -struct PackedAabb { - min: vec3, - max: vec3, -} - struct Vertex { position: vec3, normal: vec3, @@ -91,34 +100,63 @@ struct EnvironmentMapLight { const LIGHT_NOT_PRESENT_THIS_FRAME = 0xFFFFFFFFu; -@group(0) @binding(0) var vertex_buffers: binding_array; -@group(0) @binding(1) var index_buffers: binding_array; -@group(0) @binding(2) var aabb_buffers: binding_array; -@group(0) @binding(3) var textures: binding_array>; -@group(0) @binding(4) var samplers: binding_array; -@group(0) @binding(5) var materials: array; -@group(0) @binding(6) var tlas: acceleration_structure; -@group(0) @binding(7) var previous_frame_tlas: acceleration_structure; -@group(0) @binding(8) var transforms: array>; -@group(0) @binding(9) var previous_frame_transforms: array>; -@group(0) @binding(10) var geometry_ids: array; -@group(0) @binding(11) var tape_ids: array; -@group(0) @binding(12) var material_ids: array; -@group(0) @binding(13) var light_sources: array; -@group(0) @binding(14) var directional_lights: array; -@group(0) @binding(15) var previous_frame_light_id_translations: array; -@group(0) @binding(16) var brdf_dfg_lut: texture_2d; -@group(0) @binding(17) var brdf_dfg_lut_sampler: sampler; -@group(0) @binding(18) var environment_map: texture_cube; -@group(0) @binding(19) var environment_map_sampler: sampler; -@group(0) @binding(20) var environment_map_light: EnvironmentMapLight; +@group(0) @binding(0) +var vertex_buffers: binding_array; +@group(0) @binding(1) +var index_buffers: binding_array; +@group(0) @binding(2) +var aabb_buffers: binding_array; +@group(0) @binding(3) +var tape_metadata_buffers: binding_array; +@group(0) @binding(4) +var textures: binding_array>; +@group(0) @binding(5) +var samplers: binding_array; +@group(0) @binding(6) +var materials: array; +@group(0) @binding(7) +var tlas: acceleration_structure; +@group(0) @binding(8) +var previous_frame_tlas: acceleration_structure; +@group(0) @binding(9) +var transforms: array>; +@group(0) @binding(10) +var previous_frame_transforms: array>; +@group(0) @binding(11) +var geometry_ids: array; +@group(0) @binding(12) +var tape_ids: array; +@group(0) @binding(13) +var material_ids: array; +@group(0) @binding(14) +var light_sources: array; +@group(0) @binding(15) +var directional_lights: array; +@group(0) @binding(16) +var previous_frame_light_id_translations: array; +@group(0) @binding(17) +var brdf_dfg_lut: texture_2d; +@group(0) @binding(18) +var brdf_dfg_lut_sampler: sampler; +@group(0) @binding(19) +var environment_map: texture_cube; +@group(0) @binding(20) +var environment_map_sampler: sampler; +@group(0) @binding(21) +var environment_map_light: EnvironmentMapLight; const RAY_T_MIN = 0.001f; const RAY_T_MAX = 100000.0f; const RAY_NO_CULL = 0xFFu; -fn trace_ray(ray_origin: vec3, ray_direction: vec3, ray_t_min: f32, ray_t_max: f32, ray_flag: u32) -> RayIntersection { +fn trace_ray( + ray_origin: vec3, + ray_direction: vec3, + ray_t_min: f32, + ray_t_max: f32, + ray_flag: u32, +) -> RayIntersection { let ray = RayDesc(ray_flag, RAY_NO_CULL, ray_t_min, ray_t_max, ray_origin, ray_direction); var rq: ray_query; rayQueryInitialize(&rq, tlas, ray); @@ -126,7 +164,13 @@ fn trace_ray(ray_origin: vec3, ray_direction: vec3, ray_t_min: f32, ra return rayQueryGetCommittedIntersection(&rq); } -fn trace_ray_previous_frame(ray_origin: vec3, ray_direction: vec3, ray_t_min: f32, ray_t_max: f32, ray_flag: u32) -> RayIntersection { +fn trace_ray_previous_frame( + ray_origin: vec3, + ray_direction: vec3, + ray_t_min: f32, + ray_t_max: f32, + ray_flag: u32, +) -> RayIntersection { let ray = RayDesc(ray_flag, RAY_NO_CULL, ray_t_min, ray_t_max, ray_origin, ray_direction); var rq: ray_query; rayQueryInitialize(&rq, previous_frame_tlas, ray); @@ -188,33 +232,49 @@ fn resolve_material(material: Material, uv: vec2) -> ResolvedMaterial { } fn resolve_ray_hit_full(ray_hit: RayIntersection) -> ResolvedRayHitFull { - let barycentrics = vec3(1.0 - ray_hit.barycentrics.x - ray_hit.barycentrics.y, ray_hit.barycentrics); - return resolve_triangle_data_full(ray_hit.instance_custom_data, ray_hit.primitive_index, barycentrics); + let barycentrics = vec3( + 1.0 - ray_hit.barycentrics.x - ray_hit.barycentrics.y, + ray_hit.barycentrics, + ); + return resolve_triangle_data_full( + ray_hit.instance_custom_data, + ray_hit.primitive_index, + barycentrics, + ); } fn load_vertices(instance_geometry_ids: InstanceGeometryIds, triangle_id: u32) -> array { let index_buffer = &index_buffers[instance_geometry_ids.index_buffer_id].indices; let vertex_buffer = &vertex_buffers[instance_geometry_ids.vertex_buffer_id].vertices; - let indices_i = (triangle_id * 3u) + vec3(0u, 1u, 2u) + instance_geometry_ids.index_buffer_offset; - let indices = vec3((*index_buffer)[indices_i.x], (*index_buffer)[indices_i.y], (*index_buffer)[indices_i.z]) + instance_geometry_ids.vertex_buffer_offset; + let indices_i = (triangle_id * 3u) + vec3(0u, 1u, 2u) + + instance_geometry_ids.index_buffer_offset; + let indices = vec3( + (*index_buffer)[indices_i.x], + (*index_buffer)[indices_i.y], + (*index_buffer)[indices_i.z], + ) + instance_geometry_ids.vertex_buffer_offset; return array( - unpack_vertex((*vertex_buffer)[indices.x]), - unpack_vertex((*vertex_buffer)[indices.y]), - unpack_vertex((*vertex_buffer)[indices.z]) - ); + unpack_vertex((*vertex_buffer)[indices.x]), + unpack_vertex((*vertex_buffer)[indices.y]), + unpack_vertex((*vertex_buffer)[indices.z]), + ); } fn transform_positions(transform: mat4x4, vertices: array) -> array, 3> { return array, 3>( - (transform * vec4(vertices[0].position, 1.0)).xyz, - (transform * vec4(vertices[1].position, 1.0)).xyz, - (transform * vec4(vertices[2].position, 1.0)).xyz - ); + (transform * vec4(vertices[0].position, 1.0)).xyz, + (transform * vec4(vertices[1].position, 1.0)).xyz, + (transform * vec4(vertices[2].position, 1.0)).xyz, + ); } -fn resolve_triangle_data_full(instance_id: u32, triangle_id: u32, barycentrics: vec3) -> ResolvedRayHitFull { +fn resolve_triangle_data_full( + instance_id: u32, + triangle_id: u32, + barycentrics: vec3, +) -> ResolvedRayHitFull { let material_id = material_ids[instance_id]; let material = materials[material_id]; @@ -225,23 +285,51 @@ fn resolve_triangle_data_full(instance_id: u32, triangle_id: u32, barycentrics: let vertices = load_vertices(instance_geometry_ids, triangle_id); let world_vertices = transform_positions(transform, vertices); - let world_position = mat3x3(world_vertices[0], world_vertices[1], world_vertices[2]) * barycentrics; + let world_position = mat3x3( + world_vertices[0], + world_vertices[1], + world_vertices[2], + ) * barycentrics; let previous_frame_world_vertices = transform_positions(previous_frame_transform, vertices); - let previous_frame_world_position = mat3x3(previous_frame_world_vertices[0], previous_frame_world_vertices[1], previous_frame_world_vertices[2]) * barycentrics; + let previous_frame_world_position = mat3x3( + previous_frame_world_vertices[0], + previous_frame_world_vertices[1], + previous_frame_world_vertices[2], + ) * barycentrics; let uv = mat3x2(vertices[0].uv, vertices[1].uv, vertices[2].uv) * barycentrics; - let transform_3x3 = mat3x3(transform[0].xyz, transform[1].xyz, transform[2].xyz); + let transform_3x3 = mat3x3( + transform[0].xyz, + transform[1].xyz, + transform[2].xyz, + ); - let cofactor = mat3x3(cross(transform_3x3[1], transform_3x3[2]), cross(transform_3x3[2], transform_3x3[0]), cross(transform_3x3[0], transform_3x3[1])); + let cofactor = mat3x3( + cross(transform_3x3[1], transform_3x3[2]), + cross(transform_3x3[2], transform_3x3[0]), + cross(transform_3x3[0], transform_3x3[1]), + ); let determinant = dot(transform_3x3[0], cofactor[0]); let determinant_sign = select(sign(determinant), 1.0, determinant == 0.0); - let local_tangent = mat3x3(vertices[0].tangent.xyz, vertices[1].tangent.xyz, vertices[2].tangent.xyz) * barycentrics; - let world_tangent = vec4(normalize(transform_3x3 * local_tangent), vertices[0].tangent.w * determinant_sign); + let local_tangent = mat3x3( + vertices[0].tangent.xyz, + vertices[1].tangent.xyz, + vertices[2].tangent.xyz, + ) * barycentrics; + let world_tangent = vec4( + normalize(transform_3x3 * local_tangent), + vertices[0].tangent.w * determinant_sign, + ); - let local_normal = mat3x3(vertices[0].normal, vertices[1].normal, vertices[2].normal) * barycentrics; // TODO: Use barycentric lerp, ray_hit.object_to_world, cross product geo normal + let local_normal = mat3x3( + vertices[0].normal, + vertices[1].normal, + vertices[2].normal, + ) + * barycentrics; // TODO: Use barycentric lerp, ray_hit.object_to_world, cross product geo normal var world_normal = normalize(determinant_sign * (cofactor * local_normal)); let geometric_world_normal = world_normal; @@ -251,7 +339,9 @@ fn resolve_triangle_data_full(instance_id: u32, triangle_id: u32, barycentrics: let B = TBN[1]; let N = TBN[2]; var Nt = sample_texture(material.normal_map_texture_id, uv) * 2.0 - 1.0; - Nt.z = sqrt(max(1.0 - dot(Nt.xy, Nt.xy), 0.0)); // Reconstruct Z to support two-channel normal maps + Nt.z = sqrt( + max(1.0 - dot(Nt.xy, Nt.xy), 0.0), + ); // Reconstruct Z to support two-channel normal maps world_normal = normalize(Nt.x * T + Nt.y * B + Nt.z * N); } @@ -262,14 +352,14 @@ fn resolve_triangle_data_full(instance_id: u32, triangle_id: u32, barycentrics: let resolved_material = resolve_material(material, uv); return ResolvedRayHitFull( - world_position, - previous_frame_world_position, - world_normal, - geometric_world_normal, - world_tangent, - uv, - triangle_area, - instance_geometry_ids.triangle_count, - resolved_material, - ); + world_position, + previous_frame_world_position, + world_normal, + geometric_world_normal, + world_tangent, + uv, + triangle_area, + instance_geometry_ids.triangle_count, + resolved_material, + ); } diff --git a/crates/bevy_tape_load/Cargo.toml b/crates/bevy_tape_load/Cargo.toml index 4e2a563..99bfd53 100644 --- a/crates/bevy_tape_load/Cargo.toml +++ b/crates/bevy_tape_load/Cargo.toml @@ -16,7 +16,6 @@ bevy_core_pipeline = { git = "https://github.com/bevyengine/bevy.git", rev = "0f bevy_derive = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_diagnostic = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_ecs = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } -bevy_image = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_light = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_log = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_math = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } @@ -30,7 +29,8 @@ bevy_platform = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358 ] } bevy_reflect = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_render = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", features = [ - "spirv_shader_passthrough", + "shader_format_spirv", + #"spirv_shader_passthrough", ] } bevy_shader = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } bevy_shape = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", features = [ @@ -40,7 +40,7 @@ bevy_transform = { git = "https://github.com/bevyengine/bevy.git", rev = "0f3835 bevy_utils = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" } # tape drive -tape-load = { git = "https://git.stargaze.group/molive/tape-drive.git", rev = "19b241637be770db5ee6201951138f41b1f9f467", features = [ +tape-load = { git = "https://git.stargaze.group/molive/tape-drive.git", rev = "b7f83169e28105693203ec97cbe26d3b29b60cec", features = [ "bevy", ] } rspirv = "0.13" diff --git a/crates/bevy_tape_load/build.rs b/crates/bevy_tape_load/build.rs new file mode 100644 index 0000000..2cfbe67 --- /dev/null +++ b/crates/bevy_tape_load/build.rs @@ -0,0 +1,30 @@ +use std::{fs::read_dir, process::Command}; + +fn main() { + //let mut output = std::fs::File::create("output.txt").unwrap(); + println!("cargo::rerun-if-changed=build.rs"); + println!("cargo::rerun-if-changed=Cargo.lock"); + println!("cargo::rerun-if-changed=compile_shaders.py"); + + let paths = read_dir("shaders/include") + .unwrap() + .chain(read_dir("shaders/replacement").unwrap()); + for path in paths { + if let Ok(path) = path + && path + .path() + .extension() + .map(|ext| ext == "glsl") + .unwrap_or(false) + { + println!("cargo::rerun-if-changed={}", path.path().display()); + //writeln!(output, "cargo::rerun-if-changed={}", + // path.path().display()).unwrap(); + } + } + + Command::new("python3") + .arg("compile_shaders.py") + .status() + .expect("Failed to assemble header shaders"); +} diff --git a/crates/bevy_tape_load/compile_shaders.py b/crates/bevy_tape_load/compile_shaders.py new file mode 100755 index 0000000..49270b8 --- /dev/null +++ b/crates/bevy_tape_load/compile_shaders.py @@ -0,0 +1,111 @@ +#!/bin/python3 + +import shutil +import os +import sys +import subprocess +import re + +TARGET_ENV = "vulkan1.3" +SHADERS_OUT = "shaders_out" +SHADERS_BASE = "shaders" +SHADERS_INCLUDE = f"{SHADERS_BASE}/include" +#SHADERS_IN_NORMAL = f"{SHADERS_BASE}/normal" +SHADERS_IN_REPLACEMENT = f"{SHADERS_BASE}/replacement" +#SHADERS_OUT_NORMAL = f"{SHADERS_OUT}/normal" +SHADERS_OUT_REPLACEMENT = f"{SHADERS_OUT}/replacement" + +DUMP_DISASSEMBLIES = True + +if os.path.isdir(SHADERS_OUT): + shutil.rmtree(SHADERS_OUT) +os.mkdir(SHADERS_OUT) +#os.mkdir(SHADERS_OUT_NORMAL) +os.mkdir(SHADERS_OUT_REPLACEMENT) + +# normal_shaders = [f for f in os.listdir(SHADERS_IN_NORMAL) if f.endswith(".glsl")] +# +# for shader in normal_shaders: +# result = subprocess.run( +# [ +# "glslangValidator", +# f"-I{SHADERS_INCLUDE}", +# "--spirv-val", +# "-gVS", +# # "-q", +# "--target-env", +# TARGET_ENV, +# "-o", +# f"{SHADERS_OUT_NORMAL}/{shader}.spv", +# f"{SHADERS_IN_NORMAL}/{shader}", +# ] +# ) +# if result.returncode != 0: +# sys.exit(result.returncode) + +replacement_shaders = [ + f for f in os.listdir(SHADERS_IN_REPLACEMENT) if f.endswith(".glsl") +] + +for shader in replacement_shaders: + print(f"{SHADERS_IN_REPLACEMENT}/{shader}") + result = subprocess.run( + [ + "glslangValidator", + f"-I{SHADERS_INCLUDE}", + "--spirv-val", + "--spirv-dis", + "-g", + "--target-env", + TARGET_ENV, + "--quiet", + f"{SHADERS_IN_REPLACEMENT}/{shader}", + ], + capture_output=True, + text=True, + ) + if result.returncode != 0: + print(result.stdout) + sys.exit(result.returncode) + asm = result.stdout + + if DUMP_DISASSEMBLIES: + with open(f"{SHADERS_OUT_REPLACEMENT}/{shader}.stage0.spv-dis", "w") as f: + f.write(asm) + + asm = re.sub(r"(?ms)%scene_vf4_ =.*?OpFunctionEnd", "", asm) + asm = re.sub(r"%scene_vf4_", "%10000", asm) + asm = re.sub(r"(?ms)%interval_scene_vf4_vf4_ =.*?OpFunctionEnd", "", asm) + asm = re.sub(r"%interval_scene_vf4_vf4_", "%20000", asm) + asm = re.sub(r"(?ms)%gradient_scene_vf4_ =.*?OpFunctionEnd", "", asm) + asm = re.sub(r"%gradient_scene_vf4_", "%30000", asm) + + asm = re.sub(r"OpName %scene_input_one \"scene_input_one\"", "", asm) + asm = re.sub(r"OpName %interval_scene_input_one \"interval_scene_input_one\"", "", asm) + asm = re.sub(r"OpName %interval_scene_input_two \"interval_scene_input_two\"", "", asm) + asm = re.sub(r"OpName %gradient_scene_input_one \"gradient_scene_input_one\"", "", asm) + + if DUMP_DISASSEMBLIES: + with open(f"{SHADERS_OUT_REPLACEMENT}/{shader}.stage1.spv-dis", "w") as f: + f.write(asm) + + result = subprocess.run( + [ + "spirv-as", + "--preserve-numeric-ids", + "--target-env", + TARGET_ENV, + "-o", + f"{SHADERS_OUT_REPLACEMENT}/{shader}.spv", + "-", + ], + input=asm, + encoding="ascii", + ) + if result.returncode != 0: + sys.exit(result.returncode) + +for f in os.listdir("."): + if f.endswith(".spv"): + print(f"removing {f}") + os.remove(f) diff --git a/crates/bevy_tape_load/shaders/include/implicit_include.glsl b/crates/bevy_tape_load/shaders/include/implicit_include.glsl new file mode 100644 index 0000000..b514566 --- /dev/null +++ b/crates/bevy_tape_load/shaders/include/implicit_include.glsl @@ -0,0 +1,18 @@ +#ifndef implicit_include +#define implicit_include + +#extension GL_GOOGLE_include_directive : require + +float scene(vec4 scene_input_one) { + return 0.0; +} + +vec2 interval_scene(vec4 interval_scene_input_one, vec4 interval_scene_input_two) { + return vec2(0.0); +} + +vec4 gradient_scene(vec4 gradient_scene_input_one) { + return vec4(0.0); +} + +#endif diff --git a/crates/bevy_tape_load/shaders/replacement/enable_gen.comp.glsl b/crates/bevy_tape_load/shaders/replacement/enable_gen.comp.glsl new file mode 100644 index 0000000..8deeeea --- /dev/null +++ b/crates/bevy_tape_load/shaders/replacement/enable_gen.comp.glsl @@ -0,0 +1,102 @@ +#version 460 +#extension GL_GOOGLE_include_directive : require +#extension GL_EXT_buffer_reference : require +#include "implicit_include.glsl" + +struct PackedAabb { + float min_x; + float min_y; + float min_z; + float max_x; + float max_y; + float max_z; +}; + +layout(std430, buffer_reference, buffer_reference_align = 8) writeonly buffer AabbBuffer { + PackedAabb aabbs[]; +}; + +struct TapeMetadata { + vec3 lowest_corner; + uint pad_a; + vec3 dimensions; + uint pad_b; + uint subdivision_log2; +}; + +layout(std430, buffer_reference, buffer_reference_align = 8) readonly buffer TapeMetadataBuffer { + TapeMetadata metadata[]; +}; + +struct InstanceTapeIds { + uint aabb_buffer_id; + uint aabb_buffer_offset; + uint aabb_count; + uint metadata_buffer_id; + uint metadata_buffer_offset; +}; + +layout(set = 0, binding = 0, std430) restrict readonly buffer AabbBufferArray { + AabbBuffer buffers[]; +} aabb_buffers; +layout(set = 0, binding = 1, std430) restrict readonly buffer TapeMetadataBufferArray { + TapeMetadataBuffer buffers[]; +} tape_metadata_buffers; +layout(set = 0, binding = 2, std430) restrict readonly buffer InstanceTapeIdsArray { + InstanceTapeIds ids[]; +} tape_ids; + +layout(push_constant, std430) uniform PushConstantData { + uint object_index; + float time; +} pc; + +layout(local_size_x = 8, local_size_y = 8, local_size_z = 8) in; + +const float NAN = 0.0 / 0.0; + +void main() { + //if (SPEC_BRUTE_FORCE) { + // return; + //} + + InstanceTapeIds instance = tape_ids.ids[pc.object_index]; + TapeMetadata metadata = tape_metadata_buffers.buffers[instance.metadata_buffer_id].metadata[instance.metadata_buffer_offset]; + AabbBuffer aabb_buffer = aabb_buffers.buffers[instance.aabb_buffer_id]; + + uvec3 total_invocations = gl_NumWorkGroups * gl_WorkGroupSize; + uint base_index = (gl_GlobalInvocationID.z * total_invocations.x * total_invocations.y) + + (gl_GlobalInvocationID.y * total_invocations.x) + gl_GlobalInvocationID.x; + + vec3 internal_pos = vec3( + float((base_index >> (metadata.subdivision_log2 * 2)) & ((1 << metadata.subdivision_log2) - 1)) + / float(1 << metadata.subdivision_log2), + float((base_index >> (metadata.subdivision_log2 * 1)) & ((1 << metadata.subdivision_log2) - 1)) + / float(1 << metadata.subdivision_log2), + float((base_index >> (metadata.subdivision_log2 * 0)) & ((1 << metadata.subdivision_log2) - 1)) + / float(1 << metadata.subdivision_log2) + ); + + vec3 low_corner = (((vec3(0.0) / float(1 << metadata.subdivision_log2)) + internal_pos) + * metadata.dimensions) + metadata.lowest_corner; + vec3 high_corner = (((vec3(1.0) / float(1 << metadata.subdivision_log2)) + internal_pos) + * metadata.dimensions) + metadata.lowest_corner; + + vec2 interval = interval_scene( + vec4(low_corner, pc.time), + vec4(high_corner, pc.time) + ); + + bool enable = (interval.x < 0) && (interval.y > 0); + + if (enable) { + aabb_buffer.aabbs[instance.aabb_buffer_offset].min_x = low_corner.x; + aabb_buffer.aabbs[instance.aabb_buffer_offset].min_y = low_corner.y; + aabb_buffer.aabbs[instance.aabb_buffer_offset].min_z = low_corner.z; + aabb_buffer.aabbs[instance.aabb_buffer_offset].max_x = high_corner.x; + aabb_buffer.aabbs[instance.aabb_buffer_offset].max_y = high_corner.y; + aabb_buffer.aabbs[instance.aabb_buffer_offset].max_z = high_corner.z; + } else { + aabb_buffer.aabbs[instance.aabb_buffer_offset].min_x = NAN; + } +} diff --git a/crates/bevy_tape_load/shaders/replacement/enable_gen.wesl b/crates/bevy_tape_load/shaders/replacement/enable_gen.wesl new file mode 100644 index 0000000..33e5bf1 --- /dev/null +++ b/crates/bevy_tape_load/shaders/replacement/enable_gen.wesl @@ -0,0 +1,87 @@ +import bevy_tape_load::render::aabb; +import bevy_tape_load::render::metadata_types; +import bevy_tape_load::render::implicit; + +enable wgpu_binding_array; + +struct AabbBuffer { + aabbs: array, +} +struct TapeMetadataBuffer { + metadata: array, +} +struct PushConstants { + object_index: u32, + time: f32, +} + +struct InstanceTapeIds { + aabb_buffer_id: u32, + aabb_buffer_offset: u32, + aabb_count: u32, + metadata_buffer_id: u32, + metadata_buffer_offset: u32, +} + +@group(0) @binding(0) +var aabb_buffers: binding_array; +@group(0) @binding(1) +var tape_metadata_buffers: binding_array; +@group(0) @binding(2) +var tape_ids: array; + +var push_constants: PushConstants; + +struct ComputeInput { + @builtin(global_invocation_id) global_invocation_id: vec3u, + @builtin(num_workgroups) num_workgroups: vec3u, + @builtin(workgroup_id) workgroup_id: vec3u, +} + +const NAN: f32 = 0.0 / 0.0; + +@compute @workgroup_size(8, 8, 8) +fn enable_gen_entry(compute_input: ComputeInput) { + let instance = tape_ids[push_constants.object_index]; + let metadata = tape_metadata_buffers[instance.metadata_buffer_id].metadata[ + instance.metadata_buffer_offset + ]; + + let total_invocations = compute_input.num_workgroups * vec3u(8); + let base_index = + (((compute_input.global_invocation_id.z * total_invocations.y) + + compute_input.global_invocation_id.y) * total_invocations.x) + + compute_input.global_invocation_id.x; + + let internal_pos = vec3( + ((base_index >> (metadata.subdivision_log2 * 2)) + & ((1 << metadata.subdivision_log2) - 1)) / (1 << metadata.subdivision_log2), + ((base_index >> (metadata.subdivision_log2 * 1)) + & ((1 << metadata.subdivision_log2) - 1)) / (1 << metadata.subdivision_log2), + ((base_index >> (metadata.subdivision_log2 * 0)) + & ((1 << metadata.subdivision_log2) - 1)) / (1 << metadata.subdivision_log2), + ); + + let low_corner = + (((vec3(0.0) / (1 << metadata.subdivision_log2)) + internal_pos) * metadata.dimensions) + + metadata.lowest_corner; + let high_corner = + (((vec3(1.0) / (1 << metadata.subdivision_log2)) + internal_pos) * metadata.dimensions) + + metadata.lowest_corner; + + let interval = interval_scene( + vec4(low_corner, push_constants.time), + vec4(high_corner, push_constants.time), + ); + + let aabb = &aabb_buffers[instance.aabb_buffer_id].aabbs[instance.aabb_buffer_offset]; + + let en = (interval.x < 0) && (interval.y > 0); + + if en { + aabb.min = low_corner; + aabb.max = high_corner; + } else { + aabb.min.x = NAN; + } +} diff --git a/crates/bevy_tape_load/src/render/aabb.wesl b/crates/bevy_tape_load/src/render/aabb.wesl new file mode 100644 index 0000000..14e0788 --- /dev/null +++ b/crates/bevy_tape_load/src/render/aabb.wesl @@ -0,0 +1,5 @@ + +struct PackedAabb { + min: vec3, + max: vec3, +} diff --git a/crates/bevy_tape_load/src/render/allocator.rs b/crates/bevy_tape_load/src/render/allocator.rs index a85ee5c..21565f7 100644 --- a/crates/bevy_tape_load/src/render/allocator.rs +++ b/crates/bevy_tape_load/src/render/allocator.rs @@ -395,6 +395,7 @@ impl TapeAllocator { TapeMetadata { aabb_center, aabb_half_extents, + subdivision_log2: tape.subdivision.ilog2(), ..Default::default() } }; diff --git a/crates/bevy_tape_load/src/render/implicit.wesl b/crates/bevy_tape_load/src/render/implicit.wesl new file mode 100644 index 0000000..6444dd9 --- /dev/null +++ b/crates/bevy_tape_load/src/render/implicit.wesl @@ -0,0 +1,13 @@ +// These functions will be overwritten + +fn scene(p: vec4) -> f32 { + return 0.0; +} + +fn interval_scene(pl: vec4, ph: vec4) -> vec2 { + return vec2(0.0); +} + +fn gradient_scene(p: vec4) -> vec4 { + return vec4(0.0); +} diff --git a/crates/bevy_tape_load/src/render/metadata_types.wesl b/crates/bevy_tape_load/src/render/metadata_types.wesl index 307eb80..63c77e1 100644 --- a/crates/bevy_tape_load/src/render/metadata_types.wesl +++ b/crates/bevy_tape_load/src/render/metadata_types.wesl @@ -5,4 +5,5 @@ struct TapeMetadata { pad_a: u32, aabb_half_extents: vec3, pad_b: u32, + subdivision_log2: u32, }; diff --git a/crates/bevy_tape_load/src/render/mod.rs b/crates/bevy_tape_load/src/render/mod.rs index 203299c..7beff25 100644 --- a/crates/bevy_tape_load/src/render/mod.rs +++ b/crates/bevy_tape_load/src/render/mod.rs @@ -5,7 +5,7 @@ pub mod allocator; use allocator::TapeAllocatorPlugin; use bevy_app::{App, Plugin}; -use bevy_asset::{AssetId, AssetServer, Assets, Handle}; +use bevy_asset::{AssetId, AssetServer, Assets, Handle, load_embedded_asset}; use bevy_ecs::{ prelude::*, system::{SystemParamItem, lifetimeless::SRes}, @@ -25,19 +25,31 @@ use bevy_render::{ use bevy_shader::{Shader, load_shader_library}; use bytemuck::{Pod, Zeroable}; use rspirv::dr::Module; +use wgpu::{ShaderModuleDescriptor, ShaderSource, include_spirv}; use crate::{ render::allocator::{ElementClass, TapeAllocationKey, TapeAllocator, TapeSlabId}, tape::Tape, }; +fn get_module(shader: ShaderModuleDescriptor) -> Module { + let ShaderSource::SpirV(source) = shader.source else { + unreachable!() + }; + let mut loader = rspirv::dr::Loader::new(); + rspirv::binary::parse_words(source, &mut loader).unwrap(); + loader.module() +} + /// Makes sure that [`Tape`]es are extracted and prepared for the GPU. /// Does *not* add the [`Tape`] as an asset. Use [`TapePlugin`] for that. pub struct TapeRenderAssetPlugin; impl Plugin for TapeRenderAssetPlugin { fn build(&self, app: &mut App) { + load_shader_library!(app, "aabb.wesl"); load_shader_library!(app, "metadata_types.wesl"); + load_shader_library!(app, "implicit.wesl"); app.add_plugins(RenderAssetPlugin::::default()) .add_plugins(TapeAllocatorPlugin); @@ -46,6 +58,19 @@ impl Plugin for TapeRenderAssetPlugin { return; }; + let enable_gen = include_spirv!("../../shaders_out/replacement/enable_gen.comp.glsl.spv"); + + render_app.insert_resource(ReplacementModules { + enable_gen: get_module(enable_gen.clone()), + fuzz: get_module(enable_gen.clone()), + normals: get_module(enable_gen.clone()), + spatial_texture: get_module(enable_gen.clone()), + trace: get_module(enable_gen.clone()), + enable_gen_layout: BindGroupLayoutDescriptor::new("Enable Gen Layout", &[]), + fuzz_layout: BindGroupLayoutDescriptor::new("Tape Fuzz Layout", &[]), + spatial_texture_layout: BindGroupLayoutDescriptor::new("Spatial Texture Layout", &[]), + }); + render_app.add_systems( Render, prepare_tape_metadata_fallback_buffer @@ -128,6 +153,7 @@ pub struct TapeMetadata { // AABB for decompressing positions. pub aabb_half_extents: Vec3, pub pad2: u32, + pub subdivision_log2: u32, } /// The render world representation of a [`Tape`]. @@ -207,7 +233,7 @@ impl RenderAsset for RenderTape { label: Some(format!("bevy_tape_drive::gen_shader::enable_gen::{key}").into()), layout: vec![replacement_modules.enable_gen_layout.clone()], shader: enable_gen.clone(), - entry_point: Some("enable_gen_entry".into()), + entry_point: Some("main".into()), ..Default::default() }); @@ -215,7 +241,7 @@ impl RenderAsset for RenderTape { label: Some(format!("bevy_tape_drive::gen_shader::fuzz::{key}").into()), layout: vec![replacement_modules.fuzz_layout.clone()], shader: fuzz.clone(), - entry_point: Some("fuzz_entry".into()), + entry_point: Some("main".into()), ..Default::default() }); @@ -224,7 +250,7 @@ impl RenderAsset for RenderTape { label: Some(format!("bevy_tape_drive::gen_shader::spatial_texture::{key}").into()), layout: vec![replacement_modules.spatial_texture_layout.clone()], shader: spatial_texture.clone(), - entry_point: Some("spatial_texture_entry".into()), + entry_point: Some("main".into()), ..Default::default() }); diff --git a/crates/bevy_tape_load/src/tape.rs b/crates/bevy_tape_load/src/tape.rs index b3dcab1..e8092f5 100644 --- a/crates/bevy_tape_load/src/tape.rs +++ b/crates/bevy_tape_load/src/tape.rs @@ -65,6 +65,9 @@ impl Tape { let path = format!("bevy_tape_drive::gen_shader::{name}::{key}"); + std::fs::create_dir_all("shader_debug").unwrap(); + std::fs::write(format!("shader_debug/{}_{}.spv", name, key), &bytes).unwrap(); + Shader::from_spirv(bytes, path) } }