Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update glam #220

Merged
merged 1 commit into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 78 additions & 76 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ members = [
"crates/spirv-tools",
"crates/spirv-tools-sys",
]

[patch.crates-io]
# https://github.com/bitshifter/glam-rs/pull/85
glam = { git = "https://github.com/EmbarkStudios/glam-rs", rev = "d55ff75e91aab01c4fd9808e3ca9c079dfa7315c" }
2 changes: 2 additions & 0 deletions crates/spirv-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/EmbarkStudios/rust-gpu"

[dependencies]
# https://github.com/bitshifter/glam-rs/pull/85
glam = { git = "https://github.com/EmbarkStudios/glam-rs", rev = "c9561e4dfd55fa5a9d6838cae3c9e90c8edafaf9" }
2 changes: 2 additions & 0 deletions crates/spirv-std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
mod math_ext;
pub use math_ext::MathExt;

pub use glam;

macro_rules! pointer_addrspace_write {
(false) => {};
(true) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/runners/cpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish = false
minifb = "0.19.1"
# bring in the shader as natively compiled code
sky-shader = { path = "../../shaders/sky-shader" }
glam = "0.9"
spirv-std = { path = "../../../crates/spirv-std" }

# for parallelism, not really needed though
rayon = "1.5"
2 changes: 1 addition & 1 deletion examples/runners/cpu/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use glam::{vec2, Vec4};
use minifb::{Key, Window, WindowOptions};
use rayon::prelude::*;
use spirv_std::glam::{vec2, Vec4};
use std::time::Instant;

// apply the srgb OETF (i.e. do "linear to sRGB")
Expand Down
1 change: 0 additions & 1 deletion examples/shaders/simplest-shader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ crate-type = ["dylib"]

[dependencies]
spirv-std = { path = "../../../crates/spirv-std" }
glam = "0.9"
2 changes: 1 addition & 1 deletion examples/shaders/simplest-shader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![feature(register_attr)]
#![register_attr(spirv)]

use glam::Vec4;
use spirv_std::glam::Vec4;
use spirv_std::{Input, Output};

#[allow(unused_attributes)]
Expand Down
1 change: 0 additions & 1 deletion examples/shaders/sky-shader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ crate-type = ["dylib"]

[dependencies]
spirv-std = { path = "../../../crates/spirv-std" }
glam = "0.9"
8 changes: 2 additions & 6 deletions examples/shaders/sky-shader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#![register_attr(spirv)]

use core::f32::consts::PI;
use glam::{const_vec3, Mat4, Vec2, Vec3, Vec4};
use spirv_std::glam::{const_vec3, Mat4, Vec2, Vec3, Vec4};
use spirv_std::{Input, MathExt, Output};

const DEPOLARIZATION_FACTOR: f32 = 0.035;
Expand Down Expand Up @@ -160,11 +160,7 @@ pub fn fs(screen_pos: Vec2) -> Vec4 {
Vec4::new(0.0, -0.14834046, -0.98893654, 0.0),
);

let clip_pos = screen_pos.extend(1.0).extend(1.0);
let world_pos = {
let p = clip_to_world.mul_vec4(clip_pos);
p.truncate() / p.w()
};
let world_pos = clip_to_world.transform_point3(screen_pos.extend(1.0));
let dir = (world_pos - eye_pos).normalize();

// evaluate Preetham sky model
Expand Down