@@ -26,13 +26,26 @@ pub enum ShaderError {
26
26
/// Shader compilation error.
27
27
#[ error( "Shader compilation error: {0}" ) ]
28
28
Compilation ( String ) ,
29
- #[ cfg( target_os = "ios" ) ]
29
+
30
+ #[ cfg( any( target_os = "ios" , all( target_arch = "aarch64" , target_os = "macos" ) ) ) ]
30
31
/// shaderc error.
31
32
#[ error( "shaderc error" ) ]
32
33
ShaderC ( #[ from] shaderc:: Error ) ,
34
+
35
+ #[ cfg( any( target_os = "ios" , all( target_arch = "aarch64" , target_os = "macos" ) ) ) ]
36
+ #[ error( "Error initializing shaderc Compiler" ) ]
37
+ ErrorInitializingShadercCompiler ,
38
+
39
+ #[ cfg( any( target_os = "ios" , all( target_arch = "aarch64" , target_os = "macos" ) ) ) ]
40
+ #[ error( "Error initializing shaderc CompileOptions" ) ]
41
+ ErrorInitializingShadercCompileOptions ,
33
42
}
34
43
35
- #[ cfg( all( not( target_os = "ios" ) , not( target_arch = "wasm32" ) ) ) ]
44
+ #[ cfg( all(
45
+ not( target_os = "ios" ) ,
46
+ not( target_arch = "wasm32" ) ,
47
+ not( all( target_arch = "aarch64" , target_os = "macos" ) )
48
+ ) ) ]
36
49
impl Into < bevy_glsl_to_spirv:: ShaderType > for ShaderStage {
37
50
fn into ( self ) -> bevy_glsl_to_spirv:: ShaderType {
38
51
match self {
@@ -43,7 +56,11 @@ impl Into<bevy_glsl_to_spirv::ShaderType> for ShaderStage {
43
56
}
44
57
}
45
58
46
- #[ cfg( all( not( target_os = "ios" ) , not( target_arch = "wasm32" ) ) ) ]
59
+ #[ cfg( all(
60
+ not( target_os = "ios" ) ,
61
+ not( target_arch = "wasm32" ) ,
62
+ not( all( target_arch = "aarch64" , target_os = "macos" ) )
63
+ ) ) ]
47
64
pub fn glsl_to_spirv (
48
65
glsl_source : & str ,
49
66
stage : ShaderStage ,
@@ -53,7 +70,7 @@ pub fn glsl_to_spirv(
53
70
. map_err ( ShaderError :: Compilation )
54
71
}
55
72
56
- #[ cfg( target_os = "ios" ) ]
73
+ #[ cfg( any ( target_os = "ios" , all ( target_arch = "aarch64" , target_os = "macos" ) ) ) ]
57
74
impl Into < shaderc:: ShaderKind > for ShaderStage {
58
75
fn into ( self ) -> shaderc:: ShaderKind {
59
76
match self {
@@ -64,14 +81,16 @@ impl Into<shaderc::ShaderKind> for ShaderStage {
64
81
}
65
82
}
66
83
67
- #[ cfg( target_os = "ios" ) ]
84
+ #[ cfg( any ( target_os = "ios" , all ( target_arch = "aarch64" , target_os = "macos" ) ) ) ]
68
85
pub fn glsl_to_spirv (
69
86
glsl_source : & str ,
70
87
stage : ShaderStage ,
71
88
shader_defs : Option < & [ String ] > ,
72
89
) -> Result < Vec < u32 > , ShaderError > {
73
- let mut compiler = shaderc:: Compiler :: new ( ) ?;
74
- let mut options = shaderc:: CompileOptions :: new ( ) ?;
90
+ let mut compiler =
91
+ shaderc:: Compiler :: new ( ) . ok_or ( ShaderError :: ErrorInitializingShadercCompiler ) ?;
92
+ let mut options = shaderc:: CompileOptions :: new ( )
93
+ . ok_or ( ShaderError :: ErrorInitializingShadercCompileOptions ) ?;
75
94
if let Some ( shader_defs) = shader_defs {
76
95
for def in shader_defs. iter ( ) {
77
96
options. add_macro_definition ( def, None ) ;
0 commit comments