annotate test1.nim @ 1196:82feceae80b1 compiletime-tests

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