diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index bc77bccfc..5bc785efe 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -17,7 +17,7 @@ license = "MPL-2.0" [features] default = [] metal-auto-capture = ["gfx-backend-metal/auto-capture"] -serde1 = ["wgt/serde"] +serde = ["wgt/serde", "serde_crate"] #NOTE: glutin feature is not stable, use at your own risk #glutin = ["gfx-backend-gl/glutin"] @@ -33,10 +33,15 @@ parking_lot = "0.9" peek-poke = { git = "https://github.com/kvark/peek-poke", rev = "969bd7fe2be1a83f87916dc8b388c63cfd457075" } rendy-memory = "0.5" rendy-descriptor = "0.5" -serde = { version = "1.0", features = ["serde_derive"], optional = true } smallvec = "1.0" vec_map = "0.8" +[dependencies.serde_crate] +package = "serde" +version = "1.0" +features = ["serde_derive"] +optional = true + [dependencies.wgt] path = "../wgpu-types" package = "wgpu-types" diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index adee103c0..20faca8d0 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -16,12 +16,12 @@ use arrayvec::ArrayVec; use rendy_descriptor::{DescriptorRanges, DescriptorSet}; #[cfg(feature = "serde")] -use serde::{Deserialize, Serialize}; +use serde_crate::{Deserialize, Serialize}; use std::borrow::Borrow; #[repr(C)] #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))] pub enum BindingType { UniformBuffer = 0, StorageBuffer = 1, @@ -33,7 +33,7 @@ pub enum BindingType { #[repr(C)] #[derive(Clone, Debug, Hash, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))] pub struct BindGroupLayoutBinding { pub binding: u32, pub visibility: wgt::ShaderStage, @@ -73,7 +73,7 @@ pub struct PipelineLayout { #[repr(C)] #[derive(Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))] pub struct BufferBinding { pub buffer: BufferId, pub offset: BufferAddress, @@ -82,7 +82,7 @@ pub struct BufferBinding { #[repr(C)] #[derive(Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))] pub enum BindingResource { Buffer(BufferBinding), Sampler(SamplerId), @@ -91,7 +91,7 @@ pub enum BindingResource { #[repr(C)] #[derive(Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))] pub struct BindGroupBinding { pub binding: u32, pub resource: BindingResource, diff --git a/wgpu-core/src/id.rs b/wgpu-core/src/id.rs index bbd8d0aec..4a217be05 100644 --- a/wgpu-core/src/id.rs +++ b/wgpu-core/src/id.rs @@ -4,7 +4,7 @@ use crate::{Epoch, Index}; #[cfg(feature = "serde")] -use serde::{Deserialize, Serialize}; +use serde_crate::{Deserialize, Serialize}; use wgt::Backend; use std::{fmt, marker::PhantomData, mem}; @@ -13,7 +13,7 @@ const EPOCH_MASK: u32 = (1 << (32 - BACKEND_BITS)) - 1; type Dummy = crate::backend::Empty; #[repr(transparent)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))] pub struct Id(u64, PhantomData); impl Id { diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index bae96942a..9f1389249 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -13,7 +13,7 @@ use crate::{ use wgt::{Backend, BackendBit, DeviceDescriptor, PowerPreference, RequestAdapterOptions}; #[cfg(feature = "serde")] -use serde::{Deserialize, Serialize}; +use serde_crate::{Deserialize, Serialize}; use hal::{ self, @@ -103,7 +103,7 @@ pub struct Adapter { /// Metadata about a backend adapter. #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))] pub struct AdapterInfo { /// Adapter name pub name: String, @@ -138,7 +138,7 @@ impl AdapterInfo { /// Supported physical device types #[derive(Clone, Debug, PartialEq)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(crate="serde_crate"))] pub enum DeviceType { /// Other Other, diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 526b798f4..2d0e5899e 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -15,7 +15,7 @@ use wgt::{BufferAddress, BufferUsage, CompareFunction, TextureFormat}; use hal; use rendy_memory::MemoryBlock; #[cfg(feature = "serde")] -use serde::{Deserialize, Serialize}; +use serde_crate::{Deserialize, Serialize}; use std::{borrow::Borrow, fmt}; diff --git a/wgpu-remote/Cargo.toml b/wgpu-remote/Cargo.toml index 5aabb78b1..122249413 100644 --- a/wgpu-remote/Cargo.toml +++ b/wgpu-remote/Cargo.toml @@ -19,7 +19,7 @@ default = [] path = "../wgpu-core" package = "wgpu-core" version = "0.1" -features = ["serde1"] +features = ["serde"] [dependencies.wgt] path = "../wgpu-types"