-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathdebug_printf.rs
More file actions
54 lines (47 loc) · 1.36 KB
/
debug_printf.rs
File metadata and controls
54 lines (47 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// build-pass
// compile-flags: -Ctarget-feature=+ext:SPV_KHR_non_semantic_info
// ignore-naga
use spirv_std::spirv;
use spirv_std::{
glam::{IVec2, UVec2, Vec2, Vec3, Vec4},
macros::{debug_printf, debug_printfln},
};
fn func(a: f32, b: f32) -> f32 {
a * b + 1.0
}
struct Struct {
a: f32,
}
impl Struct {
fn method(&self, b: f32, c: f32) -> f32 {
self.a * b + c
}
}
#[spirv(fragment)]
pub fn main() {
unsafe {
debug_printf!();
debug_printfln!();
debug_printfln!("Hello World");
debug_printfln!("Hello World",);
debug_printfln!(r#"Hello "World""#);
debug_printfln!(
r#"Hello "World"
"#
);
debug_printfln!("Hello \"World\"\n\n");
debug_printfln!("%%r %%f %%%%f %%%%%u", 77);
}
let vec = Vec2::new(1.52, 25.1);
unsafe {
debug_printfln!("%v2f", vec);
debug_printfln!("%1v2f", { vec * 2.0 });
debug_printfln!("%1.2v2f", vec * 3.0);
debug_printfln!("%% %v2f %%", vec * 4.0);
debug_printfln!("%u %i %f 🐉", 11_u32, -11_i32, 11.0_f32);
debug_printfln!("%f", func(33.0, 44.0));
debug_printfln!("%f", Struct { a: 33.0 }.method(44.0, 55.0));
debug_printfln!("%v3f %v4f", Vec3::new(1.0, 1.0, 1.0), Vec4::splat(5.0));
debug_printfln!("%v2u %v2i", UVec2::new(1, 1), IVec2::splat(-5));
}
}