Debian Codegraph @

third_party/rust/metal/examples/compute/embedded-lib.rs

raw
1 // Copyright 2017 GFX developers
2 //
3 // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4 // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5 // http://opensource.org/licenses/MIT>, at your option. This file may not be
6 // copied, modified, or distributed except according to those terms.
7
8 use metal::*;
9 use objc::rc::autoreleasepool;
10
11 fn main() {
12 let library_data = include_bytes!("shaders.metallib");
13
14 autoreleasepool(|| {
15 let device = Device::system_default().expect("no device found");
16
17 let library = device.new_library_with_data(&library_data[..]).unwrap();
18 let kernel = library.get_function("sum", None).unwrap();
19
20 println!("Function name: {}", kernel.name());
21 println!("Function type: {:?}", kernel.function_type());
22 println!("OK");
23 });
24 }