|
16 | 16 |
|
17 | 17 | //! A simple compute shader example that draws into a window, based on wgpu.
|
18 | 18 |
|
19 |
| -use std::sync::atomic::{AtomicBool, Ordering}; |
20 | 19 | use std::time::Instant;
|
21 | 20 |
|
22 | 21 | use rust_gpu_toy_shared::Config;
|
@@ -393,39 +392,15 @@ async fn run(
|
393 | 392 | }
|
394 | 393 |
|
395 | 394 | fn main() {
|
396 |
| - let (initial_tx, initial_rx) = std::sync::mpsc::sync_channel(0); |
397 | 395 | let event_loop = EventLoop::with_user_event();
|
398 | 396 | let proxy = event_loop.create_proxy();
|
399 |
| - // This is going to be cleaned up significantly by https://github.com/EmbarkStudios/rust-gpu/pull/663 |
400 |
| - let has_sent_first = AtomicBool::new(false); |
401 | 397 | // Watch for changes on a background thread
|
402 |
| - let thread = std::thread::spawn(|| { |
403 |
| - SpirvBuilder::new("./shaders", "spirv-unknown-vulkan1.2") |
404 |
| - .print_metadata(spirv_builder::MetadataPrintout::None) |
405 |
| - .capability(spirv_builder::Capability::StorageImageWriteWithoutFormat) |
406 |
| - .watch(move |result| { |
407 |
| - if let Ok(_) = |
408 |
| - // TODO: This use of atomics is signic |
409 |
| - has_sent_first.compare_exchange( |
410 |
| - false, |
411 |
| - true, |
412 |
| - Ordering::SeqCst, |
413 |
| - Ordering::SeqCst, |
414 |
| - ) |
415 |
| - { |
416 |
| - initial_tx.send(result).unwrap(); |
417 |
| - } else { |
418 |
| - proxy |
419 |
| - .send_event(result) |
420 |
| - .expect("Event loop should still be running"); |
421 |
| - } |
422 |
| - }) |
423 |
| - .expect("Correctly setup") |
424 |
| - }); |
425 |
| - std::mem::forget(thread); |
426 |
| - let initial = initial_rx |
427 |
| - .recv() |
428 |
| - .expect("Watching should get an initial shader"); |
| 398 | + let initial_result = SpirvBuilder::new("./shaders", "spirv-unknown-vulkan1.2") |
| 399 | + .print_metadata(spirv_builder::MetadataPrintout::None) |
| 400 | + .capability(spirv_builder::Capability::StorageImageWriteWithoutFormat) |
| 401 | + .watch(move |result| proxy.send_event(result).unwrap()) |
| 402 | + .expect("Correctly setup"); |
| 403 | + |
429 | 404 | let window = Window::new(&event_loop).unwrap();
|
430 |
| - pollster::block_on(run(event_loop, window, initial)); |
| 405 | + pollster::block_on(run(event_loop, window, initial_result)); |
431 | 406 | }
|
0 commit comments