-
Notifications
You must be signed in to change notification settings - Fork 28
/
Ch12GraphicsPipelineComplete.diff
59 lines (46 loc) · 2.63 KB
/
Ch12GraphicsPipelineComplete.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
diff --git "a/G:\\Java-Dev\\Vulkan-Tutorial-Java\\src\\main\\java\\javavulkantutorial\\Ch11RenderPasses.java" "b/G:\\Java-Dev\\Vulkan-Tutorial-Java\\src\\main\\java\\javavulkantutorial\\Ch12GraphicsPipelineComplete.java"
index 216e0f1..b836f3e 100644
--- "a/G:\\Java-Dev\\Vulkan-Tutorial-Java\\src\\main\\java\\javavulkantutorial\\Ch11RenderPasses.java"
+++ "b/G:\\Java-Dev\\Vulkan-Tutorial-Java\\src\\main\\java\\javavulkantutorial\\Ch12GraphicsPipelineComplete.java"
@@ -28,7 +28,7 @@ import static org.lwjgl.vulkan.KHRSurface.*;
import static org.lwjgl.vulkan.KHRSwapchain.*;
import static org.lwjgl.vulkan.VK10.*;
-public class Ch11RenderPasses {
+public class Ch12GraphicsPipelineComplete {
private static class HelloTriangleApplication {
@@ -131,6 +131,7 @@ public class Ch11RenderPasses {
private long renderPass;
private long pipelineLayout;
+ private long graphicsPipeline;
// ======= METHODS ======= //
@@ -181,6 +182,8 @@ public class Ch11RenderPasses {
private void cleanup() {
+ vkDestroyPipeline(device, graphicsPipeline, null);
+
vkDestroyPipelineLayout(device, pipelineLayout, null);
vkDestroyRenderPass(device, renderPass, null);
@@ -626,6 +629,28 @@ public class Ch11RenderPasses {
pipelineLayout = pPipelineLayout.get(0);
+ VkGraphicsPipelineCreateInfo.Buffer pipelineInfo = VkGraphicsPipelineCreateInfo.calloc(1, stack);
+ pipelineInfo.sType(VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO);
+ pipelineInfo.pStages(shaderStages);
+ pipelineInfo.pVertexInputState(vertexInputInfo);
+ pipelineInfo.pInputAssemblyState(inputAssembly);
+ pipelineInfo.pViewportState(viewportState);
+ pipelineInfo.pRasterizationState(rasterizer);
+ pipelineInfo.pMultisampleState(multisampling);
+ pipelineInfo.pColorBlendState(colorBlending);
+ pipelineInfo.layout(pipelineLayout);
+ pipelineInfo.renderPass(renderPass);
+ pipelineInfo.subpass(0);
+ pipelineInfo.basePipelineHandle(VK_NULL_HANDLE);
+ pipelineInfo.basePipelineIndex(-1);
+
+ LongBuffer pGraphicsPipeline = stack.mallocLong(1);
+
+ if(vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, pipelineInfo, null, pGraphicsPipeline) != VK_SUCCESS) {
+ throw new RuntimeException("Failed to create graphics pipeline");
+ }
+
+ graphicsPipeline = pGraphicsPipeline.get(0);
// ===> RELEASE RESOURCES <===