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
pub use crate::backend::RayTracingPipeline;
use crate::{buffer::StridedBufferRegion, shader::Shader, PipelineLayout};

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct RayTracingPipelineInfo {
    /// Array of shaders referenced by indices in shader groups below.
    pub shaders: Vec<Shader>,

    /// Pipline-creation-time layer of indirection between individual shaders
    /// and acceleration structures.
    pub groups: Vec<RayTracingShaderGroupInfo>,

    /// Maximum recursion depth to trace rays.
    pub max_recursion_depth: u32,

    /// Pipeline layout.
    pub layout: PipelineLayout,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde-1", derive(serde::Serialize, serde::Deserialize))]
pub enum RayTracingShaderGroupInfo {
    Raygen {
        /// Index of raygen shader in `RayTracingPipelineInfo::shaders`.
        raygen: u32,
    },
    Miss {
        /// Index of miss shader in `RayTracingPipelineInfo::shaders`.
        miss: u32,
    },
    Triangles {
        /// Index of any-hit shader in `RayTracingPipelineInfo::shaders`.
        any_hit: Option<u32>,
        /// Index of closest-hit shader in `RayTracingPipelineInfo::shaders`.
        closest_hit: Option<u32>,
    },
}

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct ShaderBindingTableInfo<'a> {
    pub raygen: Option<u32>,
    pub miss: &'a [u32],
    pub hit: &'a [u32],
    pub callable: &'a [u32],
}

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct ShaderBindingTable {
    pub raygen: Option<StridedBufferRegion>,
    pub miss: Option<StridedBufferRegion>,
    pub hit: Option<StridedBufferRegion>,
    pub callable: Option<StridedBufferRegion>,
}