Skip to content

Commit e4a165b

Browse files
committed
ScalarComposite: adjust docs to the new name
1 parent 77708a3 commit e4a165b

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

crates/spirv-std/src/scalar_or_vector.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,31 @@ pub unsafe trait ScalarOrVector: ScalarComposite + Default {
1919
const N: NonZeroUsize;
2020
}
2121

22-
/// A `VectorOrScalarComposite` is a type that is either
22+
/// A `ScalarComposite` is a type that is either
2323
/// * a [`Scalar`]
24-
/// * a [`Vector`]
25-
/// * an array of `VectorOrScalarComposite`
26-
/// * a struct where all members are `VectorOrScalarComposite`
24+
/// * a [`Vector`] (since vectors are made from scalars)
25+
/// * an array of `ScalarComposite`
26+
/// * a struct where all members are `ScalarComposite`
2727
/// * an enum with a `repr` that is a [`Scalar`]
2828
///
2929
/// By calling [`Self::transform`] you can visit all the individual [`Scalar`] and [`Vector`] values this composite is
3030
/// build out of and transform them into some other value. This is particularly useful for subgroup intrinsics sending
3131
/// data to other threads.
3232
///
33-
/// To derive `#[derive(VectorOrScalarComposite)]` on a struct, all members must also implement
34-
/// `VectorOrScalarComposite`.
33+
/// To derive `ScalarComposite` on a struct, all members must also implement `ScalarComposite`.
3534
///
36-
/// To derive it on an enum, the enum must implement `From<N>` and `Into<N>` where `N` is defined by the `#[repr(N)]`
37-
/// attribute on the enum and is an [`Integer`], like `u32`.
35+
/// To derive `ScalarComposite` on an enum, the enum must implement `From<N>` and `Into<N>` where `N` is defined by the
36+
/// `#[repr(N)]` attribute on the enum and must be an [`Integer`], like `u32`.
3837
/// Note that some [safe subgroup operations] may return an "undefined result", so your `From<N>` must gracefully handle
3938
/// arbitrary bit patterns being passed to it. While panicking is legal, it is discouraged as it may result in
4039
/// unexpected control flow.
4140
/// To implement these conversion traits, we recommend [`FromPrimitive`] and [`IntoPrimitive`] from the [`num_enum`]
42-
/// crate. [`FromPrimitive`] requires that either the enum is exhaustive, or you provide it with a variant to default
43-
/// to, by either implementing [`Default`] or marking a variant with `#[num_enum(default)]`. Note to disable default
41+
/// crate. [`FromPrimitive`] requires the enum to either be exhaustive or have a variant to default to, by either
42+
/// implementing [`Default`] or marking a variant with `#[num_enum(default)]`. Note to disable default
4443
/// features on the [`num_enum`] crate, or it won't compile on SPIR-V.
4544
///
4645
/// [`Integer`]: crate::Integer
47-
/// [subgroup operations]: crate::arch::subgroup_shuffle
46+
/// [safe subgroup operations]: crate::arch::subgroup_shuffle
4847
/// [`FromPrimitive`]: https://docs.rs/num_enum/latest/num_enum/derive.FromPrimitive.html
4948
/// [`IntoPrimitive`]: https://docs.rs/num_enum/latest/num_enum/derive.IntoPrimitive.html
5049
/// [`num_enum`]: https://crates.io/crates/num_enum
@@ -60,13 +59,13 @@ pub trait ScalarOrVectorTransform {
6059
/// transform a [`ScalarOrVector`]
6160
fn transform<T: ScalarOrVector>(&mut self, value: T) -> T;
6261

63-
/// transform a [`Scalar`], defaults to [`self.transform`]
62+
/// transform a [`Scalar`], defaults to [`Self::transform`]
6463
#[inline]
6564
fn transform_scalar<T: Scalar>(&mut self, value: T) -> T {
6665
self.transform(value)
6766
}
6867

69-
/// transform a [`Vector`], defaults to [`self.transform`]
68+
/// transform a [`Vector`], defaults to [`Self::transform`]
7069
#[inline]
7170
fn transform_vector<V: Vector<S, N>, S: Scalar, const N: usize>(&mut self, value: V) -> V {
7271
self.transform(value)

crates/spirv-std/src/vector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use glam::{Vec3Swizzles, Vec4Swizzles};
4545
/// # Safety
4646
/// * Must only be implemented on types that the spirv codegen emits as valid `OpTypeVector`. This includes all structs
4747
/// marked with `#[rust_gpu::vector::v1]`, like [`glam`]'s non-SIMD "scalar" vector types.
48-
/// * `VectorOrScalar::DIM == N`, since const equality is behind rustc feature `associated_const_equality`
48+
/// * `ScalarOrVector::DIM == N`, since const equality is behind rustc feature `associated_const_equality`
4949
// Note(@firestar99) I would like to have these two generics be associated types instead. Doesn't make much sense for
5050
// a vector type to implement this interface multiple times with different Scalar types or N, after all.
5151
// While it's possible with `T: Scalar`, it's not with `const N: usize`, since some impl blocks in `image::params` need

0 commit comments

Comments
 (0)