@@ -26,13 +26,26 @@ pub enum ShaderError {
2626 /// Shader compilation error.
2727 #[ error( "Shader compilation error: {0}" ) ]
2828 Compilation ( String ) ,
29- #[ cfg( target_os = "ios" ) ]
29+
30+ #[ cfg( any( target_os = "ios" , all( target_arch = "aarch64" , target_os = "macos" ) ) ) ]
3031 /// shaderc error.
3132 #[ error( "shaderc error" ) ]
3233 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 ,
3342}
3443
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+ ) ) ]
3649impl Into < bevy_glsl_to_spirv:: ShaderType > for ShaderStage {
3750 fn into ( self ) -> bevy_glsl_to_spirv:: ShaderType {
3851 match self {
@@ -43,7 +56,11 @@ impl Into<bevy_glsl_to_spirv::ShaderType> for ShaderStage {
4356 }
4457}
4558
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+ ) ) ]
4764pub fn glsl_to_spirv (
4865 glsl_source : & str ,
4966 stage : ShaderStage ,
@@ -53,7 +70,7 @@ pub fn glsl_to_spirv(
5370 . map_err ( ShaderError :: Compilation )
5471}
5572
56- #[ cfg( target_os = "ios" ) ]
73+ #[ cfg( any ( target_os = "ios" , all ( target_arch = "aarch64" , target_os = "macos" ) ) ) ]
5774impl Into < shaderc:: ShaderKind > for ShaderStage {
5875 fn into ( self ) -> shaderc:: ShaderKind {
5976 match self {
@@ -64,14 +81,16 @@ impl Into<shaderc::ShaderKind> for ShaderStage {
6481 }
6582}
6683
67- #[ cfg( target_os = "ios" ) ]
84+ #[ cfg( any ( target_os = "ios" , all ( target_arch = "aarch64" , target_os = "macos" ) ) ) ]
6885pub fn glsl_to_spirv (
6986 glsl_source : & str ,
7087 stage : ShaderStage ,
7188 shader_defs : Option < & [ String ] > ,
7289) -> 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 ) ?;
7594 if let Some ( shader_defs) = shader_defs {
7695 for def in shader_defs. iter ( ) {
7796 options. add_macro_definition ( def, None ) ;
0 commit comments