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
use crate::queue::QueueType;
#[derive(Debug)]
pub enum General {}
#[derive(Debug)]
pub enum Graphics {}
#[derive(Debug)]
pub enum Compute {}
#[derive(Debug)]
pub enum Transfer {}
#[derive(Debug)]
pub enum GraphicsOrCompute {}
pub trait Capability {
fn supported_by(qt: QueueType) -> bool;
}
impl Capability for General {
fn supported_by(qt: QueueType) -> bool {
match qt {
QueueType::General => true,
_ => false,
}
}
}
impl Capability for Graphics {
fn supported_by(qt: QueueType) -> bool {
match qt {
QueueType::General | QueueType::Graphics => true,
_ => false,
}
}
}
impl Capability for Compute {
fn supported_by(qt: QueueType) -> bool {
match qt {
QueueType::General | QueueType::Compute => true,
_ => false,
}
}
}
impl Capability for Transfer {
fn supported_by(qt: QueueType) -> bool {
match qt {
QueueType::General | QueueType::Compute | QueueType::Graphics | QueueType::Transfer => {
true
}
}
}
}
pub trait Supports<T> {}
impl<T> Supports<T> for T {}
impl Supports<Graphics> for General {}
impl Supports<Compute> for General {}
impl Supports<Transfer> for General {}
impl Supports<Transfer> for Graphics {}
impl Supports<Transfer> for Compute {}
impl Supports<GraphicsOrCompute> for General {}
impl Supports<GraphicsOrCompute> for Graphics {}
impl Supports<GraphicsOrCompute> for Compute {}
pub trait Upper {
type Result;
}
impl<T> Upper for (T, T) {
type Result = T;
}
impl Upper for (General, Graphics) {
type Result = General;
}
impl Upper for (General, Compute) {
type Result = General;
}
impl Upper for (General, Transfer) {
type Result = General;
}
impl Upper for (Graphics, General) {
type Result = General;
}
impl Upper for (Graphics, Compute) {
type Result = General;
}
impl Upper for (Graphics, Transfer) {
type Result = Graphics;
}
impl Upper for (Compute, General) {
type Result = General;
}
impl Upper for (Compute, Graphics) {
type Result = General;
}
impl Upper for (Compute, Transfer) {
type Result = Compute;
}
impl Upper for (Transfer, General) {
type Result = General;
}
impl Upper for (Transfer, Graphics) {
type Result = Graphics;
}
impl Upper for (Transfer, Compute) {
type Result = Compute;
}