Skip to content

Commit 6e8453f

Browse files
authored
Decouple glam from spirv-std (#476)
1 parent eebb2d3 commit 6e8453f

File tree

26 files changed

+446
-233
lines changed

26 files changed

+446
-233
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ members = [
1818
[profile.release.build-override]
1919
opt-level = 3
2020
codegen-units = 16
21+
22+
[patch.crates-io]
23+
spirv-std = { path = "./crates/spirv-std" }
24+
glam = { git = "https://github.com/EmbarkStudios/glam-rs.git", branch ="spirv-std-impl" }

crates/spirv-builder/src/test/basic.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@ pub fn main() {
463463
let vector = glam::Vec2::new(1.0, 2.0);
464464
let element = unsafe { spirv_std::arch::vector_extract_dynamic(vector, 1) };
465465
assert!(2.0 == element);
466+
let uvector = glam::UVec2::new(1, 2);
467+
let element: u32 = unsafe { spirv_std::arch::vector_extract_dynamic(uvector, 1) };
468+
assert!(2 == element);
466469
}
467470
"#);
468471
}
@@ -476,6 +479,10 @@ pub fn main() {
476479
let expected = glam::Vec2::new(1.0, 3.0);
477480
let new_vector = unsafe { spirv_std::arch::vector_insert_dynamic(vector, 1, 3.0) };
478481
assert!(new_vector == expected);
482+
let uvector = glam::UVec2::new(1, 2);
483+
let uexpected = glam::UVec2::new(1, 3);
484+
let new_vector = unsafe { spirv_std::arch::vector_insert_dynamic(uvector, 1, 3) };
485+
assert!(new_vector == uexpected);
479486
}
480487
"#);
481488
}
@@ -545,7 +552,7 @@ fn complex_image_sample_inst() {
545552
}
546553
#[spirv(fragment)]
547554
pub fn main() {
548-
sample_proj_lod(glam::Vec4::zero(), glam::Vec2::zero(), glam::Vec2::zero(), 0, 0);
555+
sample_proj_lod(glam::Vec4::ZERO, glam::Vec2::ZERO, glam::Vec2::ZERO, 0, 0);
549556
}"#,
550557
"sample_proj_lod",
551558
"%1 = OpFunction %2 None %3
@@ -568,7 +575,7 @@ fn image_read() {
568575
val(r#"
569576
#[spirv(fragment)]
570577
pub fn main(image: UniformConstant<StorageImage2d>, mut output: Output<glam::Vec2>) {
571-
let coords = image.read(glam::IVec2::new(0, 1));
578+
let coords = image.read(glam::IVec2::new(0, 1));
572579
*output = coords;
573580
}
574581
"#);

crates/spirv-builder/src/test/control_flow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fn issue_283() {
330330
// version of issue 283 with loop uncommented and warnings fixed
331331
// https://github.com/EmbarkStudios/rust-gpu/issues/283
332332
val(r#"
333-
use spirv_std::glam::*;
333+
use glam::*;
334334
fn sphere_sdf(p: Vec3) -> f32 {
335335
p.length() - 1.0
336336
}

crates/spirv-builder/src/test/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ overflow-checks = false
4747
debug-assertions = false
4848
4949
[dependencies]
50-
spirv-std = { path = "../../crates/spirv-std" }
50+
spirv-std = { path = "../../crates/spirv-std", features=["const-generics"] }
51+
glam = { git = "https://github.com/EmbarkStudios/glam-rs.git", branch="spirv-std-impl", default-features=false, features = ["libm", "scalar-math"] }
52+
53+
[patch.crates-io.spirv-std]
54+
path="../../crates/spirv-std"
5155
5256
[workspace]
5357
"#;

crates/spirv-std-macros/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ description = "Macros for spirv-std"
1111
proc-macro = true
1212

1313
[dependencies]
14+
proc-macro2 = "1.0.24"
1415
quote = "1.0.8"
1516
syn = { version = "1.0.58", features=["full"] }

0 commit comments

Comments
 (0)