Skip to content
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### 🚨BREAKING🚨️

- [PR#660](https://github.com/Rust-GPU/rust-gpu/pull/660) disallows `Vec3A` for SPIR-V intrinsics and asm. Migration: use Vec3 instead and convert back and forward with `Vec3::to_vec3a()` and `Vec3A::to_vec3()`.

## [0.10.0](https://github.com/Rust-GPU/rust-gpu/compare/v0.10.0-alpha.1...v0.10.0) - 2026-10-01

Toolchain: `nightly-2026-07-03` (rustc 1.98.0)
Expand Down
3 changes: 1 addition & 2 deletions crates/spirv-std/src/arch/derivative.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::glam::{Vec2, Vec3, Vec3A, Vec4};
use crate::glam::{Vec2, Vec3, Vec4};
use crate::sealed::Sealed;

#[cfg(target_arch = "spirv")]
Expand Down Expand Up @@ -148,4 +148,3 @@ unsafe impl Derivative for f32 {}
unsafe impl Derivative for Vec2 {}
unsafe impl Derivative for Vec3 {}
unsafe impl Derivative for Vec4 {}
unsafe impl Derivative for Vec3A {}
26 changes: 13 additions & 13 deletions crates/spirv-std/src/matrix.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! a set of common SPIR-V Matrices, used for intrinsics

use crate::glam::{Affine3A, Mat3, Mat3A, Mat4, Vec3, Vec3A};
use crate::glam::{Affine3A, Mat3, Mat3A, Mat4, Vec3};
use core::fmt::{Debug, Display, Formatter};

/// A Matrix with 4 columns of [`Vec3`], very similar to glam's [`Affine3A`].
Expand All @@ -18,10 +18,10 @@ use core::fmt::{Debug, Display, Formatter};
#[spirv(matrix)]
#[allow(missing_docs)]
pub struct Matrix4x3 {
pub x_axis: Vec3A,
pub y_axis: Vec3A,
pub z_axis: Vec3A,
pub w_axis: Vec3A,
pub x_axis: Vec3,
pub y_axis: Vec3,
pub z_axis: Vec3,
pub w_axis: Vec3,
}

/// The `from_*` fn signatures should match [`Affine3A`], to make it easier to switch to [`Affine3A`] later.
Expand All @@ -30,10 +30,10 @@ impl Matrix4x3 {
/// Convert from glam's [`Affine3A`]
pub fn from_affine3a(affine: Affine3A) -> Self {
Self {
x_axis: affine.x_axis,
y_axis: affine.y_axis,
z_axis: affine.z_axis,
w_axis: affine.w_axis,
x_axis: affine.x_axis.to_vec3(),
y_axis: affine.y_axis.to_vec3(),
z_axis: affine.z_axis.to_vec3(),
w_axis: affine.w_axis.to_vec3(),
}
}

Expand Down Expand Up @@ -61,11 +61,11 @@ impl Matrix4x3 {
pub fn to_affine3a(self) -> Affine3A {
Affine3A {
matrix3: Mat3A {
x_axis: self.x_axis,
y_axis: self.y_axis,
z_axis: self.z_axis,
x_axis: self.x_axis.to_vec3a(),
y_axis: self.y_axis.to_vec3a(),
z_axis: self.z_axis.to_vec3a(),
},
translation: self.w_axis,
translation: self.w_axis.to_vec3a(),
}
}

Expand Down
13 changes: 13 additions & 0 deletions crates/spirv-std/src/scalar_or_vector.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::glam::Vec3A;
use crate::{Scalar, Vector};
use core::num::NonZeroUsize;

Expand Down Expand Up @@ -83,3 +84,15 @@ impl<T: ScalarComposite + Default, const N: usize> ScalarComposite for [T; N] {
out
}
}

/// `glam::Vec3A` is not considered a SPIR-V vector and thus needs a manual implementation
impl ScalarComposite for Vec3A {
#[inline]
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self {
Vec3A::new(
f.transform_scalar(self.x),
f.transform_scalar(self.y),
f.transform_scalar(self.z),
)
}
}
1 change: 0 additions & 1 deletion crates/spirv-std/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ macro_rules! impl_vector {
impl_vector! {
glam::Vec2: [f32; 2];
glam::Vec3: [f32; 3];
glam::Vec3A: [f32; 3];
glam::Vec4: [f32; 4];
glam::DVec2: [f64; 2];
glam::DVec3: [f64; 3];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ LL | debug_printf!("%v2f", 11.0);
|
help: the trait `spirv_std::Vector<f32, 2>` is implemented for `Vec2`
--> $SPIRV_STD_SRC/vector.rs:71:12
::: $SPIRV_STD_SRC/vector.rs:93:1
::: $SPIRV_STD_SRC/vector.rs:92:1
|
= note: in this macro invocation
note: required by a bound in `spirv_std::debug_printf::assert_is_vector`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn main(
output: &mut f32,
) {
let v2 = glam::Vec2::new(0.0, 1.0);
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
let v3 = glam::Vec3::new(0.0, 0.0, 1.0);
*output = image.sample_depth_reference(*sampler, v2, 1.0);
*output += image_array.sample_depth_reference(*sampler, v3, 1.0);
*output += cubemap.sample_depth_reference(*sampler, v3, 1.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn main(
let v2 = glam::Vec2::new(0.0, 1.0);
let v2_dx = glam::Vec2::new(0.0, 1.0);
let v2_dy = glam::Vec2::new(0.0, 1.0);
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
let v3 = glam::Vec3::new(0.0, 0.0, 1.0);
*output = image.sample_depth_reference_by_gradient(*sampler, v2, 1.0, v2_dx, v2_dy);
*output += image_array.sample_depth_reference_by_gradient(*sampler, v3, 1.0, v2_dx, v2_dy);
}
Expand All @@ -37,8 +37,8 @@ pub fn main_cubemap(
#[spirv(descriptor_set = 3, binding = 3)] cubemap: &Image!(3D, type=f32, sampled),
output: &mut f32,
) {
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
let v3_dx = glam::Vec3A::new(0.0, 1.0, 0.5);
let v3_dy = glam::Vec3A::new(0.0, 1.0, 0.5);
let v3 = glam::Vec3::new(0.0, 0.0, 1.0);
let v3_dx = glam::Vec3::new(0.0, 1.0, 0.5);
let v3_dy = glam::Vec3::new(0.0, 1.0, 0.5);
*output += cubemap.sample_depth_reference_by_gradient(*sampler, v3, 1.0, v3_dx, v3_dy);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn main(
output: &mut f32,
) {
let v2 = glam::Vec2::new(0.0, 1.0);
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
let v3 = glam::Vec3::new(0.0, 0.0, 1.0);
*output = image.sample_depth_reference_by_lod(*sampler, v2, 1.0, 0.0);
*output += image_array.sample_depth_reference_by_lod(*sampler, v3, 1.0, 0.0);
}
Expand All @@ -35,6 +35,6 @@ pub fn main_cubemap(
#[spirv(descriptor_set = 3, binding = 3)] cubemap: &Image!(3D, type=f32, sampled),
output: &mut f32,
) {
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
let v3 = glam::Vec3::new(0.0, 0.0, 1.0);
*output += cubemap.sample_depth_reference_by_lod(*sampler, v3, 1.0, 0.0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ pub fn main(
#[spirv(descriptor_set = 1, binding = 1)] sampler: &Sampler,
output: &mut f32,
) {
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
let v3 = glam::Vec3::new(0.0, 0.0, 1.0);
*output = image.sample_depth_reference_with_project_coordinate(*sampler, v3, 1.0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn main(
) {
let v2_dx = glam::Vec2::new(0.0, 1.0);
let v2_dy = glam::Vec2::new(0.0, 1.0);
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
let v3 = glam::Vec3::new(0.0, 0.0, 1.0);
*output = image.sample_depth_reference_with_project_coordinate_by_gradient(
*sampler, v3, 1.0, v2_dx, v2_dy,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ pub fn main(
#[spirv(descriptor_set = 1, binding = 1)] sampler: &Sampler,
output: &mut f32,
) {
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
let v3 = glam::Vec3::new(0.0, 0.0, 1.0);
*output = image.sample_depth_reference_with_project_coordinate_by_lod(*sampler, v3, 1.0, 0.0);
}
Loading