annotate test1.nim @ 1197:f6a0dc7ad052 compiletime-tests

sync from bedroom to office
author sam <sam@basx.dev>
date Fri, 12 Jul 2024 23:06:29 +0700
parents 82feceae80b1
children 96a094cd0c78
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1197
f6a0dc7ad052 sync from bedroom to office
sam <sam@basx.dev>
parents: 1196
diff changeset
1 import std/os
f6a0dc7ad052 sync from bedroom to office
sam <sam@basx.dev>
parents: 1196
diff changeset
2 import std/options
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
3
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
4 import semicongine
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
5
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
6 type
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
7 MeshA = object
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
8 position: GPUArray[Vec3f, VertexBuffer]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
9 indices: GPUArray[uint16, IndexBuffer]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
10 InstanceA = object
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
11 rotation: GPUArray[Vec4f, VertexBuffer]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
12 objPosition: GPUArray[Vec3f, VertexBuffer]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
13 MaterialA = object
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
14 reflection: float32
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
15 baseColor: Vec3f
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
16 UniformsA = object
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
17 defaultTexture: Texture[TVec4[uint8]]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
18 defaultMaterial: GPUValue[MaterialA, UniformBuffer]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
19 materials: GPUValue[array[3, MaterialA], UniformBuffer]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
20 materialTextures: array[3, Texture[TVec4[uint8]]]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
21 ShaderSettings = object
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
22 gamma: float32
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
23 GlobalsA = object
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
24 fontAtlas: Texture[TVec4[uint8]]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
25 settings: GPUValue[ShaderSettings, UniformBuffer]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
26
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
27 ShaderA = object
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
28 # vertex input
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
29 position {.VertexAttribute.}: Vec3f
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
30 objPosition {.InstanceAttribute.}: Vec3f
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
31 rotation {.InstanceAttribute.}: Vec4f
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
32 # intermediate
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
33 test {.Pass.}: float32
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
34 test1 {.PassFlat.}: Vec3f
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
35 # output
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
36 color {.ShaderOutput.}: Vec4f
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
37 # descriptor sets
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
38 globals: DescriptorSet[GlobalsA, GlobalSet]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
39 uniforms: DescriptorSet[UniformsA, MaterialSet]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
40 # code
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
41 vertexCode: string = "void main() {}"
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
42 fragmentCode: string = "void main() {}"
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
43
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
44 putEnv("VK_LAYER_ENABLES", "VALIDATION_CHECK_ENABLE_VENDOR_SPECIFIC_AMD,VALIDATION_CHECK_ENABLE_VENDOR_SPECIFIC_NVIDIA,VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXTVK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT,VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT")
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
45
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
46 let frameWidth = 100'u32
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
47 let frameHeight = 100'u32
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
48
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
49 var myMesh1 = MeshA(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
50 position: GPUArray[Vec3f, VertexBuffer](data: @[NewVec3f(0, 0, ), NewVec3f(0, 0, ), NewVec3f(0, 0, )]),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
51 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
52 var uniforms1 = DescriptorSet[UniformsA, MaterialSet](
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
53 data: UniformsA(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
54 defaultTexture: Texture[TVec4[uint8]](width: 1, height: 1, data: @[TVec4[uint8]([0'u8, 0'u8, 0'u8, 1'u8])]),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
55 materials: GPUValue[array[3, MaterialA], UniformBuffer](data: [
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
56 MaterialA(reflection: 0, baseColor: NewVec3f(1, 0, 0)),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
57 MaterialA(reflection: 0.1, baseColor: NewVec3f(0, 1, 0)),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
58 MaterialA(reflection: 0.5, baseColor: NewVec3f(0, 0, 1)),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
59 ]),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
60 materialTextures: [
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
61 Texture[TVec4[uint8]](width: 1, height: 1, data: @[TVec4[uint8]([0'u8, 0'u8, 0'u8, 1'u8])]),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
62 Texture[TVec4[uint8]](width: 1, height: 1, data: @[TVec4[uint8]([0'u8, 0'u8, 0'u8, 1'u8])]),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
63 Texture[TVec4[uint8]](width: 1, height: 1, data: @[TVec4[uint8]([0'u8, 0'u8, 0'u8, 1'u8])]),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
64 ]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
65 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
66 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
67 var instances1 = InstanceA(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
68 rotation: GPUArray[Vec4f, VertexBuffer](data: @[NewVec4f(1, 0, 0, 0.1), NewVec4f(0, 1, 0, 0.1)]),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
69 objPosition: GPUArray[Vec3f, VertexBuffer](data: @[NewVec3f(0, 0, 0), NewVec3f(1, 1, 1)]),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
70 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
71 var myGlobals = DescriptorSet[GlobalsA, GlobalSet](
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
72 data: GlobalsA(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
73 fontAtlas: Texture[TVec4[uint8]](width: 1, height: 1, data: @[TVec4[uint8]([0'u8, 0'u8, 0'u8, 1'u8])]),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
74 settings: GPUValue[ShaderSettings, UniformBuffer](data: ShaderSettings(gamma: 1.0))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
75 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
76 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
77
1192
90bf0cab1d02 did: so many, many things
sam <sam@basx.dev>
parents: 1191
diff changeset
78 let renderpass = CreatePresentationRenderPass()
1196
82feceae80b1 sync from bedroom to office
sam <sam@basx.dev>
parents: 1193
diff changeset
79 var swapchainResult = InitSwapchain(renderpass)
82feceae80b1 sync from bedroom to office
sam <sam@basx.dev>
parents: 1193
diff changeset
80 assert swapchainResult.isSome()
82feceae80b1 sync from bedroom to office
sam <sam@basx.dev>
parents: 1193
diff changeset
81 var swapchain = swapchainResult.get()
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
82
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
83 # shaders
1192
90bf0cab1d02 did: so many, many things
sam <sam@basx.dev>
parents: 1191
diff changeset
84 var pipeline1 = CreatePipeline[ShaderA](renderPass = renderpass)
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
85
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
86 var renderdata = InitRenderData()
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
87
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
88 # buffer assignment
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
89 echo "Assigning buffers to GPUData fields"
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
90
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
91 AssignBuffers(renderdata, myMesh1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
92 AssignBuffers(renderdata, instances1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
93 AssignBuffers(renderdata, myGlobals)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
94 AssignBuffers(renderdata, uniforms1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
95
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
96 renderdata.UploadTextures(myGlobals)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
97 renderdata.UploadTextures(uniforms1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
98
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
99 # copy everything to GPU
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
100 echo "Copying all data to GPU memory"
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
101 UpdateAllGPUBuffers(myMesh1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
102 UpdateAllGPUBuffers(instances1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
103 UpdateAllGPUBuffers(uniforms1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
104 UpdateAllGPUBuffers(myGlobals)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
105 renderdata.FlushAllMemory()
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
106
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
107
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
108 # descriptors
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
109 echo "Writing descriptors"
1192
90bf0cab1d02 did: so many, many things
sam <sam@basx.dev>
parents: 1191
diff changeset
110 InitDescriptorSet(renderdata, pipeline1.GetLayoutFor(GlobalSet), myGlobals)
90bf0cab1d02 did: so many, many things
sam <sam@basx.dev>
parents: 1191
diff changeset
111 InitDescriptorSet(renderdata, pipeline1.GetLayoutFor(MaterialSet), uniforms1)
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
112
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
113
1196
82feceae80b1 sync from bedroom to office
sam <sam@basx.dev>
parents: 1193
diff changeset
114
82feceae80b1 sync from bedroom to office
sam <sam@basx.dev>
parents: 1193
diff changeset
115
82feceae80b1 sync from bedroom to office
sam <sam@basx.dev>
parents: 1193
diff changeset
116
82feceae80b1 sync from bedroom to office
sam <sam@basx.dev>
parents: 1193
diff changeset
117
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
118 # command buffer
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
119 var
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
120 commandBufferPool: VkCommandPool
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
121 createInfo = VkCommandPoolCreateInfo(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
122 sType: VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
123 flags: toBits [VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT],
1193
5aa1184fa5eb did: a few more things
sam <sam@basx.dev>
parents: 1192
diff changeset
124 queueFamilyIndex: vulkan.graphicsQueueFamily,
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
125 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
126 checkVkResult vkCreateCommandPool(vulkan.device, addr createInfo, nil, addr commandBufferPool)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
127 var
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
128 cmdBuffers: array[INFLIGHTFRAMES.int, VkCommandBuffer]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
129 allocInfo = VkCommandBufferAllocateInfo(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
130 sType: VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
131 commandPool: commandBufferPool,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
132 level: VK_COMMAND_BUFFER_LEVEL_PRIMARY,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
133 commandBufferCount: INFLIGHTFRAMES,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
134 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
135 checkVkResult vkAllocateCommandBuffers(vulkan.device, addr allocInfo, cmdBuffers.ToCPointer)
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
136
1197
f6a0dc7ad052 sync from bedroom to office
sam <sam@basx.dev>
parents: 1196
diff changeset
137
f6a0dc7ad052 sync from bedroom to office
sam <sam@basx.dev>
parents: 1196
diff changeset
138
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
139 # start command buffer
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
140 block:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
141 let
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
142 currentFramebuffer = VkFramebuffer(0) # TODO
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
143 currentFrameInFlight = 1
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
144 cmd = cmdBuffers[currentFrameInFlight]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
145 beginInfo = VkCommandBufferBeginInfo(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
146 sType: VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
147 flags: VkCommandBufferUsageFlags(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT),
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
148 )
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
149 checkVkResult cmd.vkResetCommandBuffer(VkCommandBufferResetFlags(0))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
150 checkVkResult cmd.vkBeginCommandBuffer(addr(beginInfo))
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
151
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
152 # start renderpass
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
153 block:
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
154 var
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
155 clearColors = [VkClearValue(color: VkClearColorValue(float32: [0, 0, 0, 0]))]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
156 renderPassInfo = VkRenderPassBeginInfo(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
157 sType: VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
158 renderPass: renderpass,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
159 framebuffer: currentFramebuffer, # TODO
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
160 renderArea: VkRect2D(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
161 offset: VkOffset2D(x: 0, y: 0),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
162 extent: VkExtent2D(width: frameWidth, height: frameHeight),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
163 ),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
164 clearValueCount: uint32(clearColors.len),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
165 pClearValues: clearColors.ToCPointer(),
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
166 )
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
167 viewport = VkViewport(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
168 x: 0.0,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
169 y: 0.0,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
170 width: frameWidth.float32,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
171 height: frameHeight.float32,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
172 minDepth: 0.0,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
173 maxDepth: 1.0,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
174 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
175 scissor = VkRect2D(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
176 offset: VkOffset2D(x: 0, y: 0),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
177 extent: VkExtent2D(width: frameWidth, height: frameHeight)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
178 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
179 vkCmdBeginRenderPass(cmd, addr(renderPassInfo), VK_SUBPASS_CONTENTS_INLINE)
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
180
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
181 # setup viewport
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
182 vkCmdSetViewport(cmd, firstViewport = 0, viewportCount = 1, addr(viewport))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
183 vkCmdSetScissor(cmd, firstScissor = 0, scissorCount = 1, addr(scissor))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
184
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
185 # bind pipeline, will be loop
1197
f6a0dc7ad052 sync from bedroom to office
sam <sam@basx.dev>
parents: 1196
diff changeset
186 # block:
f6a0dc7ad052 sync from bedroom to office
sam <sam@basx.dev>
parents: 1196
diff changeset
187 # Bind(pipeline1, cmd, currentFrameInFlight = currentFrameInFlight)
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
188
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
189 # render object, will be loop
1197
f6a0dc7ad052 sync from bedroom to office
sam <sam@basx.dev>
parents: 1196
diff changeset
190 # block:
f6a0dc7ad052 sync from bedroom to office
sam <sam@basx.dev>
parents: 1196
diff changeset
191 # Render(cmd, pipeline1, myGlobals, uniforms1, myMesh1, instances1)
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
192
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
193 vkCmdEndRenderPass(cmd)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
194 checkVkResult cmd.vkEndCommandBuffer()