1#[cfg(feature = "rafx-dx12")]
2use crate::dx12::RafxRootSignatureDx12;
3#[cfg(any(
4 feature = "rafx-empty",
5 not(any(
6 feature = "rafx-dx12",
7 feature = "rafx-metal",
8 feature = "rafx-vulkan",
9 feature = "rafx-gles2",
10 feature = "rafx-gles3"
11 ))
12))]
13use crate::empty::RafxRootSignatureEmpty;
14#[cfg(feature = "rafx-gles2")]
15use crate::gles2::RafxRootSignatureGles2;
16#[cfg(feature = "rafx-gles3")]
17use crate::gles3::RafxRootSignatureGles3;
18#[cfg(feature = "rafx-metal")]
19use crate::metal::RafxRootSignatureMetal;
20#[cfg(feature = "rafx-vulkan")]
21use crate::vulkan::RafxRootSignatureVulkan;
22use crate::{RafxDescriptorIndex, RafxPipelineType, RafxShaderStageFlags};
23
24#[derive(Clone, Debug)]
29pub enum RafxRootSignature {
30 #[cfg(feature = "rafx-dx12")]
31 Dx12(RafxRootSignatureDx12),
32 #[cfg(feature = "rafx-vulkan")]
33 Vk(RafxRootSignatureVulkan),
34 #[cfg(feature = "rafx-metal")]
35 Metal(RafxRootSignatureMetal),
36 #[cfg(feature = "rafx-gles2")]
37 Gles2(RafxRootSignatureGles2),
38 #[cfg(feature = "rafx-gles3")]
39 Gles3(RafxRootSignatureGles3),
40 #[cfg(any(
41 feature = "rafx-empty",
42 not(any(
43 feature = "rafx-dx12",
44 feature = "rafx-metal",
45 feature = "rafx-vulkan",
46 feature = "rafx-gles2",
47 feature = "rafx-gles3"
48 ))
49 ))]
50 Empty(RafxRootSignatureEmpty),
51}
52
53impl RafxRootSignature {
54 pub fn pipeline_type(&self) -> RafxPipelineType {
56 match self {
57 #[cfg(feature = "rafx-dx12")]
58 RafxRootSignature::Dx12(inner) => inner.pipeline_type(),
59 #[cfg(feature = "rafx-vulkan")]
60 RafxRootSignature::Vk(inner) => inner.pipeline_type(),
61 #[cfg(feature = "rafx-metal")]
62 RafxRootSignature::Metal(inner) => inner.pipeline_type(),
63 #[cfg(feature = "rafx-gles2")]
64 RafxRootSignature::Gles2(inner) => inner.pipeline_type(),
65 #[cfg(feature = "rafx-gles3")]
66 RafxRootSignature::Gles3(inner) => inner.pipeline_type(),
67 #[cfg(any(
68 feature = "rafx-empty",
69 not(any(
70 feature = "rafx-dx12",
71 feature = "rafx-metal",
72 feature = "rafx-vulkan",
73 feature = "rafx-gles2",
74 feature = "rafx-gles3"
75 ))
76 ))]
77 RafxRootSignature::Empty(inner) => inner.pipeline_type(),
78 }
79 }
80
81 pub fn find_descriptor_by_name(
82 &self,
83 name: &str,
84 ) -> Option<RafxDescriptorIndex> {
85 match self {
86 #[cfg(feature = "rafx-dx12")]
87 RafxRootSignature::Dx12(inner) => inner.find_descriptor_by_name(name),
88 #[cfg(feature = "rafx-vulkan")]
89 RafxRootSignature::Vk(inner) => inner.find_descriptor_by_name(name),
90 #[cfg(feature = "rafx-metal")]
91 RafxRootSignature::Metal(inner) => inner.find_descriptor_by_name(name),
92 #[cfg(feature = "rafx-gles2")]
93 RafxRootSignature::Gles2(inner) => inner.find_descriptor_by_name(name),
94 #[cfg(feature = "rafx-gles3")]
95 RafxRootSignature::Gles3(inner) => inner.find_descriptor_by_name(name),
96 #[cfg(any(
97 feature = "rafx-empty",
98 not(any(
99 feature = "rafx-dx12",
100 feature = "rafx-metal",
101 feature = "rafx-vulkan",
102 feature = "rafx-gles2",
103 feature = "rafx-gles3"
104 ))
105 ))]
106 RafxRootSignature::Empty(inner) => inner.find_descriptor_by_name(name),
107 }
108 }
109
110 pub fn find_descriptor_by_binding(
111 &self,
112 set_index: u32,
113 binding: u32,
114 ) -> Option<RafxDescriptorIndex> {
115 match self {
116 #[cfg(feature = "rafx-dx12")]
117 RafxRootSignature::Dx12(inner) => inner.find_descriptor_by_binding(set_index, binding),
118 #[cfg(feature = "rafx-vulkan")]
119 RafxRootSignature::Vk(inner) => inner.find_descriptor_by_binding(set_index, binding),
120 #[cfg(feature = "rafx-metal")]
121 RafxRootSignature::Metal(inner) => inner.find_descriptor_by_binding(set_index, binding),
122 #[cfg(feature = "rafx-gles2")]
123 RafxRootSignature::Gles2(inner) => inner.find_descriptor_by_binding(set_index, binding),
124 #[cfg(feature = "rafx-gles3")]
125 RafxRootSignature::Gles3(inner) => inner.find_descriptor_by_binding(set_index, binding),
126 #[cfg(any(
127 feature = "rafx-empty",
128 not(any(
129 feature = "rafx-dx12",
130 feature = "rafx-metal",
131 feature = "rafx-vulkan",
132 feature = "rafx-gles2",
133 feature = "rafx-gles3"
134 ))
135 ))]
136 RafxRootSignature::Empty(inner) => inner.find_descriptor_by_binding(set_index, binding),
137 }
138 }
139
140 pub fn find_push_constant_descriptor(
141 &self,
142 stage: RafxShaderStageFlags,
143 ) -> Option<RafxDescriptorIndex> {
144 match self {
145 #[cfg(feature = "rafx-dx12")]
146 RafxRootSignature::Dx12(inner) => inner.find_push_constant_descriptor(stage),
147 #[cfg(feature = "rafx-vulkan")]
148 RafxRootSignature::Vk(inner) => inner.find_push_constant_descriptor(stage),
149 #[cfg(feature = "rafx-metal")]
150 RafxRootSignature::Metal(inner) => inner.find_push_constant_descriptor(stage),
151 #[cfg(feature = "rafx-gles2")]
152 RafxRootSignature::Gles2(_inner) => {
153 let _ = stage;
154 unimplemented!()
155 }
156 #[cfg(feature = "rafx-gles3")]
157 RafxRootSignature::Gles3(_inner) => {
158 let _ = stage;
159 unimplemented!()
160 }
161 #[cfg(any(
162 feature = "rafx-empty",
163 not(any(
164 feature = "rafx-dx12",
165 feature = "rafx-metal",
166 feature = "rafx-vulkan",
167 feature = "rafx-gles2",
168 feature = "rafx-gles3"
169 ))
170 ))]
171 RafxRootSignature::Empty(inner) => inner.find_push_constant_descriptor(stage),
172 }
173 }
174
175 #[cfg(feature = "rafx-dx12")]
178 pub fn dx12_root_signature(&self) -> Option<&RafxRootSignatureDx12> {
179 match self {
180 #[cfg(feature = "rafx-dx12")]
181 RafxRootSignature::Dx12(inner) => Some(inner),
182 #[cfg(feature = "rafx-vulkan")]
183 RafxRootSignature::Vk(_) => None,
184 #[cfg(feature = "rafx-metal")]
185 RafxRootSignature::Metal(_) => None,
186 #[cfg(feature = "rafx-gles2")]
187 RafxRootSignature::Gles2(_) => None,
188 #[cfg(feature = "rafx-gles3")]
189 RafxRootSignature::Gles3(_) => None,
190 #[cfg(any(
191 feature = "rafx-empty",
192 not(any(
193 feature = "rafx-dx12",
194 feature = "rafx-metal",
195 feature = "rafx-vulkan",
196 feature = "rafx-gles2",
197 feature = "rafx-gles3"
198 ))
199 ))]
200 RafxRootSignature::Empty(_) => None,
201 }
202 }
203
204 #[cfg(feature = "rafx-vulkan")]
207 pub fn vk_root_signature(&self) -> Option<&RafxRootSignatureVulkan> {
208 match self {
209 #[cfg(feature = "rafx-dx12")]
210 RafxRootSignature::Dx12(_) => None,
211 #[cfg(feature = "rafx-vulkan")]
212 RafxRootSignature::Vk(inner) => Some(inner),
213 #[cfg(feature = "rafx-metal")]
214 RafxRootSignature::Metal(_) => None,
215 #[cfg(feature = "rafx-gles2")]
216 RafxRootSignature::Gles2(_) => None,
217 #[cfg(feature = "rafx-gles3")]
218 RafxRootSignature::Gles3(_) => None,
219 #[cfg(any(
220 feature = "rafx-empty",
221 not(any(
222 feature = "rafx-dx12",
223 feature = "rafx-metal",
224 feature = "rafx-vulkan",
225 feature = "rafx-gles2",
226 feature = "rafx-gles3"
227 ))
228 ))]
229 RafxRootSignature::Empty(_) => None,
230 }
231 }
232
233 #[cfg(feature = "rafx-metal")]
236 pub fn metal_root_signature(&self) -> Option<&RafxRootSignatureMetal> {
237 match self {
238 #[cfg(feature = "rafx-dx12")]
239 RafxRootSignature::Dx12(_) => None,
240 #[cfg(feature = "rafx-vulkan")]
241 RafxRootSignature::Vk(_) => None,
242 #[cfg(feature = "rafx-metal")]
243 RafxRootSignature::Metal(inner) => Some(inner),
244 #[cfg(feature = "rafx-gles2")]
245 RafxRootSignature::Gles2(_) => None,
246 #[cfg(feature = "rafx-gles3")]
247 RafxRootSignature::Gles3(_) => None,
248 #[cfg(any(
249 feature = "rafx-empty",
250 not(any(
251 feature = "rafx-dx12",
252 feature = "rafx-metal",
253 feature = "rafx-vulkan",
254 feature = "rafx-gles2",
255 feature = "rafx-gles3"
256 ))
257 ))]
258 RafxRootSignature::Empty(_) => None,
259 }
260 }
261
262 #[cfg(feature = "rafx-gles2")]
265 pub fn gles2_root_signature(&self) -> Option<&RafxRootSignatureGles2> {
266 match self {
267 #[cfg(feature = "rafx-dx12")]
268 RafxRootSignature::Dx12(_) => None,
269 #[cfg(feature = "rafx-vulkan")]
270 RafxRootSignature::Vk(_) => None,
271 #[cfg(feature = "rafx-metal")]
272 RafxRootSignature::Metal(_) => None,
273 #[cfg(feature = "rafx-gles2")]
274 RafxRootSignature::Gles2(inner) => Some(inner),
275 #[cfg(feature = "rafx-gles3")]
276 RafxRootSignature::Gles3(_) => None,
277 #[cfg(any(
278 feature = "rafx-empty",
279 not(any(
280 feature = "rafx-dx12",
281 feature = "rafx-metal",
282 feature = "rafx-vulkan",
283 feature = "rafx-gles2",
284 feature = "rafx-gles3"
285 ))
286 ))]
287 RafxRootSignature::Empty(_) => None,
288 }
289 }
290
291 #[cfg(feature = "rafx-gles3")]
294 pub fn gles3_root_signature(&self) -> Option<&RafxRootSignatureGles3> {
295 match self {
296 #[cfg(feature = "rafx-dx12")]
297 RafxRootSignature::Dx12(_) => None,
298 #[cfg(feature = "rafx-vulkan")]
299 RafxRootSignature::Vk(_) => None,
300 #[cfg(feature = "rafx-metal")]
301 RafxRootSignature::Metal(_) => None,
302 #[cfg(feature = "rafx-gles2")]
303 RafxRootSignature::Gles2(_) => None,
304 #[cfg(feature = "rafx-gles3")]
305 RafxRootSignature::Gles3(inner) => Some(inner),
306 #[cfg(any(
307 feature = "rafx-empty",
308 not(any(
309 feature = "rafx-dx12",
310 feature = "rafx-metal",
311 feature = "rafx-vulkan",
312 feature = "rafx-gles2",
313 feature = "rafx-gles3"
314 ))
315 ))]
316 RafxRootSignature::Empty(_) => None,
317 }
318 }
319
320 #[cfg(any(
323 feature = "rafx-empty",
324 not(any(
325 feature = "rafx-dx12",
326 feature = "rafx-metal",
327 feature = "rafx-vulkan",
328 feature = "rafx-gles2",
329 feature = "rafx-gles3"
330 ))
331 ))]
332 pub fn empty_root_signature(&self) -> Option<&RafxRootSignatureEmpty> {
333 match self {
334 #[cfg(feature = "rafx-dx12")]
335 RafxRootSignature::Dx12(_) => None,
336 #[cfg(feature = "rafx-vulkan")]
337 RafxRootSignature::Vk(_) => None,
338 #[cfg(feature = "rafx-metal")]
339 RafxRootSignature::Metal(_) => None,
340 #[cfg(feature = "rafx-gles2")]
341 RafxRootSignature::Gles2(_) => None,
342 #[cfg(feature = "rafx-gles3")]
343 RafxRootSignature::Gles3(_) => None,
344 #[cfg(any(
345 feature = "rafx-empty",
346 not(any(
347 feature = "rafx-dx12",
348 feature = "rafx-metal",
349 feature = "rafx-vulkan",
350 feature = "rafx-gles2",
351 feature = "rafx-gles3"
352 ))
353 ))]
354 RafxRootSignature::Empty(inner) => Some(inner),
355 }
356 }
357}