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

Initial work for bindless buffers & textures in rust-gpu #450

Merged
merged 65 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
2f00b8e
Initial work for bindless buffers & textures in rust-gpu
Jasper-Bekkers Feb 25, 2021
b1e1317
Add more data types (vectors and plain integers)
Jasper-Bekkers Mar 3, 2021
7e91aaa
Rename lambda
Jasper-Bekkers Mar 3, 2021
de82240
checkpoint: first running bindless compute shader w/ buffer store
Jasper-Bekkers Mar 3, 2021
1255ebe
Small bugfix for loads
Jasper-Bekkers Mar 4, 2021
a09d1c2
Rebased on main
Jasper-Bekkers Mar 4, 2021
794226a
Add SimpleBuffer and ArrayBuffer
Jasper-Bekkers Mar 4, 2021
11c7967
Clean up store code a bit and move it all out to it's own file
Jasper-Bekkers Mar 17, 2021
e5a8187
Add support for u64
Jasper-Bekkers Mar 17, 2021
2159869
Add i64
Jasper-Bekkers Mar 18, 2021
3de4e69
Move out integer store functionality into seperate function
Jasper-Bekkers Mar 18, 2021
a2cf887
Add f32 and f64 support
Jasper-Bekkers Mar 18, 2021
9f21017
Add vec types
Jasper-Bekkers Mar 18, 2021
245d77d
Move load lambda's into member functions
Jasper-Bekkers Mar 19, 2021
e7bf1dc
Make ADT traversal for loads recursive, remove redundant code
Jasper-Bekkers Mar 19, 2021
98bdbf4
Fix bugs with loads, add vector types & floats
Jasper-Bekkers Mar 24, 2021
bc419db
remove debug prints
Jasper-Bekkers Mar 24, 2021
7bb5fc1
Add support for u64 and i64
Jasper-Bekkers Mar 24, 2021
cc5e63f
Add store to ArrayBuffer
Jasper-Bekkers Mar 24, 2021
1b720f2
Add store to SimpleBuffer as well
Jasper-Bekkers Mar 24, 2021
0b4d7cb
Merge main
Jasper-Bekkers Mar 31, 2021
036c89f
Clean up + better error reporting
Jasper-Bekkers Apr 7, 2021
47e6149
Merge branch 'main' into first-bindless-work
Jasper-Bekkers Apr 8, 2021
6ba0b08
Err instead of fatal
Jasper-Bekkers Apr 12, 2021
ffac0d1
Unused imports + compile fix
Jasper-Bekkers Apr 12, 2021
1931670
Also enable abi_unadjusted on cpu as well
Jasper-Bekkers Apr 12, 2021
62a2d85
Unused variables + unneeded mut fixes
Jasper-Bekkers Apr 12, 2021
2f89893
Remove unused bindless_mode setting
Jasper-Bekkers Apr 12, 2021
9f9ec30
Revert debug println
Jasper-Bekkers Apr 12, 2021
bd7585a
Remove unneeded unused_attributes
Jasper-Bekkers Apr 12, 2021
055824b
More explicit error handling for stores
Jasper-Bekkers Apr 12, 2021
98657a6
Add support for static arrays
Jasper-Bekkers Apr 12, 2021
7f91cdf
Boilerplate for error messages + dummy array impl
Jasper-Bekkers Apr 14, 2021
6644346
Add support for `Array` stores to buffers.
Jasper-Bekkers Apr 14, 2021
e80214e
Add extension + capability in buffer load/store
Jasper-Bekkers Apr 16, 2021
4ead0de
Fix unsafe warnings
Jasper-Bekkers Apr 16, 2021
2b38a1d
Support SPIR-V after 1.3 with proper decorations for buffers
Jasper-Bekkers Apr 16, 2021
b1f538d
Fix version check
Jasper-Bekkers Apr 19, 2021
74d62aa
Move `internal_` calls to private module so it's in-accessible and on…
Jasper-Bekkers Apr 19, 2021
1c01db7
Merge remote-tracking branch 'origin/main' into first-bindless-work
Jasper-Bekkers Apr 19, 2021
0829bde
Fix issue we ran into with BorrowMut because both `self.emit()` and `…
Jasper-Bekkers Apr 19, 2021
e20136e
Add error for AccelerationStructureKhr
Jasper-Bekkers Apr 19, 2021
cf5f1b9
formatting
Jasper-Bekkers Apr 20, 2021
765ed05
Address feedback where I was using a type as a value incorrectly
Jasper-Bekkers Apr 30, 2021
63367dd
Add `bindless` feature flag, this is required because we need to over…
Jasper-Bekkers Apr 30, 2021
d312d2d
Fix OpVariable declarations appearing midway through functions - vali…
Jasper-Bekkers Apr 30, 2021
e7c8904
Cargo clippy
Jasper-Bekkers Apr 30, 2021
f44d7c2
Add comment around endianness
Jasper-Bekkers May 3, 2021
d7e61a2
Move SPV_EXT_descriptor_indexing to entry point now that we have `bin…
Jasper-Bekkers May 3, 2021
1780978
Improved entry point OpVariable handling
Jasper-Bekkers May 3, 2021
e4fcaed
Intern `bindless` in the Symbols struct
Jasper-Bekkers May 3, 2021
f066dd7
Don't require `naked_functions`
Jasper-Bekkers May 3, 2021
2f23fbf
Use target_features old infrastructure to set bindless flag
Jasper-Bekkers May 3, 2021
b77c65f
Variable doesn't need mut
Jasper-Bekkers May 3, 2021
bdfea32
Set OpVariable in the right location right away instead of resorting
Jasper-Bekkers May 3, 2021
e9415dc
Don't do anything special with op_entry_point_interface_operands in t…
Jasper-Bekkers May 3, 2021
26b857d
Patch out `abi` in function signature for functions that are gpu_only…
Jasper-Bekkers May 3, 2021
8a0bd41
Merge remote-tracking branch 'origin/main' into first-bindless-work
Jasper-Bekkers May 4, 2021
0c6207d
fmt
Jasper-Bekkers May 4, 2021
7b3c244
Clippy
Jasper-Bekkers May 4, 2021
0155696
Feature flags broke during merge
Jasper-Bekkers May 4, 2021
cf48f32
Skip `bindless` feature when parsing capabilities
Jasper-Bekkers May 5, 2021
a9858b9
Update OpVariable space to fix validation error
Jasper-Bekkers May 5, 2021
55739d5
naming
Jasper-Bekkers May 5, 2021
8f49d26
fmt
Jasper-Bekkers May 5, 2021
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
21 changes: 19 additions & 2 deletions crates/rustc_codegen_spirv/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ pub enum SpirvAttribute {

// `fn`/closure attributes:
UnrollLoops,
InternalBufferLoad,
InternalBufferStore,
}

// HACK(eddyb) this is similar to `rustc_span::Spanned` but with `value` as the
Expand Down Expand Up @@ -130,6 +132,8 @@ pub struct AggregatedSpirvAttributes {

// `fn`/closure attributes:
pub unroll_loops: Option<Spanned<()>>,
pub internal_buffer_load: Option<Spanned<()>>,
pub internal_buffer_store: Option<Spanned<()>>,
}

struct MultipleAttrs {
Expand Down Expand Up @@ -211,6 +215,18 @@ impl AggregatedSpirvAttributes {
Flat => try_insert(&mut self.flat, (), span, "#[spirv(flat)]"),
Invariant => try_insert(&mut self.invariant, (), span, "#[spirv(invariant)]"),
UnrollLoops => try_insert(&mut self.unroll_loops, (), span, "#[spirv(unroll_loops)]"),
InternalBufferLoad => try_insert(
&mut self.internal_buffer_load,
(),
span,
"#[spirv(internal_buffer_load)]",
),
InternalBufferStore => try_insert(
&mut self.internal_buffer_store,
(),
span,
"#[spirv(internal_buffer_store)]",
),
}
}
}
Expand Down Expand Up @@ -334,8 +350,9 @@ impl CheckSpirvAttrVisitor<'_> {

_ => Err(Expected("function parameter")),
},

SpirvAttribute::UnrollLoops => match target {
SpirvAttribute::InternalBufferLoad
| SpirvAttribute::InternalBufferStore
| SpirvAttribute::UnrollLoops => match target {
Target::Fn
| Target::Closure
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => {
Expand Down
24 changes: 18 additions & 6 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1448,12 +1448,13 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
SpirvType::Pointer { .. } => match op {
IntEQ => {
if self.emit().version().unwrap() > (1, 3) {
self.emit()
.ptr_equal(b, None, lhs.def(self), rhs.def(self))
.map(|result| {
self.zombie_ptr_equal(result, "OpPtrEqual");
result
})
let ptr_equal =
self.emit().ptr_equal(b, None, lhs.def(self), rhs.def(self));

ptr_equal.map(|result| {
self.zombie_ptr_equal(result, "OpPtrEqual");
result
})
} else {
let int_ty = self.type_usize();
let lhs = self
Expand Down Expand Up @@ -1831,6 +1832,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
fn extract_value(&mut self, agg_val: Self::Value, idx: u64) -> Self::Value {
let result_type = match self.lookup_type(agg_val.ty) {
SpirvType::Adt { field_types, .. } => field_types[idx as usize],
SpirvType::Array { element, .. } | SpirvType::Vector { element, .. } => element,
other => self.fatal(&format!(
"extract_value not implemented on type {:?}",
other
Expand Down Expand Up @@ -2176,6 +2178,16 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
// needing to materialize `&core::panic::Location` or `format_args!`.
self.abort();
self.undef(result_type)
} else if self.internal_buffer_load_id.borrow().contains(&callee_val) {
self.codegen_internal_buffer_load(result_type, args)
} else if self.internal_buffer_store_id.borrow().contains(&callee_val) {
self.codegen_internal_buffer_store(args);

let void_ty = SpirvType::Void.def(rustc_span::DUMMY_SP, self);
SpirvValue {
kind: SpirvValueKind::IllegalTypeUsed(void_ty),
ty: void_ty,
}
} else {
let args = args.iter().map(|arg| arg.def(self)).collect::<Vec<_>>();
self.emit()
Expand Down
Loading