From 85242648069aff27e672053b1c76286aa9838b88 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 15 Nov 2019 00:29:53 +0000 Subject: [PATCH] Bug 1594182 - Move wgpu stuff under gfx/wgpu r=jgilbert,remote-protocol-reviewers This change moves wgpu mirror into a dedicated folder and also registers it in a few metadata files for proper treating. Differential Revision: https://phabricator.services.mozilla.com/D51921 --HG-- rename : dom/webgpu/wgpu-native/Cargo.toml => gfx/wgpu/wgpu-native/Cargo.toml rename : dom/webgpu/wgpu-remote/cbindgen.toml => gfx/wgpu/wgpu-native/cbindgen.toml rename : dom/webgpu/wgpu-native/src/binding_model.rs => gfx/wgpu/wgpu-native/src/binding_model.rs rename : dom/webgpu/wgpu-native/src/command/allocator.rs => gfx/wgpu/wgpu-native/src/command/allocator.rs rename : dom/webgpu/wgpu-native/src/command/bind.rs => gfx/wgpu/wgpu-native/src/command/bind.rs rename : dom/webgpu/wgpu-native/src/command/compute.rs => gfx/wgpu/wgpu-native/src/command/compute.rs rename : dom/webgpu/wgpu-native/src/command/mod.rs => gfx/wgpu/wgpu-native/src/command/mod.rs rename : dom/webgpu/wgpu-native/src/command/render.rs => gfx/wgpu/wgpu-native/src/command/render.rs rename : dom/webgpu/wgpu-native/src/command/transfer.rs => gfx/wgpu/wgpu-native/src/command/transfer.rs rename : dom/webgpu/wgpu-native/src/conv.rs => gfx/wgpu/wgpu-native/src/conv.rs rename : dom/webgpu/wgpu-native/src/device.rs => gfx/wgpu/wgpu-native/src/device.rs rename : dom/webgpu/wgpu-native/src/hub.rs => gfx/wgpu/wgpu-native/src/hub.rs rename : dom/webgpu/wgpu-native/src/id.rs => gfx/wgpu/wgpu-native/src/id.rs rename : dom/webgpu/wgpu-native/src/instance.rs => gfx/wgpu/wgpu-native/src/instance.rs rename : dom/webgpu/wgpu-native/src/lib.rs => gfx/wgpu/wgpu-native/src/lib.rs rename : dom/webgpu/wgpu-native/src/pipeline.rs => gfx/wgpu/wgpu-native/src/pipeline.rs rename : dom/webgpu/wgpu-native/src/resource.rs => gfx/wgpu/wgpu-native/src/resource.rs rename : dom/webgpu/wgpu-native/src/swap_chain.rs => gfx/wgpu/wgpu-native/src/swap_chain.rs rename : dom/webgpu/wgpu-native/src/track/buffer.rs => gfx/wgpu/wgpu-native/src/track/buffer.rs rename : dom/webgpu/wgpu-native/src/track/mod.rs => gfx/wgpu/wgpu-native/src/track/mod.rs rename : dom/webgpu/wgpu-native/src/track/range.rs => gfx/wgpu/wgpu-native/src/track/range.rs rename : dom/webgpu/wgpu-native/src/track/texture.rs => gfx/wgpu/wgpu-native/src/track/texture.rs rename : dom/webgpu/wgpu-remote/Cargo.toml => gfx/wgpu/wgpu-remote/Cargo.toml rename : dom/webgpu/wgpu-remote/cbindgen.toml => gfx/wgpu/wgpu-remote/cbindgen.toml rename : dom/webgpu/wgpu-remote/src/lib.rs => gfx/wgpu/wgpu-remote/src/lib.rs rename : dom/webgpu/wgpu-remote/src/server.rs => gfx/wgpu/wgpu-remote/src/server.rs extra : moz-landing-system : lando --- .clang-format-ignore | 1 + .eslintignore | 1 + .hgignore | 4 +- Cargo.lock | 3 - Cargo.toml | 1 + dom/webgpu/ffi/moz.build | 2 +- dom/webgpu/wgpu-native/cbindgen.toml | 37 - gfx/wgpu/.clang-format | 5 + gfx/wgpu/.gitignore | 8 + gfx/wgpu/.travis.yml | 77 ++ gfx/wgpu/CHANGELOG.md | 87 ++ gfx/wgpu/Cargo.lock | 769 +++++++++++++ gfx/wgpu/Cargo.toml | 5 + gfx/wgpu/LICENSE | 373 ++++++ gfx/wgpu/Makefile | 76 ++ gfx/wgpu/README.md | 32 + gfx/wgpu/bors.toml | 6 + gfx/wgpu/examples/compute/CMakeLists.txt | 34 + gfx/wgpu/examples/compute/main.c | 149 +++ gfx/wgpu/examples/data/collatz.comp | 31 + gfx/wgpu/examples/data/collatz.comp.spv | Bin 0 -> 1576 bytes gfx/wgpu/examples/data/triangle.frag | 7 + gfx/wgpu/examples/data/triangle.frag.spv | Bin 0 -> 352 bytes gfx/wgpu/examples/data/triangle.vert | 15 + gfx/wgpu/examples/data/triangle.vert.spv | Bin 0 -> 904 bytes gfx/wgpu/examples/framework.c | 29 + gfx/wgpu/examples/framework.h | 15 + gfx/wgpu/examples/remote/CMakeLists.txt | 15 + gfx/wgpu/examples/remote/main.c | 58 + gfx/wgpu/examples/triangle/CMakeLists.txt | 34 + gfx/wgpu/examples/triangle/main.c | 269 +++++ gfx/wgpu/ffi/wgpu-remote.h | 126 ++ gfx/wgpu/ffi/wgpu.h | 1016 +++++++++++++++++ gfx/wgpu/rustfmt.toml | 4 + .../wgpu}/wgpu-native/Cargo.toml | 2 +- gfx/wgpu/wgpu-native/cbindgen.toml | 46 + .../wgpu}/wgpu-native/src/binding_model.rs | 0 .../wgpu-native/src/command/allocator.rs | 0 .../wgpu}/wgpu-native/src/command/bind.rs | 0 .../wgpu}/wgpu-native/src/command/compute.rs | 0 .../wgpu}/wgpu-native/src/command/mod.rs | 0 .../wgpu}/wgpu-native/src/command/render.rs | 0 .../wgpu}/wgpu-native/src/command/transfer.rs | 0 .../wgpu}/wgpu-native/src/conv.rs | 0 .../wgpu}/wgpu-native/src/device.rs | 0 .../wgpu}/wgpu-native/src/hub.rs | 0 .../webgpu => gfx/wgpu}/wgpu-native/src/id.rs | 2 + .../wgpu}/wgpu-native/src/instance.rs | 50 +- .../wgpu}/wgpu-native/src/lib.rs | 0 .../wgpu}/wgpu-native/src/pipeline.rs | 0 .../wgpu}/wgpu-native/src/resource.rs | 0 .../wgpu}/wgpu-native/src/swap_chain.rs | 15 +- .../wgpu}/wgpu-native/src/track/buffer.rs | 0 .../wgpu}/wgpu-native/src/track/mod.rs | 0 .../wgpu}/wgpu-native/src/track/range.rs | 0 .../wgpu}/wgpu-native/src/track/texture.rs | 0 .../wgpu}/wgpu-remote/Cargo.toml | 2 +- .../wgpu}/wgpu-remote/cbindgen.toml | 0 .../wgpu}/wgpu-remote/src/lib.rs | 0 .../wgpu}/wgpu-remote/src/server.rs | 19 +- toolkit/library/rust/shared/Cargo.toml | 2 +- tools/vcs/mach_commands.py | 2 +- 62 files changed, 3364 insertions(+), 65 deletions(-) delete mode 100644 dom/webgpu/wgpu-native/cbindgen.toml create mode 100644 gfx/wgpu/.clang-format create mode 100644 gfx/wgpu/.gitignore create mode 100644 gfx/wgpu/.travis.yml create mode 100644 gfx/wgpu/CHANGELOG.md create mode 100644 gfx/wgpu/Cargo.lock create mode 100644 gfx/wgpu/Cargo.toml create mode 100644 gfx/wgpu/LICENSE create mode 100644 gfx/wgpu/Makefile create mode 100644 gfx/wgpu/README.md create mode 100644 gfx/wgpu/bors.toml create mode 100644 gfx/wgpu/examples/compute/CMakeLists.txt create mode 100644 gfx/wgpu/examples/compute/main.c create mode 100644 gfx/wgpu/examples/data/collatz.comp create mode 100644 gfx/wgpu/examples/data/collatz.comp.spv create mode 100644 gfx/wgpu/examples/data/triangle.frag create mode 100644 gfx/wgpu/examples/data/triangle.frag.spv create mode 100644 gfx/wgpu/examples/data/triangle.vert create mode 100644 gfx/wgpu/examples/data/triangle.vert.spv create mode 100644 gfx/wgpu/examples/framework.c create mode 100644 gfx/wgpu/examples/framework.h create mode 100644 gfx/wgpu/examples/remote/CMakeLists.txt create mode 100644 gfx/wgpu/examples/remote/main.c create mode 100644 gfx/wgpu/examples/triangle/CMakeLists.txt create mode 100644 gfx/wgpu/examples/triangle/main.c create mode 100644 gfx/wgpu/ffi/wgpu-remote.h create mode 100644 gfx/wgpu/ffi/wgpu.h create mode 100644 gfx/wgpu/rustfmt.toml rename {dom/webgpu => gfx/wgpu}/wgpu-native/Cargo.toml (95%) create mode 100644 gfx/wgpu/wgpu-native/cbindgen.toml rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/binding_model.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/command/allocator.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/command/bind.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/command/compute.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/command/mod.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/command/render.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/command/transfer.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/conv.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/device.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/hub.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/id.rs (98%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/instance.rs (93%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/lib.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/pipeline.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/resource.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/swap_chain.rs (95%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/track/buffer.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/track/mod.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/track/range.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-native/src/track/texture.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-remote/Cargo.toml (83%) rename {dom/webgpu => gfx/wgpu}/wgpu-remote/cbindgen.toml (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-remote/src/lib.rs (100%) rename {dom/webgpu => gfx/wgpu}/wgpu-remote/src/server.rs (72%) diff --git a/.clang-format-ignore b/.clang-format-ignore index 91b1c44d230c..5e3ec2decc37 100644 --- a/.clang-format-ignore +++ b/.clang-format-ignore @@ -99,6 +99,7 @@ gfx/qcms/.* gfx/sfntly/.* gfx/skia/.* gfx/vr/service/openvr/.* +gfx/wgpu/.* gfx/wr/.* gfx/ycbcr/.* intl/hyphenation/hyphen/.* diff --git a/.eslintignore b/.eslintignore index a6d5df740ded..e894ad7938f2 100644 --- a/.eslintignore +++ b/.eslintignore @@ -183,6 +183,7 @@ editor/libeditor/tests/browserscope/ # Third-party gfx/ots/ gfx/skia/ +gfx/wgpu gfx/wr/ # intl/ exclusions diff --git a/.hgignore b/.hgignore index 609f4e52eff8..c6867a20eb5c 100644 --- a/.hgignore +++ b/.hgignore @@ -201,7 +201,9 @@ tps_result\.json # Ignore browsertime output directory ^browsertime-results -# Ignore the build directories of WebRender standalone builds. +# Ignore the build directories of WebGPU and WebRender standalone builds. +gfx/wgpu/target +gfx/wgpu/.*/build gfx/wr/target/ # Ignore this files in certviewer diff --git a/Cargo.lock b/Cargo.lock index 341d45905c47..260dff53edd1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4273,13 +4273,10 @@ dependencies = [ "gfx-backend-metal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "gfx-backend-vulkan 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "gfx-hal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-window-handle 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rendy-descriptor 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rendy-memory 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.toml b/Cargo.toml index c16e8fc3731e..3c3baf5e8cea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ exclude = [ # Excluded because these crates have their own Cargo workspaces so they can't # be included in the top-level one. + "gfx/wgpu", "gfx/wr", "media/audioipc", "media/cubeb-rs", diff --git a/dom/webgpu/ffi/moz.build b/dom/webgpu/ffi/moz.build index be631048e524..569388174eac 100644 --- a/dom/webgpu/ffi/moz.build +++ b/dom/webgpu/ffi/moz.build @@ -23,7 +23,7 @@ if CONFIG['COMPILE_ENVIRONMENT']: ffi_generated = GENERATED_FILES['wgpu_ffi_generated.h'] ffi_generated.script = '/layout/style/RunCbindgen.py:generate' ffi_generated.inputs = [ - '/dom/webgpu/wgpu-remote', + '/gfx/wgpu/wgpu-remote', ] diff --git a/dom/webgpu/wgpu-native/cbindgen.toml b/dom/webgpu/wgpu-native/cbindgen.toml deleted file mode 100644 index f111779e1e98..000000000000 --- a/dom/webgpu/wgpu-native/cbindgen.toml +++ /dev/null @@ -1,37 +0,0 @@ -header = """ -#define WGPU_LOCAL -""" -include_version = true -braces = "SameLine" -line_length = 100 -tab_width = 2 -language = "C" - -[export] -prefix = "WGPU" -#TODO: figure out why cbindgen even tries to export a private type... -exclude = ["BufferMapResult"] - -[parse] -parse_deps = false - -[parse.expand] -features = ["local"] - -[fn] - -[struct] -derive_eq = true - -[enum] -prefix_with_name = true -derive_helper_methods = true - -[macro_expansion] -bitflags = true - -[defines] -"feature = local" = "WGPU_LOCAL" -"feature = gfx-backend-gl" = "WGPU_BACKEND_GL" -"feature = winit" = "WGPU_WINIT" -"feature = glutin" = "WGPU_GLUTIN" diff --git a/gfx/wgpu/.clang-format b/gfx/wgpu/.clang-format new file mode 100644 index 000000000000..3adffa8ef5b7 --- /dev/null +++ b/gfx/wgpu/.clang-format @@ -0,0 +1,5 @@ +IndentWidth: 4 + +# Reduce left indentation for nested structs +AlignOperands: false +AlignAfterOpenBracket: DontAlign diff --git a/gfx/wgpu/.gitignore b/gfx/wgpu/.gitignore new file mode 100644 index 000000000000..f176de3dc357 --- /dev/null +++ b/gfx/wgpu/.gitignore @@ -0,0 +1,8 @@ +/target +**/*.rs.bk +#Cargo.lock +.DS_Store +.vscode +.vs +build +ffi/dawn*.h diff --git a/gfx/wgpu/.travis.yml b/gfx/wgpu/.travis.yml new file mode 100644 index 000000000000..9815f3e952f9 --- /dev/null +++ b/gfx/wgpu/.travis.yml @@ -0,0 +1,77 @@ +language: rust +sudo: false +dist: xenial + +matrix: + include: + # Linux 64bit + - os: linux + rust: stable + compiler: gcc + #TODO: unlock when libglfw3 on Ubuntu comes with Vulkan support + # or when we add a GL backend. + #- os: linux + # rust: nightly + # compiler: gcc + # Windows 64bit + - os: windows + rust: stable + - os: windows + rust: nightly + + # macOS 64bit + - env: MACOSX_DEPLOYMENT_TARGET=10.9 + os: osx + rust: stable + osx_image: xcode9.4 + compiler: clang + - env: MACOSX_DEPLOYMENT_TARGET=10.9 + os: osx + rust: nightly + osx_image: xcode9.4 + compiler: clang + + # iPhoneOS 64bit + - env: TARGET=aarch64-apple-ios + os: osx + osx_image: xcode11 + rust: stable + +addons: + apt: + packages: + - cmake + - libglfw3-dev + homebrew: + update: true + packages: + - cmake + - glfw3 + +branches: + except: + - staging.tmp + +before_install: +- if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install make; fi + +script: + - cargo test + # TODO: enable GL backend + - (cd wgpu-native && cargo check --all-features) + - if [[ $TRAVIS_OS_NAME == "osx" ]]; then (cd wgpu-native && cargo check --features gfx-backend-vulkan); fi + - if [[ $TRAVIS_OS_NAME == "linux" ]]; then cargo check --release; fi + - if [[ $TRAVIS_RUST_VERSION == "nightly" ]]; then cargo +nightly install cbindgen; fi + - if [[ $TRAVIS_RUST_VERSION == "nightly" ]] && [[ $TRAVIS_OS_NAME == "windows" ]]; then + wget -nc -O glfw.zip https://github.com/glfw/glfw/archive/3.3.zip && + 7z x glfw.zip -oglfw && + cd glfw/glfw-3.3 && + export GLFW3_INCLUDE_DIR=`pwd`/include && + export GLFW3_INSTALL_DIR=`pwd`/install && + cmake . -DCMAKE_INSTALL_PREFIX=$GLFW3_INSTALL_DIR -DCMAKE_GENERATOR_PLATFORM=x64 && + cmake --build . --target install && + cd ../.. && + export CMAKE_PREFIX_PATH=$GLFW3_INSTALL_DIR && + make example-compute example-triangle VERBOSE=1; + fi + - if [[ $TRAVIS_RUST_VERSION == "nightly" ]] && [[ $TRAVIS_OS_NAME != "windows" ]]; then make VERBOSE=1; fi diff --git a/gfx/wgpu/CHANGELOG.md b/gfx/wgpu/CHANGELOG.md new file mode 100644 index 000000000000..3c06a8aaefa1 --- /dev/null +++ b/gfx/wgpu/CHANGELOG.md @@ -0,0 +1,87 @@ +# Change Log + +## v0.4 (03-11-2019) + - Platforms: removed OpenGL/WebGL support temporarily + - Features: + - based on gfx-hal-0.4 with the new swapchain model + - exposing adapters from all available backends on a system + - tracking of samplers + - cube map support with an example + - Validation: + - buffer and texture usage + +## v0.3.3 (22-08-2019) + - fixed instance creation on Windows + +## v0.3.1 (21-08-2019) + - fixed pipeline barriers that aren't transitions + +## v0.3 (21-08-2019) + - Platforms: experimental OpenGL/WebGL + - Crates: + - Rust API is moved out to [another repository](https://github.com/gfx-rs/wgpu-rs) + - Features: + - based on gfx-hal-0.3 with help of `rendy-memory` and `rendy-descriptor` + - type-system-assisted deadlock prevention (for locking internal structures) + - texture sub-resource tracking + - `raw-window-handle` integration instead of `winit` + - multisampling with an example + - indirect draws and dispatches + - stencil masks and reference values + - native "compute" example + - everything implements `Debug` + - Validation + - vertex/index/instance ranges at draw calls + - bing groups vs their expected layouts + - bind group buffer ranges + - required stencil reference, blend color + +## v0.2.6 (04-04-2019) + - fixed frame acquisition GPU waits + +## v0.2.5 (31-03-2019) + - fixed submission tracking + - added support for blend colors + - fixed bind group compatibility at the gfx-hal level + - validating the bind groups and blend colors + +## v0.2.3 (20-03-2019) + - fixed vertex format mapping + - fixed building with "empty" backend on Windows + - bumped the default descriptor pool size + - fixed host mapping alignments + - validating the uniform buffer offset + +## v0.2 (06-03-2019) + - Platforms: iOS/Metal, D3D11 + - Crates: + - `wgpu-remote`: remoting layer for the cross-process boundary + - `gfx-examples`: selected gfx pre-ll examples ported over + - Features: + - native example for compute + - "gfx-cube" and "gfx-shadow" examples + - copies between buffers and textures + - separate object identity for the remote client + - texture view tracking + - native swapchain resize support + - buffer mapping + - object index epochs + - comprehensive list of vertex and texture formats + - validation of pipeline compatibility with the pass + - Fixes + - fixed resource destruction + +## v0.1 (24-01-2019) + - Platforms: Linux/Vulkan, Windows/Vulkan, D3D12, macOS/Metal + - Crates: + - `wgpu-native`: C API implementation of WebGPU, based on gfx-hal + - `wgpu-bindings`: auto-generated C headers + - `wgpu`: idiomatic Rust wrapper + - `examples`: native C examples + - Features: + - native examples for triangle rendering + - basic native swapchain integration + - concept of the storage hub + - basic recording of passes and command buffers + - submission-based lifetime tracking and command buffer recycling + - automatic resource transitions diff --git a/gfx/wgpu/Cargo.lock b/gfx/wgpu/Cargo.lock new file mode 100644 index 000000000000..dedc0e55646c --- /dev/null +++ b/gfx/wgpu/Cargo.lock @@ -0,0 +1,769 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "arrayvec" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ash" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atom" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "autocfg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "backtrace" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bumpalo" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "byteorder" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cc" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cfg-if" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cocoa" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", + "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "colorful" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "copyless" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "core-foundation" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "core-foundation-sys" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "core-graphics" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "d3d12" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gcc" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "gfx-auxil" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-hal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spirv_cross 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gfx-backend-dx11" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-auxil 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-hal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "range-alloc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-window-handle 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "spirv_cross 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "wio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gfx-backend-dx12" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "d3d12 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-auxil 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-hal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "range-alloc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-window-handle 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "spirv_cross 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gfx-backend-empty" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gfx-hal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-window-handle 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gfx-backend-metal" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cocoa 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", + "copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", + "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-auxil 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-hal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "metal 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", + "objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "range-alloc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-window-handle 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "spirv_cross 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "storage-map 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gfx-backend-vulkan" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ash 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-hal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-window-handle 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "gfx-hal" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-window-handle 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hibitset" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atom 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "js-sys" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "lazy_static" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.55" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libloading" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "lock_api" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "log" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "metal" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cocoa 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", + "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "objc" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "objc_exception 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "objc_exception" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pkg-config" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quote" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "range-alloc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "raw-window-handle" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.54" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "relevant" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rendy-descriptor" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gfx-hal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "relevant 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rendy-memory" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "colorful 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-hal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hibitset 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "relevant 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_derive" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "shared_library" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "smallvec" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "spirv_cross" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "storage-map" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "0.15.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wasm-bindgen" +version = "0.2.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wasm-bindgen-macro 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.48" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wgpu-native" +version = "0.4.0" +dependencies = [ + "arrayvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-backend-dx11 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-backend-dx12 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-backend-empty 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-backend-metal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-backend-vulkan 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-hal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-window-handle 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rendy-descriptor 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rendy-memory 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "wgpu-remote" +version = "0.1.0" +dependencies = [ + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wgpu-native 0.4.0", +] + +[[package]] +name = "winapi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wio" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "x11" +version = "2.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[metadata] +"checksum arrayvec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ead801bcb8843bc91ea0a028f95b786f39ce519b1738de4e74a2a393332c2a16" +"checksum ash 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)" = "003d1fb2eb12eb06d4a03dbe02eea67a9fac910fa97932ab9e3a75b96a1ea5e5" +"checksum atom 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3c86699c3f02778ec07158376991c8f783dd1f2f95c579ffaf0738dc984b2fe2" +"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" +"checksum backtrace 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "f92d5d536fa03dc3d93711d97bac1fae2eb59aba467ca4c6600c0119da614f51" +"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" +"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" +"checksum bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2cd43d82f27d68911e6ee11ee791fb248f138f5d69424dc02e098d4f152b0b05" +"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" +"checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" +"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" +"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +"checksum cocoa 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8cd20045e880893b4a8286d5639e9ade85fb1f6a14c291f882cf8cf2149d37d9" +"checksum colorful 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bca1619ff57dd7a56b58a8e25ef4199f123e78e503fe1653410350a1b98ae65" +"checksum copyless 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ff9c56c9fb2a49c05ef0e431485a22400af20d33226dc0764d891d09e724127" +"checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" +"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" +"checksum core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9" +"checksum d3d12 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc7ed48e89905e5e146bcc1951cc3facb9e44aea9adf5dc01078cda1bd24b662" +"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +"checksum gfx-auxil 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "572eee952a9a23c99cfe3e4fd95d277784058a89ac3c77ff6fa3d80a4e321919" +"checksum gfx-backend-dx11 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee975e0f4e7f42d201685d2ceed8d77f946ef35d623095cadaf8526a259584f0" +"checksum gfx-backend-dx12 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6e913cc800fb12eaba2c420091a02aca9aafbefd672600dfc5b52654343d341" +"checksum gfx-backend-empty 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d383e6bc48867cb37d298a20139fd1eec298f8f6d594690cd1c50ef25470cc7" +"checksum gfx-backend-metal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8de5c71f18ba805c95b84d6c78c472ef44485a6fc46e3b49fe1e6739c8d7b0c0" +"checksum gfx-backend-vulkan 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62538fedd66a78968a162e8e1a29d085ffbc97f8782634684b2f7da7aea59207" +"checksum gfx-hal 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "977716fea7800ab5bc9a1e048dd2f72b23af166d8c2f48c6fb6d1ce37d77ca7e" +"checksum hibitset 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "47e7292fd9f7fe89fa35c98048f2d0a69b79ed243604234d18f6f8a1aa6f408d" +"checksum js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)" = "da3ea71161651a4cd97d999b2da139109c537b15ab33abc8ae4ead38deac8a03" +"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" +"checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" +"checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" +"checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" +"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" +"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +"checksum metal 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf8052f20601c7af6293d3f7bf7b9159aee5974804fe65d871d437f933ec1eb" +"checksum objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "31d20fd2b37e07cf5125be68357b588672e8cefe9a96f8c17a9d46053b3e590d" +"checksum objc_exception 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "098cd29a2fa3c230d3463ae069cecccc3fdfd64c0d2496ab5b96f82dab6a00dc" +"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +"checksum parking_lot_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a7bbaa05312363e0480e1efee133fff1a09ef4a6406b65e226b9a793c223a32" +"checksum pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c1d2cfa5a714db3b5f24f0915e74fcdf91d09d496ba61329705dda7774d2af" +"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" +"checksum range-alloc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5927936723a9e8b715d37d7e4b390455087c4bdf25b9f702309460577b14f9" +"checksum raw-window-handle 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e815b85b31e4d397ca9dd8eb1d692e9cb458b9f6ae8ac2232c995dca8236f87" +"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" +"checksum relevant 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bbc232e13d37f4547f5b9b42a5efc380cabe5dbc1807f8b893580640b2ab0308" +"checksum rendy-descriptor 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8b39c42e01e86db7d6652733bdb5617ab620dc0a5f335a1d14c443df084c809" +"checksum rendy-memory 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "898bfc8b7522ba619b7d89aefcad1717e103a7662da2b62257b24625f9b3eba9" +"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +"checksum serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "a72e9b96fa45ce22a4bc23da3858dfccfd60acd28a25bcd328a98fdd6bea43fd" +"checksum serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "101b495b109a3e3ca8c4cbe44cf62391527cdfb6ba15821c5ce80bcd5ea23f9f" +"checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" +"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +"checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" +"checksum spirv_cross 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fbbe441b3ac8ec0ae6a4f05234239bd372a241ce15793eef694e8b24afc267bb" +"checksum storage-map 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0a4829a5c591dc24a944a736d6b1e4053e51339a79fd5d4702c4c999a9c45e" +"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" +"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +"checksum wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "4de97fa1806bb1a99904216f6ac5e0c050dc4f8c676dc98775047c38e5c01b55" +"checksum wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "5d82c170ef9f5b2c63ad4460dfcee93f3ec04a9a36a4cc20bc973c39e59ab8e3" +"checksum wasm-bindgen-macro 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f07d50f74bf7a738304f6b8157f4a581e1512cd9e9cdb5baad8c31bbe8ffd81d" +"checksum wasm-bindgen-macro-support 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "95cf8fe77e45ba5f91bc8f3da0c3aa5d464b3d8ed85d84f4d4c7cc106436b1d7" +"checksum wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "d9c2d4d4756b2e46d3a5422e06277d02e4d3e1d62d138b76a4c681e925743623" +"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum wio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" +"checksum x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39697e3123f715483d311b5826e254b6f3cfebdd83cf7ef3358f579c3d68e235" diff --git a/gfx/wgpu/Cargo.toml b/gfx/wgpu/Cargo.toml new file mode 100644 index 000000000000..f8760017e13c --- /dev/null +++ b/gfx/wgpu/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "wgpu-native", + "wgpu-remote", +] diff --git a/gfx/wgpu/LICENSE b/gfx/wgpu/LICENSE new file mode 100644 index 000000000000..a612ad9813b0 --- /dev/null +++ b/gfx/wgpu/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/gfx/wgpu/Makefile b/gfx/wgpu/Makefile new file mode 100644 index 000000000000..ed0a88493dd0 --- /dev/null +++ b/gfx/wgpu/Makefile @@ -0,0 +1,76 @@ +RUST_BACKTRACE:=1 +EXCLUDES:= + +GENERATOR_PLATFORM:= + +FFI_DIR:=ffi +BUILD_DIR:=build +CLEAN_FFI_DIR:= +CREATE_BUILD_DIR:= + +WILDCARD_WGPU_NATIVE:=$(wildcard wgpu-native/**/*.rs) +WILDCARD_WGPU_NATIVE_AND_REMOTE:=$(wildcard wgpu-native/**/*.rs wgpu-remote/**/*.rs) + +ifeq (,$(TARGET)) + CHECK_TARGET_FLAG= +else + CHECK_TARGET_FLAG=--target $(TARGET) +endif + +ifeq ($(OS),Windows_NT) + CLEAN_FFI_DIR=del $(FFI_DIR)\*.* /Q /S + CREATE_BUILD_DIR=mkdir $(BUILD_DIR) + GENERATOR_PLATFORM=-DCMAKE_GENERATOR_PLATFORM=x64 +else + CLEAN_FFI_DIR=rm $(FFI_DIR)/** + CREATE_BUILD_DIR=mkdir -p $(BUILD_DIR) +endif + +.PHONY: all check test doc clear lib-native lib-remote \ + example-compute example-triangle example-remote \ + run-example-compute run-example-triangle run-example-remote + +all: example-compute example-triangle example-remote + +check: + cargo check --all + +test: + cargo test --all + +doc: + cargo doc --all + +clear: + cargo clean + $(CLEAN_FFI_DIR) + +lib-native: Cargo.lock wgpu-native/Cargo.toml $(WILDCARD_WGPU_NATIVE) + cargo build --manifest-path wgpu-native/Cargo.toml --features local + +lib-remote: Cargo.lock wgpu-remote/Cargo.toml $(WILDCARD_WGPU_NATIVE_AND_REMOTE) + cargo build --manifest-path wgpu-remote/Cargo.toml + +$(FFI_DIR)/wgpu.h: wgpu-native/cbindgen.toml $(WILDCARD_WGPU_NATIVE) + rustup run nightly cbindgen -o $(FFI_DIR)/wgpu.h wgpu-native + +$(FFI_DIR)/wgpu-remote.h: wgpu-remote/cbindgen.toml $(WILDCARD_WGPU_NATIVE_AND_REMOTE) + rustup run nightly cbindgen -o $(FFI_DIR)/wgpu-remote.h wgpu-remote + +example-compute: lib-native $(FFI_DIR)/wgpu.h examples/compute/main.c + cd examples/compute && $(CREATE_BUILD_DIR) && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. $(GENERATOR_PLATFORM) && cmake --build . + +run-example-compute: example-compute + cd examples/compute/build && ./compute 1 2 3 4 + +example-triangle: lib-native $(FFI_DIR)/wgpu.h examples/triangle/main.c + cd examples/triangle && $(CREATE_BUILD_DIR) && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. $(GENERATOR_PLATFORM) && cmake --build . + +run-example-triangle: example-triangle + cd examples/triangle/build && ./triangle + +example-remote: lib-remote $(FFI_DIR)/wgpu-remote.h examples/remote/main.c + cd examples/remote && $(CREATE_BUILD_DIR) && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. $(GENERATOR_PLATFORM) && cmake --build . + +run-example-remote: example-remote + cd examples/remote/build && ./remote diff --git a/gfx/wgpu/README.md b/gfx/wgpu/README.md new file mode 100644 index 000000000000..9f76f65b2f16 --- /dev/null +++ b/gfx/wgpu/README.md @@ -0,0 +1,32 @@ +This is an active GitHub mirror of the WebGPU native implementation in Rust, which now lives in [Mozilla-central](https://hg.mozilla.org/mozilla-central). Issues and pull requests are accepted, but we merge them in m-c manually and then sync to GitHub instead of landing directly here. + +--- +# WebGPU +[![Build Status](https://travis-ci.org/gfx-rs/wgpu.svg)](https://travis-ci.org/gfx-rs/wgpu) +[![Crates.io](https://img.shields.io/crates/v/wgpu-native.svg?label=wgpu-native)](https://crates.io/crates/wgpu-native) +[![Gitter](https://badges.gitter.im/gfx-rs/webgpu.svg)](https://gitter.im/gfx-rs/webgpu) + +This is an experimental [WebGPU](https://www.w3.org/community/gpu/) implementation as a native static library. It's written in Rust and is based on [gfx-hal](https://github.com/gfx-rs/gfx) and [Rendy](https://github.com/amethyst/rendy) libraries. The corresponding WebIDL specification can be found at [gpuweb project](https://github.com/gpuweb/gpuweb/blob/master/spec/index.bs). + +The implementation consists of the following parts: + 1. `wgpu-native` - the native implementation of WebGPU as a C API library + 2. `wgpu-remote` - remoting layer to work with WebGPU across the process boundary + 3. `ffi` - the C headers generated by [cbindgen](https://github.com/eqrion/cbindgen) for both of the libraries + +## Supported Platforms + + API | Windows | Linux | macOS & iOS | + ----- | ------------------ | ------------------ | ------------------ | + DX11 | :heavy_check_mark: | | | + DX12 | :heavy_check_mark: | | | + Vulkan | :heavy_check_mark: | :heavy_check_mark: | | + Metal | | | :heavy_check_mark: | + OpenGL | | | | + +## Usage + +This repository contains C-language examples that link to the native library targets and perform basic rendering and computation. Please refer to our [Getting Started](https://github.com/gfx-rs/wgpu/wiki/Getting-Started#getting-started) page at the wiki for more information. + +Bindings: + - https://github.com/gfx-rs/wgpu-rs - idiomatic Rust wrapper with [a few more examples](https://github.com/gfx-rs/wgpu-rs/tree/master/examples) to get a feel of the API + - https://nest.pijul.com/porky11/wgpu - experimental [Scopes](http://scopes.rocks) wrapper diff --git a/gfx/wgpu/bors.toml b/gfx/wgpu/bors.toml new file mode 100644 index 000000000000..11903dacdb95 --- /dev/null +++ b/gfx/wgpu/bors.toml @@ -0,0 +1,6 @@ +status = [ + "continuous-integration/travis-ci/push", + #"continuous-integration/appveyor/branch" +] + +timeout_sec = 18000 # 5 hours diff --git a/gfx/wgpu/examples/compute/CMakeLists.txt b/gfx/wgpu/examples/compute/CMakeLists.txt new file mode 100644 index 000000000000..9b4c748f1514 --- /dev/null +++ b/gfx/wgpu/examples/compute/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.11b) + +project(compute) + +set(TARGET_NAME compute) + +add_executable(compute main.c ../framework.c) + +if(MSVC) + add_definitions(-DWGPU_TARGET=WGPU_TARGET_WINDOWS) + target_compile_options(${TARGET_NAME} PRIVATE /W4) + set(OS_LIBRARIES "userenv" "ws2_32" "Dwmapi" "dbghelp" "d3dcompiler" "D3D12" "D3D11" "DXGI") +elseif(APPLE) + add_definitions(-DWGPU_TARGET=WGPU_TARGET_MACOS) + set(OS_LIBRARIES "-framework Cocoa" "-framework CoreVideo" "-framework IOKit" "-framework QuartzCore") + target_compile_options(${TARGET_NAME} PRIVATE -x objective-c) +else(MSVC) + add_definitions(-DWGPU_TARGET=WGPU_TARGET_LINUX) + target_compile_options(${TARGET_NAME} PRIVATE -Wall -Wextra -pedantic) +endif(MSVC) + +find_package(glfw3 3.3 REQUIRED + HINTS "$ENV{GLFW3_INSTALL_DIR}" +) + +find_library(WGPU_LIBRARY wgpu_native + HINTS "${CMAKE_CURRENT_SOURCE_DIR}/../../target/debug" +) + +target_include_directories(${TARGET_NAME} PUBLIC $ENV{GLFW3_INCLUDE_DIR}) +target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../ffi) +target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) + +target_link_libraries(${TARGET_NAME} glfw ${WGPU_LIBRARY} ${OS_LIBRARIES}) diff --git a/gfx/wgpu/examples/compute/main.c b/gfx/wgpu/examples/compute/main.c new file mode 100644 index 000000000000..5f6bfc665bdc --- /dev/null +++ b/gfx/wgpu/examples/compute/main.c @@ -0,0 +1,149 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef WGPU_H +#define WGPU_H +#include "wgpu.h" +#endif + +#include "framework.h" + +#include +#include +#include + +#define BINDINGS_LENGTH (1) +#define BIND_GROUP_LAYOUTS_LENGTH (1) + +void request_adapter_callback(WGPUAdapterId const *received, void *userdata) { + WGPUAdapterId *id = (WGPUAdapterId*) userdata; + *id = *received; +} + +void read_buffer_map( + WGPUBufferMapAsyncStatus status, + const uint8_t *data, + uint8_t *userdata) { + (void)userdata; + if (status == WGPUBufferMapAsyncStatus_Success) { + uint32_t *times = (uint32_t *) data; + printf("Times: [%d, %d, %d, %d]\n", + times[0], + times[1], + times[2], + times[3]); + } +} + +int main( + int argc, + char *argv[]) { + + if (argc != 5) { + printf("You must pass 4 positive integers!\n"); + return 0; + } + + uint32_t numbers[] = { + strtoul(argv[1], NULL, 0), + strtoul(argv[2], NULL, 0), + strtoul(argv[3], NULL, 0), + strtoul(argv[4], NULL, 0), + }; + + uint32_t size = sizeof(numbers); + + uint32_t numbers_length = size / sizeof(uint32_t); + + WGPUAdapterId adapter = { 0 }; + wgpu_request_adapter_async( + NULL, + request_adapter_callback, + (void *) &adapter + ); + + WGPUDeviceId device = wgpu_adapter_request_device(adapter, NULL); + + uint8_t *staging_memory; + + WGPUBufferId buffer = wgpu_device_create_buffer_mapped(device, + &(WGPUBufferDescriptor){ + .size = size, + .usage = WGPUBufferUsage_STORAGE | WGPUBufferUsage_MAP_READ}, + &staging_memory); + + memcpy((uint32_t *) staging_memory, numbers, size); + + wgpu_buffer_unmap(buffer); + + WGPUBindGroupLayoutId bind_group_layout = + wgpu_device_create_bind_group_layout(device, + &(WGPUBindGroupLayoutDescriptor){ + .bindings = &(WGPUBindGroupLayoutBinding){ + .binding = 0, + .visibility = WGPUShaderStage_COMPUTE, + .ty = WGPUBindingType_StorageBuffer}, + .bindings_length = BINDINGS_LENGTH}); + + WGPUBindingResource resource = { + .tag = WGPUBindingResource_Buffer, + .buffer = {(WGPUBufferBinding){ + .buffer = buffer, + .size = size, + .offset = 0}}}; + + WGPUBindGroupId bind_group = wgpu_device_create_bind_group(device, + &(WGPUBindGroupDescriptor){.layout = bind_group_layout, + .bindings = &(WGPUBindGroupBinding){ + .binding = 0, + .resource = resource}, + .bindings_length = BINDINGS_LENGTH}); + + WGPUBindGroupLayoutId bind_group_layouts[BIND_GROUP_LAYOUTS_LENGTH] = { + bind_group_layout}; + + WGPUPipelineLayoutId pipeline_layout = + wgpu_device_create_pipeline_layout(device, + &(WGPUPipelineLayoutDescriptor){ + .bind_group_layouts = bind_group_layouts, + .bind_group_layouts_length = BIND_GROUP_LAYOUTS_LENGTH}); + + WGPUShaderModuleId shader_module = wgpu_device_create_shader_module(device, + &(WGPUShaderModuleDescriptor){ + .code = read_file("./../../data/collatz.comp.spv")}); + + WGPUComputePipelineId compute_pipeline = + wgpu_device_create_compute_pipeline(device, + &(WGPUComputePipelineDescriptor){ + .layout = pipeline_layout, + .compute_stage = (WGPUProgrammableStageDescriptor){ + .module = shader_module, + .entry_point = "main" + }}); + + WGPUCommandEncoderId encoder = wgpu_device_create_command_encoder( + device, &(WGPUCommandEncoderDescriptor){ + .todo = 0 + }); + + WGPUComputePassId command_pass = + wgpu_command_encoder_begin_compute_pass(encoder, NULL); + wgpu_compute_pass_set_pipeline(command_pass, compute_pipeline); + + wgpu_compute_pass_set_bind_group(command_pass, 0, bind_group, NULL, 0); + wgpu_compute_pass_dispatch(command_pass, numbers_length, 1, 1); + wgpu_compute_pass_end_pass(command_pass); + + WGPUQueueId queue = wgpu_device_get_queue(device); + + WGPUCommandBufferId command_buffer = wgpu_command_encoder_finish(encoder, NULL); + + wgpu_queue_submit(queue, &command_buffer, 1); + + wgpu_buffer_map_read_async(buffer, 0, size, read_buffer_map, NULL); + + wgpu_device_poll(device, true); + + return 0; +} diff --git a/gfx/wgpu/examples/data/collatz.comp b/gfx/wgpu/examples/data/collatz.comp new file mode 100644 index 000000000000..d1ab4cfd2e3f --- /dev/null +++ b/gfx/wgpu/examples/data/collatz.comp @@ -0,0 +1,31 @@ +#version 450 +layout(local_size_x = 1) in; + +layout(set = 0, binding = 0) buffer PrimeIndices { + uint[] indices; +}; // this is used as both input and output for convenience + +// The Collatz Conjecture states that for any integer n: +// If n is even, n = n/2 +// If n is odd, n = 3n+1 +// And repeat this process for each new n, you will always eventually reach 1. +// Though the conjecture has not been proven, no counterexample has ever been found. +// This function returns how many times this recurrence needs to be applied to reach 1. +uint collatz_iterations(uint n) { + uint i = 0; + while(n != 1) { + if (mod(n, 2) == 0) { + n = n / 2; + } + else { + n = (3 * n) + 1; + } + i++; + } + return i; +} + +void main() { + uint index = gl_GlobalInvocationID.x; + indices[index] = collatz_iterations(indices[index]); +} \ No newline at end of file diff --git a/gfx/wgpu/examples/data/collatz.comp.spv b/gfx/wgpu/examples/data/collatz.comp.spv new file mode 100644 index 0000000000000000000000000000000000000000..972544e0f9087b83fd9fb907d1c896aecf817a1d GIT binary patch literal 1576 zcmYk6*-leY6o$8yQItU@C$I$v6oaCSA_!_yNw_fa0Z4_$G$}2CYK&K281H-%Z+!wE z$|=$KeWzz7>||yAYx?)v>#VlWG1HUMnbebd)3ek*!>I#LO8u!j)8*Y)yYnZlgZag! z`(_NJLY8RGAUR#=PUNssYZ!Qd4B^)|jF=Zvptb}1JB}_gPS-zHp!zy1Cmu{D!a#hjGPd(S}#x3-vFEQDX+f?_IIQIWA3{J*6-VcQ{QP$xr1{S?EIsC4y@1LTYMXR Y*83goNv$2<%DD#LU9f!rh>P8g|6_G!ZvX%Q literal 0 HcmV?d00001 diff --git a/gfx/wgpu/examples/data/triangle.frag b/gfx/wgpu/examples/data/triangle.frag new file mode 100644 index 000000000000..74e14f410e36 --- /dev/null +++ b/gfx/wgpu/examples/data/triangle.frag @@ -0,0 +1,7 @@ +#version 450 + +layout(location = 0) out vec4 outColor; + +void main() { + outColor = vec4(1.0, 0.0, 0.0, 1.0); +} diff --git a/gfx/wgpu/examples/data/triangle.frag.spv b/gfx/wgpu/examples/data/triangle.frag.spv new file mode 100644 index 0000000000000000000000000000000000000000..59e491519bc95272ee281f0c70f2f758e7f55974 GIT binary patch literal 352 zcmYk2yJ`Yq6og0D^=?!I?PSGL5epLnf)*Awc6ow;ji4?hYwxr9R5pU&{3>{0_MDl2 z&V`Ng!;+L!No6(kh_>=5QccB>*PEZsrPesC^-YKl-R>WRNeXqBx`>v59)9mJ_w0mknd~dA z&!5~gt&QOJR)KV0zIZKgX-t><>cAfBhU+ix^)24x@VqNZOkTje!+kgY+&8!b;(Zb8 literal 0 HcmV?d00001 diff --git a/gfx/wgpu/examples/data/triangle.vert b/gfx/wgpu/examples/data/triangle.vert new file mode 100644 index 000000000000..ac6dcc7c3245 --- /dev/null +++ b/gfx/wgpu/examples/data/triangle.vert @@ -0,0 +1,15 @@ +#version 450 + +out gl_PerVertex { + vec4 gl_Position; +}; + +const vec2 positions[3] = vec2[3]( + vec2(0.0, -0.5), + vec2(0.5, 0.5), + vec2(-0.5, 0.5) +); + +void main() { + gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0); +} diff --git a/gfx/wgpu/examples/data/triangle.vert.spv b/gfx/wgpu/examples/data/triangle.vert.spv new file mode 100644 index 0000000000000000000000000000000000000000..9a3f5994b71471f4f282bdb2299e70ce2ebd9d62 GIT binary patch literal 904 zcmYk4OD}^_5QdLdTa;4wyN_alhy@}M8mp365Q(i++DH@Hgf1-oGl^eiBk?@nMV#i% z%)Il?oH^4kpR1KZ7zm{>6t+Whsv!pxLOB#;+qk~F-hb=2_79H^R8&Gf7OEMi(lZEN znw_rx2v`7lemU$H!UBr_ngYFt$UQwj+_Ycs+pqohJ0Wbs>znJnb^4uNm->9%SKeCt zlTQk-x-F{<{FdQ6hRw(4HvT1?_jt;Q2@QJ5Ia`CN>}75TOu@>p$I~a8S^Oeg1m@8D zVq@R4n)Z^5V1}`7$Nr~j>^|gXh`lEQtR(EF@hHB>-eXvMJA?WPHUb{?#^b<#%fu5{ zYvjyZTLqpho=n2eJ$9jX3aF9KG}HK;dZw8nkP{gUl{9v?Y@P@|gpa!UO+4Rg%`tCqH}2je{|!^XdY8TZ2GpJrJHsOI z{&UpkocV$Z?_C9QYScT!8j!z5<386@4)e!tq?~WM;WqE90k!7bZv?!@`L}@If&aC0 L7_0wbD<|L=@_;WL literal 0 HcmV?d00001 diff --git a/gfx/wgpu/examples/framework.c b/gfx/wgpu/examples/framework.c new file mode 100644 index 000000000000..cc3976ccc061 --- /dev/null +++ b/gfx/wgpu/examples/framework.c @@ -0,0 +1,29 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef WGPU_H +#define WGPU_H +#include "wgpu.h" +#endif + +#include +#include + +WGPUU32Array read_file(const char *name) { + FILE *file = fopen(name, "rb"); + if (!file) { + printf("Unable to open %s\n", name); + exit(1); + } + fseek(file, 0, SEEK_END); + long length = ftell(file); + unsigned char *bytes = malloc(length); + fseek(file, 0, SEEK_SET); + fread(bytes, 1, length, file); + fclose(file); + return (WGPUU32Array){ + .bytes = (uint32_t*) bytes, + .length = length / 4, + }; +} diff --git a/gfx/wgpu/examples/framework.h b/gfx/wgpu/examples/framework.h new file mode 100644 index 000000000000..106610c8e292 --- /dev/null +++ b/gfx/wgpu/examples/framework.h @@ -0,0 +1,15 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef WGPU_H +#define WGPU_H +#include "wgpu.h" +#endif + +WGPUU32Array read_file(const char *name); + +void read_buffer_map( + WGPUBufferMapAsyncStatus status, + const uint8_t *data, + uint8_t *userdata); diff --git a/gfx/wgpu/examples/remote/CMakeLists.txt b/gfx/wgpu/examples/remote/CMakeLists.txt new file mode 100644 index 000000000000..39c57a043a3c --- /dev/null +++ b/gfx/wgpu/examples/remote/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.11b) + +project(remote) + +set(TARGET_NAME remote) + +add_executable(remote main.c) + +find_package(glfw3) + +find_library(WGPU_LIBRARY wgpu_remote + HINTS "${CMAKE_CURRENT_SOURCE_DIR}/../../target/debug" +) + +target_link_libraries(${TARGET_NAME} ${WGPU_LIBRARY}) diff --git a/gfx/wgpu/examples/remote/main.c b/gfx/wgpu/examples/remote/main.c new file mode 100644 index 000000000000..22c6f4e7349f --- /dev/null +++ b/gfx/wgpu/examples/remote/main.c @@ -0,0 +1,58 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#define WGPU_INLINE +#define WGPU_FUNC + +#include "./../../ffi/wgpu-remote.h" +#include + +int main() { + WGPUInfrastructure infra = wgpu_client_new(); + WGPUClient *client = infra.client; + + if (!client || infra.error) { + printf("Cannot initialize WGPU client: %s\n", infra.error); + return 1; + } + + WGPUGlobal* server = wgpu_server_new(); + + if (!server) { + printf("Cannot initialize WGPU client: %s\n", server); + return 1; + } + + WGPUAdapterId adapterId = 0; + { + WGPUAdapterId ids[10]; + int count = wgpu_client_make_adapter_ids(client, ids, 10); + + WGPURequestAdapterOptions options = { + .power_preference = WGPUPowerPreference_LowPower, + .backends = 2 | 4 | 8, + }; + char index = wgpu_server_instance_request_adapter(server, &options, ids, count); + if (index < 0) { + printf("No available GPU adapters!\n"); + return 2; + } + + wgpu_client_kill_adapter_ids(client, ids, index); + wgpu_client_kill_adapter_ids(client, ids+index+1, count-index-1); + adapterId = ids[index]; + } + + //TODO: do something meaningful + + if (adapterId) { + //wgpu_server_destroy_adapter() + wgpu_client_kill_adapter_ids(client, &adapterId, 1); + } + wgpu_server_delete(server); + wgpu_client_delete(client); + + printf("Done\n"); + return 0; +} diff --git a/gfx/wgpu/examples/triangle/CMakeLists.txt b/gfx/wgpu/examples/triangle/CMakeLists.txt new file mode 100644 index 000000000000..e02d478a5904 --- /dev/null +++ b/gfx/wgpu/examples/triangle/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.11b) + +project(triangle) + +set(TARGET_NAME triangle) + +add_executable(triangle main.c ../framework.c) + +if(MSVC) + add_definitions(-DWGPU_TARGET=WGPU_TARGET_WINDOWS) + target_compile_options(${TARGET_NAME} PRIVATE /W4) + set(OS_LIBRARIES "userenv" "ws2_32" "Dwmapi" "dbghelp" "d3dcompiler" "D3D12" "D3D11" "DXGI") +elseif(APPLE) + add_definitions(-DWGPU_TARGET=WGPU_TARGET_MACOS) + set(OS_LIBRARIES "-framework Cocoa" "-framework CoreVideo" "-framework IOKit" "-framework QuartzCore") + target_compile_options(${TARGET_NAME} PRIVATE -x objective-c) +else(MSVC) + add_definitions(-DWGPU_TARGET=WGPU_TARGET_LINUX) + target_compile_options(${TARGET_NAME} PRIVATE -Wall -Wextra -pedantic) +endif(MSVC) + +find_package(glfw3 3.3 REQUIRED + HINTS "$ENV{GLFW3_INSTALL_DIR}" +) + +find_library(WGPU_LIBRARY wgpu_native + HINTS "${CMAKE_CURRENT_SOURCE_DIR}/../../target/debug" +) + +target_include_directories(${TARGET_NAME} PUBLIC $ENV{GLFW3_INCLUDE_DIR}) +target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../ffi) +target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) + +target_link_libraries(${TARGET_NAME} glfw ${WGPU_LIBRARY} ${OS_LIBRARIES}) diff --git a/gfx/wgpu/examples/triangle/main.c b/gfx/wgpu/examples/triangle/main.c new file mode 100644 index 000000000000..8d18af2bf742 --- /dev/null +++ b/gfx/wgpu/examples/triangle/main.c @@ -0,0 +1,269 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef WGPU_H +#define WGPU_H +#include "wgpu.h" +#endif + +#include "framework.h" +#include +#include + +#define WGPU_TARGET_MACOS 1 +#define WGPU_TARGET_LINUX 2 +#define WGPU_TARGET_WINDOWS 3 + +#if WGPU_TARGET == WGPU_TARGET_MACOS +#include +#include +#endif + +#include +#if WGPU_TARGET == WGPU_TARGET_MACOS +#define GLFW_EXPOSE_NATIVE_COCOA +#elif WGPU_TARGET == WGPU_TARGET_LINUX +#define GLFW_EXPOSE_NATIVE_X11 +#define GLFW_EXPOSE_NATIVE_WAYLAND +#elif WGPU_TARGET == WGPU_TARGET_WINDOWS +#define GLFW_EXPOSE_NATIVE_WIN32 +#endif +#include + +#define BLEND_STATES_LENGTH (1) +#define ATTACHMENTS_LENGTH (1) +#define RENDER_PASS_ATTACHMENTS_LENGTH (1) +#define BIND_GROUP_LAYOUTS_LENGTH (1) + +void request_adapter_callback(WGPUAdapterId const *received, void *userdata) { + WGPUAdapterId *id = (WGPUAdapterId*) userdata; + *id = *received; +} + +int main() { + WGPUAdapterId adapter = { 0 }; + wgpu_request_adapter_async( + &(WGPURequestAdapterOptions){ + .power_preference = WGPUPowerPreference_LowPower, + .backends = 2 | 4 | 8, + }, + request_adapter_callback, + (void *) &adapter + ); + + WGPUDeviceId device = wgpu_adapter_request_device(adapter, + &(WGPUDeviceDescriptor){ + .extensions = + { + .anisotropic_filtering = false, + }, + .limits = + { + .max_bind_groups = 1, + }, + }); + + WGPUShaderModuleId vertex_shader = wgpu_device_create_shader_module(device, + &(WGPUShaderModuleDescriptor){ + .code = read_file("./../../data/triangle.vert.spv"), + }); + + WGPUShaderModuleId fragment_shader = + wgpu_device_create_shader_module(device, + &(WGPUShaderModuleDescriptor){ + .code = read_file("./../../data/triangle.frag.spv"), + }); + + WGPUBindGroupLayoutId bind_group_layout = + wgpu_device_create_bind_group_layout(device, + &(WGPUBindGroupLayoutDescriptor){ + .bindings = NULL, + .bindings_length = 0, + }); + WGPUBindGroupId bind_group = + wgpu_device_create_bind_group(device, + &(WGPUBindGroupDescriptor){ + .layout = bind_group_layout, + .bindings = NULL, + .bindings_length = 0, + }); + + WGPUBindGroupLayoutId bind_group_layouts[BIND_GROUP_LAYOUTS_LENGTH] = { + bind_group_layout}; + + WGPUPipelineLayoutId pipeline_layout = + wgpu_device_create_pipeline_layout(device, + &(WGPUPipelineLayoutDescriptor){ + .bind_group_layouts = bind_group_layouts, + .bind_group_layouts_length = BIND_GROUP_LAYOUTS_LENGTH, + }); + + WGPURenderPipelineId render_pipeline = + wgpu_device_create_render_pipeline(device, + &(WGPURenderPipelineDescriptor){ + .layout = pipeline_layout, + .vertex_stage = + (WGPUProgrammableStageDescriptor){ + .module = vertex_shader, + .entry_point = "main", + }, + .fragment_stage = + &(WGPUProgrammableStageDescriptor){ + .module = fragment_shader, + .entry_point = "main", + }, + .rasterization_state = + &(WGPURasterizationStateDescriptor){ + .front_face = WGPUFrontFace_Ccw, + .cull_mode = WGPUCullMode_None, + .depth_bias = 0, + .depth_bias_slope_scale = 0.0, + .depth_bias_clamp = 0.0, + }, + .primitive_topology = WGPUPrimitiveTopology_TriangleList, + .color_states = + &(WGPUColorStateDescriptor){ + .format = WGPUTextureFormat_Bgra8Unorm, + .alpha_blend = + (WGPUBlendDescriptor){ + .src_factor = WGPUBlendFactor_One, + .dst_factor = WGPUBlendFactor_Zero, + .operation = WGPUBlendOperation_Add, + }, + .color_blend = + (WGPUBlendDescriptor){ + .src_factor = WGPUBlendFactor_One, + .dst_factor = WGPUBlendFactor_Zero, + .operation = WGPUBlendOperation_Add, + }, + .write_mask = WGPUColorWrite_ALL, + }, + .color_states_length = 1, + .depth_stencil_state = NULL, + .vertex_input = + (WGPUVertexInputDescriptor){ + .index_format = WGPUIndexFormat_Uint16, + .vertex_buffers = NULL, + .vertex_buffers_length = 0, + }, + .sample_count = 1, + }); + + if (!glfwInit()) { + printf("Cannot initialize glfw"); + return 1; + } + + glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); + GLFWwindow *window = + glfwCreateWindow(640, 480, "wgpu with glfw", NULL, NULL); + + if (!window) { + printf("Cannot create window"); + return 1; + } + + WGPUSurfaceId surface; + +#if WGPU_TARGET == WGPU_TARGET_MACOS + { + id metal_layer = NULL; + NSWindow *ns_window = glfwGetCocoaWindow(window); + [ns_window.contentView setWantsLayer:YES]; + metal_layer = [CAMetalLayer layer]; + [ns_window.contentView setLayer:metal_layer]; + surface = wgpu_create_surface_from_metal_layer(metal_layer); + } +#elif WGPU_TARGET == WGPU_TARGET_LINUX + { + Display *x11_display = glfwGetX11Display(); + Window x11_window = glfwGetX11Window(window); + surface = wgpu_create_surface_from_xlib((const void **)x11_display, x11_window); + } +#elif WGPU_TARGET == WGPU_TARGET_WINDOWS + { + HWND hwnd = glfwGetWin32Window(window); + HINSTANCE hinstance = GetModuleHandle(NULL); + surface = wgpu_create_surface_from_windows_hwnd(hinstance, hwnd); + } +#else + #error "Unsupported WGPU_TARGET" +#endif + + int prev_width = 0; + int prev_height = 0; + glfwGetWindowSize(window, &prev_width, &prev_height); + + WGPUSwapChainId swap_chain = wgpu_device_create_swap_chain(device, surface, + &(WGPUSwapChainDescriptor){ + .usage = WGPUTextureUsage_OUTPUT_ATTACHMENT, + .format = WGPUTextureFormat_Bgra8Unorm, + .width = prev_width, + .height = prev_height, + .present_mode = WGPUPresentMode_Vsync, + }); + + while (!glfwWindowShouldClose(window)) { + int width = 0; + int height = 0; + glfwGetWindowSize(window, &width, &height); + if (width != prev_width || height != prev_height) { + prev_width = width; + prev_height = height; + + swap_chain = wgpu_device_create_swap_chain(device, surface, + &(WGPUSwapChainDescriptor){ + .usage = WGPUTextureUsage_OUTPUT_ATTACHMENT, + .format = WGPUTextureFormat_Bgra8Unorm, + .width = width, + .height = height, + .present_mode = WGPUPresentMode_Vsync, + }); + } + + WGPUSwapChainOutput next_texture = + wgpu_swap_chain_get_next_texture(swap_chain); + if (!next_texture.view_id) { + printf("Cannot acquire next swap chain texture"); + return 1; + } + + WGPUCommandEncoderId cmd_encoder = wgpu_device_create_command_encoder( + device, &(WGPUCommandEncoderDescriptor){.todo = 0}); + + WGPURenderPassColorAttachmentDescriptor + color_attachments[ATTACHMENTS_LENGTH] = { + { + .attachment = next_texture.view_id, + .load_op = WGPULoadOp_Clear, + .store_op = WGPUStoreOp_Store, + .clear_color = WGPUColor_GREEN, + }, + }; + + WGPURenderPassId rpass = + wgpu_command_encoder_begin_render_pass(cmd_encoder, + &(WGPURenderPassDescriptor){ + .color_attachments = color_attachments, + .color_attachments_length = RENDER_PASS_ATTACHMENTS_LENGTH, + .depth_stencil_attachment = NULL, + }); + + wgpu_render_pass_set_pipeline(rpass, render_pipeline); + wgpu_render_pass_set_bind_group(rpass, 0, bind_group, NULL, 0); + wgpu_render_pass_draw(rpass, 3, 1, 0, 0); + WGPUQueueId queue = wgpu_device_get_queue(device); + wgpu_render_pass_end_pass(rpass); + WGPUCommandBufferId cmd_buf = wgpu_command_encoder_finish(cmd_encoder, NULL); + wgpu_queue_submit(queue, &cmd_buf, 1); + wgpu_swap_chain_present(swap_chain); + + glfwPollEvents(); + } + + glfwDestroyWindow(window); + glfwTerminate(); + + return 0; +} diff --git a/gfx/wgpu/ffi/wgpu-remote.h b/gfx/wgpu/ffi/wgpu-remote.h new file mode 100644 index 000000000000..59cae1103357 --- /dev/null +++ b/gfx/wgpu/ffi/wgpu-remote.h @@ -0,0 +1,126 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Generated with cbindgen:0.9.1 */ + +/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen. + * To generate this file: + * 1. Get the latest cbindgen using `cargo install --force cbindgen` + * a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release + * 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate wgpu-remote -o dom/webgpu/ffi/wgpu_ffi_generated.h` + */ + +typedef void WGPUEmpty; + + +#include +#include +#include +#include + +typedef enum { + WGPUPowerPreference_Default = 0, + WGPUPowerPreference_LowPower = 1, + WGPUPowerPreference_HighPerformance = 2, +} WGPUPowerPreference; + +typedef struct WGPUClient WGPUClient; + +typedef struct WGPUGlobal WGPUGlobal; + +typedef uint64_t WGPUId_Adapter_Dummy; + +typedef WGPUId_Adapter_Dummy WGPUAdapterId; + +typedef uint64_t WGPUId_Device_Dummy; + +typedef WGPUId_Device_Dummy WGPUDeviceId; + +typedef struct { + WGPUClient *client; + const uint8_t *error; +} WGPUInfrastructure; + +typedef struct { + bool anisotropic_filtering; +} WGPUExtensions; + +typedef struct { + uint32_t max_bind_groups; +} WGPULimits; + +typedef struct { + WGPUExtensions extensions; + WGPULimits limits; +} WGPUDeviceDescriptor; + +typedef uint32_t WGPUBackendBit; + +typedef struct { + WGPUPowerPreference power_preference; + WGPUBackendBit backends; +} WGPURequestAdapterOptions; + +WGPU_INLINE +void wgpu_client_delete(WGPUClient *aClient) +WGPU_FUNC; + +WGPU_INLINE +void wgpu_client_kill_adapter_ids(const WGPUClient *aClient, + const WGPUAdapterId *aIds, + uintptr_t aIdLength) +WGPU_FUNC; + +WGPU_INLINE +void wgpu_client_kill_device_id(const WGPUClient *aClient, + WGPUDeviceId aId) +WGPU_FUNC; + +WGPU_INLINE +uintptr_t wgpu_client_make_adapter_ids(const WGPUClient *aClient, + WGPUAdapterId *aIds, + uintptr_t aIdLength) +WGPU_FUNC; + +WGPU_INLINE +WGPUDeviceId wgpu_client_make_device_id(const WGPUClient *aClient, + WGPUAdapterId aAdapterId) +WGPU_FUNC; + +WGPU_INLINE +WGPUInfrastructure wgpu_client_new(void) +WGPU_FUNC; + +WGPU_INLINE +void wgpu_server_adapter_request_device(const WGPUGlobal *aGlobal, + WGPUAdapterId aSelfId, + const WGPUDeviceDescriptor *aDesc, + WGPUDeviceId aNewId) +WGPU_FUNC; + +WGPU_INLINE +void wgpu_server_delete(WGPUGlobal *aGlobal) +WGPU_FUNC; + +WGPU_INLINE +void wgpu_server_device_destroy(const WGPUGlobal *aGlobal, + WGPUDeviceId aSelfId) +WGPU_FUNC; + +/** + * Request an adapter according to the specified options. + * Provide the list of IDs to pick from. + * + * Returns the index in this list, or -1 if unable to pick. + */ +WGPU_INLINE +int8_t wgpu_server_instance_request_adapter(const WGPUGlobal *aGlobal, + const WGPURequestAdapterOptions *aDesc, + const WGPUAdapterId *aIds, + uintptr_t aIdLength) +WGPU_FUNC; + +WGPU_INLINE +WGPUGlobal *wgpu_server_new(void) +WGPU_FUNC; diff --git a/gfx/wgpu/ffi/wgpu.h b/gfx/wgpu/ffi/wgpu.h new file mode 100644 index 000000000000..2b9ad562595b --- /dev/null +++ b/gfx/wgpu/ffi/wgpu.h @@ -0,0 +1,1016 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* Generated with cbindgen:0.9.1 */ + +/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen. + * To generate this file: + * 1. Get the latest cbindgen using `cargo install --force cbindgen` + * a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release + * 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate wgpu-remote -o dom/webgpu/ffi/wgpu_ffi_generated.h` + */ + +#define WGPU_LOCAL + + +#include +#include +#include +#include + +#define WGPUDEFAULT_BIND_GROUPS 4 + +#define WGPUDESIRED_NUM_FRAMES 3 + +#define WGPUMAX_BIND_GROUPS 4 + +#define WGPUMAX_COLOR_TARGETS 4 + +#define WGPUMAX_MIP_LEVELS 16 + +#define WGPUMAX_VERTEX_BUFFERS 8 + +typedef enum { + WGPUAddressMode_ClampToEdge = 0, + WGPUAddressMode_Repeat = 1, + WGPUAddressMode_MirrorRepeat = 2, +} WGPUAddressMode; + +typedef enum { + WGPUBindingType_UniformBuffer = 0, + WGPUBindingType_StorageBuffer = 1, + WGPUBindingType_ReadonlyStorageBuffer = 2, + WGPUBindingType_Sampler = 3, + WGPUBindingType_SampledTexture = 4, + WGPUBindingType_StorageTexture = 5, +} WGPUBindingType; + +typedef enum { + WGPUBlendFactor_Zero = 0, + WGPUBlendFactor_One = 1, + WGPUBlendFactor_SrcColor = 2, + WGPUBlendFactor_OneMinusSrcColor = 3, + WGPUBlendFactor_SrcAlpha = 4, + WGPUBlendFactor_OneMinusSrcAlpha = 5, + WGPUBlendFactor_DstColor = 6, + WGPUBlendFactor_OneMinusDstColor = 7, + WGPUBlendFactor_DstAlpha = 8, + WGPUBlendFactor_OneMinusDstAlpha = 9, + WGPUBlendFactor_SrcAlphaSaturated = 10, + WGPUBlendFactor_BlendColor = 11, + WGPUBlendFactor_OneMinusBlendColor = 12, +} WGPUBlendFactor; + +typedef enum { + WGPUBlendOperation_Add = 0, + WGPUBlendOperation_Subtract = 1, + WGPUBlendOperation_ReverseSubtract = 2, + WGPUBlendOperation_Min = 3, + WGPUBlendOperation_Max = 4, +} WGPUBlendOperation; + +typedef enum { + WGPUBufferMapAsyncStatus_Success, + WGPUBufferMapAsyncStatus_Error, + WGPUBufferMapAsyncStatus_Unknown, + WGPUBufferMapAsyncStatus_ContextLost, +} WGPUBufferMapAsyncStatus; + +typedef enum { + WGPUCompareFunction_Never = 0, + WGPUCompareFunction_Less = 1, + WGPUCompareFunction_Equal = 2, + WGPUCompareFunction_LessEqual = 3, + WGPUCompareFunction_Greater = 4, + WGPUCompareFunction_NotEqual = 5, + WGPUCompareFunction_GreaterEqual = 6, + WGPUCompareFunction_Always = 7, +} WGPUCompareFunction; + +typedef enum { + WGPUCullMode_None = 0, + WGPUCullMode_Front = 1, + WGPUCullMode_Back = 2, +} WGPUCullMode; + +typedef enum { + WGPUFilterMode_Nearest = 0, + WGPUFilterMode_Linear = 1, +} WGPUFilterMode; + +typedef enum { + WGPUFrontFace_Ccw = 0, + WGPUFrontFace_Cw = 1, +} WGPUFrontFace; + +typedef enum { + WGPUIndexFormat_Uint16 = 0, + WGPUIndexFormat_Uint32 = 1, +} WGPUIndexFormat; + +typedef enum { + WGPUInputStepMode_Vertex = 0, + WGPUInputStepMode_Instance = 1, +} WGPUInputStepMode; + +typedef enum { + WGPULoadOp_Clear = 0, + WGPULoadOp_Load = 1, +} WGPULoadOp; + +typedef enum { + WGPUPowerPreference_Default = 0, + WGPUPowerPreference_LowPower = 1, + WGPUPowerPreference_HighPerformance = 2, +} WGPUPowerPreference; + +typedef enum { + WGPUPresentMode_NoVsync = 0, + WGPUPresentMode_Vsync = 1, +} WGPUPresentMode; + +typedef enum { + WGPUPrimitiveTopology_PointList = 0, + WGPUPrimitiveTopology_LineList = 1, + WGPUPrimitiveTopology_LineStrip = 2, + WGPUPrimitiveTopology_TriangleList = 3, + WGPUPrimitiveTopology_TriangleStrip = 4, +} WGPUPrimitiveTopology; + +typedef enum { + WGPUStencilOperation_Keep = 0, + WGPUStencilOperation_Zero = 1, + WGPUStencilOperation_Replace = 2, + WGPUStencilOperation_Invert = 3, + WGPUStencilOperation_IncrementClamp = 4, + WGPUStencilOperation_DecrementClamp = 5, + WGPUStencilOperation_IncrementWrap = 6, + WGPUStencilOperation_DecrementWrap = 7, +} WGPUStencilOperation; + +typedef enum { + WGPUStoreOp_Clear = 0, + WGPUStoreOp_Store = 1, +} WGPUStoreOp; + +typedef enum { + WGPUTextureAspect_All, + WGPUTextureAspect_StencilOnly, + WGPUTextureAspect_DepthOnly, +} WGPUTextureAspect; + +typedef enum { + WGPUTextureDimension_D1, + WGPUTextureDimension_D2, + WGPUTextureDimension_D3, +} WGPUTextureDimension; + +typedef enum { + WGPUTextureFormat_R8Unorm = 0, + WGPUTextureFormat_R8Snorm = 1, + WGPUTextureFormat_R8Uint = 2, + WGPUTextureFormat_R8Sint = 3, + WGPUTextureFormat_R16Unorm = 4, + WGPUTextureFormat_R16Snorm = 5, + WGPUTextureFormat_R16Uint = 6, + WGPUTextureFormat_R16Sint = 7, + WGPUTextureFormat_R16Float = 8, + WGPUTextureFormat_Rg8Unorm = 9, + WGPUTextureFormat_Rg8Snorm = 10, + WGPUTextureFormat_Rg8Uint = 11, + WGPUTextureFormat_Rg8Sint = 12, + WGPUTextureFormat_R32Uint = 13, + WGPUTextureFormat_R32Sint = 14, + WGPUTextureFormat_R32Float = 15, + WGPUTextureFormat_Rg16Unorm = 16, + WGPUTextureFormat_Rg16Snorm = 17, + WGPUTextureFormat_Rg16Uint = 18, + WGPUTextureFormat_Rg16Sint = 19, + WGPUTextureFormat_Rg16Float = 20, + WGPUTextureFormat_Rgba8Unorm = 21, + WGPUTextureFormat_Rgba8UnormSrgb = 22, + WGPUTextureFormat_Rgba8Snorm = 23, + WGPUTextureFormat_Rgba8Uint = 24, + WGPUTextureFormat_Rgba8Sint = 25, + WGPUTextureFormat_Bgra8Unorm = 26, + WGPUTextureFormat_Bgra8UnormSrgb = 27, + WGPUTextureFormat_Rgb10a2Unorm = 28, + WGPUTextureFormat_Rg11b10Float = 29, + WGPUTextureFormat_Rg32Uint = 30, + WGPUTextureFormat_Rg32Sint = 31, + WGPUTextureFormat_Rg32Float = 32, + WGPUTextureFormat_Rgba16Unorm = 33, + WGPUTextureFormat_Rgba16Snorm = 34, + WGPUTextureFormat_Rgba16Uint = 35, + WGPUTextureFormat_Rgba16Sint = 36, + WGPUTextureFormat_Rgba16Float = 37, + WGPUTextureFormat_Rgba32Uint = 38, + WGPUTextureFormat_Rgba32Sint = 39, + WGPUTextureFormat_Rgba32Float = 40, + WGPUTextureFormat_Depth32Float = 41, + WGPUTextureFormat_Depth24Plus = 42, + WGPUTextureFormat_Depth24PlusStencil8 = 43, +} WGPUTextureFormat; + +typedef enum { + WGPUTextureViewDimension_D1, + WGPUTextureViewDimension_D2, + WGPUTextureViewDimension_D2Array, + WGPUTextureViewDimension_Cube, + WGPUTextureViewDimension_CubeArray, + WGPUTextureViewDimension_D3, +} WGPUTextureViewDimension; + +typedef enum { + WGPUVertexFormat_Uchar2 = 1, + WGPUVertexFormat_Uchar4 = 3, + WGPUVertexFormat_Char2 = 5, + WGPUVertexFormat_Char4 = 7, + WGPUVertexFormat_Uchar2Norm = 9, + WGPUVertexFormat_Uchar4Norm = 11, + WGPUVertexFormat_Char2Norm = 14, + WGPUVertexFormat_Char4Norm = 16, + WGPUVertexFormat_Ushort2 = 18, + WGPUVertexFormat_Ushort4 = 20, + WGPUVertexFormat_Short2 = 22, + WGPUVertexFormat_Short4 = 24, + WGPUVertexFormat_Ushort2Norm = 26, + WGPUVertexFormat_Ushort4Norm = 28, + WGPUVertexFormat_Short2Norm = 30, + WGPUVertexFormat_Short4Norm = 32, + WGPUVertexFormat_Half2 = 34, + WGPUVertexFormat_Half4 = 36, + WGPUVertexFormat_Float = 37, + WGPUVertexFormat_Float2 = 38, + WGPUVertexFormat_Float3 = 39, + WGPUVertexFormat_Float4 = 40, + WGPUVertexFormat_Uint = 41, + WGPUVertexFormat_Uint2 = 42, + WGPUVertexFormat_Uint3 = 43, + WGPUVertexFormat_Uint4 = 44, + WGPUVertexFormat_Int = 45, + WGPUVertexFormat_Int2 = 46, + WGPUVertexFormat_Int3 = 47, + WGPUVertexFormat_Int4 = 48, +} WGPUVertexFormat; + +typedef uint64_t WGPUId_Device_Dummy; + +typedef WGPUId_Device_Dummy WGPUDeviceId; + +typedef uint64_t WGPUId_Adapter_Dummy; + +typedef WGPUId_Adapter_Dummy WGPUAdapterId; + +typedef struct { + bool anisotropic_filtering; +} WGPUExtensions; + +typedef struct { + uint32_t max_bind_groups; +} WGPULimits; + +typedef struct { + WGPUExtensions extensions; + WGPULimits limits; +} WGPUDeviceDescriptor; + +typedef uint64_t WGPUId_BindGroup_Dummy; + +typedef WGPUId_BindGroup_Dummy WGPUBindGroupId; + +typedef uint64_t WGPUId_Buffer_Dummy; + +typedef WGPUId_Buffer_Dummy WGPUBufferId; + +typedef uint64_t WGPUBufferAddress; + +typedef void (*WGPUBufferMapReadCallback)(WGPUBufferMapAsyncStatus status, const uint8_t *data, uint8_t *userdata); + +typedef void (*WGPUBufferMapWriteCallback)(WGPUBufferMapAsyncStatus status, uint8_t *data, uint8_t *userdata); + +typedef uint64_t WGPUId_ComputePass_Dummy; + +typedef WGPUId_ComputePass_Dummy WGPUComputePassId; + +typedef uint64_t WGPUId_CommandBuffer_Dummy; + +typedef WGPUId_CommandBuffer_Dummy WGPUCommandBufferId; + +typedef WGPUCommandBufferId WGPUCommandEncoderId; + +typedef struct { + uint32_t todo; +} WGPUComputePassDescriptor; + +typedef uint64_t WGPUId_RenderPass_Dummy; + +typedef WGPUId_RenderPass_Dummy WGPURenderPassId; + +typedef uint64_t WGPUId_TextureView_Dummy; + +typedef WGPUId_TextureView_Dummy WGPUTextureViewId; + +typedef struct { + double r; + double g; + double b; + double a; +} WGPUColor; +#define WGPUColor_TRANSPARENT (WGPUColor){ .r = 0.0, .g = 0.0, .b = 0.0, .a = 0.0 } +#define WGPUColor_BLACK (WGPUColor){ .r = 0.0, .g = 0.0, .b = 0.0, .a = 1.0 } +#define WGPUColor_WHITE (WGPUColor){ .r = 1.0, .g = 1.0, .b = 1.0, .a = 1.0 } +#define WGPUColor_RED (WGPUColor){ .r = 1.0, .g = 0.0, .b = 0.0, .a = 1.0 } +#define WGPUColor_GREEN (WGPUColor){ .r = 0.0, .g = 1.0, .b = 0.0, .a = 1.0 } +#define WGPUColor_BLUE (WGPUColor){ .r = 0.0, .g = 0.0, .b = 1.0, .a = 1.0 } + +typedef struct { + WGPUTextureViewId attachment; + const WGPUTextureViewId *resolve_target; + WGPULoadOp load_op; + WGPUStoreOp store_op; + WGPUColor clear_color; +} WGPURenderPassColorAttachmentDescriptor; + +typedef struct { + WGPUTextureViewId attachment; + WGPULoadOp depth_load_op; + WGPUStoreOp depth_store_op; + float clear_depth; + WGPULoadOp stencil_load_op; + WGPUStoreOp stencil_store_op; + uint32_t clear_stencil; +} WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId; + +typedef struct { + const WGPURenderPassColorAttachmentDescriptor *color_attachments; + uintptr_t color_attachments_length; + const WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId *depth_stencil_attachment; +} WGPURenderPassDescriptor; + +typedef struct { + WGPUBufferId buffer; + WGPUBufferAddress offset; + uint32_t row_pitch; + uint32_t image_height; +} WGPUBufferCopyView; + +typedef uint64_t WGPUId_Texture_Dummy; + +typedef WGPUId_Texture_Dummy WGPUTextureId; + +typedef struct { + float x; + float y; + float z; +} WGPUOrigin3d; +#define WGPUOrigin3d_ZERO (WGPUOrigin3d){ .x = 0.0, .y = 0.0, .z = 0.0 } + +typedef struct { + WGPUTextureId texture; + uint32_t mip_level; + uint32_t array_layer; + WGPUOrigin3d origin; +} WGPUTextureCopyView; + +typedef struct { + uint32_t width; + uint32_t height; + uint32_t depth; +} WGPUExtent3d; + +typedef struct { + uint32_t todo; +} WGPUCommandBufferDescriptor; + +typedef const char *WGPURawString; + +typedef uint64_t WGPUId_ComputePipeline_Dummy; + +typedef WGPUId_ComputePipeline_Dummy WGPUComputePipelineId; + +typedef uint64_t WGPUId_Surface; + +typedef WGPUId_Surface WGPUSurfaceId; + +typedef uint64_t WGPUId_BindGroupLayout_Dummy; + +typedef WGPUId_BindGroupLayout_Dummy WGPUBindGroupLayoutId; + +typedef struct { + WGPUBufferId buffer; + WGPUBufferAddress offset; + WGPUBufferAddress size; +} WGPUBufferBinding; + +typedef uint64_t WGPUId_Sampler_Dummy; + +typedef WGPUId_Sampler_Dummy WGPUSamplerId; + +typedef enum { + WGPUBindingResource_Buffer, + WGPUBindingResource_Sampler, + WGPUBindingResource_TextureView, +} WGPUBindingResource_Tag; + +typedef struct { + WGPUBufferBinding _0; +} WGPUBindingResource_WGPUBuffer_Body; + +typedef struct { + WGPUSamplerId _0; +} WGPUBindingResource_WGPUSampler_Body; + +typedef struct { + WGPUTextureViewId _0; +} WGPUBindingResource_WGPUTextureView_Body; + +typedef struct { + WGPUBindingResource_Tag tag; + union { + WGPUBindingResource_WGPUBuffer_Body buffer; + WGPUBindingResource_WGPUSampler_Body sampler; + WGPUBindingResource_WGPUTextureView_Body texture_view; + }; +} WGPUBindingResource; + +typedef struct { + uint32_t binding; + WGPUBindingResource resource; +} WGPUBindGroupBinding; + +typedef struct { + WGPUBindGroupLayoutId layout; + const WGPUBindGroupBinding *bindings; + uintptr_t bindings_length; +} WGPUBindGroupDescriptor; + +typedef uint32_t WGPUShaderStage; +#define WGPUShaderStage_NONE 0 +#define WGPUShaderStage_VERTEX 1 +#define WGPUShaderStage_FRAGMENT 2 +#define WGPUShaderStage_COMPUTE 4 + +typedef struct { + uint32_t binding; + WGPUShaderStage visibility; + WGPUBindingType ty; + WGPUTextureViewDimension texture_dimension; + bool multisampled; + bool dynamic; +} WGPUBindGroupLayoutBinding; + +typedef struct { + const WGPUBindGroupLayoutBinding *bindings; + uintptr_t bindings_length; +} WGPUBindGroupLayoutDescriptor; + +typedef uint32_t WGPUBufferUsage; +#define WGPUBufferUsage_MAP_READ 1 +#define WGPUBufferUsage_MAP_WRITE 2 +#define WGPUBufferUsage_COPY_SRC 4 +#define WGPUBufferUsage_COPY_DST 8 +#define WGPUBufferUsage_INDEX 16 +#define WGPUBufferUsage_VERTEX 32 +#define WGPUBufferUsage_UNIFORM 64 +#define WGPUBufferUsage_STORAGE 128 +#define WGPUBufferUsage_STORAGE_READ 256 +#define WGPUBufferUsage_INDIRECT 512 +#define WGPUBufferUsage_NONE 0 + +typedef struct { + WGPUBufferAddress size; + WGPUBufferUsage usage; +} WGPUBufferDescriptor; + +typedef struct { + uint32_t todo; +} WGPUCommandEncoderDescriptor; + +typedef uint64_t WGPUId_PipelineLayout_Dummy; + +typedef WGPUId_PipelineLayout_Dummy WGPUPipelineLayoutId; + +typedef uint64_t WGPUId_ShaderModule_Dummy; + +typedef WGPUId_ShaderModule_Dummy WGPUShaderModuleId; + +typedef struct { + WGPUShaderModuleId module; + WGPURawString entry_point; +} WGPUProgrammableStageDescriptor; + +typedef struct { + WGPUPipelineLayoutId layout; + WGPUProgrammableStageDescriptor compute_stage; +} WGPUComputePipelineDescriptor; + +typedef struct { + const WGPUBindGroupLayoutId *bind_group_layouts; + uintptr_t bind_group_layouts_length; +} WGPUPipelineLayoutDescriptor; + +typedef uint64_t WGPUId_RenderPipeline_Dummy; + +typedef WGPUId_RenderPipeline_Dummy WGPURenderPipelineId; + +typedef struct { + WGPUFrontFace front_face; + WGPUCullMode cull_mode; + int32_t depth_bias; + float depth_bias_slope_scale; + float depth_bias_clamp; +} WGPURasterizationStateDescriptor; + +typedef struct { + WGPUBlendFactor src_factor; + WGPUBlendFactor dst_factor; + WGPUBlendOperation operation; +} WGPUBlendDescriptor; + +typedef uint32_t WGPUColorWrite; +#define WGPUColorWrite_RED 1 +#define WGPUColorWrite_GREEN 2 +#define WGPUColorWrite_BLUE 4 +#define WGPUColorWrite_ALPHA 8 +#define WGPUColorWrite_COLOR 7 +#define WGPUColorWrite_ALL 15 + +typedef struct { + WGPUTextureFormat format; + WGPUBlendDescriptor alpha_blend; + WGPUBlendDescriptor color_blend; + WGPUColorWrite write_mask; +} WGPUColorStateDescriptor; + +typedef struct { + WGPUCompareFunction compare; + WGPUStencilOperation fail_op; + WGPUStencilOperation depth_fail_op; + WGPUStencilOperation pass_op; +} WGPUStencilStateFaceDescriptor; + +typedef struct { + WGPUTextureFormat format; + bool depth_write_enabled; + WGPUCompareFunction depth_compare; + WGPUStencilStateFaceDescriptor stencil_front; + WGPUStencilStateFaceDescriptor stencil_back; + uint32_t stencil_read_mask; + uint32_t stencil_write_mask; +} WGPUDepthStencilStateDescriptor; + +typedef uint32_t WGPUShaderLocation; + +typedef struct { + WGPUBufferAddress offset; + WGPUVertexFormat format; + WGPUShaderLocation shader_location; +} WGPUVertexAttributeDescriptor; + +typedef struct { + WGPUBufferAddress stride; + WGPUInputStepMode step_mode; + const WGPUVertexAttributeDescriptor *attributes; + uintptr_t attributes_length; +} WGPUVertexBufferDescriptor; + +typedef struct { + WGPUIndexFormat index_format; + const WGPUVertexBufferDescriptor *vertex_buffers; + uintptr_t vertex_buffers_length; +} WGPUVertexInputDescriptor; + +typedef struct { + WGPUPipelineLayoutId layout; + WGPUProgrammableStageDescriptor vertex_stage; + const WGPUProgrammableStageDescriptor *fragment_stage; + WGPUPrimitiveTopology primitive_topology; + const WGPURasterizationStateDescriptor *rasterization_state; + const WGPUColorStateDescriptor *color_states; + uintptr_t color_states_length; + const WGPUDepthStencilStateDescriptor *depth_stencil_state; + WGPUVertexInputDescriptor vertex_input; + uint32_t sample_count; + uint32_t sample_mask; + bool alpha_to_coverage_enabled; +} WGPURenderPipelineDescriptor; + +typedef struct { + WGPUAddressMode address_mode_u; + WGPUAddressMode address_mode_v; + WGPUAddressMode address_mode_w; + WGPUFilterMode mag_filter; + WGPUFilterMode min_filter; + WGPUFilterMode mipmap_filter; + float lod_min_clamp; + float lod_max_clamp; + WGPUCompareFunction compare_function; +} WGPUSamplerDescriptor; + +typedef struct { + const uint32_t *bytes; + uintptr_t length; +} WGPUU32Array; + +typedef struct { + WGPUU32Array code; +} WGPUShaderModuleDescriptor; + +typedef uint64_t WGPUId_SwapChain_Dummy; + +typedef WGPUId_SwapChain_Dummy WGPUSwapChainId; + +typedef uint32_t WGPUTextureUsage; +#define WGPUTextureUsage_COPY_SRC 1 +#define WGPUTextureUsage_COPY_DST 2 +#define WGPUTextureUsage_SAMPLED 4 +#define WGPUTextureUsage_STORAGE 8 +#define WGPUTextureUsage_OUTPUT_ATTACHMENT 16 +#define WGPUTextureUsage_NONE 0 +#define WGPUTextureUsage_UNINITIALIZED 65535 + +typedef struct { + WGPUTextureUsage usage; + WGPUTextureFormat format; + uint32_t width; + uint32_t height; + WGPUPresentMode present_mode; +} WGPUSwapChainDescriptor; + +typedef struct { + WGPUExtent3d size; + uint32_t array_layer_count; + uint32_t mip_level_count; + uint32_t sample_count; + WGPUTextureDimension dimension; + WGPUTextureFormat format; + WGPUTextureUsage usage; +} WGPUTextureDescriptor; + +typedef WGPUDeviceId WGPUQueueId; + +typedef uint64_t WGPUId_RenderBundle_Dummy; + +typedef WGPUId_RenderBundle_Dummy WGPURenderBundleId; + +typedef uint32_t WGPUBackendBit; + +typedef struct { + WGPUPowerPreference power_preference; + WGPUBackendBit backends; +} WGPURequestAdapterOptions; + +typedef void (*WGPURequestAdapterCallback)(const WGPUAdapterId *adapter, void *userdata); + +typedef struct { + WGPUTextureViewId view_id; +} WGPUSwapChainOutput; + +typedef struct { + WGPUTextureFormat format; + WGPUTextureViewDimension dimension; + WGPUTextureAspect aspect; + uint32_t base_mip_level; + uint32_t level_count; + uint32_t base_array_layer; + uint32_t array_layer_count; +} WGPUTextureViewDescriptor; + +#if defined(WGPU_LOCAL) +WGPUDeviceId wgpu_adapter_request_device(WGPUAdapterId adapter_id, + const WGPUDeviceDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_bind_group_destroy(WGPUBindGroupId bind_group_id); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_buffer_destroy(WGPUBufferId buffer_id); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_buffer_map_read_async(WGPUBufferId buffer_id, + WGPUBufferAddress start, + WGPUBufferAddress size, + WGPUBufferMapReadCallback callback, + uint8_t *userdata); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_buffer_map_write_async(WGPUBufferId buffer_id, + WGPUBufferAddress start, + WGPUBufferAddress size, + WGPUBufferMapWriteCallback callback, + uint8_t *userdata); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_buffer_unmap(WGPUBufferId buffer_id); +#endif + +#if defined(WGPU_LOCAL) +WGPUComputePassId wgpu_command_encoder_begin_compute_pass(WGPUCommandEncoderId encoder_id, + const WGPUComputePassDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +WGPURenderPassId wgpu_command_encoder_begin_render_pass(WGPUCommandEncoderId encoder_id, + const WGPURenderPassDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_command_encoder_copy_buffer_to_buffer(WGPUCommandEncoderId command_encoder_id, + WGPUBufferId source, + WGPUBufferAddress source_offset, + WGPUBufferId destination, + WGPUBufferAddress destination_offset, + WGPUBufferAddress size); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_command_encoder_copy_buffer_to_texture(WGPUCommandEncoderId command_encoder_id, + const WGPUBufferCopyView *source, + const WGPUTextureCopyView *destination, + WGPUExtent3d copy_size); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_command_encoder_copy_texture_to_buffer(WGPUCommandEncoderId command_encoder_id, + const WGPUTextureCopyView *source, + const WGPUBufferCopyView *destination, + WGPUExtent3d copy_size); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_command_encoder_copy_texture_to_texture(WGPUCommandEncoderId command_encoder_id, + const WGPUTextureCopyView *source, + const WGPUTextureCopyView *destination, + WGPUExtent3d copy_size); +#endif + +#if defined(WGPU_LOCAL) +WGPUCommandBufferId wgpu_command_encoder_finish(WGPUCommandEncoderId encoder_id, + const WGPUCommandBufferDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_compute_pass_dispatch(WGPUComputePassId pass_id, uint32_t x, uint32_t y, uint32_t z); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_compute_pass_dispatch_indirect(WGPUComputePassId pass_id, + WGPUBufferId indirect_buffer_id, + WGPUBufferAddress indirect_offset); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_compute_pass_end_pass(WGPUComputePassId pass_id); +#endif + +void wgpu_compute_pass_insert_debug_marker(WGPUComputePassId _pass_id, WGPURawString _label); + +void wgpu_compute_pass_pop_debug_group(WGPUComputePassId _pass_id); + +void wgpu_compute_pass_push_debug_group(WGPUComputePassId _pass_id, WGPURawString _label); + +#if defined(WGPU_LOCAL) +void wgpu_compute_pass_set_bind_group(WGPUComputePassId pass_id, + uint32_t index, + WGPUBindGroupId bind_group_id, + const WGPUBufferAddress *offsets, + uintptr_t offsets_length); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_compute_pass_set_pipeline(WGPUComputePassId pass_id, WGPUComputePipelineId pipeline_id); +#endif + +#if defined(WGPU_LOCAL) +WGPUSurfaceId wgpu_create_surface_from_metal_layer(void *layer); +#endif + +#if defined(WGPU_LOCAL) +WGPUSurfaceId wgpu_create_surface_from_windows_hwnd(void *_hinstance, void *hwnd); +#endif + +#if defined(WGPU_LOCAL) +WGPUSurfaceId wgpu_create_surface_from_xlib(const void **display, uint64_t window); +#endif + +#if defined(WGPU_LOCAL) +WGPUBindGroupId wgpu_device_create_bind_group(WGPUDeviceId device_id, + const WGPUBindGroupDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +WGPUBindGroupLayoutId wgpu_device_create_bind_group_layout(WGPUDeviceId device_id, + const WGPUBindGroupLayoutDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +WGPUBufferId wgpu_device_create_buffer(WGPUDeviceId device_id, const WGPUBufferDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +WGPUBufferId wgpu_device_create_buffer_mapped(WGPUDeviceId device_id, + const WGPUBufferDescriptor *desc, + uint8_t **mapped_ptr_out); +#endif + +#if defined(WGPU_LOCAL) +WGPUCommandEncoderId wgpu_device_create_command_encoder(WGPUDeviceId device_id, + const WGPUCommandEncoderDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +WGPUComputePipelineId wgpu_device_create_compute_pipeline(WGPUDeviceId device_id, + const WGPUComputePipelineDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +WGPUPipelineLayoutId wgpu_device_create_pipeline_layout(WGPUDeviceId device_id, + const WGPUPipelineLayoutDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +WGPURenderPipelineId wgpu_device_create_render_pipeline(WGPUDeviceId device_id, + const WGPURenderPipelineDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +WGPUSamplerId wgpu_device_create_sampler(WGPUDeviceId device_id, const WGPUSamplerDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +WGPUShaderModuleId wgpu_device_create_shader_module(WGPUDeviceId device_id, + const WGPUShaderModuleDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +WGPUSwapChainId wgpu_device_create_swap_chain(WGPUDeviceId device_id, + WGPUSurfaceId surface_id, + const WGPUSwapChainDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +WGPUTextureId wgpu_device_create_texture(WGPUDeviceId device_id, const WGPUTextureDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_device_destroy(WGPUDeviceId device_id); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_device_get_limits(WGPUDeviceId _device_id, WGPULimits *limits); +#endif + +#if defined(WGPU_LOCAL) +WGPUQueueId wgpu_device_get_queue(WGPUDeviceId device_id); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_device_poll(WGPUDeviceId device_id, bool force_wait); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_queue_submit(WGPUQueueId queue_id, + const WGPUCommandBufferId *command_buffers, + uintptr_t command_buffers_length); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_draw(WGPURenderPassId pass_id, + uint32_t vertex_count, + uint32_t instance_count, + uint32_t first_vertex, + uint32_t first_instance); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_draw_indexed(WGPURenderPassId pass_id, + uint32_t index_count, + uint32_t instance_count, + uint32_t first_index, + int32_t base_vertex, + uint32_t first_instance); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_draw_indexed_indirect(WGPURenderPassId pass_id, + WGPUBufferId indirect_buffer_id, + WGPUBufferAddress indirect_offset); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_draw_indirect(WGPURenderPassId pass_id, + WGPUBufferId indirect_buffer_id, + WGPUBufferAddress indirect_offset); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_end_pass(WGPURenderPassId pass_id); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_execute_bundles(WGPURenderPassId _pass_id, + const WGPURenderBundleId *_bundles, + uintptr_t _bundles_length); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_insert_debug_marker(WGPURenderPassId _pass_id, WGPURawString _label); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_pop_debug_group(WGPURenderPassId _pass_id); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_push_debug_group(WGPURenderPassId _pass_id, WGPURawString _label); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_set_bind_group(WGPURenderPassId pass_id, + uint32_t index, + WGPUBindGroupId bind_group_id, + const WGPUBufferAddress *offsets, + uintptr_t offsets_length); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_set_blend_color(WGPURenderPassId pass_id, const WGPUColor *color); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_set_index_buffer(WGPURenderPassId pass_id, + WGPUBufferId buffer_id, + WGPUBufferAddress offset); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_set_pipeline(WGPURenderPassId pass_id, WGPURenderPipelineId pipeline_id); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_set_scissor_rect(WGPURenderPassId pass_id, + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_set_stencil_reference(WGPURenderPassId pass_id, uint32_t value); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_set_vertex_buffers(WGPURenderPassId pass_id, + uint32_t start_slot, + const WGPUBufferId *buffers, + const WGPUBufferAddress *offsets, + uintptr_t length); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_render_pass_set_viewport(WGPURenderPassId pass_id, + float x, + float y, + float w, + float h, + float min_depth, + float max_depth); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_request_adapter_async(const WGPURequestAdapterOptions *desc, + WGPURequestAdapterCallback callback, + void *userdata); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_sampler_destroy(WGPUSamplerId sampler_id); +#endif + +#if defined(WGPU_LOCAL) +WGPUSwapChainOutput wgpu_swap_chain_get_next_texture(WGPUSwapChainId swap_chain_id); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_swap_chain_present(WGPUSwapChainId swap_chain_id); +#endif + +#if defined(WGPU_LOCAL) +WGPUTextureViewId wgpu_texture_create_view(WGPUTextureId texture_id, + const WGPUTextureViewDescriptor *desc); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_texture_destroy(WGPUTextureId texture_id); +#endif + +#if defined(WGPU_LOCAL) +void wgpu_texture_view_destroy(WGPUTextureViewId texture_view_id); +#endif diff --git a/gfx/wgpu/rustfmt.toml b/gfx/wgpu/rustfmt.toml new file mode 100644 index 000000000000..c1733530b65e --- /dev/null +++ b/gfx/wgpu/rustfmt.toml @@ -0,0 +1,4 @@ +newline_style = "Native" +blank_lines_upper_bound = 2 +spaces_around_ranges = true +imports_layout = "HorizontalVertical" diff --git a/dom/webgpu/wgpu-native/Cargo.toml b/gfx/wgpu/wgpu-native/Cargo.toml similarity index 95% rename from dom/webgpu/wgpu-native/Cargo.toml rename to gfx/wgpu/wgpu-native/Cargo.toml index 4ed7ba1ae741..fad7250001a6 100644 --- a/dom/webgpu/wgpu-native/Cargo.toml +++ b/gfx/wgpu/wgpu-native/Cargo.toml @@ -13,8 +13,8 @@ keywords = ["graphics"] license = "MPL-2.0" [lib] +# Enabling these targets makes our CI bots try to build them and fail atm #crate-type = ["lib", "cdylib", "staticlib"] -crate-type = ["lib"] [features] default = [] diff --git a/gfx/wgpu/wgpu-native/cbindgen.toml b/gfx/wgpu/wgpu-native/cbindgen.toml new file mode 100644 index 000000000000..511a50a3b828 --- /dev/null +++ b/gfx/wgpu/wgpu-native/cbindgen.toml @@ -0,0 +1,46 @@ +header = """/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */""" +autogen_warning = """/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen. + * To generate this file: + * 1. Get the latest cbindgen using `cargo install --force cbindgen` + * a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release + * 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate wgpu-remote -o dom/webgpu/ffi/wgpu_ffi_generated.h` + */ + +#define WGPU_LOCAL +""" +include_version = true +braces = "SameLine" +line_length = 100 +tab_width = 2 +language = "C" + +[export] +prefix = "WGPU" +#TODO: figure out why cbindgen even tries to export a private type... +exclude = ["BufferMapResult"] + +[parse] +parse_deps = false + +[parse.expand] +features = ["local"] + +[fn] + +[struct] +derive_eq = true + +[enum] +prefix_with_name = true +derive_helper_methods = true + +[macro_expansion] +bitflags = true + +[defines] +"feature = local" = "WGPU_LOCAL" +"feature = gfx-backend-gl" = "WGPU_BACKEND_GL" +"feature = winit" = "WGPU_WINIT" +"feature = glutin" = "WGPU_GLUTIN" diff --git a/dom/webgpu/wgpu-native/src/binding_model.rs b/gfx/wgpu/wgpu-native/src/binding_model.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/binding_model.rs rename to gfx/wgpu/wgpu-native/src/binding_model.rs diff --git a/dom/webgpu/wgpu-native/src/command/allocator.rs b/gfx/wgpu/wgpu-native/src/command/allocator.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/command/allocator.rs rename to gfx/wgpu/wgpu-native/src/command/allocator.rs diff --git a/dom/webgpu/wgpu-native/src/command/bind.rs b/gfx/wgpu/wgpu-native/src/command/bind.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/command/bind.rs rename to gfx/wgpu/wgpu-native/src/command/bind.rs diff --git a/dom/webgpu/wgpu-native/src/command/compute.rs b/gfx/wgpu/wgpu-native/src/command/compute.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/command/compute.rs rename to gfx/wgpu/wgpu-native/src/command/compute.rs diff --git a/dom/webgpu/wgpu-native/src/command/mod.rs b/gfx/wgpu/wgpu-native/src/command/mod.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/command/mod.rs rename to gfx/wgpu/wgpu-native/src/command/mod.rs diff --git a/dom/webgpu/wgpu-native/src/command/render.rs b/gfx/wgpu/wgpu-native/src/command/render.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/command/render.rs rename to gfx/wgpu/wgpu-native/src/command/render.rs diff --git a/dom/webgpu/wgpu-native/src/command/transfer.rs b/gfx/wgpu/wgpu-native/src/command/transfer.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/command/transfer.rs rename to gfx/wgpu/wgpu-native/src/command/transfer.rs diff --git a/dom/webgpu/wgpu-native/src/conv.rs b/gfx/wgpu/wgpu-native/src/conv.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/conv.rs rename to gfx/wgpu/wgpu-native/src/conv.rs diff --git a/dom/webgpu/wgpu-native/src/device.rs b/gfx/wgpu/wgpu-native/src/device.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/device.rs rename to gfx/wgpu/wgpu-native/src/device.rs diff --git a/dom/webgpu/wgpu-native/src/hub.rs b/gfx/wgpu/wgpu-native/src/hub.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/hub.rs rename to gfx/wgpu/wgpu-native/src/hub.rs diff --git a/dom/webgpu/wgpu-native/src/id.rs b/gfx/wgpu/wgpu-native/src/id.rs similarity index 98% rename from dom/webgpu/wgpu-native/src/id.rs rename to gfx/wgpu/wgpu-native/src/id.rs index 839c8521a780..403dd23863ab 100644 --- a/dom/webgpu/wgpu-native/src/id.rs +++ b/gfx/wgpu/wgpu-native/src/id.rs @@ -16,6 +16,8 @@ type Dummy = crate::backend::Empty; pub struct Id(u64, PhantomData); impl Id { + pub const ERROR: Self = Self(0, PhantomData); + pub fn backend(&self) -> Backend { match self.0 >> (64 - BACKEND_BITS) as u8 { 0 => Backend::Empty, diff --git a/dom/webgpu/wgpu-native/src/instance.rs b/gfx/wgpu/wgpu-native/src/instance.rs similarity index 93% rename from dom/webgpu/wgpu-native/src/instance.rs rename to gfx/wgpu/wgpu-native/src/instance.rs index e721a28d9401..da3a26a3d734 100644 --- a/dom/webgpu/wgpu-native/src/instance.rs +++ b/gfx/wgpu/wgpu-native/src/instance.rs @@ -26,6 +26,7 @@ use hal::{self, adapter::PhysicalDevice as _, queue::QueueFamily as _, Instance #[cfg(feature = "local")] use std::marker::PhantomData; +use std::ffi::c_void; #[derive(Debug)] pub struct Instance { @@ -301,7 +302,21 @@ pub extern "C" fn wgpu_create_surface_from_windows_hwnd( )) } -pub fn request_adapter( +pub type RequestAdapterCallback = + extern "C" fn(adapter: *const AdapterId, userdata: *mut c_void); + +pub fn request_adapter_async( + global: &Global, + desc: &RequestAdapterOptions, + input_ids: &[Input], + callback: RequestAdapterCallback, + userdata: *mut c_void, +) { + let adapter = pick_adapter(global, desc, input_ids); + callback(adapter.as_ref().map_or(&AdapterId::ERROR, |x| x as *const _), userdata); +} + +fn pick_adapter( global: &Global, desc: &RequestAdapterOptions, input_ids: &[Input], @@ -320,10 +335,6 @@ pub fn request_adapter( None } }; - #[cfg(not(feature = "local"))] - let pick = |_output, input_maybe| input_maybe; - #[cfg(feature = "local")] - let pick = |output, _input_maybe| Some(output); let id_vulkan = find_input(Backend::Vulkan); let id_metal = find_input(Backend::Metal); @@ -397,6 +408,16 @@ pub fn request_adapter( PowerPreference::LowPower => integrated.or(other).or(discrete).or(virt), PowerPreference::HighPerformance => discrete.or(other).or(integrated).or(virt), }; + + #[allow(unused_variables)] + let local_or_remote_id = |local_id, remote_id| { + #[cfg(not(feature = "local"))] + let id = remote_id; + #[cfg(feature = "local")] + let id = Some(local_id); + id + }; + let mut token = Token::root(); let mut selected = preferred_gpu.unwrap_or(0); @@ -415,7 +436,7 @@ pub fn request_adapter( adapter, &mut token, ); - return pick(id_out, id_vulkan); + return local_or_remote_id(id_out, id_vulkan); } selected -= adapters_vk.len(); } @@ -431,7 +452,7 @@ pub fn request_adapter( adapter, &mut token, ); - return pick(id_out, id_metal); + return local_or_remote_id(id_out, id_metal); } selected -= adapters_mtl.len(); } @@ -447,7 +468,7 @@ pub fn request_adapter( adapter, &mut token, ); - return pick(id_out, id_dx12); + return local_or_remote_id(id_out, id_dx12); } selected -= adapters_dx12.len(); if selected < adapters_dx11.len() { @@ -460,18 +481,23 @@ pub fn request_adapter( adapter, &mut token, ); - return pick(id_out, id_dx11); + return local_or_remote_id(id_out, id_dx11); } selected -= adapters_dx11.len(); } + let _ = (selected, id_vulkan, id_metal, id_dx12, id_dx11); unreachable!() } #[cfg(feature = "local")] #[no_mangle] -pub extern "C" fn wgpu_request_adapter(desc: Option<&RequestAdapterOptions>) -> AdapterId { - request_adapter(&*GLOBAL, &desc.cloned().unwrap_or_default(), &[]).unwrap() +pub extern "C" fn wgpu_request_adapter_async( + desc: Option<&RequestAdapterOptions>, + callback: RequestAdapterCallback, + userdata: *mut c_void, +) { + request_adapter_async(&*GLOBAL, &desc.cloned().unwrap_or_default(), &[], callback, userdata); } pub fn adapter_request_device( @@ -509,7 +535,7 @@ pub fn adapter_request_device( BIND_BUFFER_ALIGNMENT % limits.min_uniform_buffer_offset_alignment, "Adapter uniform buffer offset alignment not compatible with WGPU" ); - if desc.limits.max_bind_groups == 0 { + if limits.max_bound_descriptor_sets == 0 { log::warn!("max_bind_groups limit is missing"); } else { assert!( diff --git a/dom/webgpu/wgpu-native/src/lib.rs b/gfx/wgpu/wgpu-native/src/lib.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/lib.rs rename to gfx/wgpu/wgpu-native/src/lib.rs diff --git a/dom/webgpu/wgpu-native/src/pipeline.rs b/gfx/wgpu/wgpu-native/src/pipeline.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/pipeline.rs rename to gfx/wgpu/wgpu-native/src/pipeline.rs diff --git a/dom/webgpu/wgpu-native/src/resource.rs b/gfx/wgpu/wgpu-native/src/resource.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/resource.rs rename to gfx/wgpu/wgpu-native/src/resource.rs diff --git a/dom/webgpu/wgpu-native/src/swap_chain.rs b/gfx/wgpu/wgpu-native/src/swap_chain.rs similarity index 95% rename from dom/webgpu/wgpu-native/src/swap_chain.rs rename to gfx/wgpu/wgpu-native/src/swap_chain.rs index 99d392383db5..cfdc10884424 100644 --- a/dom/webgpu/wgpu-native/src/swap_chain.rs +++ b/gfx/wgpu/wgpu-native/src/swap_chain.rs @@ -131,11 +131,16 @@ pub struct SwapChainOutput { pub view_id: TextureViewId, } +#[derive(Debug)] +pub enum SwapChainGetNextTextureError { + GpuProcessingTimeout, +} + pub fn swap_chain_get_next_texture( global: &Global, swap_chain_id: SwapChainId, view_id_in: Input, -) -> SwapChainOutput { +) -> Result { let hub = B::hub(global); let mut token = Token::root(); @@ -151,7 +156,7 @@ pub fn swap_chain_get_next_texture( match unsafe { suf.acquire_image(FRAME_TIMEOUT_MS * 1_000_000) } { Ok(surface_image) => surface_image, Err(hal::window::AcquireError::Timeout) => { - panic!("GPU took too much time processing last frames :("); + return Err(SwapChainGetNextTextureError::GpuProcessingTimeout); } Err(e) => { log::warn!("acquire_image() failed ({:?}), reconfiguring swapchain", e); @@ -200,13 +205,15 @@ pub fn swap_chain_get_next_texture( ref_count, }); - SwapChainOutput { view_id } + Ok(SwapChainOutput { view_id }) } #[cfg(feature = "local")] #[no_mangle] pub extern "C" fn wgpu_swap_chain_get_next_texture(swap_chain_id: SwapChainId) -> SwapChainOutput { - gfx_select!(swap_chain_id => swap_chain_get_next_texture(&*GLOBAL, swap_chain_id, PhantomData)) + gfx_select!(swap_chain_id => swap_chain_get_next_texture(&*GLOBAL, swap_chain_id, PhantomData)).unwrap_or(SwapChainOutput { + view_id: TextureViewId::ERROR, + }) } pub fn swap_chain_present(global: &Global, swap_chain_id: SwapChainId) { diff --git a/dom/webgpu/wgpu-native/src/track/buffer.rs b/gfx/wgpu/wgpu-native/src/track/buffer.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/track/buffer.rs rename to gfx/wgpu/wgpu-native/src/track/buffer.rs diff --git a/dom/webgpu/wgpu-native/src/track/mod.rs b/gfx/wgpu/wgpu-native/src/track/mod.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/track/mod.rs rename to gfx/wgpu/wgpu-native/src/track/mod.rs diff --git a/dom/webgpu/wgpu-native/src/track/range.rs b/gfx/wgpu/wgpu-native/src/track/range.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/track/range.rs rename to gfx/wgpu/wgpu-native/src/track/range.rs diff --git a/dom/webgpu/wgpu-native/src/track/texture.rs b/gfx/wgpu/wgpu-native/src/track/texture.rs similarity index 100% rename from dom/webgpu/wgpu-native/src/track/texture.rs rename to gfx/wgpu/wgpu-native/src/track/texture.rs diff --git a/dom/webgpu/wgpu-remote/Cargo.toml b/gfx/wgpu/wgpu-remote/Cargo.toml similarity index 83% rename from dom/webgpu/wgpu-remote/Cargo.toml rename to gfx/wgpu/wgpu-remote/Cargo.toml index 1c35a47fde83..ed6fa6ccaf6e 100644 --- a/dom/webgpu/wgpu-remote/Cargo.toml +++ b/gfx/wgpu/wgpu-remote/Cargo.toml @@ -8,8 +8,8 @@ authors = [ edition = "2018" [lib] +# Enabling these targets makes our CI bots try to build them and fail atm #crate-type = ["lib", "cdylib", "staticlib"] -crate-type = ["lib"] [features] default = [] diff --git a/dom/webgpu/wgpu-remote/cbindgen.toml b/gfx/wgpu/wgpu-remote/cbindgen.toml similarity index 100% rename from dom/webgpu/wgpu-remote/cbindgen.toml rename to gfx/wgpu/wgpu-remote/cbindgen.toml diff --git a/dom/webgpu/wgpu-remote/src/lib.rs b/gfx/wgpu/wgpu-remote/src/lib.rs similarity index 100% rename from dom/webgpu/wgpu-remote/src/lib.rs rename to gfx/wgpu/wgpu-remote/src/lib.rs diff --git a/dom/webgpu/wgpu-remote/src/server.rs b/gfx/wgpu/wgpu-remote/src/server.rs similarity index 72% rename from dom/webgpu/wgpu-remote/src/server.rs rename to gfx/wgpu/wgpu-remote/src/server.rs index 13dfcbf8f92d..3e59edb2a6f1 100644 --- a/dom/webgpu/wgpu-remote/src/server.rs +++ b/gfx/wgpu/wgpu-remote/src/server.rs @@ -28,10 +28,23 @@ pub extern "C" fn wgpu_server_instance_request_adapter( ids: *const wgn::AdapterId, id_length: usize, ) -> i8 { + extern "C" fn request_adapter_callback( + data: *const wgn::AdapterId, + user_data: *mut std::ffi::c_void, + ) { + unsafe { + *(user_data as *mut wgn::AdapterId) = *data; + } + } + let ids = unsafe { slice::from_raw_parts(ids, id_length) }; - match wgn::request_adapter(global, desc, ids) { - Some(id) => ids.iter().position(|&i| i == id).unwrap() as i8, - None => -1, + let mut adapter_id: wgn::AdapterId = wgn::AdapterId::ERROR; + let adapter_id_ref = &mut adapter_id; + wgn::request_adapter_async(global, desc, ids, request_adapter_callback, adapter_id_ref as *mut _ as *mut std::ffi::c_void); + if adapter_id == wgn::AdapterId::ERROR { + -1 + } else { + ids.iter().position(|&i| i == adapter_id).unwrap() as i8 } } diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml index c1ee047747cd..53c5db07d9cc 100644 --- a/toolkit/library/rust/shared/Cargo.toml +++ b/toolkit/library/rust/shared/Cargo.toml @@ -44,7 +44,7 @@ audio_thread_priority = "0.20.2" mdns_service = { path="../../../../media/mtransport/mdns_service", optional = true } neqo_glue = { path = "../../../../netwerk/socket/neqo_glue" } rlbox_lucet_sandbox = { version = "0.1.0", optional = true } -wgpu-remote = { path = "../../../../dom/webgpu/wgpu-remote", optional = true } +wgpu-remote = { path = "../../../../gfx/wgpu/wgpu-remote", optional = true } mapped_hyph = { git = "https://github.com/jfkthame/mapped_hyph.git", tag = "v0.3.0" } [build-dependencies] diff --git a/tools/vcs/mach_commands.py b/tools/vcs/mach_commands.py index afb5c71db273..23526e1c211a 100644 --- a/tools/vcs/mach_commands.py +++ b/tools/vcs/mach_commands.py @@ -34,7 +34,7 @@ PR_REPOSITORIES = { }, 'webgpu': { 'github': 'gfx-rs/wgpu', - 'path': 'dom/webgpu', + 'path': 'gfx/wgpu', 'bugzilla_product': 'Core', 'bugzilla_component': 'Graphics: WebGPU', },