Skip to main content

spatialrust_gpu/
device.rs

1use spatialrust_core::{Device, DeviceKind};
2
3/// Marker trait for GPU-capable devices.
4pub trait GpuDevice: Device {}
5
6/// Portable GPU device backed by wgpu.
7#[derive(Clone, Debug, PartialEq, Eq, Hash)]
8pub struct WgpuDevice {
9    label: String,
10}
11
12impl WgpuDevice {
13    /// Creates a labeled wgpu device handle.
14    #[must_use]
15    pub fn new(label: impl Into<String>) -> Self {
16        Self { label: label.into() }
17    }
18
19    /// Returns the device label.
20    #[must_use]
21    pub fn label(&self) -> &str {
22        &self.label
23    }
24}
25
26impl Device for WgpuDevice {
27    fn kind(&self) -> DeviceKind {
28        DeviceKind::Wgpu
29    }
30}
31
32impl GpuDevice for WgpuDevice {}
33
34#[cfg(feature = "gpu-wgpu")]
35mod wgpu_backend {
36    use super::WgpuDevice;
37
38    impl WgpuDevice {
39        /// Creates the default wgpu-backed device placeholder.
40        ///
41        /// Full adapter selection is implemented in later GPU milestones.
42        #[must_use]
43        pub fn default_adapter() -> Self {
44            Self::new("wgpu-default")
45        }
46    }
47}