Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Bottom level categories:
- Zero-initialize padding (if any) at the end of a buffer allocation. This was application-visible in rare cases on Vulkan when a shader read beyond the valid range of a vertex buffer. By @andyleiserson in [#9791](https://github.com/gfx-rs/wgpu/pull/9791).
- Fix required immediate slots calculation and remove `naga::valid::FunctionInfo::immediate_slots_used`. By @beicause in [#9725](https://github.com/gfx-rs/wgpu/pull/9725).
- Fix `PendingSubmission` releasing its lock guards out of stacking order, which tripped `--cfg wgpu_validate_locks` on any submission. By @AdrianEddy in [#9960](https://github.com/gfx-rs/wgpu/pull/9960).
- Explicitly implement `Send` and `Sync` in `wgpu-core` to reduce the risk of `recursion_limit` overflow. By @nazar-pc in [#9953](https://github.com/gfx-rs/wgpu/pull/9953)

#### naga

Expand Down Expand Up @@ -1481,7 +1482,7 @@ By @wumpf in [#8282](https://github.com/gfx-rs/wgpu/pull/8282), [#8285](https://
- naga now requires that no type be larger than 1 GB. This limit may be lowered in the future; feedback on an appropriate value for the limit is welcome. By @andyleiserson in [#7950](https://github.com/gfx-rs/wgpu/pull/7950).
- If the shader source contains control characters, naga now replaces them with U+FFFD ("replacement character") in diagnostic output. By @andyleiserson in [#8049](https://github.com/gfx-rs/wgpu/pull/8049).
- Add f16 IO polyfill on Vulkan backend to enable SHADER_F16 use without requiring `storageInputOutput16`. By @cryvosh in [#7884](https://github.com/gfx-rs/wgpu/pull/7884).
- For custom Naga backend authors: `naga::proc::Namer` now accepts reserved keywords using two new dedicated types, `proc::{KeywordSet, CaseInsensitiveKeywordSet}`. By @kpreid in [#8136](https://github.com/gfx-rs/wgpu/pull/8136).
- For custom Naga backend authors: `naga::proc::Namer` now accepts reserved keywords using two new dedicated types, `proc::{KeywordSet, CaseInsensitiveKeywordSet}`. By @kpreid in [#8136](https://github.com/gfx-rs/wgpu/pull/8136).
- **BREAKING**: Previously the WGSL storage-texture format `rg11b10float` was incorrectly accepted and generated by naga, but now only accepts the the correct name `rg11b10ufloat` instead. By @ErikWDev in [#8219](https://github.com/gfx-rs/wgpu/pull/8219).
- The [`source()`](https://doc.rust-lang.org/std/error/trait.Error.html#method.source) method of `ShaderError` no longer reports the error as its own source. By @andyleiserson in [#8258](https://github.com/gfx-rs/wgpu/pull/8258).
- naga correctly ingests SPIR-V that use descriptor runtime indexing, which in turn is correctly converted into WGSLs binding array. By @hasenbanck in [8256](https://github.com/gfx-rs/wgpu/pull/8256).
Expand Down
47 changes: 41 additions & 6 deletions wgpu-core/src/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,47 @@ impl Global {
}
}

/// Implement [`Send`] + [`Sync`] for [`Global`], and check that all of its fields are.
///
/// This is identical to the “auto trait” implementation that Rust would provide, except that
/// it is eager rather than lazy: its requirements are checked now (in
/// `_global_fields_are_send_sync`), when this crate is compiled, rather than whenever a dependent
/// wants to know whether `Global: Send` holds.
///
/// This improves compilation performance and avoids a risk of dependents running into the default
/// [`recursion_limit`] when checking types containing [`Global`]. This risk will become greater
/// when Rust’s “next solver” is stabilized.
///
/// [`recursion_limit`]: https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute
#[cfg(send_sync)]
mod global_send_sync {
use super::Global;

// SAFETY: Bounds checked below
unsafe impl Send for Global {}

// SAFETY: Bounds checked below
unsafe impl Sync for Global {}

/// This function will fail to compile if any field is not `Send + Sync`, or if a new field is
/// added to `Global`.
///
/// This technique is modeled after the macro library <https://crates.io/crates/non_structural_derive>;
/// however, we only need it once, so it’s cheaper to write out the same code the macro would generate.
fn _global_fields_are_send_sync(global: &Global) {
fn _check_bound<T: Send + Sync>(_: &T) {}

let Global {
surfaces,
hub,
instance,
} = global;
_check_bound(surfaces);
_check_bound(hub);
_check_bound(instance);
}
}

impl fmt::Debug for Global {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Global").finish()
Expand All @@ -299,9 +340,3 @@ impl Drop for Global {
resource_log!("Global::drop");
}
}

#[cfg(send_sync)]
fn _test_send_sync(global: &Global) {
fn test_internal<T: Send + Sync>(_: T) {}
test_internal(global)
}
2 changes: 0 additions & 2 deletions wgpu-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//!

#![no_std]
// `-Znext-solver` requires deeper recursion limits (at least for now) to prove Send/Sync
#![recursion_limit = "256"]
// When we have no backends, we end up with a lot of dead or otherwise unreachable code.
#![cfg_attr(
all(
Expand Down
2 changes: 0 additions & 2 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@
//!

#![no_std]
// `-Znext-solver` requires deeper recursion limits (at least for now) to prove Send/Sync
#![recursion_limit = "256"]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc(html_logo_url = "https://raw.githubusercontent.com/gfx-rs/wgpu/trunk/logo.png")]
#![warn(
Expand Down
Loading