Skip to content

Commit 2025952

Browse files
committed
Comment fixes.
Mostly by wrapping long comments 100 chars, because lines longer than that are hard to read when you have a 100-char window.
1 parent f86ecf9 commit 2025952

File tree

17 files changed

+161
-110
lines changed

17 files changed

+161
-110
lines changed

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,9 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
527527
.into_iter()
528528
.collect::<proc_macro2::TokenStream>();
529529
let op_loads = op_loads.into_iter().collect::<proc_macro2::TokenStream>();
530-
// Escapes the '{' and '}' characters in the format string.
531-
// Since the `asm!` macro expects '{' '}' to surround its arguments, we have to use '{{' and '}}' instead.
532-
// The `asm!` macro will then later turn them back into '{' and '}'.
530+
// Escapes the '{' and '}' characters in the format string. Since the `asm!` macro expects '{'
531+
// '}' to surround its arguments, we have to use '{{' and '}}' instead. The `asm!` macro will
532+
// then later turn them back into '{' and '}'.
533533
let format_string = format_string.replace('{', "{{").replace('}', "}}");
534534

535535
let op_string = format!("%string = OpString {format_string:?}");
@@ -567,8 +567,8 @@ impl SampleImplRewriter {
567567
let mut new_impl = f.clone();
568568
let mut ty_str = String::from("SampleParams<");
569569

570-
// based on the mask, form a `SampleParams` type string and add the generic parameters to the `impl<>` generics
571-
// example type string: `"SampleParams<SomeTy<B>, NoneTy, NoneTy>"`
570+
// based on the mask, form a `SampleParams` type string and add the generic parameters to
571+
// the `impl<>` generics example type string: `"SampleParams<SomeTy<B>, NoneTy, NoneTy>"`
572572
for i in 0..SAMPLE_PARAM_COUNT {
573573
if mask & (1 << i) != 0 {
574574
new_impl.generics.params.push(syn::GenericParam::Type(
@@ -600,7 +600,8 @@ impl SampleImplRewriter {
600600
new_impl
601601
}
602602

603-
// generates an operands string for use in the assembly, e.g. "Bias %bias Lod %lod", based on the mask
603+
// Generates an operands string for use in the assembly, e.g. "Bias %bias Lod %lod", based on
604+
// the mask.
604605
#[allow(clippy::needless_range_loop)]
605606
fn get_operands(&self) -> String {
606607
let mut op = String::new();
@@ -619,7 +620,7 @@ impl SampleImplRewriter {
619620
op
620621
}
621622

622-
// generates list of assembly loads for the data, e.g. "%bias = OpLoad _ {bias}", etc.
623+
// Generates list of assembly loads for the data, e.g. "%bias = OpLoad _ {bias}", etc.
623624
#[allow(clippy::needless_range_loop)]
624625
fn add_loads(&self, t: &mut Vec<TokenTree>) {
625626
for i in 0..SAMPLE_PARAM_COUNT {
@@ -651,7 +652,8 @@ impl SampleImplRewriter {
651652
}
652653
}
653654

654-
// generates list of register specifications, e.g. `bias = in(reg) &params.bias.0, ...` as separate tokens
655+
// Generates list of register specifications, e.g. `bias = in(reg) &params.bias.0, ...` as
656+
// separate tokens.
655657
#[allow(clippy::needless_range_loop)]
656658
fn add_regs(&self, t: &mut Vec<TokenTree>) {
657659
for i in 0..SAMPLE_PARAM_COUNT {
@@ -674,7 +676,8 @@ impl SampleImplRewriter {
674676

675677
impl VisitMut for SampleImplRewriter {
676678
fn visit_impl_item_fn_mut(&mut self, item: &mut ImplItemFn) {
677-
// rewrite the last parameter of this method to be of type `SampleParams<...>` we generated earlier
679+
// rewrite the last parameter of this method to be of type `SampleParams<...>` we generated
680+
// earlier
678681
if let Some(syn::FnArg::Typed(p)) = item.sig.inputs.last_mut() {
679682
*p.ty.as_mut() = self.1.clone();
680683
}

crates/spirv-std/src/arch.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub unsafe fn vector_insert_dynamic<T: Scalar, V: Vector<T, N>, const N: usize>(
136136
}
137137
}
138138

139-
/// Fragment-shader discard. Equivalvent to `discard()` from GLSL
139+
/// Fragment-shader discard. Equivalent to `discard()` from GLSL
140140
///
141141
/// Ceases all further processing in any invocation that executes it: Only
142142
/// instructions these invocations executed before [kill] have observable side
@@ -213,27 +213,31 @@ unsafe fn call_glsl_op_with_ints<T: Integer, const OP: u32>(a: T, b: T) -> T {
213213
}
214214

215215
/// Compute the minimum of two unsigned integers via a GLSL extended instruction.
216+
/// <https://registry.khronos.org/SPIR-V/specs/1.0/GLSL.std.450.html>
216217
#[spirv_std_macros::gpu_only]
217218
pub fn unsigned_min<T: UnsignedInteger>(a: T, b: T) -> T {
218-
unsafe { call_glsl_op_with_ints::<_, 38>(a, b) }
219+
unsafe { call_glsl_op_with_ints::<_, /* UMin */ 38>(a, b) }
219220
}
220221

221222
/// Compute the maximum of two unsigned integers via a GLSL extended instruction.
223+
/// <https://registry.khronos.org/SPIR-V/specs/1.0/GLSL.std.450.html>
222224
#[spirv_std_macros::gpu_only]
223225
pub fn unsigned_max<T: UnsignedInteger>(a: T, b: T) -> T {
224-
unsafe { call_glsl_op_with_ints::<_, 41>(a, b) }
226+
unsafe { call_glsl_op_with_ints::<_, /* UMax */ 41>(a, b) }
225227
}
226228

227229
/// Compute the minimum of two signed integers via a GLSL extended instruction.
230+
/// <https://registry.khronos.org/SPIR-V/specs/1.0/GLSL.std.450.html>
228231
#[spirv_std_macros::gpu_only]
229232
pub fn signed_min<T: SignedInteger>(a: T, b: T) -> T {
230-
unsafe { call_glsl_op_with_ints::<_, 39>(a, b) }
233+
unsafe { call_glsl_op_with_ints::<_, /* SMin */ 39>(a, b) }
231234
}
232235

233236
/// Compute the maximum of two signed integers via a GLSL extended instruction.
237+
/// <https://registry.khronos.org/SPIR-V/specs/1.0/GLSL.std.450.html>
234238
#[spirv_std_macros::gpu_only]
235239
pub fn signed_max<T: SignedInteger>(a: T, b: T) -> T {
236-
unsafe { call_glsl_op_with_ints::<_, 42>(a, b) }
240+
unsafe { call_glsl_op_with_ints::<_, /* SMax */ 42>(a, b) }
237241
}
238242

239243
/// Index into an array without bounds checking.
@@ -244,12 +248,16 @@ pub trait IndexUnchecked<T> {
244248
/// Returns a reference to the element at `index`. The equivalent of `get_unchecked`.
245249
///
246250
/// # Safety
247-
/// Behavior is undefined if the `index` value is greater than or equal to the length of the array.
251+
/// Behavior is undefined if the `index` value is greater than or equal to the length of the
252+
/// array.
248253
unsafe fn index_unchecked(&self, index: usize) -> &T;
249-
/// Returns a mutable reference to the element at `index`. The equivalent of `get_unchecked_mut`.
254+
255+
/// Returns a mutable reference to the element at `index`. The equivalent of
256+
/// `get_unchecked_mut`.
250257
///
251258
/// # Safety
252-
/// Behavior is undefined if the `index` value is greater than or equal to the length of the array.
259+
/// Behavior is undefined if the `index` value is greater than or equal to the length of the
260+
/// array.
253261
unsafe fn index_unchecked_mut(&mut self, index: usize) -> &mut T;
254262
}
255263

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use core::arch::asm;
1414
/// client API.
1515
///
1616
/// If [`crate::memory::Semantics`] is not [`crate::memory::Semantics::NONE`],
17-
/// this instruction also serves as an [`memory_barrier`] function call, and
17+
/// this instruction also serves as a [`memory_barrier`] function call, and
1818
/// also performs and adheres to the description and semantics of an
1919
/// [`memory_barrier`] function with the same `MEMORY` and `SEMANTICS` operands.
2020
/// This allows atomically specifying both a control barrier and a memory
@@ -103,11 +103,13 @@ pub fn workgroup_memory_barrier() {
103103
>();
104104
}
105105

106-
/// Blocks execution of all threads in a group until all group shared accesses have been completed and all threads in the group have reached this call.
106+
/// Blocks execution of all threads in a group until all group shared accesses have been completed
107+
/// and all threads in the group have reached this call.
107108
///
108109
/// This is an exact implementation of `GroupMemoryBarrierWithGroupSync()`.
109110
///
110-
/// From <https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/groupmemorybarrierwithgroupsync>
111+
/// From
112+
/// <https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/groupmemorybarrierwithgroupsync>
111113
#[spirv_std_macros::gpu_only]
112114
#[inline]
113115
pub fn workgroup_memory_barrier_with_group_sync() {

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

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

4-
/// Demote fragment shader invocation to a helper invocation. Equivalvent to
4+
/// Demote fragment shader invocation to a helper invocation. Equivalent to
55
/// `discard()` in HLSL. Any stores to memory after this instruction are
66
/// suppressed and the fragment does not write outputs to the framebuffer.
77
///

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

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ macro_rules! deriv_fn {
2121
/// Types that can be derived by partial derivatives
2222
///
2323
/// # Safety
24-
/// Result Type must be a scalar or vector of floating-point type using the IEEE 754 encoding. The component width must be 32 bits.
24+
/// Result Type must be a scalar or vector of floating-point type using the IEEE 754 encoding. The
25+
/// component width must be 32 bits.
2526
pub unsafe trait Derivative: Sealed + Default {
26-
/// Result is the partial derivative of `Self` with respect to the window x coordinate. Uses local differencing
27-
/// based on the value of `Self`. Same result as either [`Self::dfdx_fine`] or [`Self::dfdx_coarse`] on `Self`. Selection of which
28-
/// one is based on external factors.
27+
/// Result is the partial derivative of `Self` with respect to the window x coordinate. Uses
28+
/// local differencing based on the value of `Self`. Same result as either [`Self::dfdx_fine`]
29+
/// or [`Self::dfdx_coarse`] on `Self`. Selection of which one is based on external factors.
2930
///
30-
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
31-
/// derivative group have executed all dynamic instances that are program-ordered before X'.
31+
/// An invocation will not execute a dynamic instance of this instruction (X') until all
32+
/// invocations in its derivative group have executed all dynamic instances that are
33+
/// program-ordered before X'.
3234
///
3335
/// This instruction is only valid in the Fragment Execution Model.
3436
#[crate::macros::gpu_only]
@@ -37,11 +39,13 @@ pub unsafe trait Derivative: Sealed + Default {
3739
deriv_fn!(OpDPdx, self)
3840
}
3941

40-
/// Result is the partial derivative of `Self` with respect to the window x coordinate. Uses local differencing
41-
/// based on the value of `Self` for the current fragment and its immediate neighbor(s).
42+
/// Result is the partial derivative of `Self` with respect to the window x coordinate. Uses
43+
/// local differencing based on the value of `Self` for the current fragment and its immediate
44+
/// neighbor(s).
4245
///
43-
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
44-
/// derivative group have executed all dynamic instances that are program-ordered before X'.
46+
/// An invocation will not execute a dynamic instance of this instruction (X') until all
47+
/// invocations in its derivative group have executed all dynamic instances that are
48+
/// program-ordered before X'.
4549
///
4650
/// This instruction is only valid in the Fragment Execution Model.
4751
#[crate::macros::gpu_only]
@@ -50,13 +54,15 @@ pub unsafe trait Derivative: Sealed + Default {
5054
deriv_fn!(OpDPdxFine, self)
5155
}
5256

53-
/// Result is the partial derivative of `Self` with respect to the window x coordinate. Uses local differencing
54-
/// based on the value of `Self` for the current fragment’s neighbors, and possibly, but not necessarily, includes
55-
/// the value of `Self` for the current fragment. That is, over a given area, the implementation can compute x
56-
/// derivatives in fewer unique locations than would be allowed for [`Self::dfdx_fine`].
57+
/// Result is the partial derivative of `Self` with respect to the window x coordinate. Uses
58+
/// local differencing based on the value of `Self` for the current fragment’s neighbors, and
59+
/// possibly, but not necessarily, includes the value of `Self` for the current fragment. That
60+
/// is, over a given area, the implementation can compute x derivatives in fewer unique
61+
/// locations than would be allowed for [`Self::dfdx_fine`].
5762
///
58-
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
59-
/// derivative group have executed all dynamic instances that are program-ordered before X'.
63+
/// An invocation will not execute a dynamic instance of this instruction (X') until all
64+
/// invocations in its derivative group have executed all dynamic instances that are
65+
/// program-ordered before X'.
6066
///
6167
/// This instruction is only valid in the Fragment Execution Model.
6268
#[crate::macros::gpu_only]
@@ -65,12 +71,13 @@ pub unsafe trait Derivative: Sealed + Default {
6571
deriv_fn!(OpDPdxCoarse, self)
6672
}
6773

68-
/// Result is the partial derivative of `Self` with respect to the window y coordinate. Uses local differencing
69-
/// based on the value of `Self`. Same result as either [`Self::dfdy_fine`] or [`Self::dfdy_coarse`] on `Self`. Selection of which
70-
/// one is based on external factors.
74+
/// Result is the partial derivative of `Self` with respect to the window y coordinate. Uses
75+
/// local differencing based on the value of `Self`. Same result as either [`Self::dfdy_fine`]
76+
/// or [`Self::dfdy_coarse`] on `Self`. Selection of which one is based on external factors.
7177
///
72-
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
73-
/// derivative group have executed all dynamic instances that are program-ordered before X'.
78+
/// An invocation will not execute a dynamic instance of this instruction (X') until all
79+
/// invocations in its derivative group have executed all dynamic instances that are
80+
/// program-ordered before X'.
7481
///
7582
/// This instruction is only valid in the Fragment Execution Model.
7683
#[crate::macros::gpu_only]
@@ -79,11 +86,13 @@ pub unsafe trait Derivative: Sealed + Default {
7986
deriv_fn!(OpDPdy, self)
8087
}
8188

82-
/// Result is the partial derivative of `Self` with respect to the window y coordinate. Uses local differencing
83-
/// based on the value of `Self` for the current fragment and its immediate neighbor(s).
89+
/// Result is the partial derivative of `Self` with respect to the window y coordinate. Uses
90+
/// local differencing based on the value of `Self` for the current fragment and its immediate
91+
/// neighbor(s).
8492
///
85-
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
86-
/// derivative group have executed all dynamic instances that are program-ordered before X'.
93+
/// An invocation will not execute a dynamic instance of this instruction (X') until all
94+
/// invocations in its derivative group have executed all dynamic instances that are
95+
/// program-ordered before X'.
8796
///
8897
/// This instruction is only valid in the Fragment Execution Model.
8998
#[crate::macros::gpu_only]
@@ -92,13 +101,15 @@ pub unsafe trait Derivative: Sealed + Default {
92101
deriv_fn!(OpDPdyFine, self)
93102
}
94103

95-
/// Result is the partial derivative of `Self` with respect to the window y coordinate. Uses local differencing
96-
/// based on the value of `Self` for the current fragment’s neighbors, and possibly, but not necessarily, includes
97-
/// the value of `Self` for the current fragment. That is, over a given area, the implementation can compute y
98-
/// derivatives in fewer unique locations than would be allowed for [`Self::dfdy_fine`].
104+
/// Result is the partial derivative of `Self` with respect to the window y coordinate. Uses
105+
/// local differencing based on the value of `Self` for the current fragment’s neighbors, and
106+
/// possibly, but not necessarily, includes the value of `Self` for the current fragment. That
107+
/// is, over a given area, the implementation can compute y derivatives in fewer unique
108+
/// locations than would be allowed for [`Self::dfdy_fine`].
99109
///
100-
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
101-
/// derivative group have executed all dynamic instances that are program-ordered before X'.
110+
/// An invocation will not execute a dynamic instance of this instruction (X') until all
111+
/// invocations in its derivative group have executed all dynamic instances that are
112+
/// program-ordered before X'.
102113
///
103114
/// This instruction is only valid in the Fragment Execution Model.
104115
#[crate::macros::gpu_only]
@@ -107,10 +118,12 @@ pub unsafe trait Derivative: Sealed + Default {
107118
deriv_fn!(OpDPdyCoarse, self)
108119
}
109120

110-
/// Result is the same as computing the sum of the absolute values of [`Self::dfdx`] and [`Self::dfdy`] on P.
121+
/// Result is the same as computing the sum of the absolute values of [`Self::dfdx`] and
122+
/// [`Self::dfdy`] on P.
111123
///
112-
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
113-
/// derivative group have executed all dynamic instances that are program-ordered before X'.
124+
/// An invocation will not execute a dynamic instance of this instruction (X') until all
125+
/// invocations in its derivative group have executed all dynamic instances that are
126+
/// program-ordered before X'.
114127
///
115128
/// This instruction is only valid in the Fragment Execution Model.
116129
#[crate::macros::gpu_only]
@@ -119,10 +132,12 @@ pub unsafe trait Derivative: Sealed + Default {
119132
deriv_fn!(OpFwidth, self)
120133
}
121134

122-
/// Result is the same as computing the sum of the absolute values of [`Self::dfdx_fine`] and [`Self::dfdy_fine`] on P.
135+
/// Result is the same as computing the sum of the absolute values of [`Self::dfdx_fine`] and
136+
/// [`Self::dfdy_fine`] on P.
123137
///
124-
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
125-
/// derivative group have executed all dynamic instances that are program-ordered before X'.
138+
/// An invocation will not execute a dynamic instance of this instruction (X') until all
139+
/// invocations in its derivative group have executed all dynamic instances that are
140+
/// program-ordered before X'.
126141
///
127142
/// This instruction is only valid in the Fragment Execution Model.
128143
#[crate::macros::gpu_only]
@@ -131,10 +146,12 @@ pub unsafe trait Derivative: Sealed + Default {
131146
deriv_fn!(OpFwidthFine, self)
132147
}
133148

134-
/// Result is the same as computing the sum of the absolute values of [`Self::dfdx_coarse`] and [`Self::dfdy_coarse`] on P.
149+
/// Result is the same as computing the sum of the absolute values of [`Self::dfdx_coarse`] and
150+
/// [`Self::dfdy_coarse`] on P.
135151
///
136-
/// An invocation will not execute a dynamic instance of this instruction (X') until all invocations in its
137-
/// derivative group have executed all dynamic instances that are program-ordered before X'.
152+
/// An invocation will not execute a dynamic instance of this instruction (X') until all
153+
/// invocations in its derivative group have executed all dynamic instances that are
154+
/// program-ordered before X'.
138155
///
139156
/// This instruction is only valid in the Fragment Execution Model.
140157
#[crate::macros::gpu_only]

0 commit comments

Comments
 (0)