split into two crates

This commit is contained in:
2026-10-02 18:01:02 +01:00
parent 10ca25b695
commit 663f67ae3c
55 changed files with 8405 additions and 614 deletions
Generated
+292 -61
View File
@@ -250,6 +250,12 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "anyhow"
version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
[[package]]
name = "approx"
version = "0.5.1"
@@ -272,7 +278,7 @@ dependencies = [
"objc2-foundation 0.3.2",
"parking_lot",
"percent-encoding",
"windows-sys 0.60.2",
"windows-sys 0.52.0",
"wl-clipboard-rs",
"x11rb",
]
@@ -467,6 +473,12 @@ version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
[[package]]
name = "base64"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
[[package]]
name = "base64"
version = "0.23.1"
@@ -1056,7 +1068,7 @@ version = "0.20.0-dev"
source = "git+https://github.com/bevyengine/bevy.git?rev=0f38358f573a7dc6ea961076f6151be662142010#0f38358f573a7dc6ea961076f6151be662142010"
dependencies = [
"async-lock",
"base64",
"base64 0.23.1",
"bevy_animation",
"bevy_app",
"bevy_asset",
@@ -1304,7 +1316,7 @@ dependencies = [
"approx",
"bevy_reflect",
"derive_more",
"glam 0.33.11",
"glam",
"libm",
"rand",
"serde",
@@ -1331,7 +1343,7 @@ dependencies = [
"bytemuck",
"derive_more",
"encase",
"glam 0.33.11",
"glam",
"half",
"hexasphere",
"serde",
@@ -1482,7 +1494,7 @@ dependencies = [
"downcast-rs 2.0.2",
"erased-serde",
"foldhash 0.2.0",
"glam 0.33.11",
"glam",
"indexmap",
"inventory",
"petgraph",
@@ -1545,7 +1557,7 @@ dependencies = [
"derive_more",
"downcast-rs 2.0.2",
"encase",
"glam 0.33.11",
"glam",
"image",
"indexmap",
"itertools 0.14.0",
@@ -1729,8 +1741,37 @@ dependencies = [
name = "bevy_tape_drive"
version = "0.20.0-dev"
dependencies = [
"accesskit",
"anyhow",
"argh",
"bevy",
"bevy_tape_drive_solari",
"bevy_tape_load",
"bytemuck",
"chacha20",
"crossbeam-channel",
"event-listener",
"flate2",
"futures-lite",
"futures-timer",
"getrandom 0.4.3",
"gltf",
"indexmap",
"nonmax",
"rand",
"ron",
"serde",
"serde_json",
"thiserror 2.0.21",
"ureq",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "bevy_tape_drive_solari"
version = "0.20.0-dev"
dependencies = [
"bevy_anti_alias",
"bevy_app",
"bevy_asset",
@@ -1751,16 +1792,56 @@ dependencies = [
"bevy_render",
"bevy_shader",
"bevy_shape",
"bevy_tape_load",
"bevy_transform",
"bevy_utils",
"bytemuck",
"derive_more",
"tracing",
"wgpu",
]
[[package]]
name = "bevy_tape_load"
version = "0.20.0-dev"
dependencies = [
"approx",
"bevy_app",
"bevy_asset",
"bevy_camera",
"bevy_color",
"bevy_core_pipeline",
"bevy_derive",
"bevy_diagnostic",
"bevy_ecs",
"bevy_image",
"bevy_light",
"bevy_log",
"bevy_math",
"bevy_mesh",
"bevy_pbr",
"bevy_platform",
"bevy_reflect",
"bevy_render",
"bevy_shader",
"bevy_shape",
"bevy_transform",
"bevy_utils",
"bitflags 2.13.2",
"bytemuck",
"chacha20",
"derive_more",
"rand",
"encase",
"glam",
"half",
"hexasphere",
"rspirv",
"serde",
"serde_json",
"tape-load",
"thiserror 2.0.21",
"tracing",
"wgpu",
"wgpu-types",
]
[[package]]
@@ -2375,6 +2456,35 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "cookie"
version = "0.18.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a373e3602691c3cdea496d2f0ee5935151e6168fe87739483c463db1b2f2f87"
dependencies = [
"percent-encoding",
"time",
"version_check",
]
[[package]]
name = "cookie_store"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15b2c103cf610ec6cae3da84a766285b42fd16aad564758459e6ecf128c75206"
dependencies = [
"cookie",
"document-features",
"idna",
"indexmap",
"log",
"serde",
"serde_derive",
"serde_json",
"time",
"url",
]
[[package]]
name = "core-foundation"
version = "0.9.4"
@@ -2565,6 +2675,12 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
[[package]]
name = "deranged"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
[[package]]
name = "derive_more"
version = "2.1.1"
@@ -2754,7 +2870,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.61.2",
"windows-sys 0.52.0",
]
[[package]]
@@ -2907,6 +3023,15 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
[[package]]
name = "form_urlencoded"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
dependencies = [
"percent-encoding",
]
[[package]]
name = "fsevent-sys"
version = "4.1.0"
@@ -2973,6 +3098,16 @@ version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
[[package]]
name = "futures-timer"
version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af43fadb8a98512d547e37b4e92e0ced13e205c061b87b4623eff01d918d6968"
dependencies = [
"gloo-timers",
"send_wrapper",
]
[[package]]
name = "futures-util"
version = "0.3.34"
@@ -3036,9 +3171,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"r-efi 6.0.0",
"rand_core",
"wasm-bindgen",
]
[[package]]
@@ -3088,15 +3225,9 @@ dependencies = [
[[package]]
name = "glam"
version = "0.30.10"
version = "0.33.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19fc433e8437a212d1b6f1e68c7824af3aed907da60afa994e7f542d18d12aa9"
[[package]]
name = "glam"
version = "0.33.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35b4e837a1d133645d1dcf283e146a4b9901e390a1c13545f959cfed3a72f24f"
checksum = "37bfe73dc8ec21f54d181e5a60554327ec3f1c600c455a75ccbfc65d2106a6c4"
dependencies = [
"approx",
"bytemuck",
@@ -3112,6 +3243,18 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
[[package]]
name = "gloo-timers"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "482ce8a491a501da4cd806bd190275363d674f2845005c6ddbd5d3e1dd54495d"
dependencies = [
"futures-channel",
"futures-core",
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "glow"
version = "0.17.0"
@@ -3130,10 +3273,13 @@ version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3ce1918195723ce6ac74e80542c5a96a40c2b26162c1957a5cd70799b8cacf7"
dependencies = [
"base64 0.13.1",
"byteorder",
"gltf-json",
"image",
"lazy_static",
"serde_json",
"urlencoding",
]
[[package]]
@@ -3283,7 +3429,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "163385eff5a0cf606ebe2c10b3a44ab02f4306e83fbd068a64f5e1d72a3049ac"
dependencies = [
"constgebra",
"glam 0.33.11",
"glam",
"tinyvec",
]
@@ -3437,6 +3583,27 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae293c039020f9ec10710af98d29ce6aa2051486638b49c9a6409f3b4a9e98ad"
[[package]]
name = "idna"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
dependencies = [
"idna_adapter",
"smallvec",
"utf8_iter",
]
[[package]]
name = "idna_adapter"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714"
dependencies = [
"icu_normalizer",
"icu_properties",
]
[[package]]
name = "image"
version = "0.25.10"
@@ -3448,6 +3615,8 @@ dependencies = [
"moxcms",
"num-traits",
"png",
"zune-core",
"zune-jpeg",
]
[[package]]
@@ -3709,9 +3878,9 @@ dependencies = [
[[package]]
name = "lazy_static"
version = "1.5.0"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
[[package]]
name = "lewton"
@@ -4020,7 +4189,7 @@ dependencies = [
"once_cell",
"petgraph",
"rustc-hash 1.1.0",
"spirv 0.4.0+sdk-1.4.341.0",
"spirv",
"thiserror 2.0.21",
"unicode-ident",
]
@@ -4179,6 +4348,12 @@ dependencies = [
"num-traits",
]
[[package]]
name = "num-conv"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"
[[package]]
name = "num-derive"
version = "0.4.2"
@@ -4664,7 +4839,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
dependencies = [
"libc",
"windows-sys 0.61.2",
"windows-sys 0.52.0",
]
[[package]]
@@ -4868,6 +5043,12 @@ dependencies = [
"zerovec",
]
[[package]]
name = "powerfmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "precomputed-hash"
version = "0.1.1"
@@ -5136,12 +5317,12 @@ dependencies = [
[[package]]
name = "rspirv"
version = "0.12.0+sdk-1.3.268.0"
version = "0.13.0+sdk-1.4.341.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cf3a93856b6e5946537278df0d3075596371b1950ccff012f02b0f7eafec8d"
checksum = "091dca2e1d6fd3098417b5ec88e77e80d1ba5945750943419dc976858082c296"
dependencies = [
"rustc-hash 1.1.0",
"spirv 0.3.0+sdk-1.3.268.0",
"spirv",
]
[[package]]
@@ -5175,7 +5356,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.4.15",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@@ -5188,7 +5369,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.12.1",
"windows-sys 0.61.2",
"windows-sys 0.52.0",
]
[[package]]
@@ -5245,7 +5426,7 @@ dependencies = [
"security-framework",
"security-framework-sys",
"webpki-root-certs",
"windows-sys 0.61.2",
"windows-sys 0.52.0",
]
[[package]]
@@ -5528,15 +5709,6 @@ dependencies = [
"portable-atomic",
]
[[package]]
name = "spirv"
version = "0.3.0+sdk-1.3.268.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844"
dependencies = [
"bitflags 2.13.2",
]
[[package]]
name = "spirv"
version = "0.4.0+sdk-1.4.341.0"
@@ -5670,10 +5842,11 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "tape-load"
version = "0.1.0"
source = "git+https://git.stargaze.group/molive/tape-drive.git?rev=45762855bca8772798242a545cdee21afbec2828#45762855bca8772798242a545cdee21afbec2828"
source = "git+https://git.stargaze.group/molive/tape-drive.git?rev=19b241637be770db5ee6201951138f41b1f9f467#19b241637be770db5ee6201951138f41b1f9f467"
dependencies = [
"bevy_reflect",
"foldhash 0.1.5",
"glam 0.30.10",
"glam",
"humantime",
"rspirv",
]
@@ -5745,6 +5918,36 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "time"
version = "0.3.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134"
dependencies = [
"deranged",
"num-conv",
"powerfmt",
"serde_core",
"time-core",
"time-macros",
]
[[package]]
name = "time-core"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109"
[[package]]
name = "time-macros"
version = "0.2.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85"
dependencies = [
"num-conv",
"time-core",
]
[[package]]
name = "tiny-skia"
version = "0.11.4"
@@ -5998,12 +6201,16 @@ version = "3.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a7ac20be9b7726e0bbdbf974c059676d9acb1cd414961f570a4e8231cacd7fc"
dependencies = [
"base64",
"base64 0.23.1",
"cookie_store",
"flate2",
"log",
"percent-encoding",
"rustls",
"rustls-pki-types",
"rustls-platform-verifier",
"serde",
"serde_json",
"ureq-proto",
"utf8-zero",
"webpki-roots",
@@ -6015,12 +6222,30 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f86fd172ccca569e458f61b6bdd6220965a9ef36e672a6852953b51a0e1583be"
dependencies = [
"base64",
"base64 0.23.1",
"http",
"httparse",
"log",
]
[[package]]
name = "url"
version = "2.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
dependencies = [
"form_urlencoded",
"idna",
"percent-encoding",
"serde",
]
[[package]]
name = "urlencoding"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
[[package]]
name = "utf8-zero"
version = "0.8.1"
@@ -6331,9 +6556,9 @@ dependencies = [
[[package]]
name = "wesl"
version = "0.4.4"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb84b87be534d24ac15773f8942ce90a00afe06093025d014c8cfa5277afa25b"
checksum = "8fb1ecb13a378c984af75ed271558f9295c05579554b97d72d9fa0c474af7f8e"
dependencies = [
"annotate-snippets",
"anstream",
@@ -6349,9 +6574,9 @@ dependencies = [
[[package]]
name = "wesl-macros"
version = "0.4.4"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0de205d9eec254c378fa9ab1fd01e84537b6e330063d85fbf9245f65731aced"
checksum = "a8013e38716b704587f72fe8a077528503d18af7240e6a19f6792baff6e16f8d"
dependencies = [
"itertools 0.15.0",
"proc-macro2",
@@ -6533,9 +6758,9 @@ dependencies = [
[[package]]
name = "wgsl-parse"
version = "0.4.4"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c0588236e8f7cd43cd1d88322095d971fba842c7d985f484453461a376a1ce6"
checksum = "37836b24c0b4854f9a6f820585ccd5e02ad917070fe8aa67b697bf96c286ce63"
dependencies = [
"annotate-snippets",
"derive_more",
@@ -6550,9 +6775,9 @@ dependencies = [
[[package]]
name = "wgsl-types"
version = "0.4.4"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5dfc32acf991054fb0290c5fb03d9dae60be8cbc9245c9c26e4420e11e8c0045"
checksum = "8286b1a2ce08736a048da13f6fcdd427c7baf7e3c48e0b5a0c51f954675b2f73"
dependencies = [
"half",
"itertools 0.15.0",
@@ -6581,7 +6806,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.61.2",
"windows-sys 0.52.0",
]
[[package]]
@@ -6709,15 +6934,6 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.60.2"
@@ -7113,9 +7329,9 @@ dependencies = [
[[package]]
name = "yoke-derive"
version = "0.8.3"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33811428bee40dbceb6d545e95754741d17a6aef9a4849f0fd62e2ba4f412a78"
checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71"
dependencies = [
"proc-macro2",
"quote",
@@ -7222,3 +7438,18 @@ name = "zmij"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
[[package]]
name = "zune-core"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b"
[[package]]
name = "zune-jpeg"
version = "0.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296"
dependencies = [
"zune-core",
]
+138 -60
View File
@@ -2,77 +2,155 @@
name = "bevy_tape_drive"
version = "0.20.0-dev"
edition = "2024"
description = "Provides raytraced lighting for Bevy Engine"
homepage = "https://bevy.org"
repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["bevy"]
authors = ["molive <molive@stargaze.group>"]
categories = ["game-engines", "graphics", "rendering"]
description = "Provides Tape Drive support for Bevy"
exclude = ["assets/", "tools/", ".github/", "crates/", "examples/wasm/assets/"]
homepage = "https://mo.molive.live"
keywords = ["graphics", "bevy", "tape-drive"]
license = "Apache-2.0"
repository = "https://git.stargaze.group/molive/bevy-tape-drive"
rust-version = "1.96.0"
[dependencies]
# bevy
bevy_anti_alias = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_app = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_asset = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_camera = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_color = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_core_pipeline = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
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_light = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_log = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_shader = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_math = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_mesh = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_pbr = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", features = [
"dfg_lut",
] }
bevy_platform = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", default-features = false, features = [
"std",
] }
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",
] }
bevy_shape = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_image = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", features = [
"zstd_rust",
] }
bevy_utils = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_transform = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
[workspace]
resolver = "3"
members = [
# All of Bevy's official crates are within the `crates` folder!
"crates/*",
]
# tape drive
tape-load = { git = "https://git.stargaze.group/molive/tape-drive.git", rev = "45762855bca8772798242a545cdee21afbec2828" }
rspirv = "0.12"
[workspace.lints.clippy]
doc_markdown = "warn"
manual_let_else = "warn"
match_same_arms = "warn"
redundant_closure_for_method_calls = "warn"
redundant_else = "warn"
semicolon_if_nothing_returned = "warn"
type_complexity = "allow"
undocumented_unsafe_blocks = "warn"
unwrap_or_default = "warn"
needless_lifetimes = "allow"
too_many_arguments = "allow"
nonstandard_macro_braces = "warn"
print_stdout = "warn"
print_stderr = "warn"
# other
bytemuck = { version = "1" }
derive_more = { version = "2", default-features = false, features = ["from"] }
tracing = { version = "0.1", default-features = false, features = ["std"] }
wgpu = { version = "30", default-features = false }
ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
ref_as_ptr = "warn"
# see: https://github.com/bevyengine/bevy/pull/15375#issuecomment-2366966219
too_long_first_doc_paragraph = "allow"
# currently falsely fires on std::io, even tho core::io is unstable
# https://github.com/rust-lang/rust-clippy/issues/13158#issuecomment-4373196346
std_instead_of_core = "allow"
std_instead_of_alloc = "warn"
alloc_instead_of_core = "warn"
allow_attributes = "warn"
allow_attributes_without_reason = "warn"
[workspace.lints.rust]
# missing_docs = "warn"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
unsafe_code = "deny"
unsafe_op_in_unsafe_fn = "warn"
unused_qualifications = "warn"
# Unfortunately, cargo does not currently support overriding workspace lints
# inside a particular crate. See https://github.com/rust-lang/cargo/issues/13157
#
# We require an override for cases like `std_instead_of_core`, which are intended
# for the library contributors and not for how users should consume Bevy.
# To ensure examples aren't subject to these lints, below is a duplication of the
# workspace lints, with the "overrides" applied.
#
# [lints]
# workspace = true
[lints.clippy]
doc_markdown = "warn"
manual_let_else = "warn"
match_same_arms = "warn"
redundant_closure_for_method_calls = "warn"
redundant_else = "warn"
semicolon_if_nothing_returned = "warn"
type_complexity = "allow"
undocumented_unsafe_blocks = "warn"
unwrap_or_default = "warn"
needless_lifetimes = "allow"
too_many_arguments = "allow"
nonstandard_macro_braces = "warn"
ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
ref_as_ptr = "warn"
too_long_first_doc_paragraph = "allow"
std_instead_of_core = "allow"
std_instead_of_alloc = "allow"
alloc_instead_of_core = "allow"
allow_attributes = "warn"
allow_attributes_without_reason = "warn"
[lints.rust]
missing_docs = "warn"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
unsafe_code = "deny"
unsafe_op_in_unsafe_fn = "warn"
unused_qualifications = "warn"
[features]
dlss = ["bevy_anti_alias/dlss"]
force_disable_dlss = ["bevy_anti_alias/force_disable_dlss"]
# Use `--features dlss` to enable denoising with DLSS Ray Reconstruction in Solari. It
# is off by default because a build with it needs the DLSS SDK.
dlss = ["bevy_tape_drive_solari/dlss"]
force_disable_dlss = ["bevy_tape_drive_solari/force_disable_dlss"]
[package.metadata.docs.rs]
rustdoc-args = [
"-Zunstable-options",
"--generate-link-to-definition",
"--generate-macro-expansion",
]
all-features = true
[dependencies]
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 = [
"default_font",
"https",
"free_camera",
"dev",
] }
# Others
rand = "0.10.0"
chacha20 = { version = "0.10.0", default-features = false, features = ["rng"] }
bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", features = [
"default_font",
"https",
"free_camera",
"dev",
] }
ron = "0.12"
flate2 = "1.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0.140"
bytemuck = "1"
# Needed to poll Task examples
futures-lite = "2.0.1"
futures-timer = { version = "3", features = ["wasm-bindgen", "gloo-timers"] }
crossbeam-channel = "0.5.0"
argh = "0.1.12"
thiserror = "2.0"
event-listener = "5.3.0"
anyhow = "1"
accesskit = "0.25"
nonmax = "0.5"
gltf = "1.4"
indexmap = "2"
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
ureq = { version = "3.0.8", features = ["json"] }
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
getrandom = { version = "0.4", default-features = false, features = [
"wasm_js",
] }
wasm-bindgen = { version = "0.2" }
web-sys = { version = "0.3", features = ["Window"] }
[[example]]
name = "pica_pica"
File diff suppressed because it is too large Load Diff
+72
View File
@@ -0,0 +1,72 @@
[package]
name = "bevy_tape_drive_solari"
version = "0.20.0-dev"
edition = "2024"
description = "Renders tapes with a modified version of Bevy's Solari"
license = "Apache-2.0"
keywords = ["bevy"]
[dependencies]
# bevy
bevy_anti_alias = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_app = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_asset = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_camera = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_color = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_core_pipeline = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
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" }
bevy_mesh = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_pbr = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", features = [
"dfg_lut",
] }
bevy_platform = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", default-features = false, features = [
"std",
] }
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",
] }
bevy_shader = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_shape = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_transform = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_utils = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
# tape load
bevy_tape_load = { path = "../bevy_tape_load", version = "0.20.0-dev" }
# other
bytemuck = { version = "1" }
derive_more = { version = "2", default-features = false, features = ["from"] }
tracing = { version = "0.1", default-features = false, features = ["std"] }
wgpu = { version = "30", default-features = false }
[features]
dlss = ["bevy_anti_alias/dlss"]
force_disable_dlss = ["bevy_anti_alias/force_disable_dlss"]
[lints]
workspace = true
[package.metadata.docs.rs]
rustdoc-args = [
"-Zunstable-options",
"--generate-link-to-definition",
"--generate-macro-expansion",
]
all-features = true
[package.metadata.wgsl-analyzer]
edition = "2026_pre"
root = "src"
[package.metadata.wgsl-analyzer.dependencies]
bevy_render = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_pbr = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_core_pipeline = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
constants = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
+60
View File
@@ -0,0 +1,60 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
//! Provides raytraced lighting.
//!
//! See [`SolariPlugins`] for more info.
//!
//! ![`bevy_solari` logo](https://raw.githubusercontent.com/bevyengine/bevy/refs/heads/main/assets/branding/bevy_solari.svg)
extern crate alloc;
pub mod pathtracer;
pub mod realtime;
pub mod scene;
/// The solari prelude.
///
/// This includes the most common types in this crate, re-exported for your
/// convenience.
pub mod prelude {
pub use super::SolariPlugins;
pub use crate::{realtime::SolariLighting, scene::RaytracingMesh3d};
}
use bevy_app::{PluginGroup, PluginGroupBuilder};
use bevy_render::settings::WgpuFeatures;
use crate::{realtime::SolariLightingPlugin, scene::RaytracingScenePlugin};
/// An experimental set of plugins for raytraced lighting.
///
/// This plugin group provides:
/// * [`SolariLightingPlugin`] - Raytraced direct and indirect lighting.
/// * [`RaytracingScenePlugin`] - BLAS building, resource and lighting binding.
///
/// There's also:
/// * [`pathtracer::PathtracingPlugin`] - A non-realtime pathtracer for
/// validation purposes (not added by default).
///
/// To get started, add this plugin to your app, and then add `RaytracingMesh3d`
/// and `MeshMaterial3d::<StandardMaterial>` to your entities.
pub struct SolariPlugins;
impl PluginGroup for SolariPlugins {
fn build(self) -> PluginGroupBuilder {
PluginGroupBuilder::start::<Self>()
.add(RaytracingScenePlugin)
.add(SolariLightingPlugin)
}
}
impl SolariPlugins {
/// [`WgpuFeatures`] required for these plugins to function.
pub fn required_wgpu_features() -> WgpuFeatures {
WgpuFeatures::EXPERIMENTAL_RAY_QUERY
| WgpuFeatures::BUFFER_BINDING_ARRAY
| WgpuFeatures::TEXTURE_BINDING_ARRAY
| WgpuFeatures::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING
| WgpuFeatures::PARTIALLY_BOUND_BINDING_ARRAY
}
}
@@ -15,6 +15,7 @@ use bevy_render::{
mesh::allocator::MeshAllocator,
render_resource::{AtomicPod, AtomicSparseBufferVec, Buffer, BufferId, BufferUsages},
};
use bevy_tape_load::{Tape, render::allocator::TapeAllocator};
use bevy_transform::components::GlobalTransform;
use bevy_utils::once;
use bytemuck::{Pod, Zeroable};
@@ -26,7 +27,6 @@ use super::{
assets::AssetState,
lights::{GpuLightSource, LightSourceId, LightState},
};
use crate::scene::tapes::{allocator::TapeAllocator, types::Tape};
pub const MAX_MESH_SLAB_COUNT: NonZeroU32 = NonZeroU32::new(500).unwrap();
pub const MAX_TAPE_SLAB_COUNT: NonZeroU32 = NonZeroU32::new(500).unwrap();
@@ -470,9 +470,9 @@ impl InstanceState {
bevy_log::debug!("Resolving tape instance {tape_id}");
let slot = instance.slot;
let (Some(aabb_slice), Some(material_slot), Some(blas_address)) = (
inputs.tape_allocator.tape_aabb_slice(&tape_id),
inputs.assets.material_slots.get(&instance.material),
inputs.tape_blas_manager.device_address(&tape_id),
inputs.tape_allocator.tape_aabb_slice(&tape_id),
inputs.assets.material_slots.get(&instance.material),
inputs.tape_blas_manager.device_address(&tape_id),
) else {
self.deactivate_instance(lights, entity, instance);
return false;
@@ -21,6 +21,7 @@ use bevy_render::{
renderer::{RenderDevice, RenderQueue},
texture::GpuImage,
};
use bevy_tape_load::render::allocator::TapeAllocator;
use tracing::info_span;
use self::{
@@ -41,7 +42,6 @@ use super::{
RaytracingMesh3d, Tape3d, extract::StandardMaterialAssets,
meshes::blas::BlasManager as MeshBlasManager, tapes::blas::BlasManager as TapeBlasManager,
};
use crate::scene::tapes::allocator::TapeAllocator;
/// 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
@@ -18,6 +18,13 @@ use bevy_render::{
renderer::{RenderDevice, RenderGraph, RenderGraphSystems},
};
use bevy_shader::load_shader_library;
pub use bevy_tape_load::{
Tape, Tape3d, TapePlugin,
render::{
RenderTape, TapeRenderAssetPlugin,
allocator::{TapeAllocatorPlugin, allocate_and_free_tapes},
},
};
pub use binder::{
RaytracingSceneBindings, RaytracingSceneNeedsPreviousFrameData,
prepare_raytracing_scene_resources,
@@ -31,20 +38,13 @@ use extract::{
extract_raytracing_scene_transforms,
};
pub use meshes::types::RaytracingMesh3d;
pub use tapes::{
allocator::{TapeAllocatorPlugin, TapeRenderAssetPlugin},
plugin::TapePlugin,
types::{Tape, Tape3d},
};
use tracing::warn;
use crate::{
SolariPlugins, scene::{
extract::{
extract_raytracing_scene_meshes_structural,
extract_raytracing_scene_tapes_and_materials,
extract_raytracing_scene_tapes_structural,
}, tapes::{allocator::allocate_and_free_tapes, types::RenderTape},
SolariPlugins,
scene::extract::{
extract_raytracing_scene_meshes_structural, extract_raytracing_scene_tapes_and_materials,
extract_raytracing_scene_tapes_structural,
},
};
@@ -12,13 +12,14 @@ use bevy_render::{
render_resource::*,
renderer::{RenderDevice, RenderQueue},
};
use wgpu::{BlasAabbGeometry, wgt::BlasAABBGeometrySizeDescriptor};
use crate::scene::tapes::{
self,
allocator::{TapeAllocator, TapeBufferSlice},
types::{RenderTape, Tape},
use bevy_tape_load::{
Tape,
render::{
RenderTape,
allocator::{TapeAllocator, TapeBufferSlice},
},
};
use wgpu::{BlasAabbGeometry, wgt::BlasAABBGeometrySizeDescriptor};
/// Under the `wgpu_hal` build path, we need to manage BLAS lifetimes ourselves.
/// Since solari keeps both current and previous frame TLAS's around, only after
@@ -123,7 +124,7 @@ pub fn prepare_raytracing_blas(
.map(|(asset_id, aabbs_slice, blas_size)| {
let geometry = BlasAabbGeometry {
size: blas_size,
stride: size_of::<tapes::types::Aabb>() as u64,
stride: size_of::<bevy_tape_load::render::Aabb>() as u64,
aabb_buffer: aabbs_slice.buffer,
primitive_offset: aabbs_slice.range.start,
};
@@ -0,0 +1 @@
pub mod blas;
+83
View File
@@ -0,0 +1,83 @@
[package]
name = "bevy_tape_load"
version = "0.20.0-dev"
edition = "2024"
description = "Provides tape types for Bevy Engine"
license = "Apache-2.0"
keywords = ["bevy"]
[dependencies]
# bevy
bevy_app = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_asset = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_camera = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_color = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_core_pipeline = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
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" }
bevy_mesh = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_pbr = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", features = [
"dfg_lut",
] }
bevy_platform = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", default-features = false, features = [
"std",
"serialize",
] }
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",
] }
bevy_shader = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
bevy_shape = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010", features = [
"bevy_reflect",
] }
bevy_transform = { git = "https://github.com/bevyengine/bevy.git", rev = "0f38358f573a7dc6ea961076f6151be662142010" }
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 = [
"bevy",
] }
rspirv = "0.13"
# other
bitflags = { version = "2.3", features = ["serde"] }
bytemuck = { version = "1.5", features = ["must_cast"] }
wgpu = { version = "30", default-features = false }
wgpu-types = { version = "30", default-features = false }
serde = { version = "1", default-features = false, features = [
"derive",
], optional = true }
hexasphere = "19.0"
thiserror = { version = "2", default-features = false }
tracing = { version = "0.1", default-features = false, features = ["std"] }
derive_more = { version = "2", default-features = false, features = ["from"] }
half = { version = "2.4.1", features = ["bytemuck"] }
encase = "0.13"
glam = { version = "0.33.9", default-features = false, optional = true }
[dev-dependencies]
approx = "0.5"
serde_json = "1.0.140"
[features]
default = []
## Adds serialization support through `serde`.
serialize = ["dep:serde", "wgpu-types/serde", "half/serde"]
morph = ["glam/encase-013"]
[lints]
workspace = true
[package.metadata.docs.rs]
rustdoc-args = [
"-Zunstable-options",
"--generate-link-to-definition",
"--generate-macro-expansion",
]
all-features = true
@@ -1,12 +1,41 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
/**
* Defines the [Tape] asset, which responds to a Tape Drive tape.
*/
use bevy_app::{App, Plugin, PostUpdate};
use bevy_asset::{AssetApp as _, AssetEvent, AssetEventSystems, AssetId};
use bevy_asset::{AssetApp as _, AssetEvent, AssetEventSystems, AssetId, Handle};
use bevy_derive::{Deref, DerefMut};
use bevy_ecs::{
change_detection::DetectChangesMut as _, message::MessageReader,
schedule::IntoScheduleConfigs as _, system::Query,
change_detection::DetectChangesMut as _, component::Component, message::MessageReader,
prelude::*, system::Query, template::FromTemplate,
};
use bevy_pbr::{MeshMaterial3d, StandardMaterial};
use bevy_platform::{collections::HashSet, hash::FixedHasher};
use bevy_reflect::{Reflect, prelude::ReflectDefault};
use bevy_render::sync_world::SyncToRenderWorld;
use bevy_transform::components::Transform;
use derive_more::derive::From;
use crate::scene::{Tape3d, tapes::types::Tape};
extern crate alloc;
pub mod primitives;
pub mod render;
pub mod tape;
pub use tape_load::ssa;
pub use crate::tape::Tape;
/// A tape drive tape.
///
/// The material used for this entity must be
/// [`MeshMaterial3d<StandardMaterial>`].
#[derive(
Component, FromTemplate, Clone, Debug, Default, Deref, DerefMut, Reflect, PartialEq, Eq, From,
)]
#[reflect(Component, Default, Clone, PartialEq)]
#[require(MeshMaterial3d<StandardMaterial>, Transform, SyncToRenderWorld)]
pub struct Tape3d(pub Handle<Tape>);
/// A system that marks a [`Tape3d`] as changed if the associated [`Tape`] asset
/// has changed.
@@ -0,0 +1,47 @@
//! Tape generation for [primitive shapes](bevy_shape).
//!
//! Primitives that support taping implement the [`Tapeable`] trait.
//! Calling [`tape`](Tapeable::tape) will return either a [`Tape`] or a builder
//! that can be used to specify shape-specific configuration for creating the
//! [`Tape`].
//!
//! ```
//! # use bevy_asset::Assets;
//! # use bevy_ecs::prelude::ResMut;
//! # use bevy_shape::Circle;
//! # use bevy_tape_load::*;
//! #
//! # fn setup(mut tapes: ResMut<Assets<Tape>>) {
//! // Create circle tape with default configuration
//! let circle = tapes.add(Circle { radius: 25.0 });
//!
//! // Specify number of vertices
//! let circle = tapes.add(Circle { radius: 25.0 }.tape().resolution(64));
//! # }
//! ```
pub mod sphere;
use super::Tape;
/// A trait for shapes that can be turned into a [`Tape`].
pub trait Tapeable {
/// The output of [`Self::tape`]. This will be a [`TapeBuilder`] used for
/// creating a [`Tape`].
type Output: TapeBuilder;
/// Creates a [`Tape`] for a shape.
fn tape(&self) -> Self::Output;
}
/// A trait used to build [`Tape`]s from a configuration
pub trait TapeBuilder {
/// Builds a [`Tape`] based on the configuration in `self`.
fn build(&self) -> Tape;
}
impl<T: TapeBuilder> From<T> for Tape {
fn from(builder: T) -> Self {
builder.build()
}
}
@@ -0,0 +1,87 @@
use bevy_reflect::prelude::*;
use bevy_shape::Sphere;
use crate::{
Tape,
primitives::{TapeBuilder, Tapeable},
ssa::{SSAInput, SSAOpcode, SSAOpcodeSized, SSATape},
};
/// A builder used for creating a [`Tape`] with an [`Sphere`] shape.
#[derive(Clone, Copy, Debug, Default, Reflect)]
#[reflect(Default, Debug, Clone)]
pub struct SphereTapeBuilder {
/// The [`Sphere`] shape.
pub sphere: Sphere,
}
impl SphereTapeBuilder {
/// Creates a new [`SphereTapeBuilder`] from a radius.
#[inline]
pub const fn new(radius: f32) -> Self {
Self {
sphere: Sphere { radius },
}
}
/// Creates a sphere [`Tape`] with the given radius.
/// TODO: make it so that this is composable.
pub fn build_with_radius(radius: f32) -> Tape {
let mut tape = SSATape::default();
let pos = tape.push_instruction(
SSAOpcodeSized {
opcode: SSAOpcode::SSAPosition,
size: 1,
},
vec![],
);
let sphere = tape.push_instruction(
SSAOpcodeSized {
opcode: SSAOpcode::SSASDFSphere,
size: 1,
},
vec![pos[0], pos[1], pos[2], SSAInput::Constant(radius)],
);
tape.push_instruction(
SSAOpcodeSized {
opcode: SSAOpcode::SSAReturn,
size: 1,
},
sphere,
);
Tape {
parts: tape,
..Default::default()
}
}
}
impl TapeBuilder for SphereTapeBuilder {
/// Builds a [`Tape`] according to the configuration in `self`.
///
/// # Panics
///
/// Panics if the sphere is a [`SphereKind::Ico`] with a subdivision count
/// that is greater than or equal to `80` because there will be too many
/// vertices.
fn build(&self) -> Tape {
Self::build_with_radius(self.sphere.radius)
}
}
impl Tapeable for Sphere {
type Output = SphereTapeBuilder;
fn tape(&self) -> Self::Output {
SphereTapeBuilder {
sphere: *self,
..Default::default()
}
}
}
impl From<Sphere> for Tape {
fn from(sphere: Sphere) -> Self {
sphere.tape().build()
}
}
@@ -14,7 +14,7 @@ use bevy_ecs::{
use bevy_log::warn;
use bevy_render::{
GpuResourceAppExt, Render, RenderApp, RenderSystems,
render_asset::{ExtractedAssets, RenderAssetPlugin, prepare_assets},
render_asset::{ExtractedAssets, prepare_assets},
renderer::{RenderDevice, RenderQueue},
slab_allocator::{
Slab, SlabAllocationBufferSlice, SlabAllocator, SlabAllocatorSettings, SlabId, SlabItem,
@@ -24,13 +24,12 @@ use bevy_render::{
use bevy_shape::BoundingVolume;
use wgpu::{BufferUsages, COPY_BUFFER_ALIGNMENT};
use crate::scene::tapes::types::{Aabb, RenderTape, Tape, TapeMetadata};
use super::{Aabb, RenderTape, TapeMetadata};
use crate::tape::Tape;
/// A plugin that manages GPU memory for tape data.
pub struct TapeAllocatorPlugin;
pub type TapeRenderAssetPlugin = RenderAssetPlugin<RenderTape>;
/// Manages the assignment of tape data to GPU buffers.
///
/// The Bevy renderer tries to pack vertex and index data for multiple tapes
@@ -0,0 +1,8 @@
struct TapeMetadata {
/// AABB for decompressing positions.
aabb_center: vec3<f32>,
pad_a: u32,
aabb_half_extents: vec3<f32>,
pad_b: u32,
};
+247
View File
@@ -0,0 +1,247 @@
/**
* Vaguely analagous to bevy_render::mesh
*/
pub mod allocator;
use allocator::TapeAllocatorPlugin;
use bevy_app::{App, Plugin};
use bevy_asset::{AssetId, AssetServer, Assets, Handle};
use bevy_ecs::{
prelude::*,
system::{SystemParamItem, lifetimeless::SRes},
};
use bevy_math::Vec3;
use bevy_reflect::Reflect;
use bevy_render::{
Render, RenderApp, RenderSystems,
render_asset::{
AssetExtractionError, PrepareAssetError, RenderAsset, RenderAssetPlugin, prepare_assets,
},
render_resource::{
BindGroupLayoutDescriptor, Buffer, CachedComputePipelineId, ComputePipelineDescriptor,
PipelineCache, ShaderType,
},
};
use bevy_shader::{Shader, load_shader_library};
use bytemuck::{Pod, Zeroable};
use rspirv::dr::Module;
use crate::{
render::allocator::{ElementClass, TapeAllocationKey, TapeAllocator, TapeSlabId},
tape::Tape,
};
/// 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, "metadata_types.wesl");
app.add_plugins(RenderAssetPlugin::<RenderTape>::default())
.add_plugins(TapeAllocatorPlugin);
let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
return;
};
render_app.add_systems(
Render,
prepare_tape_metadata_fallback_buffer
.in_set(RenderSystems::PrepareAssets)
.after(prepare_assets::<RenderTape>),
);
}
fn finish(&self, app: &mut App) {
let mut tape_assets = app.world_mut().resource_mut::<Assets<Tape>>();
let handle =
tape_assets.add(crate::primitives::sphere::SphereTapeBuilder::build_with_radius(1.0));
let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
return;
};
render_app.insert_resource(TapeMetadataFallbackTape(handle));
}
}
#[derive(Resource)]
pub struct TapeMetadataFallbackTape(pub Handle<Tape>);
/// Metadata slab ID and buffer of [`TapeMetadataFallbackTape`],
/// used to fill bind group for tape without metadata.
#[derive(Resource)]
pub struct TapeMetadataFallbackBuffer {
pub slab_id: TapeSlabId,
pub buffer: Buffer,
}
pub fn prepare_tape_metadata_fallback_buffer(
mut commands: Commands,
tape_allocator: Res<TapeAllocator>,
metadata_fallback_tape: Res<TapeMetadataFallbackTape>,
) {
let slab_id = tape_allocator
.key_to_slab
.get(&TapeAllocationKey::new(
metadata_fallback_tape.0.id(),
ElementClass::Metadata,
))
.cloned()
.unwrap();
let buffer = tape_allocator.buffer_for_slab(slab_id).unwrap().clone();
commands.insert_resource(TapeMetadataFallbackBuffer { slab_id, buffer });
}
#[derive(Debug, PartialEq, Clone, Copy, Reflect)]
#[reflect(Debug, PartialEq, Clone)]
pub struct Aabb {
/// The minimum point of the box
pub min: Vec3,
/// The maximum point of the box
pub max: Vec3,
}
#[derive(Resource)]
pub struct ReplacementModules {
pub enable_gen: Module,
pub fuzz: Module,
pub normals: Module,
pub spatial_texture: Module,
pub trace: Module,
pub enable_gen_layout: BindGroupLayoutDescriptor,
pub fuzz_layout: BindGroupLayoutDescriptor,
pub spatial_texture_layout: BindGroupLayoutDescriptor,
}
/// Per-tape metadata, stored in [`super::allocator::TapeAllocator`].
/// Currently this is used to decompress vertex.
#[derive(Default, Pod, Zeroable, Clone, Copy, Debug, ShaderType)]
#[repr(C)]
pub struct TapeMetadata {
// AABB for decompressing positions.
pub aabb_center: Vec3,
pub pad1: u32,
// AABB for decompressing positions.
pub aabb_half_extents: Vec3,
pub pad2: u32,
}
/// The render world representation of a [`Tape`].
#[derive(Debug, Clone)]
pub struct RenderTape {
pub seed: u64,
pub subdivision: u32,
pub enable_gen: Handle<Shader>,
pub fuzz: Handle<Shader>,
pub normals: Handle<Shader>,
pub spatial_texture: Handle<Shader>,
pub trace: Handle<Shader>,
pub enable_gen_pipeline: CachedComputePipelineId,
pub fuzz_pipeline: CachedComputePipelineId,
pub spatial_texture_pipeline: CachedComputePipelineId,
}
impl RenderAsset for RenderTape {
type Param = (
SRes<AssetServer>,
SRes<ReplacementModules>,
SRes<PipelineCache>,
);
type SourceAsset = Tape;
fn take_gpu_data(
source: &mut Self::SourceAsset,
_previous_gpu_asset: Option<&Self>,
) -> Result<Self::SourceAsset, AssetExtractionError> {
Ok(source.clone())
}
fn byte_len(_tape: &Self::SourceAsset) -> Option<usize> {
// Some(0) // Is this really correct?
None
}
/// Converts the extracted tape into a [`RenderTape`].
fn prepare_asset(
tape: Self::SourceAsset,
_tape_id: AssetId<Self::SourceAsset>,
(asset_server, replacement_modules, pipeline_cache): &mut SystemParamItem<Self::Param>,
_: Option<&Self>,
) -> Result<Self, PrepareAssetError<Self::SourceAsset>> {
let key = tape.get_tape_key();
let enable_gen = asset_server.add(tape.sdf_specialize_module_with_key(
key,
replacement_modules.enable_gen.clone(),
"enable_gen",
));
let fuzz = asset_server.add(tape.sdf_specialize_module_with_key(
key,
replacement_modules.fuzz.clone(),
"fuzz",
));
let normals = asset_server.add(tape.sdf_specialize_module_with_key(
key,
replacement_modules.normals.clone(),
"normals",
));
let spatial_texture = asset_server.add(tape.sdf_specialize_module_with_key(
key,
replacement_modules.spatial_texture.clone(),
"spatial_texture",
));
let trace = asset_server.add(tape.sdf_specialize_module_with_key(
key,
replacement_modules.trace.clone(),
"trace",
));
let enable_gen_pipeline =
pipeline_cache.queue_compute_pipeline(ComputePipelineDescriptor {
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()),
..Default::default()
});
let fuzz_pipeline = pipeline_cache.queue_compute_pipeline(ComputePipelineDescriptor {
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()),
..Default::default()
});
let spatial_texture_pipeline =
pipeline_cache.queue_compute_pipeline(ComputePipelineDescriptor {
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()),
..Default::default()
});
Ok(RenderTape {
seed: tape.seed,
subdivision: tape.subdivision,
enable_gen,
fuzz,
normals,
spatial_texture,
trace,
enable_gen_pipeline,
fuzz_pipeline,
spatial_texture_pipeline,
})
}
fn unload_asset(_tape_id: AssetId<Self::SourceAsset>, (..): &mut SystemParamItem<Self::Param>) {
}
}
+70
View File
@@ -0,0 +1,70 @@
use std::hash::{Hash, Hasher};
use bevy_asset::Asset;
use bevy_reflect::Reflect;
use bevy_shader::Shader;
use bevy_shape::Aabb3d;
use rspirv::{binary::Assemble as _, dr::Module};
use crate::{render::Aabb, ssa::*};
/// A tape drive tape.
#[derive(Asset, Clone, Debug, Reflect, PartialEq, Hash)]
#[reflect(Clone)]
pub struct Tape {
pub parts: SSATape,
pub seed: u64,
pub subdivision: u32,
}
impl Default for Tape {
fn default() -> Self {
Self {
parts: Default::default(),
seed: 0,
subdivision: 8,
}
}
}
impl Tape {
pub fn get_aabb(&self, time: f32) -> Aabb3d {
let (lowest_corner, highest_corner) = self.parts.get_aabb(time);
Aabb3d::from_min_max(lowest_corner, highest_corner)
}
pub fn get_aabb_buffer_size(&self) -> u64 {
((self.subdivision * self.subdivision * self.subdivision) as u64) * size_of::<Aabb>() as u64
}
pub fn get_tape_key(&self) -> u64 {
let mut hasher = std::hash::DefaultHasher::new();
self.parts.hash(&mut hasher);
hasher.finish()
}
pub(crate) fn sdf_specialize_module(&self, module: Module, name: &str) -> Shader {
self.sdf_specialize_module_with_key(self.get_tape_key(), module, name)
}
pub(crate) fn sdf_specialize_module_with_key(
&self,
key: u64,
module: Module,
name: &str,
) -> Shader {
let new_module = self.parts.compile_to_spirv(Some(module));
let assembled_module = new_module.assemble();
let bytes = assembled_module
.iter()
.cloned()
.flat_map(u32::to_le_bytes)
.collect::<Vec<_>>();
let path = format!("bevy_tape_drive::gen_shader::{name}::{key}");
Shader::from_spirv(bytes, path)
}
}
+13 -6
View File
@@ -13,6 +13,7 @@ use bevy::{
use bevy::{
camera::CameraMainTextureUsages,
camera_controller::free_camera::{FreeCamera, FreeCameraPlugin},
color::palettes::css::RED,
diagnostic::{Diagnostic, DiagnosticPath, DiagnosticsStore},
gltf::GltfMaterialName,
image::{ImageAddressMode, ImageLoaderSettings},
@@ -22,15 +23,19 @@ use bevy::{
render::{diagnostic::RenderDiagnosticsPlugin, render_resource::TextureUsages},
world_serialization::WorldInstanceReady,
};
use bevy_color::palettes::css::RED;
use bevy_tape_drive::{
pathtracer::{Pathtracer, PathtracingPlugin},
prelude::{RaytracingMesh3d, SolariLighting, SolariPlugins},
scene::{Tape, Tape3d},
solari::{
pathtracer::{Pathtracer, PathtracingPlugin},
prelude::{RaytracingMesh3d, SolariLighting, SolariPlugins},
},
tape_load::{
Tape, Tape3d, TapePlugin,
render::TapeRenderAssetPlugin,
ssa::{SSAInput, SSAOpcode, SSAOpcodeSized, SSATape},
},
};
use chacha20::ChaCha8Rng;
use rand::{RngExt, SeedableRng, rngs::SmallRng};
use tape_load::ssa::{SSAInput, SSAOpcode, SSAOpcodeSized, SSATape};
/// `bevy_solari` demo.
#[derive(FromArgs, Resource, Clone, Copy)]
@@ -60,6 +65,8 @@ fn main() {
// filter: "wgpu=warn,bevy_ecs=info".to_string(),
..default()
}),
TapePlugin,
TapeRenderAssetPlugin,
SolariPlugins,
FreeCameraPlugin,
RenderDiagnosticsPlugin,
@@ -375,7 +382,7 @@ fn setup_pica_pica(
let csg = create_csg(0);
let tape = Tape {
parts: unsafe { core::mem::transmute(csg) },
parts: csg,
seed: 0,
subdivision: 8,
};
+3 -67
View File
@@ -1,68 +1,4 @@
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
#![feature(portable_simd)]
#![no_std]
//! Provides raytraced lighting.
//!
//! See [`SolariPlugins`] for more info.
//!
//! ![`bevy_solari` logo](https://raw.githubusercontent.com/bevyengine/bevy/refs/heads/main/assets/branding/bevy_solari.svg)
extern crate alloc;
pub mod pathtracer;
pub mod realtime;
pub mod scene;
/// The solari prelude.
///
/// This includes the most common types in this crate, re-exported for your
/// convenience.
pub mod prelude {
pub use super::SolariPlugins;
pub use crate::{realtime::SolariLighting, scene::RaytracingMesh3d};
}
use bevy_app::{PluginGroup, PluginGroupBuilder};
use bevy_render::settings::WgpuFeatures;
use crate::{
realtime::SolariLightingPlugin,
scene::{RaytracingScenePlugin, TapeAllocatorPlugin, TapePlugin, TapeRenderAssetPlugin},
};
/// An experimental set of plugins for raytraced lighting.
///
/// This plugin group provides:
/// * [`SolariLightingPlugin`] - Raytraced direct and indirect lighting.
/// * [`RaytracingScenePlugin`] - BLAS building, resource and lighting binding.
/// * [`TapeAllocatorPlugin`] - Handles Tape3d objects GPU side.
///
/// There's also:
/// * [`pathtracer::PathtracingPlugin`] - A non-realtime pathtracer for
/// validation purposes (not added by default).
///
/// To get started, add this plugin to your app, and then add `RaytracingMesh3d`
/// and `MeshMaterial3d::<StandardMaterial>` to your entities.
pub struct SolariPlugins;
impl PluginGroup for SolariPlugins {
fn build(self) -> PluginGroupBuilder {
PluginGroupBuilder::start::<Self>()
.add(TapePlugin)
.add(TapeRenderAssetPlugin::default())
.add(TapeAllocatorPlugin)
.add(RaytracingScenePlugin)
.add(SolariLightingPlugin)
}
}
impl SolariPlugins {
/// [`WgpuFeatures`] required for these plugins to function.
pub fn required_wgpu_features() -> WgpuFeatures {
WgpuFeatures::EXPERIMENTAL_RAY_QUERY
| WgpuFeatures::BUFFER_BINDING_ARRAY
| WgpuFeatures::TEXTURE_BINDING_ARRAY
| WgpuFeatures::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING
| WgpuFeatures::PARTIALLY_BOUND_BINDING_ARRAY
}
}
pub use bevy_tape_drive_solari as solari;
pub use bevy_tape_load as tape_load;
-4
View File
@@ -1,4 +0,0 @@
pub mod allocator;
pub mod blas;
pub mod plugin;
pub mod types;
-385
View File
@@ -1,385 +0,0 @@
use std::{
hash::{Hash, Hasher},
simd::StdFloat as _,
};
use bevy_asset::{Asset, AssetId, AssetServer, Handle};
use bevy_derive::{Deref, DerefMut};
use bevy_ecs::{
component::Component,
prelude::*,
resource::Resource,
system::{SystemParamItem, lifetimeless::SRes},
template::FromTemplate,
};
use bevy_math::Vec3;
use bevy_pbr::{MeshMaterial3d, StandardMaterial};
use bevy_reflect::{Reflect, prelude::ReflectDefault};
use bevy_render::{
render_asset::{AssetExtractionError, PrepareAssetError, RenderAsset},
render_resource::{
BindGroupLayoutDescriptor, CachedComputePipelineId, ComputePipelineDescriptor,
PipelineCache, ShaderType,
},
sync_world::SyncToRenderWorld,
};
use bevy_shader::Shader;
use bevy_shape::Aabb3d;
use bevy_transform::components::Transform;
use bytemuck::{Pod, Zeroable};
use derive_more::derive::From;
use rspirv::{binary::Assemble as _, dr::Module};
use tape_load::interpreters::{self, point::PointInterpreter};
#[derive(Debug, PartialEq, Clone, Copy, Reflect)]
#[reflect(Debug, PartialEq, Clone)]
pub struct Aabb {
/// The minimum point of the box
pub min: Vec3,
/// The maximum point of the box
pub max: Vec3,
}
#[derive(Resource)]
pub struct ReplacementModules {
pub enable_gen: Module,
pub fuzz: Module,
pub normals: Module,
pub spatial_texture: Module,
pub trace: Module,
pub enable_gen_layout: BindGroupLayoutDescriptor,
pub fuzz_layout: BindGroupLayoutDescriptor,
pub spatial_texture_layout: BindGroupLayoutDescriptor,
}
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy, Reflect, Hash)]
#[reflect(Clone)]
pub enum SSAOpcode {
SSAAdd,
SSASub,
SSAMul,
SSADiv,
SSAAtan2,
SSAMin,
SSAMax,
SSACompare,
SSAMod,
SSAAnd,
SSAOr,
SSANegate,
SSAAbs,
SSARecip,
SSASqrt,
SSASquare,
SSAFloor,
SSACeil,
SSARound,
SSASin,
SSACos,
SSATan,
SSAAsin,
SSAAcos,
SSAAtan,
SSAExp,
SSALog,
SSANot,
SSAFract,
SSACube,
SSASmoothMin,
SSASmoothMax,
SSAClamp,
SSAMix,
SSAFMA,
SSADot,
SSALength,
SSADistance,
#[default]
SSAStop,
SSAReturn,
SSAPosition,
SSAMinMaterial,
SSAMaxMaterial,
SSASmoothMinMaterial,
SSASmoothMaxMaterial,
SSASDFSphere,
SSASDFBox,
SSASDFTorus,
}
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy, Reflect, Hash)]
#[reflect(Clone)]
pub struct SSAOpcodeSized {
pub opcode: SSAOpcode,
pub size: u8,
}
#[derive(Debug, PartialEq, Clone, Copy, Reflect)]
#[reflect(Clone)]
pub enum SSAInput {
Register(u32),
Constant(f32),
}
impl Hash for SSAInput {
fn hash<H: Hasher>(&self, state: &mut H) {
std::mem::discriminant(self).hash(state);
match self {
SSAInput::Register(e) => e.hash(state),
SSAInput::Constant(e) => e.to_bits().hash(state),
}
}
}
#[derive(Debug, Default, PartialEq, Clone, Reflect, Hash)]
#[reflect(Clone)]
pub struct SSAInstruction {
pub opcode: SSAOpcodeSized,
pub inputs: Vec<SSAInput>,
pub outputs: Vec<u32>,
}
#[derive(Debug, Default, PartialEq, Clone, Reflect)]
#[reflect(Clone)]
pub struct SSATape {
pub last_output: u32,
pub tape: Vec<SSAInstruction>,
constants: Vec<f32>,
}
impl Hash for SSATape {
fn hash<H: Hasher>(&self, state: &mut H) {
self.last_output.hash(state);
self.tape.hash(state);
self.constants.len().hash(state);
for constant in &self.constants {
constant.to_bits().hash(state);
}
}
}
/// A tape drive tape.
#[derive(Asset, Clone, Debug, Reflect, PartialEq, Hash)]
#[reflect(Clone)]
pub struct Tape {
pub parts: SSATape,
pub seed: u64,
pub subdivision: u32,
}
impl Tape {
pub fn get_aabb(&self, time: f32) -> Aabb3d {
const INTERPRET_INPUT_X: interpreters::Value =
interpreters::Value::from_array([10000.0, 0.0, 0.0, -10000.0, 0.0, 0.0, 0.0, 0.0]);
const INTERPRET_INPUT_Y: interpreters::Value =
interpreters::Value::from_array([0.0, 10000.0, 0.0, 0.0, -10000.0, 0.0, 0.0, 0.0]);
const INTERPRET_INPUT_Z: interpreters::Value =
interpreters::Value::from_array([0.0, 0.0, 10000.0, 0.0, 0.0, -10000.0, 0.0, 0.0]);
const INTERPRET_MUL: interpreters::Value =
interpreters::Value::from_array([-1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 0.0, 0.0]);
const INTERPRET_ADD: interpreters::Value = interpreters::Value::from_array([
10000.0, 10000.0, 10000.0, -10000.0, -10000.0, -10000.0, 0.0, 0.0,
]);
// This can only go well
let parts = self.as_tape_load();
let mut interpreter = PointInterpreter::new(parts);
let interpreter_out = interpreter
.scene(
INTERPRET_INPUT_X,
INTERPRET_INPUT_Y,
INTERPRET_INPUT_Z,
interpreters::Value::splat(time),
)
.mul_add(INTERPRET_MUL, INTERPRET_ADD)
.to_array();
const EPSILON: f32 = 0.1;
let highest_corner =
Vec3::new(interpreter_out[0], interpreter_out[1], interpreter_out[2]) + EPSILON;
let lowest_corner =
Vec3::new(interpreter_out[3], interpreter_out[4], interpreter_out[5]) - EPSILON;
Aabb3d::from_min_max(lowest_corner, highest_corner)
}
pub fn get_aabb_buffer_size(&self) -> u64 {
((self.subdivision * self.subdivision * self.subdivision) as u64) * size_of::<Aabb>() as u64
}
// cursed cursed cursed
pub fn as_tape_load(&self) -> &tape_load::ssa::SSATape {
unsafe { core::mem::transmute(&self.parts) }
}
pub fn get_tape_key(&self) -> u64 {
let mut hasher = std::hash::DefaultHasher::new();
self.parts.hash(&mut hasher);
hasher.finish()
}
fn sdf_specialize_module(&self, module: Module, name: &str) -> Shader {
self.sdf_specialize_module_with_key(self.get_tape_key(), module, name)
}
fn sdf_specialize_module_with_key(&self, key: u64, module: Module, name: &str) -> Shader {
let new_module = self.as_tape_load().compile_to_spirv(Some(module));
let assembled_module = new_module.assemble();
let bytes = assembled_module
.iter()
.cloned()
.flat_map(u32::to_le_bytes)
.collect::<Vec<_>>();
let path = format!("bevy_tape_drive::gen_shader::{name}::{key}");
Shader::from_spirv(bytes, path)
}
}
/// Per-tape metadata, stored in [`super::allocator::TapeAllocator`].
/// Currently this is used to decompress vertex.
#[derive(Default, Pod, Zeroable, Clone, Copy, Debug, ShaderType)]
#[repr(C)]
pub struct TapeMetadata {
// AABB for decompressing positions.
pub aabb_center: Vec3,
pub pad1: u32,
// AABB for decompressing positions.
pub aabb_half_extents: Vec3,
pub pad2: u32,
}
/// The render world representation of a [`Tape`].
#[derive(Debug, Clone)]
pub struct RenderTape {
pub seed: u64,
pub subdivision: u32,
pub enable_gen: Handle<Shader>,
pub fuzz: Handle<Shader>,
pub normals: Handle<Shader>,
pub spatial_texture: Handle<Shader>,
pub trace: Handle<Shader>,
pub enable_gen_pipeline: CachedComputePipelineId,
pub fuzz_pipeline: CachedComputePipelineId,
pub spatial_texture_pipeline: CachedComputePipelineId,
}
impl RenderAsset for RenderTape {
type Param = (
SRes<AssetServer>,
SRes<ReplacementModules>,
SRes<PipelineCache>,
);
type SourceAsset = Tape;
fn take_gpu_data(
source: &mut Self::SourceAsset,
_previous_gpu_asset: Option<&Self>,
) -> Result<Self::SourceAsset, AssetExtractionError> {
Ok(source.clone())
}
fn byte_len(_tape: &Self::SourceAsset) -> Option<usize> {
// Some(0) // Is this really correct?
None
}
/// Converts the extracted tape into a [`RenderTape`].
fn prepare_asset(
tape: Self::SourceAsset,
_tape_id: AssetId<Self::SourceAsset>,
(asset_server, replacement_modules, pipeline_cache): &mut SystemParamItem<Self::Param>,
_: Option<&Self>,
) -> Result<Self, PrepareAssetError<Self::SourceAsset>> {
let key = tape.get_tape_key();
let enable_gen = asset_server.add(tape.sdf_specialize_module_with_key(
key,
replacement_modules.enable_gen.clone(),
"enable_gen",
));
let fuzz = asset_server.add(tape.sdf_specialize_module_with_key(
key,
replacement_modules.fuzz.clone(),
"fuzz",
));
let normals = asset_server.add(tape.sdf_specialize_module_with_key(
key,
replacement_modules.normals.clone(),
"normals",
));
let spatial_texture = asset_server.add(tape.sdf_specialize_module_with_key(
key,
replacement_modules.spatial_texture.clone(),
"spatial_texture",
));
let trace = asset_server.add(tape.sdf_specialize_module_with_key(
key,
replacement_modules.trace.clone(),
"trace",
));
let enable_gen_pipeline =
pipeline_cache.queue_compute_pipeline(ComputePipelineDescriptor {
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()),
..Default::default()
});
let fuzz_pipeline = pipeline_cache.queue_compute_pipeline(ComputePipelineDescriptor {
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()),
..Default::default()
});
let spatial_texture_pipeline =
pipeline_cache.queue_compute_pipeline(ComputePipelineDescriptor {
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()),
..Default::default()
});
Ok(RenderTape {
seed: tape.seed,
subdivision: tape.subdivision,
enable_gen,
fuzz,
normals,
spatial_texture,
trace,
enable_gen_pipeline,
fuzz_pipeline,
spatial_texture_pipeline,
})
}
fn unload_asset(_tape_id: AssetId<Self::SourceAsset>, (..): &mut SystemParamItem<Self::Param>) {
}
}
/// A tape drive tape.
///
/// The material used for this entity must be
/// [`MeshMaterial3d<StandardMaterial>`].
#[derive(
Component, FromTemplate, Clone, Debug, Default, Deref, DerefMut, Reflect, PartialEq, Eq, From,
)]
#[reflect(Component, Default, Clone, PartialEq)]
#[require(MeshMaterial3d<StandardMaterial>, Transform, SyncToRenderWorld)]
pub struct Tape3d(pub Handle<Tape>);