From e7ca1716f57c75d9e40c4483aa829a1219a410d9 Mon Sep 17 00:00:00 2001 From: James0124 Date: Tue, 10 Jan 2023 17:26:45 +0900 Subject: [PATCH 01/11] =?UTF-8?q?Fix=20panic=20in=20the=20GLES=20backend?= =?UTF-8?q?=20when=20creating=20a=20pipeline=20with=20opaque=20ty=E2=80=A6?= =?UTF-8?q?=20(#3361)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix panic in the GLES backend when creating a pipeline with opaque types other than samplers. * Add changelog entry for #3361. --- CHANGELOG.md | 1 + wgpu-hal/src/gles/conv.rs | 48 ++++++++++++++++++++++++++++++++++++- wgpu-hal/src/gles/device.rs | 2 +- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d222b4d984..61e9a6c63a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -186,6 +186,7 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non - Fixed WebGL not displaying srgb targets correctly if a non-screen filling viewport was previously set. By @Wumpf in [#3093](https://github.com/gfx-rs/wgpu/pull/3093) - Fix disallowing multisampling for float textures if otherwise supported. By @Wumpf in [#3183](https://github.com/gfx-rs/wgpu/pull/3183) +- Fix a panic when creating a pipeline with opaque types other than samplers (images and atomic counters). By @James2022-rgb in [#3361](https://github.com/gfx-rs/wgpu/pull/3361) #### Vulkan diff --git a/wgpu-hal/src/gles/conv.rs b/wgpu-hal/src/gles/conv.rs index 93f015363f..14d30e9308 100644 --- a/wgpu-hal/src/gles/conv.rs +++ b/wgpu-hal/src/gles/conv.rs @@ -439,6 +439,52 @@ pub(super) fn is_sampler(glsl_uniform_type: u32) -> bool { } } +pub(super) fn is_image(glsl_uniform_type: u32) -> bool { + match glsl_uniform_type { + glow::INT_IMAGE_1D + | glow::INT_IMAGE_1D_ARRAY + | glow::INT_IMAGE_2D + | glow::INT_IMAGE_2D_ARRAY + | glow::INT_IMAGE_2D_MULTISAMPLE + | glow::INT_IMAGE_2D_MULTISAMPLE_ARRAY + | glow::INT_IMAGE_2D_RECT + | glow::INT_IMAGE_3D + | glow::INT_IMAGE_CUBE + | glow::INT_IMAGE_CUBE_MAP_ARRAY + | glow::UNSIGNED_INT_IMAGE_1D + | glow::UNSIGNED_INT_IMAGE_1D_ARRAY + | glow::UNSIGNED_INT_IMAGE_2D + | glow::UNSIGNED_INT_IMAGE_2D_ARRAY + | glow::UNSIGNED_INT_IMAGE_2D_MULTISAMPLE + | glow::UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY + | glow::UNSIGNED_INT_IMAGE_2D_RECT + | glow::UNSIGNED_INT_IMAGE_3D + | glow::UNSIGNED_INT_IMAGE_CUBE + | glow::UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY + | glow::IMAGE_1D + | glow::IMAGE_1D_ARRAY + | glow::IMAGE_2D + | glow::IMAGE_2D_ARRAY + | glow::IMAGE_2D_MULTISAMPLE + | glow::IMAGE_2D_MULTISAMPLE_ARRAY + | glow::IMAGE_2D_RECT + | glow::IMAGE_3D + | glow::IMAGE_CUBE + | glow::IMAGE_CUBE_MAP_ARRAY => true, + _ => false, + } +} + +pub(super) fn is_atomic_counter(glsl_uniform_type: u32) -> bool { + glsl_uniform_type == glow::UNSIGNED_INT_ATOMIC_COUNTER +} + +pub(super) fn is_opaque_type(glsl_uniform_type: u32) -> bool { + is_sampler(glsl_uniform_type) + || is_image(glsl_uniform_type) + || is_atomic_counter(glsl_uniform_type) +} + pub(super) fn uniform_byte_size(glsl_uniform_type: u32) -> u32 { match glsl_uniform_type { glow::FLOAT | glow::INT => 4, @@ -448,6 +494,6 @@ pub(super) fn uniform_byte_size(glsl_uniform_type: u32) -> u32 { glow::FLOAT_MAT2 => 16, glow::FLOAT_MAT3 => 36, glow::FLOAT_MAT4 => 64, - _ => panic!("Unsupported uniform datatype!"), + _ => panic!("Unsupported uniform datatype! {glsl_uniform_type:#X}"), } } diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index fa4802f9d8..f0c630d59f 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -380,7 +380,7 @@ impl super::Device { let glow::ActiveUniform { utype, name, .. } = unsafe { gl.get_active_uniform(program, uniform) }.unwrap(); - if conv::is_sampler(utype) { + if conv::is_opaque_type(utype) { continue; } From 98ddb402eb5b404bd2ddf65e0931e3d61b290f32 Mon Sep 17 00:00:00 2001 From: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Date: Tue, 10 Jan 2023 15:48:16 +0100 Subject: [PATCH 02/11] Set `COPY_SRC`/`COPY_DST` only based on Vulkan's `TRANSFER_SRC`/`TRANSFER_DST` (#3366) * remove `BLIT_SRC`/`BLIT_DST` * add changelog entry --- CHANGELOG.md | 4 ++++ wgpu-hal/src/vulkan/adapter.rs | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61e9a6c63a..14f5a6847f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,6 +134,10 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non - Browsers that support `OVR_multiview2` now report the `MULTIVIEW` feature by @expenses in [#3121](https://github.com/gfx-rs/wgpu/pull/3121). +#### Vulkan + +- Set `COPY_SRC`/`COPY_DST` only based on Vulkan's `TRANSFER_SRC`/`TRANSFER_DST` by @teoxoy in [#3366](https://github.com/gfx-rs/wgpu/pull/3366). + ### Added/New Features #### General diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index a6571e678c..7d862bd95e 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -1476,15 +1476,11 @@ impl crate::Adapter for super::Adapter { ); flags.set( Tfc::COPY_SRC, - features.intersects( - vk::FormatFeatureFlags::TRANSFER_SRC | vk::FormatFeatureFlags::BLIT_SRC, - ), + features.intersects(vk::FormatFeatureFlags::TRANSFER_SRC), ); flags.set( Tfc::COPY_DST, - features.intersects( - vk::FormatFeatureFlags::TRANSFER_DST | vk::FormatFeatureFlags::BLIT_DST, - ), + features.intersects(vk::FormatFeatureFlags::TRANSFER_DST), ); // Vulkan is very permissive about MSAA flags.set(Tfc::MULTISAMPLE_RESOLVE, !format.describe().is_compressed()); From 80d237725e1b2e8d840d16bc442dc5aefc0aca76 Mon Sep 17 00:00:00 2001 From: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Date: Tue, 10 Jan 2023 16:33:33 +0100 Subject: [PATCH 03/11] [vk] Set `WEBGPU_TEXTURE_FORMAT_SUPPORT` downlevel flag depending on the proper format support (#3367) --- CHANGELOG.md | 1 + wgpu-hal/src/vulkan/adapter.rs | 71 +++++++++++++++++++++------------- 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14f5a6847f..0eba5dd776 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -136,6 +136,7 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non #### Vulkan +- Set `WEBGPU_TEXTURE_FORMAT_SUPPORT` downlevel flag depending on the proper format support by @teoxoy in [#3367](https://github.com/gfx-rs/wgpu/pull/3367). - Set `COPY_SRC`/`COPY_DST` only based on Vulkan's `TRANSFER_SRC`/`TRANSFER_DST` by @teoxoy in [#3366](https://github.com/gfx-rs/wgpu/pull/3366). ### Added/New Features diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index 7d862bd95e..827f651c73 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -5,6 +5,10 @@ use parking_lot::Mutex; use std::{collections::BTreeMap, ffi::CStr, sync::Arc}; +fn depth_stencil_required_flags() -> vk::FormatFeatureFlags { + vk::FormatFeatureFlags::SAMPLED_IMAGE | vk::FormatFeatureFlags::DEPTH_STENCIL_ATTACHMENT +} + //TODO: const fn? fn indexing_features() -> wgt::Features { wgt::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING @@ -325,7 +329,6 @@ impl PhysicalDeviceFeatures { | Df::VERTEX_STORAGE | Df::FRAGMENT_STORAGE | Df::DEPTH_TEXTURE_AND_BUFFER_COPIES - | Df::WEBGPU_TEXTURE_FORMAT_SUPPORT | Df::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED | Df::UNRESTRICTED_INDEX_BUFFER | Df::INDIRECT_EXECUTION; @@ -487,17 +490,31 @@ impl PhysicalDeviceFeatures { ); } - features.set( - F::DEPTH32FLOAT_STENCIL8, + let supports_depth_format = |format| { supports_format( instance, phd, - vk::Format::D32_SFLOAT_S8_UINT, + format, vk::ImageTiling::OPTIMAL, - vk::FormatFeatureFlags::DEPTH_STENCIL_ATTACHMENT, - ), + depth_stencil_required_flags(), + ) + }; + + let texture_s8 = supports_depth_format(vk::Format::S8_UINT); + let texture_d32 = supports_depth_format(vk::Format::D32_SFLOAT); + let texture_d24_s8 = supports_depth_format(vk::Format::D24_UNORM_S8_UINT); + let texture_d32_s8 = supports_depth_format(vk::Format::D32_SFLOAT_S8_UINT); + + let stencil8 = texture_s8 || texture_d24_s8; + let depth24_plus_stencil8 = texture_d24_s8 || texture_d32_s8; + + dl_flags.set( + Df::WEBGPU_TEXTURE_FORMAT_SUPPORT, + stencil8 && depth24_plus_stencil8 && texture_d32, ); + features.set(F::DEPTH32FLOAT_STENCIL8, texture_d32_s8); + (features, dl_flags) } @@ -1041,27 +1058,27 @@ impl super::Instance { .timeline_semaphore .map_or(false, |ext| ext.timeline_semaphore != 0), }, - texture_d24: unsafe { - self.shared - .raw - .get_physical_device_format_properties(phd, vk::Format::X8_D24_UNORM_PACK32) - .optimal_tiling_features - .contains(vk::FormatFeatureFlags::DEPTH_STENCIL_ATTACHMENT) - }, - texture_d24_s8: unsafe { - self.shared - .raw - .get_physical_device_format_properties(phd, vk::Format::D24_UNORM_S8_UINT) - .optimal_tiling_features - .contains(vk::FormatFeatureFlags::DEPTH_STENCIL_ATTACHMENT) - }, - texture_s8: unsafe { - self.shared - .raw - .get_physical_device_format_properties(phd, vk::Format::S8_UINT) - .optimal_tiling_features - .contains(vk::FormatFeatureFlags::DEPTH_STENCIL_ATTACHMENT) - }, + texture_d24: supports_format( + &self.shared.raw, + phd, + vk::Format::X8_D24_UNORM_PACK32, + vk::ImageTiling::OPTIMAL, + depth_stencil_required_flags(), + ), + texture_d24_s8: supports_format( + &self.shared.raw, + phd, + vk::Format::D24_UNORM_S8_UINT, + vk::ImageTiling::OPTIMAL, + depth_stencil_required_flags(), + ), + texture_s8: supports_format( + &self.shared.raw, + phd, + vk::Format::S8_UINT, + vk::ImageTiling::OPTIMAL, + depth_stencil_required_flags(), + ), non_coherent_map_mask: phd_capabilities.properties.limits.non_coherent_atom_size - 1, can_present: true, //TODO: make configurable From 5a2e60c50e54330607b6886f9107d9ad699274c0 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Tue, 10 Jan 2023 20:04:18 +0100 Subject: [PATCH 04/11] Update naga to e98bd92 (#3352) --- Cargo.lock | 2 +- Cargo.toml | 2 +- wgpu-core/Cargo.toml | 2 +- wgpu-hal/Cargo.toml | 4 ++-- wgpu/examples/shadow/main.rs | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 981c1ca445..0352f25ab6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1430,7 +1430,7 @@ dependencies = [ [[package]] name = "naga" version = "0.10.0" -source = "git+https://github.com/gfx-rs/naga?rev=e7fc8e6#e7fc8e64f2f23397b149217ecce6e123c5aa5092" +source = "git+https://github.com/gfx-rs/naga?rev=e98bd92#e98bd9264c3a6b04dff15a6b1213c0c80201740a" dependencies = [ "bit-set", "bitflags", diff --git a/Cargo.toml b/Cargo.toml index bf4231ddec..354384087d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ path = "./wgpu-hal" [workspace.dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "e7fc8e6" +rev = "e98bd92" version = "0.10" [workspace.dependencies] diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index a282b4c6cc..9fc224b2a8 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -67,7 +67,7 @@ thiserror = "1" [dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "e7fc8e6" +rev = "e98bd92" version = "0.10" features = ["clone", "span", "validate"] diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index b5d6b6e645..54f17c552e 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -111,14 +111,14 @@ android_system_properties = "0.1.1" [dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "e7fc8e6" +rev = "e98bd92" version = "0.10" features = ["clone"] # DEV dependencies [dev-dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "e7fc8e6" +rev = "e98bd92" version = "0.10" features = ["wgsl-in"] diff --git a/wgpu/examples/shadow/main.rs b/wgpu/examples/shadow/main.rs index dd215dfddb..85cff2af47 100644 --- a/wgpu/examples/shadow/main.rs +++ b/wgpu/examples/shadow/main.rs @@ -853,7 +853,6 @@ fn shadow() { optional_features: wgpu::Features::default(), base_test_parameters: framework::test_common::TestParameters::default() .downlevel_flags(wgpu::DownlevelFlags::COMPARISON_SAMPLERS) - .specific_failure(Some(wgpu::Backends::GL), None, Some("ANGLE"), false) // rpi4 on VK doesn't work: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3916 .specific_failure(Some(wgpu::Backends::VULKAN), None, Some("V3D"), false) // llvmpipe versions in CI are flaky: https://github.com/gfx-rs/wgpu/issues/2594 From 48fbb921ca3eb07076d4dc9fdbe2dd93b130b11d Mon Sep 17 00:00:00 2001 From: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Date: Wed, 11 Jan 2023 16:58:52 +0100 Subject: [PATCH 05/11] update ash (#3370) fixes https://github.com/gfx-rs/wgpu/issues/3079 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- wgpu-hal/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0352f25ab6..55c6f23809 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -75,9 +75,9 @@ dependencies = [ [[package]] name = "ash" -version = "0.37.1+1.3.235" +version = "0.37.2+1.3.238" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "911015c962d56e2e4052f40182ca5462ba60a3d2ff04e827c365a0ab3d65726d" +checksum = "28bf19c1f0a470be5fbf7522a308a05df06610252c5bcf5143e1b23f629a9a03" dependencies = [ "libloading", ] diff --git a/Cargo.toml b/Cargo.toml index 354384087d..c713e7fd4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,7 +89,7 @@ objc = "0.2.5" core-graphics-types = "0.1" # Vulkan dependencies -ash = "0.37.1" +ash = "0.37.2" gpu-alloc = "0.5" gpu-descriptor = "0.2" android_system_properties = "0.1.1" diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 54f17c552e..16389287e6 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -63,7 +63,7 @@ block = { version = "0.1", optional = true } foreign-types = { version = "0.3", optional = true } # backend: Vulkan -ash = { version = "0.37.1", optional = true } +ash = { version = "0.37.2", optional = true } gpu-alloc = { version = "0.5", optional = true } gpu-descriptor = { version = "0.2", optional = true } smallvec = { version = "1", optional = true, features = ["union"] } From f2d2a0c00c0659492fd1484fca138a0753eea575 Mon Sep 17 00:00:00 2001 From: Mica White Date: Thu, 12 Jan 2023 12:57:06 -0500 Subject: [PATCH 06/11] Remove panics in `Deref` impl of `QueueWriteBufferView` and `BufferViewMut` (#3336) --- CHANGELOG.md | 1 + wgpu/src/lib.rs | 63 +++++++++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eba5dd776..fff79879d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,6 +124,7 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non - Add missing `DEPTH_BIAS_CLAMP` and `FULL_DRAW_INDEX_UINT32` downlevel flags. By @teoxoy in [#3316](https://github.com/gfx-rs/wgpu/pull/3316) - Make `ObjectId` structure and invariants idiomatic. By @teoxoy in [#3347](https://github.com/gfx-rs/wgpu/pull/3347) - Add validation in accordance with WebGPU `GPUSamplerDescriptor` valid usage for `lodMinClamp` and `lodMaxClamp`. By @James2022-rgb in [#3353](https://github.com/gfx-rs/wgpu/pull/3353) +- Remove panics in `Deref` implementations for `QueueWriteBufferView` and `BufferViewMut`. Instead, warnings are logged, since reading from these types is not recommended. By @botahamec in [#3336] #### WebGPU diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index e70305e8ca..b5a12cdb71 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -20,7 +20,7 @@ use std::{ future::Future, marker::PhantomData, num::{NonZeroU32, NonZeroU8}, - ops::{Bound, Range, RangeBounds}, + ops::{Bound, Deref, DerefMut, Range, RangeBounds}, sync::Arc, thread, }; @@ -2297,6 +2297,9 @@ pub struct BufferView<'a> { } /// Write only view into mapped buffer. +/// +/// It is possible to read the buffer using this view, but doing so is not +/// recommended, as it is likely to be slow. #[derive(Debug)] pub struct BufferViewMut<'a> { slice: BufferSlice<'a>, @@ -2313,37 +2316,34 @@ impl std::ops::Deref for BufferView<'_> { } } -impl std::ops::Deref for BufferViewMut<'_> { - type Target = [u8]; - +impl AsRef<[u8]> for BufferView<'_> { #[inline] - fn deref(&self) -> &[u8] { - assert!( - self.readable, - "Attempting to read a write-only mapping for buffer {:?}", - self.slice.buffer.id - ); + fn as_ref(&self) -> &[u8] { self.data.slice() } } -impl std::ops::DerefMut for BufferViewMut<'_> { +impl AsMut<[u8]> for BufferViewMut<'_> { #[inline] - fn deref_mut(&mut self) -> &mut Self::Target { + fn as_mut(&mut self) -> &mut [u8] { self.data.slice_mut() } } -impl AsRef<[u8]> for BufferView<'_> { - #[inline] - fn as_ref(&self) -> &[u8] { +impl Deref for BufferViewMut<'_> { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + if !self.readable { + log::warn!("Reading from a BufferViewMut is slow and not recommended."); + } + self.data.slice() } } -impl AsMut<[u8]> for BufferViewMut<'_> { - #[inline] - fn as_mut(&mut self) -> &mut [u8] { +impl DerefMut for BufferViewMut<'_> { + fn deref_mut(&mut self) -> &mut Self::Target { self.data.slice_mut() } } @@ -3768,7 +3768,11 @@ impl<'a> RenderBundleEncoder<'a> { } } -/// A write-only view into a staging buffer +/// A read-only view into a staging buffer. +/// +/// Reading into this buffer won't yield the contents of the buffer from the +/// GPU and is likely to be slow. Because of this, although [`AsMut`] is +/// implemented for this type, [`AsRef`] is not. pub struct QueueWriteBufferView<'a> { queue: &'a Queue, buffer: &'a Buffer, @@ -3777,21 +3781,27 @@ pub struct QueueWriteBufferView<'a> { } static_assertions::assert_impl_all!(QueueWriteBufferView: Send, Sync); -impl<'a> std::ops::Deref for QueueWriteBufferView<'a> { +impl Deref for QueueWriteBufferView<'_> { type Target = [u8]; fn deref(&self) -> &Self::Target { - panic!("QueueWriteBufferView is write-only!"); + log::warn!("Reading from a QueueWriteBufferView won't yield the contents of the buffer and may be slow."); + self.inner.slice() } } -impl<'a> std::ops::DerefMut for QueueWriteBufferView<'a> { - #[inline] +impl DerefMut for QueueWriteBufferView<'_> { fn deref_mut(&mut self) -> &mut Self::Target { self.inner.slice_mut() } } +impl<'a> AsMut<[u8]> for QueueWriteBufferView<'a> { + fn as_mut(&mut self) -> &mut [u8] { + self.inner.slice_mut() + } +} + impl<'a> Drop for QueueWriteBufferView<'a> { fn drop(&mut self) { DynContext::queue_write_staging_buffer( @@ -3827,12 +3837,9 @@ impl Queue { } /// Schedule a data write into `buffer` starting at `offset` via the returned - /// [QueueWriteBufferView]. + /// [`QueueWriteBufferView`]. /// - /// The returned value can be dereferenced to a `&mut [u8]`; dereferencing it to a - /// `&[u8]` panics! - /// (It is not unsound to read through the `&mut [u8]` anyway, but doing so will not - /// yield the existing contents of `buffer` from the GPU, and it is likely to be slow.) + /// Reading from this buffer is slow and will not yield the actual contents of the buffer. /// /// This method is intended to have low performance costs. /// As such, the write is not immediately submitted, and instead enqueued From 4400ff82891e493547e09a86c0dc72d8a031ff2b Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Fri, 13 Jan 2023 01:18:54 +0100 Subject: [PATCH 07/11] Increase GL MAX_PUSH_CONSTANTS from 16 to 64 (#3374) --- CHANGELOG.md | 1 + wgpu-hal/src/gles/device.rs | 3 ++- wgpu-hal/src/gles/mod.rs | 2 +- wgpu/tests/shader/struct_layout.rs | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fff79879d9..90f7335877 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,6 +134,7 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non #### GLES - Browsers that support `OVR_multiview2` now report the `MULTIVIEW` feature by @expenses in [#3121](https://github.com/gfx-rs/wgpu/pull/3121). +- `Limits::max_push_constant_size` on GLES is now 256 by @Dinnerbone in [#3374](https://github.com/gfx-rs/wgpu/pull/3374). #### Vulkan diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index f0c630d59f..a4eb09a974 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -372,7 +372,8 @@ impl super::Device { } } - let mut uniforms: [super::UniformDesc; super::MAX_PUSH_CONSTANTS] = Default::default(); + let mut uniforms: [super::UniformDesc; super::MAX_PUSH_CONSTANTS] = + [None; super::MAX_PUSH_CONSTANTS].map(|_: Option<()>| Default::default()); let count = unsafe { gl.get_active_uniforms(program) }; let mut offset = 0; diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index e57b05a979..6ba7f89e12 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -95,7 +95,7 @@ const MAX_TEXTURE_SLOTS: usize = 16; const MAX_SAMPLERS: usize = 16; const MAX_VERTEX_ATTRIBUTES: usize = 16; const ZERO_BUFFER_SIZE: usize = 256 << 10; -const MAX_PUSH_CONSTANTS: usize = 16; +const MAX_PUSH_CONSTANTS: usize = 64; impl crate::Api for Api { type Instance = Instance; diff --git a/wgpu/tests/shader/struct_layout.rs b/wgpu/tests/shader/struct_layout.rs index c0bba4d1ed..a2f1f8a1ed 100644 --- a/wgpu/tests/shader/struct_layout.rs +++ b/wgpu/tests/shader/struct_layout.rs @@ -221,7 +221,8 @@ fn push_constant_input() { .limits(Limits { max_push_constant_size: MAX_BUFFER_SIZE as u32, ..Limits::downlevel_defaults() - }), + }) + .backend_failure(Backends::GL), |ctx| { shader_input_output_test( ctx, From 04da0c3f0bf5eb54203cb9da2a689663c85d6e88 Mon Sep 17 00:00:00 2001 From: Grisha <33952698+GrishaVar@users.noreply.github.com> Date: Sat, 14 Jan 2023 02:28:00 +0100 Subject: [PATCH 08/11] Add missing backtick --- wgpu/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index b5a12cdb71..aff3817c83 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -3316,7 +3316,7 @@ impl<'a> RenderPass<'a> { /// /// - Bytes `4..8` are accessed by both the fragment shader and the vertex shader. /// - /// - Bytes `8..12 are accessed only by the vertex shader. + /// - Bytes `8..12` are accessed only by the vertex shader. /// /// To write all twelve bytes requires three `set_push_constants` calls, one /// for each range, each passing the matching `stages` mask. From 8c9f3f159ba0cc7511f362cf71cb9aadfaa25154 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Sat, 14 Jan 2023 01:35:46 -0800 Subject: [PATCH 09/11] queue_write_texture: Validate the destination texture. (#3378) --- wgpu-core/src/device/queue.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index ba0fb053da..2f4b2bcfb4 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -595,7 +595,9 @@ impl Global { } let (mut texture_guard, _) = hub.textures.write(&mut token); // For clear we need write access to the texture. TODO: Can we acquire write lock later? - let dst = texture_guard.get_mut(destination.texture).unwrap(); + let dst = texture_guard + .get_mut(destination.texture) + .map_err(|_| TransferError::InvalidTexture(destination.texture))?; let (selector, dst_base, texture_format) = extract_texture_selector(destination, size, dst)?; @@ -707,6 +709,10 @@ impl Global { } } + // Re-get `dst` immutably here, so that the mutable borrow of the + // `texture_guard.get_mut` above ends in time for the `clear_texture` + // call above. Since we've held `texture_guard` the whole time, we know + // the texture hasn't gone away in the mean time, so we can unwrap. let dst = texture_guard.get(destination.texture).unwrap(); let transition = trackers .textures From b39c0b9de1438ab15091845ec08e13987fc2341d Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Sat, 14 Jan 2023 17:07:46 +0100 Subject: [PATCH 10/11] update deno (#3379) * update deno * update spec * remove unrelated changes --- Cargo.lock | 53 ++++++++------- Cargo.toml | 10 +-- cts_runner/src/main.rs | 2 +- deno_webgpu/Cargo.toml | 4 +- deno_webgpu/LICENSE.md | 2 +- deno_webgpu/src/01_webgpu.js | 86 +++++++------------------ deno_webgpu/src/02_idl_types.js | 2 +- deno_webgpu/src/03_surface.js | 2 +- deno_webgpu/src/04_surface_idl_types.js | 2 +- deno_webgpu/src/binding.rs | 2 +- deno_webgpu/src/buffer.rs | 2 +- deno_webgpu/src/bundle.rs | 2 +- deno_webgpu/src/command_encoder.rs | 2 +- deno_webgpu/src/compute_pass.rs | 2 +- deno_webgpu/src/error.rs | 2 +- deno_webgpu/src/lib.rs | 5 +- deno_webgpu/src/pipeline.rs | 2 +- deno_webgpu/src/queue.rs | 2 +- deno_webgpu/src/render_pass.rs | 2 +- deno_webgpu/src/sampler.rs | 2 +- deno_webgpu/src/shader.rs | 2 +- deno_webgpu/src/surface.rs | 5 +- deno_webgpu/src/texture.rs | 2 +- deno_webgpu/webgpu.idl | 3 + 24 files changed, 83 insertions(+), 117 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55c6f23809..0d88b89915 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,18 +548,18 @@ dependencies = [ [[package]] name = "deno_console" -version = "0.80.0" +version = "0.84.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a13f7497eaec2c5b7f766d7cecbdd8547611dabd6ce8f615c507d275887049" +checksum = "b1fcedec1b382f40fd1ab38d18edb5715d5cd5f65bd949c83387c43152fd34a8" dependencies = [ "deno_core", ] [[package]] name = "deno_core" -version = "0.162.0" +version = "0.166.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f2aa18d22faadc44c9c287b4d6f5a0f2aeea75a120d2a7d400a98e4b9255584" +checksum = "c5db7d38c223a683b23b7ff4967572ec863f40397fa1bb792383273629e1e39f" dependencies = [ "anyhow", "bytes", @@ -582,9 +582,9 @@ dependencies = [ [[package]] name = "deno_ops" -version = "0.40.0" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83ddd1b980dcf7c7b4ad586338704c78c6423608f4b8fd622d72bfa76006333f" +checksum = "27e85062a5f1a79194e7dd1bb8c664f0979bf5c869a8f2208192cbcb6e18e6e7" dependencies = [ "once_cell", "pmutil", @@ -597,9 +597,9 @@ dependencies = [ [[package]] name = "deno_url" -version = "0.80.0" +version = "0.84.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d0cf9b99857820d594cc816b84507ba062f276427aab815c380cdeec6554021" +checksum = "26886a84668c9420acbec6ca83b33a51c68310efdf3cdc7ec797c2f2bc873af8" dependencies = [ "deno_core", "serde", @@ -609,9 +609,9 @@ dependencies = [ [[package]] name = "deno_web" -version = "0.111.0" +version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54f0a00df81eee23798d2a516bdc54d7541e3008310b26e7f79533df7d22bd7b" +checksum = "bacd1dda9935fdc8727057b26b3bdfdb8f72a7dd0b168a2eeb3537c99c5bf1e6" dependencies = [ "async-trait", "base64-simd", @@ -625,7 +625,7 @@ dependencies = [ [[package]] name = "deno_webgpu" -version = "0.81.0" +version = "0.85.0" dependencies = [ "deno_core", "raw-window-handle 0.5.0", @@ -637,9 +637,9 @@ dependencies = [ [[package]] name = "deno_webidl" -version = "0.80.0" +version = "0.84.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92a564d515fb807b1f2712717b4de5082cc59f3f86a7e233c04231a760c001e5" +checksum = "1cfddf618b405e0399cf923f3ce7d3d7e2b472f817d2fb7f70a12e0cafd849a5" dependencies = [ "deno_core", ] @@ -1630,9 +1630,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.14.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "osmesa-sys" @@ -2087,9 +2087,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.144" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" +checksum = "256b9932320c590e707b94576e3cc1f7c9024d0ee6612dfbcf1cb106cbe8e055" dependencies = [ "serde_derive", ] @@ -2105,9 +2105,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.144" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" +checksum = "b4eae9b04cbffdfd550eb462ed33bc6a1b68c935127d008b27444d08380f94e4" dependencies = [ "proc-macro2", "quote", @@ -2139,9 +2139,9 @@ dependencies = [ [[package]] name = "serde_v8" -version = "0.73.0" +version = "0.77.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17891f7f7e138e2d25fafd19b5f7a95c2cf1e72be0e6804343c63aa6e90b0287" +checksum = "36203a818a80f973b4b487bfc32d173b2bf78821869513af2f6e8c93938fa0e3" dependencies = [ "bytes", "derive_more", @@ -2387,9 +2387,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.21.1" +version = "1.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0020c875007ad96677dcc890298f4b942882c5d4eb7cc8f439fc3bf813dc9c95" +checksum = "7125661431c26622a80ca5051a2f936c9a678318e0351007b0cc313143024e5c" dependencies = [ "autocfg", "bytes", @@ -2397,13 +2397,12 @@ dependencies = [ "memchr", "mio", "num_cpus", - "once_cell", "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "winapi", + "windows-sys 0.42.0", ] [[package]] @@ -2543,9 +2542,9 @@ dependencies = [ [[package]] name = "v8" -version = "0.58.0" +version = "0.60.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b88668afedf6ec9f8f6d30b446f622498da2ef0b3991a52e10f0ea8c6cc09" +checksum = "5867543c19b87c45ed3f2bc49eb6135474ed6a1803cac40c278620b53e9865ef" dependencies = [ "bitflags", "fslock", diff --git a/Cargo.toml b/Cargo.toml index c713e7fd4f..d0ffea48da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,11 +118,11 @@ wasm-bindgen-test = "0.3" web-sys = "0.3.60" # deno dependencies -deno_console = "0.80.0" -deno_core = "0.162.0" -deno_url = "0.80.0" -deno_web = "0.111.0" -deno_webidl = "0.80.0" +deno_console = "0.84.0" +deno_core = "0.166.0" +deno_url = "0.84.0" +deno_web = "0.115.0" +deno_webidl = "0.84.0" deno_webgpu = { path = "./deno_webgpu" } tokio = "1.19.0" termcolor = "1.1.2" diff --git a/cts_runner/src/main.rs b/cts_runner/src/main.rs index 1d459781d1..057224ccd0 100644 --- a/cts_runner/src/main.rs +++ b/cts_runner/src/main.rs @@ -71,7 +71,7 @@ async fn run() -> Result<(), AnyError> { } fn extension() -> deno_core::Extension { - deno_core::Extension::builder() + deno_core::Extension::builder("bootstrap") .ops(vec![ op_exit::decl(), op_read_file_sync::decl(), diff --git a/deno_webgpu/Cargo.toml b/deno_webgpu/Cargo.toml index 628adbd6c3..eeb012f41e 100644 --- a/deno_webgpu/Cargo.toml +++ b/deno_webgpu/Cargo.toml @@ -1,8 +1,8 @@ -# Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +# Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. [package] name = "deno_webgpu" -version = "0.81.0" +version = "0.85.0" authors = ["the Deno authors"] edition.workspace = true license = "MIT" diff --git a/deno_webgpu/LICENSE.md b/deno_webgpu/LICENSE.md index cfc3a5226e..aec557f3a0 100644 --- a/deno_webgpu/LICENSE.md +++ b/deno_webgpu/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright 2018-2022 the Deno authors +Copyright 2018-2023 the Deno authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/deno_webgpu/src/01_webgpu.js b/deno_webgpu/src/01_webgpu.js index d857bd2b42..07c03dcc69 100644 --- a/deno_webgpu/src/01_webgpu.js +++ b/deno_webgpu/src/01_webgpu.js @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // @ts-check /// @@ -34,14 +34,9 @@ SafeArrayIterator, SafePromiseAll, Set, - SetPrototypeEntries, - SetPrototypeForEach, SetPrototypeHas, - SetPrototypeKeys, - SetPrototypeValues, Symbol, SymbolFor, - SymbolIterator, TypeError, Uint32Array, Uint32ArrayPrototype, @@ -61,7 +56,6 @@ const _architecture = Symbol("[[architecture]]"); const _description = Symbol("[[description]]"); const _limits = Symbol("[[limits]]"); - const _features = Symbol("[[features]]"); const _reason = Symbol("[[reason]]"); const _message = Symbol("[[message]]"); const _label = Symbol("[[label]]"); @@ -332,8 +326,9 @@ context: "Argument 1", }); const requiredFeatures = descriptor.requiredFeatures ?? []; - for (const feature of requiredFeatures) { - if (!SetPrototypeHas(this[_adapter].features[_features], feature)) { + for (let i = 0; i < requiredFeatures.length; ++i) { + const feature = requiredFeatures[i]; + if (!SetPrototypeHas(this[_adapter].features[webidl.setlikeInner], feature)) { throw new TypeError( `${prefix}: nonGuaranteedFeatures must be a subset of the adapter features.`, ); @@ -518,6 +513,10 @@ webidl.assertBranded(this, GPUSupportedLimitsPrototype); return this[_limits].maxBindGroups; } + get maxBindingsPerBindGroup() { + webidl.assertBranded(this, GPUSupportedLimitsPrototype); + return this[_limits].maxBindingsPerBindGroup; + } get maxBufferSize() { webidl.assertBranded(this, GPUSupportedLimitsPrototype); return this[_limits].maxBufferSize; @@ -615,60 +614,19 @@ function createGPUSupportedFeatures(features) { /** @type {GPUSupportedFeatures} */ - const adapterFeatures = webidl.createBranded(GPUSupportedFeatures); - adapterFeatures[_features] = new Set(features); - return adapterFeatures; + const supportedFeatures = webidl.createBranded(GPUSupportedFeatures); + supportedFeatures[webidl.setlikeInner] = new Set(features); + return webidl.setlike( + supportedFeatures, + GPUSupportedFeaturesPrototype, + true, + ); } class GPUSupportedFeatures { - /** @type {Set} */ - [_features]; - constructor() { webidl.illegalConstructor(); } - - /** @return {IterableIterator<[string, string]>} */ - entries() { - webidl.assertBranded(this, GPUSupportedFeaturesPrototype); - return SetPrototypeEntries(this[_features]); - } - - /** @return {void} */ - forEach(callbackfn, thisArg) { - webidl.assertBranded(this, GPUSupportedFeaturesPrototype); - SetPrototypeForEach(this[_features], callbackfn, thisArg); - } - - /** @return {boolean} */ - has(value) { - webidl.assertBranded(this, GPUSupportedFeaturesPrototype); - return SetPrototypeHas(this[_features], value); - } - - /** @return {IterableIterator} */ - keys() { - webidl.assertBranded(this, GPUSupportedFeaturesPrototype); - return SetPrototypeKeys(this[_features]); - } - - /** @return {IterableIterator} */ - values() { - webidl.assertBranded(this, GPUSupportedFeaturesPrototype); - return SetPrototypeValues(this[_features]); - } - - /** @return {number} */ - get size() { - webidl.assertBranded(this, GPUSupportedFeaturesPrototype); - return this[_features].size; - } - - [SymbolIterator]() { - webidl.assertBranded(this, GPUSupportedFeaturesPrototype); - return this[_features][SymbolIterator](); - } - [SymbolFor("Deno.privateCustomInspect")](inspect) { return `${this.constructor.name} ${ inspect([...new SafeArrayIterator(this.values())]) @@ -1060,7 +1018,9 @@ context: "Argument 1", }); const device = assertDevice(this, { prefix, context: "this" }); - for (const entry of descriptor.entries) { + for (let i = 0; i < descriptor.entries.length; ++i) { + const entry = descriptor.entries[i]; + let i = 0; if (entry.buffer) i++; if (entry.sampler) i++; @@ -1599,8 +1559,8 @@ }, ); const { err } = ops.op_webgpu_queue_submit(device.rid, commandBufferRids); - for (const commandBuffer of commandBuffers) { - commandBuffer[_rid] = undefined; + for (let i = 0; i < commandBuffers.length; ++i) { + commandBuffers[i][_rid] = undefined; } device.pushError(err); } @@ -1956,7 +1916,8 @@ if (!mappedRanges) { throw new DOMException(`${prefix}: invalid state.`, "OperationError"); } - for (const [buffer, _rid, start] of mappedRanges) { + for (let i = 0; i < mappedRanges.length; ++i) { + const [buffer, _rid, start] = mappedRanges[i]; // TODO(lucacasonato): is this logic correct? const end = start + buffer.byteLength; if ( @@ -2024,7 +1985,8 @@ if (!mappedRanges) { throw new DOMException(`${prefix}: invalid state.`, "OperationError"); } - for (const [buffer, mappedRid] of mappedRanges) { + for (let i = 0; i < mappedRanges.length; ++i) { + const [buffer, mappedRid] = mappedRanges[i]; const { err } = ops.op_webgpu_buffer_unmap( bufferRid, mappedRid, diff --git a/deno_webgpu/src/02_idl_types.js b/deno_webgpu/src/02_idl_types.js index 1308834b19..0bd289aba8 100644 --- a/deno_webgpu/src/02_idl_types.js +++ b/deno_webgpu/src/02_idl_types.js @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // @ts-check /// diff --git a/deno_webgpu/src/03_surface.js b/deno_webgpu/src/03_surface.js index bd3da8cd37..a11a229119 100644 --- a/deno_webgpu/src/03_surface.js +++ b/deno_webgpu/src/03_surface.js @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // @ts-check /// diff --git a/deno_webgpu/src/04_surface_idl_types.js b/deno_webgpu/src/04_surface_idl_types.js index 942c2a5b2b..8e9f5eca2c 100644 --- a/deno_webgpu/src/04_surface_idl_types.js +++ b/deno_webgpu/src/04_surface_idl_types.js @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // @ts-check /// diff --git a/deno_webgpu/src/binding.rs b/deno_webgpu/src/binding.rs index cb14c3ac30..eeb78a2d93 100644 --- a/deno_webgpu/src/binding.rs +++ b/deno_webgpu/src/binding.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op; diff --git a/deno_webgpu/src/buffer.rs b/deno_webgpu/src/buffer.rs index 738760606c..34de46e6ae 100644 --- a/deno_webgpu/src/buffer.rs +++ b/deno_webgpu/src/buffer.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use deno_core::error::type_error; use deno_core::error::AnyError; diff --git a/deno_webgpu/src/bundle.rs b/deno_webgpu/src/bundle.rs index 6c1e1cae43..b63b076686 100644 --- a/deno_webgpu/src/bundle.rs +++ b/deno_webgpu/src/bundle.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use deno_core::error::{type_error, AnyError}; use deno_core::op; diff --git a/deno_webgpu/src/command_encoder.rs b/deno_webgpu/src/command_encoder.rs index d894fe62d2..a1009fb98e 100644 --- a/deno_webgpu/src/command_encoder.rs +++ b/deno_webgpu/src/command_encoder.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op; diff --git a/deno_webgpu/src/compute_pass.rs b/deno_webgpu/src/compute_pass.rs index cc9a81e897..012aefdcae 100644 --- a/deno_webgpu/src/compute_pass.rs +++ b/deno_webgpu/src/compute_pass.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op; diff --git a/deno_webgpu/src/error.rs b/deno_webgpu/src/error.rs index f9903579f9..17ff7c1ef4 100644 --- a/deno_webgpu/src/error.rs +++ b/deno_webgpu/src/error.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::ResourceId; use serde::Serialize; diff --git a/deno_webgpu/src/lib.rs b/deno_webgpu/src/lib.rs index bdd64b3c5f..e951ba140a 100644 --- a/deno_webgpu/src/lib.rs +++ b/deno_webgpu/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. #![warn(unsafe_op_in_unsafe_fn)] @@ -117,7 +117,8 @@ impl Resource for WebGpuQuerySet { } pub fn init(unstable: bool) -> Extension { - Extension::builder() + Extension::builder(env!("CARGO_PKG_NAME")) + .dependencies(vec!["deno_webidl", "deno_web"]) .js(include_js_files!( prefix "deno:deno_webgpu", "01_webgpu.js", diff --git a/deno_webgpu/src/pipeline.rs b/deno_webgpu/src/pipeline.rs index 280825aebf..f33dc2de3f 100644 --- a/deno_webgpu/src/pipeline.rs +++ b/deno_webgpu/src/pipeline.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op; diff --git a/deno_webgpu/src/queue.rs b/deno_webgpu/src/queue.rs index a5e830663e..5e310ae99c 100644 --- a/deno_webgpu/src/queue.rs +++ b/deno_webgpu/src/queue.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use std::num::NonZeroU32; diff --git a/deno_webgpu/src/render_pass.rs b/deno_webgpu/src/render_pass.rs index 30a966e70e..4e8431e784 100644 --- a/deno_webgpu/src/render_pass.rs +++ b/deno_webgpu/src/render_pass.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use deno_core::error::type_error; use deno_core::error::AnyError; diff --git a/deno_webgpu/src/sampler.rs b/deno_webgpu/src/sampler.rs index 51df509d69..4bf1bce15d 100644 --- a/deno_webgpu/src/sampler.rs +++ b/deno_webgpu/src/sampler.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op; diff --git a/deno_webgpu/src/shader.rs b/deno_webgpu/src/shader.rs index 8b56eb1ad2..d4025fb95e 100644 --- a/deno_webgpu/src/shader.rs +++ b/deno_webgpu/src/shader.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op; diff --git a/deno_webgpu/src/surface.rs b/deno_webgpu/src/surface.rs index 8a476667d4..4c9577f670 100644 --- a/deno_webgpu/src/surface.rs +++ b/deno_webgpu/src/surface.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use super::WebGpuResult; use deno_core::error::AnyError; @@ -13,7 +13,8 @@ use std::borrow::Cow; use wgpu_types::SurfaceStatus; pub fn init_surface(unstable: bool) -> Extension { - Extension::builder() + Extension::builder("deno_webgpu_surface") + .dependencies(vec!["deno_webidl", "deno_web", "deno_webgpu"]) .js(include_js_files!( prefix "deno:deno_webgpu", "03_surface.js", diff --git a/deno_webgpu/src/texture.rs b/deno_webgpu/src/texture.rs index db3c1143fe..e4114b43fe 100644 --- a/deno_webgpu/src/texture.rs +++ b/deno_webgpu/src/texture.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; use deno_core::op; diff --git a/deno_webgpu/webgpu.idl b/deno_webgpu/webgpu.idl index 7d5da0a878..8aa6964494 100644 --- a/deno_webgpu/webgpu.idl +++ b/deno_webgpu/webgpu.idl @@ -13,6 +13,7 @@ interface GPUSupportedLimits { readonly attribute unsigned long maxTextureDimension3D; readonly attribute unsigned long maxTextureArrayLayers; readonly attribute unsigned long maxBindGroups; + readonly attribute unsigned long maxBindingsPerBindGroup; readonly attribute unsigned long maxDynamicUniformBuffersPerPipelineLayout; readonly attribute unsigned long maxDynamicStorageBuffersPerPipelineLayout; readonly attribute unsigned long maxSampledTexturesPerShaderStage; @@ -1065,6 +1066,8 @@ enum GPUPipelineStatisticName { [Exposed=(Window, DedicatedWorker), SecureContext] interface GPUCanvasContext { + readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas; + undefined configure(GPUCanvasConfiguration configuration); undefined unconfigure(); From fac4731288117d951d0944d96cf0b00fa006dd6c Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Sat, 14 Jan 2023 10:25:21 -0800 Subject: [PATCH 11/11] Add missing CHANGELOG.md entry. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90f7335877..cd8f1ee4de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -181,6 +181,7 @@ Additionally `Surface::get_default_config` now returns an Option and returns Non - Evaluate `gfx_select!`'s `#[cfg]` conditions at the right time. By @jimblandy in [#3253](https://github.com/gfx-rs/wgpu/pull/3253) - Improve error messages when binding bind group with dynamic offsets. By @cwfitzgerald in [#3294](https://github.com/gfx-rs/wgpu/pull/3294) - Allow non-filtering sampling of integer textures. By @JMS55 in [#3362](https://github.com/gfx-rs/wgpu/pull/3362). +- Validate texture ids in `Global::queue_texture_write`. By @jimblandy in [#3378](https://github.com/gfx-rs/wgpu/pull/3378). #### Metal - Fix texture view creation with full-resource views when using an explicit `mip_level_count` or `array_layer_count`. By @cwfitzgerald in [#3323](https://github.com/gfx-rs/wgpu/pull/3323)