Skip to content

Commit 2385467

Browse files
committed
Fix serde feature gating
1 parent 990a5b2 commit 2385467

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

wgpu-core/src/command/compute_command.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use crate::command::{serde_object_reference_struct, ArcReferences, ReferenceType};
1+
#[cfg(feature = "serde")]
2+
use crate::command::serde_object_reference_struct;
3+
use crate::command::{ArcReferences, ReferenceType};
24

35
#[cfg(feature = "serde")]
46
use macro_rules_attribute::apply;

wgpu-core/src/command/encoder_command.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub struct IdReferences;
3535
/// This is used for trace recording and playback. Recording stores the pointer
3636
/// value of `Arc` references in the trace. Playback uses the integer values
3737
/// as keys to a `HashMap`.
38+
#[cfg(feature = "serde")]
3839
#[doc(hidden)]
3940
#[derive(Clone, Debug)]
4041
pub struct PointerReferences;
@@ -58,6 +59,7 @@ impl ReferenceType for IdReferences {
5859
type Tlas = id::TlasId;
5960
}
6061

62+
#[cfg(feature = "serde")]
6163
impl ReferenceType for PointerReferences {
6264
type Buffer = id::PointerId<id::markers::Buffer>;
6365
type Surface = id::PointerId<id::markers::Surface>;

wgpu-core/src/command/render_command.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use wgt::{BufferAddress, BufferSize, Color};
22

33
use super::{DrawCommandFamily, Rect};
4-
use crate::command::{serde_object_reference_struct, ArcReferences, ReferenceType};
4+
#[cfg(feature = "serde")]
5+
use crate::command::serde_object_reference_struct;
6+
use crate::command::{ArcReferences, ReferenceType};
57

68
#[cfg(feature = "serde")]
79
use macro_rules_attribute::apply;

wgpu-core/src/id.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,25 @@ pub enum SerialId {
9696
Id(Index, Epoch),
9797
}
9898

99+
#[cfg(feature = "serde")]
99100
impl From<RawId> for SerialId {
100101
fn from(id: RawId) -> Self {
101102
let (index, epoch) = id.unzip();
102103
Self::Id(index, epoch)
103104
}
104105
}
105106

107+
#[cfg(feature = "serde")]
106108
pub struct ZeroIdError;
107109

110+
#[cfg(feature = "serde")]
108111
impl fmt::Display for ZeroIdError {
109112
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
110113
write!(f, "IDs may not be zero")
111114
}
112115
}
113116

117+
#[cfg(feature = "serde")]
114118
impl TryFrom<SerialId> for RawId {
115119
type Error = ZeroIdError;
116120
fn try_from(id: SerialId) -> Result<Self, ZeroIdError> {
@@ -127,21 +131,24 @@ impl TryFrom<SerialId> for RawId {
127131
///
128132
/// This is used for tracing.
129133
#[allow(dead_code)]
130-
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
131-
#[derive(Debug)]
134+
#[cfg(feature = "serde")]
135+
#[derive(Debug, serde::Serialize, serde::Deserialize)]
132136
pub enum PointerId<T: Marker> {
133137
// The only variant forces RON to not ignore "Id"
134138
PointerId(usize, #[serde(skip)] PhantomData<T>),
135139
}
136140

141+
#[cfg(feature = "serde")]
137142
impl<T: Marker> Copy for PointerId<T> {}
138143

144+
#[cfg(feature = "serde")]
139145
impl<T: Marker> Clone for PointerId<T> {
140146
fn clone(&self) -> Self {
141147
*self
142148
}
143149
}
144150

151+
#[cfg(feature = "serde")]
145152
impl<T: Marker> PartialEq for PointerId<T> {
146153
fn eq(&self, other: &Self) -> bool {
147154
let PointerId::PointerId(this, _) = self;
@@ -150,15 +157,18 @@ impl<T: Marker> PartialEq for PointerId<T> {
150157
}
151158
}
152159

160+
#[cfg(feature = "serde")]
153161
impl<T: Marker> Eq for PointerId<T> {}
154162

163+
#[cfg(feature = "serde")]
155164
impl<T: Marker> Hash for PointerId<T> {
156165
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
157166
let PointerId::PointerId(this, _) = self;
158167
this.hash(state);
159168
}
160169
}
161170

171+
#[cfg(feature = "serde")]
162172
impl<T: StorageItem> From<&Arc<T>> for PointerId<T::Marker> {
163173
fn from(arc: &Arc<T>) -> Self {
164174
// Since the memory representation of `Arc<T>` is just a pointer to

0 commit comments

Comments
 (0)