changeset 1072:d967f9029695

add: some more debug log
author sam <sam@basx.dev>
date Tue, 02 Apr 2024 23:06:39 +0700
parents ec014e90bc46
children 56e3fb525527
files semicongine/engine.nim semicongine/vulkan/drawable.nim
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/engine.nim	Tue Apr 02 22:02:44 2024 +0700
+++ b/semicongine/engine.nim	Tue Apr 02 23:06:39 2024 +0700
@@ -154,6 +154,7 @@
   checkVkResult engine.device.vk.vkDeviceWaitIdle()
 
 proc loadScene*(engine: var Engine, scene: var Scene) =
+  debug &"start loading scene '{scene.name}'"
   assert engine.renderer.isSome
   assert not scene.loaded
   checkVkResult engine.device.vk.vkDeviceWaitIdle()
@@ -162,11 +163,11 @@
   engine.renderer.get.updateMeshData(scene, forceAll = true)
   engine.renderer.get.updateUniformData(scene, forceAll = true)
   checkVkResult engine.device.vk.vkDeviceWaitIdle()
+  debug &"done loading scene '{scene.name}'"
 
 proc unloadScene*(engine: var Engine, scene: Scene) =
-  checkVkResult engine.device.vk.vkDeviceWaitIdle()
+  debug &"unload scene '{scene.name}'"
   engine.renderer.get.destroy(scene)
-  checkVkResult engine.device.vk.vkDeviceWaitIdle()
 
 proc renderScene*(engine: var Engine, scene: var Scene) =
   assert engine.state == Running
--- a/semicongine/vulkan/drawable.nim	Tue Apr 02 22:02:44 2024 +0700
+++ b/semicongine/vulkan/drawable.nim	Tue Apr 02 23:06:39 2024 +0700
@@ -25,16 +25,18 @@
     &"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} with pipeline {pipeline}"
+  debug "Vertex buffers ", vertexBuffers
 
   var buffers: seq[VkBuffer]
   var offsets: seq[VkDeviceSize]
 
-
   for (name, performanceHint, offset) in drawable.bufferOffsets[pipeline]:
+    assert vertexBuffers[performanceHint].vk.valid
     buffers.add vertexBuffers[performanceHint].vk
     offsets.add VkDeviceSize(offset)
 
+  debug "Binding buffers: ", buffers
   commandBuffer.vkCmdBindVertexBuffers(
     firstBinding = 0'u32,
     bindingCount = uint32(buffers.len),
@@ -42,6 +44,7 @@
     pOffsets = offsets.toCPointer()
   )
   if drawable.indexed:
+    assert indexBuffer.vk.valid
     commandBuffer.vkCmdBindIndexBuffer(indexBuffer.vk, VkDeviceSize(drawable.indexBufferOffset), drawable.indexType)
     commandBuffer.vkCmdDrawIndexed(
       indexCount = uint32(drawable.elementCount),