Skip to content

Commit 989e391

Browse files
committed
revert to ugly format
1 parent e264a17 commit 989e391

35 files changed

+8520
-8489
lines changed

build.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ use spirv_builder::{MetadataPrintout, SpirvBuilder};
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 builder = SpirvBuilder::new(path_to_crate, "spirv-unknown-vulkan1.2")
6+
.print_metadata(MetadataPrintout::Full);
77

8-
let _result = builder.build()?;
9-
Ok(())
8+
let _result = builder.build()?;
9+
Ok(())
1010
}
1111

1212
fn main() -> Result<(), Box<dyn Error>> {
13-
build_shader("shaders")?;
14-
Ok(())
13+
build_shader("shaders")?;
14+
Ok(())
1515
}

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
match_block_trailing_comma = true
2-
tab_spaces = 2
2+
tab_spaces = 4
33
condense_wildcard_suffixes = false
44
newline_style = "Unix"
55

shaders/src/lib.rs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,63 @@ pub mod shared_data;
77

88
#[inline(always)]
99
pub fn fs(constants: &ShaderConstants, mut frag_coord: Vec2) -> Vec4 {
10-
let resolution = vec3(
11-
constants.width as f32 as f32,
12-
constants.height as f32 as f32,
13-
0.0,
14-
);
15-
let time = constants.time;
16-
let mut mouse = vec4(
17-
constants.drag_end_x as f32,
18-
constants.drag_end_y as f32,
19-
constants.drag_start_x as f32,
20-
constants.drag_start_y as f32,
21-
);
22-
if mouse != Vec4::ZERO {
23-
mouse.y = resolution.y - mouse.y;
24-
mouse.w = resolution.y - mouse.w;
25-
}
26-
if !(constants.mouse_left_pressed == 1) {
27-
mouse.z *= -1.0;
28-
}
29-
if !(constants.mouse_left_clicked == 1) {
30-
mouse.w *= -1.0;
31-
}
10+
let resolution = vec3(
11+
constants.width as f32 as f32,
12+
constants.height as f32 as f32,
13+
0.0,
14+
);
15+
let time = constants.time;
16+
let mut mouse = vec4(
17+
constants.drag_end_x as f32,
18+
constants.drag_end_y as f32,
19+
constants.drag_start_x as f32,
20+
constants.drag_start_y as f32,
21+
);
22+
if mouse != Vec4::ZERO {
23+
mouse.y = resolution.y - mouse.y;
24+
mouse.w = resolution.y - mouse.w;
25+
}
26+
if !(constants.mouse_left_pressed == 1) {
27+
mouse.z *= -1.0;
28+
}
29+
if !(constants.mouse_left_clicked == 1) {
30+
mouse.w *= -1.0;
31+
}
3232

33-
frag_coord.x %= resolution.x;
34-
frag_coord.y = resolution.y - frag_coord.y % resolution.y;
33+
frag_coord.x %= resolution.x;
34+
frag_coord.y = resolution.y - frag_coord.y % resolution.y;
3535

36-
let shader_input = ShaderInput {
37-
resolution,
38-
time,
39-
frag_coord,
40-
mouse,
41-
};
42-
let mut shader_output = &mut ShaderResult { color: Vec4::ZERO };
43-
shaders::render_shader(constants.shader_to_show, &shader_input, &mut shader_output);
44-
let color = shader_output.color;
45-
Vec3::powf(color.truncate(), 2.2).extend(color.w)
36+
let shader_input = ShaderInput {
37+
resolution,
38+
time,
39+
frag_coord,
40+
mouse,
41+
};
42+
let mut shader_output = &mut ShaderResult { color: Vec4::ZERO };
43+
shaders::render_shader(constants.shader_to_show, &shader_input, &mut shader_output);
44+
let color = shader_output.color;
45+
Vec3::powf(color.truncate(), 2.2).extend(color.w)
4646
}
4747

4848
#[allow(unused_attributes)]
4949
#[spirv(fragment)]
5050
pub fn main_fs(
51-
#[spirv(frag_coord)] in_frag_coord: Vec4,
52-
#[spirv(push_constant)] constants: &ShaderConstants,
53-
output: &mut Vec4,
51+
#[spirv(frag_coord)] in_frag_coord: Vec4,
52+
#[spirv(push_constant)] constants: &ShaderConstants,
53+
output: &mut Vec4,
5454
) {
55-
let frag_coord = vec2(in_frag_coord.x, in_frag_coord.y);
56-
let color = fs(constants, frag_coord);
57-
*output = color;
55+
let frag_coord = vec2(in_frag_coord.x, in_frag_coord.y);
56+
let color = fs(constants, frag_coord);
57+
*output = color;
5858
}
5959

6060
#[allow(unused_attributes)]
6161
#[spirv(vertex)]
6262
pub fn main_vs(#[spirv(vertex_index)] vert_idx: i32, #[spirv(position)] builtin_pos: &mut Vec4) {
63-
// Create a "full screen triangle" by mapping the vertex index.
64-
// ported from https://www.saschawillems.de/blog/2016/08/13/vulkan-tutorial-on-rendering-a-fullscreen-quad-without-buffers/
65-
let uv = vec2(((vert_idx << 1) & 2) as f32, (vert_idx & 2) as f32);
66-
let pos = 2.0 * uv - Vec2::ONE;
63+
// Create a "full screen triangle" by mapping the vertex index.
64+
// ported from https://www.saschawillems.de/blog/2016/08/13/vulkan-tutorial-on-rendering-a-fullscreen-quad-without-buffers/
65+
let uv = vec2(((vert_idx << 1) & 2) as f32, (vert_idx & 2) as f32);
66+
let pos = 2.0 * uv - Vec2::ONE;
6767

68-
*builtin_pos = pos.extend(0.0).extend(1.0);
68+
*builtin_pos = pos.extend(0.0).extend(1.0);
6969
}

0 commit comments

Comments
 (0)