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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
bitflags::bitflags! {
    /// Flags to specify set of pipeline stages.
    #[cfg_attr(feature = "serde-1", derive(serde::Serialize, serde::Deserialize))]
    pub struct PipelineStages: u32 {
        /// Pseudo-stage that precedes all other stages and doesn't execute any commands.
        /// Using it in first scope of dependency will
        /// not cause any waiting, because no operations should be waited upon.
        /// Using it in second scope will make all operations in second scope to wait for operations first scope.
        const TOP_OF_PIPE = 0x00000001;

        /// Stage at which indirect draw buffer is read.
        const DRAW_INDIRECT = 0x00000002;

        /// Stage at which vertex buffers are read.
        const VERTEX_INPUT = 0x00000004;

        /// Stage at which vertex shader is executed.
        const VERTEX_SHADER = 0x00000008;

        /// Stage at which tessellation control shader is executed.
        const TESSELLATION_CONTROL_SHADER = 0x00000010;

        /// Stage at which tessellation evaluation shader is executed.
        const TESSELLATION_EVALUATION_SHADER = 0x00000020;

        /// Stage at which geometry shader is executed.
        const GEOMETRY_SHADER = 0x00000040;

        /// Stage at which early fragment depth and stencil test is performed
        /// before fragment shader execution.
        const EARLY_FRAGMENT_TESTS = 0x00000100;

        /// Stage at which fragment shader is executed.
        const FRAGMENT_SHADER = 0x00000080;

        /// Stage at which late fragment depth and stencil test is performed
        /// after fragment shader execution.
        const LATE_FRAGMENT_TESTS = 0x00000200;

        /// Stage at which color output of fragment shader is written
        /// and multi-sample resolve operation happens.
        const COLOR_ATTACHMENT_OUTPUT = 0x00000400;

        /// Stage at which compute shader is executed.
        const COMPUTE_SHADER = 0x00000800;

        /// Stage at which transfer commands (Copy, Blit etc) are executed.
        const TRANSFER = 0x00001000;

        /// Pseudo-stage that follows all other stages and doesn't execute any commands.
        /// Using it in first scope will make operations in second scope to wait for all operations first scope.
        /// Using it in second scope of dependency will
        /// not cause any waiting, because no operations should be waited upon.
        const BOTTOM_OF_PIPE = 0x00002000;

        /// Pseudo-stage at which HOST access to resources is performed.
        /// It has very limited use because command submission creates
        /// memory dependency between host access and device operations.
        const HOST = 0x00004000;

        /// Flag that can be used instead of specifying all graphics stages
        /// including those from enabled extensions.
        const ALL_GRAPHICS = 0x00008000;

        /// Flag that can be used instead of specifying all compute stages
        /// including those from enabled extensions.
        const ALL_COMMANDS = 0x00010000;

        /// Stage at which ray-tracing pipeline is executed.
        const RAY_TRACING_SHADER = 0x00200000;

        /// Stage at which acceleration structures are built.
        const ACCELERATION_STRUCTURE_BUILD = 0x02000000;
    }
}

/// Enum to specify one pipeline stage.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde-1", derive(serde::Serialize, serde::Deserialize))]
pub enum PipelineStage {
    /// Pseudo-stage that precedes all other stages and doesn't execute any commands.
    /// Using it in first scope of dependency will
    /// not cause any waiting, because no operations should be waited upon.
    /// Using it in second scope will make all operations in second scope to wait for operations first scope.
    TopOfPipe,

    /// Stage at which indirect draw buffer is read.
    DrawIndirect,

    /// Stage at which vertex buffers are read.
    VertexInput,

    /// Stage at which vertex shader is executed.
    VertexShader,
    //,
    //,
    //,
    /// Stage at which early fragment depth and stencil test is performed
    /// before fragment shader execution.
    EarlyFragmentTests,

    /// Stage at which fragment shader is executed.
    FragmentShader,

    /// Stage at which late fragment depth and stencil test is performed
    /// after fragment shader execution.
    LateFragmentTests,

    /// Stage at which color output of fragment shader is written
    /// and multi-sample resolve operation happens.
    ColorAttachmentOutput,

    /// Stage at which compute shader is executed.
    ComputeShader,

    /// Stage at which transfer commands (Copy, Blit etc) are executed.
    Transfer,

    /// Pseudo-stage that follows all other stages and doesn't execute any commands.
    /// Using it in first scope will make operations in second scope to wait for all operations first scope.
    /// Using it in second scope of dependency will
    /// not cause any waiting, because no operations should be waited upon.
    BottomOfPipe,

    /// Pseudo-stage at which HOST access to resources is performed.
    /// It has very limited use because command submission creates
    /// memory dependency between host access and device operations.
    Host,

    /// Stage at which ray-tracing pipeline is executed.
    RayTracingShader,

    /// Stage at which acceleration structures are built.
    AccelerationStructureBuild,
}