mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[rs] Implement more derives for Operations (#450)
* Implement more derives for `Operations` * Use `trace` / `replay` features for serialization * Set `store` to default
This commit is contained in:
@@ -17,8 +17,8 @@ all-features = true
|
||||
|
||||
[features]
|
||||
default = []
|
||||
trace = ["wgc/trace"]
|
||||
replay = ["wgc/replay"]
|
||||
trace = ["serde", "wgc/trace"]
|
||||
replay = ["serde", "wgc/replay"]
|
||||
subscriber = ["wgc/subscriber"]
|
||||
# Make Vulkan backend available on platforms where it is by default not, e.g. macOS
|
||||
vulkan = ["wgc/gfx-backend-vulkan"]
|
||||
@@ -44,6 +44,7 @@ raw-window-handle = "0.3"
|
||||
smallvec = "1"
|
||||
tracing = { version = "0.1", default-features = false, features = ["std"] }
|
||||
typed-arena = "2.0.1"
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
|
||||
#Note: we may consider switching this to "dev-dependencies" if users
|
||||
# want to opt into X11 explicitly.
|
||||
|
||||
@@ -22,6 +22,10 @@ use std::{
|
||||
|
||||
use futures::FutureExt as _;
|
||||
use parking_lot::Mutex;
|
||||
#[cfg(feature = "trace")]
|
||||
use serde::Serialize;
|
||||
#[cfg(feature = "replay")]
|
||||
use serde::Deserialize;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use wgc::instance::{AdapterInfo, DeviceType};
|
||||
@@ -797,7 +801,9 @@ pub enum BindingResource<'a> {
|
||||
}
|
||||
|
||||
/// Operation to perform to the output attachment at the start of a renderpass.
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "trace", derive(Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
pub enum LoadOp<V> {
|
||||
/// Clear with a specified value.
|
||||
Clear(V),
|
||||
@@ -805,8 +811,16 @@ pub enum LoadOp<V> {
|
||||
Load,
|
||||
}
|
||||
|
||||
impl<V: Default> Default for LoadOp<V> {
|
||||
fn default() -> Self {
|
||||
Self::Clear(Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
/// Pair of load and store operations for an attachment aspect.
|
||||
#[derive(Clone, Debug, Hash, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "trace", derive(Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
pub struct Operations<V> {
|
||||
/// How data should be read through this attachment.
|
||||
pub load: LoadOp<V>,
|
||||
@@ -814,6 +828,15 @@ pub struct Operations<V> {
|
||||
pub store: bool,
|
||||
}
|
||||
|
||||
impl<V: Default> Default for Operations<V> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
load: Default::default(),
|
||||
store: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Describes a color attachment to a [`RenderPass`].
|
||||
#[derive(Clone)]
|
||||
pub struct RenderPassColorAttachmentDescriptor<'a> {
|
||||
|
||||
Reference in New Issue
Block a user