Skip to content

Commit dcafcc8

Browse files
committed
Upgrade to a lightly non-standard rust-gpu
1 parent 5e0c936 commit dcafcc8

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

rust-gpu-toy/Cargo.lock

Lines changed: 9 additions & 9 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 = "c4eb7af88ee0baf556cc6b46389a2e71b34919bf", features = [
15+
spirv-builder = { git = "https://github.com/DJMcNab/rust-gpu", rev = "c5bb9ebcf90a6bef3d9f11f79d3d33414f36091f", features = [
1616
"watch",
1717
] }
1818
rust-gpu-toy-shared = { path = "./shared" }

rust-gpu-toy/shaders/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2018"
1010
crate-type = ["dylib"]
1111

1212
[dependencies]
13-
spirv-std = { git = "https://github.com/EmbarkStudios/rust-gpu", rev = "c4eb7af88ee0baf556cc6b46389a2e71b34919bf", features = [
13+
spirv-std = { git = "https://github.com/DJMcNab/rust-gpu", rev = "c5bb9ebcf90a6bef3d9f11f79d3d33414f36091f", features = [
1414
"glam",
1515
] }
1616
rust-gpu-toy-shared = { path = "../shared" }

rust-gpu-toy/shaders/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ use spirv_std::{
1919
#[spirv(compute(threads(16, 16)))]
2020
pub fn main(
2121
#[spirv(push_constant)] config: &Config,
22-
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] output_buffer: &image::Image!(2D, format=rgba8, sampled=false),
22+
#[spirv(descriptor_set = 0, binding = 0, non_readable)] output_buffer: &image::Image!(2D, format=rgba8, sampled=false),
2323
#[spirv(global_invocation_id)] global_ix: UVec3,
2424
) {
25-
asm!();
2625
let frag_coord = global_ix.truncate().as_vec2()
2726
/ vec2(config.width as f32, config.height as f32)
2827
- vec2(0.5, 0.5);

rust-gpu-toy/src/main.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,19 @@ impl State {
315315
fn render_frame(&self) {
316316
let frame = match self.surface.get_current_texture() {
317317
Ok(output) => output,
318-
Err(_) => todo!(),
318+
Err(err) => {
319+
eprintln!("get_current_texture error: {:?}", err);
320+
match err {
321+
wgpu::SurfaceError::Lost => {
322+
self.surface.configure(&self.device, &self.surface_config);
323+
}
324+
wgpu::SurfaceError::OutOfMemory => {
325+
panic!();
326+
}
327+
_ => (),
328+
}
329+
return;
330+
}
319331
};
320332
let frame_view = frame
321333
.texture
@@ -355,6 +367,7 @@ impl State {
355367
rpass.draw(0..3, 0..2);
356368
}
357369
self.queue.submit(Some(encoder.finish()));
370+
frame.present();
358371
}
359372
}
360373

0 commit comments

Comments
 (0)