mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-24 00:11:11 +01:00
Prevent deserializing or defaulting LoadOp::DontCare, for soundness. (#9428)
This commit is contained in:
1 parent
c9c7359f5b
commit
0b4bdaf9ce
5 files changed
+17
-2
No files matched your search
@@ -106,6 +106,7 @@ By @teoxoy in [#9351](https://github.com/gfx-rs/wgpu/pull/9351).
|
||||
- `Buffer::get_mapped_range` and variants now return `Result<_, MapRangeError>>` instead of panicking, in line with WebGPU spec. By @atlv24 in [#9281](https://github.com/gfx-rs/wgpu/pull/9281).
|
||||
- Passthrough shaders now require a list of entry points when being created. by @inner-daemons in [#9064](https://github.com/gfx-rs/wgpu/pull/9064).
|
||||
- BREAKING: The `dispatch` and `dispatch_indirect` methods on pass and bundle encoders have been renamed to `dispatch_workgroups` and `dispatch_workgroups_indirect`, respectively, to match the WebGPU spec. By @ErichDonGubler in [#9362](https://github.com/gfx-rs/wgpu/pull/9362).
|
||||
- `LoadOp::DontCare` can no longer be deserialized, and the `LoadOpDontCare` token no longer implements `Default`. This ensures that `DontCare` can only be used with `unsafe`, as intended. By @kpreid in [#9428](https://github.com/gfx-rs/wgpu/pull/9428).
|
||||
|
||||
#### Validation
|
||||
|
||||
|
||||
Generated
+1
@@ -4975,6 +4975,7 @@ dependencies = [
|
||||
"raw-window-handle",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"static_assertions",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ serde = { workspace = true, default-features = false, features = [
|
||||
"alloc",
|
||||
"derive",
|
||||
], optional = true }
|
||||
static_assertions.workspace = true
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
js-sys = { workspace = true, optional = true, default-features = false }
|
||||
|
||||
@@ -739,7 +739,8 @@ pub enum LoadOp<V> {
|
||||
///
|
||||
/// - All pixels in the render target must be written to before
|
||||
/// any read or a [`StoreOp::Store`] occurs.
|
||||
DontCare(#[cfg_attr(feature = "serde", serde(skip))] LoadOpDontCare) = 2,
|
||||
#[cfg_attr(feature = "serde", serde(skip))] // unsafe to use, so cannot be (de)serialized
|
||||
DontCare(LoadOpDontCare) = 2,
|
||||
}
|
||||
|
||||
impl<V> LoadOp<V> {
|
||||
|
||||
@@ -45,7 +45,14 @@ impl ExperimentalFeatures {
|
||||
}
|
||||
|
||||
/// Token of the user agreeing to use [`LoadOp::DontCare`](crate::LoadOp::DontCare).
|
||||
#[derive(Debug, Default, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
//
|
||||
// Maintenance note: This type MUST NOT implement Default, Deserialize, or anything else which
|
||||
// allows safely constructing it. This differs from `ExperimentalFeatures` because it doesn't have
|
||||
// an "enabled" flag, because its role is to prevent its container (an enum variant) from being
|
||||
// constructed at all. We could change that if necessary (e.g. perhaps for the wgpu trace/player),
|
||||
// but if we did, we would have to give `LoadOp::DontCare` a specific fallback behavior when the
|
||||
// token is disabled/invalid.
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct LoadOpDontCare {
|
||||
// Private to prevent construction outside of the unsafe
|
||||
// enabled() function.
|
||||
@@ -72,3 +79,7 @@ impl LoadOpDontCare {
|
||||
Self { _private: () }
|
||||
}
|
||||
}
|
||||
|
||||
static_assertions::assert_not_impl_any!(LoadOpDontCare: Default);
|
||||
#[cfg(feature = "serde")]
|
||||
static_assertions::assert_not_impl_any!(LoadOpDontCare: serde::Deserialize<'static>);
|
||||
Reference in new issue
Block a user