Skip to content

Commit

Permalink
Add derivatives for vector functions (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
khyperia authored Jan 18, 2021
1 parent f7cdf1d commit 8eadd90
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions crates/spirv-std/src/derivative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ macro_rules! deriv_fn {
panic!(concat!(stringify!($name), " is not supported on the CPU"));
#[cfg(target_arch = "spirv")]
unsafe {
let o;
let mut o = Default::default();
deriv_caps!($needs_caps);
asm!(
concat!("{1} = ", stringify!($inst), " typeof{0} {0}"),
in(reg) self,
out(reg) o,
"%input = OpLoad typeof*{0} {0}",
concat!("%result = ", stringify!($inst), " typeof*{0} %input"),
"OpStore {1} %result",
in(reg) &self,
in(reg) &mut o,
);
o
}
Expand All @@ -92,7 +94,7 @@ macro_rules! deriv_impl {

// "must be a scalar or vector of floating-point type. The component width must be 32 bits."
deriv_impl!(f32);
// TODO: Fix rustc to support these
// deriv_impl!(glam::Vec2);
// deriv_impl!(glam::Vec3);
// deriv_impl!(glam::Vec4);
deriv_impl!(glam::Vec2);
deriv_impl!(glam::Vec3);
deriv_impl!(glam::Vec3A);
deriv_impl!(glam::Vec4);

0 comments on commit 8eadd90

Please sign in to comment.