Skip to content

Commit bd040ca

Browse files
committed
scalar or vector: reexport all Scalar traits in lib.rs, make mods private
apart from `mod float`, which contains functionality
1 parent 87f4f2d commit bd040ca

17 files changed

+41
-59
lines changed

crates/spirv-std/src/arch.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
//! These functions will typically map to a single instruction, and will perform
55
//! no additional safety checks beyond type-checking.
66
#[cfg(target_arch = "spirv")]
7-
use crate::integer::Integer;
8-
use crate::{
9-
integer::{SignedInteger, UnsignedInteger},
10-
scalar::Scalar,
11-
vector::Vector,
12-
};
7+
use crate::Integer;
8+
use crate::{Scalar, SignedInteger, UnsignedInteger, Vector};
139
#[cfg(target_arch = "spirv")]
1410
use core::arch::asm;
1511
use glam::UVec2;

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
#[cfg(target_arch = "spirv")]
22
use core::arch::asm;
33

4-
use crate::{
5-
float::Float,
6-
integer::{Integer, SignedInteger, UnsignedInteger},
7-
number::Number,
8-
};
4+
use crate::{Float, Integer, Number, SignedInteger, UnsignedInteger};
95

106
/// Atomically load through `ptr` using the given `SEMANTICS`. All subparts of
117
/// the value that is loaded are read atomically with respect to all other

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
use crate::VectorOrScalar;
12
#[cfg(target_arch = "spirv")]
23
use crate::arch::barrier;
3-
use crate::float::Float;
4-
use crate::integer::{Integer, SignedInteger, UnsignedInteger};
54
#[cfg(target_arch = "spirv")]
65
use crate::memory::{Scope, Semantics};
7-
use crate::vector::VectorOrScalar;
6+
use crate::{Float, Integer, SignedInteger, UnsignedInteger};
87
#[cfg(target_arch = "spirv")]
98
use core::arch::asm;
109

crates/spirv-std/src/image.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
//! Image types
22
3+
pub use self::params::{ImageCoordinate, ImageCoordinateSubpassData, ImageSizeQuery, SampleType};
34
#[cfg(target_arch = "spirv")]
4-
use crate::vector::VectorTruncateInto;
5+
use crate::VectorTruncateInto;
6+
pub use crate::macros::Image;
7+
use crate::{Float, Integer, Sampler, Vector};
58
#[cfg(target_arch = "spirv")]
69
use core::arch::asm;
7-
8-
mod params;
9-
10-
/// Contains extra image operands
11-
pub mod sample_with;
12-
13-
pub use self::params::{ImageCoordinate, ImageCoordinateSubpassData, ImageSizeQuery, SampleType};
14-
pub use crate::macros::Image;
10+
use sample_with::{NoneTy, SampleParams, SomeTy};
1511
pub use spirv_std_types::image_params::{
1612
AccessQualifier, Arrayed, Dimensionality, ImageDepth, ImageFormat, Multisampled, Sampled,
1713
};
1814

19-
use sample_with::{NoneTy, SampleParams, SomeTy};
15+
mod params;
2016

21-
use crate::{Sampler, float::Float, integer::Integer, vector::Vector};
17+
/// Contains extra image operands
18+
pub mod sample_with;
2219

2320
/// Re-export of primitive types to ensure the `Image` proc macro always points
2421
/// to the right type.

crates/spirv-std/src/image/params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{Arrayed, Dimensionality, ImageFormat};
2-
use crate::{integer::Integer, scalar::Scalar, vector::Vector, vector::VectorTruncateInto};
2+
use crate::{Integer, Scalar, Vector, VectorTruncateInto};
33

44
/// Marker trait for arguments that accept single scalar values or vectors
55
/// of scalars. Defines 2-, 3- and 4-component vector types based on the sample type.

crates/spirv-std/src/lib.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,29 @@ pub mod byte_addressable_buffer;
9494
pub mod float;
9595
pub mod image;
9696
pub mod indirect_command;
97-
pub mod integer;
97+
mod integer;
9898
pub mod matrix;
9999
pub mod memory;
100-
pub mod number;
100+
mod number;
101101
pub mod ray_tracing;
102102
mod runtime_array;
103103
mod sampler;
104-
pub mod scalar;
104+
mod scalar;
105105
pub(crate) mod sealed;
106106
mod typed_buffer;
107-
pub mod vector;
107+
mod vector;
108108

109109
pub use self::sampler::Sampler;
110110
pub use crate::macros::Image;
111111
pub use byte_addressable_buffer::ByteAddressableBuffer;
112+
pub use float::Float;
113+
pub use integer::*;
112114
pub use num_traits;
115+
pub use number::*;
113116
pub use runtime_array::*;
117+
pub use scalar::*;
114118
pub use typed_buffer::*;
119+
pub use vector::*;
115120

116121
pub use glam;
117122

@@ -136,11 +141,7 @@ pub fn debug_printf_assert_is_type<T>(ty: T) -> T {
136141
}
137142

138143
#[doc(hidden)]
139-
pub fn debug_printf_assert_is_vector<
140-
TY: crate::scalar::Scalar,
141-
V: crate::vector::Vector<TY, SIZE>,
142-
const SIZE: usize,
143-
>(
144+
pub fn debug_printf_assert_is_vector<TY: Scalar, V: Vector<TY, SIZE>, const SIZE: usize>(
144145
vec: V,
145146
) -> V {
146147
vec

crates/spirv-std/src/vector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Traits related to vectors.
22
3-
use crate::scalar::Scalar;
3+
use crate::Scalar;
44
use core::num::NonZeroUsize;
55
use glam::{Vec3Swizzles, Vec4Swizzles};
66

tests/compiletests/ui/arch/all.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// build-pass
22

3-
use core::num::NonZeroUsize;
43
use spirv_std::spirv;
5-
use spirv_std::{scalar::Scalar, vector::Vector, vector::VectorOrScalar};
64

75
#[spirv(fragment)]
86
pub fn main() {

tests/compiletests/ui/arch/any.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// build-pass
22

3-
use core::num::NonZeroUsize;
43
use spirv_std::spirv;
5-
use spirv_std::{scalar::Scalar, vector::Vector, vector::VectorOrScalar};
64

75
#[spirv(fragment)]
86
pub fn main() {

tests/compiletests/ui/arch/debug_printf_type_checking.stderr

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ LL | debug_printf!("%f", 11_u32);
7575
| |
7676
| this argument influences the return type of `debug_printf_assert_is_type`
7777
note: function defined here
78-
--> $SPIRV_STD_SRC/lib.rs:134:8
78+
--> $SPIRV_STD_SRC/lib.rs:139:8
7979
|
8080
LL | pub fn debug_printf_assert_is_type<T>(ty: T) -> T {
8181
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -103,7 +103,7 @@ LL | debug_printf!("%u", 11.0_f32);
103103
| |
104104
| this argument influences the return type of `debug_printf_assert_is_type`
105105
note: function defined here
106-
--> $SPIRV_STD_SRC/lib.rs:134:8
106+
--> $SPIRV_STD_SRC/lib.rs:139:8
107107
|
108108
LL | pub fn debug_printf_assert_is_type<T>(ty: T) -> T {
109109
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -131,13 +131,10 @@ LL | debug_printf!("%v2f", 11.0);
131131
`IVec3` implements `Vector<i32, 3>`
132132
and 8 others
133133
note: required by a bound in `debug_printf_assert_is_vector`
134-
--> $SPIRV_STD_SRC/lib.rs:141:8
134+
--> $SPIRV_STD_SRC/lib.rs:144:53
135135
|
136-
LL | pub fn debug_printf_assert_is_vector<
137-
| ----------------------------- required by a bound in this function
138-
LL | TY: crate::scalar::Scalar,
139-
LL | V: crate::vector::Vector<TY, SIZE>,
140-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `debug_printf_assert_is_vector`
136+
LL | pub fn debug_printf_assert_is_vector<TY: Scalar, V: Vector<TY, SIZE>, const SIZE: usize>(
137+
| ^^^^^^^^^^^^^^^^ required by this bound in `debug_printf_assert_is_vector`
141138
= note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info)
142139

143140
error[E0308]: mismatched types
@@ -157,7 +154,7 @@ LL | debug_printf!("%f", Vec2::splat(33.3));
157154
| |
158155
| this argument influences the return type of `debug_printf_assert_is_type`
159156
note: function defined here
160-
--> $SPIRV_STD_SRC/lib.rs:134:8
157+
--> $SPIRV_STD_SRC/lib.rs:139:8
161158
|
162159
LL | pub fn debug_printf_assert_is_type<T>(ty: T) -> T {
163160
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)