Move to A Single Example Executable (#4756)

* Move to combined examples

* Fix paths

* Curtail some tests

* Format

* Clippy

* Fix wasm

* Refactor main for wasm

* Style sheet

* Readme

* Lock
This commit is contained in:
Connor Fitzgerald 2023-11-23 05:26:42 -05:00 committed by GitHub
parent 3c261f3652
commit 06e9876adf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
146 changed files with 654 additions and 1445 deletions

511
Cargo.lock generated
View File

@ -4,9 +4,9 @@ version = 3
[[package]] [[package]]
name = "ab_glyph" name = "ab_glyph"
version = "0.2.22" version = "0.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1061f3ff92c2f65800df1f12fc7b4ff44ee14783104187dd04dfee6f11b0fd2" checksum = "80179d7dd5d7e8c285d67c4a1e652972a92de7475beddfb92028c76463b13225"
dependencies = [ dependencies = [
"ab_glyph_rasterizer", "ab_glyph_rasterizer",
"owned_ttf_parser", "owned_ttf_parser",
@ -502,9 +502,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.4.7" version = "4.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@ -512,9 +512,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.4.7" version = "4.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@ -881,9 +881,9 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
[[package]] [[package]]
name = "cursor-icon" name = "cursor-icon"
version = "1.0.0" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "740bb192a8e2d1350119916954f4409ee7f62f149b536911eeb78ba5a20526bf" checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
[[package]] [[package]]
name = "d3d12" name = "d3d12"
@ -931,9 +931,9 @@ dependencies = [
[[package]] [[package]]
name = "data-encoding" name = "data-encoding"
version = "2.4.0" version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
[[package]] [[package]]
name = "ddsfile" name = "ddsfile"
@ -1025,7 +1025,7 @@ dependencies = [
"lazy-regex", "lazy-regex",
"once_cell", "once_cell",
"pmutil", "pmutil",
"proc-macro-crate", "proc-macro-crate 1.3.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"regex", "regex",
@ -1240,9 +1240,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]] [[package]]
name = "errno" name = "errno"
version = "0.3.5" version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys 0.48.0", "windows-sys 0.48.0",
@ -1269,9 +1269,9 @@ dependencies = [
[[package]] [[package]]
name = "fdeflate" name = "fdeflate"
version = "0.3.0" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" checksum = "64d6dafc854908ff5da46ff3f8f473c6984119a2876a383a860246dd7841a868"
dependencies = [ dependencies = [
"simd-adler32", "simd-adler32",
] ]
@ -1364,9 +1364,9 @@ checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
[[package]] [[package]]
name = "form_urlencoded" name = "form_urlencoded"
version = "1.2.0" version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
dependencies = [ dependencies = [
"percent-encoding", "percent-encoding",
] ]
@ -1793,9 +1793,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]] [[package]]
name = "idna" name = "idna"
version = "0.4.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
dependencies = [ dependencies = [
"unicode-bidi", "unicode-bidi",
"unicode-normalization", "unicode-normalization",
@ -1930,9 +1930,9 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
[[package]] [[package]]
name = "lazy-regex" name = "lazy-regex"
version = "3.0.2" version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e723bd417b2df60a0f6a2b6825f297ea04b245d4ba52b5a22cb679bdf58b05fa" checksum = "5d12be4595afdf58bd19e4a9f4e24187da2a66700786ff660a418e9059937a4c"
dependencies = [ dependencies = [
"lazy-regex-proc_macros", "lazy-regex-proc_macros",
"once_cell", "once_cell",
@ -1941,9 +1941,9 @@ dependencies = [
[[package]] [[package]]
name = "lazy-regex-proc_macros" name = "lazy-regex-proc_macros"
version = "3.0.1" version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f0a1d9139f0ee2e862e08a9c5d0ba0470f2aa21cd1e1aa1b1562f83116c725f" checksum = "44bcd58e6c97a7fcbaffcdc95728b393b8d98933bfadad49ed4097845b57ef0b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1994,6 +1994,17 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "libredox"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607"
dependencies = [
"bitflags 2.4.1",
"libc",
"redox_syscall 0.4.1",
]
[[package]] [[package]]
name = "libtest-mimic" name = "libtest-mimic"
version = "0.6.1" version = "0.6.1"
@ -2017,9 +2028,9 @@ dependencies = [
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
version = "0.4.10" version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
@ -2272,7 +2283,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c" checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c"
dependencies = [ dependencies = [
"darling", "darling",
"proc-macro-crate", "proc-macro-crate 1.3.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 1.0.109", "syn 1.0.109",
@ -2429,7 +2440,7 @@ version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate 1.3.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 1.0.109", "syn 1.0.109",
@ -2441,7 +2452,7 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate 2.0.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.39", "syn 2.0.39",
@ -2535,11 +2546,11 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
[[package]] [[package]]
name = "orbclient" name = "orbclient"
version = "0.3.46" version = "0.3.47"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8378ac0dfbd4e7895f2d2c1f1345cab3836910baf3a300b000d04250f0c8428f" checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166"
dependencies = [ dependencies = [
"redox_syscall 0.3.5", "libredox",
] ]
[[package]] [[package]]
@ -2559,9 +2570,9 @@ checksum = "4030760ffd992bef45b0ae3f10ce1aba99e33464c90d14dd7c039884963ddc7a"
[[package]] [[package]]
name = "owned_ttf_parser" name = "owned_ttf_parser"
version = "0.19.0" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "706de7e2214113d63a8238d1910463cfce781129a6f263d13fdb09ff64355ba4" checksum = "d4586edfe4c648c71797a74c84bacb32b52b212eff5dfe2bb9f2c599844023e7"
dependencies = [ dependencies = [
"ttf-parser", "ttf-parser",
] ]
@ -2606,9 +2617,9 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.3.0" version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]] [[package]]
name = "petgraph" name = "petgraph"
@ -2772,7 +2783,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"toml_edit", "toml_edit 0.19.15",
]
[[package]]
name = "proc-macro-crate"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8"
dependencies = [
"toml_edit 0.20.7",
] ]
[[package]] [[package]]
@ -2879,15 +2899,6 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]]
name = "redox_syscall"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
"bitflags 1.3.2",
]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.3.5" version = "0.3.5"
@ -2994,9 +3005,9 @@ dependencies = [
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.38.21" version = "0.38.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e"
dependencies = [ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"errno", "errno",
@ -3285,9 +3296,9 @@ dependencies = [
[[package]] [[package]]
name = "sourcemap" name = "sourcemap"
version = "7.0.0" version = "7.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbecc42a2b6131acc3bf9a25c9fe4161dba438eb52131bba83c5d781b5b70be3" checksum = "10da010a590ed2fa9ca8467b00ce7e9c5a8017742c0c09c45450efc172208c4b"
dependencies = [ dependencies = [
"data-encoding", "data-encoding",
"debugid", "debugid",
@ -3420,12 +3431,11 @@ dependencies = [
[[package]] [[package]]
name = "thread-id" name = "thread-id"
version = "4.1.0" version = "4.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ee93aa2b8331c0fec9091548843f2c90019571814057da3b783f9de09349d73" checksum = "f0ec81c46e9eb50deaa257be2f148adf052d1fb7701cfd55ccfab2525280b70b"
dependencies = [ dependencies = [
"libc", "libc",
"redox_syscall 0.2.16",
"winapi", "winapi",
] ]
@ -3560,6 +3570,17 @@ dependencies = [
"winnow", "winnow",
] ]
[[package]]
name = "toml_edit"
version = "0.20.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"
dependencies = [
"indexmap",
"toml_datetime",
"winnow",
]
[[package]] [[package]]
name = "tracing" name = "tracing"
version = "0.1.40" version = "0.1.40"
@ -3578,9 +3599,9 @@ checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
[[package]] [[package]]
name = "ttf-parser" name = "ttf-parser"
version = "0.19.2" version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49d64318d8311fc2668e48b63969f4343e0a85c4a109aa8460d6672e364b8bd1" checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4"
[[package]] [[package]]
name = "unic-char-property" name = "unic-char-property"
@ -3670,9 +3691,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]] [[package]]
name = "url" name = "url"
version = "2.4.1" version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633"
dependencies = [ dependencies = [
"form_urlencoded", "form_urlencoded",
"idna", "idna",
@ -3701,9 +3722,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "1.5.0" version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560"
dependencies = [ dependencies = [
"getrandom", "getrandom",
"serde", "serde",
@ -4087,45 +4108,6 @@ dependencies = [
"wgpu-types", "wgpu-types",
] ]
[[package]]
name = "wgpu-boids-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"nanorand",
"wasm-bindgen-test",
"wgpu",
"wgpu-example",
"wgpu-test",
"winit 0.29.3",
]
[[package]]
name = "wgpu-bunnymark-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"glam",
"nanorand",
"png",
"wasm-bindgen-test",
"wgpu",
"wgpu-example",
"wgpu-test",
"winit 0.29.3",
]
[[package]]
name = "wgpu-conservative-raster-example"
version = "0.18.0"
dependencies = [
"wasm-bindgen-test",
"wgpu",
"wgpu-example",
"wgpu-test",
"winit 0.29.3",
]
[[package]] [[package]]
name = "wgpu-core" name = "wgpu-core"
version = "0.18.0" version = "0.18.0"
@ -4150,33 +4132,31 @@ dependencies = [
] ]
[[package]] [[package]]
name = "wgpu-cube-example" name = "wgpu-examples"
version = "0.18.0" version = "0.18.0"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"glam",
"wasm-bindgen-test",
"wgpu",
"wgpu-example",
"wgpu-test",
"winit 0.29.3",
]
[[package]]
name = "wgpu-example"
version = "0.18.0"
dependencies = [
"cfg-if", "cfg-if",
"console_error_panic_hook", "console_error_panic_hook",
"console_log", "console_log",
"ddsfile",
"encase",
"env_logger", "env_logger",
"fern", "fern",
"flume",
"futures-intrusive",
"getrandom",
"glam",
"js-sys", "js-sys",
"log", "log",
"nanorand",
"noise",
"obj",
"png", "png",
"pollster", "pollster",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
"wasm-bindgen-test",
"web-sys", "web-sys",
"web-time", "web-time",
"wgpu", "wgpu",
@ -4230,101 +4210,6 @@ dependencies = [
"winit 0.29.3", "winit 0.29.3",
] ]
[[package]]
name = "wgpu-hello-compute-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"console_error_panic_hook",
"console_log",
"env_logger",
"flume",
"log",
"pollster",
"wasm-bindgen-futures",
"wasm-bindgen-test",
"wgpu",
"wgpu-test",
]
[[package]]
name = "wgpu-hello-example"
version = "0.18.0"
dependencies = [
"console_error_panic_hook",
"console_log",
"env_logger",
"glam",
"log",
"pollster",
"wasm-bindgen-futures",
"wgpu",
"wgpu-test",
]
[[package]]
name = "wgpu-hello-synchronization-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"console_error_panic_hook",
"console_log",
"env_logger",
"flume",
"log",
"pollster",
"wasm-bindgen-futures",
"wasm-bindgen-test",
"web-sys",
"wgpu",
"wgpu-example",
"wgpu-test",
]
[[package]]
name = "wgpu-hello-triangle-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"console_error_panic_hook",
"console_log",
"env_logger",
"pollster",
"wasm-bindgen-futures",
"web-sys",
"wgpu",
"winit 0.29.3",
]
[[package]]
name = "wgpu-hello-windows-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"console_error_panic_hook",
"env_logger",
"pollster",
"wgpu",
"winit 0.29.3",
]
[[package]]
name = "wgpu-hello-workgroups-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"console_error_panic_hook",
"console_log",
"env_logger",
"futures-intrusive",
"log",
"pollster",
"wasm-bindgen-futures",
"web-sys",
"wgpu",
"wgpu-example",
]
[[package]] [[package]]
name = "wgpu-info" name = "wgpu-info"
version = "0.18.0" version = "0.18.0"
@ -4348,148 +4233,6 @@ dependencies = [
"syn 2.0.39", "syn 2.0.39",
] ]
[[package]]
name = "wgpu-mipmap-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"glam",
"wasm-bindgen-test",
"wgpu",
"wgpu-example",
"wgpu-test",
"winit 0.29.3",
]
[[package]]
name = "wgpu-msaa-line-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"glam",
"log",
"wasm-bindgen-test",
"wgpu",
"wgpu-example",
"wgpu-test",
"winit 0.29.3",
]
[[package]]
name = "wgpu-render-to-texture-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"console_error_panic_hook",
"console_log",
"env_logger",
"futures-intrusive",
"log",
"png",
"pollster",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"wgpu",
"wgpu-example",
"winit 0.29.3",
]
[[package]]
name = "wgpu-repeated-compute-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"console_error_panic_hook",
"console_log",
"env_logger",
"futures-intrusive",
"getrandom",
"log",
"pollster",
"wasm-bindgen-futures",
"wasm-bindgen-test",
"web-sys",
"wgpu",
"wgpu-example",
"wgpu-test",
]
[[package]]
name = "wgpu-shadow-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"glam",
"wasm-bindgen-test",
"wgpu",
"wgpu-example",
"wgpu-test",
"winit 0.29.3",
]
[[package]]
name = "wgpu-skybox-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"ddsfile",
"glam",
"log",
"obj",
"wasm-bindgen-test",
"wgpu",
"wgpu-example",
"wgpu-test",
"winit 0.29.3",
]
[[package]]
name = "wgpu-srgb-blend-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"glam",
"wasm-bindgen-test",
"wgpu",
"wgpu-example",
"wgpu-test",
"winit 0.29.3",
]
[[package]]
name = "wgpu-stencil-triangle-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"wasm-bindgen-test",
"wgpu",
"wgpu-example",
"wgpu-test",
"winit 0.29.3",
]
[[package]]
name = "wgpu-storage-texture-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"console_error_panic_hook",
"console_log",
"env_logger",
"futures-intrusive",
"log",
"png",
"pollster",
"wasm-bindgen",
"wasm-bindgen-futures",
"wasm-bindgen-test",
"web-sys",
"wgpu",
"wgpu-example",
"wgpu-test",
]
[[package]] [[package]]
name = "wgpu-test" name = "wgpu-test"
version = "0.18.0" version = "0.18.0"
@ -4526,36 +4269,6 @@ dependencies = [
"wgpu-types", "wgpu-types",
] ]
[[package]]
name = "wgpu-texture-arrays-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"wasm-bindgen-test",
"wgpu",
"wgpu-example",
"wgpu-test",
"winit 0.29.3",
]
[[package]]
name = "wgpu-timestamp-queries-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"console_error_panic_hook",
"console_log",
"env_logger",
"futures-intrusive",
"log",
"pollster",
"wasm-bindgen-futures",
"wasm-bindgen-test",
"wgpu",
"wgpu-test",
"winit 0.29.3",
]
[[package]] [[package]]
name = "wgpu-types" name = "wgpu-types"
version = "0.18.0" version = "0.18.0"
@ -4567,38 +4280,6 @@ dependencies = [
"web-sys", "web-sys",
] ]
[[package]]
name = "wgpu-uniform-values-example"
version = "0.18.0"
dependencies = [
"console_error_panic_hook",
"console_log",
"encase",
"env_logger",
"glam",
"png",
"pollster",
"wasm-bindgen-futures",
"web-sys",
"wgpu",
"winit 0.29.3",
]
[[package]]
name = "wgpu-water-example"
version = "0.18.0"
dependencies = [
"bytemuck",
"glam",
"nanorand",
"noise",
"wasm-bindgen-test",
"wgpu",
"wgpu-example",
"wgpu-test",
"winit 0.29.3",
]
[[package]] [[package]]
name = "which" name = "which"
version = "4.4.2" version = "4.4.2"
@ -4934,9 +4615,9 @@ dependencies = [
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.5.17" version = "0.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@ -5023,18 +4704,18 @@ checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a"
[[package]] [[package]]
name = "zerocopy" name = "zerocopy"
version = "0.7.15" version = "0.7.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81ba595b9f2772fbee2312de30eeb80ec773b4cb2f1e8098db024afadda6c06f" checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0"
dependencies = [ dependencies = [
"zerocopy-derive", "zerocopy-derive",
] ]
[[package]] [[package]]
name = "zerocopy-derive" name = "zerocopy-derive"
version = "0.7.15" version = "0.7.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "772666c41fb6dceaf520b564b962d738a8e1a83b41bd48945f50837aed78bb1d" checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@ -6,7 +6,7 @@ members = [
# default members # default members
"d3d12", "d3d12",
"examples/*", "examples/",
"naga-cli", "naga-cli",
"naga", "naga",
"naga/fuzz", "naga/fuzz",
@ -23,7 +23,7 @@ members = [
exclude = [] exclude = []
default-members = [ default-members = [
"d3d12", "d3d12",
"examples/*", "examples/",
"naga-cli", "naga-cli",
"naga", "naga",
"naga/fuzz", "naga/fuzz",
@ -79,12 +79,14 @@ codespan-reporting = "0.11"
ctor = "0.2" ctor = "0.2"
# https://github.com/SiegeEngine/ddsfile/issues/15 (Updated dependencies) # https://github.com/SiegeEngine/ddsfile/issues/15 (Updated dependencies)
ddsfile = { version = "0.5.2-unstable", git = "https://github.com/SiegeEngine/ddsfile.git", rev = "9b597930edc00502391cbb1a39708dadde0fd0ff" } ddsfile = { version = "0.5.2-unstable", git = "https://github.com/SiegeEngine/ddsfile.git", rev = "9b597930edc00502391cbb1a39708dadde0fd0ff" }
encase = "0.6"
env_logger = "0.10" env_logger = "0.10"
fern = "0.6" fern = "0.6"
flume = "0.11" flume = "0.11"
futures-lite = "1" futures-lite = "1"
futures-intrusive = "0.5" futures-intrusive = "0.5"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
getrandom = "0.2"
glam = "0.24.2" glam = "0.24.2"
heck = "0.4.0" heck = "0.4.0"
image = { version = "0.24", default-features = false, features = ["png"] } image = { version = "0.24", default-features = false, features = ["png"] }

View File

@ -37,11 +37,11 @@ For an overview of all the components in the gfx-rs ecosystem, see [the big pict
### Rust ### Rust
Rust examples can be found at [wgpu/examples](examples). You can run the examples on native with `cargo run --bin <name>`. See the [list of examples](examples). Rust examples can be found at [wgpu/examples](examples). You can run the examples on native with `cargo run --bin wgpu-examples <example>`. See the [list of examples](examples).
To run the examples on WebGPU on wasm, run `cargo xtask run-wasm --bin <name>`. Then connect to `http://localhost:8000` in your WebGPU enabled browser. To run the examples on WebGPU on wasm, run `cargo xtask run-wasm --bin wgpu-example`. Then connect to `http://localhost:8000` in your WebGPU enabled browser, and you can choose an example to run.
To run the examples on WebGL on wasm, run `cargo xtask run-wasm --bin <name> --features webgl`. Then connect to `http://localhost:8000` in your WebGL enabled browser. To run the examples on WebGL on wasm, run `cargo xtask run-wasm --bin wgpu-example --features webgl`. Then connect to `http://localhost:8000` in your WebGL enabled browser, and you can choose an example to run.
If you are looking for a wgpu tutorial, look at the following: If you are looking for a wgpu tutorial, look at the following:

View File

@ -1,5 +1,5 @@
[package] [package]
name = "wgpu-example" name = "wgpu-examples"
version.workspace = true version.workspace = true
authors.workspace = true authors.workspace = true
edition.workspace = true edition.workspace = true
@ -10,15 +10,36 @@ keywords.workspace = true
license.workspace = true license.workspace = true
publish = false publish = false
[lib]
path = "src/lib.rs"
harness = false
[[bin]]
name = "wgpu-examples"
path = "src/main.rs"
test = false
[dependencies] [dependencies]
bytemuck.workspace = true
cfg-if.workspace = true cfg-if.workspace = true
ddsfile.workspace = true
encase = { workspace = true, features = ["glam"] }
env_logger.workspace = true env_logger.workspace = true
flume.workspace = true
futures-intrusive.workspace = true
getrandom.workspace = true
glam.workspace = true
log.workspace = true log.workspace = true
pollster.workspace = true nanorand.workspace = true
noise.workspace = true
obj.workspace = true
png.workspace = true png.workspace = true
pollster.workspace = true
web-time.workspace = true web-time.workspace = true
winit.workspace = true
wgpu.workspace = true wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true wgpu-test.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
@ -27,6 +48,7 @@ console_log.workspace = true
fern.workspace = true fern.workspace = true
js-sys.workspace = true js-sys.workspace = true
wasm-bindgen.workspace = true wasm-bindgen.workspace = true
wasm-bindgen-test.workspace = true
wasm-bindgen-futures.workspace = true wasm-bindgen-futures.workspace = true
hal = { workspace = true, optional = true } hal = { workspace = true, optional = true }
# We need these features in the framework examples and tests # We need these features in the framework examples and tests
@ -36,7 +58,13 @@ web-sys = { workspace = true, features = [
"RequestInit", "RequestInit",
"RequestMode", "RequestMode",
"Request", "Request",
"ImageData",
"Response", "Response",
"HtmlImageElement",
"WebGl2RenderingContext", "WebGl2RenderingContext",
"CanvasRenderingContext2d" "CanvasRenderingContext2d",
# Needed for example display logic
"HtmlStyleElement",
"HtmlHeadElement",
] } ] }

View File

@ -1,25 +0,0 @@
[package]
name = "wgpu-boids-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu boids example"
publish = false
[[bin]]
name = "boids"
path = "src/main.rs"
harness = false
[dependencies]
bytemuck.workspace = true
nanorand.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-test.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

@ -1,27 +0,0 @@
[package]
name = "wgpu-bunnymark-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu bunnymark example"
publish = false
[[bin]]
name = "bunnymark"
path = "src/main.rs"
harness = false
[dependencies]
bytemuck.workspace = true
nanorand.workspace = true
glam.workspace = true
png.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test.workspace = true

View File

@ -1,2 +0,0 @@
pub mod framework;
pub mod utils;

View File

@ -1,23 +0,0 @@
[package]
name = "wgpu-conservative-raster-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu conservative raster example"
publish = false
[[bin]]
name = "conservative-raster"
path = "src/main.rs"
harness = false
[dependencies]
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test.workspace = true

View File

@ -1,25 +0,0 @@
[package]
name = "wgpu-cube-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu cube example"
publish = false
[[bin]]
name = "cube"
path = "src/main.rs"
harness = false
[dependencies]
bytemuck.workspace = true
glam.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-test.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

@ -1,31 +0,0 @@
[package]
name = "wgpu-hello-compute-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu hello compute example"
publish = false
[[bin]]
name = "hello-compute"
path = "src/main.rs"
harness = false
[dependencies]
bytemuck.workspace = true
env_logger.workspace = true
flume.workspace = true
pollster.workspace = true
wgpu.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
log.workspace = true
wasm-bindgen-futures.workspace = true
[dev-dependencies]
wgpu-test.workspace = true
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test.workspace = true

View File

@ -1,33 +0,0 @@
[package]
name = "wgpu-hello-synchronization-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu hello synchronization example"
publish = false
[[bin]]
name = "hello-synchronization"
path = "src/main.rs"
harness = false
[dependencies]
bytemuck.workspace = true
env_logger.workspace = true
flume.workspace = true
log.workspace = true
pollster.workspace = true
wgpu.workspace = true
wgpu-example.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
wasm-bindgen-futures.workspace = true
web-sys = { workspace = true, features = ["Document"] }
[dev-dependencies]
wgpu-test.workspace = true
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test.workspace = true

View File

@ -1,24 +0,0 @@
[package]
name = "wgpu-hello-triangle-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu hello triangle example"
publish = false
[[bin]]
name = "hello-triangle"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
env_logger.workspace = true
pollster.workspace = true
wgpu.workspace = true
winit.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
wasm-bindgen-futures.workspace = true
web-sys.workspace = true

View File

@ -1,21 +0,0 @@
[package]
name = "wgpu-hello-windows-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu hello windows example"
publish = false
[[bin]]
name = "hello-windows"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
env_logger.workspace = true
pollster.workspace = true
wgpu.workspace = true
winit.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true

View File

@ -1,26 +0,0 @@
[package]
name = "wgpu-hello-workgroups-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu hello workgroups example"
publish = false
[[bin]]
name = "hello-workgroups"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
env_logger.workspace = true
futures-intrusive.workspace = true
log.workspace = true
pollster.workspace = true
wgpu.workspace = true
wgpu-example.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
wasm-bindgen-futures.workspace = true
web-sys = { workspace = true, features = ["Document"] }

View File

@ -1,27 +0,0 @@
[package]
name = "wgpu-hello-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu hello example"
publish = false
[[bin]]
name = "hello"
path = "src/main.rs"
[dependencies]
env_logger.workspace = true
glam.workspace = true
log.workspace = true
pollster.workspace = true
wgpu.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
wasm-bindgen-futures.workspace = true
[dev-dependencies]
wgpu-test.workspace = true

View File

@ -1,25 +0,0 @@
[package]
name = "wgpu-mipmap-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu mipmap example"
publish = false
[[bin]]
name = "mipmap"
path = "src/main.rs"
harness = false
[dependencies]
bytemuck.workspace = true
glam.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test.workspace = true

View File

@ -1,26 +0,0 @@
[package]
name = "wgpu-msaa-line-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu msaa line example"
publish = false
[[bin]]
name = "msaa-line"
path = "src/main.rs"
harness = false
[dependencies]
bytemuck.workspace = true
glam.workspace = true
log.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test.workspace = true

View File

@ -1,34 +0,0 @@
[package]
name = "wgpu-render-to-texture-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu render to texture example"
publish = false
[[bin]]
name = "render-to-texture"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
env_logger.workspace = true
futures-intrusive.workspace = true
log.workspace = true
pollster.workspace = true
wgpu.workspace = true
wgpu-example.workspace = true
winit.workspace = true
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
png.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
wasm-bindgen.workspace = true
wasm-bindgen-futures.workspace = true
web-sys = { workspace = true, features = [
"HtmlCanvasElement", "Document", "CanvasRenderingContext2d", "Window", "ImageData",
"HtmlImageElement"
] }

View File

@ -1,33 +0,0 @@
[package]
name = "wgpu-repeated-compute-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu repeated compute example"
publish = false
[[bin]]
name = "repeated-compute"
path = "src/main.rs"
[dependencies]
bytemuck.workspace = true
env_logger.workspace = true
futures-intrusive.workspace = true
getrandom = { version = "0.2.11", features = ["js"] }
log.workspace = true
pollster.workspace = true
wgpu.workspace = true
wgpu-example.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook.workspace = true
console_log.workspace = true
wasm-bindgen-futures.workspace = true
web-sys = { workspace = true, features = ["Document"] }
[dev-dependencies]
wgpu-test.workspace = true
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test.workspace = true

View File

@ -1,25 +0,0 @@
[package]
name = "wgpu-shadow-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu shadow example"
publish = false
[[bin]]
name = "shadow"
path = "src/main.rs"
harness = false
[dependencies]
bytemuck.workspace = true
glam.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test.workspace = true

View File

@ -1,28 +0,0 @@
[package]
name = "wgpu-skybox-example"
version.workspace = true
license.workspace = true
edition.workspace = true
description = "wgpu skybox example"
publish = false
[[bin]]
name = "skybox"
path = "src/main.rs"
harness = false
[dependencies]
bytemuck.workspace = true
ddsfile.workspace = true
glam.workspace = true
obj.workspace = true
log.workspace = true
wgpu-example.workspace = true
wgpu.workspace = true
winit.workspace = true
[dev-dependencies]
wgpu-test.workspace = true
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test.workspace = true

View File

@ -24,7 +24,7 @@ struct Example {
frame_num: usize, frame_num: usize,
} }
impl wgpu_example::framework::Example for Example { impl crate::framework::Example for Example {
fn required_limits() -> wgpu::Limits { fn required_limits() -> wgpu::Limits {
wgpu::Limits::downlevel_defaults() wgpu::Limits::downlevel_defaults()
} }
@ -320,29 +320,24 @@ impl wgpu_example::framework::Example for Example {
} }
/// run example /// run example
#[cfg(not(test))] pub fn main() {
fn main() { crate::framework::run::<Example>("boids");
wgpu_example::framework::run::<Example>("boids");
} }
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST: wgpu_example::framework::ExampleTestParams = static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "boids",
name: "boids", // Generated on 1080ti on Vk/Windows
// Generated on 1080ti on Vk/Windows image_path: "/examples/src/boids/screenshot.png",
image_path: "examples/boids/screenshot.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: wgpu::Features::default(),
optional_features: wgpu::Features::default(), base_test_parameters: wgpu_test::TestParameters::default()
base_test_parameters: wgpu_test::TestParameters::default() .downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS)
.downlevel_flags(wgpu::DownlevelFlags::COMPUTE_SHADERS) .limits(wgpu::Limits::downlevel_defaults())
.limits(wgpu::Limits::downlevel_defaults()) // Lots of validation errors, maybe related to https://github.com/gfx-rs/wgpu/issues/3160
// Lots of validation errors, maybe related to https://github.com/gfx-rs/wgpu/issues/3160 .expect_fail(wgpu_test::FailureCase::molten_vk()),
.expect_fail(wgpu_test::FailureCase::molten_vk()), comparisons: &[wgpu_test::ComparisonType::Mean(0.005)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.005)], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)]
wgpu_test::gpu_test_main!();

View File

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 116 KiB

View File

@ -131,7 +131,7 @@ impl Example {
} }
} }
impl wgpu_example::framework::Example for Example { impl crate::framework::Example for Example {
fn init( fn init(
config: &wgpu::SurfaceConfiguration, config: &wgpu::SurfaceConfiguration,
_adapter: &wgpu::Adapter, _adapter: &wgpu::Adapter,
@ -375,31 +375,26 @@ impl wgpu_example::framework::Example for Example {
} }
} }
#[cfg(not(test))] pub fn main() {
fn main() { crate::framework::run::<Example>("bunnymark");
wgpu_example::framework::run::<Example>("bunnymark");
} }
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST: wgpu_example::framework::ExampleTestParams = static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "bunnymark",
name: "bunnymark", image_path: "/examples/src/bunnymark/screenshot.png",
image_path: "/examples/bunnymark/screenshot.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: wgpu::Features::default(),
optional_features: wgpu::Features::default(), base_test_parameters: wgpu_test::TestParameters::default(),
base_test_parameters: wgpu_test::TestParameters::default(), // We're looking for very small differences, so look in the high percentiles.
// We're looking for very small differences, so look in the high percentiles. comparisons: &[
comparisons: &[ wgpu_test::ComparisonType::Mean(0.05),
wgpu_test::ComparisonType::Mean(0.05), wgpu_test::ComparisonType::Percentile {
wgpu_test::ComparisonType::Percentile { percentile: 0.99,
percentile: 0.99, threshold: 0.37,
threshold: 0.37, },
}, ],
], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)]
wgpu_test::gpu_test_main!();

View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

@ -63,7 +63,7 @@ impl Example {
} }
} }
impl wgpu_example::framework::Example for Example { impl crate::framework::Example for Example {
fn required_features() -> wgpu::Features { fn required_features() -> wgpu::Features {
wgpu::Features::CONSERVATIVE_RASTERIZATION wgpu::Features::CONSERVATIVE_RASTERIZATION
} }
@ -306,24 +306,19 @@ impl wgpu_example::framework::Example for Example {
} }
} }
#[cfg(not(test))] pub fn main() {
fn main() { crate::framework::run::<Example>("conservative-raster");
wgpu_example::framework::run::<Example>("conservative-raster");
} }
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST: wgpu_example::framework::ExampleTestParams = static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "conservative-raster",
name: "conservative-raster", image_path: "/examples/src/conservative_raster/screenshot.png",
image_path: "/examples/conservative-raster/screenshot.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: wgpu::Features::default(),
optional_features: wgpu::Features::default(), base_test_parameters: wgpu_test::TestParameters::default(),
base_test_parameters: wgpu_test::TestParameters::default(), comparisons: &[wgpu_test::ComparisonType::Mean(0.0)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.0)], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)]
wgpu_test::gpu_test_main!();

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@ -102,7 +102,7 @@ impl Example {
} }
} }
impl wgpu_example::framework::Example for Example { impl crate::framework::Example for Example {
fn optional_features() -> wgpu::Features { fn optional_features() -> wgpu::Features {
wgpu::Features::POLYGON_MODE_LINE wgpu::Features::POLYGON_MODE_LINE
} }
@ -371,49 +371,43 @@ impl wgpu_example::framework::Example for Example {
} }
} }
#[cfg(not(test))] pub fn main() {
fn main() { crate::framework::run::<Example>("cube");
wgpu_example::framework::run::<Example>("cube");
} }
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST: wgpu_example::framework::ExampleTestParams = static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "cube",
name: "cube", // Generated on 1080ti on Vk/Windows
// Generated on 1080ti on Vk/Windows image_path: "/examples/src/cube/screenshot.png",
image_path: "/examples/cube/screenshot.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: wgpu::Features::default(),
optional_features: wgpu::Features::default(), base_test_parameters: wgpu_test::TestParameters::default(),
base_test_parameters: wgpu_test::TestParameters::default(), comparisons: &[
comparisons: &[ wgpu_test::ComparisonType::Mean(0.04), // Bounded by Intel 630 on Vk/Windows
wgpu_test::ComparisonType::Mean(0.04), // Bounded by Intel 630 on Vk/Windows ],
], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST_LINES: wgpu_example::framework::ExampleTestParams = static TEST_LINES: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "cube-lines",
name: "cube-lines", // Generated on 1080ti on Vk/Windows
// Generated on 1080ti on Vk/Windows image_path: "/examples/src/cube/screenshot-lines.png",
image_path: "/examples/cube/screenshot-lines.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: wgpu::Features::POLYGON_MODE_LINE,
optional_features: wgpu::Features::POLYGON_MODE_LINE, base_test_parameters: wgpu_test::TestParameters::default(),
base_test_parameters: wgpu_test::TestParameters::default(), // We're looking for tiny changes here, so we focus on a spike in the 95th percentile.
// We're looking for tiny changes here, so we focus on a spike in the 95th percentile. comparisons: &[
comparisons: &[ wgpu_test::ComparisonType::Mean(0.05), // Bounded by Intel 630 on Vk/Windows
wgpu_test::ComparisonType::Mean(0.05), // Bounded by Intel 630 on Vk/Windows wgpu_test::ComparisonType::Percentile {
wgpu_test::ComparisonType::Percentile { percentile: 0.95,
percentile: 0.95, threshold: 0.36,
threshold: 0.36, }, // Bounded by 1080ti on DX12
}, // Bounded by 1080ti on DX12 ],
], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)]
wgpu_test::gpu_test_main!();

View File

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View File

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

@ -1,7 +1,6 @@
use std::sync::Arc; use std::sync::Arc;
use wgpu::{Instance, Surface, WasmNotSendSync}; use wgpu::{Instance, Surface};
use wgpu_test::GpuTestConfiguration;
use winit::{ use winit::{
dpi::PhysicalSize, dpi::PhysicalSize,
event::{Event, KeyEvent, StartCause, WindowEvent}, event::{Event, KeyEvent, StartCause, WindowEvent},
@ -496,8 +495,10 @@ pub fn parse_url_query_string<'a>(query: &'a str, search_key: &str) -> Option<&'
None None
} }
#[cfg(test)]
pub use wgpu_test::image::ComparisonType; pub use wgpu_test::image::ComparisonType;
#[cfg(test)]
#[derive(Clone)] #[derive(Clone)]
pub struct ExampleTestParams<E> { pub struct ExampleTestParams<E> {
pub name: &'static str, pub name: &'static str,
@ -512,9 +513,12 @@ pub struct ExampleTestParams<E> {
pub _phantom: std::marker::PhantomData<E>, pub _phantom: std::marker::PhantomData<E>,
} }
impl<E: Example + WasmNotSendSync> From<ExampleTestParams<E>> for GpuTestConfiguration { #[cfg(test)]
impl<E: Example + wgpu::WasmNotSendSync> From<ExampleTestParams<E>>
for wgpu_test::GpuTestConfiguration
{
fn from(params: ExampleTestParams<E>) -> Self { fn from(params: ExampleTestParams<E>) -> Self {
GpuTestConfiguration::new() wgpu_test::GpuTestConfiguration::new()
.name(params.name) .name(params.name)
.parameters({ .parameters({
assert_eq!(params.width % 64, 0, "width needs to be aligned 64"); assert_eq!(params.width % 64, 0, "width needs to be aligned 64");
@ -604,7 +608,7 @@ impl<E: Example + WasmNotSendSync> From<ExampleTestParams<E>> for GpuTestConfigu
let bytes = dst_buffer_slice.get_mapped_range().to_vec(); let bytes = dst_buffer_slice.get_mapped_range().to_vec();
wgpu_test::image::compare_image_output( wgpu_test::image::compare_image_output(
env!("CARGO_MANIFEST_DIR").to_string() + "/../../" + params.image_path, dbg!(env!("CARGO_MANIFEST_DIR").to_string() + "/../" + params.image_path),
&ctx.adapter_info, &ctx.adapter_info,
params.width, params.width,
params.height, params.height,

View File

@ -19,7 +19,7 @@ async fn run() {
log::info!("Selected adapter: {:?}", adapter.get_info()) log::info!("Selected adapter: {:?}", adapter.get_info())
} }
fn main() { pub fn main() {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
{ {
env_logger::init(); env_logger::init();

View File

@ -177,8 +177,7 @@ async fn execute_gpu_inner(
} }
} }
#[cfg(not(test))] pub fn main() {
fn main() {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
{ {
env_logger::init(); env_logger::init();
@ -194,6 +193,3 @@ fn main() {
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
#[cfg(test)]
wgpu_test::gpu_test_main!();

View File

@ -189,8 +189,7 @@ async fn get_data<T: bytemuck::Pod>(
staging_buffer.unmap(); staging_buffer.unmap();
} }
#[cfg(not(test))] pub fn main() {
fn main() {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
{ {
env_logger::builder() env_logger::builder()
@ -204,14 +203,11 @@ fn main() {
std::panic::set_hook(Box::new(console_error_panic_hook::hook)); std::panic::set_hook(Box::new(console_error_panic_hook::hook));
console_log::init_with_level(log::Level::Info).expect("could not initialize logger"); console_log::init_with_level(log::Level::Info).expect("could not initialize logger");
wgpu_example::utils::add_web_nothing_to_see_msg(); crate::utils::add_web_nothing_to_see_msg();
wasm_bindgen_futures::spawn_local(run()); wasm_bindgen_futures::spawn_local(run());
} }
} }
#[cfg(test)]
wgpu_test::gpu_test_main!();
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;

View File

@ -148,7 +148,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
.unwrap(); .unwrap();
} }
fn main() { pub fn main() {
let event_loop = EventLoop::new().unwrap(); let event_loop = EventLoop::new().unwrap();
let window = winit::window::Window::new(&event_loop).unwrap(); let window = winit::window::Window::new(&event_loop).unwrap();
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -161,7 +161,7 @@ async fn run(event_loop: EventLoop<()>, viewports: Vec<(Arc<Window>, wgpu::Color
.unwrap(); .unwrap();
} }
fn main() { pub fn main() {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
{ {
const WINDOW_SIZE: u32 = 128; const WINDOW_SIZE: u32 = 128;

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -178,7 +178,7 @@ async fn get_data<T: bytemuck::Pod>(
staging_buffer.unmap(); staging_buffer.unmap();
} }
fn main() { pub fn main() {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
{ {
env_logger::builder() env_logger::builder()
@ -192,7 +192,7 @@ fn main() {
std::panic::set_hook(Box::new(console_error_panic_hook::hook)); std::panic::set_hook(Box::new(console_error_panic_hook::hook));
console_log::init_with_level(log::Level::Info).expect("could not initialize logger"); console_log::init_with_level(log::Level::Info).expect("could not initialize logger");
wgpu_example::utils::add_web_nothing_to_see_msg(); crate::utils::add_web_nothing_to_see_msg();
wasm_bindgen_futures::spawn_local(run()); wasm_bindgen_futures::spawn_local(run());
} }

29
examples/src/lib.rs Normal file
View File

@ -0,0 +1,29 @@
pub mod framework;
pub mod utils;
pub mod boids;
pub mod bunnymark;
pub mod conservative_raster;
pub mod cube;
pub mod hello;
pub mod hello_compute;
pub mod hello_synchronization;
pub mod hello_triangle;
pub mod hello_windows;
pub mod hello_workgroups;
pub mod mipmap;
pub mod msaa_line;
pub mod render_to_texture;
pub mod repeated_compute;
pub mod shadow;
pub mod skybox;
pub mod srgb_blend;
pub mod stencil_triangles;
pub mod storage_texture;
pub mod texture_arrays;
pub mod timestamp_queries;
pub mod uniform_values;
pub mod water;
#[cfg(test)]
wgpu_test::gpu_test_main!();

112
examples/src/main.rs Normal file
View File

@ -0,0 +1,112 @@
const EXAMPLES: &[(&str, fn())] = &[
("boids", wgpu_examples::boids::main),
("bunnymark", wgpu_examples::bunnymark::main),
(
"conservative_raster",
wgpu_examples::conservative_raster::main,
),
("cube", wgpu_examples::cube::main),
("hello", wgpu_examples::hello::main),
("hello_compute", wgpu_examples::hello_compute::main),
(
"hello_synchronization",
wgpu_examples::hello_synchronization::main,
),
("hello_triangle", wgpu_examples::hello_triangle::main),
("hello_windows", wgpu_examples::hello_windows::main),
("hello_workgroups", wgpu_examples::hello_workgroups::main),
("mipmap", wgpu_examples::mipmap::main),
("msaa_line", wgpu_examples::msaa_line::main),
("render_to_texture", wgpu_examples::render_to_texture::main),
("repeated_compute", wgpu_examples::repeated_compute::main),
("shadow", wgpu_examples::shadow::main),
("skybox", wgpu_examples::skybox::main),
("srgb_blend", wgpu_examples::srgb_blend::main),
("stencil_triangles", wgpu_examples::stencil_triangles::main),
("storage_texture", wgpu_examples::storage_texture::main),
("texture_arrays", wgpu_examples::texture_arrays::main),
("timestamp_queries", wgpu_examples::timestamp_queries::main),
("uniform_values", wgpu_examples::uniform_values::main),
("water", wgpu_examples::water::main),
];
fn get_example_name() -> Option<String> {
cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {
let query_string = web_sys::window()?.location().search().ok()?;
wgpu_examples::framework::parse_url_query_string(&query_string, "example").map(String::from)
} else {
std::env::args().nth(1)
}
}
}
fn print_unknown_example(result: Option<String>) {
cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {
use wasm_bindgen::JsCast;
use web_sys::HtmlStyleElement;
// Get the document, header, and body elements.
let document = web_sys::window().unwrap().document().unwrap();
let head = document.head().unwrap();
let body = document.body().unwrap();
// Add a basic style sheet to center the text and remove some margin.
let style_sheet: HtmlStyleElement = document.create_element("style").unwrap().dyn_into().unwrap();
style_sheet.set_inner_text("div { text-align: center; } p { margin: 4px }");
head.append_child(&style_sheet).unwrap();
// A div to provide a container and some padding.
let div = document.create_element("div").unwrap();
body.append_child(&div).unwrap();
let user_message = if let Some(example) = result {
format!("Unknown example: {example}. Please choose an example!")
} else {
String::from("Please choose an example!")
};
// A header to display the message to the user.
let header = document.create_element("h1").unwrap();
header.set_text_content(Some(&user_message));
div.append_child(&header).unwrap();
// Write a link for each example, wrapped in a paragraph.
for (name, _) in EXAMPLES {
let paragraph = document.create_element("p").unwrap();
let link = document.create_element("a").unwrap();
link.set_text_content(Some(name));
link.set_attribute("href", &format!("?example={name}")).unwrap();
paragraph.append_child(&link).unwrap();
div.append_child(&paragraph).unwrap();
}
} else {
if let Some(example) = result {
println!("Unknown example: {}", example);
} else {
println!("Please specify an example as the first argument!");
}
println!("\nAvailable Examples:");
for (name, _) in EXAMPLES {
println!("\t{name}");
}
}
}
}
fn main() {
let Some(example) = get_example_name() else {
print_unknown_example(None);
return;
};
let Some((_, function)) = EXAMPLES.iter().find(|(name, _)| *name == example) else {
print_unknown_example(Some(example));
return;
};
function();
}

View File

@ -204,7 +204,7 @@ impl Example {
} }
} }
impl wgpu_example::framework::Example for Example { impl crate::framework::Example for Example {
fn optional_features() -> wgpu::Features { fn optional_features() -> wgpu::Features {
QUERY_FEATURES QUERY_FEATURES
} }
@ -500,38 +500,32 @@ impl wgpu_example::framework::Example for Example {
} }
} }
#[cfg(not(test))] pub fn main() {
fn main() { crate::framework::run::<Example>("mipmap");
wgpu_example::framework::run::<Example>("mipmap");
} }
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST: wgpu_example::framework::ExampleTestParams = static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "mipmap",
name: "mipmap", image_path: "/examples/src/mipmap/screenshot.png",
image_path: "/examples/mipmap/screenshot.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: wgpu::Features::default(),
optional_features: wgpu::Features::default(), base_test_parameters: wgpu_test::TestParameters::default(),
base_test_parameters: wgpu_test::TestParameters::default(), comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST_QUERY: wgpu_example::framework::ExampleTestParams = static TEST_QUERY: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "mipmap-query",
name: "mipmap-query", image_path: "/examples/src/mipmap/screenshot-query.png",
image_path: "/examples/mipmap/screenshot-query.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: QUERY_FEATURES,
optional_features: QUERY_FEATURES, base_test_parameters: wgpu_test::TestParameters::default(),
base_test_parameters: wgpu_test::TestParameters::default(), comparisons: &[wgpu_test::ComparisonType::Mean(0.025)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.025)], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)]
wgpu_test::gpu_test_main!();

View File

Before

Width:  |  Height:  |  Size: 494 KiB

After

Width:  |  Height:  |  Size: 494 KiB

View File

Before

Width:  |  Height:  |  Size: 487 KiB

After

Width:  |  Height:  |  Size: 487 KiB

View File

@ -120,7 +120,7 @@ impl Example {
} }
} }
impl wgpu_example::framework::Example for Example { impl crate::framework::Example for Example {
fn optional_features() -> wgpu::Features { fn optional_features() -> wgpu::Features {
wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
} }
@ -313,32 +313,27 @@ impl wgpu_example::framework::Example for Example {
} }
} }
#[cfg(not(test))] pub fn main() {
fn main() { crate::framework::run::<Example>("msaa-line");
wgpu_example::framework::run::<Example>("msaa-line");
} }
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST: wgpu_example::framework::ExampleTestParams = static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "msaa-line",
name: "msaa-line", image_path: "/examples/src/msaa_line/screenshot.png",
image_path: "/examples/msaa-line/screenshot.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
optional_features: wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES, base_test_parameters: wgpu_test::TestParameters::default(),
base_test_parameters: wgpu_test::TestParameters::default(), // There's a lot of natural variance so we check the weighted median too to differentiate
// There's a lot of natural variance so we check the weighted median too to differentiate // real failures from variance.
// real failures from variance. comparisons: &[
comparisons: &[ wgpu_test::ComparisonType::Mean(0.065),
wgpu_test::ComparisonType::Mean(0.065), wgpu_test::ComparisonType::Percentile {
wgpu_test::ComparisonType::Percentile { percentile: 0.5,
percentile: 0.5, threshold: 0.29,
threshold: 0.29, },
}, ],
], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)]
wgpu_test::gpu_test_main!();

View File

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 138 KiB

View File

@ -1,7 +1,7 @@
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
use wgpu_example::utils::output_image_native; use crate::utils::output_image_native;
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
use wgpu_example::utils::output_image_wasm; use crate::utils::output_image_wasm;
const TEXTURE_DIMS: (usize, usize) = (512, 512); const TEXTURE_DIMS: (usize, usize) = (512, 512);
@ -148,7 +148,7 @@ async fn run(_path: Option<String>) {
log::info!("Done."); log::info!("Done.");
} }
fn main() { pub fn main() {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
{ {
env_logger::builder() env_logger::builder()

View File

@ -126,7 +126,7 @@ async fn compute(local_buffer: &mut [u32], context: &WgpuContext) {
context.output_staging_buffer.unmap(); context.output_staging_buffer.unmap();
} }
fn main() { pub fn main() {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
{ {
env_logger::builder() env_logger::builder()
@ -140,7 +140,7 @@ fn main() {
std::panic::set_hook(Box::new(console_error_panic_hook::hook)); std::panic::set_hook(Box::new(console_error_panic_hook::hook));
console_log::init_with_level(log::Level::Info).expect("could not initialize logger"); console_log::init_with_level(log::Level::Info).expect("could not initialize logger");
wgpu_example::utils::add_web_nothing_to_see_msg(); crate::utils::add_web_nothing_to_see_msg();
wasm_bindgen_futures::spawn_local(run()); wasm_bindgen_futures::spawn_local(run());
} }

View File

@ -201,7 +201,7 @@ impl Example {
} }
} }
impl wgpu_example::framework::Example for Example { impl crate::framework::Example for Example {
fn optional_features() -> wgpu::Features { fn optional_features() -> wgpu::Features {
wgpu::Features::DEPTH_CLIP_CONTROL wgpu::Features::DEPTH_CLIP_CONTROL
} }
@ -834,30 +834,25 @@ impl wgpu_example::framework::Example for Example {
} }
} }
#[cfg(not(test))] pub fn main() {
fn main() { crate::framework::run::<Example>("shadow");
wgpu_example::framework::run::<Example>("shadow");
} }
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST: wgpu_example::framework::ExampleTestParams = static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "shadow",
name: "shadow", image_path: "/examples/src/shadow/screenshot.png",
image_path: "/examples/shadow/screenshot.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: wgpu::Features::default(),
optional_features: wgpu::Features::default(), base_test_parameters: wgpu_test::TestParameters::default()
base_test_parameters: wgpu_test::TestParameters::default() .downlevel_flags(wgpu::DownlevelFlags::COMPARISON_SAMPLERS)
.downlevel_flags(wgpu::DownlevelFlags::COMPARISON_SAMPLERS) // rpi4 on VK doesn't work: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3916
// rpi4 on VK doesn't work: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3916 .expect_fail(wgpu_test::FailureCase::backend_adapter(
.expect_fail(wgpu_test::FailureCase::backend_adapter( wgpu::Backends::VULKAN,
wgpu::Backends::VULKAN, "V3D",
"V3D", )),
)), comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)]
wgpu_test::gpu_test_main!();

View File

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

View File

@ -89,7 +89,7 @@ impl Example {
} }
} }
impl wgpu_example::framework::Example for Example { impl crate::framework::Example for Example {
fn optional_features() -> wgpu::Features { fn optional_features() -> wgpu::Features {
wgpu::Features::TEXTURE_COMPRESSION_ASTC wgpu::Features::TEXTURE_COMPRESSION_ASTC
| wgpu::Features::TEXTURE_COMPRESSION_ETC2 | wgpu::Features::TEXTURE_COMPRESSION_ETC2
@ -104,7 +104,7 @@ impl wgpu_example::framework::Example for Example {
) -> Self { ) -> Self {
let mut entities = Vec::new(); let mut entities = Vec::new();
{ {
let source = include_bytes!("../models/teslacyberv3.0.obj"); let source = include_bytes!("models/teslacyberv3.0.obj");
let data = obj::ObjData::load_buf(&source[..]).unwrap(); let data = obj::ObjData::load_buf(&source[..]).unwrap();
let mut vertices = Vec::new(); let mut vertices = Vec::new();
for object in data.objects { for object in data.objects {
@ -306,10 +306,10 @@ impl wgpu_example::framework::Example for Example {
wgpu::TextureFormat::Astc { wgpu::TextureFormat::Astc {
block: AstcBlock::B4x4, block: AstcBlock::B4x4,
channel: AstcChannel::UnormSrgb, channel: AstcChannel::UnormSrgb,
} => &include_bytes!("../images/astc.dds")[..], } => &include_bytes!("images/astc.dds")[..],
wgpu::TextureFormat::Etc2Rgb8UnormSrgb => &include_bytes!("../images/etc2.dds")[..], wgpu::TextureFormat::Etc2Rgb8UnormSrgb => &include_bytes!("images/etc2.dds")[..],
wgpu::TextureFormat::Bc1RgbaUnormSrgb => &include_bytes!("../images/bc1.dds")[..], wgpu::TextureFormat::Bc1RgbaUnormSrgb => &include_bytes!("images/bc1.dds")[..],
wgpu::TextureFormat::Bgra8UnormSrgb => &include_bytes!("../images/bgra.dds")[..], wgpu::TextureFormat::Bgra8UnormSrgb => &include_bytes!("images/bgra.dds")[..],
_ => unreachable!(), _ => unreachable!(),
}; };
@ -455,68 +455,60 @@ impl wgpu_example::framework::Example for Example {
} }
} }
#[cfg(not(test))] pub fn main() {
fn main() { crate::framework::run::<Example>("skybox");
wgpu_example::framework::run::<Example>("skybox");
} }
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST: wgpu_example::framework::ExampleTestParams = static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "skybox",
name: "skybox", image_path: "/examples/src/skybox/screenshot.png",
image_path: "/examples/skybox/screenshot.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: wgpu::Features::default(),
optional_features: wgpu::Features::default(), base_test_parameters: wgpu_test::TestParameters::default().expect_fail(
base_test_parameters: wgpu_test::TestParameters::default().expect_fail( wgpu_test::FailureCase::backend_adapter(wgpu::Backends::GL, "ANGLE"),
wgpu_test::FailureCase::backend_adapter(wgpu::Backends::GL, "ANGLE"), ),
), comparisons: &[wgpu_test::ComparisonType::Mean(0.015)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.015)], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST_BCN: wgpu_example::framework::ExampleTestParams = static TEST_BCN: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "skybox-bc1",
name: "skybox-bc1", image_path: "/examples/src/skybox/screenshot-bc1.png",
image_path: "/examples/skybox/screenshot-bc1.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: wgpu::Features::TEXTURE_COMPRESSION_BC,
optional_features: wgpu::Features::TEXTURE_COMPRESSION_BC, base_test_parameters: wgpu_test::TestParameters::default(), // https://bugs.chromium.org/p/angleproject/issues/detail?id=7056
base_test_parameters: wgpu_test::TestParameters::default(), // https://bugs.chromium.org/p/angleproject/issues/detail?id=7056 comparisons: &[wgpu_test::ComparisonType::Mean(0.02)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.02)], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST_ETC2: wgpu_example::framework::ExampleTestParams = static TEST_ETC2: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "skybox-etc2",
name: "skybox-etc2", image_path: "/examples/src/skybox/screenshot-etc2.png",
image_path: "/examples/skybox/screenshot-etc2.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: wgpu::Features::TEXTURE_COMPRESSION_ETC2,
optional_features: wgpu::Features::TEXTURE_COMPRESSION_ETC2, base_test_parameters: wgpu_test::TestParameters::default(), // https://bugs.chromium.org/p/angleproject/issues/detail?id=7056
base_test_parameters: wgpu_test::TestParameters::default(), // https://bugs.chromium.org/p/angleproject/issues/detail?id=7056 comparisons: &[wgpu_test::ComparisonType::Mean(0.015)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.015)], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST_ASTC: wgpu_example::framework::ExampleTestParams = static TEST_ASTC: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "skybox-astc",
name: "skybox-astc", image_path: "/examples/src/skybox/screenshot-astc.png",
image_path: "/examples/skybox/screenshot-astc.png", width: 1024,
width: 1024, height: 768,
height: 768, optional_features: wgpu::Features::TEXTURE_COMPRESSION_ASTC,
optional_features: wgpu::Features::TEXTURE_COMPRESSION_ASTC, base_test_parameters: wgpu_test::TestParameters::default(), // https://bugs.chromium.org/p/angleproject/issues/detail?id=7056
base_test_parameters: wgpu_test::TestParameters::default(), // https://bugs.chromium.org/p/angleproject/issues/detail?id=7056 comparisons: &[wgpu_test::ComparisonType::Mean(0.016)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.016)], _phantom: std::marker::PhantomData::<Example>,
_phantom: std::marker::PhantomData::<Example>, };
};
#[cfg(test)]
wgpu_test::gpu_test_main!();

View File

Before

Width:  |  Height:  |  Size: 546 KiB

After

Width:  |  Height:  |  Size: 546 KiB

View File

Before

Width:  |  Height:  |  Size: 536 KiB

After

Width:  |  Height:  |  Size: 536 KiB

View File

Before

Width:  |  Height:  |  Size: 456 KiB

After

Width:  |  Height:  |  Size: 456 KiB

View File

Before

Width:  |  Height:  |  Size: 588 KiB

After

Width:  |  Height:  |  Size: 588 KiB

View File

@ -56,7 +56,7 @@ struct Example<const SRGB: bool> {
pipeline: wgpu::RenderPipeline, pipeline: wgpu::RenderPipeline,
} }
impl<const SRGB: bool> wgpu_example::framework::Example for Example<SRGB> { impl<const SRGB: bool> crate::framework::Example for Example<SRGB> {
const SRGB: bool = SRGB; const SRGB: bool = SRGB;
fn optional_features() -> wgpu::Features { fn optional_features() -> wgpu::Features {
@ -211,46 +211,40 @@ impl<const SRGB: bool> wgpu_example::framework::Example for Example<SRGB> {
} }
} }
#[cfg(not(test))] pub fn main() {
fn main() {
let mut args = std::env::args(); let mut args = std::env::args();
args.next(); args.next();
if Some("linear") == args.next().as_deref() { if Some("linear") == args.next().as_deref() {
wgpu_example::framework::run::<Example<false>>("srgb-blend-linear"); crate::framework::run::<Example<false>>("srgb-blend-linear");
} else { } else {
wgpu_example::framework::run::<Example<true>>("srgb-blend-srg"); crate::framework::run::<Example<true>>("srgb-blend-srg");
} }
} }
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST_SRGB: wgpu_example::framework::ExampleTestParams = static TEST_SRGB: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "srgb-blend-srg",
name: "srgb-blend-srg", // Generated on WARP/Windows
// Generated on WARP/Windows image_path: "/examples/src/srgb_blend/screenshot-srgb.png",
image_path: "/examples/srgb-blend/screenshot-srgb.png", width: 192,
width: 192, height: 192,
height: 192, optional_features: wgpu::Features::default(),
optional_features: wgpu::Features::default(), base_test_parameters: wgpu_test::TestParameters::default(),
base_test_parameters: wgpu_test::TestParameters::default(), comparisons: &[wgpu_test::ComparisonType::Mean(0.04)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.04)], _phantom: std::marker::PhantomData::<Example<true>>,
_phantom: std::marker::PhantomData::<Example<true>>, };
};
#[cfg(test)] #[cfg(test)]
#[wgpu_test::gpu_test] #[wgpu_test::gpu_test]
static TEST_LINEAR: wgpu_example::framework::ExampleTestParams = static TEST_LINEAR: crate::framework::ExampleTestParams = crate::framework::ExampleTestParams {
wgpu_example::framework::ExampleTestParams { name: "srgb-blend-linear",
name: "srgb-blend-linear", // Generated on WARP/Windows
// Generated on WARP/Windows image_path: "/examples/src/srgb_blend/screenshot-linear.png",
image_path: "/examples/srgb-blend/screenshot-linear.png", width: 192,
width: 192, height: 192,
height: 192, optional_features: wgpu::Features::default(),
optional_features: wgpu::Features::default(), base_test_parameters: wgpu_test::TestParameters::default(),
base_test_parameters: wgpu_test::TestParameters::default(), comparisons: &[wgpu_test::ComparisonType::Mean(0.04)],
comparisons: &[wgpu_test::ComparisonType::Mean(0.04)], _phantom: std::marker::PhantomData::<Example<false>>,
_phantom: std::marker::PhantomData::<Example<false>>, };
};
#[cfg(test)]
wgpu_test::gpu_test_main!();

View File

Before

Width:  |  Height:  |  Size: 915 B

After

Width:  |  Height:  |  Size: 915 B

View File

Before

Width:  |  Height:  |  Size: 704 B

After

Width:  |  Height:  |  Size: 704 B

Some files were not shown because too many files have changed in this diff Show More