Skip to content

Commit c1acf6e

Browse files
committed
compiletest webpage example
1 parent 8b62c3e commit c1acf6e

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/compiletests/ui/webpage.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// build-pass
2+
3+
use glam::UVec3;
4+
use spirv_std::spirv;
5+
6+
#[repr(u32)]
7+
pub enum Outcome {
8+
Fizz,
9+
Buzz,
10+
FizzBuzz,
11+
}
12+
13+
trait Game {
14+
fn fizzbuzz(&self) -> Option<Outcome>;
15+
}
16+
17+
impl Game for usize {
18+
fn fizzbuzz(&self) -> Option<Outcome> {
19+
match (self % 3 == 0, self % 5 == 0) {
20+
(true, true) => Some(Outcome::FizzBuzz),
21+
(true, false) => Some(Outcome::Fizz),
22+
(false, true) => Some(Outcome::Buzz),
23+
_ => None,
24+
}
25+
}
26+
}
27+
28+
#[spirv(compute(threads(64)))]
29+
pub fn main(
30+
#[spirv(global_invocation_id)] id: UVec3,
31+
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] output: &mut [Option<Outcome>; 64],
32+
) {
33+
let index = id.x as usize;
34+
output[index] = index.fizzbuzz();
35+
}

0 commit comments

Comments
 (0)