Skip to content

Commit 234f67c

Browse files
committed
Run cargo fmt
1 parent ac45bf9 commit 234f67c

File tree

140 files changed

+1869
-1209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+1869
-1209
lines changed

shaders/rust/base/textoverlay/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#![cfg_attr(target_arch = "spirv", no_std)]
22
#![allow(clippy::missing_safety_doc)]
33

4-
use spirv_std::{spirv, glam::{vec4, Vec2, Vec4}, Image};
54
use spirv_std::image::SampledImage;
5+
use spirv_std::{
6+
glam::{vec4, Vec2, Vec4},
7+
spirv, Image,
8+
};
69

710
// Text overlay vertex shader - simple passthrough with position transformation
811
#[spirv(vertex)]
@@ -20,9 +23,11 @@ pub fn main_vs(
2023
#[spirv(fragment)]
2124
pub fn main_fs(
2225
in_uv: Vec2,
23-
#[spirv(descriptor_set = 0, binding = 0)] font_sampler: &SampledImage<Image!(2D, type=f32, sampled)>,
26+
#[spirv(descriptor_set = 0, binding = 0)] font_sampler: &SampledImage<
27+
Image!(2D, type=f32, sampled),
28+
>,
2429
out_frag_color: &mut Vec4,
2530
) {
2631
let color = font_sampler.sample(in_uv).x; // Sample red channel like GLSL .r
2732
*out_frag_color = vec4(color, color, color, 1.0); // Convert to grayscale with full alpha
28-
}
33+
}

shaders/rust/base/uioverlay/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#![cfg_attr(target_arch = "spirv", no_std)]
22
#![allow(clippy::missing_safety_doc)]
33

4-
use spirv_std::{spirv, glam::{vec4, Vec2, Vec4}, Image};
54
use spirv_std::image::SampledImage;
5+
use spirv_std::{
6+
glam::{vec4, Vec2, Vec4},
7+
spirv, Image,
8+
};
69

710
// Push constants structure for UI overlay
811
#[repr(C)]
@@ -38,9 +41,11 @@ pub fn main_vs(
3841
pub fn main_fs(
3942
in_uv: Vec2,
4043
in_color: Vec4,
41-
#[spirv(descriptor_set = 0, binding = 0)] font_sampler: &SampledImage<Image!(2D, type=f32, sampled)>,
44+
#[spirv(descriptor_set = 0, binding = 0)] font_sampler: &SampledImage<
45+
Image!(2D, type=f32, sampled),
46+
>,
4247
out_frag_color: &mut Vec4,
4348
) {
4449
let tex_color = font_sampler.sample(in_uv);
4550
*out_frag_color = in_color * tex_color;
46-
}
51+
}

shaders/rust/bloom/colorpass/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ pub fn main_vs(
2929
}
3030

3131
#[spirv(fragment)]
32-
pub fn main_fs(
33-
in_color: Vec3,
34-
_in_uv: Vec2,
35-
out_frag_color: &mut Vec4,
36-
) {
32+
pub fn main_fs(in_color: Vec3, _in_uv: Vec2, out_frag_color: &mut Vec4) {
3733
*out_frag_color = Vec4::new(in_color.x, in_color.y, in_color.z, 1.0);
38-
}
34+
}
Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#![cfg_attr(target_arch = "spirv", no_std)]
22

3+
use spirv_std::image::SampledImage;
34
use spirv_std::{
45
glam::{vec2, UVec2, Vec2, Vec4},
56
spirv, Image,
67
};
7-
use spirv_std::image::SampledImage;
88

99
#[repr(C)]
1010
#[derive(Copy, Clone)]
@@ -13,24 +13,22 @@ pub struct UBO {
1313
pub blur_strength: f32,
1414
}
1515

16-
1716
#[spirv(vertex)]
1817
pub fn main_vs(
1918
#[spirv(vertex_index)] vertex_index: i32,
2019
#[spirv(position)] out_position: &mut Vec4,
2120
out_uv: &mut Vec2,
2221
) {
2322
// Generate fullscreen triangle using vertex index
24-
*out_uv = vec2(
25-
((vertex_index << 1) & 2) as f32,
26-
(vertex_index & 2) as f32
27-
);
23+
*out_uv = vec2(((vertex_index << 1) & 2) as f32, (vertex_index & 2) as f32);
2824
*out_position = Vec4::new(out_uv.x * 2.0 - 1.0, out_uv.y * 2.0 - 1.0, 0.0, 1.0);
2925
}
3026

3127
#[spirv(fragment)]
3228
pub fn main_fs(
33-
#[spirv(descriptor_set = 0, binding = 1)] sampler_color: &SampledImage<Image!(2D, type=f32, sampled)>,
29+
#[spirv(descriptor_set = 0, binding = 1)] sampler_color: &SampledImage<
30+
Image!(2D, type=f32, sampled),
31+
>,
3432
#[spirv(uniform, descriptor_set = 0, binding = 0)] ubo: &UBO,
3533
#[spirv(spec_constant(id = 0, default = 0))] blur_direction: u32,
3634
in_uv: Vec2,
@@ -42,24 +40,40 @@ pub fn main_fs(
4240
// Get texture size for offset calculation (matches original GLSL)
4341
let tex_size: UVec2 = sampler_color.query_size_lod(0);
4442
let tex_offset = vec2(1.0 / tex_size.x as f32, 1.0 / tex_size.y as f32) * ubo.blur_scale;
45-
43+
4644
// Sample current fragment
4745
let mut result = sampler_color.sample(in_uv).truncate() * weight[0];
48-
46+
4947
// Sample surrounding pixels for blur
5048
for i in 1..5i32 {
5149
let offset = i as f32;
52-
50+
5351
if blur_direction == 1 {
5452
// Horizontal blur
55-
result += sampler_color.sample(in_uv + vec2(tex_offset.x * offset, 0.0)).truncate() * weight[i as usize] * ubo.blur_strength;
56-
result += sampler_color.sample(in_uv - vec2(tex_offset.x * offset, 0.0)).truncate() * weight[i as usize] * ubo.blur_strength;
53+
result += sampler_color
54+
.sample(in_uv + vec2(tex_offset.x * offset, 0.0))
55+
.truncate()
56+
* weight[i as usize]
57+
* ubo.blur_strength;
58+
result += sampler_color
59+
.sample(in_uv - vec2(tex_offset.x * offset, 0.0))
60+
.truncate()
61+
* weight[i as usize]
62+
* ubo.blur_strength;
5763
} else {
5864
// Vertical blur
59-
result += sampler_color.sample(in_uv + vec2(0.0, tex_offset.y * offset)).truncate() * weight[i as usize] * ubo.blur_strength;
60-
result += sampler_color.sample(in_uv - vec2(0.0, tex_offset.y * offset)).truncate() * weight[i as usize] * ubo.blur_strength;
65+
result += sampler_color
66+
.sample(in_uv + vec2(0.0, tex_offset.y * offset))
67+
.truncate()
68+
* weight[i as usize]
69+
* ubo.blur_strength;
70+
result += sampler_color
71+
.sample(in_uv - vec2(0.0, tex_offset.y * offset))
72+
.truncate()
73+
* weight[i as usize]
74+
* ubo.blur_strength;
6175
}
6276
}
63-
77+
6478
*out_frag_color = Vec4::new(result.x, result.y, result.z, 1.0);
65-
}
79+
}

shaders/rust/bloom/phongpass/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
use spirv_std::{
44
glam::{Mat3, Mat4, Vec2, Vec3, Vec4},
5-
spirv,
65
num_traits::Float,
6+
spirv,
77
};
88

99
#[repr(C)]
@@ -51,8 +51,8 @@ pub fn main_fs(
5151
out_frag_color: &mut Vec4,
5252
) {
5353
let mut ambient = Vec3::ZERO;
54-
55-
// Adjust light calculations for glow color
54+
55+
// Adjust light calculations for glow color
5656
if in_color.x >= 0.9 || in_color.y >= 0.9 || in_color.z >= 0.9 {
5757
ambient = in_color * 0.25;
5858
}
@@ -63,11 +63,11 @@ pub fn main_fs(
6363
let r = (-l).reflect(n);
6464
let diffuse = n.dot(l).max(0.0) * in_color;
6565
let specular = r.dot(v).max(0.0).powf(8.0) * Vec3::new(0.75, 0.75, 0.75);
66-
66+
6767
*out_frag_color = Vec4::new(
6868
ambient.x + diffuse.x + specular.x,
6969
ambient.y + diffuse.y + specular.y,
7070
ambient.z + diffuse.z + specular.z,
71-
1.0
71+
1.0,
7272
);
73-
}
73+
}

shaders/rust/bloom/skybox/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#![cfg_attr(target_arch = "spirv", no_std)]
22

3+
use spirv_std::image::SampledImage;
34
use spirv_std::{
45
glam::{Mat4, Vec3, Vec4},
56
spirv, Image,
67
};
7-
use spirv_std::image::SampledImage;
88

99
#[repr(C)]
1010
#[derive(Copy, Clone)]
@@ -22,14 +22,17 @@ pub fn main_vs(
2222
out_uvw: &mut Vec3,
2323
) {
2424
*out_uvw = in_pos;
25-
*out_position = ubo.projection * ubo.view * ubo.model * Vec4::new(in_pos.x, in_pos.y, in_pos.z, 1.0);
25+
*out_position =
26+
ubo.projection * ubo.view * ubo.model * Vec4::new(in_pos.x, in_pos.y, in_pos.z, 1.0);
2627
}
2728

2829
#[spirv(fragment)]
2930
pub fn main_fs(
30-
#[spirv(descriptor_set = 0, binding = 1)] sampler_cube_map: &SampledImage<Image!(cube, type=f32, sampled)>,
31+
#[spirv(descriptor_set = 0, binding = 1)] sampler_cube_map: &SampledImage<
32+
Image!(cube, type=f32, sampled),
33+
>,
3134
in_uvw: Vec3,
3235
out_frag_color: &mut Vec4,
3336
) {
3437
*out_frag_color = sampler_cube_map.sample(in_uvw);
35-
}
38+
}

shaders/rust/computecloth/cloth/src/lib.rs

Lines changed: 63 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![no_std]
22

3+
use spirv_std::glam::{IVec2, Mat4, UVec3, Vec2, Vec3, Vec4, Vec4Swizzles};
4+
use spirv_std::num_traits::Float;
35
use spirv_std::spirv;
4-
use spirv_std::glam::{IVec2, UVec3, Vec2, Vec3, Vec4, Vec4Swizzles, Mat4};
56
use spirv_std::{Image, Sampler};
6-
use spirv_std::num_traits::Float;
77

88
#[repr(C)]
99
#[derive(Copy, Clone)]
@@ -60,59 +60,99 @@ pub fn main_cs(
6060
if index >= particle_count_x * particle_count_y {
6161
return;
6262
}
63-
63+
6464
// Initial force from gravity
6565
let mut force = ubo.gravity.xyz() * ubo.particle_mass;
66-
66+
6767
let idx = index as usize;
6868
let pos = particle_in[idx].pos.xyz();
6969
let vel = particle_in[idx].vel.xyz();
70-
70+
7171
// Spring forces from neighboring particles
7272
// left
7373
if id.x > 0 {
74-
force += spring_force(particle_in[idx - 1].pos.xyz(), pos, ubo.rest_dist_h, ubo.spring_stiffness);
74+
force += spring_force(
75+
particle_in[idx - 1].pos.xyz(),
76+
pos,
77+
ubo.rest_dist_h,
78+
ubo.spring_stiffness,
79+
);
7580
}
7681
// right
7782
if id.x < particle_count_x - 1 {
78-
force += spring_force(particle_in[idx + 1].pos.xyz(), pos, ubo.rest_dist_h, ubo.spring_stiffness);
83+
force += spring_force(
84+
particle_in[idx + 1].pos.xyz(),
85+
pos,
86+
ubo.rest_dist_h,
87+
ubo.spring_stiffness,
88+
);
7989
}
8090
// upper
8191
if id.y < particle_count_y - 1 {
82-
force += spring_force(particle_in[idx + particle_count_x as usize].pos.xyz(), pos, ubo.rest_dist_v, ubo.spring_stiffness);
92+
force += spring_force(
93+
particle_in[idx + particle_count_x as usize].pos.xyz(),
94+
pos,
95+
ubo.rest_dist_v,
96+
ubo.spring_stiffness,
97+
);
8398
}
8499
// lower
85100
if id.y > 0 {
86-
force += spring_force(particle_in[idx - particle_count_x as usize].pos.xyz(), pos, ubo.rest_dist_v, ubo.spring_stiffness);
101+
force += spring_force(
102+
particle_in[idx - particle_count_x as usize].pos.xyz(),
103+
pos,
104+
ubo.rest_dist_v,
105+
ubo.spring_stiffness,
106+
);
87107
}
88108
// upper-left
89109
if id.x > 0 && id.y < particle_count_y - 1 {
90-
force += spring_force(particle_in[idx + particle_count_x as usize - 1].pos.xyz(), pos, ubo.rest_dist_d, ubo.spring_stiffness);
110+
force += spring_force(
111+
particle_in[idx + particle_count_x as usize - 1].pos.xyz(),
112+
pos,
113+
ubo.rest_dist_d,
114+
ubo.spring_stiffness,
115+
);
91116
}
92117
// lower-left
93118
if id.x > 0 && id.y > 0 {
94-
force += spring_force(particle_in[idx - particle_count_x as usize - 1].pos.xyz(), pos, ubo.rest_dist_d, ubo.spring_stiffness);
119+
force += spring_force(
120+
particle_in[idx - particle_count_x as usize - 1].pos.xyz(),
121+
pos,
122+
ubo.rest_dist_d,
123+
ubo.spring_stiffness,
124+
);
95125
}
96126
// upper-right
97127
if id.x < particle_count_x - 1 && id.y < particle_count_y - 1 {
98-
force += spring_force(particle_in[idx + particle_count_x as usize + 1].pos.xyz(), pos, ubo.rest_dist_d, ubo.spring_stiffness);
128+
force += spring_force(
129+
particle_in[idx + particle_count_x as usize + 1].pos.xyz(),
130+
pos,
131+
ubo.rest_dist_d,
132+
ubo.spring_stiffness,
133+
);
99134
}
100135
// lower-right
101136
if id.x < particle_count_x - 1 && id.y > 0 {
102-
force += spring_force(particle_in[idx - particle_count_x as usize + 1].pos.xyz(), pos, ubo.rest_dist_d, ubo.spring_stiffness);
137+
force += spring_force(
138+
particle_in[idx - particle_count_x as usize + 1].pos.xyz(),
139+
pos,
140+
ubo.rest_dist_d,
141+
ubo.spring_stiffness,
142+
);
103143
}
104-
144+
105145
// Damping
106146
force += -ubo.damping * vel;
107-
147+
108148
// Integrate
109149
let f = force * (1.0 / ubo.particle_mass);
110150
let new_pos = pos + vel * ubo.delta_t + 0.5 * f * ubo.delta_t * ubo.delta_t;
111151
let new_vel = vel + f * ubo.delta_t;
112-
152+
113153
particle_out[idx].pos = Vec4::new(new_pos.x, new_pos.y, new_pos.z, 1.0);
114154
particle_out[idx].vel = Vec4::new(new_vel.x, new_vel.y, new_vel.z, 0.0);
115-
155+
116156
// Sphere collision
117157
let sphere_dist = new_pos - ubo.sphere_pos.xyz();
118158
if sphere_dist.length() < ubo.sphere_radius + 0.01 {
@@ -122,11 +162,11 @@ pub fn main_cs(
122162
// Cancel out velocity
123163
particle_out[idx].vel = Vec4::ZERO;
124164
}
125-
165+
126166
// Calculate normals
127167
if push_consts.calculate_normals == 1 {
128168
let mut normal = Vec3::ZERO;
129-
169+
130170
let stride = particle_count_x as usize;
131171
if id.y > 0 {
132172
if id.x > 0 {
@@ -156,13 +196,13 @@ pub fn main_cs(
156196
normal += a.cross(b) + b.cross(c);
157197
}
158198
}
159-
199+
160200
if normal.length() > 0.0 {
161201
normal = normal.normalize();
162202
}
163203
particle_out[idx].normal = Vec4::new(normal.x, normal.y, normal.z, 0.0);
164204
}
165-
205+
166206
// Copy UV coordinates
167207
particle_out[idx].uv = particle_in[idx].uv;
168208
}
@@ -221,6 +261,6 @@ pub fn main_fs(
221261
diffuse.x * color.x + specular.x,
222262
diffuse.y * color.y + specular.y,
223263
diffuse.z * color.z + specular.z,
224-
1.0
264+
1.0,
225265
);
226-
}
266+
}

0 commit comments

Comments
 (0)