Skip to content

Commit 83dfa8d

Browse files
committed
Update to newer rust-gpu
1 parent 7b90577 commit 83dfa8d

8 files changed

Lines changed: 48 additions & 44 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ spirv-builder.workspace = true
3232
members = ["shaders", "shared"]
3333

3434
[workspace.dependencies]
35-
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "96fcc9dbe475921997050c25c02a62c7a12d48e0", default-features = false }
36-
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "96fcc9dbe475921997050c25c02a62c7a12d48e0" }
35+
spirv-builder = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "ddb039b9c97e1c9bbed19c6386f4d1dc9230911b", default-features = false }
36+
spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu", rev = "ddb039b9c97e1c9bbed19c6386f4d1dc9230911b" }
3737

3838
# Compile build-dependencies in release mode with
3939
# the same settings as regular dependencies.

build.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use spirv_builder::{MetadataPrintout, SpirvBuilder};
1+
use spirv_builder::{SpirvBuilder, SpirvMetadata};
22
use std::error::Error;
33

44
fn build_shader(path_to_crate: &str) -> Result<(), Box<dyn Error>> {
5-
let builder = SpirvBuilder::new(path_to_crate, "spirv-unknown-vulkan1.2")
6-
.print_metadata(MetadataPrintout::Full);
5+
let mut builder = SpirvBuilder::new(path_to_crate, "spirv-unknown-vulkan1.2")
6+
.spirv_metadata(SpirvMetadata::Full);
7+
builder.build_script.env_shader_spv_path = Some(true);
78

89
let _result = builder.build()?;
910
Ok(())

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2025-06-30"
2+
channel = "nightly-2026-04-02"
33
components = ["rust-src", "rustc-dev", "llvm-tools"]

shaders/src/a_question_of_time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl Inputs {
153153

154154
// drag your mouse to apply circle inversion
155155
if ms.y != -2.0 && ms.w > -2.0 {
156-
uv = inversion(uv, 60.0.to_radians().cos());
156+
uv = inversion(uv, 60.0_f32.to_radians().cos());
157157
ci = ms.xy();
158158
}
159159

shaders/src/atmosphere_system_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl State {
240240

241241
pub fn main_image(&mut self, frag_color: &mut Vec4, frag_coord: Vec2) {
242242
let aspect_ratio: Vec2 = vec2(self.inputs.resolution.x / self.inputs.resolution.y, 1.0);
243-
let fov: f32 = 45.0.to_radians().tan();
243+
let fov: f32 = 45.0_f32.to_radians().tan();
244244
let point_ndc: Vec2 = frag_coord / self.inputs.resolution.xy();
245245
let point_cam: Vec3 = ((2.0 * point_ndc - Vec2::ONE) * aspect_ratio * fov).extend(-1.0);
246246

shared/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Ported to Rust from https://github.com/Tw1ddle/Sky-Shader/blob/master/src/shaders/glsl/sky.fragment
22
33
#![cfg_attr(target_arch = "spirv", no_std)]
4-
#![feature(asm_experimental_arch)]
54

65
use bytemuck::{Pod, Zeroable};
76
use core::f32::consts::PI;

src/main.rs

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use futures::executor::block_on;
22
use ouroboros::self_referencing;
3+
use shared::ShaderConstants;
34
use std::error::Error;
45
use std::time::Instant;
56
use wgpu::{self, InstanceDescriptor};
@@ -10,7 +11,6 @@ use winit::event::{ElementState, MouseButton, WindowEvent};
1011
use winit::event_loop::{ActiveEventLoop, ControlFlow, EventLoop};
1112
use winit::keyboard::NamedKey;
1213
use winit::window::{Window, WindowAttributes, WindowId};
13-
use shared::ShaderConstants;
1414

1515
#[self_referencing]
1616
struct WindowSurface {
@@ -110,7 +110,10 @@ impl ShaderToyApp {
110110
const MAX_PUSH_CONSTANT_SIZE: u32 = {
111111
let v = size_of::<ShaderConstants>();
112112
// Not sure if this is portable on Metal or DX12 in the first place...
113-
assert!(v <= 128, "Push constant larger than the minimum that Vulkan requires, may not be portable!");
113+
assert!(
114+
v <= 128,
115+
"Push constant larger than the minimum that Vulkan requires, may not be portable!"
116+
);
114117
v as u32
115118
};
116119
let required_limits = wgpu::Limits {
@@ -302,26 +305,32 @@ impl ApplicationHandler for ShaderToyApp {
302305
self.drag_end_y = self.cursor_y;
303306
}
304307
}
305-
WindowEvent::MouseInput { state, button, .. } => {
306-
if button == MouseButton::Left {
307-
self.mouse_left_pressed = state == ElementState::Pressed;
308-
if self.mouse_left_pressed {
309-
self.drag_start_x = self.cursor_x;
310-
self.drag_start_y = self.cursor_y;
311-
self.drag_end_x = self.cursor_x;
312-
self.drag_end_y = self.cursor_y;
313-
self.mouse_left_clicked = true;
314-
}
308+
WindowEvent::MouseInput {
309+
state,
310+
button: MouseButton::Left,
311+
..
312+
} => {
313+
self.mouse_left_pressed = state == ElementState::Pressed;
314+
if self.mouse_left_pressed {
315+
self.drag_start_x = self.cursor_x;
316+
self.drag_start_y = self.cursor_y;
317+
self.drag_end_x = self.cursor_x;
318+
self.drag_end_y = self.cursor_y;
319+
self.mouse_left_clicked = true;
315320
}
316321
}
317-
WindowEvent::MouseWheel { delta: winit::event::MouseScrollDelta::LineDelta(x, y), .. } => {
322+
WindowEvent::MouseWheel {
323+
delta: winit::event::MouseScrollDelta::LineDelta(x, y),
324+
..
325+
} => {
318326
self.drag_end_x = x * 0.1;
319327
self.drag_end_y = y * 0.1;
320328
}
321-
WindowEvent::KeyboardInput { event, .. } => {
322-
if event.logical_key == NamedKey::Escape && event.state == ElementState::Pressed {
323-
self.close_requested = true;
324-
}
329+
WindowEvent::KeyboardInput { event, .. }
330+
if event.logical_key == NamedKey::Escape
331+
&& event.state == ElementState::Pressed =>
332+
{
333+
self.close_requested = true;
325334
}
326335
WindowEvent::RedrawRequested => self.render(),
327336
_ => {}

0 commit comments

Comments
 (0)