Skip to content

Commit 77708a3

Browse files
committed
ScalarComposite: rename ScalarOrVectorComposite to ScalarComposite, bulk rename
1 parent 7c73d49 commit 77708a3

15 files changed

+64
-66
lines changed

crates/spirv-std/macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ pub fn gen_sample_param_permutations(_attr: TokenStream, item: TokenStream) -> T
313313
sample_param_permutations::gen_sample_param_permutations(item)
314314
}
315315

316-
#[proc_macro_derive(ScalarOrVectorComposite)]
316+
#[proc_macro_derive(ScalarComposite)]
317317
pub fn derive_scalar_or_vector_composite(item: TokenStream) -> TokenStream {
318318
scalar_or_vector_composite::derive(item.into())
319319
.unwrap_or_else(syn::Error::into_compile_error)

crates/spirv-std/macros/src/scalar_or_vector_composite.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn derive(item: TokenStream) -> syn::Result<TokenStream> {
3535
let where_clause = &item.generics.where_clause;
3636

3737
Ok(quote! {
38-
impl<#gens> #spirv_std::ScalarOrVectorComposite for #ident<#gen_refs> #where_clause {
38+
impl<#gens> #spirv_std::ScalarComposite for #ident<#gen_refs> #where_clause {
3939
#[inline]
4040
fn transform<F: #spirv_std::ScalarOrVectorTransform>(self, f: &mut F) -> Self {
4141
#content
@@ -51,7 +51,7 @@ pub fn derive_struct(spirv_std: &TokenStream, data: &DataStruct) -> syn::Result<
5151
.iter()
5252
.map(|f| {
5353
let ident = &f.ident;
54-
quote!(#ident: #spirv_std::ScalarOrVectorComposite::transform(self.#ident, f))
54+
quote!(#ident: #spirv_std::ScalarComposite::transform(self.#ident, f))
5555
})
5656
.collect::<Punctuated<_, Token![,]>>();
5757
quote!(Self { #content })
@@ -60,7 +60,7 @@ pub fn derive_struct(spirv_std: &TokenStream, data: &DataStruct) -> syn::Result<
6060
let content = (0..unnamed.len())
6161
.map(|i| {
6262
let i = syn::Index::from(i);
63-
quote!(#spirv_std::ScalarOrVectorComposite::transform(self.#i, f))
63+
quote!(#spirv_std::ScalarComposite::transform(self.#i, f))
6464
})
6565
.collect::<Punctuated<_, Token![,]>>();
6666
quote!(Self(#content))
@@ -85,6 +85,6 @@ pub fn derive_enum(spirv_std: &TokenStream, item: &DeriveInput) -> syn::Result<T
8585
let prim = &repr.meta.require_list()?.tokens;
8686
Ok(quote! {
8787
#spirv_std::assert_is_integer::<#prim>();
88-
<Self as From<#prim>>::from(#spirv_std::ScalarOrVectorComposite::transform(<Self as Into<#prim>>::into(self), f))
88+
<Self as From<#prim>>::from(#spirv_std::ScalarComposite::transform(<Self as Into<#prim>>::into(self), f))
8989
})
9090
}

crates/spirv-std/src/arch/subgroup.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ use crate::ScalarOrVectorTransform;
44
use crate::arch::{asm, barrier};
55
#[cfg(target_arch = "spirv")]
66
use crate::memory::{Scope, Semantics};
7-
use crate::{
8-
Float, Integer, ScalarOrVector, ScalarOrVectorComposite, SignedInteger, UnsignedInteger,
9-
};
7+
use crate::{Float, Integer, ScalarComposite, ScalarOrVector, SignedInteger, UnsignedInteger};
108

119
#[cfg(target_arch = "spirv")]
1210
const SUBGROUP: u32 = Scope::Subgroup as u32;
@@ -244,7 +242,7 @@ pub fn subgroup_any(predicate: bool) -> bool {
244242
#[spirv_std_macros::gpu_only]
245243
#[doc(alias = "OpGroupNonUniformAllEqual")]
246244
#[inline]
247-
pub fn subgroup_all_equal<T: ScalarOrVectorComposite>(value: T) -> bool {
245+
pub fn subgroup_all_equal<T: ScalarComposite>(value: T) -> bool {
248246
struct Transform(bool);
249247

250248
impl ScalarOrVectorTransform for Transform {
@@ -299,7 +297,7 @@ pub fn subgroup_all_equal<T: ScalarOrVectorComposite>(value: T) -> bool {
299297
#[spirv_std_macros::gpu_only]
300298
#[doc(alias = "OpGroupNonUniformBroadcast")]
301299
#[inline]
302-
pub unsafe fn subgroup_broadcast<T: ScalarOrVectorComposite>(value: T, id: u32) -> T {
300+
pub unsafe fn subgroup_broadcast<T: ScalarComposite>(value: T, id: u32) -> T {
303301
struct Transform {
304302
id: u32,
305303
}
@@ -390,7 +388,7 @@ pub unsafe fn subgroup_broadcast_const<T: ScalarOrVector, const ID: u32>(value:
390388
#[spirv_std_macros::gpu_only]
391389
#[doc(alias = "OpGroupNonUniformBroadcastFirst")]
392390
#[inline]
393-
pub fn subgroup_broadcast_first<T: ScalarOrVectorComposite>(value: T) -> T {
391+
pub fn subgroup_broadcast_first<T: ScalarComposite>(value: T) -> T {
394392
struct Transform;
395393

396394
impl ScalarOrVectorTransform for Transform {
@@ -672,7 +670,7 @@ pub fn subgroup_ballot_find_msb(value: SubgroupMask) -> u32 {
672670
#[spirv_std_macros::gpu_only]
673671
#[doc(alias = "OpGroupNonUniformShuffle")]
674672
#[inline]
675-
pub fn subgroup_shuffle<T: ScalarOrVectorComposite>(value: T, id: u32) -> T {
673+
pub fn subgroup_shuffle<T: ScalarComposite>(value: T, id: u32) -> T {
676674
struct Transform {
677675
id: u32,
678676
}
@@ -722,7 +720,7 @@ pub fn subgroup_shuffle<T: ScalarOrVectorComposite>(value: T, id: u32) -> T {
722720
#[spirv_std_macros::gpu_only]
723721
#[doc(alias = "OpGroupNonUniformShuffleXor")]
724722
#[inline]
725-
pub fn subgroup_shuffle_xor<T: ScalarOrVectorComposite>(value: T, mask: u32) -> T {
723+
pub fn subgroup_shuffle_xor<T: ScalarComposite>(value: T, mask: u32) -> T {
726724
struct Transform {
727725
mask: u32,
728726
}
@@ -772,7 +770,7 @@ pub fn subgroup_shuffle_xor<T: ScalarOrVectorComposite>(value: T, mask: u32) ->
772770
#[spirv_std_macros::gpu_only]
773771
#[doc(alias = "OpGroupNonUniformShuffleUp")]
774772
#[inline]
775-
pub fn subgroup_shuffle_up<T: ScalarOrVectorComposite>(value: T, delta: u32) -> T {
773+
pub fn subgroup_shuffle_up<T: ScalarComposite>(value: T, delta: u32) -> T {
776774
struct Transform {
777775
delta: u32,
778776
}
@@ -822,7 +820,7 @@ pub fn subgroup_shuffle_up<T: ScalarOrVectorComposite>(value: T, delta: u32) ->
822820
#[spirv_std_macros::gpu_only]
823821
#[doc(alias = "OpGroupNonUniformShuffleDown")]
824822
#[inline]
825-
pub fn subgroup_shuffle_down<T: ScalarOrVectorComposite>(value: T, delta: u32) -> T {
823+
pub fn subgroup_shuffle_down<T: ScalarComposite>(value: T, delta: u32) -> T {
826824
struct Transform {
827825
delta: u32,
828826
}
@@ -1458,7 +1456,7 @@ Requires Capability `GroupNonUniformArithmetic` and `GroupNonUniformClustered`.
14581456
#[spirv_std_macros::gpu_only]
14591457
#[doc(alias = "OpGroupNonUniformQuadBroadcast")]
14601458
#[inline]
1461-
pub fn subgroup_quad_broadcast<T: ScalarOrVectorComposite>(value: T, index: u32) -> T {
1459+
pub fn subgroup_quad_broadcast<T: ScalarComposite>(value: T, index: u32) -> T {
14621460
struct Transform {
14631461
index: u32,
14641462
}
@@ -1550,7 +1548,7 @@ pub enum QuadDirection {
15501548
#[spirv_std_macros::gpu_only]
15511549
#[doc(alias = "OpGroupNonUniformQuadSwap")]
15521550
#[inline]
1553-
pub fn subgroup_quad_swap<const DIRECTION: u32, T: ScalarOrVectorComposite>(value: T) -> T {
1551+
pub fn subgroup_quad_swap<const DIRECTION: u32, T: ScalarComposite>(value: T) -> T {
15541552
struct Transform<const DIRECTION: u32>;
15551553

15561554
impl<const DIRECTION: u32> ScalarOrVectorTransform for Transform<DIRECTION> {

crates/spirv-std/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
/// Public re-export of the `spirv-std-macros` crate.
8888
#[macro_use]
8989
pub extern crate spirv_std_macros as macros;
90-
pub use macros::ScalarOrVectorComposite;
90+
pub use macros::ScalarComposite;
9191
pub use macros::spirv;
9292
pub use macros::{debug_printf, debug_printfln};
9393

crates/spirv-std/src/scalar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Traits related to scalars.
22
33
use crate::sealed::Sealed;
4-
use crate::{ScalarOrVector, ScalarOrVectorComposite, ScalarOrVectorTransform};
4+
use crate::{ScalarComposite, ScalarOrVector, ScalarOrVectorTransform};
55
use core::num::NonZeroUsize;
66

77
/// Abstract trait representing a SPIR-V scalar type, which includes:
@@ -61,7 +61,7 @@ pub unsafe trait Float: num_traits::Float + Number {
6161
macro_rules! impl_scalar {
6262
(impl Scalar for $ty:ty;) => {
6363
impl Sealed for $ty {}
64-
impl ScalarOrVectorComposite for $ty {
64+
impl ScalarComposite for $ty {
6565
#[inline]
6666
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self {
6767
f.transform_scalar(self)

crates/spirv-std/src/scalar_or_vector.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub(crate) mod sealed {
1111
///
1212
/// # Safety
1313
/// Your type must also implement [`Scalar`] or [`Vector`], see their safety sections as well.
14-
pub unsafe trait ScalarOrVector: ScalarOrVectorComposite + Default {
14+
pub unsafe trait ScalarOrVector: ScalarComposite + Default {
1515
/// Either the scalar component type of the vector or the scalar itself.
1616
type Scalar: Scalar;
1717

@@ -48,14 +48,14 @@ pub unsafe trait ScalarOrVector: ScalarOrVectorComposite + Default {
4848
/// [`FromPrimitive`]: https://docs.rs/num_enum/latest/num_enum/derive.FromPrimitive.html
4949
/// [`IntoPrimitive`]: https://docs.rs/num_enum/latest/num_enum/derive.IntoPrimitive.html
5050
/// [`num_enum`]: https://crates.io/crates/num_enum
51-
pub trait ScalarOrVectorComposite: Copy + Send + Sync + 'static {
51+
pub trait ScalarComposite: Copy + Send + Sync + 'static {
5252
/// Transform the individual [`Scalar`] and [`Vector`] values of this type to a different value.
5353
///
5454
/// See [`Self`] for more detail.
5555
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self;
5656
}
5757

58-
/// A transform operation for [`ScalarOrVectorComposite::transform`]
58+
/// A transform operation for [`ScalarComposite::transform`]
5959
pub trait ScalarOrVectorTransform {
6060
/// transform a [`ScalarOrVector`]
6161
fn transform<T: ScalarOrVector>(&mut self, value: T) -> T;
@@ -74,7 +74,7 @@ pub trait ScalarOrVectorTransform {
7474
}
7575

7676
/// `Default` is unfortunately necessary until rust-gpu improves
77-
impl<T: ScalarOrVectorComposite + Default, const N: usize> ScalarOrVectorComposite for [T; N] {
77+
impl<T: ScalarComposite + Default, const N: usize> ScalarComposite for [T; N] {
7878
#[inline]
7979
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self {
8080
let mut out = [T::default(); N];

crates/spirv-std/src/vector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Traits related to vectors.
22
33
use crate::sealed::Sealed;
4-
use crate::{Scalar, ScalarOrVector, ScalarOrVectorComposite, ScalarOrVectorTransform};
4+
use crate::{Scalar, ScalarComposite, ScalarOrVector, ScalarOrVectorTransform};
55
use core::num::NonZeroUsize;
66
use glam::{Vec3Swizzles, Vec4Swizzles};
77

@@ -57,7 +57,7 @@ macro_rules! impl_vector {
5757
($($ty:ty: [$scalar:ty; $n:literal];)+) => {
5858
$(
5959
impl Sealed for $ty {}
60-
impl ScalarOrVectorComposite for $ty {
60+
impl ScalarComposite for $ty {
6161
#[inline]
6262
fn transform<F: ScalarOrVectorTransform>(self, f: &mut F) -> Self {
6363
f.transform_vector(self)

tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_0_fail.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: evaluation panicked: `ClusterSize` must be at least 1
2-
--> $SPIRV_STD_SRC/arch/subgroup.rs:939:1
2+
--> $SPIRV_STD_SRC/arch/subgroup.rs:937:1
33
|
44
LL | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r"
55
LL | | An integer add group operation of all `value` operands contributed by active invocations in the group.
@@ -13,7 +13,7 @@ LL | | ");
1313
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `macro_subgroup_op_clustered` (in Nightly builds, run with -Z macro-backtrace for more info)
1414

1515
note: erroneous constant encountered
16-
--> $SPIRV_STD_SRC/arch/subgroup.rs:939:1
16+
--> $SPIRV_STD_SRC/arch/subgroup.rs:937:1
1717
|
1818
LL | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r"
1919
LL | | An integer add group operation of all `value` operands contributed by active invocations in the group.

tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_non_power_of_two_fail.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: evaluation panicked: `ClusterSize` must be a power of 2
2-
--> $SPIRV_STD_SRC/arch/subgroup.rs:939:1
2+
--> $SPIRV_STD_SRC/arch/subgroup.rs:937:1
33
|
44
LL | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r"
55
LL | | An integer add group operation of all `value` operands contributed by active invocations in the group.
@@ -13,7 +13,7 @@ LL | | ");
1313
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `macro_subgroup_op_clustered` (in Nightly builds, run with -Z macro-backtrace for more info)
1414

1515
note: erroneous constant encountered
16-
--> $SPIRV_STD_SRC/arch/subgroup.rs:939:1
16+
--> $SPIRV_STD_SRC/arch/subgroup.rs:937:1
1717
|
1818
LL | / macro_subgroup_op_clustered!(impl Integer, "OpGroupNonUniformIAdd", subgroup_clustered_i_add; r"
1919
LL | | An integer add group operation of all `value` operands contributed by active invocations in the group.

tests/compiletests/ui/arch/subgroup/subgroup_composite.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@
1010
// ignore-spv1.4
1111

1212
use glam::*;
13-
use spirv_std::ScalarOrVectorComposite;
13+
use spirv_std::ScalarComposite;
1414
use spirv_std::arch::*;
1515
use spirv_std::spirv;
1616

17-
#[derive(Copy, Clone, ScalarOrVectorComposite)]
17+
#[derive(Copy, Clone, ScalarComposite)]
1818
pub struct MyStruct {
1919
a: f32,
2020
b: UVec3,
2121
c: Nested,
2222
d: Zst,
2323
}
2424

25-
#[derive(Copy, Clone, ScalarOrVectorComposite)]
25+
#[derive(Copy, Clone, ScalarComposite)]
2626
pub struct Nested(i32);
2727

28-
#[derive(Copy, Clone, ScalarOrVectorComposite)]
28+
#[derive(Copy, Clone, ScalarComposite)]
2929
pub struct Zst;
3030

3131
#[spirv(compute(threads(32)))]

0 commit comments

Comments
 (0)