diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 3adffa8ef..000000000 --- a/.clang-format +++ /dev/null @@ -1,5 +0,0 @@ -IndentWidth: 4 - -# Reduce left indentation for nested structs -AlignOperands: false -AlignAfterOpenBracket: DontAlign diff --git a/.gitignore b/.gitignore index c8507b213..70f37a548 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,8 @@ +Cargo.lock /target **/*.rs.bk #Cargo.lock .DS_Store .vscode .vs -build -ffi/dawn*.h -dist .idea diff --git a/.travis.yml b/.travis.yml index 5986d6f27..d206b11c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,23 +52,11 @@ matrix: - TARGET=aarch64-apple-ios - BUILD_COMMAND=clippy -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 - if [[ $TRAVIS_RUST_VERSION != "nightly" ]] && [[ $TRAVIS_OS_NAME == "windows" ]]; then rustup default stable-msvc; fi - if [[ $TRAVIS_RUST_VERSION == "nightly" ]] && [[ $TRAVIS_OS_NAME == "windows" ]]; then rustup default nightly-msvc; fi @@ -77,37 +65,5 @@ before_script: script: - cargo test - # TODO: enable GL backend - (cd wgpu-core && cargo $BUILD_COMMAND --all-features) - - (cd wgpu-native && cargo $BUILD_COMMAND) - - (cd wgpu-remote && cargo $BUILD_COMMAND --all-features) - - if [[ $TRAVIS_OS_NAME == "osx" ]]; then (cd wgpu-native && cargo $BUILD_COMMAND --features vulkan-portability); fi - if [[ $TRAVIS_OS_NAME == "linux" ]]; then cargo $BUILD_COMMAND --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 - - if [[ $TRAVIS_RUST_VERSION == "stable" ]]; then make package; fi - -deploy: - provider: releases - api_key: - secure: GcBxH6M6X9UU+5QBR4nEdNbXDfGpCrggZkPaztfK1vGAjmOyvHnK6P3M00C5Pf0nLmyWhGT5P0I4Rpy0z8WyQLOaHNWUuRGlRqlehWiJEmi6MpS2O8noJEfbLut9vYPpl0sdrtFrU5e0F77fWm5UWYQLMaeqXj66xv4lVxZp/JkXwhChTpU0PRJtSBuYiLFzbwz9CEjsvBXjw5ZzxmGTHnbw5p19B63yy3mORV91QQrRfCAHMg9z9zthpoZHEGqXXTIFuvh1DZqC5SHhUbt865MHMJS/2IaPH5zA/fOzZCCk6IvbNKLJ/ghE0zRJjHeVU4vjxNMxrFEBKVFCmQB7CpTqGCLy2qTB0tnSmNzqY82xUehl23jZ0LxnKODzCjx4hgfskWnr5p7Pv1Ql9UcAZXDV8UG+7JL34BQY4yyvknpTxK4MTXN9ZNahKJv+zSB9jDuLnB6uVbNV1hwFOUNm7KyAWA7XjFN7k8p4h678Xfg+EUWYxtV1auOItuXdxvzMWgDUDGmk74FdUWxy+GVzjboAmBMVRW/KMQFp4INIaS0gPRPK/jodLqrrZ+1otgYvMM/CsnOh4GLl86RTewuyid2jNnUeXepHPuU+JsDLLCJfyYoAfSxDCdQEuqNLAvpFPJJrBcWREVoqXWVUlWmwhEIWbLRUi2l5AhHnu+PfVhE= - skip_cleanup: true - overwrite: true - file_glob: true - file: dist/wgpu-*.zip - on: - repo: gfx-rs/wgpu - tags: true - condition: $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_BRANCH == $TRAVIS_TAG && ${TRAVIS_TAG::1} == "v" diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index d55279d6f..000000000 --- a/Cargo.lock +++ /dev/null @@ -1,830 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "arrayvec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ash" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libloading 0.5.2 (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 = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "battery" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", - "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "uom 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bitflags" -version = "1.2.1" -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 = "3.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cc" -version = "1.0.50" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cfg-if" -version = "0.1.10" -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.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "cocoa" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (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.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.19.0 (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.68 (registry+https://github.com/rust-lang/crates.io-index)", - "objc 0.2.7 (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.68 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "core-foundation" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.68 (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-foundation-sys" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "core-graphics" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation 0.7.0 (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.68 (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.2.1 (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.8 (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.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "gfx-auxil" -version = "0.3.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.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "spirv_cross 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "gfx-backend-dx11" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-auxil 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.10.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.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "spirv_cross 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (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.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (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.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (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.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "spirv_cross 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "gfx-backend-empty" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "gfx-backend-metal" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "cocoa 0.20.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.19.0 (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.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-hal 0.5.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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "metal 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", - "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.10.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.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "spirv_cross 0.18.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.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ash 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-hal 0.5.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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "x11 2.18.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "gfx-descriptor" -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.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "gfx-hal" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "gfx-memory" -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.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hibitset 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "hibitset" -version = "0.6.3" -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.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazycell" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.68" -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.50 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lock_api" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "mach" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.68 (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.68 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "metal" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "cocoa 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.19.0 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "nix" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "num-traits" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "objc" -version = "0.2.7" -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.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "objc_exception" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lock_api 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot_core" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (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.68 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "peek-poke" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "peek-poke-derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "peek-poke-derive" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pkg-config" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro2" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.9 (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.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.105" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde_derive 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_derive" -version = "1.0.105" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.17 (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 = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "spirv_cross" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.60 (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.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syn" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "synstructure" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "typenum" -version = "1.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "uom" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "typenum 1.11.2 (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 = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasm-bindgen" -version = "0.2.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bumpalo 3.2.1 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.60" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wgpu-core" -version = "0.5.0" -dependencies = [ - "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "battery 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (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.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-backend-dx12 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-backend-empty 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-backend-metal 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-backend-vulkan 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-descriptor 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-memory 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "wgpu-types 0.5.0", -] - -[[package]] -name = "wgpu-native" -version = "0.5.0" -dependencies = [ - "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", - "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "wgpu-core 0.5.0", - "wgpu-types 0.5.0", -] - -[[package]] -name = "wgpu-remote" -version = "0.1.0" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wgpu-core 0.5.0", - "wgpu-types 0.5.0", -] - -[[package]] -name = "wgpu-types" -version = "0.5.0" -dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi" -version = "0.3.8" -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.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "x11" -version = "2.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[metadata] -"checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" -"checksum ash 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)" = "69daec0742947f33a85931fa3cb0ce5f07929159dcbd1f0cbb5b2912e2978509" -"checksum atom 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3c86699c3f02778ec07158376991c8f783dd1f2f95c579ffaf0738dc984b2fe2" -"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -"checksum battery 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "36a698e449024a5d18994a815998bf5e2e4bc1883e35a7d7ba95b6b69ee45907" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -"checksum bumpalo 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187" -"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -"checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" -"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cocoa 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0a4736c86d51bd878b474400d9ec888156f4037015f5d09794fab9f26eab1ad4" -"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 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" -"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" -"checksum core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" -"checksum core-graphics 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "59e78b2e0aaf43f08e7ae0d6bc96895ef72ff0921c7d4ff4762201b2dba376dd" -"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 gfx-auxil 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b46e6f0031330a0be08d17820f2dcaaa91cb36710a97a9500cb4f1c36e785c8" -"checksum gfx-backend-dx11 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b148219292624126f78245e50a9720d95ea149a415ce8ce73ab7014205301b88" -"checksum gfx-backend-dx12 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0e526746379e974501551b08958947e67a81b5ea8cdc717a000cdd72577da05" -"checksum gfx-backend-empty 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b67bd2d7bc022b257ddbdabc5fa3b10c29c292372c3409f2b6a6e3f4e11cdb85" -"checksum gfx-backend-metal 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cfe128c29675b5afc8acdda1dfe096d6abd5e3528059ab0b98bda8215d8beed9" -"checksum gfx-backend-vulkan 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12b0e215ad54ffb7965ffaf6de6d0ec00143952ddf960d7d2255b539d129525d" -"checksum gfx-descriptor 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1bf35f5d66d1bc56e63e68d7528441453f25992bd954b84309d23c659df2c5da" -"checksum gfx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc96180204064c9493e0fe4a9efeb721e0ac59fe8e1906d0c659142a93114fb1" -"checksum gfx-memory 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12e0d05a5a1c849561bcc8b9cc1a79ad7d250c9bae458e1de477e184cd63fc5a" -"checksum hibitset 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "93a1bb8316a44459a7d14253c4d28dd7395cbd23cc04a68c46e851b8e46d64b1" -"checksum js-sys 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "6a27d435371a2fa5b6d2b028a74bbdb1234f308da363226a2854ca3ff8ba7055" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" -"checksum libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)" = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" -"checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -"checksum lock_api 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -"checksum metal 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e198a0ee42bdbe9ef2c09d0b9426f3b2b47d90d93a4a9b0395c4cea605e92dc0" -"checksum nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229" -"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" -"checksum objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -"checksum objc_exception 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" -"checksum parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" -"checksum parking_lot_core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" -"checksum peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d93fd6a575ebf1ac2668d08443c97a22872cfb463fd8b7ddd141e9f6be59af2f" -"checksum peek-poke-derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6fb44a25c5bba983be0fc8592dfaf3e6d0935ce8be0c6b15b2a39507af34a926" -"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" -"checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" -"checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" -"checksum range-alloc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5927936723a9e8b715d37d7e4b390455087c4bdf25b9f702309460577b14f9" -"checksum raw-window-handle 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211" -"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -"checksum serde 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)" = "e707fbbf255b8fc8c3b99abb91e7257a622caeb20a9818cbadbeeede4e0932ff" -"checksum serde_derive 1.0.105 (registry+https://github.com/rust-lang/crates.io-index)" = "ac5d00fc561ba2724df6758a17de23df5914f20e41cb00f94d5b7ae42fffaff8" -"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" -"checksum spirv_cross 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "946216f8793f7199e3ea5b995ee8dc20a0ace1fcf46293a0ef4c17e1d046dbde" -"checksum storage-map 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0a4829a5c591dc24a944a736d6b1e4053e51339a79fd5d4702c4c999a9c45e" -"checksum syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" -"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum uom 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4cec796ec5f7ac557631709079168286056205c51c60aac33f51764bdc7b8dc4" -"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" -"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f" -"checksum wasm-bindgen-backend 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd" -"checksum wasm-bindgen-macro 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4" -"checksum wasm-bindgen-macro-support 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931" -"checksum wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639" -"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -"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.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77ecd092546cb16f25783a5451538e73afc8d32e242648d54f4ae5459ba1e773" diff --git a/Cargo.toml b/Cargo.toml index 496b09cac..7958bd98a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,5 @@ [workspace] members = [ "wgpu-core", - "wgpu-native", - "wgpu-remote", "wgpu-types", ] diff --git a/Makefile b/Makefile deleted file mode 100644 index 6e3759664..000000000 --- a/Makefile +++ /dev/null @@ -1,117 +0,0 @@ -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 wgpu-core/**/*.rs) -WILDCARD_WGPU_REMOTE:=$(wildcard wgpu-remote/**/*.rs wgpu-core/**/*.rs) - -GIT_TAG=$(shell git describe --abbrev=0 --tags) -GIT_TAG_FULL=$(shell git describe --tags) -OS_NAME= - -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 - -ifeq ($(OS),Windows_NT) - LIB_EXTENSION=dll - OS_NAME=windows - ZIP_TOOL=7z -else - UNAME_S:=$(shell uname -s) - ZIP_TOOL=zip - ifeq ($(UNAME_S),Linux) - LIB_EXTENSION=so - OS_NAME=linux - endif - ifeq ($(UNAME_S),Darwin) - LIB_EXTENSION=dylib - OS_NAME=macos - endif -endif - - -.PHONY: all check test doc clear \ - example-compute example-triangle example-remote \ - run-example-compute run-example-triangle run-example-remote \ - lib-native lib-native-release \ - lib-remote - -#TODO: example-remote -all: example-compute example-triangle lib-remote - -package: lib-native lib-native-release - mkdir -p dist - echo "$(GIT_TAG_FULL)" > dist/commit-sha - for RELEASE in debug release; do \ - ARCHIVE=wgpu-$$RELEASE-$(OS_NAME)-$(GIT_TAG).zip; \ - rm -f dist/$$ARCHIVE; \ - if [ $(ZIP_TOOL) = zip ]; then \ - zip -j dist/$$ARCHIVE target/$$RELEASE/libwgpu_*.$(LIB_EXTENSION) ffi/*.h dist/commit-sha; \ - else \ - 7z a -tzip dist/$$ARCHIVE ./target/$$RELEASE/wgpu_*.$(LIB_EXTENSION) ./ffi/*.h ./dist/commit-sha; \ - fi; \ - done - -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 - -lib-native-release: Cargo.lock wgpu-native/Cargo.toml $(WILDCARD_WGPU_NATIVE) - cargo build --manifest-path wgpu-native/Cargo.toml --release - -lib-remote: Cargo.lock wgpu-remote/Cargo.toml $(WILDCARD_WGPU_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_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/README.md b/README.md index 585211491..641132ea1 100644 --- a/README.md +++ b/README.md @@ -9,22 +9,16 @@ This is an active GitHub mirror of the WebGPU implementation in Rust, which now [![Crates.io](https://img.shields.io/crates/v/wgpu-core.svg?label=wgpu-core)](https://crates.io/crates/wgpu-core) [![Crates.io](https://img.shields.io/crates/v/wgpu-native.svg?label=wgpu-native)](https://crates.io/crates/wgpu-native) -This is an experimental [WebGPU](https://www.w3.org/community/gpu/) implementation, exposing both Rust and C interfaces as a native static library. It's written in Rust and is based on [gfx-hal](https://github.com/gfx-rs/gfx) with help of [gfx-extras](https://github.com/gfx-rs/gfx-extras). See the upstream [WebGPU specification](https://gpuweb.github.io/gpuweb/) (work in progress). +This is the core logic of an experimental [WebGPU](https://www.w3.org/community/gpu/) implementation. It's written in Rust and is based on [gfx-hal](https://github.com/gfx-rs/gfx) with help of [gfx-extras](https://github.com/gfx-rs/gfx-extras). See the upstream [WebGPU specification](https://gpuweb.github.io/gpuweb/) (work in progress). The implementation consists of the following parts: - 1. `wgpu-core` - internal Rust API for WebGPU implementations to use - 2. `wgpu-native` - the native implementation of WebGPU as a C API library - 3. `wgpu-remote` - remoting layer to work with WebGPU across the process boundary, as a C API library used by Gecko - 4. `wgpu-types` - Rust types shared between `wgpu-core`, `wgpu-native`, `wgpu-remote`, and [`wgpu-rs`](https://github.com/gfx-rs/wgpu-rs) - 5. `ffi` - the C headers generated by [cbindgen](https://github.com/eqrion/cbindgen) for the native headers + - `wgpu-core` - internal Rust API for WebGPU implementations to use + - `wgpu-types` - Rust types shared between `wgpu-core`, `wgpu-native`, and `wgpu-rs` -# Bindings - -- [gfx-rs/wgpu-rs](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 -- [almarklein/wgpu-py](https://github.com/almarklein/wgpu-py) - experimental Python wrapper -- [porky11/wgpu](https://nest.pijul.com/porky11/wgpu) - experimental [Scopes](http://scopes.rocks) wrapper -- [cshenton/WebGPU.jl](https://github.com/cshenton/WebGPU.jl) - experimental Julia wrapper +This repository is not meant for direct use by applications. +If you are looking for the user-facing Rust API, you need [wgpu-rs](https://github.com/gfx-rs/wgpu-rs). +If you are looking for the native implementation or bindings to the API in other languages, you need [wgpu-native](https://github.com/gfx-rs/wgpu-native). ## Supported Platforms @@ -37,7 +31,3 @@ The implementation consists of the following parts: OpenGL | :construction: | :construction: | :construction: | :heavy_check_mark: = Primary support — :white_check_mark: = Secondary support — :construction: = Unsupported, but support in progress - -## 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. diff --git a/examples/compute/CMakeLists.txt b/examples/compute/CMakeLists.txt deleted file mode 100644 index d9fbfc752..000000000 --- a/examples/compute/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -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" "setupapi") -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/examples/compute/main.c b/examples/compute/main.c deleted file mode 100644 index 4c2624679..000000000 --- a/examples/compute/main.c +++ /dev/null @@ -1,153 +0,0 @@ -/* 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 BIND_ENTRIES_LENGTH (1) -#define BIND_GROUP_LAYOUTS_LENGTH (1) - -void request_adapter_callback(WGPUAdapterId received, void *userdata) { - *(WGPUAdapterId*)userdata = 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, - 2 | 4 | 8, - 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){ - .label = "buffer", - .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){ - .label = "bind group layout", - .entries = &(WGPUBindGroupLayoutEntry){ - .binding = 0, - .visibility = WGPUShaderStage_COMPUTE, - .ty = WGPUBindingType_StorageBuffer}, - .entries_length = BIND_ENTRIES_LENGTH}); - - WGPUBindingResource resource = { - .tag = WGPUBindingResource_Buffer, - .buffer = {(WGPUBufferBinding){ - .buffer = buffer, - .size = size, - .offset = 0}}}; - - WGPUBindGroupId bind_group = wgpu_device_create_bind_group(device, - &(WGPUBindGroupDescriptor){ - .label = "bind group", - .layout = bind_group_layout, - .entries = &(WGPUBindGroupEntry){ - .binding = 0, - .resource = resource}, - .entries_length = BIND_ENTRIES_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){ - .label = "command encoder", - }); - - 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_default_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/examples/data/collatz.comp b/examples/data/collatz.comp deleted file mode 100644 index d1ab4cfd2..000000000 --- a/examples/data/collatz.comp +++ /dev/null @@ -1,31 +0,0 @@ -#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/examples/data/collatz.comp.spv b/examples/data/collatz.comp.spv deleted file mode 100644 index 972544e0f..000000000 Binary files a/examples/data/collatz.comp.spv and /dev/null differ diff --git a/examples/data/triangle.frag b/examples/data/triangle.frag deleted file mode 100644 index 74e14f410..000000000 --- a/examples/data/triangle.frag +++ /dev/null @@ -1,7 +0,0 @@ -#version 450 - -layout(location = 0) out vec4 outColor; - -void main() { - outColor = vec4(1.0, 0.0, 0.0, 1.0); -} diff --git a/examples/data/triangle.frag.spv b/examples/data/triangle.frag.spv deleted file mode 100644 index 59e491519..000000000 Binary files a/examples/data/triangle.frag.spv and /dev/null differ diff --git a/examples/data/triangle.vert b/examples/data/triangle.vert deleted file mode 100644 index ac6dcc7c3..000000000 --- a/examples/data/triangle.vert +++ /dev/null @@ -1,15 +0,0 @@ -#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/examples/data/triangle.vert.spv b/examples/data/triangle.vert.spv deleted file mode 100644 index 9a3f5994b..000000000 Binary files a/examples/data/triangle.vert.spv and /dev/null differ diff --git a/examples/framework.c b/examples/framework.c deleted file mode 100644 index cc3976ccc..000000000 --- a/examples/framework.c +++ /dev/null @@ -1,29 +0,0 @@ -/* 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/examples/framework.h b/examples/framework.h deleted file mode 100644 index 106610c8e..000000000 --- a/examples/framework.h +++ /dev/null @@ -1,15 +0,0 @@ -/* 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/examples/remote/CMakeLists.txt b/examples/remote/CMakeLists.txt deleted file mode 100644 index 39c57a043..000000000 --- a/examples/remote/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -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/examples/remote/main.c b/examples/remote/main.c deleted file mode 100644 index 89fe71b4d..000000000 --- a/examples/remote/main.c +++ /dev/null @@ -1,57 +0,0 @@ -/* 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, - }; - 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/examples/triangle/CMakeLists.txt b/examples/triangle/CMakeLists.txt deleted file mode 100644 index 56a44db98..000000000 --- a/examples/triangle/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -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" "setupapi") -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) -if(USE_WAYLAND) - add_definitions(-DWGPU_TARGET=WGPU_TARGET_LINUX_WAYLAND) -else(USE_WAYLAND) - add_definitions(-DWGPU_TARGET=WGPU_TARGET_LINUX_X11) -endif(USE_WAYLAND) - 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/examples/triangle/main.c b/examples/triangle/main.c deleted file mode 100644 index 695335914..000000000 --- a/examples/triangle/main.c +++ /dev/null @@ -1,279 +0,0 @@ -/* 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_X11 2 -#define WGPU_TARGET_WINDOWS 3 -#define WGPU_TARGET_LINUX_WAYLAND 4 - -#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_X11 -#define GLFW_EXPOSE_NATIVE_X11 -#elif WGPU_TARGET == WGPU_TARGET_LINUX_WAYLAND -#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 received, void *userdata) { - *(WGPUAdapterId*)userdata = received; -} - -int main() { - 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_X11 - { - 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_LINUX_WAYLAND - { - struct wl_display *wayland_display = glfwGetWaylandDisplay(); - struct wl_surface *wayland_surface = glfwGetWaylandWindow(window); - surface = wgpu_create_surface_from_wayland(wayland_surface, wayland_display); - } -#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 - - WGPUAdapterId adapter = { 0 }; - wgpu_request_adapter_async( - &(WGPURequestAdapterOptions){ - .power_preference = WGPUPowerPreference_LowPower, - .compatible_surface = surface, - }, - 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){ - .label = "bind group layout", - .entries = NULL, - .entries_length = 0, - }); - WGPUBindGroupId bind_group = - wgpu_device_create_bind_group(device, - &(WGPUBindGroupDescriptor){ - .label = "bind group", - .layout = bind_group_layout, - .entries = NULL, - .entries_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_state = - (WGPUVertexStateDescriptor){ - .index_format = WGPUIndexFormat_Uint16, - .vertex_buffers = NULL, - .vertex_buffers_length = 0, - }, - .sample_count = 1, - }); - - 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_Fifo, - }); - - 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_Fifo, - }); - } - - 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){.label = "command encoder"}); - - 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_default_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/ffi/wgpu-remote.h b/ffi/wgpu-remote.h deleted file mode 100644 index 07aa16da3..000000000 --- a/ffi/wgpu-remote.h +++ /dev/null @@ -1,1453 +0,0 @@ -/* 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.14.0 */ - -/* 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 uint64_t WGPUNonZeroU64; -typedef uint64_t WGPUOption_AdapterId; -typedef uint64_t WGPUOption_SurfaceId; -typedef uint64_t WGPUOption_TextureViewId; - - -#include -#include -#include -#include - -/** - * Bound uniform/storage buffer offsets must be aligned to this number. - */ -#define WGPUBIND_BUFFER_ALIGNMENT 256 - -#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 - -enum WGPUAddressMode { - WGPUAddressMode_ClampToEdge = 0, - WGPUAddressMode_Repeat = 1, - WGPUAddressMode_MirrorRepeat = 2, - /** - * Must be last for serialization purposes - */ - WGPUAddressMode_Sentinel, -}; - -enum WGPUBindingType { - WGPUBindingType_UniformBuffer = 0, - WGPUBindingType_StorageBuffer = 1, - WGPUBindingType_ReadonlyStorageBuffer = 2, - WGPUBindingType_Sampler = 3, - WGPUBindingType_ComparisonSampler = 4, - WGPUBindingType_SampledTexture = 5, - WGPUBindingType_ReadonlyStorageTexture = 6, - WGPUBindingType_WriteonlyStorageTexture = 7, - /** - * Must be last for serialization purposes - */ - WGPUBindingType_Sentinel, -}; - -enum WGPUBlendFactor { - 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, - /** - * Must be last for serialization purposes - */ - WGPUBlendFactor_Sentinel, -}; - -enum WGPUBlendOperation { - WGPUBlendOperation_Add = 0, - WGPUBlendOperation_Subtract = 1, - WGPUBlendOperation_ReverseSubtract = 2, - WGPUBlendOperation_Min = 3, - WGPUBlendOperation_Max = 4, - /** - * Must be last for serialization purposes - */ - WGPUBlendOperation_Sentinel, -}; - -enum WGPUBufferMapAsyncStatus { - WGPUBufferMapAsyncStatus_Success, - WGPUBufferMapAsyncStatus_Error, - WGPUBufferMapAsyncStatus_Unknown, - WGPUBufferMapAsyncStatus_ContextLost, - /** - * Must be last for serialization purposes - */ - WGPUBufferMapAsyncStatus_Sentinel, -}; - -enum WGPUCompareFunction { - WGPUCompareFunction_Undefined = 0, - WGPUCompareFunction_Never = 1, - WGPUCompareFunction_Less = 2, - WGPUCompareFunction_Equal = 3, - WGPUCompareFunction_LessEqual = 4, - WGPUCompareFunction_Greater = 5, - WGPUCompareFunction_NotEqual = 6, - WGPUCompareFunction_GreaterEqual = 7, - WGPUCompareFunction_Always = 8, - /** - * Must be last for serialization purposes - */ - WGPUCompareFunction_Sentinel, -}; - -enum WGPUCullMode { - WGPUCullMode_None = 0, - WGPUCullMode_Front = 1, - WGPUCullMode_Back = 2, - /** - * Must be last for serialization purposes - */ - WGPUCullMode_Sentinel, -}; - -enum WGPUFilterMode { - WGPUFilterMode_Nearest = 0, - WGPUFilterMode_Linear = 1, - /** - * Must be last for serialization purposes - */ - WGPUFilterMode_Sentinel, -}; - -enum WGPUFrontFace { - WGPUFrontFace_Ccw = 0, - WGPUFrontFace_Cw = 1, - /** - * Must be last for serialization purposes - */ - WGPUFrontFace_Sentinel, -}; - -enum WGPUIndexFormat { - WGPUIndexFormat_Uint16 = 0, - WGPUIndexFormat_Uint32 = 1, - /** - * Must be last for serialization purposes - */ - WGPUIndexFormat_Sentinel, -}; - -enum WGPUInputStepMode { - WGPUInputStepMode_Vertex = 0, - WGPUInputStepMode_Instance = 1, - /** - * Must be last for serialization purposes - */ - WGPUInputStepMode_Sentinel, -}; - -enum WGPULoadOp { - WGPULoadOp_Clear = 0, - WGPULoadOp_Load = 1, - /** - * Must be last for serialization purposes - */ - WGPULoadOp_Sentinel, -}; - -enum WGPUPowerPreference { - WGPUPowerPreference_Default = 0, - WGPUPowerPreference_LowPower = 1, - WGPUPowerPreference_HighPerformance = 2, - /** - * Must be last for serialization purposes - */ - WGPUPowerPreference_Sentinel, -}; - -enum WGPUPrimitiveTopology { - WGPUPrimitiveTopology_PointList = 0, - WGPUPrimitiveTopology_LineList = 1, - WGPUPrimitiveTopology_LineStrip = 2, - WGPUPrimitiveTopology_TriangleList = 3, - WGPUPrimitiveTopology_TriangleStrip = 4, - /** - * Must be last for serialization purposes - */ - WGPUPrimitiveTopology_Sentinel, -}; - -enum WGPUStencilOperation { - WGPUStencilOperation_Keep = 0, - WGPUStencilOperation_Zero = 1, - WGPUStencilOperation_Replace = 2, - WGPUStencilOperation_Invert = 3, - WGPUStencilOperation_IncrementClamp = 4, - WGPUStencilOperation_DecrementClamp = 5, - WGPUStencilOperation_IncrementWrap = 6, - WGPUStencilOperation_DecrementWrap = 7, - /** - * Must be last for serialization purposes - */ - WGPUStencilOperation_Sentinel, -}; - -enum WGPUStoreOp { - WGPUStoreOp_Clear = 0, - WGPUStoreOp_Store = 1, - /** - * Must be last for serialization purposes - */ - WGPUStoreOp_Sentinel, -}; - -enum WGPUTextureAspect { - WGPUTextureAspect_All, - WGPUTextureAspect_StencilOnly, - WGPUTextureAspect_DepthOnly, - /** - * Must be last for serialization purposes - */ - WGPUTextureAspect_Sentinel, -}; - -enum WGPUTextureComponentType { - WGPUTextureComponentType_Float, - WGPUTextureComponentType_Sint, - WGPUTextureComponentType_Uint, - /** - * Must be last for serialization purposes - */ - WGPUTextureComponentType_Sentinel, -}; - -enum WGPUTextureDimension { - WGPUTextureDimension_D1, - WGPUTextureDimension_D2, - WGPUTextureDimension_D3, - /** - * Must be last for serialization purposes - */ - WGPUTextureDimension_Sentinel, -}; - -enum WGPUTextureFormat { - WGPUTextureFormat_R8Unorm = 0, - WGPUTextureFormat_R8Snorm = 1, - WGPUTextureFormat_R8Uint = 2, - WGPUTextureFormat_R8Sint = 3, - WGPUTextureFormat_R16Uint = 4, - WGPUTextureFormat_R16Sint = 5, - WGPUTextureFormat_R16Float = 6, - WGPUTextureFormat_Rg8Unorm = 7, - WGPUTextureFormat_Rg8Snorm = 8, - WGPUTextureFormat_Rg8Uint = 9, - WGPUTextureFormat_Rg8Sint = 10, - WGPUTextureFormat_R32Uint = 11, - WGPUTextureFormat_R32Sint = 12, - WGPUTextureFormat_R32Float = 13, - WGPUTextureFormat_Rg16Uint = 14, - WGPUTextureFormat_Rg16Sint = 15, - WGPUTextureFormat_Rg16Float = 16, - WGPUTextureFormat_Rgba8Unorm = 17, - WGPUTextureFormat_Rgba8UnormSrgb = 18, - WGPUTextureFormat_Rgba8Snorm = 19, - WGPUTextureFormat_Rgba8Uint = 20, - WGPUTextureFormat_Rgba8Sint = 21, - WGPUTextureFormat_Bgra8Unorm = 22, - WGPUTextureFormat_Bgra8UnormSrgb = 23, - WGPUTextureFormat_Rgb10a2Unorm = 24, - WGPUTextureFormat_Rg11b10Float = 25, - WGPUTextureFormat_Rg32Uint = 26, - WGPUTextureFormat_Rg32Sint = 27, - WGPUTextureFormat_Rg32Float = 28, - WGPUTextureFormat_Rgba16Uint = 29, - WGPUTextureFormat_Rgba16Sint = 30, - WGPUTextureFormat_Rgba16Float = 31, - WGPUTextureFormat_Rgba32Uint = 32, - WGPUTextureFormat_Rgba32Sint = 33, - WGPUTextureFormat_Rgba32Float = 34, - WGPUTextureFormat_Depth32Float = 35, - WGPUTextureFormat_Depth24Plus = 36, - WGPUTextureFormat_Depth24PlusStencil8 = 37, - /** - * Must be last for serialization purposes - */ - WGPUTextureFormat_Sentinel, -}; - -enum WGPUTextureViewDimension { - WGPUTextureViewDimension_D1, - WGPUTextureViewDimension_D2, - WGPUTextureViewDimension_D2Array, - WGPUTextureViewDimension_Cube, - WGPUTextureViewDimension_CubeArray, - WGPUTextureViewDimension_D3, - /** - * Must be last for serialization purposes - */ - WGPUTextureViewDimension_Sentinel, -}; - -enum WGPUVertexFormat { - 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, - /** - * Must be last for serialization purposes - */ - WGPUVertexFormat_Sentinel, -}; - -struct WGPUClient; - -struct WGPUGlobal_IdentityRecyclerFactory; - -typedef WGPUNonZeroU64 WGPUId_Adapter_Dummy; - -typedef WGPUId_Adapter_Dummy WGPUAdapterId; - -typedef WGPUNonZeroU64 WGPUId_BindGroup_Dummy; - -typedef WGPUId_BindGroup_Dummy WGPUBindGroupId; - -typedef WGPUNonZeroU64 WGPUId_BindGroupLayout_Dummy; - -typedef WGPUId_BindGroupLayout_Dummy WGPUBindGroupLayoutId; - -typedef WGPUNonZeroU64 WGPUId_Buffer_Dummy; - -typedef WGPUId_Buffer_Dummy WGPUBufferId; - -typedef WGPUNonZeroU64 WGPUId_ComputePipeline_Dummy; - -typedef WGPUId_ComputePipeline_Dummy WGPUComputePipelineId; - -typedef WGPUNonZeroU64 WGPUId_Device_Dummy; - -typedef WGPUId_Device_Dummy WGPUDeviceId; - -typedef WGPUNonZeroU64 WGPUId_CommandBuffer_Dummy; - -typedef WGPUId_CommandBuffer_Dummy WGPUCommandBufferId; - -typedef WGPUCommandBufferId WGPUCommandEncoderId; - -typedef WGPUNonZeroU64 WGPUId_PipelineLayout_Dummy; - -typedef WGPUId_PipelineLayout_Dummy WGPUPipelineLayoutId; - -typedef WGPUNonZeroU64 WGPUId_RenderPipeline_Dummy; - -typedef WGPUId_RenderPipeline_Dummy WGPURenderPipelineId; - -typedef WGPUNonZeroU64 WGPUId_Sampler_Dummy; - -typedef WGPUId_Sampler_Dummy WGPUSamplerId; - -typedef WGPUNonZeroU64 WGPUId_ShaderModule_Dummy; - -typedef WGPUId_ShaderModule_Dummy WGPUShaderModuleId; - -typedef WGPUNonZeroU64 WGPUId_Texture_Dummy; - -typedef WGPUId_Texture_Dummy WGPUTextureId; - -typedef WGPUNonZeroU64 WGPUId_TextureView_Dummy; - -typedef WGPUId_TextureView_Dummy WGPUTextureViewId; - -struct WGPUInfrastructure { - struct WGPUClient *client; - const uint8_t *error; -}; - -struct WGPURawPass { - uint8_t *data; - uint8_t *base; - uintptr_t capacity; - WGPUCommandEncoderId parent; -}; - -struct WGPUComputePassDescriptor { - uint32_t todo; -}; - -struct WGPUColor { - double r; - double g; - double b; - double a; -}; -#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 } - -struct WGPURenderPassColorAttachmentDescriptorBase_TextureViewId { - WGPUTextureViewId attachment; - WGPUOption_TextureViewId resolve_target; - enum WGPULoadOp load_op; - enum WGPUStoreOp store_op; - struct WGPUColor clear_color; -}; - -typedef struct WGPURenderPassColorAttachmentDescriptorBase_TextureViewId WGPURenderPassColorAttachmentDescriptor; - -struct WGPURenderPassDepthStencilAttachmentDescriptorBase_TextureViewId { - WGPUTextureViewId attachment; - enum WGPULoadOp depth_load_op; - enum WGPUStoreOp depth_store_op; - float clear_depth; - enum WGPULoadOp stencil_load_op; - enum WGPUStoreOp stencil_store_op; - uint32_t clear_stencil; -}; - -typedef struct WGPURenderPassDepthStencilAttachmentDescriptorBase_TextureViewId WGPURenderPassDepthStencilAttachmentDescriptor; - -struct WGPURenderPassDescriptor { - const WGPURenderPassColorAttachmentDescriptor *color_attachments; - uintptr_t color_attachments_length; - const WGPURenderPassDepthStencilAttachmentDescriptor *depth_stencil_attachment; -}; - -typedef uint64_t WGPUBufferAddress; - -typedef const char *WGPURawString; - -typedef uint32_t WGPUDynamicOffset; - -typedef WGPUNonZeroU64 WGPUId_RenderBundle_Dummy; - -typedef WGPUId_RenderBundle_Dummy WGPURenderBundleId; - -typedef struct WGPUGlobal_IdentityRecyclerFactory WGPUGlobal; - -struct WGPUExtensions { - bool anisotropic_filtering; -}; - -struct WGPULimits { - uint32_t max_bind_groups; -}; - -struct WGPUDeviceDescriptor { - struct WGPUExtensions extensions; - struct WGPULimits limits; -}; - -typedef void (*WGPUBufferMapReadCallback)(enum WGPUBufferMapAsyncStatus status, const uint8_t *data, uint8_t *userdata); - -struct WGPUBufferBinding { - WGPUBufferId buffer; - WGPUBufferAddress offset; - WGPUBufferAddress size; -}; - -enum WGPUBindingResource_Tag { - WGPUBindingResource_Buffer, - WGPUBindingResource_Sampler, - WGPUBindingResource_TextureView, - /** - * Must be last for serialization purposes - */ - WGPUBindingResource_Sentinel, -}; - -struct WGPUBindingResource_WGPUBuffer_Body { - struct WGPUBufferBinding _0; -}; - -struct WGPUBindingResource_WGPUSampler_Body { - WGPUSamplerId _0; -}; - -struct WGPUBindingResource_WGPUTextureView_Body { - WGPUTextureViewId _0; -}; - -struct WGPUBindingResource { - enum WGPUBindingResource_Tag tag; - union { - struct WGPUBindingResource_WGPUBuffer_Body buffer; - struct WGPUBindingResource_WGPUSampler_Body sampler; - struct WGPUBindingResource_WGPUTextureView_Body texture_view; - }; -}; - -struct WGPUBindGroupEntry { - uint32_t binding; - struct WGPUBindingResource resource; -}; - -struct WGPUBindGroupDescriptor { - const char *label; - WGPUBindGroupLayoutId layout; - const struct WGPUBindGroupEntry *entries; - uintptr_t entries_length; -}; - -typedef uint32_t WGPUShaderStage; -#define WGPUShaderStage_NONE 0 -#define WGPUShaderStage_VERTEX 1 -#define WGPUShaderStage_FRAGMENT 2 -#define WGPUShaderStage_COMPUTE 4 - -struct WGPUBindGroupLayoutEntry { - uint32_t binding; - WGPUShaderStage visibility; - enum WGPUBindingType ty; - bool multisampled; - bool has_dynamic_offset; - enum WGPUTextureViewDimension view_dimension; - enum WGPUTextureComponentType texture_component_type; - enum WGPUTextureFormat storage_texture_format; -}; - -struct WGPUBindGroupLayoutDescriptor { - const char *label; - const struct WGPUBindGroupLayoutEntry *entries; - uintptr_t entries_length; -}; - -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_INDIRECT 256 -#define WGPUBufferUsage_STORAGE_READ 512 -#define WGPUBufferUsage_NONE 0 - -struct WGPUBufferDescriptor { - const char *label; - WGPUBufferAddress size; - WGPUBufferUsage usage; -}; - -struct WGPUProgrammableStageDescriptor { - WGPUShaderModuleId module; - WGPURawString entry_point; -}; - -struct WGPUComputePipelineDescriptor { - WGPUPipelineLayoutId layout; - struct WGPUProgrammableStageDescriptor compute_stage; -}; - -struct WGPUCommandEncoderDescriptor { - const char *label; -}; - -struct WGPUPipelineLayoutDescriptor { - const WGPUBindGroupLayoutId *bind_group_layouts; - uintptr_t bind_group_layouts_length; -}; - -struct WGPURasterizationStateDescriptor { - enum WGPUFrontFace front_face; - enum WGPUCullMode cull_mode; - int32_t depth_bias; - float depth_bias_slope_scale; - float depth_bias_clamp; -}; - -struct WGPUBlendDescriptor { - enum WGPUBlendFactor src_factor; - enum WGPUBlendFactor dst_factor; - enum WGPUBlendOperation operation; -}; - -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 - -struct WGPUColorStateDescriptor { - enum WGPUTextureFormat format; - struct WGPUBlendDescriptor alpha_blend; - struct WGPUBlendDescriptor color_blend; - WGPUColorWrite write_mask; -}; - -struct WGPUStencilStateFaceDescriptor { - enum WGPUCompareFunction compare; - enum WGPUStencilOperation fail_op; - enum WGPUStencilOperation depth_fail_op; - enum WGPUStencilOperation pass_op; -}; - -struct WGPUDepthStencilStateDescriptor { - enum WGPUTextureFormat format; - bool depth_write_enabled; - enum WGPUCompareFunction depth_compare; - struct WGPUStencilStateFaceDescriptor stencil_front; - struct WGPUStencilStateFaceDescriptor stencil_back; - uint32_t stencil_read_mask; - uint32_t stencil_write_mask; -}; - -typedef uint32_t WGPUShaderLocation; - -struct WGPUVertexAttributeDescriptor { - WGPUBufferAddress offset; - enum WGPUVertexFormat format; - WGPUShaderLocation shader_location; -}; - -struct WGPUVertexBufferLayoutDescriptor { - WGPUBufferAddress array_stride; - enum WGPUInputStepMode step_mode; - const struct WGPUVertexAttributeDescriptor *attributes; - uintptr_t attributes_length; -}; - -struct WGPUVertexStateDescriptor { - enum WGPUIndexFormat index_format; - const struct WGPUVertexBufferLayoutDescriptor *vertex_buffers; - uintptr_t vertex_buffers_length; -}; - -struct WGPURenderPipelineDescriptor { - WGPUPipelineLayoutId layout; - struct WGPUProgrammableStageDescriptor vertex_stage; - const struct WGPUProgrammableStageDescriptor *fragment_stage; - enum WGPUPrimitiveTopology primitive_topology; - const struct WGPURasterizationStateDescriptor *rasterization_state; - const struct WGPUColorStateDescriptor *color_states; - uintptr_t color_states_length; - const struct WGPUDepthStencilStateDescriptor *depth_stencil_state; - struct WGPUVertexStateDescriptor vertex_state; - uint32_t sample_count; - uint32_t sample_mask; - bool alpha_to_coverage_enabled; -}; - -struct WGPUSamplerDescriptor { - enum WGPUAddressMode address_mode_u; - enum WGPUAddressMode address_mode_v; - enum WGPUAddressMode address_mode_w; - enum WGPUFilterMode mag_filter; - enum WGPUFilterMode min_filter; - enum WGPUFilterMode mipmap_filter; - float lod_min_clamp; - float lod_max_clamp; - enum WGPUCompareFunction compare; -}; - -struct WGPUU32Array { - const uint32_t *bytes; - uintptr_t length; -}; - -struct WGPUShaderModuleDescriptor { - struct WGPUU32Array code; -}; - -struct WGPUExtent3d { - uint32_t width; - uint32_t height; - uint32_t depth; -}; - -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 - -struct WGPUTextureDescriptor { - const char *label; - struct WGPUExtent3d size; - uint32_t array_layer_count; - uint32_t mip_level_count; - uint32_t sample_count; - enum WGPUTextureDimension dimension; - enum WGPUTextureFormat format; - WGPUTextureUsage usage; -}; - -struct WGPUBufferCopyView { - WGPUBufferId buffer; - WGPUBufferAddress offset; - uint32_t bytes_per_row; - uint32_t rows_per_image; -}; - -struct WGPUOrigin3d { - uint32_t x; - uint32_t y; - uint32_t z; -}; -#define WGPUOrigin3d_ZERO (WGPUOrigin3d){ .x = 0, .y = 0, .z = 0 } - -struct WGPUTextureCopyView { - WGPUTextureId texture; - uint32_t mip_level; - uint32_t array_layer; - struct WGPUOrigin3d origin; -}; - -struct WGPUCommandBufferDescriptor { - uint32_t todo; -}; - -struct WGPURequestAdapterOptions { - enum WGPUPowerPreference power_preference; - WGPUOption_SurfaceId compatible_surface; -}; - -typedef void *WGPUFactoryParam; - -typedef WGPUNonZeroU64 WGPUId_SwapChain_Dummy; - -typedef WGPUId_SwapChain_Dummy WGPUSwapChainId; - -typedef WGPUNonZeroU64 WGPUId_Surface; - -typedef WGPUId_Surface WGPUSurfaceId; - -struct WGPUIdentityRecyclerFactory { - WGPUFactoryParam param; - void (*free_adapter)(WGPUAdapterId, WGPUFactoryParam); - void (*free_device)(WGPUDeviceId, WGPUFactoryParam); - void (*free_swap_chain)(WGPUSwapChainId, WGPUFactoryParam); - void (*free_pipeline_layout)(WGPUPipelineLayoutId, WGPUFactoryParam); - void (*free_shader_module)(WGPUShaderModuleId, WGPUFactoryParam); - void (*free_bind_group_layout)(WGPUBindGroupLayoutId, WGPUFactoryParam); - void (*free_bind_group)(WGPUBindGroupId, WGPUFactoryParam); - void (*free_command_buffer)(WGPUCommandBufferId, WGPUFactoryParam); - void (*free_render_pipeline)(WGPURenderPipelineId, WGPUFactoryParam); - void (*free_compute_pipeline)(WGPUComputePipelineId, WGPUFactoryParam); - void (*free_buffer)(WGPUBufferId, WGPUFactoryParam); - void (*free_texture)(WGPUTextureId, WGPUFactoryParam); - void (*free_texture_view)(WGPUTextureViewId, WGPUFactoryParam); - void (*free_sampler)(WGPUSamplerId, WGPUFactoryParam); - void (*free_surface)(WGPUSurfaceId, WGPUFactoryParam); -}; - -typedef WGPUDeviceId WGPUQueueId; - -struct WGPUTextureViewDescriptor { - enum WGPUTextureFormat format; - enum WGPUTextureViewDimension dimension; - enum WGPUTextureAspect aspect; - uint32_t base_mip_level; - uint32_t level_count; - uint32_t base_array_layer; - uint32_t array_layer_count; -}; - -/** - * # Safety - * - * This function is unsafe because improper use may lead to memory - * problems. For example, a double-free may occur if the function is called - * twice on the same raw pointer. - */ -WGPU_INLINE -void wgpu_client_delete(struct WGPUClient *aClient) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_adapter_id(const struct WGPUClient *aClient, - WGPUAdapterId aId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_bind_group_id(const struct WGPUClient *aClient, - WGPUBindGroupId aId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_bind_group_layout_id(const struct WGPUClient *aClient, - WGPUBindGroupLayoutId aId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_buffer_id(const struct WGPUClient *aClient, - WGPUBufferId aId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_compute_pipeline_id(const struct WGPUClient *aClient, - WGPUComputePipelineId aId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_device_id(const struct WGPUClient *aClient, - WGPUDeviceId aId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_encoder_id(const struct WGPUClient *aClient, - WGPUCommandEncoderId aId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_pipeline_layout_id(const struct WGPUClient *aClient, - WGPUPipelineLayoutId aId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_render_pipeline_id(const struct WGPUClient *aClient, - WGPURenderPipelineId aId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_sampler_id(const struct WGPUClient *aClient, - WGPUSamplerId aId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_shader_module_id(const struct WGPUClient *aClient, - WGPUShaderModuleId aId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_texture_id(const struct WGPUClient *aClient, - WGPUTextureId aId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_client_kill_texture_view_id(const struct WGPUClient *aClient, - WGPUTextureViewId aId) -WGPU_FUNC; - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointer is - * valid for `id_length` elements. - */ -WGPU_INLINE -uintptr_t wgpu_client_make_adapter_ids(const struct WGPUClient *aClient, - WGPUAdapterId *aIds, - uintptr_t aIdLength) -WGPU_FUNC; - -WGPU_INLINE -WGPUBindGroupId wgpu_client_make_bind_group_id(const struct WGPUClient *aClient, - WGPUDeviceId aDeviceId) -WGPU_FUNC; - -WGPU_INLINE -WGPUBindGroupLayoutId wgpu_client_make_bind_group_layout_id(const struct WGPUClient *aClient, - WGPUDeviceId aDeviceId) -WGPU_FUNC; - -WGPU_INLINE -WGPUBufferId wgpu_client_make_buffer_id(const struct WGPUClient *aClient, - WGPUDeviceId aDeviceId) -WGPU_FUNC; - -WGPU_INLINE -WGPUComputePipelineId wgpu_client_make_compute_pipeline_id(const struct WGPUClient *aClient, - WGPUDeviceId aDeviceId) -WGPU_FUNC; - -WGPU_INLINE -WGPUDeviceId wgpu_client_make_device_id(const struct WGPUClient *aClient, - WGPUAdapterId aAdapterId) -WGPU_FUNC; - -WGPU_INLINE -WGPUCommandEncoderId wgpu_client_make_encoder_id(const struct WGPUClient *aClient, - WGPUDeviceId aDeviceId) -WGPU_FUNC; - -WGPU_INLINE -WGPUPipelineLayoutId wgpu_client_make_pipeline_layout_id(const struct WGPUClient *aClient, - WGPUDeviceId aDeviceId) -WGPU_FUNC; - -WGPU_INLINE -WGPURenderPipelineId wgpu_client_make_render_pipeline_id(const struct WGPUClient *aClient, - WGPUDeviceId aDeviceId) -WGPU_FUNC; - -WGPU_INLINE -WGPUSamplerId wgpu_client_make_sampler_id(const struct WGPUClient *aClient, - WGPUDeviceId aDeviceId) -WGPU_FUNC; - -WGPU_INLINE -WGPUShaderModuleId wgpu_client_make_shader_module_id(const struct WGPUClient *aClient, - WGPUDeviceId aDeviceId) -WGPU_FUNC; - -WGPU_INLINE -WGPUTextureId wgpu_client_make_texture_id(const struct WGPUClient *aClient, - WGPUDeviceId aDeviceId) -WGPU_FUNC; - -WGPU_INLINE -WGPUTextureViewId wgpu_client_make_texture_view_id(const struct WGPUClient *aClient, - WGPUDeviceId aDeviceId) -WGPU_FUNC; - -WGPU_INLINE -struct WGPUInfrastructure wgpu_client_new(void) -WGPU_FUNC; - -WGPU_INLINE -struct WGPURawPass wgpu_command_encoder_begin_compute_pass(WGPUCommandEncoderId aEncoderId, - const struct WGPUComputePassDescriptor *aDesc) -WGPU_FUNC; - -WGPU_INLINE -struct WGPURawPass wgpu_command_encoder_begin_render_pass(WGPUCommandEncoderId aEncoderId, - const struct WGPURenderPassDescriptor *aDesc) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_compute_pass_destroy(struct WGPURawPass aPass) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_compute_pass_dispatch(struct WGPURawPass *aPass, - uint32_t aGroupsX, - uint32_t aGroupsY, - uint32_t aGroupsZ) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_compute_pass_dispatch_indirect(struct WGPURawPass *aPass, - WGPUBufferId aBufferId, - WGPUBufferAddress aOffset) -WGPU_FUNC; - -WGPU_INLINE -const uint8_t *wgpu_compute_pass_finish(struct WGPURawPass *aPass, - uintptr_t *aLength) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_compute_pass_insert_debug_marker(struct WGPURawPass *aPass, - WGPURawString aLabel) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_compute_pass_pop_debug_group(struct WGPURawPass *aPass) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_compute_pass_push_debug_group(struct WGPURawPass *aPass, - WGPURawString aLabel) -WGPU_FUNC; - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointer is - * valid for `offset_length` elements. - */ -WGPU_INLINE -void wgpu_compute_pass_set_bind_group(struct WGPURawPass *aPass, - uint32_t aIndex, - WGPUBindGroupId aBindGroupId, - const WGPUDynamicOffset *aOffsets, - uintptr_t aOffsetLength) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_compute_pass_set_pipeline(struct WGPURawPass *aPass, - WGPUComputePipelineId aPipelineId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_destroy(struct WGPURawPass aPass) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_draw(struct WGPURawPass *aPass, - uint32_t aVertexCount, - uint32_t aInstanceCount, - uint32_t aFirstVertex, - uint32_t aFirstInstance) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_draw_indexed(struct WGPURawPass *aPass, - uint32_t aIndexCount, - uint32_t aInstanceCount, - uint32_t aFirstIndex, - int32_t aBaseVertex, - uint32_t aFirstInstance) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_draw_indexed_indirect(struct WGPURawPass *aPass, - WGPUBufferId aBufferId, - WGPUBufferAddress aOffset) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_draw_indirect(struct WGPURawPass *aPass, - WGPUBufferId aBufferId, - WGPUBufferAddress aOffset) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_execute_bundles(struct WGPURawPass *aPass, - const WGPURenderBundleId *aBundles, - uintptr_t aBundlesLength) -WGPU_FUNC; - -WGPU_INLINE -const uint8_t *wgpu_render_pass_finish(struct WGPURawPass *aPass, - uintptr_t *aLength) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_insert_debug_marker(struct WGPURawPass *aPass, - WGPURawString aLabel) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_pop_debug_group(struct WGPURawPass *aPass) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_push_debug_group(struct WGPURawPass *aPass, - WGPURawString aLabel) -WGPU_FUNC; - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointer is - * valid for `offset_length` elements. - */ -WGPU_INLINE -void wgpu_render_pass_set_bind_group(struct WGPURawPass *aPass, - uint32_t aIndex, - WGPUBindGroupId aBindGroupId, - const WGPUDynamicOffset *aOffsets, - uintptr_t aOffsetLength) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_set_blend_color(struct WGPURawPass *aPass, - const struct WGPUColor *aColor) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_set_index_buffer(struct WGPURawPass *aPass, - WGPUBufferId aBufferId, - WGPUBufferAddress aOffset, - WGPUBufferAddress aSize) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_set_pipeline(struct WGPURawPass *aPass, - WGPURenderPipelineId aPipelineId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_set_scissor_rect(struct WGPURawPass *aPass, - uint32_t aX, - uint32_t aY, - uint32_t aW, - uint32_t aH) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_set_stencil_reference(struct WGPURawPass *aPass, - uint32_t aValue) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_set_vertex_buffer(struct WGPURawPass *aPass, - uint32_t aSlot, - WGPUBufferId aBufferId, - WGPUBufferAddress aOffset, - WGPUBufferAddress aSize) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_render_pass_set_viewport(struct WGPURawPass *aPass, - float aX, - float aY, - float aW, - float aH, - float aDepthMin, - float aDepthMax) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_adapter_destroy(const WGPUGlobal *aGlobal, - WGPUAdapterId aAdapterId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_adapter_request_device(const WGPUGlobal *aGlobal, - WGPUAdapterId aSelfId, - const struct WGPUDeviceDescriptor *aDesc, - WGPUDeviceId aNewId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_bind_group_destroy(const WGPUGlobal *aGlobal, - WGPUBindGroupId aSelfId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_bind_group_layout_destroy(const WGPUGlobal *aGlobal, - WGPUBindGroupLayoutId aSelfId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_buffer_destroy(const WGPUGlobal *aGlobal, - WGPUBufferId aSelfId) -WGPU_FUNC; - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointer is - * valid for `size` elements. - */ -WGPU_INLINE -void wgpu_server_buffer_map_read(const WGPUGlobal *aGlobal, - WGPUBufferId aBufferId, - WGPUBufferAddress aStart, - WGPUBufferAddress aSize, - WGPUBufferMapReadCallback aCallback, - uint8_t *aUserdata) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_buffer_unmap(const WGPUGlobal *aGlobal, - WGPUBufferId aBufferId) -WGPU_FUNC; - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointer is - * valid for `byte_length` elements. - */ -WGPU_INLINE -void wgpu_server_command_buffer_destroy(const WGPUGlobal *aGlobal, - WGPUCommandBufferId aSelfId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_compute_pipeline_destroy(const WGPUGlobal *aGlobal, - WGPUComputePipelineId aSelfId) -WGPU_FUNC; - -/** - * # Safety - * - * This function is unsafe because improper use may lead to memory - * problems. For example, a double-free may occur if the function is called - * twice on the same raw pointer. - */ -WGPU_INLINE -void wgpu_server_delete(WGPUGlobal *aGlobal) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_device_create_bind_group(const WGPUGlobal *aGlobal, - WGPUDeviceId aSelfId, - const struct WGPUBindGroupDescriptor *aDesc, - WGPUBindGroupId aNewId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_device_create_bind_group_layout(const WGPUGlobal *aGlobal, - WGPUDeviceId aSelfId, - const struct WGPUBindGroupLayoutDescriptor *aDesc, - WGPUBindGroupLayoutId aNewId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_device_create_buffer(const WGPUGlobal *aGlobal, - WGPUDeviceId aSelfId, - const struct WGPUBufferDescriptor *aDesc, - WGPUBufferId aNewId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_device_create_compute_pipeline(const WGPUGlobal *aGlobal, - WGPUDeviceId aSelfId, - const struct WGPUComputePipelineDescriptor *aDesc, - WGPUComputePipelineId aNewId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_device_create_encoder(const WGPUGlobal *aGlobal, - WGPUDeviceId aSelfId, - const struct WGPUCommandEncoderDescriptor *aDesc, - WGPUCommandEncoderId aNewId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_device_create_pipeline_layout(const WGPUGlobal *aGlobal, - WGPUDeviceId aSelfId, - const struct WGPUPipelineLayoutDescriptor *aDesc, - WGPUPipelineLayoutId aNewId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_device_create_render_pipeline(const WGPUGlobal *aGlobal, - WGPUDeviceId aSelfId, - const struct WGPURenderPipelineDescriptor *aDesc, - WGPURenderPipelineId aNewId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_device_create_sampler(const WGPUGlobal *aGlobal, - WGPUDeviceId aSelfId, - const struct WGPUSamplerDescriptor *aDesc, - WGPUSamplerId aNewId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_device_create_shader_module(const WGPUGlobal *aGlobal, - WGPUDeviceId aSelfId, - const struct WGPUShaderModuleDescriptor *aDesc, - WGPUShaderModuleId aNewId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_device_create_texture(const WGPUGlobal *aGlobal, - WGPUDeviceId aSelfId, - const struct WGPUTextureDescriptor *aDesc, - WGPUTextureId aNewId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_device_destroy(const WGPUGlobal *aGlobal, - WGPUDeviceId aSelfId) -WGPU_FUNC; - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointer is - * valid for `size` elements. - */ -WGPU_INLINE -void wgpu_server_device_set_buffer_sub_data(const WGPUGlobal *aGlobal, - WGPUDeviceId aSelfId, - WGPUBufferId aBufferId, - WGPUBufferAddress aOffset, - const uint8_t *aData, - WGPUBufferAddress aSize) -WGPU_FUNC; - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointers are - * valid for `color_attachments_length` and `command_length` elements, - * respectively. - */ -WGPU_INLINE -void wgpu_server_encode_compute_pass(const WGPUGlobal *aGlobal, - WGPUCommandEncoderId aSelfId, - const uint8_t *aBytes, - uintptr_t aByteLength) -WGPU_FUNC; - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointers are - * valid for `color_attachments_length` and `command_length` elements, - * respectively. - */ -WGPU_INLINE -void wgpu_server_encode_render_pass(const WGPUGlobal *aGlobal, - WGPUCommandEncoderId aSelfId, - const uint8_t *aCommands, - uintptr_t aCommandLength) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_encoder_copy_buffer_to_buffer(const WGPUGlobal *aGlobal, - WGPUCommandEncoderId aSelfId, - WGPUBufferId aSourceId, - WGPUBufferAddress aSourceOffset, - WGPUBufferId aDestinationId, - WGPUBufferAddress aDestinationOffset, - WGPUBufferAddress aSize) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_encoder_copy_buffer_to_texture(const WGPUGlobal *aGlobal, - WGPUCommandEncoderId aSelfId, - const struct WGPUBufferCopyView *aSource, - const struct WGPUTextureCopyView *aDestination, - struct WGPUExtent3d aSize) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_encoder_copy_texture_to_buffer(const WGPUGlobal *aGlobal, - WGPUCommandEncoderId aSelfId, - const struct WGPUTextureCopyView *aSource, - const struct WGPUBufferCopyView *aDestination, - struct WGPUExtent3d aSize) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_encoder_copy_texture_to_texture(const WGPUGlobal *aGlobal, - WGPUCommandEncoderId aSelfId, - const struct WGPUTextureCopyView *aSource, - const struct WGPUTextureCopyView *aDestination, - struct WGPUExtent3d aSize) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_encoder_destroy(const WGPUGlobal *aGlobal, - WGPUCommandEncoderId aSelfId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_encoder_finish(const WGPUGlobal *aGlobal, - WGPUCommandEncoderId aSelfId, - const struct WGPUCommandBufferDescriptor *aDesc) -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. - * - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointer is - * valid for `id_length` elements. - */ -WGPU_INLINE -int8_t wgpu_server_instance_request_adapter(const WGPUGlobal *aGlobal, - const struct WGPURequestAdapterOptions *aDesc, - const WGPUAdapterId *aIds, - uintptr_t aIdLength) -WGPU_FUNC; - -WGPU_INLINE -WGPUGlobal *wgpu_server_new(struct WGPUIdentityRecyclerFactory aFactory) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_pipeline_layout_destroy(const WGPUGlobal *aGlobal, - WGPUPipelineLayoutId aSelfId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_poll_all_devices(const WGPUGlobal *aGlobal, - bool aForceWait) -WGPU_FUNC; - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointer is - * valid for `command_buffer_id_length` elements. - */ -WGPU_INLINE -void wgpu_server_queue_submit(const WGPUGlobal *aGlobal, - WGPUQueueId aSelfId, - const WGPUCommandBufferId *aCommandBufferIds, - uintptr_t aCommandBufferIdLength) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_render_pipeline_destroy(const WGPUGlobal *aGlobal, - WGPURenderPipelineId aSelfId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_sampler_destroy(const WGPUGlobal *aGlobal, - WGPUSamplerId aSelfId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_shader_module_destroy(const WGPUGlobal *aGlobal, - WGPUShaderModuleId aSelfId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_texture_create_view(const WGPUGlobal *aGlobal, - WGPUTextureId aSelfId, - const struct WGPUTextureViewDescriptor *aDesc, - WGPUTextureViewId aNewId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_texture_destroy(const WGPUGlobal *aGlobal, - WGPUTextureId aSelfId) -WGPU_FUNC; - -WGPU_INLINE -void wgpu_server_texture_view_destroy(const WGPUGlobal *aGlobal, - WGPUTextureViewId aSelfId) -WGPU_FUNC; diff --git a/ffi/wgpu.h b/ffi/wgpu.h deleted file mode 100644 index da39c7fe1..000000000 --- a/ffi/wgpu.h +++ /dev/null @@ -1,1006 +0,0 @@ -/* 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.14.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 unsigned long long WGPUNonZeroU64; -typedef unsigned long long WGPUOption_AdapterId; -typedef unsigned long long WGPUOption_SurfaceId; -typedef unsigned long long WGPUOption_TextureViewId; - - -#include -#include -#include -#include - -/** - * Bound uniform/storage buffer offsets must be aligned to this number. - */ -#define WGPUBIND_BUFFER_ALIGNMENT 256 - -#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 16 - -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_ComparisonSampler = 4, - WGPUBindingType_SampledTexture = 5, - WGPUBindingType_ReadonlyStorageTexture = 6, - WGPUBindingType_WriteonlyStorageTexture = 7, -} 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_Undefined = 0, - WGPUCompareFunction_Never = 1, - WGPUCompareFunction_Less = 2, - WGPUCompareFunction_Equal = 3, - WGPUCompareFunction_LessEqual = 4, - WGPUCompareFunction_Greater = 5, - WGPUCompareFunction_NotEqual = 6, - WGPUCompareFunction_GreaterEqual = 7, - WGPUCompareFunction_Always = 8, -} 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 { - /** - * The presentation engine does **not** wait for a vertical blanking period and - * the request is presented immediately. This is a low-latency presentation mode, - * but visible tearing may be observed. Will fallback to `Fifo` if unavailable on the - * selected platform and backend. Not optimal for mobile. - */ - WGPUPresentMode_Immediate = 0, - /** - * The presentation engine waits for the next vertical blanking period to update - * the current image, but frames may be submitted without delay. This is a low-latency - * presentation mode and visible tearing will **not** be observed. Will fallback to `Fifo` - * if unavailable on the selected platform and backend. Not optimal for mobile. - */ - WGPUPresentMode_Mailbox = 1, - /** - * The presentation engine waits for the next vertical blanking period to update - * the current image. The framerate will be capped at the display refresh rate, - * corresponding to the `VSync`. Tearing cannot be observed. Optimal for mobile. - */ - WGPUPresentMode_Fifo = 2, -} 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 { - WGPUTextureComponentType_Float, - WGPUTextureComponentType_Sint, - WGPUTextureComponentType_Uint, -} WGPUTextureComponentType; - -typedef enum { - WGPUTextureDimension_D1, - WGPUTextureDimension_D2, - WGPUTextureDimension_D3, -} WGPUTextureDimension; - -typedef enum { - WGPUTextureFormat_R8Unorm = 0, - WGPUTextureFormat_R8Snorm = 1, - WGPUTextureFormat_R8Uint = 2, - WGPUTextureFormat_R8Sint = 3, - WGPUTextureFormat_R16Uint = 4, - WGPUTextureFormat_R16Sint = 5, - WGPUTextureFormat_R16Float = 6, - WGPUTextureFormat_Rg8Unorm = 7, - WGPUTextureFormat_Rg8Snorm = 8, - WGPUTextureFormat_Rg8Uint = 9, - WGPUTextureFormat_Rg8Sint = 10, - WGPUTextureFormat_R32Uint = 11, - WGPUTextureFormat_R32Sint = 12, - WGPUTextureFormat_R32Float = 13, - WGPUTextureFormat_Rg16Uint = 14, - WGPUTextureFormat_Rg16Sint = 15, - WGPUTextureFormat_Rg16Float = 16, - WGPUTextureFormat_Rgba8Unorm = 17, - WGPUTextureFormat_Rgba8UnormSrgb = 18, - WGPUTextureFormat_Rgba8Snorm = 19, - WGPUTextureFormat_Rgba8Uint = 20, - WGPUTextureFormat_Rgba8Sint = 21, - WGPUTextureFormat_Bgra8Unorm = 22, - WGPUTextureFormat_Bgra8UnormSrgb = 23, - WGPUTextureFormat_Rgb10a2Unorm = 24, - WGPUTextureFormat_Rg11b10Float = 25, - WGPUTextureFormat_Rg32Uint = 26, - WGPUTextureFormat_Rg32Sint = 27, - WGPUTextureFormat_Rg32Float = 28, - WGPUTextureFormat_Rgba16Uint = 29, - WGPUTextureFormat_Rgba16Sint = 30, - WGPUTextureFormat_Rgba16Float = 31, - WGPUTextureFormat_Rgba32Uint = 32, - WGPUTextureFormat_Rgba32Sint = 33, - WGPUTextureFormat_Rgba32Float = 34, - WGPUTextureFormat_Depth32Float = 35, - WGPUTextureFormat_Depth24Plus = 36, - WGPUTextureFormat_Depth24PlusStencil8 = 37, -} WGPUTextureFormat; - -typedef enum { - WGPUTextureViewDimension_D1, - WGPUTextureViewDimension_D2, - WGPUTextureViewDimension_D2Array, - WGPUTextureViewDimension_Cube, - WGPUTextureViewDimension_CubeArray, - WGPUTextureViewDimension_D3, -} WGPUTextureViewDimension; - -typedef enum { - WGPUVertexFormat_Uchar2 = 0, - WGPUVertexFormat_Uchar4 = 1, - WGPUVertexFormat_Char2 = 2, - WGPUVertexFormat_Char4 = 3, - WGPUVertexFormat_Uchar2Norm = 4, - WGPUVertexFormat_Uchar4Norm = 5, - WGPUVertexFormat_Char2Norm = 6, - WGPUVertexFormat_Char4Norm = 7, - WGPUVertexFormat_Ushort2 = 8, - WGPUVertexFormat_Ushort4 = 9, - WGPUVertexFormat_Short2 = 10, - WGPUVertexFormat_Short4 = 11, - WGPUVertexFormat_Ushort2Norm = 12, - WGPUVertexFormat_Ushort4Norm = 13, - WGPUVertexFormat_Short2Norm = 14, - WGPUVertexFormat_Short4Norm = 15, - WGPUVertexFormat_Half2 = 16, - WGPUVertexFormat_Half4 = 17, - WGPUVertexFormat_Float = 18, - WGPUVertexFormat_Float2 = 19, - WGPUVertexFormat_Float3 = 20, - WGPUVertexFormat_Float4 = 21, - WGPUVertexFormat_Uint = 22, - WGPUVertexFormat_Uint2 = 23, - WGPUVertexFormat_Uint3 = 24, - WGPUVertexFormat_Uint4 = 25, - WGPUVertexFormat_Int = 26, - WGPUVertexFormat_Int2 = 27, - WGPUVertexFormat_Int3 = 28, - WGPUVertexFormat_Int4 = 29, -} WGPUVertexFormat; - -typedef WGPUNonZeroU64 WGPUId_Adapter_Dummy; - -typedef WGPUId_Adapter_Dummy WGPUAdapterId; - -typedef WGPUNonZeroU64 WGPUId_Device_Dummy; - -typedef WGPUId_Device_Dummy WGPUDeviceId; - -typedef struct { - bool anisotropic_filtering; -} WGPUExtensions; - -typedef struct { - uint32_t max_bind_groups; -} WGPULimits; - -typedef struct { - WGPUExtensions extensions; - WGPULimits limits; -} WGPUDeviceDescriptor; - -typedef WGPUNonZeroU64 WGPUId_BindGroup_Dummy; - -typedef WGPUId_BindGroup_Dummy WGPUBindGroupId; - -typedef WGPUNonZeroU64 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 WGPUNonZeroU64 WGPUId_CommandBuffer_Dummy; - -typedef WGPUId_CommandBuffer_Dummy WGPUCommandBufferId; - -typedef WGPUCommandBufferId WGPUCommandEncoderId; - -typedef struct { - uint8_t *data; - uint8_t *base; - uintptr_t capacity; - WGPUCommandEncoderId parent; -} WGPURawPass; - -typedef struct { - uint32_t todo; -} WGPUComputePassDescriptor; - -typedef WGPUNonZeroU64 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; - WGPUOption_TextureViewId resolve_target; - WGPULoadOp load_op; - WGPUStoreOp store_op; - WGPUColor clear_color; -} WGPURenderPassColorAttachmentDescriptorBase_TextureViewId; - -typedef WGPURenderPassColorAttachmentDescriptorBase_TextureViewId 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; -} WGPURenderPassDepthStencilAttachmentDescriptorBase_TextureViewId; - -typedef WGPURenderPassDepthStencilAttachmentDescriptorBase_TextureViewId WGPURenderPassDepthStencilAttachmentDescriptor; - -typedef struct { - const WGPURenderPassColorAttachmentDescriptor *color_attachments; - uintptr_t color_attachments_length; - const WGPURenderPassDepthStencilAttachmentDescriptor *depth_stencil_attachment; -} WGPURenderPassDescriptor; - -typedef struct { - WGPUBufferId buffer; - WGPUBufferAddress offset; - uint32_t bytes_per_row; - uint32_t rows_per_image; -} WGPUBufferCopyView; - -typedef WGPUNonZeroU64 WGPUId_Texture_Dummy; - -typedef WGPUId_Texture_Dummy WGPUTextureId; - -typedef struct { - uint32_t x; - uint32_t y; - uint32_t z; -} WGPUOrigin3d; -#define WGPUOrigin3d_ZERO (WGPUOrigin3d){ .x = 0, .y = 0, .z = 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 WGPURawPass *WGPUComputePassId; - -typedef const char *WGPURawString; - -typedef uint32_t WGPUDynamicOffset; - -typedef WGPUNonZeroU64 WGPUId_ComputePipeline_Dummy; - -typedef WGPUId_ComputePipeline_Dummy WGPUComputePipelineId; - -typedef WGPUNonZeroU64 WGPUId_Surface; - -typedef WGPUId_Surface WGPUSurfaceId; - -typedef WGPUNonZeroU64 WGPUId_BindGroupLayout_Dummy; - -typedef WGPUId_BindGroupLayout_Dummy WGPUBindGroupLayoutId; - -typedef struct { - WGPUBufferId buffer; - WGPUBufferAddress offset; - WGPUBufferAddress size; -} WGPUBufferBinding; - -typedef WGPUNonZeroU64 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; -} WGPUBindGroupEntry; - -typedef struct { - const char *label; - WGPUBindGroupLayoutId layout; - const WGPUBindGroupEntry *entries; - uintptr_t entries_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; - bool multisampled; - bool has_dynamic_offset; - WGPUTextureViewDimension view_dimension; - WGPUTextureComponentType texture_component_type; - WGPUTextureFormat storage_texture_format; -} WGPUBindGroupLayoutEntry; - -typedef struct { - const char *label; - const WGPUBindGroupLayoutEntry *entries; - uintptr_t entries_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_INDIRECT 256 -#define WGPUBufferUsage_STORAGE_READ 512 -#define WGPUBufferUsage_NONE 0 - -typedef struct { - const char *label; - WGPUBufferAddress size; - WGPUBufferUsage usage; -} WGPUBufferDescriptor; - -typedef struct { - const char *label; -} WGPUCommandEncoderDescriptor; - -typedef WGPUNonZeroU64 WGPUId_PipelineLayout_Dummy; - -typedef WGPUId_PipelineLayout_Dummy WGPUPipelineLayoutId; - -typedef WGPUNonZeroU64 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 WGPUNonZeroU64 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 array_stride; - WGPUInputStepMode step_mode; - const WGPUVertexAttributeDescriptor *attributes; - uintptr_t attributes_length; -} WGPUVertexBufferLayoutDescriptor; - -typedef struct { - WGPUIndexFormat index_format; - const WGPUVertexBufferLayoutDescriptor *vertex_buffers; - uintptr_t vertex_buffers_length; -} WGPUVertexStateDescriptor; - -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; - WGPUVertexStateDescriptor vertex_state; - 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; -} WGPUSamplerDescriptor; - -typedef struct { - const uint32_t *bytes; - uintptr_t length; -} WGPUU32Array; - -typedef struct { - WGPUU32Array code; -} WGPUShaderModuleDescriptor; - -typedef WGPUNonZeroU64 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 { - const char *label; - WGPUExtent3d size; - uint32_t mip_level_count; - uint32_t sample_count; - WGPUTextureDimension dimension; - WGPUTextureFormat format; - WGPUTextureUsage usage; -} WGPUTextureDescriptor; - -typedef WGPUDeviceId WGPUQueueId; - -typedef WGPURawPass *WGPURenderPassId; - -typedef WGPUNonZeroU64 WGPUId_RenderBundle_Dummy; - -typedef WGPUId_RenderBundle_Dummy WGPURenderBundleId; - -typedef struct { - WGPUPowerPreference power_preference; - WGPUOption_SurfaceId compatible_surface; -} WGPURequestAdapterOptions; - -typedef uint32_t WGPUBackendBit; - -typedef void (*WGPURequestAdapterCallback)(WGPUOption_AdapterId id, void *userdata); - -typedef struct { - WGPUOption_TextureViewId 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; - -void wgpu_adapter_destroy(WGPUAdapterId adapter_id); - -WGPUDeviceId wgpu_adapter_request_device(WGPUAdapterId adapter_id, - const WGPUDeviceDescriptor *desc); - -void wgpu_bind_group_destroy(WGPUBindGroupId bind_group_id); - -void wgpu_buffer_destroy(WGPUBufferId buffer_id); - -void wgpu_buffer_map_read_async(WGPUBufferId buffer_id, - WGPUBufferAddress start, - WGPUBufferAddress size, - WGPUBufferMapReadCallback callback, - uint8_t *userdata); - -void wgpu_buffer_map_write_async(WGPUBufferId buffer_id, - WGPUBufferAddress start, - WGPUBufferAddress size, - WGPUBufferMapWriteCallback callback, - uint8_t *userdata); - -void wgpu_buffer_unmap(WGPUBufferId buffer_id); - -void wgpu_command_buffer_destroy(WGPUCommandBufferId command_buffer_id); - -/** - * # Safety - * - * This function is unsafe because improper use may lead to memory - * problems. For example, a double-free may occur if the function is called - * twice on the same raw pointer. - */ -WGPURawPass *wgpu_command_encoder_begin_compute_pass(WGPUCommandEncoderId encoder_id, - const WGPUComputePassDescriptor *_desc); - -/** - * # Safety - * - * This function is unsafe because improper use may lead to memory - * problems. For example, a double-free may occur if the function is called - * twice on the same raw pointer. - */ -WGPURawPass *wgpu_command_encoder_begin_render_pass(WGPUCommandEncoderId encoder_id, - const WGPURenderPassDescriptor *desc); - -void wgpu_command_encoder_copy_buffer_to_buffer(WGPUCommandEncoderId command_encoder_id, - WGPUBufferId source, - WGPUBufferAddress source_offset, - WGPUBufferId destination, - WGPUBufferAddress destination_offset, - WGPUBufferAddress size); - -void wgpu_command_encoder_copy_buffer_to_texture(WGPUCommandEncoderId command_encoder_id, - const WGPUBufferCopyView *source, - const WGPUTextureCopyView *destination, - WGPUExtent3d copy_size); - -void wgpu_command_encoder_copy_texture_to_buffer(WGPUCommandEncoderId command_encoder_id, - const WGPUTextureCopyView *source, - const WGPUBufferCopyView *destination, - WGPUExtent3d copy_size); - -void wgpu_command_encoder_copy_texture_to_texture(WGPUCommandEncoderId command_encoder_id, - const WGPUTextureCopyView *source, - const WGPUTextureCopyView *destination, - WGPUExtent3d copy_size); - -void wgpu_command_encoder_destroy(WGPUCommandEncoderId command_encoder_id); - -WGPUCommandBufferId wgpu_command_encoder_finish(WGPUCommandEncoderId encoder_id, - const WGPUCommandBufferDescriptor *desc); - -void wgpu_compute_pass_destroy(WGPURawPass *pass); - -void wgpu_compute_pass_dispatch(WGPURawPass *pass, - uint32_t groups_x, - uint32_t groups_y, - uint32_t groups_z); - -void wgpu_compute_pass_dispatch_indirect(WGPURawPass *pass, - WGPUBufferId buffer_id, - WGPUBufferAddress offset); - -void wgpu_compute_pass_end_pass(WGPUComputePassId pass_id); - -const uint8_t *wgpu_compute_pass_finish(WGPURawPass *pass, uintptr_t *length); - -void wgpu_compute_pass_insert_debug_marker(WGPURawPass *_pass, WGPURawString _label); - -void wgpu_compute_pass_pop_debug_group(WGPURawPass *_pass); - -void wgpu_compute_pass_push_debug_group(WGPURawPass *_pass, WGPURawString _label); - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointer is - * valid for `offset_length` elements. - */ -void wgpu_compute_pass_set_bind_group(WGPURawPass *pass, - uint32_t index, - WGPUBindGroupId bind_group_id, - const WGPUDynamicOffset *offsets, - uintptr_t offset_length); - -void wgpu_compute_pass_set_pipeline(WGPURawPass *pass, WGPUComputePipelineId pipeline_id); - -WGPUSurfaceId wgpu_create_surface_from_metal_layer(void *layer); - -WGPUSurfaceId wgpu_create_surface_from_wayland(void *surface, void *display); - -WGPUSurfaceId wgpu_create_surface_from_windows_hwnd(void *_hinstance, void *hwnd); - -WGPUSurfaceId wgpu_create_surface_from_xlib(const void **display, unsigned long window); - -WGPUBindGroupId wgpu_device_create_bind_group(WGPUDeviceId device_id, - const WGPUBindGroupDescriptor *desc); - -WGPUBindGroupLayoutId wgpu_device_create_bind_group_layout(WGPUDeviceId device_id, - const WGPUBindGroupLayoutDescriptor *desc); - -WGPUBufferId wgpu_device_create_buffer(WGPUDeviceId device_id, const WGPUBufferDescriptor *desc); - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointer - * dereferenced in this function is valid. - */ -WGPUBufferId wgpu_device_create_buffer_mapped(WGPUDeviceId device_id, - const WGPUBufferDescriptor *desc, - uint8_t **mapped_ptr_out); - -WGPUCommandEncoderId wgpu_device_create_command_encoder(WGPUDeviceId device_id, - const WGPUCommandEncoderDescriptor *desc); - -WGPUComputePipelineId wgpu_device_create_compute_pipeline(WGPUDeviceId device_id, - const WGPUComputePipelineDescriptor *desc); - -WGPUPipelineLayoutId wgpu_device_create_pipeline_layout(WGPUDeviceId device_id, - const WGPUPipelineLayoutDescriptor *desc); - -WGPURenderPipelineId wgpu_device_create_render_pipeline(WGPUDeviceId device_id, - const WGPURenderPipelineDescriptor *desc); - -WGPUSamplerId wgpu_device_create_sampler(WGPUDeviceId device_id, const WGPUSamplerDescriptor *desc); - -WGPUShaderModuleId wgpu_device_create_shader_module(WGPUDeviceId device_id, - const WGPUShaderModuleDescriptor *desc); - -WGPUSwapChainId wgpu_device_create_swap_chain(WGPUDeviceId device_id, - WGPUSurfaceId surface_id, - const WGPUSwapChainDescriptor *desc); - -WGPUTextureId wgpu_device_create_texture(WGPUDeviceId device_id, const WGPUTextureDescriptor *desc); - -void wgpu_device_destroy(WGPUDeviceId device_id); - -WGPUQueueId wgpu_device_get_default_queue(WGPUDeviceId device_id); - -void wgpu_device_get_limits(WGPUDeviceId _device_id, WGPULimits *limits); - -void wgpu_device_poll(WGPUDeviceId device_id, bool force_wait); - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointer is - * valid for `command_buffers_length` elements. - */ -void wgpu_queue_submit(WGPUQueueId queue_id, - const WGPUCommandBufferId *command_buffers, - uintptr_t command_buffers_length); - -void wgpu_render_pass_destroy(WGPURawPass *pass); - -void wgpu_render_pass_draw(WGPURawPass *pass, - uint32_t vertex_count, - uint32_t instance_count, - uint32_t first_vertex, - uint32_t first_instance); - -void wgpu_render_pass_draw_indexed(WGPURawPass *pass, - uint32_t index_count, - uint32_t instance_count, - uint32_t first_index, - int32_t base_vertex, - uint32_t first_instance); - -void wgpu_render_pass_draw_indexed_indirect(WGPURawPass *pass, - WGPUBufferId buffer_id, - WGPUBufferAddress offset); - -void wgpu_render_pass_draw_indirect(WGPURawPass *pass, - WGPUBufferId buffer_id, - WGPUBufferAddress offset); - -/** - * # Safety - * - * This function is unsafe because improper use may lead to memory - * problems. For example, a double-free may occur if the function is called - * twice on the same raw pointer. - */ -void wgpu_render_pass_end_pass(WGPURenderPassId pass_id); - -void wgpu_render_pass_execute_bundles(WGPURawPass *_pass, - const WGPURenderBundleId *_bundles, - uintptr_t _bundles_length); - -const uint8_t *wgpu_render_pass_finish(WGPURawPass *pass, uintptr_t *length); - -void wgpu_render_pass_insert_debug_marker(WGPURawPass *_pass, WGPURawString _label); - -void wgpu_render_pass_pop_debug_group(WGPURawPass *_pass); - -void wgpu_render_pass_push_debug_group(WGPURawPass *_pass, WGPURawString _label); - -/** - * # Safety - * - * This function is unsafe as there is no guarantee that the given pointer is - * valid for `offset_length` elements. - */ -void wgpu_render_pass_set_bind_group(WGPURawPass *pass, - uint32_t index, - WGPUBindGroupId bind_group_id, - const WGPUDynamicOffset *offsets, - uintptr_t offset_length); - -void wgpu_render_pass_set_blend_color(WGPURawPass *pass, const WGPUColor *color); - -void wgpu_render_pass_set_index_buffer(WGPURawPass *pass, - WGPUBufferId buffer_id, - WGPUBufferAddress offset, - WGPUBufferAddress size); - -void wgpu_render_pass_set_pipeline(WGPURawPass *pass, WGPURenderPipelineId pipeline_id); - -void wgpu_render_pass_set_scissor_rect(WGPURawPass *pass, - uint32_t x, - uint32_t y, - uint32_t w, - uint32_t h); - -void wgpu_render_pass_set_stencil_reference(WGPURawPass *pass, uint32_t value); - -void wgpu_render_pass_set_vertex_buffer(WGPURawPass *pass, - uint32_t slot, - WGPUBufferId buffer_id, - WGPUBufferAddress offset, - WGPUBufferAddress size); - -void wgpu_render_pass_set_viewport(WGPURawPass *pass, - float x, - float y, - float w, - float h, - float depth_min, - float depth_max); - -/** - * # Safety - * - * This function is unsafe as it calls an unsafe extern callback. - */ -void wgpu_request_adapter_async(const WGPURequestAdapterOptions *desc, - WGPUBackendBit mask, - WGPURequestAdapterCallback callback, - void *userdata); - -void wgpu_sampler_destroy(WGPUSamplerId sampler_id); - -WGPUSwapChainOutput wgpu_swap_chain_get_next_texture(WGPUSwapChainId swap_chain_id); - -void wgpu_swap_chain_present(WGPUSwapChainId swap_chain_id); - -WGPUTextureViewId wgpu_texture_create_view(WGPUTextureId texture_id, - const WGPUTextureViewDescriptor *desc); - -void wgpu_texture_destroy(WGPUTextureId texture_id); - -void wgpu_texture_view_destroy(WGPUTextureViewId texture_view_id); diff --git a/wgpu-native/Cargo.toml b/wgpu-native/Cargo.toml deleted file mode 100644 index 273999a6d..000000000 --- a/wgpu-native/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -[package] -name = "wgpu-native" -version = "0.5.0" -authors = [ - "Dzmitry Malyshau ", - "Joshua Groves ", -] -edition = "2018" -description = "WebGPU native implementation on gfx-hal" -homepage = "https://github.com/gfx-rs/wgpu" -repository = "https://github.com/gfx-rs/wgpu" -keywords = ["graphics"] -license = "MPL-2.0" - -[lib] -crate-type = ["lib", "cdylib", "staticlib"] - -[features] -default = [] -#metal-auto-capture = ["gfx-backend-metal/auto-capture"] -vulkan-portability = ["core/gfx-backend-vulkan"] - -[dependencies.core] -path = "../wgpu-core" -package = "wgpu-core" -version = "0.5" - -[dependencies.wgt] -path = "../wgpu-types" -package = "wgpu-types" -version = "0.5" - -[dependencies] -arrayvec = "0.5" -lazy_static = "1.1" -parking_lot = "0.10" -raw-window-handle = "0.3" -libc = {version="0.2", features=[]} - -[target.'cfg(target_os = "macos")'.dependencies] -objc = "0.2.7" diff --git a/wgpu-native/cbindgen.toml b/wgpu-native/cbindgen.toml deleted file mode 100644 index 25289299f..000000000 --- a/wgpu-native/cbindgen.toml +++ /dev/null @@ -1,48 +0,0 @@ -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` - */ - -typedef unsigned long long WGPUNonZeroU64; -typedef unsigned long long WGPUOption_AdapterId; -typedef unsigned long long WGPUOption_SurfaceId; -typedef unsigned long long WGPUOption_TextureViewId; -""" -include_version = true -braces = "SameLine" -line_length = 100 -tab_width = 2 -language = "C" - -[export] -prefix = "WGPU" -exclude = ["Option_AdapterId", "Option_SurfaceId", "Option_TextureViewId"] - -[parse] -parse_deps = true -include = ["wgpu-core", "wgpu-types"] - -extra_bindings = ["wgpu-core", "wgpu-types"] - -[fn] - -[struct] -derive_eq = true - -[enum] -prefix_with_name = true -derive_helper_methods = true - -[macro_expansion] -bitflags = true - -[defines] -#"target_os = ios" = "WGPU_TARGET_IOS" -#"target_os = macos" = "WGPU_TARGET_MACOS" -#"unix" = "WGPU_TARGET_FAMILY_UNIX" -#"windows" = "WGPU_TARGET_WINDOWS" diff --git a/wgpu-native/src/command.rs b/wgpu-native/src/command.rs deleted file mode 100644 index 662156426..000000000 --- a/wgpu-native/src/command.rs +++ /dev/null @@ -1,132 +0,0 @@ -/* 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/. */ - -use crate::GLOBAL; - -pub use core::command::{compute_ffi::*, render_ffi::*}; - -use core::{gfx_select, id}; - -#[no_mangle] -pub extern "C" fn wgpu_command_encoder_finish( - encoder_id: id::CommandEncoderId, - desc: Option<&wgt::CommandBufferDescriptor>, -) -> id::CommandBufferId { - let desc = &desc.cloned().unwrap_or_default(); - gfx_select!(encoder_id => GLOBAL.command_encoder_finish(encoder_id, desc)) -} - -#[no_mangle] -pub extern "C" fn wgpu_command_encoder_copy_buffer_to_buffer( - command_encoder_id: id::CommandEncoderId, - source: id::BufferId, - source_offset: wgt::BufferAddress, - destination: id::BufferId, - destination_offset: wgt::BufferAddress, - size: wgt::BufferAddress, -) { - gfx_select!(command_encoder_id => GLOBAL.command_encoder_copy_buffer_to_buffer( - command_encoder_id, - source, source_offset, - destination, - destination_offset, - size)) -} - -#[no_mangle] -pub extern "C" fn wgpu_command_encoder_copy_buffer_to_texture( - command_encoder_id: id::CommandEncoderId, - source: &core::command::BufferCopyView, - destination: &core::command::TextureCopyView, - copy_size: wgt::Extent3d, -) { - gfx_select!(command_encoder_id => GLOBAL.command_encoder_copy_buffer_to_texture( - command_encoder_id, - source, - destination, - copy_size)) -} - -#[no_mangle] -pub extern "C" fn wgpu_command_encoder_copy_texture_to_buffer( - command_encoder_id: id::CommandEncoderId, - source: &core::command::TextureCopyView, - destination: &core::command::BufferCopyView, - copy_size: wgt::Extent3d, -) { - gfx_select!(command_encoder_id => GLOBAL.command_encoder_copy_texture_to_buffer( - command_encoder_id, - source, - destination, - copy_size)) -} - -#[no_mangle] -pub extern "C" fn wgpu_command_encoder_copy_texture_to_texture( - command_encoder_id: id::CommandEncoderId, - source: &core::command::TextureCopyView, - destination: &core::command::TextureCopyView, - copy_size: wgt::Extent3d, -) { - gfx_select!(command_encoder_id => GLOBAL.command_encoder_copy_texture_to_texture( - command_encoder_id, - source, - destination, - copy_size)) -} - -/// # Safety -/// -/// This function is unsafe because improper use may lead to memory -/// problems. For example, a double-free may occur if the function is called -/// twice on the same raw pointer. -#[no_mangle] -pub unsafe extern "C" fn wgpu_command_encoder_begin_render_pass( - encoder_id: id::CommandEncoderId, - desc: &core::command::RenderPassDescriptor, -) -> *mut core::command::RawPass { - let pass = core::command::RawPass::new_render(encoder_id, desc); - Box::into_raw(Box::new(pass)) -} - -/// # Safety -/// -/// This function is unsafe because improper use may lead to memory -/// problems. For example, a double-free may occur if the function is called -/// twice on the same raw pointer. -#[no_mangle] -pub unsafe extern "C" fn wgpu_render_pass_end_pass(pass_id: id::RenderPassId) { - let (pass_data, encoder_id) = Box::from_raw(pass_id).finish_render(); - gfx_select!(encoder_id => GLOBAL.command_encoder_run_render_pass(encoder_id, &pass_data)) -} - -#[no_mangle] -pub unsafe extern "C" fn wgpu_render_pass_destroy(pass: *mut core::command::RawPass) { - let _ = Box::from_raw(pass).into_vec(); -} - -/// # Safety -/// -/// This function is unsafe because improper use may lead to memory -/// problems. For example, a double-free may occur if the function is called -/// twice on the same raw pointer. -#[no_mangle] -pub unsafe extern "C" fn wgpu_command_encoder_begin_compute_pass( - encoder_id: id::CommandEncoderId, - _desc: Option<&core::command::ComputePassDescriptor>, -) -> *mut core::command::RawPass { - let pass = core::command::RawPass::new_compute(encoder_id); - Box::into_raw(Box::new(pass)) -} - -#[no_mangle] -pub unsafe extern "C" fn wgpu_compute_pass_end_pass(pass_id: id::ComputePassId) { - let (pass_data, encoder_id) = Box::from_raw(pass_id).finish_compute(); - gfx_select!(encoder_id => GLOBAL.command_encoder_run_compute_pass(encoder_id, &pass_data)) -} - -#[no_mangle] -pub unsafe extern "C" fn wgpu_compute_pass_destroy(pass: *mut core::command::RawPass) { - let _ = Box::from_raw(pass).into_vec(); -} diff --git a/wgpu-native/src/device.rs b/wgpu-native/src/device.rs deleted file mode 100644 index 09a26a818..000000000 --- a/wgpu-native/src/device.rs +++ /dev/null @@ -1,411 +0,0 @@ -/* 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/. */ - -use crate::GLOBAL; - -use core::{gfx_select, hub::Token, id}; -use wgt::{BackendBit, DeviceDescriptor, Limits}; - -use std::{marker::PhantomData, slice}; - -#[cfg(target_os = "macos")] -use objc::{msg_send, runtime::Object, sel, sel_impl}; - -pub type RequestAdapterCallback = - unsafe extern "C" fn(id: Option, userdata: *mut std::ffi::c_void); - -pub fn wgpu_create_surface(raw_handle: raw_window_handle::RawWindowHandle) -> id::SurfaceId { - use raw_window_handle::RawWindowHandle as Rwh; - - let instance = &GLOBAL.instance; - let surface = match raw_handle { - #[cfg(target_os = "ios")] - Rwh::IOS(h) => core::instance::Surface { - #[cfg(feature = "vulkan-portability")] - vulkan: None, - metal: instance - .metal - .create_surface_from_uiview(h.ui_view, cfg!(debug_assertions)), - }, - #[cfg(target_os = "macos")] - Rwh::MacOS(h) => { - let ns_view = if h.ns_view.is_null() { - let ns_window = h.ns_window as *mut Object; - unsafe { msg_send![ns_window, contentView] } - } else { - h.ns_view - }; - core::instance::Surface { - #[cfg(feature = "vulkan-portability")] - vulkan: instance - .vulkan - .as_ref() - .map(|inst| inst.create_surface_from_ns_view(ns_view)), - metal: instance - .metal - .create_surface_from_nsview(ns_view, cfg!(debug_assertions)), - } - } - #[cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))] - Rwh::Xlib(h) => core::instance::Surface { - vulkan: instance - .vulkan - .as_ref() - .map(|inst| inst.create_surface_from_xlib(h.display as _, h.window as _)), - }, - #[cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))] - Rwh::Wayland(h) => core::instance::Surface { - vulkan: instance - .vulkan - .as_ref() - .map(|inst| inst.create_surface_from_wayland(h.display, h.surface)), - }, - #[cfg(windows)] - Rwh::Windows(h) => core::instance::Surface { - vulkan: instance - .vulkan - .as_ref() - .map(|inst| inst.create_surface_from_hwnd(std::ptr::null_mut(), h.hwnd)), - dx12: instance - .dx12 - .as_ref() - .map(|inst| inst.create_surface_from_hwnd(h.hwnd)), - dx11: instance.dx11.create_surface_from_hwnd(h.hwnd), - }, - _ => panic!("Unsupported window handle"), - }; - - let mut token = Token::root(); - GLOBAL - .surfaces - .register_identity(PhantomData, surface, &mut token) -} - -#[cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))] -#[no_mangle] -pub extern "C" fn wgpu_create_surface_from_xlib( - display: *mut *const std::ffi::c_void, - window: libc::c_ulong, -) -> id::SurfaceId { - use raw_window_handle::unix::XlibHandle; - wgpu_create_surface(raw_window_handle::RawWindowHandle::Xlib(XlibHandle { - window, - display: display as *mut _, - ..XlibHandle::empty() - })) -} - -#[cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))] -#[no_mangle] -pub extern "C" fn wgpu_create_surface_from_wayland( - surface: *mut std::ffi::c_void, - display: *mut std::ffi::c_void, -) -> id::SurfaceId { - use raw_window_handle::unix::WaylandHandle; - wgpu_create_surface(raw_window_handle::RawWindowHandle::Wayland(WaylandHandle { - surface, - display, - ..WaylandHandle::empty() - })) -} - -#[cfg(any(target_os = "ios", target_os = "macos"))] -#[no_mangle] -pub extern "C" fn wgpu_create_surface_from_metal_layer( - layer: *mut std::ffi::c_void, -) -> id::SurfaceId { - let surface = core::instance::Surface { - #[cfg(feature = "vulkan-portability")] - vulkan: None, //TODO: currently requires `NSView` - metal: GLOBAL - .instance - .metal - .create_surface_from_layer(layer as *mut _, cfg!(debug_assertions)), - }; - - GLOBAL - .surfaces - .register_identity(PhantomData, surface, &mut Token::root()) -} - -#[cfg(windows)] -#[no_mangle] -pub extern "C" fn wgpu_create_surface_from_windows_hwnd( - _hinstance: *mut std::ffi::c_void, - hwnd: *mut std::ffi::c_void, -) -> id::SurfaceId { - use raw_window_handle::windows::WindowsHandle; - wgpu_create_surface(raw_window_handle::RawWindowHandle::Windows( - raw_window_handle::windows::WindowsHandle { - hwnd, - ..WindowsHandle::empty() - }, - )) -} - -pub fn wgpu_enumerate_adapters(mask: BackendBit) -> Vec { - GLOBAL.enumerate_adapters(core::instance::AdapterInputs::Mask(mask, || PhantomData)) -} - -/// # Safety -/// -/// This function is unsafe as it calls an unsafe extern callback. -#[no_mangle] -pub unsafe extern "C" fn wgpu_request_adapter_async( - desc: Option<&core::instance::RequestAdapterOptions>, - mask: BackendBit, - callback: RequestAdapterCallback, - userdata: *mut std::ffi::c_void, -) { - let id = GLOBAL.pick_adapter( - &desc.cloned().unwrap_or_default(), - core::instance::AdapterInputs::Mask(mask, || PhantomData), - ); - callback(id, userdata); -} - -#[no_mangle] -pub extern "C" fn wgpu_adapter_request_device( - adapter_id: id::AdapterId, - desc: Option<&DeviceDescriptor>, -) -> id::DeviceId { - let desc = &desc.cloned().unwrap_or_default(); - gfx_select!(adapter_id => GLOBAL.adapter_request_device(adapter_id, desc, PhantomData)) -} - -pub fn adapter_get_info(adapter_id: id::AdapterId) -> core::instance::AdapterInfo { - gfx_select!(adapter_id => GLOBAL.adapter_get_info(adapter_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_adapter_destroy(adapter_id: id::AdapterId) { - gfx_select!(adapter_id => GLOBAL.adapter_destroy(adapter_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_get_limits(_device_id: id::DeviceId, limits: &mut Limits) { - *limits = Limits::default(); // TODO -} - -#[no_mangle] -pub extern "C" fn wgpu_device_create_buffer( - device_id: id::DeviceId, - desc: &wgt::BufferDescriptor, -) -> id::BufferId { - gfx_select!(device_id => GLOBAL.device_create_buffer(device_id, desc, PhantomData)) -} - -/// # Safety -/// -/// This function is unsafe as there is no guarantee that the given pointer -/// dereferenced in this function is valid. -#[no_mangle] -pub unsafe extern "C" fn wgpu_device_create_buffer_mapped( - device_id: id::DeviceId, - desc: &wgt::BufferDescriptor, - mapped_ptr_out: *mut *mut u8, -) -> id::BufferId { - let (id, ptr) = - gfx_select!(device_id => GLOBAL.device_create_buffer_mapped(device_id, desc, PhantomData)); - *mapped_ptr_out = ptr; - id -} - -#[no_mangle] -pub extern "C" fn wgpu_buffer_destroy(buffer_id: id::BufferId) { - gfx_select!(buffer_id => GLOBAL.buffer_destroy(buffer_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_create_texture( - device_id: id::DeviceId, - desc: &wgt::TextureDescriptor, -) -> id::TextureId { - gfx_select!(device_id => GLOBAL.device_create_texture(device_id, desc, PhantomData)) -} - -#[no_mangle] -pub extern "C" fn wgpu_texture_destroy(texture_id: id::TextureId) { - gfx_select!(texture_id => GLOBAL.texture_destroy(texture_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_texture_create_view( - texture_id: id::TextureId, - desc: Option<&wgt::TextureViewDescriptor>, -) -> id::TextureViewId { - gfx_select!(texture_id => GLOBAL.texture_create_view(texture_id, desc, PhantomData)) -} - -#[no_mangle] -pub extern "C" fn wgpu_texture_view_destroy(texture_view_id: id::TextureViewId) { - gfx_select!(texture_view_id => GLOBAL.texture_view_destroy(texture_view_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_create_sampler( - device_id: id::DeviceId, - desc: &wgt::SamplerDescriptor, -) -> id::SamplerId { - gfx_select!(device_id => GLOBAL.device_create_sampler(device_id, desc, PhantomData)) -} - -#[no_mangle] -pub extern "C" fn wgpu_sampler_destroy(sampler_id: id::SamplerId) { - gfx_select!(sampler_id => GLOBAL.sampler_destroy(sampler_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_create_bind_group_layout( - device_id: id::DeviceId, - desc: &core::binding_model::BindGroupLayoutDescriptor, -) -> id::BindGroupLayoutId { - gfx_select!(device_id => GLOBAL.device_create_bind_group_layout(device_id, desc, PhantomData)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_create_pipeline_layout( - device_id: id::DeviceId, - desc: &core::binding_model::PipelineLayoutDescriptor, -) -> id::PipelineLayoutId { - gfx_select!(device_id => GLOBAL.device_create_pipeline_layout(device_id, desc, PhantomData)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_create_bind_group( - device_id: id::DeviceId, - desc: &core::binding_model::BindGroupDescriptor, -) -> id::BindGroupId { - gfx_select!(device_id => GLOBAL.device_create_bind_group(device_id, desc, PhantomData)) -} - -#[no_mangle] -pub extern "C" fn wgpu_bind_group_destroy(bind_group_id: id::BindGroupId) { - gfx_select!(bind_group_id => GLOBAL.bind_group_destroy(bind_group_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_create_shader_module( - device_id: id::DeviceId, - desc: &core::pipeline::ShaderModuleDescriptor, -) -> id::ShaderModuleId { - gfx_select!(device_id => GLOBAL.device_create_shader_module(device_id, desc, PhantomData)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_create_command_encoder( - device_id: id::DeviceId, - desc: Option<&wgt::CommandEncoderDescriptor>, -) -> id::CommandEncoderId { - let desc = &desc.cloned().unwrap_or_default(); - gfx_select!(device_id => GLOBAL.device_create_command_encoder(device_id, desc, PhantomData)) -} - -#[no_mangle] -pub extern "C" fn wgpu_command_encoder_destroy(command_encoder_id: id::CommandEncoderId) { - gfx_select!(command_encoder_id => GLOBAL.command_encoder_destroy(command_encoder_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_command_buffer_destroy(command_buffer_id: id::CommandBufferId) { - gfx_select!(command_buffer_id => GLOBAL.command_buffer_destroy(command_buffer_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_get_default_queue(device_id: id::DeviceId) -> id::QueueId { - device_id -} - -/// # Safety -/// -/// This function is unsafe as there is no guarantee that the given pointer is -/// valid for `command_buffers_length` elements. -#[no_mangle] -pub unsafe extern "C" fn wgpu_queue_submit( - queue_id: id::QueueId, - command_buffers: *const id::CommandBufferId, - command_buffers_length: usize, -) { - let command_buffer_ids = slice::from_raw_parts(command_buffers, command_buffers_length); - gfx_select!(queue_id => GLOBAL.queue_submit(queue_id, command_buffer_ids)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_create_render_pipeline( - device_id: id::DeviceId, - desc: &core::pipeline::RenderPipelineDescriptor, -) -> id::RenderPipelineId { - gfx_select!(device_id => GLOBAL.device_create_render_pipeline(device_id, desc, PhantomData)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_create_compute_pipeline( - device_id: id::DeviceId, - desc: &core::pipeline::ComputePipelineDescriptor, -) -> id::ComputePipelineId { - gfx_select!(device_id => GLOBAL.device_create_compute_pipeline(device_id, desc, PhantomData)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_create_swap_chain( - device_id: id::DeviceId, - surface_id: id::SurfaceId, - desc: &wgt::SwapChainDescriptor, -) -> id::SwapChainId { - gfx_select!(device_id => GLOBAL.device_create_swap_chain(device_id, surface_id, desc)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_poll(device_id: id::DeviceId, force_wait: bool) { - gfx_select!(device_id => GLOBAL.device_poll(device_id, force_wait)) -} - -#[no_mangle] -pub extern "C" fn wgpu_device_destroy(device_id: id::DeviceId) { - gfx_select!(device_id => GLOBAL.device_destroy(device_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_buffer_map_read_async( - buffer_id: id::BufferId, - start: wgt::BufferAddress, - size: wgt::BufferAddress, - callback: core::device::BufferMapReadCallback, - userdata: *mut u8, -) { - let operation = core::resource::BufferMapOperation::Read { callback, userdata }; - - gfx_select!(buffer_id => GLOBAL.buffer_map_async(buffer_id, wgt::BufferUsage::MAP_READ, start .. start + size, operation)) -} - -#[no_mangle] -pub extern "C" fn wgpu_buffer_map_write_async( - buffer_id: id::BufferId, - start: wgt::BufferAddress, - size: wgt::BufferAddress, - callback: core::device::BufferMapWriteCallback, - userdata: *mut u8, -) { - let operation = core::resource::BufferMapOperation::Write { callback, userdata }; - - gfx_select!(buffer_id => GLOBAL.buffer_map_async(buffer_id, wgt::BufferUsage::MAP_WRITE, start .. start + size, operation)) -} - -#[no_mangle] -pub extern "C" fn wgpu_buffer_unmap(buffer_id: id::BufferId) { - gfx_select!(buffer_id => GLOBAL.buffer_unmap(buffer_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_swap_chain_get_next_texture( - swap_chain_id: id::SwapChainId, -) -> core::swap_chain::SwapChainOutput { - gfx_select!(swap_chain_id => GLOBAL.swap_chain_get_next_texture(swap_chain_id, PhantomData)) - .unwrap_or(core::swap_chain::SwapChainOutput { view_id: None }) -} - -#[no_mangle] -pub extern "C" fn wgpu_swap_chain_present(swap_chain_id: id::SwapChainId) { - gfx_select!(swap_chain_id => GLOBAL.swap_chain_present(swap_chain_id)) -} diff --git a/wgpu-native/src/lib.rs b/wgpu-native/src/lib.rs deleted file mode 100644 index d86fa0530..000000000 --- a/wgpu-native/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -/* 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/. */ - -use std::sync::Arc; - -mod command; -mod device; - -pub use self::command::*; -pub use self::device::*; - -type Global = core::hub::Global; - -lazy_static::lazy_static! { - static ref GLOBAL: Arc = Arc::new(Global::new("wgpu", core::hub::IdentityManagerFactory)); -} diff --git a/wgpu-remote/Cargo.toml b/wgpu-remote/Cargo.toml deleted file mode 100644 index 87cabad1c..000000000 --- a/wgpu-remote/Cargo.toml +++ /dev/null @@ -1,33 +0,0 @@ -[package] -name = "wgpu-remote" -version = "0.1.0" -authors = [ - "Dzmitry Malyshau ", - "Joshua Groves ", -] -edition = "2018" -license = "MPL-2.0" -publish = false - -[lib] -# Enabling these targets makes our CI bots try to build them and fail atm -#crate-type = ["lib", "cdylib", "staticlib"] - -[features] -default = [] - -[dependencies.core] -path = "../wgpu-core" -package = "wgpu-core" -version = "0.5" -features = ["serde"] - -[dependencies.wgt] -path = "../wgpu-types" -package = "wgpu-types" -version = "0.5" -features = ["serde"] - -[dependencies] -log = "0.4" -parking_lot = { version = "0.10" } diff --git a/wgpu-remote/cbindgen.toml b/wgpu-remote/cbindgen.toml deleted file mode 100644 index 451994485..000000000 --- a/wgpu-remote/cbindgen.toml +++ /dev/null @@ -1,53 +0,0 @@ -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` - */ - -typedef uint64_t WGPUNonZeroU64; -typedef uint64_t WGPUOption_AdapterId; -typedef uint64_t WGPUOption_SurfaceId; -typedef uint64_t WGPUOption_TextureViewId; -""" -include_version = true -braces = "SameLine" -line_length = 100 -tab_width = 2 -language = "C" -style = "tag" - -[export] -prefix = "WGPU" -exclude = ["Option_AdapterId", "Option_SurfaceId", "Option_TextureViewId"] - -[parse] -parse_deps = true -include = ["wgpu-core", "wgpu-types"] - -extra_bindings = ["wgpu-core", "wgpu-types"] - -[fn] -prefix = "WGPU_INLINE" -postfix = "WGPU_FUNC" -args = "Vertical" -rename_args = "GeckoCase" - -[struct] -derive_eq = true - -[enum] -prefix_with_name = true -derive_helper_methods = true -add_sentinel = true - -[macro_expansion] -bitflags = true - -[defines] -"target_os = windows" = "XP_WIN" -"target_os = macos" = "XP_MACOSX" -"target_os = android" = "ANDROID" diff --git a/wgpu-remote/src/identity.rs b/wgpu-remote/src/identity.rs deleted file mode 100644 index 59eeda0ee..000000000 --- a/wgpu-remote/src/identity.rs +++ /dev/null @@ -1,202 +0,0 @@ -/* 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/. */ - -use core::id; - -pub type FactoryParam = *mut std::ffi::c_void; - -#[derive(Debug)] -pub struct IdentityRecycler { - fun: extern "C" fn(I, FactoryParam), - param: FactoryParam, - kind: &'static str, -} - -impl core::hub::IdentityHandler - for IdentityRecycler -{ - type Input = I; - fn process(&self, id: I, _backend: wgt::Backend) -> I { - log::debug!("process {} {:?}", self.kind, id); - //debug_assert_eq!(id.unzip().2, backend); - id - } - fn free(&self, id: I) { - log::debug!("free {} {:?}", self.kind, id); - (self.fun)(id, self.param); - } -} - -#[repr(C)] -pub struct IdentityRecyclerFactory { - param: FactoryParam, - free_adapter: extern "C" fn(id::AdapterId, FactoryParam), - free_device: extern "C" fn(id::DeviceId, FactoryParam), - free_swap_chain: extern "C" fn(id::SwapChainId, FactoryParam), - free_pipeline_layout: extern "C" fn(id::PipelineLayoutId, FactoryParam), - free_shader_module: extern "C" fn(id::ShaderModuleId, FactoryParam), - free_bind_group_layout: extern "C" fn(id::BindGroupLayoutId, FactoryParam), - free_bind_group: extern "C" fn(id::BindGroupId, FactoryParam), - free_command_buffer: extern "C" fn(id::CommandBufferId, FactoryParam), - free_render_pipeline: extern "C" fn(id::RenderPipelineId, FactoryParam), - free_compute_pipeline: extern "C" fn(id::ComputePipelineId, FactoryParam), - free_buffer: extern "C" fn(id::BufferId, FactoryParam), - free_texture: extern "C" fn(id::TextureId, FactoryParam), - free_texture_view: extern "C" fn(id::TextureViewId, FactoryParam), - free_sampler: extern "C" fn(id::SamplerId, FactoryParam), - free_surface: extern "C" fn(id::SurfaceId, FactoryParam), -} - -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_adapter, - param: self.param, - kind: "adapter", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_device, - param: self.param, - kind: "device", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_swap_chain, - param: self.param, - kind: "swap_chain", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_pipeline_layout, - param: self.param, - kind: "pipeline_layout", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_shader_module, - param: self.param, - kind: "shader_module", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_bind_group_layout, - param: self.param, - kind: "bind_group_layout", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_bind_group, - param: self.param, - kind: "bind_group", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_command_buffer, - param: self.param, - kind: "command_buffer", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_render_pipeline, - param: self.param, - kind: "render_pipeline", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_compute_pipeline, - param: self.param, - kind: "compute_pipeline", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_buffer, - param: self.param, - kind: "buffer", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_texture, - param: self.param, - kind: "texture", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_texture_view, - param: self.param, - kind: "texture_view", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_sampler, - param: self.param, - kind: "sampler", - } - } -} -impl core::hub::IdentityHandlerFactory for IdentityRecyclerFactory { - type Filter = IdentityRecycler; - fn spawn(&self, _min_index: u32) -> Self::Filter { - IdentityRecycler { - fun: self.free_surface, - param: self.param, - kind: "surface", - } - } -} - -impl core::hub::GlobalIdentityHandlerFactory for IdentityRecyclerFactory {} diff --git a/wgpu-remote/src/lib.rs b/wgpu-remote/src/lib.rs deleted file mode 100644 index 99b1221c8..000000000 --- a/wgpu-remote/src/lib.rs +++ /dev/null @@ -1,446 +0,0 @@ -/* 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/. */ - -use core::{hub::IdentityManager, id}; - -use wgt::Backend; - -pub use core::command::{compute_ffi::*, render_ffi::*}; - -use parking_lot::Mutex; - -use std::{ptr, slice}; - -pub mod identity; -pub mod server; - -#[derive(Debug, Default)] -struct IdentityHub { - adapters: IdentityManager, - devices: IdentityManager, - buffers: IdentityManager, - command_buffers: IdentityManager, - bind_group_layouts: IdentityManager, - pipeline_layouts: IdentityManager, - bind_groups: IdentityManager, - shader_modules: IdentityManager, - compute_pipelines: IdentityManager, - render_pipelines: IdentityManager, - textures: IdentityManager, - texture_views: IdentityManager, - samplers: IdentityManager, -} - -#[derive(Debug, Default)] -struct Identities { - surfaces: IdentityManager, - vulkan: IdentityHub, - #[cfg(any(target_os = "ios", target_os = "macos"))] - metal: IdentityHub, - #[cfg(windows)] - dx12: IdentityHub, -} - -impl Identities { - fn select(&mut self, backend: Backend) -> &mut IdentityHub { - match backend { - Backend::Vulkan => &mut self.vulkan, - #[cfg(any(target_os = "ios", target_os = "macos"))] - Backend::Metal => &mut self.metal, - #[cfg(windows)] - Backend::Dx12 => &mut self.dx12, - _ => panic!("Unexpected backend: {:?}", backend), - } - } -} - -#[derive(Debug)] -pub struct Client { - identities: Mutex, -} - -#[repr(C)] -#[derive(Debug)] -pub struct Infrastructure { - pub client: *mut Client, - pub error: *const u8, -} - -#[no_mangle] -pub extern "C" fn wgpu_client_new() -> Infrastructure { - log::info!("Initializing WGPU client"); - let client = Box::new(Client { - identities: Mutex::new(Identities::default()), - }); - Infrastructure { - client: Box::into_raw(client), - error: ptr::null(), - } -} - -/// # Safety -/// -/// This function is unsafe because improper use may lead to memory -/// problems. For example, a double-free may occur if the function is called -/// twice on the same raw pointer. -#[no_mangle] -pub unsafe extern "C" fn wgpu_client_delete(client: *mut Client) { - log::info!("Terminating WGPU client"); - let _client = Box::from_raw(client); -} - -/// # Safety -/// -/// This function is unsafe as there is no guarantee that the given pointer is -/// valid for `id_length` elements. -#[no_mangle] -pub unsafe extern "C" fn wgpu_client_make_adapter_ids( - client: &Client, - ids: *mut id::AdapterId, - id_length: usize, -) -> usize { - let mut identities = client.identities.lock(); - assert_ne!(id_length, 0); - let mut ids = slice::from_raw_parts_mut(ids, id_length).iter_mut(); - - *ids.next().unwrap() = identities.vulkan.adapters.alloc(Backend::Vulkan); - - #[cfg(any(target_os = "ios", target_os = "macos"))] - { - *ids.next().unwrap() = identities.metal.adapters.alloc(Backend::Metal); - } - #[cfg(windows)] - { - *ids.next().unwrap() = identities.dx12.adapters.alloc(Backend::Dx12); - } - - id_length - ids.len() -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_adapter_id(client: &Client, id: id::AdapterId) { - client - .identities - .lock() - .select(id.backend()) - .adapters - .free(id) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_make_device_id( - client: &Client, - adapter_id: id::AdapterId, -) -> id::DeviceId { - let backend = adapter_id.backend(); - client - .identities - .lock() - .select(backend) - .devices - .alloc(backend) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_device_id(client: &Client, id: id::DeviceId) { - client - .identities - .lock() - .select(id.backend()) - .devices - .free(id) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_make_buffer_id( - client: &Client, - device_id: id::DeviceId, -) -> id::BufferId { - let backend = device_id.backend(); - client - .identities - .lock() - .select(backend) - .buffers - .alloc(backend) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_buffer_id(client: &Client, id: id::BufferId) { - client - .identities - .lock() - .select(id.backend()) - .buffers - .free(id) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_make_texture_id( - client: &Client, - device_id: id::DeviceId, -) -> id::TextureId { - let backend = device_id.backend(); - client - .identities - .lock() - .select(backend) - .textures - .alloc(backend) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_texture_id(client: &Client, id: id::TextureId) { - client - .identities - .lock() - .select(id.backend()) - .textures - .free(id) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_make_texture_view_id( - client: &Client, - device_id: id::DeviceId, -) -> id::TextureViewId { - let backend = device_id.backend(); - client - .identities - .lock() - .select(backend) - .texture_views - .alloc(backend) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_texture_view_id(client: &Client, id: id::TextureViewId) { - client - .identities - .lock() - .select(id.backend()) - .texture_views - .free(id) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_make_sampler_id( - client: &Client, - device_id: id::DeviceId, -) -> id::SamplerId { - let backend = device_id.backend(); - client - .identities - .lock() - .select(backend) - .samplers - .alloc(backend) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_sampler_id(client: &Client, id: id::SamplerId) { - client - .identities - .lock() - .select(id.backend()) - .samplers - .free(id) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_make_encoder_id( - client: &Client, - device_id: id::DeviceId, -) -> id::CommandEncoderId { - let backend = device_id.backend(); - client - .identities - .lock() - .select(backend) - .command_buffers - .alloc(backend) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_encoder_id(client: &Client, id: id::CommandEncoderId) { - client - .identities - .lock() - .select(id.backend()) - .command_buffers - .free(id) -} - -#[no_mangle] -pub unsafe extern "C" fn wgpu_command_encoder_begin_compute_pass( - encoder_id: id::CommandEncoderId, - _desc: Option<&core::command::ComputePassDescriptor>, -) -> core::command::RawPass { - core::command::RawPass::new_compute(encoder_id) -} - -#[no_mangle] -pub unsafe extern "C" fn wgpu_compute_pass_destroy(pass: core::command::RawPass) { - let _ = pass.into_vec(); -} - -#[no_mangle] -pub unsafe extern "C" fn wgpu_command_encoder_begin_render_pass( - encoder_id: id::CommandEncoderId, - desc: &core::command::RenderPassDescriptor, -) -> core::command::RawPass { - core::command::RawPass::new_render(encoder_id, desc) -} - -#[no_mangle] -pub unsafe extern "C" fn wgpu_render_pass_destroy(pass: core::command::RawPass) { - let _ = pass.into_vec(); -} - -#[no_mangle] -pub extern "C" fn wgpu_client_make_bind_group_layout_id( - client: &Client, - device_id: id::DeviceId, -) -> id::BindGroupLayoutId { - let backend = device_id.backend(); - client - .identities - .lock() - .select(backend) - .bind_group_layouts - .alloc(backend) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_bind_group_layout_id( - client: &Client, - id: id::BindGroupLayoutId, -) { - client - .identities - .lock() - .select(id.backend()) - .bind_group_layouts - .free(id) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_make_pipeline_layout_id( - client: &Client, - device_id: id::DeviceId, -) -> id::PipelineLayoutId { - let backend = device_id.backend(); - client - .identities - .lock() - .select(backend) - .pipeline_layouts - .alloc(backend) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_pipeline_layout_id(client: &Client, id: id::PipelineLayoutId) { - client - .identities - .lock() - .select(id.backend()) - .pipeline_layouts - .free(id) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_make_bind_group_id( - client: &Client, - device_id: id::DeviceId, -) -> id::BindGroupId { - let backend = device_id.backend(); - client - .identities - .lock() - .select(backend) - .bind_groups - .alloc(backend) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_bind_group_id(client: &Client, id: id::BindGroupId) { - client - .identities - .lock() - .select(id.backend()) - .bind_groups - .free(id) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_make_shader_module_id( - client: &Client, - device_id: id::DeviceId, -) -> id::ShaderModuleId { - let backend = device_id.backend(); - client - .identities - .lock() - .select(backend) - .shader_modules - .alloc(backend) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_shader_module_id(client: &Client, id: id::ShaderModuleId) { - client - .identities - .lock() - .select(id.backend()) - .shader_modules - .free(id) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_make_compute_pipeline_id( - client: &Client, - device_id: id::DeviceId, -) -> id::ComputePipelineId { - let backend = device_id.backend(); - client - .identities - .lock() - .select(backend) - .compute_pipelines - .alloc(backend) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_compute_pipeline_id(client: &Client, id: id::ComputePipelineId) { - client - .identities - .lock() - .select(id.backend()) - .compute_pipelines - .free(id) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_make_render_pipeline_id( - client: &Client, - device_id: id::DeviceId, -) -> id::RenderPipelineId { - let backend = device_id.backend(); - client - .identities - .lock() - .select(backend) - .render_pipelines - .alloc(backend) -} - -#[no_mangle] -pub extern "C" fn wgpu_client_kill_render_pipeline_id(client: &Client, id: id::RenderPipelineId) { - client - .identities - .lock() - .select(id.backend()) - .render_pipelines - .free(id) -} diff --git a/wgpu-remote/src/server.rs b/wgpu-remote/src/server.rs deleted file mode 100644 index d6988420b..000000000 --- a/wgpu-remote/src/server.rs +++ /dev/null @@ -1,416 +0,0 @@ -/* 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/. */ - -use crate::identity::IdentityRecyclerFactory; - -use core::{gfx_select, id}; - -use std::slice; - -pub type Global = core::hub::Global; - -#[no_mangle] -pub extern "C" fn wgpu_server_new(factory: IdentityRecyclerFactory) -> *mut Global { - log::info!("Initializing WGPU server"); - Box::into_raw(Box::new(Global::new("wgpu", factory))) -} - -/// # Safety -/// -/// This function is unsafe because improper use may lead to memory -/// problems. For example, a double-free may occur if the function is called -/// twice on the same raw pointer. -#[no_mangle] -pub unsafe extern "C" fn wgpu_server_delete(global: *mut Global) { - log::info!("Terminating WGPU server"); - Box::from_raw(global).delete(); - log::info!("\t...done"); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_poll_all_devices(global: &Global, force_wait: bool) { - global.poll_all_devices(force_wait); -} - -/// 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. -/// -/// # Safety -/// -/// This function is unsafe as there is no guarantee that the given pointer is -/// valid for `id_length` elements. -#[no_mangle] -pub unsafe extern "C" fn wgpu_server_instance_request_adapter( - global: &Global, - desc: &core::instance::RequestAdapterOptions, - ids: *const id::AdapterId, - id_length: usize, -) -> i8 { - let ids = slice::from_raw_parts(ids, id_length); - match global.pick_adapter( - desc, - core::instance::AdapterInputs::IdSet(ids, |i| i.backend()), - ) { - Some(id) => ids.iter().position(|&i| i == id).unwrap() as i8, - None => -1, - } -} - -#[no_mangle] -pub extern "C" fn wgpu_server_adapter_request_device( - global: &Global, - self_id: id::AdapterId, - desc: &wgt::DeviceDescriptor, - new_id: id::DeviceId, -) { - gfx_select!(self_id => global.adapter_request_device(self_id, desc, new_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_adapter_destroy(global: &Global, adapter_id: id::AdapterId) { - gfx_select!(adapter_id => global.adapter_destroy(adapter_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_server_device_destroy(global: &Global, self_id: id::DeviceId) { - gfx_select!(self_id => global.device_destroy(self_id)) -} - -#[no_mangle] -pub extern "C" fn wgpu_server_device_create_buffer( - global: &Global, - self_id: id::DeviceId, - desc: &wgt::BufferDescriptor, - new_id: id::BufferId, -) { - gfx_select!(self_id => global.device_create_buffer(self_id, desc, new_id)); -} - -/// # Safety -/// -/// This function is unsafe as there is no guarantee that the given pointer is -/// valid for `size` elements. -#[no_mangle] -pub unsafe extern "C" fn wgpu_server_device_set_buffer_sub_data( - global: &Global, - self_id: id::DeviceId, - buffer_id: id::BufferId, - offset: wgt::BufferAddress, - data: *const u8, - size: wgt::BufferAddress, -) { - let slice = slice::from_raw_parts(data, size as usize); - gfx_select!(self_id => global.device_set_buffer_sub_data(self_id, buffer_id, offset, slice)); -} - -/// # Safety -/// -/// This function is unsafe as there is no guarantee that the given pointer is -/// valid for `size` elements. -#[no_mangle] -pub extern "C" fn wgpu_server_buffer_map_read( - global: &Global, - buffer_id: id::BufferId, - start: wgt::BufferAddress, - size: wgt::BufferAddress, - callback: core::device::BufferMapReadCallback, - userdata: *mut u8, -) { - let operation = core::resource::BufferMapOperation::Read { callback, userdata }; - - gfx_select!(buffer_id => global.buffer_map_async( - buffer_id, - wgt::BufferUsage::MAP_READ, - start .. start + size, - operation - )); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_buffer_unmap(global: &Global, buffer_id: id::BufferId) { - gfx_select!(buffer_id => global.buffer_unmap(buffer_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_buffer_destroy(global: &Global, self_id: id::BufferId) { - gfx_select!(self_id => global.buffer_destroy(self_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_device_create_encoder( - global: &Global, - self_id: id::DeviceId, - desc: &wgt::CommandEncoderDescriptor, - new_id: id::CommandEncoderId, -) { - gfx_select!(self_id => global.device_create_command_encoder(self_id, &desc, new_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_encoder_finish( - global: &Global, - self_id: id::CommandEncoderId, - desc: &wgt::CommandBufferDescriptor, -) { - gfx_select!(self_id => global.command_encoder_finish(self_id, desc)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_encoder_destroy(global: &Global, self_id: id::CommandEncoderId) { - gfx_select!(self_id => global.command_encoder_destroy(self_id)); -} - -/// # Safety -/// -/// This function is unsafe as there is no guarantee that the given pointer is -/// valid for `byte_length` elements. -#[no_mangle] -pub extern "C" fn wgpu_server_command_buffer_destroy( - global: &Global, - self_id: id::CommandBufferId, -) { - gfx_select!(self_id => global.command_buffer_destroy(self_id)); -} - -#[no_mangle] -pub unsafe extern "C" fn wgpu_server_encoder_copy_buffer_to_buffer( - global: &Global, - self_id: id::CommandEncoderId, - source_id: id::BufferId, - source_offset: wgt::BufferAddress, - destination_id: id::BufferId, - destination_offset: wgt::BufferAddress, - size: wgt::BufferAddress, -) { - gfx_select!(self_id => global.command_encoder_copy_buffer_to_buffer(self_id, source_id, source_offset, destination_id, destination_offset, size)); -} - -#[no_mangle] -pub unsafe extern "C" fn wgpu_server_encoder_copy_texture_to_buffer( - global: &Global, - self_id: id::CommandEncoderId, - source: &core::command::TextureCopyView, - destination: &core::command::BufferCopyView, - size: wgt::Extent3d, -) { - gfx_select!(self_id => global.command_encoder_copy_texture_to_buffer(self_id, source, destination, size)); -} - -#[no_mangle] -pub unsafe extern "C" fn wgpu_server_encoder_copy_buffer_to_texture( - global: &Global, - self_id: id::CommandEncoderId, - source: &core::command::BufferCopyView, - destination: &core::command::TextureCopyView, - size: wgt::Extent3d, -) { - gfx_select!(self_id => global.command_encoder_copy_buffer_to_texture(self_id, source, destination, size)); -} - -#[no_mangle] -pub unsafe extern "C" fn wgpu_server_encoder_copy_texture_to_texture( - global: &Global, - self_id: id::CommandEncoderId, - source: &core::command::TextureCopyView, - destination: &core::command::TextureCopyView, - size: wgt::Extent3d, -) { - gfx_select!(self_id => global.command_encoder_copy_texture_to_texture(self_id, source, destination, size)); -} - -/// # Safety -/// -/// This function is unsafe as there is no guarantee that the given pointers are -/// valid for `color_attachments_length` and `command_length` elements, -/// respectively. -#[no_mangle] -pub unsafe extern "C" fn wgpu_server_encode_compute_pass( - global: &Global, - self_id: id::CommandEncoderId, - bytes: *const u8, - byte_length: usize, -) { - let raw_data = slice::from_raw_parts(bytes, byte_length); - gfx_select!(self_id => global.command_encoder_run_compute_pass(self_id, raw_data)); -} - -/// # Safety -/// -/// This function is unsafe as there is no guarantee that the given pointers are -/// valid for `color_attachments_length` and `command_length` elements, -/// respectively. -#[no_mangle] -pub unsafe extern "C" fn wgpu_server_encode_render_pass( - global: &Global, - self_id: id::CommandEncoderId, - commands: *const u8, - command_length: usize, -) { - let raw_pass = slice::from_raw_parts(commands, command_length); - gfx_select!(self_id => global.command_encoder_run_render_pass(self_id, raw_pass)); -} - -/// # Safety -/// -/// This function is unsafe as there is no guarantee that the given pointer is -/// valid for `command_buffer_id_length` elements. -#[no_mangle] -pub unsafe extern "C" fn wgpu_server_queue_submit( - global: &Global, - self_id: id::QueueId, - command_buffer_ids: *const id::CommandBufferId, - command_buffer_id_length: usize, -) { - let command_buffers = slice::from_raw_parts(command_buffer_ids, command_buffer_id_length); - gfx_select!(self_id => global.queue_submit(self_id, command_buffers)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_device_create_bind_group_layout( - global: &Global, - self_id: id::DeviceId, - desc: &core::binding_model::BindGroupLayoutDescriptor, - new_id: id::BindGroupLayoutId, -) { - gfx_select!(self_id => global.device_create_bind_group_layout(self_id, desc, new_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_bind_group_layout_destroy( - global: &Global, - self_id: id::BindGroupLayoutId, -) { - gfx_select!(self_id => global.bind_group_layout_destroy(self_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_device_create_pipeline_layout( - global: &Global, - self_id: id::DeviceId, - desc: &core::binding_model::PipelineLayoutDescriptor, - new_id: id::PipelineLayoutId, -) { - gfx_select!(self_id => global.device_create_pipeline_layout(self_id, desc, new_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_pipeline_layout_destroy( - global: &Global, - self_id: id::PipelineLayoutId, -) { - gfx_select!(self_id => global.pipeline_layout_destroy(self_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_device_create_bind_group( - global: &Global, - self_id: id::DeviceId, - desc: &core::binding_model::BindGroupDescriptor, - new_id: id::BindGroupId, -) { - gfx_select!(self_id => global.device_create_bind_group(self_id, desc, new_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_bind_group_destroy(global: &Global, self_id: id::BindGroupId) { - gfx_select!(self_id => global.bind_group_destroy(self_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_device_create_shader_module( - global: &Global, - self_id: id::DeviceId, - desc: &core::pipeline::ShaderModuleDescriptor, - new_id: id::ShaderModuleId, -) { - gfx_select!(self_id => global.device_create_shader_module(self_id, desc, new_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_shader_module_destroy(global: &Global, self_id: id::ShaderModuleId) { - gfx_select!(self_id => global.shader_module_destroy(self_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_device_create_compute_pipeline( - global: &Global, - self_id: id::DeviceId, - desc: &core::pipeline::ComputePipelineDescriptor, - new_id: id::ComputePipelineId, -) { - gfx_select!(self_id => global.device_create_compute_pipeline(self_id, desc, new_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_compute_pipeline_destroy( - global: &Global, - self_id: id::ComputePipelineId, -) { - gfx_select!(self_id => global.compute_pipeline_destroy(self_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_device_create_render_pipeline( - global: &Global, - self_id: id::DeviceId, - desc: &core::pipeline::RenderPipelineDescriptor, - new_id: id::RenderPipelineId, -) { - gfx_select!(self_id => global.device_create_render_pipeline(self_id, desc, new_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_render_pipeline_destroy( - global: &Global, - self_id: id::RenderPipelineId, -) { - gfx_select!(self_id => global.render_pipeline_destroy(self_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_device_create_texture( - global: &Global, - self_id: id::DeviceId, - desc: &wgt::TextureDescriptor, - new_id: id::TextureId, -) { - gfx_select!(self_id => global.device_create_texture(self_id, desc, new_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_texture_create_view( - global: &Global, - self_id: id::TextureId, - desc: Option<&wgt::TextureViewDescriptor>, - new_id: id::TextureViewId, -) { - gfx_select!(self_id => global.texture_create_view(self_id, desc, new_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_texture_destroy(global: &Global, self_id: id::TextureId) { - gfx_select!(self_id => global.texture_destroy(self_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_texture_view_destroy(global: &Global, self_id: id::TextureViewId) { - gfx_select!(self_id => global.texture_view_destroy(self_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_device_create_sampler( - global: &Global, - self_id: id::DeviceId, - desc: &wgt::SamplerDescriptor, - new_id: id::SamplerId, -) { - gfx_select!(self_id => global.device_create_sampler(self_id, desc, new_id)); -} - -#[no_mangle] -pub extern "C" fn wgpu_server_sampler_destroy(global: &Global, self_id: id::SamplerId) { - gfx_select!(self_id => global.sampler_destroy(self_id)); -}