update wgpu 0.9 => 0.12

there looks to be a 25% perf hit when running the 160x160x160 benchmark.
This commit is contained in:
Colin 2022-01-25 04:11:24 -08:00
parent a997e01c48
commit d399d51895
3 changed files with 116 additions and 364 deletions

427
Cargo.lock generated
View File

@ -20,12 +20,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
[[package]]
name = "ahash"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e"
[[package]]
name = "ahash"
version = "0.7.6"
@ -72,15 +66,15 @@ checksum = "d67af77d68a931ecd5cbd8a3b5987d63a1d1d1278f7f6a60ae33db485cdebb69"
[[package]]
name = "arrayvec"
version = "0.5.2"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
[[package]]
name = "ash"
version = "0.32.1"
version = "0.34.0+1.2.203"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06063a002a77d2734631db74e8f4ce7148b77fe522e6bca46f2ae7774fd48112"
checksum = "b0f780da53d0063880d45554306489f09dd8d1bda47688b4a57bc579119356df"
dependencies = [
"libloading",
]
@ -219,21 +213,6 @@ dependencies = [
"vec_map",
]
[[package]]
name = "cocoa-foundation"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318"
dependencies = [
"bitflags",
"block",
"core-foundation",
"core-graphics-types",
"foreign-types",
"libc",
"objc",
]
[[package]]
name = "codespan-reporting"
version = "0.11.1"
@ -543,15 +522,6 @@ dependencies = [
"byteorder",
]
[[package]]
name = "drm-fourcc"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0aafbcdb8afc29c1a7ee5fbe53b5d62f4565b35a042a662ca9fecd0b54dae6f4"
dependencies = [
"serde",
]
[[package]]
name = "dyn-clone"
version = "1.0.4"
@ -598,22 +568,6 @@ dependencies = [
"serde",
]
[[package]]
name = "external-memory"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4dfe8d292b014422776a8c516862d2bff8a81b223a4461dfdc45f3862dc9d39"
dependencies = [
"bitflags",
"drm-fourcc",
]
[[package]]
name = "fixedbitset"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
[[package]]
name = "float_eq"
version = "0.7.0"
@ -761,168 +715,6 @@ dependencies = [
"wasi 0.10.2+wasi-snapshot-preview1",
]
[[package]]
name = "gfx-auxil"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1694991b11d642680e82075a75c7c2bd75556b805efa7660b705689f05b1ab1c"
dependencies = [
"fxhash",
"gfx-hal",
"spirv_cross",
]
[[package]]
name = "gfx-backend-dx11"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f9e453baf3aaef2b0c354ce0b3d63d76402e406a59b64b7182d123cfa6635ae"
dependencies = [
"arrayvec",
"bitflags",
"gfx-auxil",
"gfx-hal",
"gfx-renderdoc",
"libloading",
"log",
"parking_lot",
"range-alloc",
"raw-window-handle 0.3.4",
"smallvec",
"spirv_cross",
"thunderdome",
"winapi",
"wio",
]
[[package]]
name = "gfx-backend-dx12"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21506399f64a3c4d389182a89a30073856ae33eb712315456b4fd8f39ee7682a"
dependencies = [
"arrayvec",
"bit-set",
"bitflags",
"d3d12",
"gfx-auxil",
"gfx-hal",
"gfx-renderdoc",
"log",
"parking_lot",
"range-alloc",
"raw-window-handle 0.3.4",
"smallvec",
"spirv_cross",
"thunderdome",
"winapi",
]
[[package]]
name = "gfx-backend-empty"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29c8f813c47791918aa00dc9c9ddf961d23fa8c2a5d869e6cb8ea84f944820f4"
dependencies = [
"gfx-hal",
"log",
"raw-window-handle 0.3.4",
]
[[package]]
name = "gfx-backend-gl"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bae057fc3a0ab23ecf97ae51d4017d27d5ddf0aab16ee6dcb58981af88c3152"
dependencies = [
"arrayvec",
"bitflags",
"fxhash",
"gfx-hal",
"glow",
"js-sys",
"khronos-egl",
"libloading",
"log",
"naga",
"parking_lot",
"raw-window-handle 0.3.4",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "gfx-backend-metal"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0de85808e2a98994c6af925253f8a9593bc57180ef1ea137deab6d35cc949517"
dependencies = [
"arrayvec",
"bitflags",
"block",
"cocoa-foundation",
"copyless",
"core-graphics-types",
"foreign-types",
"fxhash",
"gfx-hal",
"log",
"metal",
"naga",
"objc",
"parking_lot",
"profiling",
"range-alloc",
"raw-window-handle 0.3.4",
"storage-map",
]
[[package]]
name = "gfx-backend-vulkan"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9861ec855acbbc65c0e4f966d761224886e811dc2c6d413a4776e9293d0e5c0"
dependencies = [
"arrayvec",
"ash",
"byteorder",
"core-graphics-types",
"gfx-hal",
"gfx-renderdoc",
"inplace_it",
"log",
"naga",
"objc",
"parking_lot",
"raw-window-handle 0.3.4",
"smallvec",
"winapi",
]
[[package]]
name = "gfx-hal"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fbb575ea793dd0507b3082f4f2cde62dc9f3cebd98f5cd49ba2a4da97a976fd"
dependencies = [
"bitflags",
"external-memory",
"naga",
"raw-window-handle 0.3.4",
"thiserror",
]
[[package]]
name = "gfx-renderdoc"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8027995e247e2426d3a00d13f5191dd56c314bff02dc4b54cbf727f1ba9c40a"
dependencies = [
"libloading",
"log",
"renderdoc-sys",
]
[[package]]
name = "ghost"
version = "0.1.2"
@ -955,9 +747,9 @@ dependencies = [
[[package]]
name = "glow"
version = "0.9.0"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b80b98efaa8a34fce11d60dd2ce2760d5d83c373cbcc73bb87c2a3a84a54108"
checksum = "d8bd5877156a19b8ac83a29b2306fe20537429d318f3ff0a1a2119f8d9c61919"
dependencies = [
"js-sys",
"slotmap",
@ -967,9 +759,9 @@ dependencies = [
[[package]]
name = "gpu-alloc"
version = "0.4.7"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbc1b6ca374e81862526786d9cb42357ce03706ed1b8761730caafd02ab91f3a"
checksum = "7fc59e5f710e310e76e6707f86c561dd646f69a8876da9131703b2f717de818d"
dependencies = [
"bitflags",
"gpu-alloc-types",
@ -986,13 +778,13 @@ dependencies = [
[[package]]
name = "gpu-descriptor"
version = "0.1.1"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8a70f1e87a3840ed6a3e99e02c2b861e4dbdf26f0d07e38f42ea5aff46cfce2"
checksum = "a538f217be4d405ff4719a283ca68323cc2384003eca5baaa87501e821c81dda"
dependencies = [
"bitflags",
"gpu-descriptor-types",
"hashbrown 0.9.1",
"hashbrown",
]
[[package]]
@ -1010,22 +802,13 @@ version = "1.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
[[package]]
name = "hashbrown"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
dependencies = [
"ahash 0.4.7",
]
[[package]]
name = "hashbrown"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [
"ahash 0.7.6",
"ahash",
]
[[package]]
@ -1046,6 +829,12 @@ dependencies = [
"libc",
]
[[package]]
name = "hexf-parse"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "humantime"
version = "2.1.0"
@ -1095,7 +884,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
dependencies = [
"autocfg",
"hashbrown 0.11.2",
"hashbrown",
]
[[package]]
@ -1111,6 +900,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if",
"js-sys",
"wasm-bindgen",
"web-sys",
]
[[package]]
@ -1242,7 +1034,7 @@ version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "274353858935c992b13c0ca408752e2121da852d07dec7ce5f108c77dfa14d1f"
dependencies = [
"hashbrown 0.11.2",
"hashbrown",
]
[[package]]
@ -1350,19 +1142,19 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389"
[[package]]
name = "naga"
version = "0.5.0"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef670817eef03d356d5a509ea275e7dd3a78ea9e24261ea3cb2dfed1abb08f64"
checksum = "33f2a8d82486d74d708bec00bba92749cb3f685551e8220b625af4bcc70a9d15"
dependencies = [
"bit-set",
"bitflags",
"codespan-reporting",
"fxhash",
"hexf-parse",
"indexmap",
"log",
"num-traits",
"petgraph",
"rose_tree",
"spirv_headers",
"rustc-hash",
"spirv",
"thiserror",
]
@ -1605,16 +1397,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "petgraph"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7"
dependencies = [
"fixedbitset",
"indexmap",
]
[[package]]
name = "pin-project-lite"
version = "0.2.8"
@ -1823,16 +1605,6 @@ version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0501e134c6905fee1f10fed25b0a7e1261bf676cffac9543a7d0730dec01af2"
[[package]]
name = "raw-window-handle"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e28f55143d0548dad60bb4fbdc835a3d7ac6acc3324506450c5fdd6e42903a76"
dependencies = [
"libc",
"raw-window-handle 0.4.2",
]
[[package]]
name = "raw-window-handle"
version = "0.4.2"
@ -1917,15 +1689,6 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1382d1f0a252c4bf97dc20d979a2fdd05b024acd7c2ed0f7595d7817666a157"
[[package]]
name = "rose_tree"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "284de9dae38774e2813aaabd7e947b4a6fe9b8c58c2309f754a487cdd50de1c2"
dependencies = [
"petgraph",
]
[[package]]
name = "rspirv"
version = "0.11.0+1.5.4"
@ -1953,6 +1716,12 @@ version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc_codegen_spirv"
version = "0.4.0-alpha.12"
@ -1960,7 +1729,7 @@ source = "git+https://github.com/EmbarkStudios/rust-gpu#31e3fdb09b60c33c611e8db5
dependencies = [
"ar",
"bimap",
"hashbrown 0.11.2",
"hashbrown",
"indexmap",
"libc",
"num-traits",
@ -2115,9 +1884,12 @@ checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5"
[[package]]
name = "slotmap"
version = "0.4.3"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bf34684c5767b87de9119790e92e9a1d60056be2ceeaf16a8e6ef13082aeab1"
checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342"
dependencies = [
"version_check",
]
[[package]]
name = "smallvec"
@ -2200,36 +1972,6 @@ dependencies = [
"spirv-std",
]
[[package]]
name = "spirv_cross"
version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60647fadbf83c4a72f0d7ea67a7ca3a81835cf442b8deae5c134c3e0055b2e14"
dependencies = [
"cc",
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "spirv_headers"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f5b132530b1ac069df335577e3581765995cba5a13995cdbbdbc8fb057c532c"
dependencies = [
"bitflags",
"num-traits",
]
[[package]]
name = "storage-map"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418bb14643aa55a7841d5303f72cf512cfb323b8cc221d51580500a1ca75206c"
dependencies = [
"lock_api",
]
[[package]]
name = "strsim"
version = "0.8.0"
@ -2318,12 +2060,6 @@ dependencies = [
"num_cpus",
]
[[package]]
name = "thunderdome"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f685624f172cd0bde6f3363412455e81c018f2379fdf5a218e0be003f1bba642"
[[package]]
name = "tiff"
version = "0.6.1"
@ -2496,9 +2232,9 @@ checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2"
[[package]]
name = "web-sys"
version = "0.3.50"
version = "0.3.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be"
checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb"
dependencies = [
"js-sys",
"wasm-bindgen",
@ -2512,59 +2248,91 @@ checksum = "d8b77fdfd5a253be4ab714e4ffa3c49caf146b4de743e97510c0656cf90f1e8e"
[[package]]
name = "wgpu"
version = "0.9.0"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd247f8b26fd3d42ef2f320d378025cd6e84d782ef749fab45cc3b981fbe3275"
checksum = "b97cd781ff044d6d697b632a2e212032c2e957d1afaa21dbf58069cbb8f78567"
dependencies = [
"arrayvec",
"js-sys",
"log",
"naga",
"parking_lot",
"raw-window-handle 0.3.4",
"raw-window-handle",
"smallvec",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"wgpu-core",
"wgpu-hal",
"wgpu-types",
]
[[package]]
name = "wgpu-core"
version = "0.9.2"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "958a8a5e418492723ab4e7933bf6dbdf06f5dc87274ba2ae0e4f9c891aac579c"
checksum = "c4688c000eb841ca55f7b35db659b78d6e1cd77d7caf8fb929f4e181f754047d"
dependencies = [
"arrayvec",
"bitflags",
"cfg_aliases",
"codespan-reporting",
"copyless",
"fxhash",
"gfx-backend-dx11",
"gfx-backend-dx12",
"gfx-backend-empty",
"gfx-backend-gl",
"gfx-backend-metal",
"gfx-backend-vulkan",
"gfx-hal",
"gpu-alloc",
"gpu-descriptor",
"log",
"naga",
"parking_lot",
"profiling",
"raw-window-handle 0.3.4",
"raw-window-handle",
"smallvec",
"thiserror",
"wgpu-hal",
"wgpu-types",
]
[[package]]
name = "wgpu-types"
version = "0.9.0"
name = "wgpu-hal"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f5c9678cd533558e28b416d66947b099742df1939307478db54f867137f1b60"
checksum = "93b1a9400e8d7f32dd4dd909bb9a391015d70633d639775ddd3f14d1104bc970"
dependencies = [
"arrayvec",
"ash",
"bit-set",
"bitflags",
"block",
"core-graphics-types",
"d3d12",
"foreign-types",
"fxhash",
"glow",
"gpu-alloc",
"gpu-descriptor",
"inplace_it",
"js-sys",
"khronos-egl",
"libloading",
"log",
"metal",
"naga",
"objc",
"parking_lot",
"profiling",
"range-alloc",
"raw-window-handle",
"renderdoc-sys",
"thiserror",
"wasm-bindgen",
"web-sys",
"wgpu-types",
"winapi",
]
[[package]]
name = "wgpu-types"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "549533d9e1cdd4b4cda7718d33ff500fc4c34b5467b71d76b547ae0324f3b2a2"
dependencies = [
"bitflags",
]
@ -2600,15 +2368,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "wio"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5"
dependencies = [
"winapi",
]
[[package]]
name = "y4m"
version = "0.7.0"

View File

@ -46,7 +46,7 @@ y4m = "0.7"
# erased-serde = "0.3"
# serde_cbor = "0.11"
wgpu = "0.9"
wgpu = "0.12"
spirv-builder = { git = "https://github.com/EmbarkStudios/rust-gpu", features=["use-compiled-tools"] }
spirv-std = { git = "https://github.com/EmbarkStudios/rust-gpu" }
spirv-std-macros = { git = "https://github.com/EmbarkStudios/rust-gpu" }

View File

@ -48,7 +48,7 @@ impl WgpuData {
pub fn new() -> Self {
let (device, queue) = futures::executor::block_on(open_device());
let shader_binary = get_shader();
let shader_module = device.create_shader_module(&shader_binary);
let shader_module = unsafe { device.create_shader_module_spirv(&shader_binary) };
let (step_bind_group_layout, step_h_pipeline, step_e_pipeline) = make_pipelines(&device, &shader_module);
Self {
step_bind_group_layout,
@ -352,7 +352,7 @@ impl SpirvSim {
let sim_meta_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("gpu-side simulation metadata"),
contents: to_bytes(&sim_meta[..]),
usage: wgpu::BufferUsage::STORAGE,
usage: wgpu::BufferUsages::STORAGE,
});
assert_eq!(std::mem::size_of::<SpirvMaterial>(), 44);
@ -360,40 +360,40 @@ impl SpirvSim {
label: Some("gpu-side materials matrix"),
contents: to_bytes(self.mat.as_slice()),
// Can be used by the GPU and copied back to the CPU
usage: wgpu::BufferUsage::STORAGE,
usage: wgpu::BufferUsages::STORAGE,
});
let e_field_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("gpu-side in/out e field"),
contents: to_bytes(self.e.as_slice()),
usage: wgpu::BufferUsage::STORAGE | wgpu::BufferUsage::COPY_SRC,
usage: wgpu::BufferUsages::STORAGE.union(wgpu::BufferUsages::COPY_SRC),
});
let h_field_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("gpu-side in/out h field"),
contents: to_bytes(self.h.as_slice()),
// Can be used by the GPU and copied back to the CPU
usage: wgpu::BufferUsage::STORAGE | wgpu::BufferUsage::COPY_SRC,
usage: wgpu::BufferUsages::STORAGE.union(wgpu::BufferUsages::COPY_SRC),
});
let m_field_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("gpu-side in/out m field"),
contents: to_bytes(self.m.as_slice()),
// Can be used by the GPU and copied back to the CPU
usage: wgpu::BufferUsage::STORAGE | wgpu::BufferUsage::COPY_SRC,
usage: wgpu::BufferUsages::STORAGE.union(wgpu::BufferUsages::COPY_SRC),
});
let stim_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("gpu-side in/out m field"),
contents: to_bytes(stim_cpu.as_slice().unwrap()),
usage: wgpu::BufferUsage::STORAGE
usage: wgpu::BufferUsages::STORAGE
});
let e_readback_buffer = device.create_buffer(&wgpu::BufferDescriptor {
label: Some("cpu-side copy of e output buffer"),
size: field_bytes as wgpu::BufferAddress,
// Can be read to the CPU, and can be copied from the shader's storage buffer
usage: wgpu::BufferUsage::MAP_READ | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::MAP_READ | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
@ -401,7 +401,7 @@ impl SpirvSim {
label: Some("cpu-side copy of h output buffer"),
size: field_bytes as wgpu::BufferAddress,
// Can be read to the CPU, and can be copied from the shader's storage buffer
usage: wgpu::BufferUsage::MAP_READ | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::MAP_READ | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
@ -409,7 +409,7 @@ impl SpirvSim {
label: Some("cpu-side copy of m output buffer"),
size: field_bytes as wgpu::BufferAddress,
// Can be read to the CPU, and can be copied from the shader's storage buffer
usage: wgpu::BufferUsage::MAP_READ | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::MAP_READ | wgpu::BufferUsages::COPY_DST,
mapped_at_creation: false,
});
@ -585,7 +585,7 @@ unsafe fn from_bytes<T>(slice: &[u8]) -> &[T] {
}
/// Compiles the compute shader to spirv
fn get_shader() -> wgpu::ShaderModuleDescriptor<'static> {
fn get_shader() -> wgpu::ShaderModuleDescriptorSpirV<'static> {
// based on rust-gpu/examples/runners/wgpu/src/lib.rs:maybe_watch
// Hack: spirv_builder builds into a custom directory if running under cargo, to not
// deadlock, and the default target directory if not. However, packages like `proc-macro2`
@ -615,28 +615,21 @@ fn get_shader() -> wgpu::ShaderModuleDescriptor<'static> {
let module_path = initial_result.module.unwrap_single();
let data = std::fs::read(module_path.clone()).unwrap_or_else(|e| { panic!("module path: {:?}: {:?}", module_path, e) });
let spirv = match wgpu::util::make_spirv(&data) {
wgpu::ShaderSource::Wgsl(cow) => {
wgpu::ShaderSource::Wgsl(Cow::Owned(cow.into_owned()))
}
wgpu::ShaderSource::SpirV(cow) => {
wgpu::ShaderSource::SpirV(Cow::Owned(cow.into_owned()))
}
};
let spirv = Cow::Owned(wgpu::util::make_spirv_raw(&data).into_owned());
wgpu::ShaderModuleDescriptor {
wgpu::ShaderModuleDescriptorSpirV {
label: None,
source: spirv,
flags: wgpu::ShaderFlags::default(),
}
}
async fn open_device() -> (wgpu::Device, wgpu::Queue) {
// based on rust-gpu/examples/runners/wgpu/src/compute.rs:start_internal
let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY);
let instance = wgpu::Instance::new(wgpu::Backends::PRIMARY);
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::default(),
force_fallback_adapter: false,
compatible_surface: None,
})
.await
@ -656,7 +649,7 @@ async fn open_device() -> (wgpu::Device, wgpu::Queue) {
.request_device(
&wgpu::DeviceDescriptor {
label: None,
features: wgpu::Features::default(),
features: wgpu::Features::SPIRV_SHADER_PASSTHROUGH,
limits,
},
None,
@ -676,7 +669,7 @@ fn make_pipelines(device: &wgpu::Device, shader_module: &wgpu::ShaderModule) ->
// meta
binding: 0,
count: None,
visibility: wgpu::ShaderStage::COMPUTE,
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::Buffer {
has_dynamic_offset: false,
min_binding_size: Some(NonZeroU64::new(1).unwrap()),
@ -687,7 +680,7 @@ fn make_pipelines(device: &wgpu::Device, shader_module: &wgpu::ShaderModule) ->
// stimulus
binding: 1,
count: None,
visibility: wgpu::ShaderStage::COMPUTE,
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::Buffer {
has_dynamic_offset: false,
min_binding_size: Some(NonZeroU64::new(1).unwrap()),
@ -698,7 +691,7 @@ fn make_pipelines(device: &wgpu::Device, shader_module: &wgpu::ShaderModule) ->
// materials
binding: 2,
count: None,
visibility: wgpu::ShaderStage::COMPUTE,
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::Buffer {
has_dynamic_offset: false,
min_binding_size: Some(NonZeroU64::new(1).unwrap()),
@ -709,7 +702,7 @@ fn make_pipelines(device: &wgpu::Device, shader_module: &wgpu::ShaderModule) ->
// e field
binding: 3,
count: None,
visibility: wgpu::ShaderStage::COMPUTE,
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::Buffer {
has_dynamic_offset: false,
min_binding_size: Some(NonZeroU64::new(1).unwrap()),
@ -720,7 +713,7 @@ fn make_pipelines(device: &wgpu::Device, shader_module: &wgpu::ShaderModule) ->
// h field
binding: 4,
count: None,
visibility: wgpu::ShaderStage::COMPUTE,
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::Buffer {
has_dynamic_offset: false,
min_binding_size: Some(NonZeroU64::new(1).unwrap()),
@ -731,7 +724,7 @@ fn make_pipelines(device: &wgpu::Device, shader_module: &wgpu::ShaderModule) ->
// m field
binding: 5,
count: None,
visibility: wgpu::ShaderStage::COMPUTE,
visibility: wgpu::ShaderStages::COMPUTE,
ty: wgpu::BindingType::Buffer {
has_dynamic_offset: false,
min_binding_size: Some(NonZeroU64::new(1).unwrap()),