Skip to content

Commit ad86165

Browse files
committed
First bits of wgpu-remote
1 parent 2daba8f commit ad86165

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ crate-type = ["lib", "cdylib", "staticlib"]
1818
[features]
1919
default = []
2020
local = ["winit", "gfx-backend-empty/winit"]
21+
remote = ["serde"]
2122
metal-auto-capture = ["gfx-backend-metal/auto-capture"]
2223

2324
[dependencies]
@@ -32,4 +33,5 @@ gfx-backend-dx11 = { version = "0.1.0", optional = true }
3233
gfx-backend-dx12 = { version = "0.1.0", optional = true }
3334
gfx-backend-metal = { version = "0.1.0", optional = true }
3435
#rendy-memory = { git = "https://github.com/rustgd/rendy", rev = "ce7dd7f", features = ["gfx-hal"] }
36+
serde = { version = "1.0", features = ["serde_derive"], optional = true }
3537
winit = { version = "0.18", optional = true }

src/hub.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ impl<T> Registry<T> {
107107
}
108108
}
109109

110+
#[cfg(feature = "remote")]
111+
impl<T> Registry<T> {
112+
pub fn register(&self, id: Id, value: T) {
113+
let old = self.data.write().map.insert(id, value);
114+
assert!(old.is_none());
115+
}
116+
}
117+
110118
#[derive(Default)]
111119
pub struct Hub {
112120
pub(crate) instances: Arc<Registry<InstanceHandle>>,

src/instance.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,35 @@ use crate::{
77
#[cfg(feature = "local")]
88
use crate::{DeviceId, SurfaceId};
99

10+
#[cfg(feature = "remote")]
11+
use serde::{Serialize, Deserialize};
12+
1013
use hal::{self, Instance as _Instance, PhysicalDevice as _PhysicalDevice};
1114

1215

1316
#[repr(C)]
1417
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
18+
#[cfg_attr(feature = "remote", derive(Serialize, Deserialize))]
1519
pub enum PowerPreference {
1620
Default = 0,
1721
LowPower = 1,
1822
HighPerformance = 2,
1923
}
2024

2125
#[repr(C)]
26+
#[cfg_attr(feature = "remote", derive(Clone, Serialize, Deserialize))]
2227
pub struct AdapterDescriptor {
2328
pub power_preference: PowerPreference,
2429
}
2530

2631
#[repr(C)]
32+
#[cfg_attr(feature = "remote", derive(Clone, Serialize, Deserialize))]
2733
pub struct Extensions {
2834
pub anisotropic_filtering: bool,
2935
}
3036

3137
#[repr(C)]
38+
#[cfg_attr(feature = "remote", derive(Clone, Serialize, Deserialize))]
3239
pub struct DeviceDescriptor {
3340
pub extensions: Extensions,
3441
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub use self::pipeline::*;
3939
pub use self::resource::*;
4040
pub use self::swap_chain::*;
4141
#[cfg(not(feature = "local"))]
42-
pub use self::hub::{Id, IdentityManager};
42+
pub use self::hub::{HUB, Id, IdentityManager, Registry};
4343

4444
use std::ptr;
4545
use std::sync::atomic::{AtomicUsize, Ordering};

0 commit comments

Comments
 (0)