1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
use crate::empty::RafxFenceEmpty;
#[cfg(feature = "rafx-metal")]
use crate::metal::RafxFenceMetal;
#[cfg(feature = "rafx-vulkan")]
use crate::vulkan::RafxFenceVulkan;
use crate::{RafxFenceStatus, RafxResult};
pub enum RafxFence {
#[cfg(feature = "rafx-vulkan")]
Vk(RafxFenceVulkan),
#[cfg(feature = "rafx-metal")]
Metal(RafxFenceMetal),
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
Empty(RafxFenceEmpty),
}
impl RafxFence {
pub fn get_fence_status(&self) -> RafxResult<RafxFenceStatus> {
match self {
#[cfg(feature = "rafx-vulkan")]
RafxFence::Vk(inner) => inner.get_fence_status(),
#[cfg(feature = "rafx-metal")]
RafxFence::Metal(inner) => inner.get_fence_status(),
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
RafxFence::Empty(inner) => inner.get_fence_status(),
}
}
pub fn wait(&self) -> RafxResult<()> {
match self {
#[cfg(feature = "rafx-vulkan")]
RafxFence::Vk(inner) => inner.wait(),
#[cfg(feature = "rafx-metal")]
RafxFence::Metal(inner) => inner.wait(),
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
RafxFence::Empty(inner) => inner.wait(),
}
}
#[cfg(feature = "rafx-vulkan")]
pub fn vk_fence(&self) -> Option<&RafxFenceVulkan> {
match self {
#[cfg(feature = "rafx-vulkan")]
RafxFence::Vk(inner) => Some(inner),
#[cfg(feature = "rafx-metal")]
RafxFence::Metal(_) => None,
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
RafxFence::Empty(_) => None,
}
}
#[cfg(feature = "rafx-metal")]
pub fn metal_fence(&self) -> Option<&RafxFenceMetal> {
match self {
#[cfg(feature = "rafx-vulkan")]
RafxFence::Vk(_) => None,
#[cfg(feature = "rafx-metal")]
RafxFence::Metal(inner) => Some(inner),
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
RafxFence::Empty(inner) => None,
}
}
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
pub fn empty_fence(&self) -> Option<&RafxFenceEmpty> {
match self {
#[cfg(feature = "rafx-vulkan")]
RafxFence::Vk(_) => None,
#[cfg(feature = "rafx-metal")]
RafxFence::Metal(inner) => None,
#[cfg(any(
feature = "rafx-empty",
not(any(feature = "rafx-metal", feature = "rafx-vulkan"))
))]
RafxFence::Empty(inner) => Some(inner),
}
}
}