@@ -28,7 +28,7 @@ class Metadata;
28
28
namespace hlsl {
29
29
namespace rootsig {
30
30
31
- enum class ErrorKind {
31
+ enum class RSErrorKind {
32
32
Validation,
33
33
AppendAfterUnboundedRange,
34
34
ShaderRegisterOverflow,
@@ -41,124 +41,97 @@ enum class ErrorKind {
41
41
42
42
template <typename T>
43
43
void formatImpl (raw_string_ostream &Buff,
44
- std::integral_constant<ErrorKind, ErrorKind::Validation>,
45
- StringRef ParamName, T Value) {
46
- Buff << " Invalid value for: " << ParamName << " :" << Value;
47
- }
44
+ std::integral_constant<RSErrorKind, RSErrorKind::Validation>,
45
+ StringRef ParamName, T Value);
48
46
49
47
void formatImpl (
50
48
raw_string_ostream &Buff,
51
- std::integral_constant<ErrorKind, ErrorKind::AppendAfterUnboundedRange>,
52
- dxil::ResourceClass Type, uint32_t Register, uint32_t Space) {
53
- Buff << " Range " << getResourceClassName (Type) << " (register=" << Register
54
- << " , space=" << Space << " ) "
55
- << " cannot be appended after an unbounded range " ;
56
- }
49
+ std::integral_constant<RSErrorKind, RSErrorKind::AppendAfterUnboundedRange>,
50
+ dxil::ResourceClass Type, uint32_t Register, uint32_t Space);
57
51
58
52
void formatImpl (
59
53
raw_string_ostream &Buff,
60
- std::integral_constant<ErrorKind, ErrorKind::ShaderRegisterOverflow>,
61
- dxil::ResourceClass Type, uint32_t Register, uint32_t Space) {
62
- Buff << " Overflow for shader register range: " << getResourceClassName (Type)
63
- << " (register=" << Register << " , space=" << Space << " )." ;
64
- }
54
+ std::integral_constant<RSErrorKind, RSErrorKind::ShaderRegisterOverflow>,
55
+ dxil::ResourceClass Type, uint32_t Register, uint32_t Space);
65
56
66
- void formatImpl (raw_string_ostream &Buff,
67
- std::integral_constant<ErrorKind, ErrorKind::OffsetOverflow>,
68
- dxil::ResourceClass Type, uint32_t Register, uint32_t Space) {
69
- Buff << " Offset overflow for descriptor range: " << getResourceClassName (Type)
70
- << " (register=" << Register << " , space=" << Space << " )." ;
71
- }
57
+ void formatImpl (
58
+ raw_string_ostream &Buff,
59
+ std::integral_constant<RSErrorKind, RSErrorKind::OffsetOverflow>,
60
+ dxil::ResourceClass Type, uint32_t Register, uint32_t Space);
72
61
73
62
void formatImpl (raw_string_ostream &Buff,
74
- std::integral_constant<ErrorKind, ErrorKind::SamplerMixin>,
75
- dxil::ResourceClass Type, uint32_t Location) {
76
- Buff << " Samplers cannot be mixed with other "
77
- << " resource types in a descriptor table, " << getResourceClassName (Type)
78
- << " (location=" << Location << " )" ;
79
- }
63
+ std::integral_constant<RSErrorKind, RSErrorKind::SamplerMixin>,
64
+ dxil::ResourceClass Type, uint32_t Location);
80
65
81
66
void formatImpl (
82
67
raw_string_ostream &Buff,
83
- std::integral_constant<ErrorKind, ErrorKind::InvalidMetadataFormat>,
84
- StringRef ElementName) {
85
- Buff << " Invalid format for " << ElementName;
86
- }
68
+ std::integral_constant<RSErrorKind, RSErrorKind::InvalidMetadataFormat>,
69
+ StringRef ElementName);
87
70
88
71
void formatImpl (
89
72
raw_string_ostream &Buff,
90
- std::integral_constant<ErrorKind, ErrorKind::InvalidMetadataValue>,
91
- StringRef ParamName) {
92
- Buff << " Invalid value for " << ParamName;
93
- }
73
+ std::integral_constant<RSErrorKind, RSErrorKind::InvalidMetadataValue>,
74
+ StringRef ParamName);
94
75
95
- void formatImpl (raw_string_ostream &Buff,
96
- std::integral_constant<ErrorKind, ErrorKind::GenericMetadata>,
97
- StringRef Message, MDNode *MD) {
98
- Buff << Message;
99
- if (MD) {
100
- Buff << " \n " ;
101
- MD->printTree (Buff);
102
- }
103
- }
76
+ void formatImpl (
77
+ raw_string_ostream &Buff,
78
+ std::integral_constant<RSErrorKind, RSErrorKind::GenericMetadata>,
79
+ StringRef Message, MDNode *MD);
104
80
105
81
template <typename ... ArgsTs>
106
- static void formatErrMsg (raw_string_ostream &Buff, ErrorKind Kind,
107
- ArgsTs... Args) {
82
+ inline void formatImpl (raw_string_ostream &Buff, RSErrorKind Kind,
83
+ ArgsTs... Args) {
108
84
switch (Kind) {
109
- case ErrorKind::Validation:
110
- formatImpl (Buff, std::integral_constant<ErrorKind, ErrorKind::Validation>{},
111
- Args...);
112
- break ;
113
- case ErrorKind::AppendAfterUnboundedRange:
114
- formatImpl (Buff,
115
- std::integral_constant<ErrorKind,
116
- ErrorKind::AppendAfterUnboundedRange>{},
117
- Args...);
118
- break ;
119
- case ErrorKind::ShaderRegisterOverflow:
120
- formatImpl (
85
+ case RSErrorKind::Validation:
86
+ return formatImpl (
87
+ Buff, std::integral_constant<RSErrorKind, RSErrorKind::Validation>(),
88
+ Args...);
89
+ case RSErrorKind::AppendAfterUnboundedRange:
90
+ return formatImpl (
121
91
Buff,
122
- std::integral_constant<ErrorKind, ErrorKind::ShaderRegisterOverflow>{},
92
+ std::integral_constant<RSErrorKind,
93
+ RSErrorKind::AppendAfterUnboundedRange>(),
123
94
Args...);
124
- break ;
125
- case ErrorKind::OffsetOverflow:
126
- formatImpl (Buff,
127
- std::integral_constant<ErrorKind, ErrorKind::OffsetOverflow>{},
128
- Args...);
129
- break ;
130
- case ErrorKind::SamplerMixin:
131
- formatImpl (Buff,
132
- std::integral_constant<ErrorKind, ErrorKind::SamplerMixin>{},
133
- Args...);
134
- break ;
135
- case ErrorKind::GenericMetadata:
136
- formatImpl (Buff,
137
- std::integral_constant<ErrorKind, ErrorKind::GenericMetadata>{},
138
- Args...);
139
- break ;
140
-
141
- case ErrorKind::InvalidMetadataFormat:
142
- formatImpl (
95
+ case RSErrorKind::ShaderRegisterOverflow:
96
+ return formatImpl (
143
97
Buff,
144
- std::integral_constant<ErrorKind, ErrorKind::InvalidMetadataFormat>{},
98
+ std::integral_constant<RSErrorKind,
99
+ RSErrorKind::ShaderRegisterOverflow>(),
145
100
Args...);
146
- break ;
147
-
148
- case ErrorKind::InvalidMetadataValue:
149
- formatImpl (
101
+ case RSErrorKind::OffsetOverflow:
102
+ return formatImpl (
103
+ Buff,
104
+ std::integral_constant<RSErrorKind, RSErrorKind::OffsetOverflow>(),
105
+ Args...);
106
+ case RSErrorKind::SamplerMixin:
107
+ return formatImpl (
108
+ Buff, std::integral_constant<RSErrorKind, RSErrorKind::SamplerMixin>(),
109
+ Args...);
110
+ case RSErrorKind::InvalidMetadataFormat:
111
+ return formatImpl (
112
+ Buff,
113
+ std::integral_constant<RSErrorKind,
114
+ RSErrorKind::InvalidMetadataFormat>(),
115
+ Args...);
116
+ case RSErrorKind::InvalidMetadataValue:
117
+ return formatImpl (
118
+ Buff,
119
+ std::integral_constant<RSErrorKind,
120
+ RSErrorKind::InvalidMetadataValue>(),
121
+ Args...);
122
+ case RSErrorKind::GenericMetadata:
123
+ return formatImpl (
150
124
Buff,
151
- std::integral_constant<ErrorKind, ErrorKind::InvalidMetadataValue>{} ,
125
+ std::integral_constant<RSErrorKind, RSErrorKind::GenericMetadata>() ,
152
126
Args...);
153
- break ;
154
127
}
155
128
}
156
129
157
130
template <typename ... ArgsTs>
158
- static llvm::Error createRSError (ErrorKind Kind, ArgsTs... Args) {
131
+ static llvm::Error createRSError (RSErrorKind Kind, ArgsTs... Args) {
159
132
std::string Msg;
160
133
raw_string_ostream Buff (Msg);
161
- formatErrMsg (Buff, Kind, Args...);
134
+ formatImpl (Buff, Kind, Args...);
162
135
return createStringError (std::move (Buff.str ()), inconvertibleErrorCode ());
163
136
}
164
137
0 commit comments