Mercurial > games > semicongine
comparison static_utils.nim @ 1160:836dc1eda5e3 compiletime-tests
did: some stuff
author | sam <sam@basx.dev> |
---|---|
date | Wed, 19 Jun 2024 09:17:24 +0700 |
parents | e7cbb13999e4 |
children | dbca0528c714 |
comparison
equal
deleted
inserted
replaced
1159:e7cbb13999e4 | 1160:836dc1eda5e3 |
---|---|
104 elif typeof(value) is TVec4 and sizeof(getElementType(value)) == 8: | 104 elif typeof(value) is TVec4 and sizeof(getElementType(value)) == 8: |
105 return 2 | 105 return 2 |
106 else: | 106 else: |
107 return 1 | 107 return 1 |
108 | 108 |
109 | |
110 type | 109 type |
111 Renderable[IndexType: static VkIndexType] = object | 110 Renderable = object |
112 buffers: seq[VkBuffer] | 111 buffers: seq[VkBuffer] |
113 offsets: seq[VkDeviceSize] | 112 offsets: seq[VkDeviceSize] |
114 instanceCount: uint32 | 113 instanceCount: uint32 |
115 when IndexType == VK_INDEX_TYPE_NONE_KHR: | 114 case indexType: VkIndexType |
116 vertexCount: uint32 | 115 of VK_INDEX_TYPE_NONE_KHR: |
117 else: | 116 vertexCount: uint32 |
118 indexBuffer: VkBuffer | 117 of VK_INDEX_TYPE_UINT8_EXT, VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32: |
119 indexCount: uint32 | 118 indexBuffer: VkBuffer |
120 indexBufferOffset: VkDeviceSize | 119 indexCount: uint32 |
120 indexBufferOffset: VkDeviceSize | |
121 Pipeline = object | 121 Pipeline = object |
122 pipeline: VkPipeline | 122 pipeline: VkPipeline |
123 layout: VkPipelineLayout | 123 layout: VkPipelineLayout |
124 descriptorSets: array[2, seq[VkDescriptorSet]] | 124 descriptorSets: array[2, seq[VkDescriptorSet]] |
125 ShaderSet[ShaderInputType, ShaderDescriptorType] = object | 125 ShaderSet[ShaderInputType, ShaderDescriptorType] = object |
269 nil, | 269 nil, |
270 addr(result.pipeline) | 270 addr(result.pipeline) |
271 ) | 271 ) |
272 | 272 |
273 | 273 |
274 proc Render*[IndexType: static VkIndexType](renderable: Renderable[IndexType], commandBuffer: VkCommandBuffer, pipeline: Pipeline, frameInFlight: int) = | 274 proc Render*(renderable: Renderable, commandBuffer: VkCommandBuffer, pipeline: Pipeline, frameInFlight: int) = |
275 assert 0 <= frameInFlight and frameInFlight < 2 | 275 assert 0 <= frameInFlight and frameInFlight < 2 |
276 commandBuffer.vkCmdBindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.pipeline) | 276 commandBuffer.vkCmdBindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.pipeline) |
277 commandBuffer.vkCmdBindDescriptorSets( | 277 commandBuffer.vkCmdBindDescriptorSets( |
278 VK_PIPELINE_BIND_POINT_GRAPHICS, | 278 VK_PIPELINE_BIND_POINT_GRAPHICS, |
279 pipeline.layout, | 279 pipeline.layout, |
287 firstBinding = 0'u32, | 287 firstBinding = 0'u32, |
288 bindingCount = uint32(renderable.buffers.len), | 288 bindingCount = uint32(renderable.buffers.len), |
289 pBuffers = renderable.buffers.ToCPointer(), | 289 pBuffers = renderable.buffers.ToCPointer(), |
290 pOffsets = renderable.offsets.ToCPointer() | 290 pOffsets = renderable.offsets.ToCPointer() |
291 ) | 291 ) |
292 when IndexType != VK_INDEX_TYPE_NONE_KHR: | 292 if renderable.indexType != VK_INDEX_TYPE_NONE_KHR: |
293 commandBuffer.vkCmdBindIndexBuffer( | 293 commandBuffer.vkCmdBindIndexBuffer( |
294 renderable.indexBuffer, | 294 renderable.indexBuffer, |
295 renderable.indexBufferOffset, | 295 renderable.indexBufferOffset, |
296 IndexType, | 296 IndexType, |
297 ) | 297 ) |