annotate test1.nim @ 1192:90bf0cab1d02 compiletime-tests

did: so many, many things
author sam <sam@basx.dev>
date Mon, 08 Jul 2024 16:05:06 +0700
parents 239adab121a3
children 5aa1184fa5eb
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()
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
78
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
79 # shaders
1192
90bf0cab1d02 did: so many, many things
sam <sam@basx.dev>
parents: 1191
diff changeset
80 var pipeline1 = CreatePipeline[ShaderA](renderPass = renderpass)
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 var renderdata = InitRenderData()
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
83
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
84 # buffer assignment
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
85 echo "Assigning buffers to GPUData fields"
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 AssignBuffers(renderdata, myMesh1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
88 AssignBuffers(renderdata, instances1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
89 AssignBuffers(renderdata, myGlobals)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
90 AssignBuffers(renderdata, uniforms1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
91
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
92 renderdata.UploadTextures(myGlobals)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
93 renderdata.UploadTextures(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 # copy everything to GPU
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
96 echo "Copying all data to GPU memory"
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
97 UpdateAllGPUBuffers(myMesh1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
98 UpdateAllGPUBuffers(instances1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
99 UpdateAllGPUBuffers(uniforms1)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
100 UpdateAllGPUBuffers(myGlobals)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
101 renderdata.FlushAllMemory()
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
102
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
103
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
104 # descriptors
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
105 echo "Writing descriptors"
1192
90bf0cab1d02 did: so many, many things
sam <sam@basx.dev>
parents: 1191
diff changeset
106 InitDescriptorSet(renderdata, pipeline1.GetLayoutFor(GlobalSet), myGlobals)
90bf0cab1d02 did: so many, many things
sam <sam@basx.dev>
parents: 1191
diff changeset
107 InitDescriptorSet(renderdata, pipeline1.GetLayoutFor(MaterialSet), uniforms1)
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
108
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
109
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
110 # command buffer
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
111 var
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
112 commandBufferPool: VkCommandPool
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
113 createInfo = VkCommandPoolCreateInfo(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
114 sType: VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
115 flags: toBits [VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT],
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
116 queueFamilyIndex: vulkan.queueFamilyIndex,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
117 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
118 checkVkResult vkCreateCommandPool(vulkan.device, addr createInfo, nil, addr commandBufferPool)
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 cmdBuffers: array[INFLIGHTFRAMES.int, VkCommandBuffer]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
121 allocInfo = VkCommandBufferAllocateInfo(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
122 sType: VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
123 commandPool: commandBufferPool,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
124 level: VK_COMMAND_BUFFER_LEVEL_PRIMARY,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
125 commandBufferCount: INFLIGHTFRAMES,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
126 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
127 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
128
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
129 # start command buffer
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
130 block:
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
131 let
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
132 currentFramebuffer = VkFramebuffer(0) # TODO
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
133 currentFrameInFlight = 1
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
134 cmd = cmdBuffers[currentFrameInFlight]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
135 beginInfo = VkCommandBufferBeginInfo(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
136 sType: VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
137 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
138 )
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
139 checkVkResult cmd.vkResetCommandBuffer(VkCommandBufferResetFlags(0))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
140 checkVkResult cmd.vkBeginCommandBuffer(addr(beginInfo))
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
141
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
142 # start renderpass
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
143 block:
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
144 var
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
145 clearColors = [VkClearValue(color: VkClearColorValue(float32: [0, 0, 0, 0]))]
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
146 renderPassInfo = VkRenderPassBeginInfo(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
147 sType: VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
148 renderPass: renderpass,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
149 framebuffer: currentFramebuffer, # TODO
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
150 renderArea: VkRect2D(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
151 offset: VkOffset2D(x: 0, y: 0),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
152 extent: VkExtent2D(width: frameWidth, height: frameHeight),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
153 ),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
154 clearValueCount: uint32(clearColors.len),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
155 pClearValues: clearColors.ToCPointer(),
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
156 )
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
157 viewport = VkViewport(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
158 x: 0.0,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
159 y: 0.0,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
160 width: frameWidth.float32,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
161 height: frameHeight.float32,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
162 minDepth: 0.0,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
163 maxDepth: 1.0,
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
164 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
165 scissor = VkRect2D(
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
166 offset: VkOffset2D(x: 0, y: 0),
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
167 extent: VkExtent2D(width: frameWidth, height: frameHeight)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
168 )
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
169 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
170
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
171 # setup viewport
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
172 vkCmdSetViewport(cmd, firstViewport = 0, viewportCount = 1, addr(viewport))
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
173 vkCmdSetScissor(cmd, firstScissor = 0, scissorCount = 1, addr(scissor))
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 # bind pipeline, will be loop
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
176 block:
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
177 Bind(pipeline1, cmd, currentFrameInFlight = currentFrameInFlight)
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
178
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
179 # render object, will be loop
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
180 block:
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
181 Render(cmd, pipeline1, myGlobals, uniforms1, myMesh1, instances1)
1190
a3eb305bcac2 start of complete and total refactoring: the ULTIMATE
sam <sam@basx.dev>
parents:
diff changeset
182
1191
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
183 vkCmdEndRenderPass(cmd)
239adab121a3 sync from bedroom to office
sam <sam@basx.dev>
parents: 1190
diff changeset
184 checkVkResult cmd.vkEndCommandBuffer()