Skip to content

Commit 9889519

Browse files
committed
[core] Rename Varying::Local to UserDefined. Doc fixes.
In `wgpu_core::validation`, rename `Varying::Local` to `Varying::UserDefined`. This matches the terminology used in the WGSL specification. Add documentation for the `Varying` enum. There are no substantive code changes in this commit.
1 parent 7a65558 commit 9889519

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

wgpu-core/src/validation.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,26 @@ impl fmt::Display for InterfaceVar {
151151
}
152152
}
153153

154+
/// An [inter-stage input or output value][io].
155+
///
156+
/// A value of this type describes one value to be passed to or returned from
157+
/// some entry point.
158+
///
159+
/// [io]: https://www.w3.org/TR/WGSL/#stage-inputs-outputs
154160
#[derive(Debug, Eq, PartialEq)]
155161
enum Varying {
156-
Local { location: u32, iv: InterfaceVar },
162+
/// A [user-defined input or output][uio].
163+
///
164+
/// In WGSL, this is a value with a `@location` attribute.
165+
///
166+
/// [uio]: https://www.w3.org/TR/WGSL/#user-defined-inputs-outputs
167+
UserDefined { location: u32, iv: InterfaceVar },
168+
169+
/// A [built-in input or output][bio].
170+
///
171+
/// In WGSL, this is a value with a `@builtin` attribute.
172+
///
173+
/// [bio]: https://www.w3.org/TR/WGSL/#builtin-inputs-outputs
157174
BuiltIn(BuiltIn),
158175
}
159176

@@ -1177,7 +1194,7 @@ impl Interface {
11771194
sampling,
11781195
per_primitive,
11791196
blend_src: _,
1180-
}) => Varying::Local {
1197+
}) => Varying::UserDefined {
11811198
location,
11821199
iv: InterfaceVar {
11831200
ty: numeric_ty,
@@ -1609,7 +1626,7 @@ impl Interface {
16091626
// check inputs compatibility
16101627
for input in entry_point.inputs.iter() {
16111628
match *input {
1612-
Varying::Local { location, ref iv } => {
1629+
Varying::UserDefined { location, ref iv } => {
16131630
let result = inputs
16141631
.varyings
16151632
.get(&location)
@@ -1727,7 +1744,7 @@ impl Interface {
17271744

17281745
for output in entry_point.outputs.iter() {
17291746
match *output {
1730-
Varying::Local { ref iv, location } => {
1747+
Varying::UserDefined { ref iv, location } => {
17311748
if location > max_vertex_shader_output_location {
17321749
return Err(StageError::VertexOutputLocationTooLarge {
17331750
location,
@@ -1780,7 +1797,7 @@ impl Interface {
17801797
self.limits.max_inter_stage_shader_variables;
17811798

17821799
let deductions = entry_point.inputs.iter().filter_map(|output| match output {
1783-
Varying::Local { .. } => None,
1800+
Varying::UserDefined { .. } => None,
17841801
Varying::BuiltIn(builtin) => {
17851802
MaxFragmentShaderInputDeduction::from_inter_stage_builtin(builtin.to_naga())
17861803
.or_else(|| {
@@ -1807,7 +1824,7 @@ impl Interface {
18071824

18081825
for output in entry_point.inputs.iter() {
18091826
match *output {
1810-
Varying::Local { ref iv, location } => {
1827+
Varying::UserDefined { ref iv, location } => {
18111828
if location >= self.limits.max_inter_stage_shader_variables {
18121829
return Err(StageError::FragmentInputLocationTooLarge {
18131830
location,
@@ -1831,7 +1848,7 @@ impl Interface {
18311848
}
18321849

18331850
for output in &entry_point.outputs {
1834-
let &Varying::Local { location, ref iv } = output else {
1851+
let &Varying::UserDefined { location, ref iv } = output else {
18351852
continue;
18361853
};
18371854
if location >= self.limits.max_color_attachments {
@@ -1930,7 +1947,7 @@ impl Interface {
19301947
.outputs
19311948
.iter()
19321949
.filter_map(|output| match *output {
1933-
Varying::Local { location, ref iv } => Some((location, iv.clone())),
1950+
Varying::UserDefined { location, ref iv } => Some((location, iv.clone())),
19341951
Varying::BuiltIn(_) => None,
19351952
})
19361953
.collect();

0 commit comments

Comments
 (0)