diff src/engine.nim @ 11:3415afff1d1a

Merge /mnt/Users/sam/git/vulkan
author Sam <sam@basx.dev>
date Sat, 24 Dec 2022 22:38:09 +0700
parents 227e53d1a853 0660ba9d1930
children b40466fa446a
line wrap: on
line diff
--- a/src/engine.nim	Sat Dec 24 22:38:03 2022 +0700
+++ b/src/engine.nim	Sat Dec 24 22:38:09 2022 +0700
@@ -12,6 +12,7 @@
 import ./glslang/glslang
 
 const MAX_FRAMES_IN_FLIGHT = 2
+const DEBUG_LOG = not defined(release)
 
 var logger = newConsoleLogger()
 addHandler(logger)
@@ -137,7 +138,7 @@
       height: min(max(uint32(height), capabilities.minImageExtent.height), capabilities.maxImageExtent.height),
     )
 
-when not defined(release):
+when DEBUG_LOG:
   proc setupDebugLog(instance: VkInstance): VkDebugUtilsMessengerEXT =
     var createInfo = VkDebugUtilsMessengerCreateInfoEXT(
       sType: VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
@@ -422,8 +423,6 @@
     vulkan.frameDimension
   )
 
-  # createFramebuffers();
-
 
 proc setupCommandBuffers(device: VkDevice, graphicsQueueFamily: uint32): (VkCommandPool, array[MAX_FRAMES_IN_FLIGHT, VkCommandBuffer]) =
   # set up command buffer
@@ -465,11 +464,12 @@
   vkLoad1_0()
   vkLoad1_1()
   vkLoad1_2()
+
   checkGlslangResult glslang_initialize_process()
 
   # create vulkan instance
   result.vulkan.instance = createVulkanInstance(VULKAN_VERSION)
-  when not defined(release):
+  when DEBUG_LOG:
     result.vulkan.debugMessenger = result.vulkan.instance.setupDebugLog()
   result.vulkan.surface = result.vulkan.instance.createVulkanSurface(result.window)
   result.vulkan.device = result.vulkan.instance.setupVulkanDeviceAndQueues(result.vulkan.surface)
@@ -638,7 +638,7 @@
 
   engine.vulkan.instance.vkDestroySurfaceKHR(engine.vulkan.surface, nil)
   engine.vulkan.device.device.vkDestroyDevice(nil)
-  when ENABLEVULKANVALIDATIONLAYERS:
+  when DEBUG_LOG:
     engine.vulkan.instance.vkDestroyDebugUtilsMessengerEXT(engine.vulkan.debugMessenger, nil)
   glslang_finalize_process()
   engine.window.trash()