Debian Codegraph @

third_party/rust/metal/examples/fence/main.rs

raw
1 // Copyright 2020 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
10 fn main() {
11 let device = Device::system_default().expect("No device found");
12
13 let command_queue = device.new_command_queue();
14 let command_buffer = command_queue.new_command_buffer();
15
16 let fence = device.new_fence();
17
18 let blit_encoder = command_buffer.new_blit_command_encoder();
19 blit_encoder.update_fence(&fence);
20 blit_encoder.end_encoding();
21
22 let compute_encoder = command_buffer.new_compute_command_encoder();
23 compute_encoder.wait_for_fence(&fence);
24 compute_encoder.end_encoding();
25
26 command_buffer.commit();
27 command_buffer.wait_until_completed();
28
29 println!("Done");
30 }