Skip to content

Commit c43d3ec

Browse files
committed
Update glam and re-export glam from spirv_std
1 parent bfa0f50 commit c43d3ec

File tree

10 files changed

+88
-92
lines changed

10 files changed

+88
-92
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,3 @@ members = [
1313
"crates/spirv-tools",
1414
"crates/spirv-tools-sys",
1515
]
16-
17-
[patch.crates-io]
18-
# https://github.com/bitshifter/glam-rs/pull/85
19-
glam = { git = "https://github.com/EmbarkStudios/glam-rs", rev = "d55ff75e91aab01c4fd9808e3ca9c079dfa7315c" }

crates/spirv-std/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ license = "MIT OR Apache-2.0"
77
repository = "https://github.com/EmbarkStudios/rust-gpu"
88

99
[dependencies]
10+
# https://github.com/bitshifter/glam-rs/pull/85
11+
glam = { git = "https://github.com/EmbarkStudios/glam-rs", rev = "c9561e4dfd55fa5a9d6838cae3c9e90c8edafaf9" }

crates/spirv-std/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
mod math_ext;
4040
pub use math_ext::MathExt;
4141

42+
pub use glam;
43+
4244
macro_rules! pointer_addrspace_write {
4345
(false) => {};
4446
(true) => {

examples/runners/cpu/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ publish = false
1010
minifb = "0.19.1"
1111
# bring in the shader as natively compiled code
1212
sky-shader = { path = "../../shaders/sky-shader" }
13-
glam = "0.9"
13+
spirv-std = { path = "../../../crates/spirv-std" }
1414

1515
# for parallelism, not really needed though
1616
rayon = "1.5"

examples/runners/cpu/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use glam::{vec2, Vec4};
1+
use spirv_std::glam::{vec2, Vec4};
22
use minifb::{Key, Window, WindowOptions};
33
use rayon::prelude::*;
44
use std::time::Instant;

examples/shaders/simplest-shader/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ crate-type = ["dylib"]
1111

1212
[dependencies]
1313
spirv-std = { path = "../../../crates/spirv-std" }
14-
glam = "0.9"

examples/shaders/simplest-shader/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![feature(register_attr)]
44
#![register_attr(spirv)]
55

6-
use glam::Vec4;
6+
use spirv_std::glam::Vec4;
77
use spirv_std::{Input, Output};
88

99
#[allow(unused_attributes)]

examples/shaders/sky-shader/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ crate-type = ["dylib"]
1111

1212
[dependencies]
1313
spirv-std = { path = "../../../crates/spirv-std" }
14-
glam = "0.9"

examples/shaders/sky-shader/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![register_attr(spirv)]
77

88
use core::f32::consts::PI;
9-
use glam::{const_vec3, Mat4, Vec2, Vec3, Vec4};
9+
use spirv_std::glam::{const_vec3, Mat4, Vec2, Vec3, Vec4};
1010
use spirv_std::{Input, MathExt, Output};
1111

1212
const DEPOLARIZATION_FACTOR: f32 = 0.035;
@@ -160,15 +160,11 @@ pub fn fs(screen_pos: Vec2) -> Vec4 {
160160
Vec4::new(0.0, -0.14834046, -0.98893654, 0.0),
161161
);
162162

163-
let clip_pos = screen_pos.extend(1.0).extend(1.0);
164-
let world_pos = {
165-
let p = clip_to_world.mul_vec4(clip_pos);
166-
p.truncate() / p.w()
167-
};
163+
let world_pos = clip_to_world.transform_point3(screen_pos.extend(1.0));
168164
let dir = (world_pos - eye_pos).normalize();
169165

170166
// evaluate Preetham sky model
171-
let color = sky(dir, sun_pos);
167+
let color = sky(dir.into(), sun_pos);
172168

173169
// Tonemapping
174170
let color = color.max(Vec3::splat(0.0)).min(Vec3::splat(1024.0));

0 commit comments

Comments
 (0)