Add initial bindings

This commit is contained in:
grovesNL 2018-09-22 16:54:19 -06:00
parent 99edaa256f
commit 5759f769b0
22 changed files with 481 additions and 261 deletions

262
Cargo.lock generated
View File

@ -3,6 +3,14 @@ name = "android_glue"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ash"
version = "0.24.4"
@ -13,6 +21,16 @@ dependencies = [
"shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "atty"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "backtrace"
version = "0.3.9"
@ -22,7 +40,7 @@ dependencies = [
"cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -49,6 +67,21 @@ name = "byteorder"
version = "1.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cbindgen"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cc"
version = "1.0.25"
@ -59,6 +92,20 @@ name = "cfg-if"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "clap"
version = "2.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cloudabi"
version = "0.0.3"
@ -86,7 +133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"objc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -118,7 +165,7 @@ dependencies = [
[[package]]
name = "core-graphics"
version = "0.17.0"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -155,6 +202,13 @@ name = "either"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "examples"
version = "0.1.0"
dependencies = [
"wgpu-native 0.1.0",
]
[[package]]
name = "failure"
version = "0.1.2"
@ -226,7 +280,7 @@ dependencies = [
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"spirv_cross 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"winit 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
"wio 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -247,7 +301,7 @@ dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cocoa 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -255,7 +309,7 @@ dependencies = [
"objc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"spirv_cross 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
"spirv_cross 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
"storage-map 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winit 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -271,7 +325,7 @@ dependencies = [
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"winit 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
"x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)",
"xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -306,6 +360,11 @@ dependencies = [
"either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "itoa"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lazy_static"
version = "0.2.11"
@ -330,7 +389,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -364,7 +423,7 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -375,7 +434,7 @@ dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cocoa 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.17.1 (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.43 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -457,7 +516,7 @@ dependencies = [
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -500,7 +559,7 @@ dependencies = [
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -508,11 +567,32 @@ name = "rand_core"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "redox_syscall"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "redox_termios"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "relevant"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "remove_dir_all"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc-demangle"
version = "0.1.9"
@ -526,6 +606,11 @@ dependencies = [
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ryu"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "scopeguard"
version = "0.3.3"
@ -544,6 +629,43 @@ name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde_derive 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_derive"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive_internals 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_derive_internals"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
"synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_json"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "shared_library"
version = "0.1.9"
@ -587,7 +709,7 @@ dependencies = [
[[package]]
name = "spirv_cross"
version = "0.11.1"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
@ -606,6 +728,11 @@ dependencies = [
"lock_api 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "strsim"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "syn"
version = "0.10.8"
@ -615,6 +742,16 @@ dependencies = [
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syn"
version = "0.11.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syn"
version = "0.14.9"
@ -625,6 +762,14 @@ dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "synom"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "synstructure"
version = "0.9.0"
@ -636,6 +781,50 @@ dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tempfile"
version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "termion"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "textwrap"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "toml"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unicode-width"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.0.4"
@ -654,6 +843,11 @@ dependencies = [
"void 1.0.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 = "version_check"
version = "0.1.4"
@ -714,6 +908,13 @@ dependencies = [
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wgpu-bindings"
version = "0.1.0"
dependencies = [
"cbindgen 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wgpu-native"
version = "0.1.0"
@ -725,11 +926,12 @@ dependencies = [
"gfx-backend-vulkan 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)",
"gfx-memory 0.1.0 (git+https://github.com/gfx-rs/gfx-memory?rev=483d64d)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
version = "0.3.5"
version = "0.3.6"
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)",
@ -763,7 +965,7 @@ dependencies = [
"percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"smithay-client-toolkit 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"wayland-client 0.20.12 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"x11-dl 2.18.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -772,7 +974,7 @@ name = "wio"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -813,21 +1015,25 @@ dependencies = [
[metadata]
"checksum android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum ash 0.24.4 (registry+https://github.com/rust-lang/crates.io-index)" = "11f080bc0414ee1b6b959442cb36478d56c6e6b9bb2b04079a5048d9acc91a30"
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a"
"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0"
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
"checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781"
"checksum cbindgen 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f1f920442b99c6eb6208905a2b71b055e4c8f170287fbe7c7ceb9b6cd206878d"
"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3"
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum cocoa 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5cd1afb83b2de9c41e5dfedb2bcccb779d433b958404876009ae4b01746ff23"
"checksum cocoa 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "53a840785348e998a1433d1f9d0b350fd83e91711fae8507c76ce510afc77e72"
"checksum core-foundation 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cc3532ec724375c7cb7ff0a097b714fde180bb1f6ed2ab27cfcd99ffca873cd2"
"checksum core-foundation-sys 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a3fb15cdbdd9cf8b82d97d0296bb5cd3631bba58d6e31650a002a8e7fb5721f9"
"checksum core-graphics 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92801c908ea6301ae619ed842a72e01098085fc321b9c2f3f833dad555bba055"
"checksum core-graphics 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de51fc45f0de4bc07e7ecdb172f0559e0f19ca016a0059577a149b11a2f05324"
"checksum core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "62ceafe1622ffc9a332199096841d0ff9912ec8cf8f9cde01e254a7d5217cd10"
"checksum derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67b3d6d0e84e53a5bdc263cc59340541877bb541706a191d762bfac6a481bdde"
"checksum dlib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a"
"checksum downcast-rs 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "18df8ce4470c189d18aa926022da57544f31e154631eb4cfe796aea97051fe6c"
@ -847,6 +1053,7 @@ dependencies = [
"checksum gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=a435a05)" = "<none>"
"checksum gfx-memory 0.1.0 (git+https://github.com/gfx-rs/gfx-memory?rev=483d64d)" = "<none>"
"checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc"
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7"
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
@ -871,25 +1078,42 @@ dependencies = [
"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5"
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
"checksum rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edecf0f94da5551fc9b492093e30b041a891657db7940ee221f9d2f66e82eef2"
"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum relevant 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c2b087c662aa6d36c6bb22c44a97911196ffd4a1df324c1fabdbcb80d18b0302"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9"
"checksum serde_derive 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "652bc323d694dc925829725ec6c890156d8e70ae5202919869cb00fe2eff3788"
"checksum serde_derive_internals 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "32f1926285523b2db55df263d2aa4eb69ddcfa7a7eade6430323637866b513ab"
"checksum serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "d30ec34ac923489285d24688c7a9c0898d16edff27fc1f1bd854edeff6ca3b7f"
"checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"
"checksum smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d"
"checksum smithay-client-toolkit 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1609083d6bca3991a3c648d80ae16e1764d70881c3321bee1c915149073d605"
"checksum spirv_cross 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1c2c0be48967fec392de4749ac34a2da758aaa359ca648abaa47b90b36845013"
"checksum spirv_cross 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e1b0b4e01f61e50a6e223fde32934883df4086004174a1fc522fc97bda2ce938"
"checksum spirv_cross 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2cc3aef2f7822a4fdd4174f547700f208bbc0f0871c59b754573717c92fd29f4"
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
"checksum storage-map 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cb94f167ccba0941876c8e722e888be8b4c05511ffdacc8cfcd4c647adfd424d"
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
"checksum syn 0.10.8 (registry+https://github.com/rust-lang/crates.io-index)" = "58fd09df59565db3399efbba34ba8a2fec1307511ebd245d0061ff9d42691673"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
"checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7"
"checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b"
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6"
"checksum toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a0263c6c02c4db6c8f7681f9fd35e90de799ebd4cfdeab77a38f4ff6b3d8c0d9"
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
"checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum wayland-client 0.20.12 (registry+https://github.com/rust-lang/crates.io-index)" = "e7516a23419a55bd2e6d466c75a6a52c85718e5013660603289c2b8bee794b12"
@ -897,7 +1121,7 @@ dependencies = [
"checksum wayland-protocols 0.20.12 (registry+https://github.com/rust-lang/crates.io-index)" = "bd4d31a96be6ecdbaddbf35200f5af2daee01be592afecd8feaf443d417e9230"
"checksum wayland-scanner 0.20.12 (registry+https://github.com/rust-lang/crates.io-index)" = "e674d85ae9c67cbbc590374d8f2e20a7a02fff87ce3a31fc52213afece8d05ad"
"checksum wayland-sys 0.20.12 (registry+https://github.com/rust-lang/crates.io-index)" = "87c82ee658aa657fdfd7061f22e442030d921cfefc5bad68bcf41973e67922f7"
"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd"
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
"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 winit 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ba44cf306b981badc781894ab5d6fda54764a0512cbbf8db4685d329014143fa"

View File

@ -1,4 +1,6 @@
[workspace]
members = [
"wgpu-native",
"wgpu-bindings",
"examples",
]

21
examples/Cargo.toml Normal file
View File

@ -0,0 +1,21 @@
[package]
name = "examples"
version = "0.1.0"
authors = [
"Dzmitry Malyshau <kvark@mozilla.com>",
"Joshua Groves <josh@joshgroves.com>",
]
publish = false
[[bin]]
name = "hello_triangle"
path = "hello_triangle/main.rs"
[features]
default = []
metal = ["wgpu-native/metal"]
dx12 = ["wgpu-native/dx12"]
vulkan = ["wgpu-native/vulkan"]
[dependencies]
wgpu-native = { path = "../wgpu-native" }

View File

@ -11,9 +11,9 @@ fn main() {
},
});
let _vs = wgn::device_create_shader_module(device, wgn::ShaderModuleDescriptor {
code: include_bytes!("./data/hello_triangle.vert.spv"),
code: include_bytes!("./shaders/hello_triangle.vert.spv"),
});
let _fs = wgn::device_create_shader_module(device, wgn::ShaderModuleDescriptor {
code: include_bytes!("./data/hello_triangle.frag.spv"),
code: include_bytes!("./shaders/hello_triangle.frag.spv"),
});
}

13
wgpu-bindings/Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "wgpu-bindings"
version = "0.1.0"
authors = [
"Dzmitry Malyshau <kvark@mozilla.com>",
"Joshua Groves <josh@joshgroves.com>",
]
[features]
default = []
[dependencies]
cbindgen = "0.6.3"

54
wgpu-bindings/bindings.h Normal file
View File

@ -0,0 +1,54 @@
#include <cstdint>
#include <cstdlib>
enum class PowerPreference {
Default = 0,
LowPower = 1,
HighPerformance = 2,
};
struct ShaderModuleDescriptor;
using Id = uint32_t;
using DeviceId = Id;
using AdapterId = Id;
struct Extensions {
bool anisotropic_filtering;
};
struct DeviceDescriptor {
Extensions extensions;
};
using ComputePassId = Id;
using RenderPassId = Id;
using CommandBufferId = Id;
using InstanceId = Id;
using ShaderModuleId = Id;
struct AdapterDescriptor {
PowerPreference power_preference;
};
extern "C" {
DeviceId adapter_create_device(AdapterId adapter_id, DeviceDescriptor desc);
ComputePassId command_buffer_begin_compute_pass();
RenderPassId command_buffer_begin_render_pass(CommandBufferId command_buffer);
InstanceId create_instance();
ShaderModuleId device_create_shader_module(DeviceId device_id, ShaderModuleDescriptor desc);
AdapterId instance_get_adapter(InstanceId instance_id, AdapterDescriptor desc);
} // extern "C"

14
wgpu-bindings/src/main.rs Normal file
View File

@ -0,0 +1,14 @@
extern crate cbindgen;
use std::path::PathBuf;
fn main() {
let mut crate_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
crate_dir.push("../wgpu-native");
cbindgen::Builder::new()
.with_crate(crate_dir)
.generate()
.expect("Unable to generate bindings")
.write_to_file("bindings.h");
}

View File

@ -6,11 +6,18 @@ authors = [
"Joshua Groves <josh@joshgroves.com>",
]
[lib]
crate-type = ["lib", "cdylib", "staticlib"]
[features]
default = []
metal = ["gfx-backend-metal"]
dx12 = ["gfx-backend-dx12"]
vulkan = ["gfx-backend-vulkan"]
[dependencies]
bitflags = "1.0"
lazy_static = "1.1.0"
gfx-hal = { git = "https://github.com/gfx-rs/gfx", rev = "a435a05" } # required by gfx-memory
gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "a435a05" }
gfx-backend-vulkan = { git = "https://github.com/gfx-rs/gfx", rev = "a435a05", optional = true }

View File

@ -1,6 +1,6 @@
use hal;
use {BindGroupLayoutHandle, BufferHandle, SamplerHandle, TextureViewHandle};
use {BindGroupLayoutId, BufferId, SamplerId, TextureViewId};
bitflags! {
#[repr(transparent)]
@ -38,7 +38,7 @@ pub struct BindGroupLayout {
#[repr(C)]
pub struct PipelineLayoutDescriptor<'a> {
pub bind_group_layouts: &'a [BindGroupLayoutHandle],
pub bind_group_layouts: &'a [BindGroupLayoutId],
}
pub struct PipelineLayout<B: hal::Backend> {
@ -47,7 +47,7 @@ pub struct PipelineLayout<B: hal::Backend> {
#[repr(C)]
pub struct BufferBinding {
pub buffer: BufferHandle,
pub buffer: BufferId,
pub offset: u32,
pub size: u32,
}
@ -55,8 +55,8 @@ pub struct BufferBinding {
#[repr(C)]
pub enum BindingResource {
Buffer(BufferBinding),
Sampler(SamplerHandle),
TextureView(TextureViewHandle),
Sampler(SamplerId),
TextureView(TextureViewId),
}
#[repr(C)]

View File

@ -1,25 +1,8 @@
use hal;
use {CommandBuffer, CommandBufferHandle, ComputePassHandle};
use {CommandBuffer, CommandBufferId, ComputePassId};
pub struct ComputePass<B: hal::Backend> {
raw: B::CommandBuffer,
}
pub extern "C"
fn compute_pass_dispatch(
pass: ComputePassHandle, groups_x: u32, groups_y: u32, groups_z: u32
) {
unimplemented!()
}
pub extern "C"
fn compute_pass_end(pass: ComputePassHandle) -> CommandBufferHandle {
match pass.unbox() {
Some(pass) => CommandBufferHandle::new(CommandBuffer {
raw: pass.raw,
}),
None => CommandBufferHandle::null(),
}
}

View File

@ -6,8 +6,8 @@ pub use self::render::*;
use hal;
use {BufferHandle, Color, CommandBufferHandle, ComputePassHandle, Origin3d,
RenderPassHandle, TextureViewHandle, TextureHandle};
use {BufferId, Color, CommandBufferId, ComputePassId, Origin3d,
RenderPassId, TextureViewId, TextureId};
#[repr(C)]
@ -23,7 +23,7 @@ pub enum StoreOp {
#[repr(C)]
pub struct RenderPassColorAttachmentDescriptor {
pub attachment: TextureViewHandle,
pub attachment: TextureViewId,
pub load_op: LoadOp,
pub store_op: StoreOp,
pub clear_color: Color,
@ -31,7 +31,7 @@ pub struct RenderPassColorAttachmentDescriptor {
#[repr(C)]
pub struct RenderPassDepthStencilAttachmentDescriptor {
pub attachment: TextureViewHandle,
pub attachment: TextureViewId,
pub depth_load_op: LoadOp,
pub depth_store_op: StoreOp,
pub clear_depth: f32,
@ -48,7 +48,7 @@ pub struct RenderPassDescriptor<'a> {
#[repr(C)]
pub struct BufferCopyView {
pub buffer: BufferHandle,
pub buffer: BufferId,
pub offset: u32,
pub row_pitch: u32,
pub image_height: u32,
@ -56,7 +56,7 @@ pub struct BufferCopyView {
#[repr(C)]
pub struct TextureCopyView {
pub texture: TextureHandle,
pub texture: TextureId,
pub level: u32,
pub slice: u32,
pub origin: Origin3d,
@ -70,15 +70,15 @@ pub struct CommandBuffer<B: hal::Backend> {
#[repr(C)]
pub struct CommandBufferDescriptor;
pub extern "C"
fn command_buffer_begin_render_pass(
command_buffer: CommandBufferHandle
) -> RenderPassHandle {
#[no_mangle]
pub extern "C" fn command_buffer_begin_render_pass(
command_buffer: CommandBufferId
) -> RenderPassId {
unimplemented!()
}
pub extern "C"
fn command_buffer_begin_compute_pass(
) -> ComputePassHandle {
#[no_mangle]
pub extern "C" fn command_buffer_begin_compute_pass(
) -> ComputePassId {
unimplemented!()
}

View File

@ -1,32 +1,8 @@
use hal;
use {CommandBuffer, CommandBufferHandle, RenderPassHandle};
use {CommandBuffer, CommandBufferId, RenderPassId};
pub struct RenderPass<B: hal::Backend> {
raw: B::CommandBuffer,
}
pub extern "C"
fn render_pass_draw(
pass: RenderPassHandle, vertex_count: u32, instance_count: u32, first_vertex: u32, first_instance: u32
) {
unimplemented!()
}
pub extern "C"
fn render_pass_draw_indexed(
pass: RenderPassHandle, index_count: u32, instance_count: u32, first_index: u32, vertex_offset: i32, first_instance: u32
) {
unimplemented!()
}
pub extern "C"
fn render_pass_end(pass: RenderPassHandle) -> CommandBufferHandle {
match pass.unbox() {
Some(pass) => CommandBufferHandle::new(CommandBuffer {
raw: pass.raw,
}),
None => CommandBufferHandle::null(),
}
}

View File

@ -1,7 +1,8 @@
use hal::{self, Device as _Device, QueueGroup};
use {conv, memory, pipeline, resource};
use {BufferHandle, CommandBufferHandle, DeviceHandle, ShaderModuleHandle};
use registry;
use {BufferId, CommandBufferId, DeviceId, ShaderModuleId};
#[repr(C)]
@ -28,35 +29,18 @@ impl<B: hal::Backend> Device<B> {
}
}
pub extern "C"
fn device_create_buffer(
device: DeviceHandle, desc: resource::BufferDescriptor
) -> BufferHandle {
let (usage, memory_properties) = conv::map_buffer_usage(desc.usage);
let buffer = device.device.create_buffer(desc.size as u64, usage).unwrap();
BufferHandle::new(resource::Buffer {
raw: buffer,
memory_properties,
})
}
pub struct ShaderModule<B: hal::Backend> {
pub raw: B::ShaderModule,
}
pub extern "C"
fn device_create_shader_module(
device: DeviceHandle, desc: pipeline::ShaderModuleDescriptor
) -> ShaderModuleHandle {
#[no_mangle]
pub extern "C" fn device_create_shader_module(
device_id: DeviceId, desc: pipeline::ShaderModuleDescriptor
) -> ShaderModuleId {
let device_registry = registry::DEVICE_REGISTRY.lock().unwrap();
let device = device_registry.get(device_id).unwrap();
let shader = device.device.create_shader_module(desc.code).unwrap();
ShaderModuleHandle::new(ShaderModule {
registry::SHADER_MODULE_REGISTRY.lock().unwrap().register(ShaderModule {
raw: shader,
})
}
pub extern "C"
fn device_create_command_buffer(
device: DeviceHandle, desc: CommandBufferDescriptor
) -> CommandBufferHandle {
unimplemented!()
}

View File

@ -1,113 +0,0 @@
use std::{borrow, cmp, fmt, ops, ptr};
#[cfg(feature = "nightly")]
use std::sync::{Arc, Mutex};
#[cfg(feature = "nightly")]
use hal::backend::FastHashMap;
#[cfg(feature = "nightly")]
lazy_static! {
static ref REGISTRY: Arc<Mutex<FastHashMap<usize, &'static str>>> = Arc::new(Mutex::new(FastHashMap::default()));
}
#[repr(C)]
pub struct Handle<T>(*mut T);
#[cfg(feature = "nightly")]
impl Handle<()> {
pub fn report_leaks() {
println!("Leaked handles:");
let mut map = REGISTRY.lock().unwrap();
for (_, type_id) in map.drain() {
println!("\t{:?}", type_id);
}
}
}
impl<T: 'static> Handle<T> {
pub fn new(value: T) -> Self {
let ptr = Box::into_raw(Box::new(value));
#[cfg(feature = "nightly")]
{
use std::intrinsics::type_name;
let name = unsafe { type_name::<T>() };
REGISTRY.lock().unwrap().insert(ptr as _, name);
}
Handle(ptr)
}
pub fn null() -> Self {
Handle(ptr::null_mut())
}
pub fn unbox(self) -> Option<T> {
if self.0.is_null() {
None
} else {
#[cfg(feature = "nightly")]
{
REGISTRY.lock().unwrap().remove(&(self.0 as _)).unwrap();
}
Some(*unsafe { Box::from_raw(self.0) })
}
}
pub fn as_ref(&self) -> Option<&T> {
unsafe { self.0.as_ref() }
}
}
impl<T> Handle<T> {
#[cfg(feature = "nightly")]
#[inline]
fn check(&self) {
assert!(REGISTRY.lock().unwrap().contains_key(&(self.0 as _)));
}
#[cfg(not(feature = "nightly"))]
#[inline]
fn check(&self) {
debug_assert!(!self.0.is_null());
}
}
impl<T> Clone for Handle<T> {
fn clone(&self) -> Self {
Handle(self.0)
}
}
impl<T> Copy for Handle<T> {}
impl<T> ops::Deref for Handle<T> {
type Target = T;
fn deref(&self) -> &T {
self.check();
unsafe { &*self.0 }
}
}
impl<T> ops::DerefMut for Handle<T> {
fn deref_mut(&mut self) -> &mut T {
self.check();
unsafe { &mut *self.0 }
}
}
impl<T> borrow::Borrow<T> for Handle<T> {
fn borrow(&self) -> &T {
self.check();
unsafe { &*self.0 }
}
}
impl<T> cmp::PartialEq for Handle<T> {
fn eq(&self, other: &Self) -> bool {
self.0.eq(&other.0)
}
}
impl<T> fmt::Debug for Handle<T> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "Handle({:p})", self.0)
}
}

View File

@ -1,6 +1,7 @@
use hal::{self, Instance as _Instance, PhysicalDevice as _PhysicalDevice};
use {AdapterHandle, Device, DeviceHandle, InstanceHandle};
use registry;
use {AdapterId, Device, DeviceId, InstanceId};
#[repr(C)]
@ -25,12 +26,13 @@ pub struct DeviceDescriptor {
pub extensions: Extensions,
}
pub extern "C"
fn create_instance() -> InstanceHandle {
#[no_mangle]
pub extern "C" fn create_instance() -> InstanceId {
#[cfg(any(feature = "gfx-backend-vulkan", feature = "gfx-backend-dx12", feature = "gfx-backend-metal"))]
{
let mut registry = registry::INSTANCE_REGISTRY.lock().unwrap();
let inst = ::back::Instance::create("wgpu", 1);
InstanceHandle::new(inst)
registry.register(inst)
}
#[cfg(not(any(feature = "gfx-backend-vulkan", feature = "gfx-backend-dx12", feature = "gfx-backend-metal")))]
{
@ -38,10 +40,13 @@ fn create_instance() -> InstanceHandle {
}
}
pub extern "C"
fn instance_get_adapter(
instance: InstanceHandle, desc: AdapterDescriptor
) -> AdapterHandle {
#[no_mangle]
pub extern "C" fn instance_get_adapter(
instance_id: InstanceId, desc: AdapterDescriptor
) -> AdapterId {
let instance_registry = registry::INSTANCE_REGISTRY.lock().unwrap();
let instance = instance_registry.get(instance_id).unwrap();
let (mut low, mut high, mut other) = (None, None, None);
for adapter in instance.enumerate_adapters() {
match adapter.info.device_type {
@ -56,14 +61,16 @@ fn instance_get_adapter(
PowerPreference::HighPerformance |
PowerPreference::Default => high.or(low),
};
AdapterHandle::new(some.or(other).unwrap())
registry::ADAPTER_REGISTRY.lock().unwrap().register(some.or(other).unwrap())
}
pub extern "C"
fn adapter_create_device(
mut adapter: AdapterHandle, desc: DeviceDescriptor
) -> DeviceHandle {
#[no_mangle]
pub extern "C" fn adapter_create_device(
adapter_id: AdapterId, desc: DeviceDescriptor
) -> DeviceId {
let mut adapter_registry = registry::ADAPTER_REGISTRY.lock().unwrap();
let adapter = adapter_registry.get_mut(adapter_id).unwrap();
let (device, queue_group) = adapter.open_with::<_, hal::General>(1, |_qf| true).unwrap();
let mem_props = adapter.physical_device.memory_properties();
DeviceHandle::new(Device::new(device, queue_group, mem_props))
registry::DEVICE_REGISTRY.lock().unwrap().register(Device::new(device, queue_group, mem_props))
}

View File

@ -1,4 +1,5 @@
#[macro_use] extern crate bitflags;
#[macro_use] extern crate lazy_static;
#[cfg(feature = "gfx-backend-vulkan")]
extern crate gfx_backend_vulkan as back;
@ -13,12 +14,12 @@ extern crate gfx_hal as hal;
extern crate gfx_memory as memory;
mod binding_model;
mod conv;
mod command;
mod conv;
mod device;
mod handle;
mod instance;
mod pipeline;
mod registry;
mod resource;
pub use self::binding_model::*;
@ -29,7 +30,7 @@ pub use self::pipeline::*;
pub use self::resource::*;
use back::Backend as B;
use handle::Handle;
use registry::Id;
#[repr(C)]
pub struct Color {
@ -53,29 +54,33 @@ pub struct Extent3d {
pub depth: f32,
}
pub type InstanceHandle = Handle<back::Instance>;
pub type AdapterHandle = Handle<hal::Adapter<B>>;
pub type DeviceHandle = Handle<Device<B>>;
pub type BufferHandle = Handle<Buffer<B>>;
pub type InstanceId = Id;
pub(crate) type InstanceHandle = back::Instance;
pub type AdapterId = Id;
pub(crate) type AdapterHandle = hal::Adapter<B>;
pub type DeviceId = Id;
pub(crate) type DeviceHandle = Device<B>;
pub type BufferId = Id;
// Resource
pub type TextureViewHandle = Handle<TextureView>;
pub type TextureHandle = Handle<Texture>;
pub type SamplerHandle = Handle<Sampler>;
pub type TextureViewId = Id;
pub type TextureId = Id;
pub type SamplerId = Id;
// Binding model
pub type BindGroupLayoutHandle = Handle<BindGroupLayout>;
pub type PipelineLayoutHandle = Handle<PipelineLayout<B>>;
pub type BindGroupLayoutId = Id;
pub type PipelineLayoutId = Id;
// Pipeline
pub type BlendStateHandle = Handle<BlendState>;
pub type DepthStencilStateHandle = Handle<DepthStencilState>;
pub type InputStateHandle = Handle<InputState>;
pub type ShaderModuleHandle = Handle<ShaderModule<B>>;
pub type AttachmentStateHandle = Handle<AttachmentState>;
pub type ComputePipelineHandle = Handle<ComputePipeline>;
pub type RenderPipelineHandle = Handle<RenderPipeline>;
pub type BlendStateId = Id;
pub type DepthStencilStateId = Id;
pub type InputStateId = Id;
pub type ShaderModuleId = Id;
pub(crate) type ShaderModuleHandle = ShaderModule<B>;
pub type AttachmentStateId = Id;
pub type ComputePipelineId = Id;
pub type RenderPipelineId = Id;
pub type CommandBufferHandle = Handle<CommandBuffer<B>>;
pub type RenderPassHandle = Handle<RenderPass<B>>;
pub type ComputePassHandle = Handle<ComputePass<B>>;
pub type CommandBufferId = Id;
pub type RenderPassId = Id;
pub type ComputePassId = Id;

View File

@ -1,7 +1,7 @@
use hal;
use resource;
use {BlendStateHandle, DepthStencilStateHandle, PipelineLayoutHandle};
use {BlendStateId, DepthStencilStateId, PipelineLayoutId};
#[repr(C)]
@ -171,7 +171,7 @@ pub struct PipelineStageDescriptor<'a> {
#[repr(C)]
pub struct ComputePipelineDescriptor<'a> {
pub layout: PipelineLayoutHandle,
pub layout: PipelineLayoutId,
pub stages: &'a [PipelineStageDescriptor<'a>],
}
@ -190,11 +190,11 @@ pub enum PrimitiveTopology {
#[repr(C)]
pub struct RenderPipelineDescriptor<'a> {
pub layout: PipelineLayoutHandle,
pub layout: PipelineLayoutId,
pub stages: &'a [PipelineStageDescriptor<'a>],
pub primitive_topology: PrimitiveTopology,
pub blend_state: &'a [BlendStateHandle],
pub depth_stencil_state: DepthStencilStateHandle,
pub blend_state: &'a [BlendStateId],
pub depth_stencil_state: DepthStencilStateId,
pub attachment_state: AttachmentState,
}

View File

@ -0,0 +1,43 @@
use std::{borrow, cmp, fmt, ops, ptr};
use std::sync::{Arc, Mutex};
use hal::backend::FastHashMap;
use {AdapterHandle, DeviceHandle, InstanceHandle, ShaderModuleHandle};
pub(crate) type Id = u32;
pub(crate) struct Registry<T> {
next_id: Id,
tracked: FastHashMap<Id, T>,
}
impl<T> Registry<T> {
fn new() -> Self {
Registry {
next_id: 0,
tracked: FastHashMap::default(),
}
}
pub(crate) fn register(&mut self, handle: T) -> Id {
let id = self.next_id;
self.tracked.insert(id, handle);
self.next_id += 1;
id
}
pub(crate) fn get(&self, id: Id) -> Option<&T> {
self.tracked.get(&id)
}
pub(crate) fn get_mut(&mut self, id: Id) -> Option<&mut T> {
self.tracked.get_mut(&id)
}
}
lazy_static! {
pub(crate) static ref ADAPTER_REGISTRY: Arc<Mutex<Registry<AdapterHandle>>> = Arc::new(Mutex::new(Registry::new()));
pub(crate) static ref DEVICE_REGISTRY: Arc<Mutex<Registry<DeviceHandle>>> = Arc::new(Mutex::new(Registry::new()));
pub(crate) static ref INSTANCE_REGISTRY: Arc<Mutex<Registry<InstanceHandle>>> = Arc::new(Mutex::new(Registry::new()));
pub(crate) static ref SHADER_MODULE_REGISTRY: Arc<Mutex<Registry<ShaderModuleHandle>>> = Arc::new(Mutex::new(Registry::new()));
}