Skip to content

Commit

Permalink
Adds GatherMode::Shuffle, GatherMode::ShuffleDown, GatherMode::Shuffl…
Browse files Browse the repository at this point in the history
…eUp, GatherMode::ShuffleXor.
  • Loading branch information
Lichtso committed Oct 14, 2023
1 parent 7008d27 commit b41cce8
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/back/spv/subgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ impl<'w> BlockContext<'w> {
arg_id,
));
}
crate::GatherMode::Shuffle(index)
| crate::GatherMode::ShuffleDown(index)
| crate::GatherMode::ShuffleUp(index)
| crate::GatherMode::ShuffleXor(index) => todo!(),
}
self.cached[result] = id;
Ok(())
Expand Down
12 changes: 10 additions & 2 deletions src/compact/statements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ impl FunctionTracer<'_> {
} => {
match mode {
crate::GatherMode::BroadcastFirst => {}
crate::GatherMode::Broadcast(index) => self.trace_expression(index),
crate::GatherMode::Broadcast(index)
| crate::GatherMode::Shuffle(index)
| crate::GatherMode::ShuffleDown(index)
| crate::GatherMode::ShuffleUp(index)
| crate::GatherMode::ShuffleXor(index) => self.trace_expression(index),
}
self.trace_expression(argument);
self.trace_expression(result);
Expand Down Expand Up @@ -296,7 +300,11 @@ impl FunctionMap {
} => {
match *mode {
crate::GatherMode::BroadcastFirst => {}
crate::GatherMode::Broadcast(ref mut index) => adjust(index),
crate::GatherMode::Broadcast(ref mut index)
| crate::GatherMode::Shuffle(ref mut index)
| crate::GatherMode::ShuffleDown(ref mut index)
| crate::GatherMode::ShuffleUp(ref mut index)
| crate::GatherMode::ShuffleXor(ref mut index) => adjust(index),
}
adjust(argument);
adjust(result);
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,10 @@ pub enum SwizzleComponent {
pub enum GatherMode {
BroadcastFirst,
Broadcast(Handle<Expression>),
Shuffle(Handle<Expression>),
ShuffleDown(Handle<Expression>),
ShuffleUp(Handle<Expression>),
ShuffleXor(Handle<Expression>),
}

#[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)]
Expand Down
11 changes: 9 additions & 2 deletions src/valid/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,15 @@ impl FunctionInfo {
result: _,
} => {
let _ = self.add_ref(argument);
if let crate::GatherMode::Broadcast(expr) = mode {
let _ = self.add_ref(expr);
match mode {
crate::GatherMode::BroadcastFirst => {}
crate::GatherMode::Broadcast(index)
| crate::GatherMode::Shuffle(index)
| crate::GatherMode::ShuffleDown(index)
| crate::GatherMode::ShuffleUp(index)
| crate::GatherMode::ShuffleXor(index) => {
let _ = self.add_ref(index);
}
}
FunctionUniformity::new()
}
Expand Down
6 changes: 5 additions & 1 deletion src/valid/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,11 @@ impl super::Validator {
) -> Result<(), WithSpan<FunctionError>> {
match *mode {
crate::GatherMode::BroadcastFirst => {}
crate::GatherMode::Broadcast(index) => {
crate::GatherMode::Broadcast(index)
| crate::GatherMode::Shuffle(index)
| crate::GatherMode::ShuffleDown(index)
| crate::GatherMode::ShuffleUp(index)
| crate::GatherMode::ShuffleXor(index) => {
let index_ty = context.resolve_type(index, &self.valid_expression_set)?;
match *index_ty {
crate::TypeInner::Scalar {
Expand Down
6 changes: 5 additions & 1 deletion src/valid/handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,11 @@ impl super::Validator {
validate_expr(argument)?;
match mode {
crate::GatherMode::BroadcastFirst => {}
crate::GatherMode::Broadcast(index) => validate_expr(index)?,
crate::GatherMode::Broadcast(index)
| crate::GatherMode::Shuffle(index)
| crate::GatherMode::ShuffleDown(index)
| crate::GatherMode::ShuffleUp(index)
| crate::GatherMode::ShuffleXor(index) => validate_expr(index)?,
}
validate_expr(result)?;
Ok(())
Expand Down

0 comments on commit b41cce8

Please sign in to comment.