Skip to content

Commit

Permalink
Merge pull request #1 from warpdotdev/v0.20
Browse files Browse the repository at this point in the history
Merge `v0.20` into `warpdotdev/v0.20`
  • Loading branch information
alokedesai authored Jul 8, 2024
2 parents 44b2170 + 14a7698 commit 51c125c
Show file tree
Hide file tree
Showing 33 changed files with 854 additions and 358 deletions.
42 changes: 41 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,47 @@ Bottom level categories:
- Hal
-->

## Unreleased
## Unreleased

## v0.20.2 (2024-06-12)

This release force-bumps transitive dependencies of `wgpu` on `wgpu-core` and `wgpu-hal` to 0.21.1, to resolve some undefined behavior observable in the DX12 backend after upgrading to Rust 1.79 or later.

### Bug Fixes

#### General

* Fix a `CommandBuffer` leak. By @cwfitzgerald and @nical in [#5141](https://github.com/gfx-rs/wgpu/pull/5141)

#### DX12

* Do not feed `&""` to `D3DCompile`, by @workingjubilee in [#5812](https://github.com/gfx-rs/wgpu/issues/5812).

## v0.20.1 (2024-06-12)

This release included v0.21.0 of `wgpu-core` and `wgpu-hal`, due to breaking changes needed to solve vulkan validation issues.

### Bug Fixes

This release fixes the validation errors whenever a surface is used with the vulkan backend. By @cwfitzgerald in [#5681](https://github.com/gfx-rs/wgpu/pull/5681).

#### General

- Clean up weak references to texture views and bind groups to prevent memory leaks. By @xiaopengli89 in [#5595](https://github.com/gfx-rs/wgpu/pull/5595).
- Fix segfault on exit is queue & device are dropped before surface. By @sagudev in [#5640](https://github.com/gfx-rs/wgpu/pull/5640).

#### Metal

- Fix unrecognized selector crash on iOS 12. By @vladasz in [#5744](https://github.com/gfx-rs/wgpu/pull/5744).

#### Vulkan

- Fix enablement of subgroup ops extension on Vulkan devices that don't support Vulkan 1.3. By @cwfitzgerald in [#5624](https://github.com/gfx-rs/wgpu/pull/5624).


#### GLES / OpenGL

- Fix regression on OpenGL (EGL) where non-sRGB still used sRGB [#5642](https://github.com/gfx-rs/wgpu/pull/5642)

## v0.20.0 (2024-04-28)

Expand Down
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ keywords = ["graphics"]
license = "MIT OR Apache-2.0"
homepage = "https://wgpu.rs/"
repository = "https://github.com/gfx-rs/wgpu"
version = "0.20.0"
version = "0.20.2"
authors = ["gfx-rs developers"]

[workspace.dependencies.wgc]
package = "wgpu-core"
path = "./wgpu-core"
version = "0.20.0"
version = "0.21.0"

[workspace.dependencies.wgt]
package = "wgpu-types"
Expand All @@ -61,7 +61,7 @@ version = "0.20.0"
[workspace.dependencies.hal]
package = "wgpu-hal"
path = "./wgpu-hal"
version = "0.20.0"
version = "0.21.0"

[workspace.dependencies.naga]
path = "./naga"
Expand Down Expand Up @@ -119,7 +119,7 @@ smallvec = "1"
static_assertions = "1.1.0"
thiserror = "1"
wgpu = { version = "0.20.0", path = "./wgpu" }
wgpu-core = { version = "0.20.0", path = "./wgpu-core" }
wgpu-core = { version = "0.21.0", path = "./wgpu-core" }
wgpu-example = { version = "0.20.0", path = "./examples/common" }
wgpu-macros = { version = "0.20.0", path = "./wgpu-macros" }
wgpu-test = { version = "0.20.0", path = "./tests" }
Expand Down
2 changes: 1 addition & 1 deletion deno_webgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ workspace = true
features = ["dx12"]

[target.'cfg(windows)'.dependencies.wgpu-hal]
version = "0.20.0"
version = "0.21.0"
path = "../wgpu-hal"
features = ["windows_rs"]

Expand Down
16 changes: 14 additions & 2 deletions tests/tests/subgroup_operations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@ static SUBGROUP_OPERATIONS: GpuTestConfiguration = GpuTestConfiguration::new()
TestParameters::default()
.features(wgpu::Features::SUBGROUP)
.limits(wgpu::Limits::downlevel_defaults())
.expect_fail(wgpu_test::FailureCase::molten_vk())
// Expect metal to fail on tests involving operations in divergent control flow
//
// Newlines are included in the panic message to ensure that _additional_ failures
// are not matched against.
.expect_fail(
wgpu_test::FailureCase::molten_vk()
// 14.3 doesn't fail test 29
.panic("thread 0 failed tests: 27,\nthread 1 failed tests: 27, 28,\n")
// Prior versions do.
.panic("thread 0 failed tests: 27, 29,\nthread 1 failed tests: 27, 28, 29,\n"),
)
.expect_fail(
// Expect metal to fail on tests involving operations in divergent control flow
wgpu_test::FailureCase::backend(wgpu::Backends::METAL)
// 14.3 doesn't fail test 29
.panic("thread 0 failed tests: 27,\nthread 1 failed tests: 27, 28,\n")
// Prior versions do.
.panic("thread 0 failed tests: 27, 29,\nthread 1 failed tests: 27, 28, 29,\n"),
),
)
Expand Down
3 changes: 3 additions & 0 deletions tests/tests/subgroup_operations/shader.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ fn main(
add_result_to_mask(&passed, 25u, subgroup_invocation_id == 0u || subgroupShuffleUp(subgroup_invocation_id, 1u) == subgroup_invocation_id - 1u);
add_result_to_mask(&passed, 26u, subgroupShuffleXor(subgroup_invocation_id, subgroup_size - 1u) == (subgroup_invocation_id ^ (subgroup_size - 1u)));

// Mac/Apple will fail this test.
var passed_27 = false;
if subgroup_invocation_id % 2u == 0u {
passed_27 |= subgroupAdd(1u) == (subgroup_size / 2u);
Expand All @@ -119,6 +120,7 @@ fn main(
}
add_result_to_mask(&passed, 27u, passed_27);

// Mac/Apple will fail this test.
var passed_28 = false;
switch subgroup_invocation_id % 3u {
case 0u: {
Expand All @@ -134,6 +136,7 @@ fn main(
}
add_result_to_mask(&passed, 28u, passed_28);

// Mac/Apple will sometimes fail this test. MacOS 14.3 passes it, so the bug in the metal compiler seems to be fixed.
expected = 0u;
for (var i = subgroup_size; i >= 0u; i -= 1u) {
expected = subgroupAdd(1u);
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wgpu-core"
version = "0.20.0"
version = "0.21.1"
authors = ["gfx-rs developers"]
edition = "2021"
description = "WebGPU core logic on wgpu-hal"
Expand Down Expand Up @@ -127,7 +127,7 @@ version = "0.20.0"
[dependencies.hal]
package = "wgpu-hal"
path = "../wgpu-hal"
version = "0.20.0"
version = "0.21.0"
default_features = false

[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/device/any_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl AnyDevice {
unsafe fn drop_glue<A: HalApi>(ptr: *mut ()) {
// Drop the arc this instance is holding.
unsafe {
_ = Arc::from_raw(ptr.cast::<A::Surface>());
_ = Arc::from_raw(ptr.cast::<A::Device>());
}
}

Expand Down
19 changes: 19 additions & 0 deletions wgpu-core/src/device/life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,18 @@ impl<A: HalApi> LifetimeTracker<A> {
&mut trackers.textures,
|maps| &mut maps.textures,
);

// We may have been suspected because a texture view or bind group
// referring to us was dropped. Remove stale weak references, so that
// the backlink table doesn't grow without bound.
for texture in self.suspected_resources.textures.values() {
texture.views.lock().retain(|view| view.strong_count() > 0);
texture
.bind_groups
.lock()
.retain(|bg| bg.strong_count() > 0);
}

self
}

Expand All @@ -621,6 +633,13 @@ impl<A: HalApi> LifetimeTracker<A> {
|maps| &mut maps.buffers,
);

// We may have been suspected because a bind group referring to us was
// dropped. Remove stale weak references, so that the backlink table
// doesn't grow without bound.
for buffer in self.suspected_resources.buffers.values() {
buffer.bind_groups.lock().retain(|bg| bg.strong_count() > 0);
}

self
}

Expand Down
16 changes: 11 additions & 5 deletions wgpu-core/src/device/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,9 @@ impl Global {

let mut used_surface_textures = track::TextureUsageScope::default();

let mut submit_surface_textures_owned = SmallVec::<[_; 2]>::new();
// Use a hashmap here to deduplicate the surface textures that are used in the command buffers.
// This avoids vulkan deadlocking from the same surface texture being submitted multiple times.
let mut submit_surface_textures_owned = FastHashMap::default();

{
let mut command_buffer_guard = hub.command_buffers.write();
Expand Down Expand Up @@ -1279,7 +1281,9 @@ impl Global {
Some(TextureInner::Native { .. }) => false,
Some(TextureInner::Surface { ref raw, .. }) => {
if raw.is_some() {
submit_surface_textures_owned.push(texture.clone());
// Compare the Arcs by pointer as Textures don't implement Eq.
submit_surface_textures_owned
.insert(Arc::as_ptr(&texture), texture.clone());
}

true
Expand Down Expand Up @@ -1472,7 +1476,9 @@ impl Global {
Some(TextureInner::Native { .. }) => {}
Some(TextureInner::Surface { ref raw, .. }) => {
if raw.is_some() {
submit_surface_textures_owned.push(texture.clone());
// Compare the Arcs by pointer as Textures don't implement Eq
submit_surface_textures_owned
.insert(Arc::as_ptr(texture), texture.clone());
}

unsafe {
Expand Down Expand Up @@ -1517,7 +1523,7 @@ impl Global {
let mut submit_surface_textures =
SmallVec::<[_; 2]>::with_capacity(submit_surface_textures_owned.len());

for texture in &submit_surface_textures_owned {
for texture in submit_surface_textures_owned.values() {
submit_surface_textures.extend(match texture.inner.get(&snatch_guard) {
Some(TextureInner::Surface { raw, .. }) => raw.as_ref(),
_ => None,
Expand All @@ -1529,7 +1535,7 @@ impl Global {
.raw
.as_ref()
.unwrap()
.submit(&refs, &submit_surface_textures, Some((fence, submit_index)))
.submit(&refs, &submit_surface_textures, (fence, submit_index))
.map_err(DeviceError::from)?;
}

Expand Down
15 changes: 9 additions & 6 deletions wgpu-core/src/present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,20 @@ impl Global {
parent_id: surface_id,
});
}
#[cfg(not(feature = "trace"))]
let _ = device;

let fence_guard = device.fence.read();
let fence = fence_guard.as_ref().unwrap();

let suf = A::surface_as_hal(surface.as_ref());
let (texture_id, status) = match unsafe {
suf.unwrap()
.acquire_texture(Some(std::time::Duration::from_millis(
FRAME_TIMEOUT_MS as u64,
)))
suf.unwrap().acquire_texture(
Some(std::time::Duration::from_millis(FRAME_TIMEOUT_MS as u64)),
fence,
)
} {
Ok(Some(ast)) => {
drop(fence_guard);

let texture_desc = wgt::TextureDescriptor {
label: (),
size: wgt::Extent3d {
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wgpu-hal"
version = "0.20.0"
version = "0.21.1"
authors = ["gfx-rs developers"]
edition = "2021"
description = "WebGPU hardware abstraction layer"
Expand Down
Loading

0 comments on commit 51c125c

Please sign in to comment.