annotate semiconginev2/rendering/renderpasses.nim @ 1221:000befd9479f compiletime-tests

did: remove support for git, for now
author sam <sam@basx.dev>
date Wed, 17 Jul 2024 21:05:47 +0700
parents 56781cc0fc7c
children 5dcb503ef0c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1214
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
1 proc CreateDirectPresentationRenderPass*(samples = VK_SAMPLE_COUNT_1_BIT): VkRenderPass =
1204
e2901100a596 add: tests, some fixes, some helpers
sam <sam@basx.dev>
parents: 1199
diff changeset
2 assert vulkan.instance.Valid, "Vulkan not initialized"
e2901100a596 add: tests, some fixes, some helpers
sam <sam@basx.dev>
parents: 1199
diff changeset
3
1199
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
4 let format = DefaultSurfaceFormat()
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
5 var attachments = @[VkAttachmentDescription(
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
6 format: format,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
7 samples: samples,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
8 loadOp: VK_ATTACHMENT_LOAD_OP_CLEAR,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
9 storeOp: VK_ATTACHMENT_STORE_OP_STORE,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
10 stencilLoadOp: VK_ATTACHMENT_LOAD_OP_DONT_CARE,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
11 stencilStoreOp: VK_ATTACHMENT_STORE_OP_DONT_CARE,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
12 initialLayout: VK_IMAGE_LAYOUT_UNDEFINED,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
13 finalLayout: if samples == VK_SAMPLE_COUNT_1_BIT: VK_IMAGE_LAYOUT_PRESENT_SRC_KHR else: VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
14 )]
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
15 if samples != VK_SAMPLE_COUNT_1_BIT:
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
16 attachments.add VkAttachmentDescription(
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
17 format: format,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
18 samples: VK_SAMPLE_COUNT_1_BIT,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
19 loadOp: VK_ATTACHMENT_LOAD_OP_DONT_CARE,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
20 storeOp: VK_ATTACHMENT_STORE_OP_STORE,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
21 stencilLoadOp: VK_ATTACHMENT_LOAD_OP_DONT_CARE,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
22 stencilStoreOp: VK_ATTACHMENT_STORE_OP_DONT_CARE,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
23 initialLayout: VK_IMAGE_LAYOUT_UNDEFINED,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
24 finalLayout: VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
25 )
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
26 var
1214
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
27 dependencies = @[
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
28 VkSubpassDependency(
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
29 srcSubpass: VK_SUBPASS_EXTERNAL,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
30 dstSubpass: 0,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
31 srcStageMask: toBits [VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
32 dstStageMask: toBits [VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
33 srcAccessMask: toBits [VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
34 dstAccessMask: toBits [VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
35 )
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
36 ]
1199
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
37 colorAttachment = VkAttachmentReference(
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
38 attachment: 0,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
39 layout: VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
40 )
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
41 resolveAttachment = VkAttachmentReference(
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
42 attachment: 1,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
43 layout: VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
44 )
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
45
1214
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
46 if samples == VK_SAMPLE_COUNT_1_BIT:
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
47 return svkCreateRenderPass(attachments, [colorAttachment], [], dependencies)
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
48 else:
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
49 return svkCreateRenderPass(attachments, [colorAttachment], [resolveAttachment], dependencies)
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
50
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
51 proc CreateIndirectPresentationRenderPass*(): (VkRenderPass, VkRenderPass) =
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
52 assert vulkan.instance.Valid, "Vulkan not initialized"
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
53
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
54 # first renderpass, drawing
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
55 let format = DefaultSurfaceFormat()
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
56 var
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
57 attachments = @[VkAttachmentDescription(
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
58 format: format,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
59 samples: VK_SAMPLE_COUNT_1_BIT,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
60 loadOp: VK_ATTACHMENT_LOAD_OP_CLEAR,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
61 storeOp: VK_ATTACHMENT_STORE_OP_STORE,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
62 stencilLoadOp: VK_ATTACHMENT_LOAD_OP_DONT_CARE,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
63 stencilStoreOp: VK_ATTACHMENT_STORE_OP_DONT_CARE,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
64 initialLayout: VK_IMAGE_LAYOUT_UNDEFINED,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
65 finalLayout: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
66 )]
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
67
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
68 dependencies = @[
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
69 VkSubpassDependency(
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
70 srcSubpass: VK_SUBPASS_EXTERNAL,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
71 dstSubpass: 0,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
72 srcStageMask: toBits [VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
73 dstStageMask: toBits [VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
74 srcAccessMask: VkAccessFlags(0),
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
75 dstAccessMask: toBits [VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
76 ),
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
77 VkSubpassDependency(
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
78 srcSubpass: VK_SUBPASS_EXTERNAL,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
79 dstSubpass: 0,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
80 srcStageMask: toBits [VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
81 dstStageMask: toBits [VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
82 srcAccessMask: toBits [VK_ACCESS_SHADER_READ_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
83 dstAccessMask: toBits [VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
84 ),
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
85 VkSubpassDependency(
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
86 srcSubpass: 0,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
87 dstSubpass: VK_SUBPASS_EXTERNAL,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
88 srcStageMask: toBits [VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
89 dstStageMask: toBits [VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
90 srcAccessMask: toBits [VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
91 dstAccessMask: toBits [VK_ACCESS_SHADER_READ_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
92 ),
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
93 ]
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
94 colorAttachment = VkAttachmentReference(
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
95 attachment: 0,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
96 layout: VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
97 )
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
98
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
99 # second renderpass, presentation
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
100 var
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
101 presentAttachments = @[VkAttachmentDescription(
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
102 format: format,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
103 samples: VK_SAMPLE_COUNT_1_BIT,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
104 loadOp: VK_ATTACHMENT_LOAD_OP_CLEAR,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
105 storeOp: VK_ATTACHMENT_STORE_OP_STORE,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
106 stencilLoadOp: VK_ATTACHMENT_LOAD_OP_DONT_CARE,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
107 stencilStoreOp: VK_ATTACHMENT_STORE_OP_DONT_CARE,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
108 initialLayout: VK_IMAGE_LAYOUT_UNDEFINED,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
109 finalLayout: VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
110 )]
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
111 presentDependencies = @[VkSubpassDependency(
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
112 srcSubpass: VK_SUBPASS_EXTERNAL,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
113 dstSubpass: 0,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
114 srcStageMask: toBits [VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
115 dstStageMask: toBits [VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
116 srcAccessMask: VkAccessFlags(0),
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
117 dstAccessMask: toBits [VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT],
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
118 )]
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
119 presentColorAttachment = VkAttachmentReference(
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
120 attachment: 0,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
121 layout: VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
122 )
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
123
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
124 result = (
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
125 svkCreateRenderPass(attachments, [colorAttachment], [], dependencies),
04e446a7eb2b add: multipass renderer, finish tets for now
sam <sam@basx.dev>
parents: 1204
diff changeset
126 svkCreateRenderPass(presentAttachments, [presentColorAttachment], [], presentDependencies)
1199
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
127 )
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
128
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
129 template WithRenderPass*(
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
130 theRenderpass: VkRenderPass,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
131 theFramebuffer: VkFramebuffer,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
132 commandbuffer: VkCommandBuffer,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
133 renderWidth: uint32,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
134 renderHeight: uint32,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
135 clearColor: Vec4f,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
136 body: untyped
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
137 ): untyped =
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
138 var
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
139 clearColors = [VkClearValue(color: VkClearColorValue(float32: clearColor))]
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
140 renderPassInfo = VkRenderPassBeginInfo(
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
141 sType: VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
142 renderPass: theRenderpass,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
143 framebuffer: theFramebuffer,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
144 renderArea: VkRect2D(
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
145 offset: VkOffset2D(x: 0, y: 0),
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
146 extent: VkExtent2D(width: renderWidth, height: renderHeight),
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
147 ),
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
148 clearValueCount: uint32(clearColors.len),
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
149 pClearValues: clearColors.ToCPointer(),
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
150 )
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
151 viewport = VkViewport(
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
152 x: 0.0,
1204
e2901100a596 add: tests, some fixes, some helpers
sam <sam@basx.dev>
parents: 1199
diff changeset
153 y: renderHeight.float32,
1199
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
154 width: renderWidth.float32,
1204
e2901100a596 add: tests, some fixes, some helpers
sam <sam@basx.dev>
parents: 1199
diff changeset
155 height: -renderHeight.float32,
1199
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
156 minDepth: 0.0,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
157 maxDepth: 1.0,
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
158 )
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
159 scissor = VkRect2D(
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
160 offset: VkOffset2D(x: 0, y: 0),
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
161 extent: VkExtent2D(width: renderWidth, height: renderHeight)
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
162 )
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
163
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
164 vkCmdBeginRenderPass(commandbuffer, addr(renderPassInfo), VK_SUBPASS_CONTENTS_INLINE)
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
165
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
166 # setup viewport
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
167 vkCmdSetViewport(commandbuffer, firstViewport = 0, viewportCount = 1, addr(viewport))
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
168 vkCmdSetScissor(commandbuffer, firstScissor = 0, scissorCount = 1, addr(scissor))
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
169
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
170 block:
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
171 body
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
172
ba1af13233ee add: working main-renderloop
sam <sam@basx.dev>
parents:
diff changeset
173 vkCmdEndRenderPass(commandbuffer)