Skip to main content

mtl_gpu/library/
mod.rs

1//! Metal shader libraries.
2//!
3//! Corresponds to `Metal/MTLLibrary.hpp` and `Metal/MTLFunctionDescriptor.hpp`.
4//!
5//! Libraries contain compiled shader functions.
6
7mod attribute;
8mod compile_options;
9mod dynamic_library;
10mod function;
11mod function_constant;
12mod function_constant_values;
13mod function_descriptor;
14mod function_reflection;
15mod intersection_function_descriptor;
16mod library;
17mod linked_functions;
18mod vertex_attribute;
19
20pub use attribute::Attribute;
21pub use compile_options::CompileOptions;
22pub use dynamic_library::DynamicLibrary;
23pub use function::Function;
24pub use function_constant::FunctionConstant;
25pub use function_constant_values::FunctionConstantValues;
26pub use function_descriptor::FunctionDescriptor;
27pub use function_reflection::FunctionReflection;
28pub use intersection_function_descriptor::IntersectionFunctionDescriptor;
29pub use library::Library;
30pub use linked_functions::LinkedFunctions;
31pub use vertex_attribute::VertexAttribute;
32
33#[cfg(test)]
34mod tests {
35    use super::*;
36    use std::ffi::c_void;
37
38    #[test]
39    fn test_library_size() {
40        assert_eq!(
41            std::mem::size_of::<Library>(),
42            std::mem::size_of::<*mut c_void>()
43        );
44    }
45
46    #[test]
47    fn test_function_size() {
48        assert_eq!(
49            std::mem::size_of::<Function>(),
50            std::mem::size_of::<*mut c_void>()
51        );
52    }
53
54    #[test]
55    fn test_compile_options_creation() {
56        let opts = CompileOptions::new();
57        assert!(opts.is_some());
58    }
59
60    #[test]
61    fn test_function_constant_values_size() {
62        assert_eq!(
63            std::mem::size_of::<FunctionConstantValues>(),
64            std::mem::size_of::<*mut c_void>()
65        );
66    }
67
68    #[test]
69    fn test_linked_functions_size() {
70        assert_eq!(
71            std::mem::size_of::<LinkedFunctions>(),
72            std::mem::size_of::<*mut c_void>()
73        );
74    }
75
76    #[test]
77    fn test_dynamic_library_size() {
78        assert_eq!(
79            std::mem::size_of::<DynamicLibrary>(),
80            std::mem::size_of::<*mut c_void>()
81        );
82    }
83
84    #[test]
85    fn test_vertex_attribute_size() {
86        assert_eq!(
87            std::mem::size_of::<VertexAttribute>(),
88            std::mem::size_of::<*mut c_void>()
89        );
90    }
91
92    #[test]
93    fn test_attribute_size() {
94        assert_eq!(
95            std::mem::size_of::<Attribute>(),
96            std::mem::size_of::<*mut c_void>()
97        );
98    }
99
100    #[test]
101    fn test_function_constant_size() {
102        assert_eq!(
103            std::mem::size_of::<FunctionConstant>(),
104            std::mem::size_of::<*mut c_void>()
105        );
106    }
107
108    #[test]
109    fn test_function_reflection_size() {
110        assert_eq!(
111            std::mem::size_of::<FunctionReflection>(),
112            std::mem::size_of::<*mut c_void>()
113        );
114    }
115
116    #[test]
117    fn test_function_descriptor_size() {
118        assert_eq!(
119            std::mem::size_of::<FunctionDescriptor>(),
120            std::mem::size_of::<*mut c_void>()
121        );
122    }
123
124    #[test]
125    fn test_intersection_function_descriptor_size() {
126        assert_eq!(
127            std::mem::size_of::<IntersectionFunctionDescriptor>(),
128            std::mem::size_of::<*mut c_void>()
129        );
130    }
131}