forked from vkngwrapper/vulkan-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10_fixed_functions.diff
110 lines (103 loc) · 2.91 KB
/
10_fixed_functions.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
diff --git a/../steps/09_shader_modules/main.go b/../steps/10_fixed_functions/main.go
index 9c32b99..393be28 100644
--- a/../steps/09_shader_modules/main.go
+++ b/../steps/10_fixed_functions/main.go
@@ -59,6 +59,8 @@ type HelloTriangleApplication struct {
swapchainImageFormat core1_0.Format
swapchainExtent core1_0.Extent2D
swapchainImageViews []core1_0.ImageView
+
+ pipelineLayout core1_0.PipelineLayout
}
func (app *HelloTriangleApplication) Run() error {
@@ -144,6 +146,10 @@ appLoop:
}
func (app *HelloTriangleApplication) cleanup() {
+ if app.pipelineLayout != nil {
+ app.pipelineLayout.Destroy(nil)
+ }
+
for _, imageView := range app.swapchainImageViews {
imageView.Destroy(nil)
}
@@ -284,7 +290,7 @@ func (app *HelloTriangleApplication) pickPhysicalDevice() error {
}
if app.physicalDevice == nil {
- return errors.Newf("failed to find a suitable GPU!")
+ return errors.New("failed to find a suitable GPU!")
}
return nil
@@ -473,6 +479,13 @@ func (app *HelloTriangleApplication) createGraphicsPipeline() error {
}
defer fragShader.Destroy(nil)
+ _ = &core1_0.PipelineVertexInputStateCreateInfo{}
+
+ _ = &core1_0.PipelineInputAssemblyStateCreateInfo{
+ Topology: core1_0.PrimitiveTopologyTriangleList,
+ PrimitiveRestartEnable: false,
+ }
+
_ = &core1_0.PipelineShaderStageCreateInfo{
Stage: core1_0.StageVertex,
Module: vertShader,
@@ -485,6 +498,62 @@ func (app *HelloTriangleApplication) createGraphicsPipeline() error {
Name: "main",
}
+ _ = &core1_0.PipelineViewportStateCreateInfo{
+ Viewports: []core1_0.Viewport{
+ {
+ X: 0,
+ Y: 0,
+ Width: float32(app.swapchainExtent.Width),
+ Height: float32(app.swapchainExtent.Height),
+ MinDepth: 0,
+ MaxDepth: 1,
+ },
+ },
+ Scissors: []core1_0.Rect2D{
+ {
+ Offset: core1_0.Offset2D{X: 0, Y: 0},
+ Extent: app.swapchainExtent,
+ },
+ },
+ }
+
+ _ = &core1_0.PipelineRasterizationStateCreateInfo{
+ DepthClampEnable: false,
+ RasterizerDiscardEnable: false,
+
+ PolygonMode: core1_0.PolygonModeFill,
+ CullMode: core1_0.CullModeBack,
+ FrontFace: core1_0.FrontFaceClockwise,
+
+ DepthBiasEnable: false,
+
+ LineWidth: 1.0,
+ }
+
+ _ = &core1_0.PipelineMultisampleStateCreateInfo{
+ SampleShadingEnable: false,
+ RasterizationSamples: core1_0.Samples1,
+ MinSampleShading: 1.0,
+ }
+
+ _ = &core1_0.PipelineColorBlendStateCreateInfo{
+ LogicOpEnabled: false,
+ LogicOp: core1_0.LogicOpCopy,
+
+ BlendConstants: [4]float32{0, 0, 0, 0},
+ Attachments: []core1_0.PipelineColorBlendAttachmentState{
+ {
+ BlendEnabled: false,
+ ColorWriteMask: core1_0.ColorComponentRed | core1_0.ColorComponentGreen | core1_0.ColorComponentBlue | core1_0.ColorComponentAlpha,
+ },
+ },
+ }
+
+ app.pipelineLayout, _, err = app.device.CreatePipelineLayout(nil, core1_0.PipelineLayoutCreateInfo{})
+ if err != nil {
+ return err
+ }
+
return nil
}