Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subgroup intrinsics #14

Merged
merged 15 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ target/
.vim/
tests/Cargo.lock
.github/install-spirv-tools/Cargo.lock
rustc-ice-*.txt
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Signed for loops like `for _ in 0..4i32 {}` no longer compile. We recommend switching to unsigned for loops and casting back to signed integers in the meanwhile.

### Changed 🛠
- [PR#14](https://github.com/Rust-GPU/rust-gpu/pull/14) add subgroup intrinsics matching glsl's [`GL_KHR_shader_subgroup`](https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt)
- [PR#13](https://github.com/Rust-GPU/rust-gpu/pull/13) allow cargo features to be passed to the shader crate
- [PR#12](https://github.com/rust-gpu/rust-gpu/pull/12) updated toolchain to `nightly-2024-04-24`
- [PR#9](https://github.com/Rust-GPU/rust-gpu/pull/9) relaxed `glam` version requirements (`>=0.22, <=0.29`)
Expand Down
19 changes: 13 additions & 6 deletions crates/rustc_codegen_spirv/src/builder/spirv_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ use super::Builder;
use crate::builder_spirv::{BuilderCursor, SpirvValue};
use crate::codegen_cx::CodegenCx;
use crate::spirv_type::SpirvType;
use num_traits::FromPrimitive;
use rspirv::dr;
use rspirv::grammar::{reflect, LogicalOperand, OperandKind, OperandQuantifier};
use rspirv::spirv::{
FPFastMathMode, FragmentShadingRate, FunctionControl, ImageOperands, KernelProfilingInfo,
LoopControl, MemoryAccess, MemorySemantics, Op, RayFlags, SelectionControl, StorageClass, Word,
FPFastMathMode, FragmentShadingRate, FunctionControl, GroupOperation, ImageOperands,
KernelProfilingInfo, LoopControl, MemoryAccess, MemorySemantics, Op, RayFlags,
SelectionControl, StorageClass, Word,
};
use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_codegen_ssa::mir::place::PlaceRef;
Expand Down Expand Up @@ -1347,10 +1349,15 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
Ok(x) => inst.operands.push(dr::Operand::Scope(x)),
Err(()) => self.err(format!("unknown Scope {word}")),
},
(OperandKind::GroupOperation, Some(word)) => match word.parse() {
Ok(x) => inst.operands.push(dr::Operand::GroupOperation(x)),
Err(()) => self.err(format!("unknown GroupOperation {word}")),
},
(OperandKind::GroupOperation, Some(word)) => {
match word.parse::<u32>().ok().and_then(GroupOperation::from_u32) {
Some(id) => inst.operands.push(dr::Operand::GroupOperation(id)),
None => match word.parse() {
Ok(x) => inst.operands.push(dr::Operand::GroupOperation(x)),
Err(()) => self.err(format!("unknown GroupOperation {word}")),
},
}
}
(OperandKind::KernelEnqueueFlags, Some(word)) => match word.parse() {
Ok(x) => inst.operands.push(dr::Operand::KernelEnqueueFlags(x)),
Err(()) => self.err(format!("unknown KernelEnqueueFlags {word}")),
Expand Down
2 changes: 2 additions & 0 deletions crates/spirv-std/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ mod demote_to_helper_invocation_ext;
mod derivative;
mod primitive;
mod ray_tracing;
mod subgroup;

pub use atomics::*;
pub use barrier::*;
pub use demote_to_helper_invocation_ext::*;
pub use derivative::*;
pub use primitive::*;
pub use ray_tracing::*;
pub use subgroup::*;

/// Result is true if any component of `vector` is true, otherwise result is
/// false.
Expand Down
Loading