mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
web: reimplement adapter|device_features (#3428)
This commit is contained in:
@@ -56,6 +56,7 @@ Bottom level categories:
|
||||
|
||||
- Implement `CommandEncoder::clear_buffer`. By @raphlinus in [#3426](https://github.com/gfx-rs/wgpu/pull/3426)
|
||||
- Implement the new checks for readonly stencils. By @JCapucho in [#3443](https://github.com/gfx-rs/wgpu/pull/3443)
|
||||
- Reimplement `adapter|device_features`. By @jinleili in [#3428](https://github.com/gfx-rs/wgpu/pull/3428)
|
||||
|
||||
#### Vulkan
|
||||
|
||||
|
||||
67
Cargo.lock
generated
67
Cargo.lock
generated
@@ -260,9 +260,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cargo-run-wasm"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "611b811fad83eebfcdcf47ae1e425c82d1249608bc571d537448d706be08cf27"
|
||||
checksum = "13b0eb1208f33599c1fea41f2f6a09bb7e27341acb79aa92e6d6847cc60a1828"
|
||||
dependencies = [
|
||||
"devserver_lib",
|
||||
"pico-args",
|
||||
@@ -1314,9 +1314,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.60"
|
||||
version = "0.3.61"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47"
|
||||
checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
@@ -2672,9 +2672,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
|
||||
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
@@ -2682,9 +2682,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
|
||||
checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
@@ -2697,9 +2697,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-cli-support"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03f35e0387a2c787ca5ee299bfb4259352b2a2184b406f8ee9f978c3c4671645"
|
||||
checksum = "9d4780c659b883a19ddb7ced365db19f7f45cd182d832ee14de2b7ef52e88a9f"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.9.3",
|
||||
@@ -2707,6 +2707,7 @@ dependencies = [
|
||||
"rustc-demangle",
|
||||
"serde_json",
|
||||
"tempfile",
|
||||
"unicode-ident",
|
||||
"walrus",
|
||||
"wasm-bindgen-externref-xform",
|
||||
"wasm-bindgen-multi-value-xform",
|
||||
@@ -2721,9 +2722,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-externref-xform"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d010a32a516a793adbea5835eab6f736d11c0cdd10ebe0c762c420f67510244"
|
||||
checksum = "1d154c3843bf3b635b602ad41b56f505f8f1a25f8a0133fca4bbd0918d74efdc"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"walrus",
|
||||
@@ -2731,9 +2732,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.33"
|
||||
version = "0.4.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d"
|
||||
checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
@@ -2743,9 +2744,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
|
||||
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -2753,9 +2754,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
|
||||
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -2766,9 +2767,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-multi-value-xform"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78b8c8d5dcc451b7e6a9c98d8fd966ff768a1e8f8afb270a829780086f2885ac"
|
||||
checksum = "c00a577fbd4be358ef8095432189b5c2e6b6e71f5081797c2032572f77d65d26"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"walrus",
|
||||
@@ -2776,9 +2777,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
|
||||
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test"
|
||||
@@ -2806,9 +2807,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-threads-xform"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d10f9246c4daa911283a7096fc3be9f1fab9e3e36400478a4ab8d7056701420"
|
||||
checksum = "0aa93941bae037b7b4fac4ecfc132294b828036c5990a806d0e6fd9284297d94"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"walrus",
|
||||
@@ -2817,9 +2818,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-wasm-conventions"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4a5ab217f12f73b7c3ff23cbbbb5d36f7ee97dd65bb0be44beebda887df9002"
|
||||
checksum = "d8f5de325048d945c90600fdf66b13521f3340d85971287775c36aa99c04466b"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"walrus",
|
||||
@@ -2827,9 +2828,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-wasm-interpreter"
|
||||
version = "0.2.83"
|
||||
version = "0.2.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fbb6c773b486889b7c1211d27a7a08eebaf54ec4269380266cadf69e269cd91"
|
||||
checksum = "f695df44962e3a107436282232a2daa185b8453c16be8ddfb637cd2601f31128"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"log",
|
||||
@@ -2943,9 +2944,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.60"
|
||||
version = "0.3.61"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
|
||||
checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
@@ -2973,7 +2974,7 @@ dependencies = [
|
||||
"nanorand",
|
||||
"noise",
|
||||
"obj",
|
||||
"parking_lot 0.11.2",
|
||||
"parking_lot 0.12.1",
|
||||
"png",
|
||||
"pollster",
|
||||
"profiling",
|
||||
@@ -3002,7 +3003,7 @@ dependencies = [
|
||||
"fxhash",
|
||||
"log",
|
||||
"naga",
|
||||
"parking_lot 0.11.2",
|
||||
"parking_lot 0.12.1",
|
||||
"profiling",
|
||||
"raw-window-handle 0.5.0",
|
||||
"ron",
|
||||
@@ -3043,7 +3044,7 @@ dependencies = [
|
||||
"metal",
|
||||
"naga",
|
||||
"objc",
|
||||
"parking_lot 0.11.2",
|
||||
"parking_lot 0.12.1",
|
||||
"profiling",
|
||||
"range-alloc",
|
||||
"raw-window-handle 0.5.0",
|
||||
|
||||
10
Cargo.toml
10
Cargo.toml
@@ -51,7 +51,7 @@ async-executor = "1.0"
|
||||
bitflags = "1"
|
||||
bit-vec = "0.6"
|
||||
bytemuck = "1.4"
|
||||
cargo-run-wasm = "0.2.0"
|
||||
cargo-run-wasm = "0.3.0"
|
||||
cfg_aliases = "0.1"
|
||||
cfg-if = "1"
|
||||
codespan-reporting = "0.11"
|
||||
@@ -114,11 +114,11 @@ glutin = "0.29.1"
|
||||
# wasm32 dependencies
|
||||
console_error_panic_hook = "0.1.7"
|
||||
console_log = "0.2"
|
||||
js-sys = "0.3.60"
|
||||
wasm-bindgen = "0.2.83"
|
||||
wasm-bindgen-futures = "0.4.33"
|
||||
js-sys = "0.3.61"
|
||||
wasm-bindgen = "0.2.84"
|
||||
wasm-bindgen-futures = "0.4.34"
|
||||
wasm-bindgen-test = "0.3"
|
||||
web-sys = "0.3.60"
|
||||
web-sys = "0.3.61"
|
||||
|
||||
# deno dependencies
|
||||
deno_console = "0.84.0"
|
||||
|
||||
@@ -102,9 +102,9 @@ objc = "0.2.5"
|
||||
core-graphics-types = "0.1"
|
||||
|
||||
[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies]
|
||||
wasm-bindgen = "0.2.83"
|
||||
web-sys = { version = "0.3.60", features = ["Window", "HtmlCanvasElement", "WebGl2RenderingContext", "OffscreenCanvas"] }
|
||||
js-sys = "0.3.60"
|
||||
wasm-bindgen = "0.2.84"
|
||||
web-sys = { version = "0.3.61", features = ["Window", "HtmlCanvasElement", "WebGl2RenderingContext", "OffscreenCanvas"] }
|
||||
js-sys = "0.3.61"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
libc = "0.2"
|
||||
@@ -127,7 +127,7 @@ features = ["wgsl-in"]
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.9"
|
||||
winit = "0.27.1" # for "halmark" example
|
||||
winit = "0.27.1" # for "halmark" example
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
||||
glutin = "0.29.1" # for "gles" example
|
||||
|
||||
@@ -585,6 +585,17 @@ const FEATURES_MAPPING: [(wgt::Features, web_sys::GpuFeatureName); 8] = [
|
||||
),
|
||||
];
|
||||
|
||||
fn map_wgt_features(supported_features: web_sys::GpuSupportedFeatures) -> wgt::Features {
|
||||
let mut features = wgt::Features::empty();
|
||||
for (wgpu_feat, web_feat) in FEATURES_MAPPING {
|
||||
match wasm_bindgen::JsValue::from(web_feat).as_string() {
|
||||
Some(value) if supported_features.has(&value) => features |= wgpu_feat,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
features
|
||||
}
|
||||
|
||||
type JsFutureResult = Result<wasm_bindgen::JsValue, wasm_bindgen::JsValue>;
|
||||
|
||||
fn future_request_adapter(result: JsFutureResult) -> Option<(Identified<web_sys::GpuAdapter>, ())> {
|
||||
@@ -931,23 +942,7 @@ impl crate::context::Context for Context {
|
||||
adapter: &Self::AdapterId,
|
||||
_adapter_data: &Self::AdapterData,
|
||||
) -> wgt::Features {
|
||||
let features = adapter.0.features();
|
||||
|
||||
let features_set: js_sys::Set = features
|
||||
.dyn_into()
|
||||
.expect("adapter.features() is not setlike");
|
||||
|
||||
let mut features = wgt::Features::empty();
|
||||
|
||||
for (wgpu_feat, web_feat) in FEATURES_MAPPING {
|
||||
let value = wasm_bindgen::JsValue::from(web_feat);
|
||||
|
||||
if features_set.has(&value) {
|
||||
features |= wgpu_feat;
|
||||
}
|
||||
}
|
||||
|
||||
features
|
||||
map_wgt_features(adapter.0.features())
|
||||
}
|
||||
|
||||
fn adapter_limits(
|
||||
@@ -1112,23 +1107,7 @@ impl crate::context::Context for Context {
|
||||
device: &Self::DeviceId,
|
||||
_device_data: &Self::DeviceData,
|
||||
) -> wgt::Features {
|
||||
let features = device.0.features();
|
||||
|
||||
let features_set: js_sys::Set = features
|
||||
.dyn_into()
|
||||
.expect("device.features() is not setlike");
|
||||
|
||||
let mut features = wgt::Features::empty();
|
||||
|
||||
for (wgpu_feat, web_feat) in FEATURES_MAPPING {
|
||||
let value = wasm_bindgen::JsValue::from(web_feat);
|
||||
|
||||
if features_set.has(&value) {
|
||||
features |= wgpu_feat;
|
||||
}
|
||||
}
|
||||
|
||||
features
|
||||
map_wgt_features(device.0.features())
|
||||
}
|
||||
|
||||
fn device_limits(
|
||||
|
||||
Reference in New Issue
Block a user