-
Notifications
You must be signed in to change notification settings - Fork 2
/
12_graphics_pipeline_complete.diff
114 lines (99 loc) · 3.35 KB
/
12_graphics_pipeline_complete.diff
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
diff --git a/../steps/11_render_passes/main.go b/../steps/12_graphics_pipeline_complete/main.go
index 81b6945..00e5503 100644
--- a/../steps/11_render_passes/main.go
+++ b/../steps/12_graphics_pipeline_complete/main.go
@@ -60,8 +60,9 @@ type HelloTriangleApplication struct {
swapchainExtent core1_0.Extent2D
swapchainImageViews []core1_0.ImageView
- renderPass core1_0.RenderPass
- pipelineLayout core1_0.PipelineLayout
+ renderPass core1_0.RenderPass
+ pipelineLayout core1_0.PipelineLayout
+ graphicsPipeline core1_0.Pipeline
}
func (app *HelloTriangleApplication) Run() error {
@@ -152,6 +153,10 @@ appLoop:
}
func (app *HelloTriangleApplication) cleanup() {
+ if app.graphicsPipeline != nil {
+ app.graphicsPipeline.Destroy(nil)
+ }
+
if app.pipelineLayout != nil {
app.pipelineLayout.Destroy(nil)
}
@@ -536,26 +541,26 @@ func (app *HelloTriangleApplication) createGraphicsPipeline() error {
}
defer fragShader.Destroy(nil)
- _ = &core1_0.PipelineVertexInputStateCreateInfo{}
+ vertexInput := &core1_0.PipelineVertexInputStateCreateInfo{}
- _ = &core1_0.PipelineInputAssemblyStateCreateInfo{
+ inputAssembly := &core1_0.PipelineInputAssemblyStateCreateInfo{
Topology: core1_0.PrimitiveTopologyTriangleList,
PrimitiveRestartEnable: false,
}
- _ = &core1_0.PipelineShaderStageCreateInfo{
+ vertStage := core1_0.PipelineShaderStageCreateInfo{
Stage: core1_0.StageVertex,
Module: vertShader,
Name: "main",
}
- _ = &core1_0.PipelineShaderStageCreateInfo{
+ fragStage := core1_0.PipelineShaderStageCreateInfo{
Stage: core1_0.StageFragment,
Module: fragShader,
Name: "main",
}
- _ = &core1_0.PipelineViewportStateCreateInfo{
+ viewport := &core1_0.PipelineViewportStateCreateInfo{
Viewports: []core1_0.Viewport{
{
X: 0,
@@ -574,7 +579,7 @@ func (app *HelloTriangleApplication) createGraphicsPipeline() error {
},
}
- _ = &core1_0.PipelineRasterizationStateCreateInfo{
+ rasterization := &core1_0.PipelineRasterizationStateCreateInfo{
DepthClampEnable: false,
RasterizerDiscardEnable: false,
@@ -587,13 +592,13 @@ func (app *HelloTriangleApplication) createGraphicsPipeline() error {
LineWidth: 1.0,
}
- _ = &core1_0.PipelineMultisampleStateCreateInfo{
+ multisample := &core1_0.PipelineMultisampleStateCreateInfo{
SampleShadingEnable: false,
RasterizationSamples: core1_0.Samples1,
MinSampleShading: 1.0,
}
- _ = &core1_0.PipelineColorBlendStateCreateInfo{
+ colorBlend := &core1_0.PipelineColorBlendStateCreateInfo{
LogicOpEnabled: false,
LogicOp: core1_0.LogicOpCopy,
@@ -611,6 +616,29 @@ func (app *HelloTriangleApplication) createGraphicsPipeline() error {
return err
}
+ pipelines, _, err := app.device.CreateGraphicsPipelines(nil, nil, []core1_0.GraphicsPipelineCreateInfo{
+ {
+ Stages: []core1_0.PipelineShaderStageCreateInfo{
+ vertStage,
+ fragStage,
+ },
+ VertexInputState: vertexInput,
+ InputAssemblyState: inputAssembly,
+ ViewportState: viewport,
+ RasterizationState: rasterization,
+ MultisampleState: multisample,
+ ColorBlendState: colorBlend,
+ Layout: app.pipelineLayout,
+ RenderPass: app.renderPass,
+ Subpass: 0,
+ BasePipelineIndex: -1,
+ },
+ })
+ if err != nil {
+ return err
+ }
+ app.graphicsPipeline = pipelines[0]
+
return nil
}