web: march web-sys 0.3.58, sparse attachments support (#2813)

This commit is contained in:
Jinlei Li 2022-06-29 02:15:57 +08:00 committed by GitHub
parent b0c798639a
commit 0eb6845b6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 123 additions and 114 deletions

56
Cargo.lock generated
View File

@ -888,9 +888,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]]
name = "js-sys"
version = "0.3.57"
version = "0.3.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397"
checksum = "c3fac17f7123a73ca62df411b1bf727ccc805daa070338fda671c86dac1bdc27"
dependencies = [
"wasm-bindgen",
]
@ -1796,9 +1796,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.80"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad"
checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994"
dependencies = [
"cfg-if 1.0.0",
"wasm-bindgen-macro",
@ -1806,9 +1806,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.80"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4"
checksum = "5491a68ab4500fa6b4d726bd67408630c3dbe9c4fe7bda16d5c82a1fd8c7340a"
dependencies = [
"bumpalo",
"lazy_static",
@ -1821,9 +1821,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-cli-support"
version = "0.2.80"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab11a7bfc3e3d5c075ee93626160b720a1cd9c320a9b932be4fc243dea9ed507"
checksum = "4016fbd42224de21aab2f009aeaec61067d278a298ba7f8f7f8d40fbffea0822"
dependencies = [
"anyhow",
"base64 0.9.3",
@ -1845,9 +1845,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-externref-xform"
version = "0.2.80"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83f23b0f14e12b08bcf95b75d1896771afbdd0a4167c889d202b81ed7858e3d5"
checksum = "f33c8e2d3f3b6f6647f982911eb4cb44998c8cca97a4fe7afc99f616ebb33a73"
dependencies = [
"anyhow",
"walrus",
@ -1855,9 +1855,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.30"
version = "0.4.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2"
checksum = "de9a9cec1733468a8c657e57fa2413d2ae2c0129b95e87c5b72b8ace4d13f31f"
dependencies = [
"cfg-if 1.0.0",
"js-sys",
@ -1867,9 +1867,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.80"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5"
checksum = "c441e177922bc58f1e12c022624b6216378e5febc2f0533e41ba443d505b80aa"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@ -1877,9 +1877,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.80"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b"
checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048"
dependencies = [
"proc-macro2",
"quote",
@ -1890,9 +1890,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-multi-value-xform"
version = "0.2.80"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eae02fd62b4954e74bd808ff160b58932b9a208e03a69e5776460655df11ed5"
checksum = "7015b54357604811162710d5cf274ab85d974fe1e324222dd5b2133afdefe9b9"
dependencies = [
"anyhow",
"walrus",
@ -1900,15 +1900,15 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.80"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744"
checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be"
[[package]]
name = "wasm-bindgen-threads-xform"
version = "0.2.80"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d5d14d234eb095de93a856f4740f0f46e57e58f7cb5c303b35ff3e9db189e90"
checksum = "6961b838d9a9c121ba4a1eea1628014cc759469e3defb42bbac9c5ed0f65be14"
dependencies = [
"anyhow",
"walrus",
@ -1917,9 +1917,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-wasm-conventions"
version = "0.2.80"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0febe9c6944f60dd5d38359ef5ab3eab82e8ac7a6e9b3961e4357d89192db686"
checksum = "c0a0eca38fe89471f57d6903f3e17e732d2d6f995a7af5b23f27df7fee0f0d18"
dependencies = [
"anyhow",
"walrus",
@ -1927,9 +1927,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-wasm-interpreter"
version = "0.2.80"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03e3e00a34cb517890ac55321277286ac5e072f7076ab62eb85d58a781449d24"
checksum = "0b1c9fb7f71137840932bbb853ef1f83d68c88584b716c9bbae38675c9fb8b86"
dependencies = [
"anyhow",
"log",
@ -2043,9 +2043,9 @@ dependencies = [
[[package]]
name = "web-sys"
version = "0.3.57"
version = "0.3.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283"
checksum = "2fed94beee57daf8dd7d51f2b15dc2bcde92d7a72304cdf662a4371008b71b90"
dependencies = [
"js-sys",
"wasm-bindgen",

View File

@ -158,8 +158,7 @@ rev = "27d38aae"
features = ["wgsl-out"]
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2.80"
web-sys = { version = "0.3.57", features = [
web-sys = { version = "0.3.58", features = [
"Document",
"Navigator",
"Node",
@ -167,6 +166,7 @@ web-sys = { version = "0.3.57", features = [
"Gpu",
"GpuAdapter",
"GpuAddressMode",
"GpuAutoLayoutMode",
"GpuBindGroup",
"GpuBindGroupDescriptor",
"GpuBindGroupEntry",
@ -182,12 +182,10 @@ web-sys = { version = "0.3.57", features = [
"GpuBufferBindingLayout",
"GpuBufferBindingType",
"GpuBufferDescriptor",
"GpuBufferUsage",
"GpuCanvasContext",
"GpuCanvasConfiguration",
"GpuColorDict",
"GpuColorTargetState",
"GpuColorWrite",
"GpuCommandBuffer",
"GpuCommandBufferDescriptor",
"GpuCommandEncoder",
@ -206,6 +204,7 @@ web-sys = { version = "0.3.57", features = [
"GpuDeviceDescriptor",
"GpuDeviceLostInfo",
"GpuDeviceLostReason",
"GpuError",
"GpuErrorFilter",
"GpuExtent3dDict",
"GpuFeatureName",
@ -217,7 +216,8 @@ web-sys = { version = "0.3.57", features = [
"GpuImageDataLayout",
"GpuIndexFormat",
"GpuLoadOp",
"GpuMapMode",
"gpu_map_mode",
"GpuMipmapFilterMode",
"GpuMultisampleState",
"GpuObjectDescriptorBase",
"GpuOrigin2dDict",
@ -226,7 +226,6 @@ web-sys = { version = "0.3.57", features = [
"GpuPipelineDescriptorBase",
"GpuPipelineLayout",
"GpuPipelineLayoutDescriptor",
"GpuPipelineStatisticName",
"GpuPowerPreference",
"GpuPrimitiveState",
"GpuPrimitiveTopology",
@ -252,7 +251,6 @@ web-sys = { version = "0.3.57", features = [
"GpuSamplerDescriptor",
"GpuShaderModule",
"GpuShaderModuleDescriptor",
"GpuShaderStage",
"GpuStencilFaceState",
"GpuStencilOperation",
"GpuStorageTextureAccess",
@ -267,7 +265,6 @@ web-sys = { version = "0.3.57", features = [
"GpuTextureDimension",
"GpuTextureFormat",
"GpuTextureSampleType",
"GpuTextureUsage",
"GpuTextureView",
"GpuTextureViewDescriptor",
"GpuTextureViewDimension",
@ -285,8 +282,9 @@ web-sys = { version = "0.3.57", features = [
"ImageBitmapRenderingContext",
"Window"
] }
js-sys = "0.3.57"
wasm-bindgen-futures = "0.4.30"
wasm-bindgen = "0.2.81"
js-sys = "0.3.58"
wasm-bindgen-futures = "0.4.31"
# parking_lot 0.12 switches from `winapi` to `windows`; permit either
parking_lot = ">=0.11,<0.13"
@ -294,4 +292,4 @@ parking_lot = ">=0.11,<0.13"
console_error_panic_hook = "0.1.6"
console_log = "0.1.2"
# We need the Location feature in the framework examples
web-sys = { version = "0.3.53", features = ["Location"] }
web-sys = { version = "0.3.58", features = ["Location"] }

View File

@ -132,7 +132,8 @@ impl crate::ComputePassInner<Context> for ComputePass {
}
fn dispatch_workgroups(&mut self, x: u32, y: u32, z: u32) {
self.0.dispatch_with_y_and_z(x, y, z);
self.0
.dispatch_workgroups_with_workgroup_count_y_and_workgroup_count_z(x, y, z);
}
fn dispatch_workgroups_indirect(
&mut self,
@ -140,7 +141,7 @@ impl crate::ComputePassInner<Context> for ComputePass {
indirect_offset: wgt::BufferAddress,
) {
self.0
.dispatch_indirect_with_f64(&indirect_buffer.0, indirect_offset as f64);
.dispatch_workgroups_indirect_with_f64(&indirect_buffer.0, indirect_offset as f64);
}
fn write_timestamp(&mut self, _query_set: &(), _query_index: u32) {
@ -838,6 +839,13 @@ fn map_filter_mode(mode: wgt::FilterMode) -> web_sys::GpuFilterMode {
}
}
fn map_mipmap_filter_mode(mode: wgt::FilterMode) -> web_sys::GpuMipmapFilterMode {
match mode {
wgt::FilterMode::Nearest => web_sys::GpuMipmapFilterMode::Nearest,
wgt::FilterMode::Linear => web_sys::GpuMipmapFilterMode::Linear,
}
}
fn map_address_mode(mode: wgt::AddressMode) -> web_sys::GpuAddressMode {
match mode {
wgt::AddressMode::ClampToEdge => web_sys::GpuAddressMode::ClampToEdge,
@ -861,8 +869,8 @@ fn map_store_op(store: bool) -> web_sys::GpuStoreOp {
fn map_map_mode(mode: crate::MapMode) -> u32 {
match mode {
crate::MapMode::Read => web_sys::GpuMapMode::READ,
crate::MapMode::Write => web_sys::GpuMapMode::WRITE,
crate::MapMode::Read => web_sys::gpu_map_mode::READ,
crate::MapMode::Write => web_sys::gpu_map_mode::WRITE,
}
}
@ -1078,24 +1086,29 @@ impl crate::Context for Context {
let possible_features = [
//TODO: update the name
(wgt::Features::DEPTH_CLIP_CONTROL, Gfn::DepthClamping),
(
wgt::Features::DEPTH24UNORM_STENCIL8,
Gfn::Depth24unormStencil8,
),
(wgt::Features::DEPTH_CLIP_CONTROL, Gfn::DepthClipControl),
(
wgt::Features::DEPTH32FLOAT_STENCIL8,
Gfn::Depth32floatStencil8,
),
(
wgt::Features::PIPELINE_STATISTICS_QUERY,
Gfn::PipelineStatisticsQuery,
),
(
wgt::Features::TEXTURE_COMPRESSION_BC,
Gfn::TextureCompressionBc,
),
(
wgt::Features::TEXTURE_COMPRESSION_ETC2,
Gfn::TextureCompressionEtc2,
),
(
wgt::Features::TEXTURE_COMPRESSION_ASTC_LDR,
Gfn::TextureCompressionAstc,
),
(wgt::Features::TIMESTAMP_QUERY, Gfn::TimestampQuery),
(
wgt::Features::INDIRECT_FIRST_INSTANCE,
Gfn::IndirectFirstInstance,
),
(wgt::Features::SHADER_FLOAT16, Gfn::ShaderF16),
];
let required_features = possible_features
.iter()
@ -1538,16 +1551,19 @@ impl crate::Context for Context {
mapped_vertex_state.buffers(&buffers);
let mut mapped_desc = web_sys::GpuRenderPipelineDescriptor::new(&mapped_vertex_state);
let auto_layout = wasm_bindgen::JsValue::from(web_sys::GpuAutoLayoutMode::Auto);
let mut mapped_desc = web_sys::GpuRenderPipelineDescriptor::new(
match desc.layout {
Some(layout) => &layout.id.0,
None => &auto_layout,
},
&mapped_vertex_state,
);
if let Some(label) = desc.label {
mapped_desc.label(label);
}
if let Some(layout) = desc.layout {
mapped_desc.layout(&layout.id.0);
}
if let Some(ref depth_stencil) = desc.depth_stencil {
mapped_desc.depth_stencil(&map_depth_stencil_state(depth_stencil));
}
@ -1556,8 +1572,8 @@ impl crate::Context for Context {
let targets = frag
.targets
.iter()
.filter_map(|t| {
t.as_ref().map(|target| {
.map(|target| match target {
Some(target) => {
let mapped_format = map_texture_format(target.format);
let mut mapped_color_state =
web_sys::GpuColorTargetState::new(mapped_format);
@ -1568,8 +1584,9 @@ impl crate::Context for Context {
mapped_color_state.blend(&mapped_blend_state);
}
mapped_color_state.write_mask(target.write_mask.bits());
mapped_color_state
})
wasm_bindgen::JsValue::from(mapped_color_state)
}
None => wasm_bindgen::JsValue::null(),
})
.collect::<js_sys::Array>();
let mapped_fragment_desc =
@ -1596,10 +1613,14 @@ impl crate::Context for Context {
) -> Self::ComputePipelineId {
let mapped_compute_stage =
web_sys::GpuProgrammableStage::new(desc.entry_point, &desc.module.id.0);
let mut mapped_desc = web_sys::GpuComputePipelineDescriptor::new(&mapped_compute_stage);
if let Some(layout) = desc.layout {
mapped_desc.layout(&layout.id.0);
}
let auto_layout = wasm_bindgen::JsValue::from(web_sys::GpuAutoLayoutMode::Auto);
let mut mapped_desc = web_sys::GpuComputePipelineDescriptor::new(
match desc.layout {
Some(layout) => &layout.id.0,
None => &auto_layout,
},
&mapped_compute_stage,
);
if let Some(label) = desc.label {
mapped_desc.label(label);
}
@ -1655,7 +1676,7 @@ impl crate::Context for Context {
mapped_desc.lod_min_clamp(desc.lod_min_clamp);
mapped_desc.mag_filter(map_filter_mode(desc.mag_filter));
mapped_desc.min_filter(map_filter_mode(desc.min_filter));
mapped_desc.mipmap_filter(map_filter_mode(desc.mipmap_filter));
mapped_desc.mipmap_filter(map_mipmap_filter_mode(desc.mipmap_filter));
// TODO: `max_anisotropy` is not available on `desc` yet
// mapped_desc.max_anisotropy(desc.max_anisotropy);
if let Some(label) = desc.label {
@ -1693,9 +1714,9 @@ impl crate::Context for Context {
let mapped_color_formats = desc
.color_formats
.iter()
.filter_map(|cf| {
cf.as_ref()
.map(|format| wasm_bindgen::JsValue::from(map_texture_format(*format)))
.map(|cf| match cf {
Some(cf) => wasm_bindgen::JsValue::from(map_texture_format(*cf)),
None => wasm_bindgen::JsValue::null(),
})
.collect::<js_sys::Array>();
let mut mapped_desc = web_sys::GpuRenderBundleEncoderDescriptor::new(&mapped_color_formats);
@ -1724,7 +1745,7 @@ impl crate::Context for Context {
handler: impl crate::UncapturedErrorHandler,
) {
let f = Closure::wrap(Box::new(move |event: web_sys::GpuUncapturedErrorEvent| {
let error = crate::Error::from_js(event.error());
let error = crate::Error::from_js(event.error().value_of());
handler(error);
}) as Box<dyn FnMut(_)>);
device
@ -1980,7 +2001,7 @@ impl crate::Context for Context {
_encoder: &Self::CommandEncoderId,
pass: &mut Self::ComputePassId,
) {
pass.0.end_pass();
pass.0.end();
}
fn command_encoder_begin_render_pass<'a>(
@ -1991,31 +2012,33 @@ impl crate::Context for Context {
let mapped_color_attachments = desc
.color_attachments
.iter()
.filter_map(|attachment| {
attachment.as_ref().map(|ca| {
.map(|attachment| match attachment {
Some(ca) => {
let mut clear_value: Option<wasm_bindgen::JsValue> = None;
let load_value = match ca.ops.load {
crate::LoadOp::Clear(color) => {
wasm_bindgen::JsValue::from(map_color(color))
}
crate::LoadOp::Load => {
wasm_bindgen::JsValue::from(web_sys::GpuLoadOp::Load)
clear_value = Some(wasm_bindgen::JsValue::from(map_color(color)));
web_sys::GpuLoadOp::Clear
}
crate::LoadOp::Load => web_sys::GpuLoadOp::Load,
};
let mut mapped_color_attachment = web_sys::GpuRenderPassColorAttachment::new(
&load_value,
load_value,
map_store_op(ca.ops.store),
&ca.view.id.0,
);
if let Some(cv) = clear_value {
mapped_color_attachment.clear_value(&cv);
}
if let Some(rt) = ca.resolve_target {
mapped_color_attachment.resolve_target(&rt.id.0);
}
mapped_color_attachment.store_op(map_store_op(ca.ops.store));
mapped_color_attachment
})
wasm_bindgen::JsValue::from(mapped_color_attachment)
}
None => wasm_bindgen::JsValue::null(),
})
.collect::<js_sys::Array>();
@ -2029,41 +2052,29 @@ impl crate::Context for Context {
let (depth_load_op, depth_store_op) = match dsa.depth_ops {
Some(ref ops) => {
let load_op = match ops.load {
crate::LoadOp::Clear(value) => wasm_bindgen::JsValue::from(value),
crate::LoadOp::Load => {
wasm_bindgen::JsValue::from(web_sys::GpuLoadOp::Load)
}
crate::LoadOp::Clear(_) => web_sys::GpuLoadOp::Clear,
crate::LoadOp::Load => web_sys::GpuLoadOp::Load,
};
(load_op, map_store_op(ops.store))
}
None => (
wasm_bindgen::JsValue::from(web_sys::GpuLoadOp::Load),
web_sys::GpuStoreOp::Store,
),
None => (web_sys::GpuLoadOp::Load, web_sys::GpuStoreOp::Store),
};
let (stencil_load_op, stencil_store_op) = match dsa.stencil_ops {
Some(ref ops) => {
let load_op = match ops.load {
crate::LoadOp::Clear(value) => wasm_bindgen::JsValue::from(value),
crate::LoadOp::Load => {
wasm_bindgen::JsValue::from(web_sys::GpuLoadOp::Load)
}
crate::LoadOp::Clear(_) => web_sys::GpuLoadOp::Clear,
crate::LoadOp::Load => web_sys::GpuLoadOp::Load,
};
(load_op, map_store_op(ops.store))
}
None => (
wasm_bindgen::JsValue::from(web_sys::GpuLoadOp::Load),
web_sys::GpuStoreOp::Store,
),
None => (web_sys::GpuLoadOp::Load, web_sys::GpuStoreOp::Store),
};
let mapped_depth_stencil_attachment = web_sys::GpuRenderPassDepthStencilAttachment::new(
&depth_load_op,
depth_store_op,
&stencil_load_op,
stencil_store_op,
&dsa.view.id.0,
);
let mut mapped_depth_stencil_attachment =
web_sys::GpuRenderPassDepthStencilAttachment::new(&dsa.view.id.0);
mapped_depth_stencil_attachment.depth_load_op(depth_load_op);
mapped_depth_stencil_attachment.depth_store_op(depth_store_op);
mapped_depth_stencil_attachment.stencil_load_op(stencil_load_op);
mapped_depth_stencil_attachment.stencil_store_op(stencil_store_op);
mapped_desc.depth_stencil_attachment(&mapped_depth_stencil_attachment);
}
@ -2075,17 +2086,17 @@ impl crate::Context for Context {
_encoder: &Self::CommandEncoderId,
pass: &mut Self::RenderPassId,
) {
pass.0.end_pass();
pass.0.end();
}
fn command_encoder_finish(&self, encoder: Self::CommandEncoderId) -> Self::CommandBufferId {
Sendable(match encoder.label() {
Some(ref label) => {
let mut mapped_desc = web_sys::GpuCommandBufferDescriptor::new();
mapped_desc.label(label);
encoder.finish_with_descriptor(&mapped_desc)
}
None => encoder.finish(),
let label = encoder.label();
Sendable(if label.is_empty() {
encoder.finish()
} else {
let mut mapped_desc = web_sys::GpuCommandBufferDescriptor::new();
mapped_desc.label(&label);
encoder.finish_with_descriptor(&mapped_desc)
})
}