Bug 1878375 - Synchronize vendored Rust libraries with mozilla-central. r=leftmostcat

mozilla-central: f956d7e03a822a09fbb84e9b474db8e0167095f1
comm-central: 25f09ad6335a5166fde773c81be1268147cda21f

Differential Revision: https://phabricator.services.mozilla.com/D210702

--HG--
extra : amend_source : 09d7d6c866423f0131fd871e2808fa6a0f448516
This commit is contained in:
Thunderbird Updatebot 2024-05-16 10:38:57 -07:00
Родитель 8bc93658fc
Коммит 4741c84d2c
19 изменённых файлов: 1107 добавлений и 282 удалений

Просмотреть файл

@ -21,9 +21,9 @@ git = "https://github.com/franziskuskiefer/cose-rust"
rev = "43c22248d136c8b38fe42ea709d08da6355cf04b"
replace-with = "vendored-sources"
[source."git+https://github.com/gfx-rs/wgpu?rev=d5d683d3c491ec8cd2f5cdb43ac61e526cb7c231"]
[source."git+https://github.com/gfx-rs/wgpu?rev=2f4522714c4037a1842d27bb448b634f089664ab"]
git = "https://github.com/gfx-rs/wgpu"
rev = "d5d683d3c491ec8cd2f5cdb43ac61e526cb7c231"
rev = "2f4522714c4037a1842d27bb448b634f089664ab"
replace-with = "vendored-sources"
[source."git+https://github.com/glandium/mio?rev=9a2ef335c366044ffe73b1c4acabe50a1daefe05"]

14
rust/Cargo.lock сгенерированный
Просмотреть файл

@ -1035,7 +1035,7 @@ dependencies = [
[[package]]
name = "d3d12"
version = "0.20.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=d5d683d3c491ec8cd2f5cdb43ac61e526cb7c231#d5d683d3c491ec8cd2f5cdb43ac61e526cb7c231"
source = "git+https://github.com/gfx-rs/wgpu?rev=2f4522714c4037a1842d27bb448b634f089664ab#2f4522714c4037a1842d27bb448b634f089664ab"
dependencies = [
"bitflags 2.5.0",
"libloading 0.8.3",
@ -2273,9 +2273,9 @@ dependencies = [
[[package]]
name = "gpu-allocator"
version = "0.25.0"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f56f6318968d03c18e1bcf4857ff88c61157e9da8e47c5f29055d60e1228884"
checksum = "fdd4240fc91d3433d5e5b0fc5b67672d771850dc19bbee03c1381e19322803d7"
dependencies = [
"log",
"presser",
@ -3275,7 +3275,7 @@ checksum = "a2983372caf4480544083767bf2d27defafe32af49ab4df3a0b7fc90793a3664"
[[package]]
name = "naga"
version = "0.20.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=d5d683d3c491ec8cd2f5cdb43ac61e526cb7c231#d5d683d3c491ec8cd2f5cdb43ac61e526cb7c231"
source = "git+https://github.com/gfx-rs/wgpu?rev=2f4522714c4037a1842d27bb448b634f089664ab#2f4522714c4037a1842d27bb448b634f089664ab"
dependencies = [
"arrayvec",
"bit-set",
@ -5544,7 +5544,7 @@ dependencies = [
[[package]]
name = "wgpu-core"
version = "0.20.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=d5d683d3c491ec8cd2f5cdb43ac61e526cb7c231#d5d683d3c491ec8cd2f5cdb43ac61e526cb7c231"
source = "git+https://github.com/gfx-rs/wgpu?rev=2f4522714c4037a1842d27bb448b634f089664ab#2f4522714c4037a1842d27bb448b634f089664ab"
dependencies = [
"arrayvec",
"bit-vec",
@ -5570,7 +5570,7 @@ dependencies = [
[[package]]
name = "wgpu-hal"
version = "0.20.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=d5d683d3c491ec8cd2f5cdb43ac61e526cb7c231#d5d683d3c491ec8cd2f5cdb43ac61e526cb7c231"
source = "git+https://github.com/gfx-rs/wgpu?rev=2f4522714c4037a1842d27bb448b634f089664ab#2f4522714c4037a1842d27bb448b634f089664ab"
dependencies = [
"android_system_properties",
"arrayvec",
@ -5609,7 +5609,7 @@ dependencies = [
[[package]]
name = "wgpu-types"
version = "0.20.0"
source = "git+https://github.com/gfx-rs/wgpu?rev=d5d683d3c491ec8cd2f5cdb43ac61e526cb7c231#d5d683d3c491ec8cd2f5cdb43ac61e526cb7c231"
source = "git+https://github.com/gfx-rs/wgpu?rev=2f4522714c4037a1842d27bb448b634f089664ab#2f4522714c4037a1842d27bb448b634f089664ab"
dependencies = [
"bitflags 2.5.0",
"js-sys",

Просмотреть файл

@ -1 +1 @@
{"mc_workspace_toml": "76186190c57a41b30df0c6bff56ce9bbc79daa854a3205cb7569afe8f20732e95fc4119f4d20f04affd304f005e13c4936b47cdb58a5d99453c9f34884edce9e", "mc_gkrust_toml": "7b85230288493ac65c5496e68dd5b14661b51bc7667784c7afd8608bccb814195ca20d8e6a29f207190024607037f6621fa527c370be69bb9e28fc1cb51a8700", "mc_cargo_lock": "72c026ee7c2b6210a9c7f7d9e9c169b29c4768e8a6b5a2980923b40c2af56a45e8cf03a6a115e4eca769fb4e34247e7874d9f68b5a6775c454f63c8af72bfafb"}
{"mc_workspace_toml": "76186190c57a41b30df0c6bff56ce9bbc79daa854a3205cb7569afe8f20732e95fc4119f4d20f04affd304f005e13c4936b47cdb58a5d99453c9f34884edce9e", "mc_gkrust_toml": "7b85230288493ac65c5496e68dd5b14661b51bc7667784c7afd8608bccb814195ca20d8e6a29f207190024607037f6621fa527c370be69bb9e28fc1cb51a8700", "mc_cargo_lock": "c9cdf8c5399d0ecac3b161d3f9e7f104915b78772c4328cd1aa8d19e23dab177cb6a39f1b38020e37c2243dde7a2cc621f30a39e4775f4e16249f977d7b596b9"}

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.lock":"22fb0e1bc7319a72fcade655a344b017ca726271634362f1853ceb9f4f62d676","Cargo.toml":"93af1b7d358dfe27714e78bd7eb19a9c6aec79e509d96af6c7716b6d5e1c2802","LICENSE-APACHE":"0178e21322b0e88aa3aeb3146f6a9611bc1f8df6d98bdfb34be28b9dd56a8107","LICENSE-MIT":"ad41be6cc6538b29b9346648f41432b5e460bad6be073b5eeaa41320ea2921dc","README.md":"130475ab08599e30a1d783453e4678e9140c5b93923a7181864c8dd74835237e","examples/d3d12-buffer-winrs.rs":"c2c66ace6e41d302f244b95dbe38f2272ac59357a1c717a767dac3df89ea4718","examples/d3d12-buffer.rs":"abd9acc233a45c44f421dcaa4109f5a408de5335979654b1acbb55c73197ed5b","examples/vulkan-buffer.rs":"8097b361074302cf294d09a309e0cb8bfa8fbc586096f77a1cca9f7ba1f735dc","src/allocator/dedicated_block_allocator/mod.rs":"184ab11fcb52d3438586d10909277b54f1dbec9aeafb29ea338fd4df0e025e76","src/allocator/dedicated_block_allocator/visualizer.rs":"5b9019dd73ebe7bb9e9d103c48368014b73cdd4ae7f36a706ae047919f56fac6","src/allocator/free_list_allocator/mod.rs":"cab1d7e451c08978e67163ad45006cf8fdf2bdbb40e205c04bfec17490ca605f","src/allocator/free_list_allocator/visualizer.rs":"46214d07285d72a0a29c8d7e76322243853eba7d25d87ebfbb17c75e7815d07f","src/allocator/mod.rs":"09a560d3f4b0ba174bceea6d71bc201afcbea2b8170430c21365cbea8ca315f9","src/d3d12/mod.rs":"ae42a4740e7b54f1fef21f1f3e23dc2d315fd5a6129855fb53a76b7f7d455cec","src/d3d12/visualizer.rs":"955c587a0d676e7e67fe02a3c3d4a59e8857e323c316ab7c352ef8d1a247193d","src/lib.rs":"2751d2365f8223d800fb8242f2c66ef949f1927c6a6770b368764d3322c6f878","src/result.rs":"ce944b6af3e0e83920f25b23ddcf61f95ee5a815f529443415b899d1d3d11b76","src/visualizer/allocation_reports.rs":"571528b72c2a7946dae4c5b849efe88fd068786626b7d5e5e2a2cd5703c99c66","src/visualizer/memory_chunks.rs":"7d07c01f1471d25ff5702b53f5ccda09d6135888f6a77d1eaf06c541b4cafd5e","src/visualizer/mod.rs":"7d56c956abba968400aa6794e399db4b7ec10135a948beef21ea13ba3bd1fd9e","src/vulkan/mod.rs":"245492ce89f82e2846638efd7a1a9e98a5a98b9d947474a7b74612462ecc4a48","src/vulkan/visualizer.rs":"7d6c113c70fa36f1a85a989d7020bd8e9814584f11c43bc151606be643a07c6c"},"package":"6f56f6318968d03c18e1bcf4857ff88c61157e9da8e47c5f29055d60e1228884"}
{"files":{"Cargo.lock":"7dffc5e93a0c3ff20a743e47d81da0baea4436153d5700be93805f3e0e982deb","Cargo.toml":"0b3005bccdea36f58aa260d17393d97fcdc2d80b86d39af2b7dd6828777524af","LICENSE-APACHE":"0178e21322b0e88aa3aeb3146f6a9611bc1f8df6d98bdfb34be28b9dd56a8107","LICENSE-MIT":"ad41be6cc6538b29b9346648f41432b5e460bad6be073b5eeaa41320ea2921dc","README.md":"0830d3914152fa9afa9ffe48651cbbbb31d34fe330785dee98ef747078a92079","examples/d3d12-buffer-winrs.rs":"c2c66ace6e41d302f244b95dbe38f2272ac59357a1c717a767dac3df89ea4718","examples/d3d12-buffer.rs":"abd9acc233a45c44f421dcaa4109f5a408de5335979654b1acbb55c73197ed5b","examples/metal-buffer.rs":"0fbd65a5a8381013199ff98f76c3830b96eb5e46591d4043f54614d582f26523","examples/vulkan-buffer.rs":"8097b361074302cf294d09a309e0cb8bfa8fbc586096f77a1cca9f7ba1f735dc","src/allocator/dedicated_block_allocator/mod.rs":"184ab11fcb52d3438586d10909277b54f1dbec9aeafb29ea338fd4df0e025e76","src/allocator/dedicated_block_allocator/visualizer.rs":"5b9019dd73ebe7bb9e9d103c48368014b73cdd4ae7f36a706ae047919f56fac6","src/allocator/free_list_allocator/mod.rs":"cab1d7e451c08978e67163ad45006cf8fdf2bdbb40e205c04bfec17490ca605f","src/allocator/free_list_allocator/visualizer.rs":"46214d07285d72a0a29c8d7e76322243853eba7d25d87ebfbb17c75e7815d07f","src/allocator/mod.rs":"09a560d3f4b0ba174bceea6d71bc201afcbea2b8170430c21365cbea8ca315f9","src/d3d12/mod.rs":"8fddd0755bd804cfcedf89c9a0a1f9686b6f0f728ff094cf3cb42a2ba12dc3d6","src/d3d12/visualizer.rs":"955c587a0d676e7e67fe02a3c3d4a59e8857e323c316ab7c352ef8d1a247193d","src/lib.rs":"4e19cd56ceaeb38f3fcaa71619c0fb180306cd79b25db583a05c8954b766c3da","src/metal/mod.rs":"5d156324aaaa054745054ae612056da5e854f18893756d86563b0f05ecd98bb2","src/result.rs":"6c7d85ee13afbd0b17c1b81ed0b6d7094247dd693444b62c28daf4d9f2248846","src/visualizer/allocation_reports.rs":"8e848f56503ee9b1a0b744804ac68a415dd5d761b20b0be0b15f9d4a5299607b","src/visualizer/memory_chunks.rs":"7d07c01f1471d25ff5702b53f5ccda09d6135888f6a77d1eaf06c541b4cafd5e","src/visualizer/mod.rs":"7d56c956abba968400aa6794e399db4b7ec10135a948beef21ea13ba3bd1fd9e","src/vulkan/mod.rs":"e14cfa043c938d9da3171bf9e9cbe7e4c0132e02c5c20af2726307ad40179491","src/vulkan/visualizer.rs":"7d6c113c70fa36f1a85a989d7020bd8e9814584f11c43bc151606be643a07c6c"},"package":"fdd4240fc91d3433d5e5b0fc5b67672d771850dc19bbee03c1381e19322803d7"}

400
third_party/rust/gpu-allocator/Cargo.lock сгенерированный поставляемый
Просмотреть файл

@ -4,9 +4,9 @@ version = 3
[[package]]
name = "ab_glyph"
version = "0.2.23"
version = "0.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80179d7dd5d7e8c285d67c4a1e652972a92de7475beddfb92028c76463b13225"
checksum = "6f90148830dac590fac7ccfe78ec4a8ea404c60f75a24e16407a71f0f40de775"
dependencies = [
"ab_glyph_rasterizer",
"owned_ttf_parser",
@ -20,9 +20,9 @@ checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046"
[[package]]
name = "accesskit"
version = "0.12.2"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6cb10ed32c63247e4e39a8f42e8e30fb9442fbf7878c8e4a9849e7e381619bea"
checksum = "74a4b14f3d99c1255dcba8f45621ab1a2e7540a0009652d33989005a4d0bfc6b"
dependencies = [
"enumn",
"serde",
@ -30,9 +30,9 @@ dependencies = [
[[package]]
name = "ahash"
version = "0.8.7"
version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01"
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
dependencies = [
"cfg-if",
"once_cell",
@ -43,9 +43,9 @@ dependencies = [
[[package]]
name = "aho-corasick"
version = "1.1.2"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
@ -61,9 +61,9 @@ dependencies = [
[[package]]
name = "autocfg"
version = "1.1.0"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80"
[[package]]
name = "bitflags"
@ -73,9 +73,21 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.1"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
[[package]]
name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "cc"
version = "1.0.96"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd"
[[package]]
name = "cfg-if"
@ -84,19 +96,52 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "ecolor"
version = "0.24.1"
name = "core-foundation"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b7637fc2e74d17e52931bac90ff4fc061ac776ada9c7fa272f24cdca5991972"
checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
[[package]]
name = "core-graphics-types"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"libc",
]
[[package]]
name = "dispatch"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b"
[[package]]
name = "ecolor"
version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20930a432bbd57a6d55e07976089708d4893f3d556cf42a0d79e9e321fa73b10"
dependencies = [
"serde",
]
[[package]]
name = "egui"
version = "0.24.1"
version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c55bcb864b764eb889515a38b8924757657a250738ad15126637ee2df291ee6b"
checksum = "584c5d1bf9a67b25778a3323af222dbe1a1feb532190e103901187f92c7fe29a"
dependencies = [
"accesskit",
"ahash",
@ -107,9 +152,9 @@ dependencies = [
[[package]]
name = "egui_extras"
version = "0.24.2"
version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97624eaf17a16058265d3a3e712e167798655baf7c8f693de25be75cdd6c57b5"
checksum = "1b78779f35ded1a853786c9ce0b43fe1053e10a21ea3b23ebea411805ce41593"
dependencies = [
"egui",
"enum-map",
@ -119,9 +164,9 @@ dependencies = [
[[package]]
name = "emath"
version = "0.24.1"
version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a045c6c0b44b35e98513fc1e9d183ab42881ac27caccb9fa345465601f56cce4"
checksum = "e4c3a552cfca14630702449d35f41c84a0d15963273771c6059175a803620f3f"
dependencies = [
"serde",
]
@ -160,9 +205,9 @@ dependencies = [
[[package]]
name = "env_logger"
version = "0.10.1"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece"
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
dependencies = [
"humantime",
"is-terminal",
@ -173,9 +218,9 @@ dependencies = [
[[package]]
name = "epaint"
version = "0.24.1"
version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d1b9e000d21bab9b535ce78f9f7745be28b3f777f6c7223936561c5c7fefab8"
checksum = "b381f8b149657a4acf837095351839f32cd5c4aec1817fc4df84e18d76334176"
dependencies = [
"ab_glyph",
"ahash",
@ -187,24 +232,42 @@ dependencies = [
]
[[package]]
name = "errno"
version = "0.3.8"
name = "foreign-types"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
dependencies = [
"libc",
"windows-sys",
"foreign-types-macros",
"foreign-types-shared",
]
[[package]]
name = "foreign-types-macros"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "foreign-types-shared"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
[[package]]
name = "gpu-allocator"
version = "0.25.0"
version = "0.26.0"
dependencies = [
"ash",
"egui",
"egui_extras",
"env_logger",
"log",
"metal",
"presser",
"thiserror",
"winapi",
@ -213,9 +276,9 @@ dependencies = [
[[package]]
name = "hermit-abi"
version = "0.3.3"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "humantime"
@ -225,20 +288,20 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "is-terminal"
version = "0.4.10"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455"
checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b"
dependencies = [
"hermit-abi",
"rustix",
"libc",
"windows-sys",
]
[[package]]
name = "libc"
version = "0.2.151"
version = "0.2.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
[[package]]
name = "libloading"
@ -251,16 +314,10 @@ dependencies = [
]
[[package]]
name = "linux-raw-sys"
name = "lock_api"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
[[package]]
name = "lock_api"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
dependencies = [
"autocfg",
"scopeguard",
@ -268,15 +325,40 @@ dependencies = [
[[package]]
name = "log"
version = "0.4.20"
version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
[[package]]
name = "malloc_buf"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
dependencies = [
"libc",
]
[[package]]
name = "memchr"
version = "2.7.1"
version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
[[package]]
name = "metal"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c43f73953f8cbe511f021b58f18c3ce1c3d1ae13fe953293e13345bf83217f25"
dependencies = [
"bitflags 2.5.0",
"block",
"core-graphics-types",
"dispatch",
"foreign-types",
"log",
"objc",
"paste",
]
[[package]]
name = "nohash-hasher"
@ -284,6 +366,25 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
dependencies = [
"malloc_buf",
"objc_exception",
]
[[package]]
name = "objc_exception"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4"
dependencies = [
"cc",
]
[[package]]
name = "once_cell"
version = "1.19.0"
@ -301,9 +402,9 @@ dependencies = [
[[package]]
name = "parking_lot"
version = "0.12.1"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb"
dependencies = [
"lock_api",
"parking_lot_core",
@ -311,17 +412,23 @@ dependencies = [
[[package]]
name = "parking_lot_core"
version = "0.9.9"
version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets 0.48.5",
"windows-targets",
]
[[package]]
name = "paste"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
[[package]]
name = "presser"
version = "0.3.1"
@ -330,36 +437,36 @@ checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa"
[[package]]
name = "proc-macro2"
version = "1.0.75"
version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "907a61bd0f64c2f29cd1cf1dc34d05176426a3f504a78010f08416ddb7b13708"
checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.35"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
dependencies = [
"proc-macro2",
]
[[package]]
name = "redox_syscall"
version = "0.4.1"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e"
dependencies = [
"bitflags 1.3.2",
"bitflags 2.5.0",
]
[[package]]
name = "regex"
version = "1.10.2"
version = "1.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
dependencies = [
"aho-corasick",
"memchr",
@ -369,9 +476,9 @@ dependencies = [
[[package]]
name = "regex-automata"
version = "0.4.3"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
dependencies = [
"aho-corasick",
"memchr",
@ -380,22 +487,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.8.2"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "rustix"
version = "0.38.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316"
dependencies = [
"bitflags 2.4.1",
"errno",
"libc",
"linux-raw-sys",
"windows-sys",
]
checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
[[package]]
name = "scopeguard"
@ -405,18 +499,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "serde"
version = "1.0.194"
version = "1.0.199"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773"
checksum = "0c9f6e76df036c77cd94996771fb40db98187f096dd0b9af39c6c6e452ba966a"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.194"
version = "1.0.199"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0"
checksum = "11bd257a6541e141e42ca6d24ae26f7714887b47e89aa739099104c7e4d3b7fc"
dependencies = [
"proc-macro2",
"quote",
@ -425,15 +519,15 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.11.2"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "syn"
version = "2.0.47"
version = "2.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1726efe18f42ae774cc644f330953a5e7b3c3003d3edcecf18850fe9d4dd9afb"
checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
dependencies = [
"proc-macro2",
"quote",
@ -442,27 +536,27 @@ dependencies = [
[[package]]
name = "termcolor"
version = "1.4.0"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
[[package]]
name = "thiserror"
version = "1.0.56"
version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad"
checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.56"
version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66"
dependencies = [
"proc-macro2",
"quote",
@ -505,11 +599,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.6"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
dependencies = [
"winapi",
"windows-sys",
]
[[package]]
@ -525,7 +619,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be"
dependencies = [
"windows-core",
"windows-targets 0.52.0",
"windows-targets",
]
[[package]]
@ -534,7 +628,7 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
dependencies = [
"windows-targets 0.52.0",
"windows-targets",
]
[[package]]
@ -543,122 +637,72 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.0",
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
dependencies = [
"windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc 0.48.5",
"windows_i686_gnu 0.48.5",
"windows_i686_msvc 0.48.5",
"windows_x86_64_gnu 0.48.5",
"windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc 0.48.5",
]
[[package]]
name = "windows-targets"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
"windows_aarch64_gnullvm 0.52.0",
"windows_aarch64_msvc 0.52.0",
"windows_i686_gnu 0.52.0",
"windows_i686_msvc 0.52.0",
"windows_x86_64_gnu 0.52.0",
"windows_x86_64_gnullvm 0.52.0",
"windows_x86_64_msvc 0.52.0",
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
[[package]]
name = "windows_i686_gnu"
version = "0.52.0"
name = "windows_i686_gnullvm"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
[[package]]
name = "zerocopy"

28
third_party/rust/gpu-allocator/Cargo.toml поставляемый
Просмотреть файл

@ -13,7 +13,7 @@
edition = "2021"
rust-version = "1.65"
name = "gpu-allocator"
version = "0.25.0"
version = "0.26.0"
authors = ["Traverse Research <opensource@traverseresearch.nl>"]
include = [
"/README.md",
@ -58,6 +58,10 @@ required-features = [
name = "d3d12-buffer-winrs"
required-features = ["d3d12"]
[[example]]
name = "metal-buffer"
required-features = ["metal"]
[dependencies.ash]
version = ">=0.34, <=0.37"
features = ["debug"]
@ -65,12 +69,12 @@ optional = true
default-features = false
[dependencies.egui]
version = "0.24"
version = ">=0.24, <=0.27"
optional = true
default-features = false
[dependencies.egui_extras]
version = "0.24"
version = ">=0.24, <=0.27"
optional = true
default-features = false
@ -95,17 +99,27 @@ default-features = false
version = "0.10"
[features]
d3d12 = ["windows"]
d3d12 = ["dep:windows"]
default = [
"d3d12",
"vulkan",
]
metal = ["dep:metal"]
public-winapi = ["dep:winapi"]
visualizer = [
"egui",
"egui_extras",
"dep:egui",
"dep:egui_extras",
]
vulkan = ["ash"]
vulkan = ["dep:ash"]
[target."cfg(any(target_os = \"macos\", target_os = \"ios\"))".dependencies.metal]
version = "0.27.0"
features = [
"link",
"dispatch",
]
optional = true
default-features = false
[target."cfg(windows)".dependencies.winapi]
version = "0.3.9"

37
third_party/rust/gpu-allocator/README.md поставляемый
Просмотреть файл

@ -12,12 +12,12 @@
```toml
[dependencies]
gpu-allocator = "0.25.0"
gpu-allocator = "0.26.0"
```
![Visualizer](visualizer.png)
This crate provides a fully written in Rust memory allocator for Vulkan and DirectX 12.
This crate provides a fully written in Rust memory allocator for Vulkan, DirectX 12 and Metal.
## [Windows-rs] and [winapi]
@ -130,9 +130,40 @@ drop(resource);
allocator.free(allocation).unwrap();
```
## Setting up the Metal memory allocator
```rust
use gpu_allocator::metal::*;
let mut allocator = Allocator::new(&AllocatorCreateDesc {
device: device.clone(),
debug_settings: Default::default(),
allocation_sizes: Default::default(),
});
```
## Simple Metal allocation example
```rust
use gpu_allocator::metal::*;
use gpu_allocator::MemoryLocation;
let allocation_desc = AllocationCreateDesc::buffer(
&device,
"Example allocation",
512, // size in bytes
gpu_allocator::MemoryLocation::GpuOnly,
);
let allocation = allocator.allocate(&allocation_desc).unwrap();
let resource = allocation.make_buffer().unwrap();
// Cleanup
drop(resource);
allocator.free(&allocation).unwrap();
```
## Minimum Supported Rust Version
The MSRV for this crate and the `vulkan` and `d3d12` features is Rust 1.65. Any other features such as the `visualizer` (with all the `egui` dependencies) may have a higher requirement and are not tested in our CI.
The MSRV for this crate and the `vulkan`, `d3d12` and `metal` features is Rust 1.65. Any other features such as the `visualizer` (with all the `egui` dependencies) may have a higher requirement and are not tested in our CI.
## License

93
third_party/rust/gpu-allocator/examples/metal-buffer.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,93 @@
use std::sync::Arc;
use gpu_allocator::metal::{AllocationCreateDesc, Allocator, AllocatorCreateDesc};
use log::info;
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("trace")).init();
let device = Arc::new(metal::Device::system_default().unwrap());
// Setting up the allocator
let mut allocator = Allocator::new(&AllocatorCreateDesc {
device: device.clone(),
debug_settings: Default::default(),
allocation_sizes: Default::default(),
})
.unwrap();
// Test allocating Gpu Only memory
{
let allocation_desc = AllocationCreateDesc::buffer(
&device,
"Test allocation (Gpu Only)",
512,
gpu_allocator::MemoryLocation::GpuOnly,
);
let allocation = allocator.allocate(&allocation_desc).unwrap();
let _buffer = allocation.make_buffer().unwrap();
allocator.free(&allocation).unwrap();
info!("Allocation and deallocation of GpuOnly memory was successful.");
}
// Test allocating Cpu to Gpu memory
{
let allocation_desc = AllocationCreateDesc::buffer(
&device,
"Test allocation (Cpu to Gpu)",
512,
gpu_allocator::MemoryLocation::CpuToGpu,
);
let allocation = allocator.allocate(&allocation_desc).unwrap();
let _buffer = allocation.make_buffer().unwrap();
allocator.free(&allocation).unwrap();
info!("Allocation and deallocation of CpuToGpu memory was successful.");
}
// Test allocating Gpu to Cpu memory
{
let allocation_desc = AllocationCreateDesc::buffer(
&device,
"Test allocation (Gpu to Cpu)",
512,
gpu_allocator::MemoryLocation::GpuToCpu,
);
let allocation = allocator.allocate(&allocation_desc).unwrap();
let _buffer = allocation.make_buffer().unwrap();
allocator.free(&allocation).unwrap();
info!("Allocation and deallocation of GpuToCpu memory was successful.");
}
// Test allocating texture
{
let texture_desc = metal::TextureDescriptor::new();
texture_desc.set_pixel_format(metal::MTLPixelFormat::RGBA8Unorm);
texture_desc.set_width(64);
texture_desc.set_height(64);
texture_desc.set_storage_mode(metal::MTLStorageMode::Private);
let allocation_desc =
AllocationCreateDesc::texture(&device, "Test allocation (Texture)", &texture_desc);
let allocation = allocator.allocate(&allocation_desc).unwrap();
let _texture = allocation.make_texture(&texture_desc).unwrap();
allocator.free(&allocation).unwrap();
info!("Allocation and deallocation of Texture was successful.");
}
// Test allocating acceleration structure
{
let empty_array = metal::Array::from_slice(&[]);
let acc_desc = metal::PrimitiveAccelerationStructureDescriptor::descriptor();
acc_desc.set_geometry_descriptors(empty_array);
let sizes = device.acceleration_structure_sizes_with_descriptor(&acc_desc);
let allocation_desc = AllocationCreateDesc::acceleration_structure_with_size(
&device,
"Test allocation (Acceleration structure)",
sizes.acceleration_structure_size,
gpu_allocator::MemoryLocation::GpuOnly,
);
let allocation = allocator.allocate(&allocation_desc).unwrap();
let _acc_structure = allocation.make_acceleration_structure();
allocator.free(&allocation).unwrap();
info!("Allocation and deallocation of Acceleration structure was successful.");
}
}

Просмотреть файл

@ -4,7 +4,10 @@ use std::{backtrace::Backtrace, fmt, sync::Arc};
use log::{debug, warn, Level};
use windows::Win32::{Foundation::E_OUTOFMEMORY, Graphics::Direct3D12::*};
use windows::Win32::{
Foundation::E_OUTOFMEMORY,
Graphics::{Direct3D12::*, Dxgi::Common::DXGI_FORMAT},
};
#[cfg(feature = "public-winapi")]
mod public_winapi {
@ -110,6 +113,7 @@ pub struct ResourceCreateDesc<'a> {
pub memory_location: MemoryLocation,
pub resource_category: ResourceCategory,
pub resource_desc: &'a D3D12_RESOURCE_DESC,
pub castable_formats: &'a [DXGI_FORMAT],
pub clear_value: Option<&'a D3D12_CLEAR_VALUE>,
pub initial_state_or_layout: ResourceStateOrBarrierLayout,
pub resource_type: &'a ResourceType<'a>,
@ -242,6 +246,8 @@ pub enum ID3D12DeviceVersion {
/// Required for enhanced barrier support, i.e. when using
/// [`ResourceStateOrBarrierLayout::BarrierLayout`].
Device10(ID3D12Device10),
/// Required for castable formats support, implies use of enhanced barriers
Device12(ID3D12Device12),
}
impl std::ops::Deref for ID3D12DeviceVersion {
@ -250,8 +256,9 @@ impl std::ops::Deref for ID3D12DeviceVersion {
fn deref(&self) -> &Self::Target {
match self {
Self::Device(device) => device,
// Windows-rs hides CanInto, we know that Device10 is a subclass of Device but there's not even a Deref.
// Windows-rs hides CanInto, we know that Device10/Device12 is a subclass of Device but there's not even a Deref.
Self::Device10(device10) => windows::core::CanInto::can_into(device10),
Self::Device12(device12) => windows::core::CanInto::can_into(device12),
}
}
}
@ -806,6 +813,66 @@ impl Allocator {
}
}
fn d3d12_resource_desc_1(desc: &D3D12_RESOURCE_DESC) -> D3D12_RESOURCE_DESC1 {
D3D12_RESOURCE_DESC1 {
Dimension: desc.Dimension,
Alignment: desc.Alignment,
Width: desc.Width,
Height: desc.Height,
DepthOrArraySize: desc.DepthOrArraySize,
MipLevels: desc.MipLevels,
Format: desc.Format,
SampleDesc: desc.SampleDesc,
Layout: desc.Layout,
Flags: desc.Flags,
// TODO: This is the only new field
SamplerFeedbackMipRegion: D3D12_MIP_REGION::default(),
}
}
fn resource_allocation_info(
device: &ID3D12DeviceVersion,
desc: &ResourceCreateDesc<'_>,
) -> D3D12_RESOURCE_ALLOCATION_INFO {
match device {
ID3D12DeviceVersion::Device(device) => unsafe {
device.GetResourceAllocationInfo(0, &[*desc.resource_desc])
},
ID3D12DeviceVersion::Device10(device) => unsafe {
device.GetResourceAllocationInfo(0, &[*desc.resource_desc])
},
ID3D12DeviceVersion::Device12(device) => unsafe {
let resource_desc1 = Self::d3d12_resource_desc_1(desc.resource_desc);
let resource_descs = &[resource_desc1];
// We always have one resource desc, hence we only have one mapping castable format array
let num_castable_formats = desc.castable_formats.len() as u32;
let num_castable_formats_array = &[num_castable_formats];
let castable_formats_array = &[desc.castable_formats.as_ptr()];
let (num_castable_formats_opt, castable_formats_opt) = if num_castable_formats > 0 {
(
Some(num_castable_formats_array.as_ptr()),
Some(castable_formats_array.as_ptr()),
)
} else {
(None, None)
};
device.GetResourceAllocationInfo3(
0,
resource_descs.len() as u32,
resource_descs.as_ptr(),
num_castable_formats_opt,
castable_formats_opt,
None,
)
},
}
}
/// Create a resource according to the provided parameters.
/// Created resources should be freed at the end of their lifetime by calling [`Self::free_resource()`].
pub fn create_resource(&mut self, desc: &ResourceCreateDesc<'_>) -> Result<Resource> {
@ -821,6 +888,52 @@ impl Allocator {
if let Err(e) = unsafe {
match (&self.device, desc.initial_state_or_layout) {
(_, ResourceStateOrBarrierLayout::ResourceState(_))
if !desc.castable_formats.is_empty() =>
{
return Err(AllocationError::CastableFormatsRequiresEnhancedBarriers)
}
(
ID3D12DeviceVersion::Device12(device),
ResourceStateOrBarrierLayout::BarrierLayout(initial_layout),
) => {
let resource_desc1 = Self::d3d12_resource_desc_1(desc.resource_desc);
device.CreateCommittedResource3(
*heap_properties,
*heap_flags,
&resource_desc1,
initial_layout,
clear_value,
None, // TODO
Some(desc.castable_formats),
&mut result,
)
}
(_, ResourceStateOrBarrierLayout::BarrierLayout(_))
if !desc.castable_formats.is_empty() =>
{
return Err(AllocationError::CastableFormatsRequiresAtLeastDevice12)
}
(
ID3D12DeviceVersion::Device10(device),
ResourceStateOrBarrierLayout::BarrierLayout(initial_layout),
) => {
let resource_desc1 = Self::d3d12_resource_desc_1(desc.resource_desc);
device.CreateCommittedResource3(
*heap_properties,
*heap_flags,
&resource_desc1,
initial_layout,
clear_value,
None, // TODO
None,
&mut result,
)
}
(_, ResourceStateOrBarrierLayout::BarrierLayout(_)) => {
return Err(AllocationError::BarrierLayoutNeedsDevice10)
}
(device, ResourceStateOrBarrierLayout::ResourceState(initial_state)) => {
device.CreateCommittedResource(
*heap_properties,
@ -831,37 +944,6 @@ impl Allocator {
&mut result,
)
}
(
ID3D12DeviceVersion::Device10(device),
ResourceStateOrBarrierLayout::BarrierLayout(initial_layout),
) => {
let resource_desc1 = D3D12_RESOURCE_DESC1 {
Dimension: desc.resource_desc.Dimension,
Alignment: desc.resource_desc.Alignment,
Width: desc.resource_desc.Width,
Height: desc.resource_desc.Height,
DepthOrArraySize: desc.resource_desc.DepthOrArraySize,
MipLevels: desc.resource_desc.MipLevels,
Format: desc.resource_desc.Format,
SampleDesc: desc.resource_desc.SampleDesc,
Layout: desc.resource_desc.Layout,
Flags: desc.resource_desc.Flags,
// TODO: This is the only new field
SamplerFeedbackMipRegion: D3D12_MIP_REGION::default(),
};
device.CreateCommittedResource3(
*heap_properties,
*heap_flags,
&resource_desc1,
initial_layout,
clear_value,
None, // TODO
None, // TODO: https://github.com/microsoft/DirectX-Specs/blob/master/d3d/VulkanOn12.md#format-list-casting
&mut result,
)
}
_ => return Err(AllocationError::BarrierLayoutNeedsDevice10),
}
} {
return Err(AllocationError::Internal(format!(
@ -872,10 +954,7 @@ impl Allocator {
let resource = result.expect("Allocation succeeded but no resource was returned?");
let allocation_info = unsafe {
self.device
.GetResourceAllocationInfo(0, &[*desc.resource_desc])
};
let allocation_info = Self::resource_allocation_info(&self.device, desc);
let memory_type = self
.memory_types
@ -906,10 +985,7 @@ impl Allocator {
}
ResourceType::Placed => {
let allocation_desc = {
let allocation_info = unsafe {
self.device
.GetResourceAllocationInfo(0, &[*desc.resource_desc])
};
let allocation_info = Self::resource_allocation_info(&self.device, desc);
AllocationCreateDesc {
name: desc.name,
@ -925,6 +1001,49 @@ impl Allocator {
let mut result: Option<ID3D12Resource> = None;
if let Err(e) = unsafe {
match (&self.device, desc.initial_state_or_layout) {
(_, ResourceStateOrBarrierLayout::ResourceState(_))
if !desc.castable_formats.is_empty() =>
{
return Err(AllocationError::CastableFormatsRequiresEnhancedBarriers)
}
(
ID3D12DeviceVersion::Device12(device),
ResourceStateOrBarrierLayout::BarrierLayout(initial_layout),
) => {
let resource_desc1 = Self::d3d12_resource_desc_1(desc.resource_desc);
device.CreatePlacedResource2(
allocation.heap(),
allocation.offset(),
&resource_desc1,
initial_layout,
None,
Some(desc.castable_formats),
&mut result,
)
}
(_, ResourceStateOrBarrierLayout::BarrierLayout(_))
if !desc.castable_formats.is_empty() =>
{
return Err(AllocationError::CastableFormatsRequiresAtLeastDevice12)
}
(
ID3D12DeviceVersion::Device10(device),
ResourceStateOrBarrierLayout::BarrierLayout(initial_layout),
) => {
let resource_desc1 = Self::d3d12_resource_desc_1(desc.resource_desc);
device.CreatePlacedResource2(
allocation.heap(),
allocation.offset(),
&resource_desc1,
initial_layout,
None,
None,
&mut result,
)
}
(_, ResourceStateOrBarrierLayout::BarrierLayout(_)) => {
return Err(AllocationError::BarrierLayoutNeedsDevice10)
}
(device, ResourceStateOrBarrierLayout::ResourceState(initial_state)) => {
device.CreatePlacedResource(
allocation.heap(),
@ -935,35 +1054,6 @@ impl Allocator {
&mut result,
)
}
(
ID3D12DeviceVersion::Device10(device),
ResourceStateOrBarrierLayout::BarrierLayout(initial_layout),
) => {
let resource_desc1 = D3D12_RESOURCE_DESC1 {
Dimension: desc.resource_desc.Dimension,
Alignment: desc.resource_desc.Alignment,
Width: desc.resource_desc.Width,
Height: desc.resource_desc.Height,
DepthOrArraySize: desc.resource_desc.DepthOrArraySize,
MipLevels: desc.resource_desc.MipLevels,
Format: desc.resource_desc.Format,
SampleDesc: desc.resource_desc.SampleDesc,
Layout: desc.resource_desc.Layout,
Flags: desc.resource_desc.Flags,
// TODO: This is the only new field
SamplerFeedbackMipRegion: D3D12_MIP_REGION::default(),
};
device.CreatePlacedResource2(
allocation.heap(),
allocation.offset(),
&resource_desc1,
initial_layout,
None,
None, // TODO: https://github.com/microsoft/DirectX-Specs/blob/master/d3d/VulkanOn12.md#format-list-casting
&mut result,
)
}
_ => return Err(AllocationError::BarrierLayoutNeedsDevice10),
}
} {
return Err(AllocationError::Internal(format!(

56
third_party/rust/gpu-allocator/src/lib.rs поставляемый
Просмотреть файл

@ -1,4 +1,4 @@
//! This crate provides a fully written in Rust memory allocator for Vulkan and DirectX 12.
//! This crate provides a fully written in Rust memory allocator for Vulkan, DirectX 12 and Metal.
//!
//! # [Windows-rs] and [winapi]
//!
@ -155,6 +155,57 @@
//! # #[cfg(not(feature = "d3d12"))]
//! # fn main() {}
//! ```
//!
//! # Setting up the Metal memory allocator
//!
//! ```no_run
//! # #[cfg(feature = "metal")]
//! # fn main() {
//! # use std::sync::Arc;
//! use gpu_allocator::metal::*;
//!
//! # let device = Arc::new(metal::Device::system_default().unwrap());
//! let mut allocator = Allocator::new(&AllocatorCreateDesc {
//! device: device.clone(),
//! debug_settings: Default::default(),
//! allocation_sizes: Default::default(),
//! });
//! # }
//! # #[cfg(not(feature = "metal"))]
//! # fn main() {}
//! ```
//!
//! # Simple Metal allocation example
//! ```no_run
//! # #[cfg(feature = "metal")]
//! # fn main() {
//! # use std::sync::Arc;
//! use gpu_allocator::metal::*;
//! use gpu_allocator::MemoryLocation;
//! # let device = Arc::new(metal::Device::system_default().unwrap());
//! # let mut allocator = Allocator::new(&AllocatorCreateDesc {
//! # device: device.clone(),
//! # debug_settings: Default::default(),
//! # allocation_sizes: Default::default(),
//! # })
//! # .unwrap();
//!
//! let allocation_desc = AllocationCreateDesc::buffer(
//! &device,
//! "Example allocation",
//! 512, // size in bytes
//! gpu_allocator::MemoryLocation::GpuOnly,
//! );
//! let allocation = allocator.allocate(&allocation_desc).unwrap();
//! let resource = allocation.make_buffer().unwrap();
//!
//! // Cleanup
//! drop(resource);
//! allocator.free(&allocation).unwrap();
//! # }
//! # #[cfg(not(feature = "metal"))]
//! # fn main() {}
//! ```
mod result;
pub use result::*;
@ -170,6 +221,9 @@ pub mod vulkan;
#[cfg(all(windows, feature = "d3d12"))]
pub mod d3d12;
#[cfg(all(any(target_os = "macos", target_os = "ios"), feature = "metal"))]
pub mod metal;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum MemoryLocation {
/// The allocated resource is stored at an unknown memory location; let the driver decide what's the best location

488
third_party/rust/gpu-allocator/src/metal/mod.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,488 @@
#![deny(clippy::unimplemented, clippy::unwrap_used, clippy::ok_expect)]
use std::{backtrace::Backtrace, sync::Arc};
use crate::{
allocator, AllocationError, AllocationSizes, AllocatorDebugSettings, MemoryLocation, Result,
};
use log::{debug, Level};
fn memory_location_to_metal(location: MemoryLocation) -> metal::MTLResourceOptions {
match location {
MemoryLocation::GpuOnly => metal::MTLResourceOptions::StorageModePrivate,
MemoryLocation::CpuToGpu | MemoryLocation::GpuToCpu | MemoryLocation::Unknown => {
metal::MTLResourceOptions::StorageModeShared
}
}
}
pub struct Allocation {
chunk_id: Option<std::num::NonZeroU64>,
offset: u64,
size: u64,
memory_block_index: usize,
memory_type_index: usize,
heap: Arc<metal::Heap>,
name: Option<Box<str>>,
}
impl Allocation {
pub fn heap(&self) -> &metal::Heap {
self.heap.as_ref()
}
pub fn make_buffer(&self) -> Option<metal::Buffer> {
let resource =
self.heap
.new_buffer_with_offset(self.size, self.heap.resource_options(), self.offset);
if let Some(resource) = &resource {
if let Some(name) = &self.name {
resource.set_label(name);
}
}
resource
}
pub fn make_texture(&self, desc: &metal::TextureDescriptor) -> Option<metal::Texture> {
let resource = self.heap.new_texture_with_offset(desc, self.offset);
if let Some(resource) = &resource {
if let Some(name) = &self.name {
resource.set_label(name);
}
}
resource
}
pub fn make_acceleration_structure(&self) -> Option<metal::AccelerationStructure> {
let resource = self
.heap
.new_acceleration_structure_with_size_offset(self.size, self.offset);
if let Some(resource) = &resource {
if let Some(name) = &self.name {
resource.set_label(name);
}
}
resource
}
fn is_null(&self) -> bool {
self.chunk_id.is_none()
}
}
pub struct AllocationCreateDesc<'a> {
/// Name of the allocation, for tracking and debugging purposes
pub name: &'a str,
/// Location where the memory allocation should be stored
pub location: MemoryLocation,
pub size: u64,
pub alignment: u64,
}
impl<'a> AllocationCreateDesc<'a> {
pub fn buffer(
device: &metal::Device,
name: &'a str,
length: u64,
location: MemoryLocation,
) -> AllocationCreateDesc<'a> {
let size_and_align =
device.heap_buffer_size_and_align(length, memory_location_to_metal(location));
Self {
name,
location,
size: size_and_align.size,
alignment: size_and_align.align,
}
}
pub fn texture(
device: &metal::Device,
name: &'a str,
desc: &metal::TextureDescriptor,
) -> AllocationCreateDesc<'a> {
let size_and_align = device.heap_texture_size_and_align(desc);
Self {
name,
location: match desc.storage_mode() {
metal::MTLStorageMode::Shared
| metal::MTLStorageMode::Managed
| metal::MTLStorageMode::Memoryless => MemoryLocation::Unknown,
metal::MTLStorageMode::Private => MemoryLocation::GpuOnly,
},
size: size_and_align.size,
alignment: size_and_align.align,
}
}
pub fn acceleration_structure_with_size(
device: &metal::Device,
name: &'a str,
size: u64,
location: MemoryLocation,
) -> AllocationCreateDesc<'a> {
let size_and_align = device.heap_acceleration_structure_size_and_align_with_size(size);
Self {
name,
location,
size: size_and_align.size,
alignment: size_and_align.align,
}
}
}
pub struct Allocator {
device: Arc<metal::Device>,
debug_settings: AllocatorDebugSettings,
memory_types: Vec<MemoryType>,
allocation_sizes: AllocationSizes,
}
pub struct AllocatorCreateDesc {
pub device: Arc<metal::Device>,
pub debug_settings: AllocatorDebugSettings,
pub allocation_sizes: AllocationSizes,
}
pub struct CommittedAllocationStatistics {
pub num_allocations: usize,
pub total_size: u64,
}
struct MemoryBlock {
heap: Arc<metal::Heap>,
_size: u64,
sub_allocator: Box<dyn allocator::SubAllocator>,
}
impl MemoryBlock {
fn new(
device: &Arc<metal::Device>,
size: u64,
heap_descriptor: &metal::HeapDescriptor,
dedicated: bool,
) -> Result<Self> {
heap_descriptor.set_size(size);
let heap = Arc::new(device.new_heap(heap_descriptor));
let sub_allocator: Box<dyn allocator::SubAllocator> = if dedicated {
Box::new(allocator::DedicatedBlockAllocator::new(size))
} else {
Box::new(allocator::FreeListAllocator::new(size))
};
Ok(Self {
heap,
_size: size,
sub_allocator,
})
}
}
struct MemoryType {
memory_blocks: Vec<Option<MemoryBlock>>,
_committed_allocations: CommittedAllocationStatistics,
memory_location: MemoryLocation,
heap_properties: metal::HeapDescriptor,
memory_type_index: usize,
active_general_blocks: usize,
}
impl MemoryType {
fn allocate(
&mut self,
device: &Arc<metal::Device>,
desc: &AllocationCreateDesc<'_>,
backtrace: Arc<Backtrace>,
allocation_sizes: &AllocationSizes,
) -> Result<Allocation> {
let allocation_type = allocator::AllocationType::Linear;
let memblock_size = if self.heap_properties.storage_mode() == metal::MTLStorageMode::Private
{
allocation_sizes.device_memblock_size
} else {
allocation_sizes.host_memblock_size
};
let size = desc.size;
let alignment = desc.alignment;
// Create a dedicated block for large memory allocations
if size > memblock_size {
let mem_block = MemoryBlock::new(device, size, &self.heap_properties, true)?;
let block_index = self.memory_blocks.iter().position(|block| block.is_none());
let block_index = match block_index {
Some(i) => {
self.memory_blocks[i].replace(mem_block);
i
}
None => {
self.memory_blocks.push(Some(mem_block));
self.memory_blocks.len() - 1
}
};
let mem_block = self.memory_blocks[block_index]
.as_mut()
.ok_or_else(|| AllocationError::Internal("Memory block must be Some".into()))?;
let (offset, chunk_id) = mem_block.sub_allocator.allocate(
size,
alignment,
allocation_type,
1,
desc.name,
backtrace,
)?;
return Ok(Allocation {
chunk_id: Some(chunk_id),
size,
offset,
memory_block_index: block_index,
memory_type_index: self.memory_type_index,
heap: mem_block.heap.clone(),
name: Some(desc.name.into()),
});
}
let mut empty_block_index = None;
for (mem_block_i, mem_block) in self.memory_blocks.iter_mut().enumerate().rev() {
if let Some(mem_block) = mem_block {
let allocation = mem_block.sub_allocator.allocate(
size,
alignment,
allocation_type,
1,
desc.name,
backtrace.clone(),
);
match allocation {
Ok((offset, chunk_id)) => {
return Ok(Allocation {
chunk_id: Some(chunk_id),
offset,
size,
memory_block_index: mem_block_i,
memory_type_index: self.memory_type_index,
heap: mem_block.heap.clone(),
name: Some(desc.name.into()),
});
}
Err(AllocationError::OutOfMemory) => {} // Block is full, continue search.
Err(err) => return Err(err), // Unhandled error, return.
}
} else if empty_block_index.is_none() {
empty_block_index = Some(mem_block_i);
}
}
let new_memory_block =
MemoryBlock::new(device, memblock_size, &self.heap_properties, false)?;
let new_block_index = if let Some(block_index) = empty_block_index {
self.memory_blocks[block_index] = Some(new_memory_block);
block_index
} else {
self.memory_blocks.push(Some(new_memory_block));
self.memory_blocks.len() - 1
};
self.active_general_blocks += 1;
let mem_block = self.memory_blocks[new_block_index]
.as_mut()
.ok_or_else(|| AllocationError::Internal("Memory block must be Some".into()))?;
let allocation = mem_block.sub_allocator.allocate(
size,
alignment,
allocation_type,
1,
desc.name,
backtrace,
);
let (offset, chunk_id) = match allocation {
Err(AllocationError::OutOfMemory) => Err(AllocationError::Internal(
"Allocation that must succeed failed. This is a bug in the allocator.".into(),
)),
a => a,
}?;
Ok(Allocation {
chunk_id: Some(chunk_id),
offset,
size,
memory_block_index: new_block_index,
memory_type_index: self.memory_type_index,
heap: mem_block.heap.clone(),
name: Some(desc.name.into()),
})
}
fn free(&mut self, allocation: &Allocation) -> Result<()> {
let block_idx = allocation.memory_block_index;
let mem_block = self.memory_blocks[block_idx]
.as_mut()
.ok_or_else(|| AllocationError::Internal("Memory block must be Some.".into()))?;
mem_block.sub_allocator.free(allocation.chunk_id)?;
if mem_block.sub_allocator.is_empty() {
if mem_block.sub_allocator.supports_general_allocations() {
if self.active_general_blocks > 1 {
let block = self.memory_blocks[block_idx].take();
if block.is_none() {
return Err(AllocationError::Internal(
"Memory block must be Some.".into(),
));
}
// Note that `block` will be destroyed on `drop` here
self.active_general_blocks -= 1;
}
} else {
let block = self.memory_blocks[block_idx].take();
if block.is_none() {
return Err(AllocationError::Internal(
"Memory block must be Some.".into(),
));
}
// Note that `block` will be destroyed on `drop` here
}
}
Ok(())
}
}
pub struct ResourceCreateDesc {}
pub struct Resource {}
impl Allocator {
pub fn device(&self) -> &metal::Device {
todo!()
}
pub fn new(desc: &AllocatorCreateDesc) -> Result<Self> {
let heap_types = [
(MemoryLocation::GpuOnly, {
let heap_desc = metal::HeapDescriptor::new();
heap_desc.set_cpu_cache_mode(metal::MTLCPUCacheMode::DefaultCache);
heap_desc.set_storage_mode(metal::MTLStorageMode::Private);
heap_desc.set_heap_type(metal::MTLHeapType::Placement);
heap_desc
}),
(MemoryLocation::CpuToGpu, {
let heap_desc = metal::HeapDescriptor::new();
heap_desc.set_cpu_cache_mode(metal::MTLCPUCacheMode::WriteCombined);
heap_desc.set_storage_mode(metal::MTLStorageMode::Shared);
heap_desc.set_heap_type(metal::MTLHeapType::Placement);
heap_desc
}),
(MemoryLocation::GpuToCpu, {
let heap_desc = metal::HeapDescriptor::new();
heap_desc.set_cpu_cache_mode(metal::MTLCPUCacheMode::DefaultCache);
heap_desc.set_storage_mode(metal::MTLStorageMode::Shared);
heap_desc.set_heap_type(metal::MTLHeapType::Placement);
heap_desc
}),
];
let memory_types = heap_types
.iter()
.enumerate()
.map(|(i, (memory_location, heap_descriptor))| MemoryType {
memory_blocks: vec![],
_committed_allocations: CommittedAllocationStatistics {
num_allocations: 0,
total_size: 0,
},
memory_location: *memory_location,
heap_properties: heap_descriptor.clone(),
memory_type_index: i,
active_general_blocks: 0,
})
.collect();
Ok(Self {
device: desc.device.clone(),
debug_settings: desc.debug_settings,
memory_types,
allocation_sizes: desc.allocation_sizes,
})
}
pub fn allocate(&mut self, desc: &AllocationCreateDesc<'_>) -> Result<Allocation> {
let size = desc.size;
let alignment = desc.alignment;
let backtrace = Arc::new(if self.debug_settings.store_stack_traces {
Backtrace::force_capture()
} else {
Backtrace::disabled()
});
if self.debug_settings.log_allocations {
debug!(
"Allocating `{}` of {} bytes with an alignment of {}.",
&desc.name, size, alignment
);
if self.debug_settings.log_stack_traces {
let backtrace = Backtrace::force_capture();
debug!("Allocation stack trace: {}", backtrace);
}
}
if size == 0 || !alignment.is_power_of_two() {
return Err(AllocationError::InvalidAllocationCreateDesc);
}
// Find memory type
let memory_type = self
.memory_types
.iter_mut()
.find(|memory_type| {
// Is location compatible
desc.location == MemoryLocation::Unknown
|| desc.location == memory_type.memory_location
})
.ok_or(AllocationError::NoCompatibleMemoryTypeFound)?;
memory_type.allocate(&self.device, desc, backtrace, &self.allocation_sizes)
}
pub fn free(&mut self, allocation: &Allocation) -> Result<()> {
if self.debug_settings.log_frees {
let name = allocation.name.as_deref().unwrap_or("<null>");
debug!("Freeing `{}`.", name);
if self.debug_settings.log_stack_traces {
let backtrace = Backtrace::force_capture();
debug!("Free stack trace: {}", backtrace);
}
}
if allocation.is_null() {
return Ok(());
}
self.memory_types[allocation.memory_type_index].free(allocation)?;
Ok(())
}
pub fn get_heaps(&self) -> Vec<&metal::HeapRef> {
// Get all memory blocks
let mut heaps: Vec<&metal::HeapRef> = Vec::new();
for memory_type in &self.memory_types {
for block in memory_type.memory_blocks.iter().flatten() {
heaps.push(block.heap.as_ref());
}
}
heaps
}
pub fn rename_allocation(&mut self, _allocation: &mut Allocation, _name: &str) -> Result<()> {
todo!()
}
pub fn report_memory_leaks(&self, _log_level: Level) {
todo!()
}
}

Просмотреть файл

@ -14,8 +14,12 @@ pub enum AllocationError {
InvalidAllocatorCreateDesc(String),
#[error("Internal error: {0}")]
Internal(String),
#[error("Initial `BARRIER_LAYOUT` needs `Device10`")]
#[error("Initial `BARRIER_LAYOUT` needs at least `Device10`")]
BarrierLayoutNeedsDevice10,
#[error("Castable formats require enhanced barriers")]
CastableFormatsRequiresEnhancedBarriers,
#[error("Castable formats require at least `Device12`")]
CastableFormatsRequiresAtLeastDevice12,
}
pub type Result<V, E = AllocationError> = ::std::result::Result<V, E>;

Просмотреть файл

@ -37,9 +37,11 @@ pub(crate) fn render_allocation_reports_ui(
.enumerate()
.filter(|(_, report)| report.name.to_lowercase().contains(&breakdown_filter))
.collect::<Vec<_>>();
let total_size_under_filter: u64 = allocations.iter().map(|a| a.1.size).sum();
ui.label(format!("Total: {}", fmt_bytes(total_size_under_filter)));
let row_height = ui.text_style_height(&egui::TextStyle::Body);
let table = TableBuilder::new(ui)
.striped(true)
.resizable(true)
@ -49,7 +51,7 @@ pub(crate) fn render_allocation_reports_ui(
fn header_button(ui: &mut Ui, label: &str) -> Response {
let label = WidgetText::from(label).strong();
let label = Label::new(label.strong()).sense(Sense::click());
let label = Label::new(label).sense(Sense::click());
ui.add(label)
}

Просмотреть файл

@ -10,7 +10,7 @@ use std::{backtrace::Backtrace, fmt, marker::PhantomData, sync::Arc};
use ash::vk;
use log::{debug, Level};
use super::allocator::{self, AllocationType};
use super::allocator;
use crate::{
allocator::fmt_bytes, AllocationError, AllocationSizes, AllocatorDebugSettings, MemoryLocation,
Result,
@ -459,9 +459,9 @@ impl MemoryType {
allocation_sizes: &AllocationSizes,
) -> Result<Allocation> {
let allocation_type = if desc.linear {
AllocationType::Linear
allocator::AllocationType::Linear
} else {
AllocationType::NonLinear
allocator::AllocationType::NonLinear
};
let memblock_size = if self

2
third_party/rust/naga/.cargo-checksum.json поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

2
third_party/rust/naga/Cargo.toml поставляемый
Просмотреть файл

@ -79,7 +79,7 @@ version = "0.2.1"
optional = true
[dependencies.serde]
version = "1.0.198"
version = "1.0.200"
features = ["derive"]
optional = true

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

4
third_party/rust/wgpu-hal/Cargo.toml поставляемый
Просмотреть файл

@ -86,7 +86,7 @@ path = "../naga"
features = ["wgsl-in"]
[dev-dependencies.winit]
version = "0.29.14"
version = "0.29"
features = ["android-native-activity"]
[build-dependencies]
@ -234,7 +234,7 @@ version = "0.5"
optional = true
[target."cfg(windows)".dependencies.gpu-allocator]
version = "0.25"
version = "0.26"
features = [
"d3d12",
"public-winapi",

Просмотреть файл

@ -215,11 +215,16 @@ mod placed {
);
Self::Lost
}
gpu_allocator::AllocationError::Internal(e) => {
log::error!("DX12 gpu-allocator: Internal Error: {}", e);
Self::Lost
}
gpu_allocator::AllocationError::BarrierLayoutNeedsDevice10 => todo!(),
gpu_allocator::AllocationError::BarrierLayoutNeedsDevice10
| gpu_allocator::AllocationError::CastableFormatsRequiresEnhancedBarriers
| gpu_allocator::AllocationError::CastableFormatsRequiresAtLeastDevice12 => {
unreachable!()
}
}
}
}