Skip to content

Commit d855dce

Browse files
committed
⬆ rust-gpu
1 parent 94e6f7b commit d855dce

File tree

3 files changed

+10
-35
lines changed

3 files changed

+10
-35
lines changed

rust-gpu-toy/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust-gpu-toy/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ winit = "0.25"
1212
pollster = "0.2"
1313
async-executor = "1.0"
1414
bytemuck = "1.6.3"
15-
spirv-builder = { git = "https://github.com/EmbarkStudios/rust-gpu", rev = "c3eff4d4a5a52607aa3bc8b4ba8409f6659425ee", features = ["watch"] }
15+
spirv-builder = { git = "https://github.com/EmbarkStudios/rust-gpu", rev = "e66e72b049a88f3ae1f7c54cd6823ae458612952", features = ["watch"] }
1616
rust-gpu-toy-shared = { path = "./shared" }
1717

1818
[workspace]

rust-gpu-toy/src/main.rs

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
//! A simple compute shader example that draws into a window, based on wgpu.
1818
19-
use std::sync::atomic::{AtomicBool, Ordering};
2019
use std::time::Instant;
2120

2221
use rust_gpu_toy_shared::Config;
@@ -393,39 +392,15 @@ async fn run(
393392
}
394393

395394
fn main() {
396-
let (initial_tx, initial_rx) = std::sync::mpsc::sync_channel(0);
397395
let event_loop = EventLoop::with_user_event();
398396
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);
401397
// 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+
429404
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));
431406
}

0 commit comments

Comments
 (0)