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    unsafe {
15        asm! {
16            "OpEmitVertex",
17        }
18    }
19}
20
21/// Finish the current primitive and start a new one. No vertex is emitted.
22/// Requires capability `Geometry`.
23///
24/// # Safety
25/// This instruction must only be used when only one stream is present.
26#[spirv_std_macros::gpu_only]
27#[doc(alias = "OpEndPrimitive")]
28#[inline]
29pub unsafe fn end_primitive() {
30    unsafe {
31        asm! {
32            "OpEndPrimitive",
33        }
34    }
35}
36
37/// Emits the current values of all output variables to the current output
38/// primitive. After execution, the values of all output variables
39/// are undefined.
40///
41/// `STREAM` is the output-primitive stream number.
42///
43/// Requires capability `GeometryStreams`.
44///
45/// # Safety
46/// This instruction must only be used when multiple streams are present.
47#[spirv_std_macros::gpu_only]
48#[doc(alias = "OpEmitStreamVertex")]
49#[inline]
50// FIXME(eddyb) why does this require `i64` instead of `i32`?
51pub unsafe fn emit_stream_vertex<const STREAM: i64>() {
52    unsafe {
53        asm! {
54            "%i64 = OpTypeInt 64 1",
55            "%stream = OpConstant %i64 {stream}",
56            "OpEmitStreamVertex %stream",
57            stream = const STREAM,
58        }
59    }
60}
61
62/// Finish the current primitive and start a new one. No vertex is emitted.
63///
64/// `STREAM` is the output-primitive stream number.
65///
66/// Requires capability `GeometryStreams`.
67///
68/// # Safety
69/// This instruction must only be used when multiple streams are present.
70#[spirv_std_macros::gpu_only]
71#[doc(alias = "OpEndStreamPrimitive")]
72#[inline]
73// FIXME(eddyb) why does this require `i64` instead of `i32`?
74pub unsafe fn end_stream_primitive<const STREAM: i64>() {
75    unsafe {
76        asm! {
77            "%i64 = OpTypeInt 64 1",
78            "%stream = OpConstant %i64 {stream}",
79            "OpEndStreamPrimitive %stream",
80            stream = const STREAM,
81        }
82    }
83}