1
2use serde::{Serialize, Deserialize, };
3
4#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
5pub enum Platform {
6 Unix,
7 Windows,
8
9 Hsa(self::hsa::Device),
10 Cuda,
12 Vulkan(self::vk::ExeModel),
13}
14
15pub mod hsa {
16 use serde::{Serialize, Deserialize, };
17 use std::str::FromStr;
18
19 #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
22 pub enum AmdGpu {
23 Gfx801,
27 Carrizo,
28 Gfx802,
29 Iceland,
30 Tonga,
31 Gfx803,
32 Fiji,
33 Polaris10,
34 Polaris11,
35 Gfx810,
36 Stoney,
37
38 Gfx900,
43 Gfx902,
44 Gfx904,
45 Gfx906,
46 Gfx909,
47 }
48 impl FromStr for AmdGpu {
49 type Err = ();
50 fn from_str(s: &str) -> Result<Self, ()> {
51 use self::AmdGpu::*;
52
53 let v = match s {
54 "gfx801" => Gfx801,
55 "carrizo" => Carrizo,
56 "gfx802" => Gfx802,
57 "iceland" => Iceland,
58 "tonga" => Tonga,
59 "gfx803" => Gfx803,
60 "fiji" => Fiji,
61 "polaris10" => Polaris10,
62 "polaris11" => Polaris11,
63 "gfx810" => Gfx810,
64 "stoney" => Stoney,
65
66 "gfx900" => Gfx900,
67 "gfx902" => Gfx902,
68 "gfx904" => Gfx904,
69 "gfx906" => Gfx906,
70 "gfx909" => Gfx909,
71
72 _ => { return Err(()); },
73 };
74
75 Ok(v)
76 }
77 }
78
79 #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
80 pub enum Device {
81 AmdGcn(AmdGpu)
82 }
83}
84pub mod vk {
85 use std::str::FromStr;
86
87 use serde::{Serialize, Deserialize, };
88
89 #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
90 #[repr(u32)]
91 pub enum ExeModel {
92 Vertex,
93 TessellationControl,
94 TessellationEval,
95 Geometry,
96 Fragment,
97 GLCompute,
98 Kernel,
100 }
101 impl FromStr for ExeModel {
102 type Err = ();
103 fn from_str(s: &str) -> Result<Self, ()> {
104 let r = match s {
105 "Vertex" => ExeModel::Vertex,
106 "TessellationControl" => ExeModel::TessellationControl,
107 "TessellationEval" => ExeModel::TessellationEval,
108 "Geometry" => ExeModel::Geometry,
109 "Fragment" => ExeModel::Fragment,
110 "GLCompute" => ExeModel::GLCompute,
111 "Kernel" => ExeModel::Kernel,
112 _ => { return Err(()); },
113 };
114
115 Ok(r)
116 }
117 }
118}
119
120#[cfg(unix)]
121#[inline(always)]
122pub const fn host_platform() -> Platform {
123 Platform::Unix
124}
125#[cfg(windows)]
126#[inline(always)]
127pub const fn host_platform() -> Platform {
128 Platform::Windows
129}