spirv_std/arch/primitive.rs
1#[cfg(target_arch = "spirv")]
2use core::arch::asm;
3
4/// Emits the current values of all output variables to the current output
5/// primitive. After execution, the values of all output variables
6/// are undefined. Requires capability `Geometry`.
7///
8/// # Safety
9/// This instruction must only be used when only one stream is present.
10#[spirv_std_macros::gpu_only]
11#[doc(alias = "OpEmitVertex")]
12#[inline]
13pub unsafe fn emit_vertex() {
14 asm! {
15 "OpEmitVertex",
16 }
17}
18
19/// Finish the current primitive and start a new one. No vertex is emitted.
20/// Requires capability `Geometry`.
21///
22/// # Safety
23/// This instruction must only be used when only one stream is present.
24#[spirv_std_macros::gpu_only]
25#[doc(alias = "OpEndPrimitive")]
26#[inline]
27pub unsafe fn end_primitive() {
28 asm! {
29 "OpEndPrimitive",
30 }
31}
32
33/// Emits the current values of all output variables to the current output
34/// primitive. After execution, the values of all output variables
35/// are undefined.
36///
37/// `STREAM` is the output-primitive stream number.
38///
39/// Requires capability `GeometryStreams`.
40///
41/// # Safety
42/// This instruction must only be used when multiple streams are present.
43#[spirv_std_macros::gpu_only]
44#[doc(alias = "OpEmitStreamVertex")]
45#[inline]
46pub unsafe fn emit_stream_vertex<const STREAM: i64>() {
47 asm! {
48 "%i64 = OpTypeInt 64 1",
49 "%stream = OpConstant %i64 {stream}",
50 "OpEmitStreamVertex %stream",
51 stream = const STREAM,
52 }
53}
54
55/// Finish the current primitive and start a new one. No vertex is emitted.
56///
57/// `STREAM` is the output-primitive stream number.
58///
59/// Requires capability `GeometryStreams`.
60///
61/// # Safety
62/// This instruction must only be used when multiple streams are present.
63#[spirv_std_macros::gpu_only]
64#[doc(alias = "OpEndStreamPrimitive")]
65#[inline]
66pub unsafe fn end_stream_primitive<const STREAM: i64>() {
67 asm! {
68 "%i64 = OpTypeInt 64 1",
69 "%stream = OpConstant %i64 {stream}",
70 "OpEndStreamPrimitive %stream",
71 stream = const STREAM,
72 }
73}