diff --git a/Cargo.toml b/Cargo.toml index 5588ac7f7..9a3950d25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,12 +73,18 @@ test = true #gfx-descriptor = { version = "0.1.0", path = "../gfx-extras/gfx-descriptor" } #gfx-memory = { version = "0.1.0", path = "../gfx-extras/gfx-memory" } +[patch.crates-io] +wasm-bindgen = { path = "../wasm-bindgen" } +wasm-bindgen-futures = { path = "../wasm-bindgen/crates/futures" } +web-sys = { path = "../wasm-bindgen/crates/web-sys" } +js-sys = { path = "../wasm-bindgen/crates/js-sys" } + [target.'cfg(not(target_arch = "wasm32"))'.dependencies] env_logger = "0.7" [target.'cfg(target_arch = "wasm32")'.dependencies] -wasm-bindgen = "0.2.59" -web-sys = { version = "0.3.36", features = [ +wasm-bindgen = "0.2.60" +web-sys = { version = "0.3.37", features = [ "Document", "Navigator", "Node", @@ -87,10 +93,10 @@ web-sys = { version = "0.3.36", features = [ "GpuAdapter", "GpuAddressMode", "GpuBindGroup", - "GpuBindGroupBinding", + "GpuBindGroupEntry", "GpuBindGroupDescriptor", "GpuBindGroupLayout", - "GpuBindGroupLayoutBinding", + "GpuBindGroupLayoutEntry", "GpuBindGroupLayoutDescriptor", "GpuBlendDescriptor", "GpuBlendFactor", @@ -164,8 +170,8 @@ web-sys = { version = "0.3.36", features = [ "HtmlCanvasElement", "Window", ]} -js-sys = "0.3.36" -wasm-bindgen-futures = "0.4.9" +js-sys = "0.3.37" +wasm-bindgen-futures = "0.4.10" [target.'cfg(target_arch = "wasm32")'.dev-dependencies] console_error_panic_hook = "0.1.6" diff --git a/src/backend/web.rs b/src/backend/web.rs index 520193f82..35cbcf33b 100644 --- a/src/backend/web.rs +++ b/src/backend/web.rs @@ -114,14 +114,14 @@ pub(crate) fn create_bind_group_layout(device: &DeviceId, desc: &BindGroupLayout _ => web_sys::GpuTextureViewDimension::N2d, }; - let mut mapped_binding = web_sys::GpuBindGroupLayoutBinding::new(bind.binding, mapped_type, bind.visibility.bits()); - mapped_binding.has_dynamic_offset(mapped_dynamic); - mapped_binding.multisampled(mapped_multisampled); - mapped_binding.texture_dimension(mapped_view_dimension); + let mut mapped_entry = web_sys::GpuBindGroupLayoutEntry::new(bind.binding, mapped_type, bind.visibility.bits()); + mapped_entry.has_dynamic_offset(mapped_dynamic); + mapped_entry.multisampled(mapped_multisampled); + mapped_entry.view_dimension(mapped_view_dimension); // TODO: Texture component type, storage texture format - mapped_binding + mapped_entry }) .collect::(); @@ -130,7 +130,7 @@ pub(crate) fn create_bind_group_layout(device: &DeviceId, desc: &BindGroupLayout } pub(crate) fn create_bind_group(device: &DeviceId, desc: &BindGroupDescriptor) -> BindGroupId { - let mapped_bindings = desc + let mapped_entries = desc .bindings .iter() .map(|binding| { @@ -148,11 +148,11 @@ pub(crate) fn create_bind_group(device: &DeviceId, desc: &BindGroupDescriptor) - BindingResource::TextureView(ref texture_view) => JsValue::from(texture_view.id.clone()), }; - web_sys::GpuBindGroupBinding::new(binding.binding, &mapped_resource) + web_sys::GpuBindGroupEntry::new(binding.binding, &mapped_resource) }) .collect::(); - let mapped_desc = web_sys::GpuBindGroupDescriptor::new(&mapped_bindings, &desc.layout.id); + let mapped_desc = web_sys::GpuBindGroupDescriptor::new(&mapped_entries, &desc.layout.id); device.create_bind_group(&mapped_desc) } @@ -454,7 +454,8 @@ fn map_texture_view_dimension(texture_view_dimension: wgt::TextureViewDimension) } fn map_buffer_copy_view(view: crate::BufferCopyView<'_>) -> web_sys::GpuBufferCopyView { - let mut mapped = web_sys::GpuBufferCopyView::new(&view.buffer.id, view.rows_per_image, view.bytes_per_row); + let mut mapped = web_sys::GpuBufferCopyView::new(&view.buffer.id, view.bytes_per_row); + mapped.rows_per_image(view.rows_per_image); mapped.offset(view.offset as f64); mapped } @@ -621,13 +622,13 @@ pub(crate) fn device_create_buffer(device: &DeviceId, desc: &BufferDescriptor) - } pub(crate) fn device_create_texture(device: &DeviceId, desc: &TextureDescriptor) -> TextureId { - let extent = map_extent_3d(desc.size); + let mut extent = map_extent_3d(desc.size); + // TODO: Remove `array_layer_count` for existing descriptors + extent.depth(desc.size.depth * desc.array_layer_count); let mut mapped_desc = web_sys::GpuTextureDescriptor::new(map_texture_format(desc.format), &extent, desc.usage.bits()); - mapped_desc.array_layer_count(desc.array_layer_count); mapped_desc.dimension(map_texture_dimension(desc.dimension)); mapped_desc.mip_level_count(desc.mip_level_count); mapped_desc.sample_count(desc.sample_count); - mapped_desc.array_layer_count(desc.array_layer_count); device.create_texture(&mapped_desc) } @@ -929,7 +930,7 @@ pub(crate) fn render_pass_draw( vertices: Range, instances: Range, ) { - render_pass.draw( + render_pass.draw_with_instance_count_and_first_vertex_and_first_instance( vertices.end - vertices.start, instances.end - instances.start, vertices.start, @@ -943,7 +944,7 @@ pub(crate) fn render_pass_draw_indexed( base_vertex: i32, instances: Range, ) { - render_pass.draw_indexed( + render_pass.draw_indexed_with_instance_count_and_first_index_and_base_vertex_and_first_instance( indices.end - indices.start, instances.end - instances.start, indices.start, diff --git a/src/lib.rs b/src/lib.rs index a7abe3cad..695cf0abe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1251,7 +1251,8 @@ impl SwapChain { match backend::swap_chain_get_next_texture(&self.id) { Some(id) => Ok(SwapChainOutput { view: TextureView { id, owned: false }, - swap_chain_id: self.id, + // TODO: Remove from web backend + swap_chain_id: self.id.clone(), }), None => Err(TimeOut), }