diff semicongine/vulkan/drawable.nim @ 902:904e0a827ef3

did: auto-formatting
author Sam <sam@basx.dev>
date Sat, 17 Feb 2024 16:37:24 +0700
parents 44ec744fbedc
children c66503386e8b
line wrap: on
line diff
--- a/semicongine/vulkan/drawable.nim	Sat Feb 17 16:31:54 2024 +0700
+++ b/semicongine/vulkan/drawable.nim	Sat Feb 17 16:37:24 2024 +0700
@@ -8,9 +8,9 @@
 type
   Drawable* = object
     name*: string
-    elementCount*: int # number of vertices or indices
+    elementCount*: int                                                           # number of vertices or indices
     bufferOffsets*: Table[VkPipeline, seq[(string, MemoryPerformanceHint, int)]] # list of buffers and list of offset for each attribute in that buffer
-    instanceCount*: int # number of instance
+    instanceCount*: int                                                          # number of instance
     case indexed*: bool
     of true:
       indexType*: VkIndexType
@@ -25,35 +25,35 @@
     &"Drawable({drawable.name}, elementCount: {drawable.elementCount}, instanceCount: {drawable.instanceCount}, bufferOffsets: {drawable.bufferOffsets})"
 
 proc draw*(drawable: Drawable, commandBuffer: VkCommandBuffer, vertexBuffers: Table[MemoryPerformanceHint, Buffer], indexBuffer: Buffer, pipeline: VkPipeline) =
-    debug "Draw ", drawable
+  debug "Draw ", drawable
 
-    var buffers: seq[VkBuffer]
-    var offsets: seq[VkDeviceSize]
+  var buffers: seq[VkBuffer]
+  var offsets: seq[VkDeviceSize]
 
 
-    for (name, performanceHint, offset) in drawable.bufferOffsets[pipeline]:
-      buffers.add vertexBuffers[performanceHint].vk
-      offsets.add VkDeviceSize(offset)
+  for (name, performanceHint, offset) in drawable.bufferOffsets[pipeline]:
+    buffers.add vertexBuffers[performanceHint].vk
+    offsets.add VkDeviceSize(offset)
 
-    commandBuffer.vkCmdBindVertexBuffers(
-      firstBinding=0'u32,
-      bindingCount=uint32(buffers.len),
-      pBuffers=buffers.toCPointer(),
-      pOffsets=offsets.toCPointer()
+  commandBuffer.vkCmdBindVertexBuffers(
+    firstBinding = 0'u32,
+    bindingCount = uint32(buffers.len),
+    pBuffers = buffers.toCPointer(),
+    pOffsets = offsets.toCPointer()
+  )
+  if drawable.indexed:
+    commandBuffer.vkCmdBindIndexBuffer(indexBuffer.vk, VkDeviceSize(drawable.indexBufferOffset), drawable.indexType)
+    commandBuffer.vkCmdDrawIndexed(
+      indexCount = uint32(drawable.elementCount),
+      instanceCount = uint32(drawable.instanceCount),
+      firstIndex = 0,
+      vertexOffset = 0,
+      firstInstance = 0
     )
-    if drawable.indexed:
-      commandBuffer.vkCmdBindIndexBuffer(indexBuffer.vk, VkDeviceSize(drawable.indexBufferOffset), drawable.indexType)
-      commandBuffer.vkCmdDrawIndexed(
-        indexCount=uint32(drawable.elementCount),
-        instanceCount=uint32(drawable.instanceCount),
-        firstIndex=0,
-        vertexOffset=0,
-        firstInstance=0
-      )
-    else:
-      commandBuffer.vkCmdDraw(
-        vertexCount=uint32(drawable.elementCount),
-        instanceCount=uint32(drawable.instanceCount),
-        firstVertex=0,
-        firstInstance=0
-      )
+  else:
+    commandBuffer.vkCmdDraw(
+      vertexCount = uint32(drawable.elementCount),
+      instanceCount = uint32(drawable.instanceCount),
+      firstVertex = 0,
+      firstInstance = 0
+    )