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
use Resources;
use descriptor::DescriptorSetLayout;
use shader::Type;
use std::fmt;
pub trait GraphicsPipeline {
}
pub struct GraphicsPipelineInfo<'r: 'b, 'b, R: 'r + Resources<'r>> {
pub input_assembler: InputAssembler,
pub vertex_shader: PipelineShader<'r, 'b, R>,
pub fragment_shader: PipelineShader<'r, 'b, R>
}
pub struct InputAssembler {
pub topology: Topology
}
pub struct PipelineShader<'r: 'b, 'b, R: 'r + Resources<'r>> {
pub shader: &'b R::Shader,
pub descriptor_layout: Vec<DescriptorSetLayout>
}
#[derive(Debug, Copy, Clone)]
pub enum Topology {
Points,
Lines,
LineStrip,
LineLoop,
Triangles,
TriangleStrip,
TriangleFan
}
#[derive(PartialEq, Eq, Clone)]
pub enum GraphicsPipelineCreationError {
ProgramLinkError(LinkError),
DescriptorSetLayoutCountMismatch(Type, usize, Type, usize),
DescriptorSetLayoutSlotCountMismatch(usize, Type, usize, Type, usize),
ShaderEntityIndexNotFound(Type, u32),
DescriptorSetToTraditionalBindingConversionError(String)
}
impl fmt::Debug for GraphicsPipelineCreationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&GraphicsPipelineCreationError::ProgramLinkError(ref error) => write!(f, "ProgramLinkError({:?})", error),
&GraphicsPipelineCreationError::DescriptorSetLayoutCountMismatch(first_shader, first, this_shader, this) => write!(f, "DescriptorSetLayoutCountMismatch: the {} shader has {} layouts, but the {} shader has {} layouts", first_shader.to_lowercase(), first, this_shader.to_lowercase(), this),
&GraphicsPipelineCreationError::DescriptorSetLayoutSlotCountMismatch(set, first_shader, first, this_shader, this) => write!(f, "DescriptorSetLayoutSlotCountMismatch: descriptor set {} in the {} shader has {} slots, but the same descriptor set in the {} shader has {} slots", set, first_shader.to_lowercase(), first, this_shader.to_lowercase(), this),
&GraphicsPipelineCreationError::ShaderEntityIndexNotFound(ty, index) => write!(f, "ShaderEntityIndexNotFound: index {} in the {} shader", index, ty.to_lowercase()),
&GraphicsPipelineCreationError::DescriptorSetToTraditionalBindingConversionError(ref message) => write!(f, "DescriptorSetToTraditionalBindingConversionError({:?})", message)
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LinkError {
pub message: String
}
impl From<LinkError> for GraphicsPipelineCreationError {
fn from(error: LinkError) -> Self {
GraphicsPipelineCreationError::ProgramLinkError(error)
}
}