1
+ use alloc:: borrow:: Cow ;
1
2
use alloc:: {
2
3
format,
3
4
string:: { String , ToString } ,
4
5
} ;
5
-
6
6
use codespan_reporting:: diagnostic:: Diagnostic ;
7
7
use codespan_reporting:: files:: SimpleFile ;
8
8
use codespan_reporting:: term;
@@ -14,6 +14,8 @@ use crate::{
14
14
front:: atomic_upgrade,
15
15
} ;
16
16
17
+ use crate :: proc:: ConstantEvaluatorError ;
18
+
17
19
#[ derive( Clone , Debug , thiserror:: Error ) ]
18
20
pub enum Error {
19
21
#[ error( "invalid header" ) ]
@@ -30,6 +32,8 @@ pub enum Error {
30
32
UnsupportedSpecConstantOp ( spirv:: Op ) ,
31
33
#[ error( "invalid opcode in specialization constant operation {0:?}" ) ]
32
34
InvalidSpecConstantOp ( spirv:: Op ) ,
35
+ #[ error( "{0}" ) ]
36
+ SemanticError ( Cow < ' static , str > ) ,
33
37
#[ error( "unsupported capability {0:?}" ) ]
34
38
UnsupportedCapability ( spirv:: Capability ) ,
35
39
#[ error( "unsupported extension {0}" ) ]
@@ -155,11 +159,16 @@ pub enum Error {
155
159
NonBindingArrayOfImageOrSamplers ,
156
160
#[ error( "naga only supports specialization constant IDs up to 65535 but was given {0}" ) ]
157
161
SpecIdTooHigh ( u32 ) ,
158
-
159
162
#[ error( "atomic upgrade error: {0}" ) ]
160
163
AtomicUpgradeError ( atomic_upgrade:: Error ) ,
161
164
}
162
165
166
+ impl From < ConstantEvaluatorError > for Error {
167
+ fn from ( err : ConstantEvaluatorError ) -> Self {
168
+ Error :: SemanticError ( err. to_string ( ) . into ( ) )
169
+ }
170
+ }
171
+
163
172
impl Error {
164
173
pub fn emit_to_writer ( & self , writer : & mut impl ErrorWrite , source : & str ) {
165
174
self . emit_to_writer_with_path ( writer, source, "glsl" ) ;
0 commit comments