-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathgeometry.rs
More file actions
85 lines (80 loc) · 2.32 KB
/
geometry.rs
File metadata and controls
85 lines (80 loc) · 2.32 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! Intrinsics for geometry shaders
#[cfg(target_arch = "spirv")]
use core::arch::asm;
/// Emits the current values of all output variables to the current output
/// primitive. After execution, the values of all output variables
/// are undefined. Requires capability `Geometry`.
///
/// # Safety
/// This instruction must only be used when only one stream is present.
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpEmitVertex")]
#[inline]
pub unsafe fn emit_vertex() {
unsafe {
asm! {
"OpEmitVertex",
}
}
}
/// Finish the current primitive and start a new one. No vertex is emitted.
/// Requires capability `Geometry`.
///
/// # Safety
/// This instruction must only be used when only one stream is present.
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpEndPrimitive")]
#[inline]
pub unsafe fn end_primitive() {
unsafe {
asm! {
"OpEndPrimitive",
}
}
}
/// Emits the current values of all output variables to the current output
/// primitive. After execution, the values of all output variables
/// are undefined.
///
/// `STREAM` is the output-primitive stream number.
///
/// Requires capability `GeometryStreams`.
///
/// # Safety
/// This instruction must only be used when multiple streams are present.
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpEmitStreamVertex")]
#[inline]
// FIXME(eddyb) why does this require `i64` instead of `i32`?
pub unsafe fn emit_stream_vertex<const STREAM: i64>() {
unsafe {
asm! {
"%i64 = OpTypeInt 64 1",
"%stream = OpConstant %i64 {stream}",
"OpEmitStreamVertex %stream",
stream = const STREAM,
}
}
}
/// Finish the current primitive and start a new one. No vertex is emitted.
///
/// `STREAM` is the output-primitive stream number.
///
/// Requires capability `GeometryStreams`.
///
/// # Safety
/// This instruction must only be used when multiple streams are present.
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpEndStreamPrimitive")]
#[inline]
// FIXME(eddyb) why does this require `i64` instead of `i32`?
pub unsafe fn end_stream_primitive<const STREAM: i64>() {
unsafe {
asm! {
"%i64 = OpTypeInt 64 1",
"%stream = OpConstant %i64 {stream}",
"OpEndStreamPrimitive %stream",
stream = const STREAM,
}
}
}