From 3231f488e3225bf0985b7b19dec6d7329ac938f0 Mon Sep 17 00:00:00 2001 From: Kyle Cesare Date: Fri, 3 Sep 2021 21:53:17 -0700 Subject: [PATCH] examples: update to imgui-wgpu 0.17/wgpu 0.10 --- CHANGELOG.md | 3 + implot-examples/implot-glium-demo/Cargo.lock | 6 +- implot-examples/implot-wgpu-demo/Cargo.lock | 369 ++++++------------ implot-examples/implot-wgpu-demo/Cargo.toml | 6 +- .../implot-wgpu-demo/src/support/mod.rs | 34 +- 5 files changed, 142 insertions(+), 276 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 583b3d9..3889cef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## Unreleased +### General notes +* Updated imgui-rs dependency to 0.7 +* Examples: updated wgpu dependency to 0.10 and imgui-wgpu to 0.17 ## v0.5.0 ### General notes diff --git a/implot-examples/implot-glium-demo/Cargo.lock b/implot-examples/implot-glium-demo/Cargo.lock index 11bb226..ec7142a 100644 --- a/implot-examples/implot-glium-demo/Cargo.lock +++ b/implot-examples/implot-glium-demo/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "ab_glyph_rasterizer" version = "0.1.4" @@ -671,7 +673,7 @@ dependencies = [ [[package]] name = "implot" -version = "0.4.0" +version = "0.5.0" dependencies = [ "bitflags", "imgui", @@ -698,7 +700,7 @@ dependencies = [ [[package]] name = "implot-sys" -version = "0.4.0" +version = "0.5.0" dependencies = [ "cc", "imgui-sys", diff --git a/implot-examples/implot-wgpu-demo/Cargo.lock b/implot-examples/implot-wgpu-demo/Cargo.lock index e9f0f80..1c55204 100644 --- a/implot-examples/implot-wgpu-demo/Cargo.lock +++ b/implot-examples/implot-wgpu-demo/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "ab_glyph_rasterizer" version = "0.1.4" @@ -27,15 +29,15 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.5.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "be4dc07131ffa69b8072d35f5007352af944213cde02545e2103680baed38fcd" [[package]] name = "ash" -version = "0.32.1" +version = "0.33.2+1.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06063a002a77d2734631db74e8f4ce7148b77fe522e6bca46f2ae7774fd48112" +checksum = "73e2b957a47afef62973ed5fa0a52afb3289c7a243bfbc3906090b8434971237" dependencies = [ "libloading 0.7.0", ] @@ -106,9 +108,6 @@ name = "cc" version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" -dependencies = [ - "jobserver", -] [[package]] name = "cfg-if" @@ -265,9 +264,9 @@ dependencies = [ [[package]] name = "d3d12" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "091ed1b25fe47c7ff129fc440c23650b6114f36aa00bc7212cc8041879294428" +checksum = "2daefd788d1e96e0a9d66dee4b828b883509bc3ea9ce30665f04c3246372690c" dependencies = [ "bitflags", "libloading 0.7.0", @@ -351,9 +350,9 @@ dependencies = [ [[package]] name = "fixedbitset" -version = "0.2.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" +checksum = "398ea4fabe40b9b0d885340a2a991a44c8a645624075ad966d21f88688e2b69e" [[package]] name = "fnv" @@ -496,157 +495,11 @@ dependencies = [ "byteorder", ] -[[package]] -name = "gfx-auxil" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccf8711c9994dfa34337466bee3ae1462e172874c432ce4eb120ab2e98d39cf" -dependencies = [ - "fxhash", - "gfx-hal", - "spirv_cross", -] - -[[package]] -name = "gfx-backend-dx11" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f839f27f8c8a6dc553ccca7f5b35a42009432bc25db9688bba7061cd394161f" -dependencies = [ - "arrayvec", - "bitflags", - "gfx-auxil", - "gfx-hal", - "libloading 0.7.0", - "log", - "parking_lot", - "range-alloc", - "raw-window-handle", - "smallvec", - "spirv_cross", - "thunderdome", - "winapi 0.3.9", - "wio", -] - -[[package]] -name = "gfx-backend-dx12" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3937738b0da5839bba4e33980d29f9a06dbce184d04a3a08c9a949e7953700e3" -dependencies = [ - "arrayvec", - "bit-set", - "bitflags", - "d3d12", - "gfx-auxil", - "gfx-hal", - "log", - "parking_lot", - "range-alloc", - "raw-window-handle", - "smallvec", - "spirv_cross", - "thunderdome", - "winapi 0.3.9", -] - -[[package]] -name = "gfx-backend-empty" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ac55ada4bfcd35479b3421eea324d36d7da5f724e2f66ecb36d4efdb7041a5e" -dependencies = [ - "gfx-hal", - "log", - "raw-window-handle", -] - -[[package]] -name = "gfx-backend-gl" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0caa03d6e0b7b4f202aea1f20c3f3288cfa06d92d24cea9d69c9a7627967244a" -dependencies = [ - "arrayvec", - "bitflags", - "fxhash", - "gfx-hal", - "glow", - "js-sys", - "khronos-egl", - "libloading 0.7.0", - "log", - "naga", - "parking_lot", - "raw-window-handle", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "gfx-backend-metal" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "340895ad544ba46433acb3bdabece0ef16f2dbedc030adbd7c9eaf2839fbed41" -dependencies = [ - "arrayvec", - "bitflags", - "block", - "cocoa-foundation", - "copyless", - "foreign-types", - "fxhash", - "gfx-hal", - "log", - "metal", - "naga", - "objc", - "parking_lot", - "profiling", - "range-alloc", - "raw-window-handle", - "storage-map", -] - -[[package]] -name = "gfx-backend-vulkan" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a353fc6fdb42ec646de49bbb74e4870e37a7e680caf33f3ac0615c30b1146d94" -dependencies = [ - "arrayvec", - "ash", - "byteorder", - "core-graphics-types", - "gfx-hal", - "inplace_it", - "log", - "naga", - "objc", - "parking_lot", - "raw-window-handle", - "smallvec", - "winapi 0.3.9", -] - -[[package]] -name = "gfx-hal" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d285bfd566f6b9134af908446ca350c0a1047495dfb9bbd826e701e8ee1d259" -dependencies = [ - "bitflags", - "naga", - "raw-window-handle", - "thiserror", -] - [[package]] name = "glow" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b80b98efaa8a34fce11d60dd2ce2760d5d83c373cbcc73bb87c2a3a84a54108" +checksum = "4f04649123493bc2483cbef4daddb45d40bbdae5adb221a63a23efdb0cc99520" dependencies = [ "js-sys", "slotmap", @@ -656,9 +509,9 @@ dependencies = [ [[package]] name = "gpu-alloc" -version = "0.4.5" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76088804bb65a6f3b880bea9306fdaeffb25ebb453105fafa691282ee9fdba" +checksum = "ab8524eac5fc9d05625c891adf78fcf64dc0ee9f8d0882874b9f220f42b442bf" dependencies = [ "bitflags", "gpu-alloc-types", @@ -675,13 +528,13 @@ dependencies = [ [[package]] name = "gpu-descriptor" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d74668a6a6f0202e29f212a6d47ef8c7e092a76f4ab267b0065b6e0d175e45c6" +checksum = "d7a237f0419ab10d17006d55c62ac4f689a6bf52c75d3f38b8361d249e8d4b0b" dependencies = [ "bitflags", "gpu-descriptor-types", - "hashbrown", + "hashbrown 0.9.1", ] [[package]] @@ -702,6 +555,12 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + [[package]] name = "ident_case" version = "1.0.1" @@ -731,9 +590,9 @@ dependencies = [ [[package]] name = "imgui-wgpu" -version = "0.15.1" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e416ae1d240daa57a0d2a143251e6f925ca3705a1c8f58c986f9a1a17f98b56a" +checksum = "e06d48d73d62ba5ecc91a1c389579d1a90c69b52a11b19268aa7c14f8baeefbf" dependencies = [ "bytemuck", "imgui", @@ -754,7 +613,7 @@ dependencies = [ [[package]] name = "implot" -version = "0.4.0" +version = "0.5.0" dependencies = [ "bitflags", "imgui", @@ -765,7 +624,7 @@ dependencies = [ [[package]] name = "implot-sys" -version = "0.4.0" +version = "0.5.0" dependencies = [ "cc", "imgui-sys", @@ -787,12 +646,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.11.2", ] [[package]] @@ -825,15 +684,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" -[[package]] -name = "jobserver" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" version = "0.3.51" @@ -877,9 +727,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.85" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3" +checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" [[package]] name = "libloading" @@ -951,13 +801,13 @@ dependencies = [ [[package]] name = "metal" -version = "0.22.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c12e48c737ee9a55e8bb2352bcde588f79ae308d3529ee888f7cc0f469b5777" +checksum = "e0514f491f4cc03632ab399ee01e2c1c1b12d3e1cf2d667c1ff5f87d6dcd2084" dependencies = [ "bitflags", "block", - "cocoa-foundation", + "core-graphics-types", "foreign-types", "log", "objc", @@ -1008,9 +858,9 @@ dependencies = [ [[package]] name = "naga" -version = "0.4.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f470a97eafcdd0dbea43d5e1a8ef3557aa31f49ba643d9430dbbf911c162b24c" +checksum = "9b136bf483e309f330c74880370fa6f0553d9249399ac1dfa8e92c96a1612add" dependencies = [ "bit-set", "bitflags", @@ -1019,7 +869,8 @@ dependencies = [ "log", "num-traits", "petgraph", - "spirv_headers", + "rose_tree", + "spirv", "thiserror", ] @@ -1199,9 +1050,9 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "petgraph" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" +checksum = "4a13a2fa9d0b63e5f22328828741e523766fff0ee9e779316902290dff3f824f" dependencies = [ "fixedbitset", "indexmap", @@ -1291,6 +1142,21 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "renderdoc-sys" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1382d1f0a252c4bf97dc20d979a2fdd05b024acd7c2ed0f7595d7817666a157" + +[[package]] +name = "rose_tree" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcd16c61e9205949fa4f8a22096705b4c2f8b8025b2ff67ff6c86afd854039ae" +dependencies = [ + "petgraph", +] + [[package]] name = "rusttype" version = "0.9.2" @@ -1342,9 +1208,12 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "slotmap" -version = "0.4.0" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c46a3482db8f247956e464d783693ece164ca056e6e67563ee5505bdb86452cd" +checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342" +dependencies = [ + "version_check", +] [[package]] name = "smallvec" @@ -1354,9 +1223,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "smithay-client-toolkit" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "316e13a3eb853ce7bf72ad3530dc186cb2005c57c521ef5f4ada5ee4eed74de6" +checksum = "4750c76fd5d3ac95fa3ed80fe667d6a3d8590a960e5b575b98eea93339a80b80" dependencies = [ "andrew", "bitflags", @@ -1372,35 +1241,15 @@ dependencies = [ ] [[package]] -name = "spirv_cross" -version = "0.23.0" +name = "spirv" +version = "0.2.0+1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06db6bd7b6518f761593783e2896eefe55e90455efc5f44511078ce0426ed418" -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" +checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830" 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.9.3" @@ -1429,30 +1278,24 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.23" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" +checksum = "283d5230e63df9608ac7d9691adc1dfb6e701225436eb64d0b9a7f0a5a04f6ec" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.23" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" +checksum = "fa3884228611f5cd3608e2d409bf7dce832e4eb3135e3f11addbd7e41bd68e71" dependencies = [ "proc-macro2", "quote", "syn", ] -[[package]] -name = "thunderdome" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87b4947742c93ece24a0032141d9caa3d853752e694a57e35029dd2bd08673e0" - [[package]] name = "toml" version = "0.5.8" @@ -1638,9 +1481,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.50" +version = "0.3.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be" +checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" dependencies = [ "js-sys", "wasm-bindgen", @@ -1648,9 +1491,9 @@ dependencies = [ [[package]] name = "wgpu" -version = "0.8.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "215fd50e66f794bd16683e7e0e0b9b53be265eb10fdf02276caf5de3e5743fcf" +checksum = "3d92a4fe73b1e7d7ef99938dacd49258cbf1ad87cdb5bf6efa20c27447442b45" dependencies = [ "arrayvec", "js-sys", @@ -1663,29 +1506,21 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "wgpu-core", + "wgpu-hal", "wgpu-types", ] [[package]] name = "wgpu-core" -version = "0.8.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d56c368fc0e6f3927c711d2b55a51ad4321218efc0239c4acf69e456ab70399" +checksum = "425b975c319d311e051bf3afb54120a34b187f9d889edc68e347567e512774c8" dependencies = [ "arrayvec", "bitflags", "cfg_aliases", "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", @@ -1693,14 +1528,49 @@ dependencies = [ "raw-window-handle", "smallvec", "thiserror", + "wgpu-hal", "wgpu-types", ] [[package]] -name = "wgpu-types" -version = "0.8.0" +name = "wgpu-hal" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa248d90c8e6832269b8955bf800e8241f942c25e18a235b7752226804d21556" +checksum = "cd9bf514ccb78d4b409bb09db9d6c11ac54c9f69112faf5c0440bf54fdfb45ce" +dependencies = [ + "arrayvec", + "ash", + "bit-set", + "bitflags", + "block", + "core-graphics-types", + "d3d12", + "foreign-types", + "fxhash", + "glow", + "gpu-alloc", + "gpu-descriptor", + "inplace_it", + "khronos-egl", + "libloading 0.7.0", + "log", + "metal", + "naga", + "objc", + "parking_lot", + "range-alloc", + "raw-window-handle", + "renderdoc-sys", + "thiserror", + "wgpu-types", + "winapi 0.3.9", +] + +[[package]] +name = "wgpu-types" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25feb2fbf24ab3219a9f10890ceb8e1ef02b13314ed89d64a9ae99dcad883e18" dependencies = [ "bitflags", ] @@ -1779,15 +1649,6 @@ dependencies = [ "x11-dl", ] -[[package]] -name = "wio" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "ws2_32-sys" version = "0.2.1" diff --git a/implot-examples/implot-wgpu-demo/Cargo.toml b/implot-examples/implot-wgpu-demo/Cargo.toml index 454ec88..09c9cc4 100644 --- a/implot-examples/implot-wgpu-demo/Cargo.toml +++ b/implot-examples/implot-wgpu-demo/Cargo.toml @@ -3,15 +3,15 @@ name = "implot-wgpu-demo" version = "0.1.0" authors = ["Benedikt Mandelkow ", "imgui-wgpu contributors"] edition = "2018" +resolver = "2" [dependencies] implot = { path = "../../" } -wgpu = "0.8.1" +wgpu = "0.10" winit = "0.24" # opening windows and handling input futures = "^0.3.5" # executing async functions using blocking executor imgui = "=0.7.0" imgui-winit-support = "=0.7.0" # connection of input (keys) to imgui -#imgui-wgpu = "=0.13.0" # imgui backend for drawing using wgpu -imgui-wgpu = "=0.15.1" +imgui-wgpu = "=0.17.0" examples-shared = { path = "../examples-shared" } diff --git a/implot-examples/implot-wgpu-demo/src/support/mod.rs b/implot-examples/implot-wgpu-demo/src/support/mod.rs index f8f9ab0..c4161ba 100644 --- a/implot-examples/implot-wgpu-demo/src/support/mod.rs +++ b/implot-examples/implot-wgpu-demo/src/support/mod.rs @@ -17,8 +17,7 @@ pub struct System { pub platform: WinitPlatform, pub font_size: f32, pub hidpi_factor: f64, - pub sc_desc: wgpu::SwapChainDescriptor, - pub swap_chain: wgpu::SwapChain, + pub surface_conf: wgpu::SurfaceConfiguration, pub window: Window, pub device: wgpu::Device, pub queue: wgpu::Queue, @@ -28,7 +27,7 @@ pub struct System { pub fn init(title: &str) -> System { // Set up window and GPU let event_loop = EventLoop::new(); - let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY); + let instance = wgpu::Instance::new(wgpu::Backends::PRIMARY); let (window, size, surface) = { let window = Window::new(&event_loop).unwrap(); @@ -54,15 +53,15 @@ pub fn init(title: &str) -> System { block_on(adapter.request_device(&wgpu::DeviceDescriptor::default(), None)).unwrap(); // Set up swap chain - let sc_desc = wgpu::SwapChainDescriptor { - usage: wgpu::TextureUsage::RENDER_ATTACHMENT, + let surface_conf = wgpu::SurfaceConfiguration { + usage: wgpu::TextureUsages::RENDER_ATTACHMENT, format: wgpu::TextureFormat::Bgra8UnormSrgb, width: size.width as u32, height: size.height as u32, present_mode: wgpu::PresentMode::Mailbox, }; - let swap_chain = device.create_swap_chain(&surface, &sc_desc); + surface.configure(&device, &surface_conf); // Set up dear imgui let mut imgui = imgui::Context::create(); @@ -93,7 +92,7 @@ pub fn init(title: &str) -> System { // Set up dear imgui wgpu renderer // let renderer_config = RendererConfig { - texture_format: sc_desc.format, + texture_format: surface_conf.format, ..Default::default() }; @@ -106,8 +105,7 @@ pub fn init(title: &str) -> System { platform, font_size, hidpi_factor, - sc_desc, - swap_chain, + surface_conf, window, device, queue, @@ -123,10 +121,9 @@ impl System { mut renderer, // Currently not used, but was used pre-refactor // mut hidpi_factor, - mut sc_desc, + mut surface_conf, mut platform, window, - mut swap_chain, device, queue, surface, @@ -153,9 +150,9 @@ impl System { let size = window.inner_size(); // Recreate the swap chain with the new size - sc_desc.width = size.width as u32; - sc_desc.height = size.height as u32; - swap_chain = device.create_swap_chain(&surface, &sc_desc); + surface_conf.width = size.width as u32; + surface_conf.height = size.height as u32; + surface.configure(&device, &surface_conf); } Event::WindowEvent { event: WindowEvent::CloseRequested, @@ -167,13 +164,16 @@ impl System { imgui.io_mut().update_delta_time(now - last_frame); last_frame = now; - let frame = match swap_chain.get_current_frame() { - Ok(frame) => frame, + let frame = match surface.get_current_frame() { + Ok(frame) => frame.output, Err(e) => { eprintln!("dropped frame: {:?}", e); return; } }; + let view = frame + .texture + .create_view(&wgpu::TextureViewDescriptor::default()); platform .prepare_frame(imgui.io_mut(), &window) @@ -199,7 +199,7 @@ impl System { let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: None, color_attachments: &[wgpu::RenderPassColorAttachment { - view: &frame.output.view, + view: &view, resolve_target: None, ops: wgpu::Operations { load: wgpu::LoadOp::Clear(wgpu::Color {