Mercurial > games > semicongine
comparison src/engine.nim @ 8:1134f41a49e9
add: a few missing changes
author | Sam <sam@basx.dev> |
---|---|
date | Thu, 22 Dec 2022 19:35:54 +0700 |
parents | 4ed9cb098315 |
children | 227e53d1a853 0660ba9d1930 |
comparison
equal
deleted
inserted
replaced
7:a48af6ac67d6 | 8:1134f41a49e9 |
---|---|
135 return VkExtent2D( | 135 return VkExtent2D( |
136 width: min(max(uint32(width), capabilities.minImageExtent.width), capabilities.maxImageExtent.width), | 136 width: min(max(uint32(width), capabilities.minImageExtent.width), capabilities.maxImageExtent.width), |
137 height: min(max(uint32(height), capabilities.minImageExtent.height), capabilities.maxImageExtent.height), | 137 height: min(max(uint32(height), capabilities.minImageExtent.height), capabilities.maxImageExtent.height), |
138 ) | 138 ) |
139 | 139 |
140 proc setupDebugLog(instance: VkInstance): VkDebugUtilsMessengerEXT = | 140 when not defined(release): |
141 var createInfo = VkDebugUtilsMessengerCreateInfoEXT( | 141 proc setupDebugLog(instance: VkInstance): VkDebugUtilsMessengerEXT = |
142 sType: VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, | 142 var createInfo = VkDebugUtilsMessengerCreateInfoEXT( |
143 messageSeverity: VkDebugUtilsMessageSeverityFlagsEXT( | 143 sType: VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, |
144 ord(VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) or | 144 messageSeverity: VkDebugUtilsMessageSeverityFlagsEXT( |
145 ord(VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) or | 145 ord(VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) or |
146 ord(VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) | 146 ord(VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) or |
147 ), | 147 ord(VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) |
148 messageType: VkDebugUtilsMessageTypeFlagsEXT( | 148 ), |
149 ord(VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT) or | 149 messageType: VkDebugUtilsMessageTypeFlagsEXT( |
150 ord(VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) or | 150 ord(VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT) or |
151 ord(VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) | 151 ord(VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) or |
152 ), | 152 ord(VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) |
153 pfnUserCallback: debugCallback, | 153 ), |
154 pUserData: nil, | 154 pfnUserCallback: debugCallback, |
155 ) | 155 pUserData: nil, |
156 checkVkResult instance.vkCreateDebugUtilsMessengerEXT(addr(createInfo), nil, addr(result)) | 156 ) |
157 checkVkResult instance.vkCreateDebugUtilsMessengerEXT(addr(createInfo), nil, addr(result)) | |
157 | 158 |
158 proc setupVulkanDeviceAndQueues(instance: VkInstance, surface: VkSurfaceKHR): Device = | 159 proc setupVulkanDeviceAndQueues(instance: VkInstance, surface: VkSurfaceKHR): Device = |
159 let usableDevices = instance.getAllPhysicalDevices(surface).filterForDevice() | 160 let usableDevices = instance.getAllPhysicalDevices(surface).filterForDevice() |
160 if len(usableDevices) == 0: | 161 if len(usableDevices) == 0: |
161 raise newException(Exception, "No suitable graphics device found") | 162 raise newException(Exception, "No suitable graphics device found") |
466 vkLoad1_2() | 467 vkLoad1_2() |
467 checkGlslangResult glslang_initialize_process() | 468 checkGlslangResult glslang_initialize_process() |
468 | 469 |
469 # create vulkan instance | 470 # create vulkan instance |
470 result.vulkan.instance = createVulkanInstance(VULKAN_VERSION) | 471 result.vulkan.instance = createVulkanInstance(VULKAN_VERSION) |
471 when ENABLEVULKANVALIDATIONLAYERS: | 472 when not defined(release): |
472 result.vulkan.debugMessenger = result.vulkan.instance.setupDebugLog() | 473 result.vulkan.debugMessenger = result.vulkan.instance.setupDebugLog() |
473 result.vulkan.surface = result.vulkan.instance.createVulkanSurface(result.window) | 474 result.vulkan.surface = result.vulkan.instance.createVulkanSurface(result.window) |
474 result.vulkan.device = result.vulkan.instance.setupVulkanDeviceAndQueues(result.vulkan.surface) | 475 result.vulkan.device = result.vulkan.instance.setupVulkanDeviceAndQueues(result.vulkan.surface) |
475 | 476 |
476 # get basic frame information | 477 # get basic frame information |