librashader_runtime_mtl/
lib.rs

1//! librashader Metal runtime
2//!
3//! This crate should not be used directly.
4//! See [`librashader::runtime::mtl`](https://docs.rs/librashader/latest/aarch64-apple-darwin/librashader/runtime/mtl/index.html) instead.
5
6#![cfg(target_vendor = "apple")]
7#![cfg_attr(not(feature = "stable"), feature(type_alias_impl_trait))]
8
9mod buffer;
10mod draw_quad;
11mod filter_chain;
12mod filter_pass;
13mod graphics_pipeline;
14mod luts;
15mod samplers;
16mod texture;
17
18pub use filter_chain::FilterChainMetal;
19use objc2_metal::MTLPixelFormat;
20
21pub mod error;
22pub mod options;
23use librashader_runtime::impl_filter_chain_parameters;
24impl_filter_chain_parameters!(FilterChainMetal);
25
26pub use texture::MetalTextureRef;
27
28fn select_optimal_pixel_format(format: MTLPixelFormat) -> MTLPixelFormat {
29    if format == MTLPixelFormat::RGBA8Unorm {
30        return MTLPixelFormat::BGRA8Unorm;
31    }
32
33    if format == MTLPixelFormat::RGBA8Unorm_sRGB {
34        return MTLPixelFormat::BGRA8Unorm_sRGB;
35    }
36    format
37}