-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
asm: infer the result type of OpAccessChain (when indexing into arrays).
- Loading branch information
Showing
2 changed files
with
56 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Tests that `asm!` can infer the result type of `OpAccessChain`, | ||
// when used to index arrays. | ||
|
||
// build-pass | ||
|
||
use spirv_std as _; | ||
|
||
use glam::Vec4; | ||
|
||
#[spirv(fragment)] | ||
pub fn main(#[spirv(push_constant)] array_in: &[Vec4; 16], i: u32, out: &mut Vec4) { | ||
unsafe { | ||
asm!( | ||
"%val_ptr = OpAccessChain _ {array_ptr} {index}", | ||
"%val = OpLoad _ %val_ptr", | ||
"OpStore {out_ptr} %val", | ||
array_ptr = in(reg) array_in, | ||
index = in(reg) i, | ||
out_ptr = in(reg) out, | ||
); | ||
} | ||
} |