From c373595c66af6e6e27771cfb5868015494bf839a Mon Sep 17 00:00:00 2001 From: Rajesh Malviya Date: Tue, 24 Oct 2023 20:46:48 +0000 Subject: [PATCH] update wgpu to current trunk (#306) --- Cargo.lock | 206 +++++++++++++-------- Cargo.toml | 35 ++-- examples/capture/CMakeLists.txt | 2 +- examples/compute/CMakeLists.txt | 2 +- examples/enumerate_adapters/CMakeLists.txt | 2 +- examples/framework/CMakeLists.txt | 2 +- examples/texture_arrays/CMakeLists.txt | 2 +- examples/triangle/CMakeLists.txt | 2 +- ffi/wgpu.h | 27 ++- src/conv.rs | 66 +++++-- 10 files changed, 224 insertions(+), 122 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb005ca0..7a339609 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,20 +4,21 @@ version = 3 [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "cd7d5a2cecb58716e47d67d5703a249964b14c7be1ec3cad3affc295b2d1c35d" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] name = "aho-corasick" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -63,17 +64,17 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bindgen" -version = "0.66.1" +version = "0.68.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "cexpr", "clang-sys", "lazy_static", @@ -113,9 +114,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" dependencies = [ "serde", ] @@ -210,7 +211,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e16e44ab292b1dddfdaf7be62cfd8877df52f2f3fde5858d95bab606be259f20" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "libloading 0.8.1", "winapi", ] @@ -229,25 +230,14 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" dependencies = [ - "errno-dragonfly", "libc", "windows-sys", ] -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "fixedbitset" version = "0.4.2" @@ -281,6 +271,17 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + [[package]] name = "glob" version = "0.3.1" @@ -289,9 +290,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "glow" -version = "0.12.3" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca0fe580e4b60a8ab24a868bc08e2f03cbcb20d3d676601fa909386713333728" +checksum = "886c2a30b160c4c6fec8f987430c26b526b7988ca71f664e6a699ddf6f9601e4" dependencies = [ "js-sys", "slotmap", @@ -299,13 +300,22 @@ dependencies = [ "web-sys", ] +[[package]] +name = "glutin_wgl_sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8098adac955faa2d31079b65dc48841251f69efd3ac25477903fc424362ead" +dependencies = [ + "gl_generator", +] + [[package]] name = "gpu-alloc" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "gpu-alloc-types", ] @@ -315,7 +325,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", ] [[package]] @@ -324,7 +334,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "gpu-descriptor-types", "hashbrown", ] @@ -335,14 +345,14 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bf0b36e6f090b7e1d8a4b49c0cb81c1f8376f72198c65dd3ad9ff3556b8b78c" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", ] [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ "ahash", "allocator-api2", @@ -385,15 +395,21 @@ dependencies = [ [[package]] name = "khronos-egl" -version = "4.1.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2352bd1d0bceb871cb9d40f24360c8133c11d7486b68b5381c1dd1a32015e3" +checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" dependencies = [ "libc", - "libloading 0.7.4", + "libloading 0.8.1", "pkg-config", ] +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + [[package]] name = "lazy_static" version = "1.4.0" @@ -408,9 +424,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.148" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libloading" @@ -434,15 +450,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" +checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -465,16 +481,16 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "metal" version = "0.26.0" source = "git+https://github.com/gfx-rs/metal-rs/?rev=d24f1a4#d24f1a4ae92470bf87a0c65ecfe78c9299835505" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "block", "core-graphics-types", "foreign-types", @@ -492,10 +508,10 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "naga" version = "0.13.0" -source = "git+https://github.com/gfx-rs/naga?rev=df8107b7#df8107b78812cc2b1e3d5de35279cedc1f0da3fb" +source = "git+https://github.com/gfx-rs/naga?rev=e25280df9316434ef7752970016d01a3aede3f17#e25280df9316434ef7752970016d01a3aede3f17" dependencies = [ "bit-set", - "bitflags 2.4.0", + "bitflags 2.4.1", "codespan-reporting", "hexf-parse", "indexmap", @@ -523,9 +539,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -567,9 +583,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", @@ -627,9 +643,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -663,18 +679,18 @@ checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.9.6" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", @@ -684,9 +700,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.9" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", @@ -695,9 +711,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "ron" @@ -706,7 +722,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ "base64", - "bitflags 2.4.0", + "bitflags 2.4.1", "serde", "serde_derive", ] @@ -719,11 +735,11 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.38.15" +version = "0.38.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2f9da0cbd88f9f09e7814e388301c8414c51c62aa6ce1e4b5c551d49d96e531" +checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", @@ -738,18 +754,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" dependencies = [ "proc-macro2", "quote", @@ -789,9 +805,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -809,18 +825,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", @@ -918,11 +934,11 @@ dependencies = [ [[package]] name = "wgpu-core" version = "0.17.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=9a76c483da4891fb7046c579e36d7c54bdb0b251#9a76c483da4891fb7046c579e36d7c54bdb0b251" +source = "git+https://github.com/gfx-rs/wgpu?rev=dd9b282c72a696ffaee100b69e7c8e37668e6149#dd9b282c72a696ffaee100b69e7c8e37668e6149" dependencies = [ "arrayvec", "bit-vec", - "bitflags 2.4.0", + "bitflags 2.4.1", "codespan-reporting", "log", "naga", @@ -942,17 +958,18 @@ dependencies = [ [[package]] name = "wgpu-hal" version = "0.17.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=9a76c483da4891fb7046c579e36d7c54bdb0b251#9a76c483da4891fb7046c579e36d7c54bdb0b251" +source = "git+https://github.com/gfx-rs/wgpu?rev=dd9b282c72a696ffaee100b69e7c8e37668e6149#dd9b282c72a696ffaee100b69e7c8e37668e6149" dependencies = [ "android_system_properties", "arrayvec", "ash", "bit-set", - "bitflags 2.4.0", + "bitflags 2.4.1", "block", "core-graphics-types", "d3d12", "glow", + "glutin_wgl_sys", "gpu-alloc", "gpu-descriptor", "js-sys", @@ -963,6 +980,7 @@ dependencies = [ "metal", "naga", "objc", + "once_cell", "parking_lot", "profiling", "range-alloc", @@ -995,9 +1013,9 @@ dependencies = [ [[package]] name = "wgpu-types" version = "0.17.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=9a76c483da4891fb7046c579e36d7c54bdb0b251#9a76c483da4891fb7046c579e36d7c54bdb0b251" +source = "git+https://github.com/gfx-rs/wgpu?rev=dd9b282c72a696ffaee100b69e7c8e37668e6149#dd9b282c72a696ffaee100b69e7c8e37668e6149" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "js-sys", "serde", "web-sys", @@ -1111,3 +1129,29 @@ name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "xml-rs" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" + +[[package]] +name = "zerocopy" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c19fae0c8a9efc6a8281f2e623db8af1db9e57852e04cde3e754dd2dc29340f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc56589e9ddd1f1c28d4b4b5c773ce232910a6bb67a70133d61c9e347585efe9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index cd4c99dc..21393b25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,9 @@ crate-type = ["lib", "cdylib", "staticlib"] [features] default = ["wgsl", "spirv", "glsl", "trace"] -angle = ["wgc/angle"] +# Enables the GLES backend on Windows & macOS +angle = ["wgc/gles"] +# Enables the Vulkan backend on macOS & iOS vulkan-portability = ["wgc/vulkan"] wgsl = ["wgc/wgsl"] spirv = ["naga/spv-in"] @@ -30,40 +32,51 @@ trace = ["wgc/trace"] [dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "9a76c483da4891fb7046c579e36d7c54bdb0b251" +rev = "dd9b282c72a696ffaee100b69e7c8e37668e6149" version = "0.17" -features = ["raw-window-handle", "gles"] +features = ["raw-window-handle"] +# We want the wgpu-core Metal backend on macOS and iOS. [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "9a76c483da4891fb7046c579e36d7c54bdb0b251" +rev = "dd9b282c72a696ffaee100b69e7c8e37668e6149" version = "0.17" features = ["metal"] +# We want the wgpu-core Direct3D backends and OpenGL (via WGL) on Windows. [target.'cfg(windows)'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "9a76c483da4891fb7046c579e36d7c54bdb0b251" +rev = "dd9b282c72a696ffaee100b69e7c8e37668e6149" version = "0.17" -features = ["dx11", "dx12"] +features = ["dx11", "dx12", "gles"] -[target.'cfg(any(windows, all(unix, not(target_arch = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc] +# We want the wgpu-core Vulkan backend on Unix (but not emscripten, macOS, iOS) and Windows. +[target.'cfg(any(windows, all(unix, not(target_os = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "9a76c483da4891fb7046c579e36d7c54bdb0b251" +rev = "dd9b282c72a696ffaee100b69e7c8e37668e6149" version = "0.17" features = ["vulkan"] +# We want the wgpu-core GLES backend on Unix (but not macOS, iOS). +[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies.wgc] +package = "wgpu-core" +git = "https://github.com/gfx-rs/wgpu" +rev = "dd9b282c72a696ffaee100b69e7c8e37668e6149" +version = "0.17" +features = ["gles"] + [dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "9a76c483da4891fb7046c579e36d7c54bdb0b251" +rev = "dd9b282c72a696ffaee100b69e7c8e37668e6149" version = "0.17" [dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "df8107b7" +rev = "e25280df9316434ef7752970016d01a3aede3f17" version = "0.13.0" [dependencies] @@ -75,7 +88,7 @@ parking_lot = "0.12" smallvec = "1" [build-dependencies] -bindgen = "0.66" +bindgen = "0.68" [workspace] resolver = "2" diff --git a/examples/capture/CMakeLists.txt b/examples/capture/CMakeLists.txt index e415c977..60f261ec 100644 --- a/examples/capture/CMakeLists.txt +++ b/examples/capture/CMakeLists.txt @@ -15,7 +15,7 @@ include_directories(${CMAKE_SOURCE_DIR}/../ffi) include_directories(${CMAKE_SOURCE_DIR}/framework) if (WIN32) - set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll) + set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32) elseif(UNIX AND NOT APPLE) set(OS_LIBRARIES "-lm -ldl") elseif(APPLE) diff --git a/examples/compute/CMakeLists.txt b/examples/compute/CMakeLists.txt index 3b4e8e74..cbd28afa 100644 --- a/examples/compute/CMakeLists.txt +++ b/examples/compute/CMakeLists.txt @@ -13,7 +13,7 @@ include_directories(${CMAKE_SOURCE_DIR}/../ffi) include_directories(${CMAKE_SOURCE_DIR}/framework) if (WIN32) - set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll) + set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32) elseif(UNIX AND NOT APPLE) set(OS_LIBRARIES "-lm -ldl") elseif(APPLE) diff --git a/examples/enumerate_adapters/CMakeLists.txt b/examples/enumerate_adapters/CMakeLists.txt index e12a2411..82c26d94 100644 --- a/examples/enumerate_adapters/CMakeLists.txt +++ b/examples/enumerate_adapters/CMakeLists.txt @@ -13,7 +13,7 @@ include_directories(${CMAKE_SOURCE_DIR}/../ffi) include_directories(${CMAKE_SOURCE_DIR}/framework) if (WIN32) - set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll) + set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32) elseif(UNIX AND NOT APPLE) set(OS_LIBRARIES "-lm -ldl") elseif(APPLE) diff --git a/examples/framework/CMakeLists.txt b/examples/framework/CMakeLists.txt index 58422a0f..caee9824 100644 --- a/examples/framework/CMakeLists.txt +++ b/examples/framework/CMakeLists.txt @@ -12,7 +12,7 @@ endif() include_directories(${CMAKE_SOURCE_DIR}/../ffi) if (WIN32) - set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll) + set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32) elseif(UNIX AND NOT APPLE) set(OS_LIBRARIES "-lm -ldl") elseif(APPLE) diff --git a/examples/texture_arrays/CMakeLists.txt b/examples/texture_arrays/CMakeLists.txt index 634695f4..b399b70d 100644 --- a/examples/texture_arrays/CMakeLists.txt +++ b/examples/texture_arrays/CMakeLists.txt @@ -15,7 +15,7 @@ include_directories(${DEP_GLFW_DIR}/include) if (WIN32) add_definitions(-DWGPU_TARGET_WINDOWS) - set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll) + set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32) elseif(UNIX AND NOT APPLE) add_definitions(-DWGPU_TARGET_LINUX_X11) set(OS_LIBRARIES "-lm -ldl") diff --git a/examples/triangle/CMakeLists.txt b/examples/triangle/CMakeLists.txt index 2b10b868..7bcf82e8 100644 --- a/examples/triangle/CMakeLists.txt +++ b/examples/triangle/CMakeLists.txt @@ -15,7 +15,7 @@ include_directories(${DEP_GLFW_DIR}/include) if (WIN32) add_definitions(-DWGPU_TARGET_WINDOWS) - set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll) + set(OS_LIBRARIES d3dcompiler ws2_32 userenv bcrypt ntdll opengl32) elseif(UNIX AND NOT APPLE) add_definitions(-DWGPU_TARGET_LINUX_X11) set(OS_LIBRARIES "-lm -ldl") diff --git a/ffi/wgpu.h b/ffi/wgpu.h index 68fa2f2f..d2f17e4e 100644 --- a/ffi/wgpu.h +++ b/ffi/wgpu.h @@ -38,21 +38,30 @@ typedef enum WGPULogLevel { } WGPULogLevel; typedef enum WGPUInstanceBackend { - WGPUInstanceBackend_Vulkan = 1 << 1, - WGPUInstanceBackend_GL = 1 << 5, + WGPUInstanceBackend_All = 0x00000000, + WGPUInstanceBackend_Vulkan = 1 << 0, + WGPUInstanceBackend_GL = 1 << 1, WGPUInstanceBackend_Metal = 1 << 2, WGPUInstanceBackend_DX12 = 1 << 3, WGPUInstanceBackend_DX11 = 1 << 4, - WGPUInstanceBackend_BrowserWebGPU = 1 << 6, + WGPUInstanceBackend_BrowserWebGPU = 1 << 5, WGPUInstanceBackend_Primary = WGPUInstanceBackend_Vulkan | WGPUInstanceBackend_Metal | WGPUInstanceBackend_DX12 | WGPUInstanceBackend_BrowserWebGPU, WGPUInstanceBackend_Secondary = WGPUInstanceBackend_GL | WGPUInstanceBackend_DX11, - WGPUInstanceBackend_None = 0x00000000, WGPUInstanceBackend_Force32 = 0x7FFFFFFF } WGPUInstanceBackend; typedef WGPUFlags WGPUInstanceBackendFlags; +typedef enum WGPUInstanceFlag { + WGPUInstanceFlag_Default = 0x00000000, + WGPUInstanceFlag_Debug = 1 << 0, + WGPUInstanceFlag_Validation = 1 << 1, + WGPUInstanceFlag_DiscardHalLabels = 1 << 2, + WGPUInstanceFlag_Force32 = 0x7FFFFFFF +} WGPUInstanceFlag; +typedef WGPUFlags WGPUInstanceFlags; + typedef enum WGPUDx12Compiler { WGPUDx12Compiler_Undefined = 0x00000000, WGPUDx12Compiler_Fxc = 0x00000001, @@ -71,6 +80,7 @@ typedef enum WGPUGles3MinorVersion { typedef struct WGPUInstanceExtras { WGPUChainedStruct chain; WGPUInstanceBackendFlags backends; + WGPUInstanceFlags flags; WGPUDx12Compiler dx12ShaderCompiler; WGPUGles3MinorVersion gles3MinorVersion; const char * dxilPath; @@ -82,14 +92,19 @@ typedef struct WGPUDeviceExtras { const char * tracePath; } WGPUDeviceExtras; +typedef struct WGPUNativeLimits { + uint32_t maxPushConstantSize; + uint32_t maxNonSamplerBindings; +} WGPUNativeLimits; + typedef struct WGPURequiredLimitsExtras { WGPUChainedStruct chain; - uint32_t maxPushConstantSize; + WGPUNativeLimits limits; } WGPURequiredLimitsExtras; typedef struct WGPUSupportedLimitsExtras { WGPUChainedStructOut chain; - uint32_t maxPushConstantSize; + WGPUNativeLimits limits; } WGPUSupportedLimitsExtras; typedef struct WGPUPushConstantRange { diff --git a/src/conv.rs b/src/conv.rs index cf7fda22..60833cba 100644 --- a/src/conv.rs +++ b/src/conv.rs @@ -245,7 +245,7 @@ pub fn map_origin3d(native: &native::WGPUOrigin3D) -> wgt::Origin3d { #[inline] pub fn map_instance_backend_flags(flags: native::WGPUInstanceBackend) -> wgt::Backends { - let mut result: wgt::Backends = wgt::Backends::empty(); + let mut result = wgt::Backends::empty(); if (flags & native::WGPUInstanceBackend_BrowserWebGPU) != 0 { result |= wgt::Backends::BROWSER_WEBGPU; } @@ -267,6 +267,21 @@ pub fn map_instance_backend_flags(flags: native::WGPUInstanceBackend) -> wgt::Ba result } +#[inline] +pub fn map_instance_flags(flags: native::WGPUInstanceFlag) -> wgt::InstanceFlags { + let mut result = wgt::InstanceFlags::empty(); + if (flags & native::WGPUInstanceFlag_Debug) != 0 { + result.insert(wgt::InstanceFlags::DEBUG); + } + if (flags & native::WGPUInstanceFlag_Validation) != 0 { + result.insert(wgt::InstanceFlags::VALIDATION); + } + if (flags & native::WGPUInstanceFlag_DiscardHalLabels) != 0 { + result.insert(wgt::InstanceFlags::DISCARD_HAL_LABELS); + } + result +} + #[inline] pub fn map_instance_descriptor( _base: &native::WGPUInstanceDescriptor, @@ -283,9 +298,16 @@ pub fn map_instance_descriptor( }; wgt::InstanceDescriptor { - backends: map_instance_backend_flags(extras.backends as native::WGPUInstanceBackend), + backends: match extras.backends as native::WGPUInstanceBackend { + native::WGPUInstanceBackend_All => wgt::Backends::all(), + backends => map_instance_backend_flags(backends), + }, dx12_shader_compiler, gles_minor_version: map_gles3_minor_version(extras.gles3MinorVersion), + flags: match extras.flags as native::WGPUInstanceFlag { + native::WGPUInstanceFlag_Default => wgt::InstanceFlags::default(), + flags => map_instance_flags(flags), + }, } } else { wgt::InstanceDescriptor::default() @@ -388,12 +410,12 @@ pub fn write_limits_struct( limits.maxUniformBuffersPerShaderStage = wgt_limits.max_uniform_buffers_per_shader_stage; limits.maxUniformBufferBindingSize = wgt_limits.max_uniform_buffer_binding_size as _; limits.maxStorageBufferBindingSize = wgt_limits.max_storage_buffer_binding_size as _; - limits.minUniformBufferOffsetAlignment = wgt_limits.min_uniform_buffer_offset_alignment; - limits.minStorageBufferOffsetAlignment = wgt_limits.min_storage_buffer_offset_alignment; limits.maxVertexBuffers = wgt_limits.max_vertex_buffers; limits.maxBufferSize = wgt_limits.max_buffer_size; limits.maxVertexAttributes = wgt_limits.max_vertex_attributes; limits.maxVertexBufferArrayStride = wgt_limits.max_vertex_buffer_array_stride; + limits.minUniformBufferOffsetAlignment = wgt_limits.min_uniform_buffer_offset_alignment; + limits.minStorageBufferOffsetAlignment = wgt_limits.min_storage_buffer_offset_alignment; limits.maxInterStageShaderComponents = wgt_limits.max_inter_stage_shader_components; // TODO: not yet in wgt // limits.maxInterStageShaderVariables = wgt_limits.max_inter_stage_shader_variables; @@ -409,19 +431,22 @@ pub fn write_limits_struct( limits.maxComputeWorkgroupsPerDimension = wgt_limits.max_compute_workgroups_per_dimension; supported_limits.limits = limits; - if !supported_limits.nextInChain.is_null() { - unsafe { + match unsafe { supported_limits.nextInChain.as_ref() } { + Some(native::WGPUChainedStructOut { + sType: native::WGPUSType_SupportedLimitsExtras, + .. + }) => unsafe { let extras = std::mem::transmute::< *mut native::WGPUChainedStructOut, *mut native::WGPUSupportedLimitsExtras, >(supported_limits.nextInChain); - - (*extras).chain.next = std::ptr::null_mut(); - (*extras).chain.sType = native::WGPUSType_SupportedLimitsExtras; - - (*extras).maxPushConstantSize = wgt_limits.max_push_constant_size; - } - } + (*extras).limits = native::WGPUNativeLimits { + maxPushConstantSize: wgt_limits.max_push_constant_size, + maxNonSamplerBindings: wgt_limits.max_non_sampler_bindings, + }; + }, + _ => {} + }; } #[inline] @@ -509,8 +534,7 @@ pub fn map_required_limits( } // TODO: not yet in wgt // if limits.maxInterStageShaderVariables != native::WGPU_LIMIT_U32_UNDEFINED { - // wgt_limits.max_inter_stage_shader_variables = - // limits.maxInterStageShaderVariables; + // wgt_limits.max_inter_stage_shader_variables = limits.maxInterStageShaderVariables; // } // TODO: not yet in wgt // if limits.maxColorAttachments != native::WGPU_LIMIT_U32_UNDEFINED { @@ -539,8 +563,12 @@ pub fn map_required_limits( wgt_limits.max_compute_workgroups_per_dimension = limits.maxComputeWorkgroupsPerDimension; } if let Some(extras) = extras { - if extras.maxPushConstantSize != native::WGPU_LIMIT_U32_UNDEFINED { - wgt_limits.max_push_constant_size = extras.maxPushConstantSize; + let limits = extras.limits; + if limits.maxPushConstantSize != native::WGPU_LIMIT_U32_UNDEFINED { + wgt_limits.max_push_constant_size = limits.maxPushConstantSize; + } + if limits.maxNonSamplerBindings != native::WGPU_LIMIT_U32_UNDEFINED { + wgt_limits.max_non_sampler_bindings = limits.maxNonSamplerBindings; } } wgt_limits @@ -815,6 +843,7 @@ pub fn to_native_texture_format(rs_type: wgt::TextureFormat) -> Option None, wgt::TextureFormat::Rgba16Unorm => None, wgt::TextureFormat::Rgba16Snorm => None, + wgt::TextureFormat::Rgb10a2Uint => None, wgt::TextureFormat::Astc { block:_, channel: AstcChannel::Hdr } => None, wgt::TextureFormat::R8Unorm => Some(native::WGPUTextureFormat_R8Unorm), @@ -985,7 +1014,7 @@ pub fn write_global_report( windows, all( unix, - not(target_arch = "emscripten"), + not(target_os = "emscripten"), not(target_os = "ios"), not(target_os = "macos") ) @@ -1013,6 +1042,7 @@ pub fn write_global_report( } } + #[cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))] if let Some(gl) = report.gl { native_report.gl = map_hub_report(gl); native_report.backendType = native::WGPUBackendType_OpenGL;