Mercurial > games > semicongine
comparison src/vulkan_helpers.nim @ 473:04b8471bdab4
did: cleanup up a bit
author | Sam <sam@basx.dev> |
---|---|
date | Tue, 27 Dec 2022 20:47:48 +0700 |
parents | 9eeaeb35eb1c |
children | b40466fa446a |
comparison
equal
deleted
inserted
replaced
472:af43f2acf2b9 | 473:04b8471bdab4 |
---|---|
127 return VK_PRESENT_MODE_FIFO_KHR | 127 return VK_PRESENT_MODE_FIFO_KHR |
128 | 128 |
129 | 129 |
130 proc createVulkanInstance*(vulkanVersion: uint32): VkInstance = | 130 proc createVulkanInstance*(vulkanVersion: uint32): VkInstance = |
131 | 131 |
132 var requiredExtensions = @["VK_KHR_surface".cstring] | |
132 when defined(linux): | 133 when defined(linux): |
133 var requiredExtensions = [ | 134 requiredExtensions.add("VK_KHR_xlib_surface".cstring) |
134 # "VK_EXT_acquire_xlib_display".cstring, | |
135 # "VK_EXT_direct_mode_display".cstring, | |
136 # "VK_KHR_display".cstring, | |
137 "VK_KHR_surface".cstring, | |
138 "VK_KHR_xlib_surface".cstring, | |
139 "VK_EXT_debug_utils".cstring, | |
140 ] | |
141 when defined(windows): | 135 when defined(windows): |
142 var requiredExtensions = [ | 136 requiredExtensions.add("VK_KHR_win32_surface".cstring) |
143 "VK_KHR_win32_surface".cstring, | 137 when ENABLEVULKANVALIDATIONLAYERS: |
144 #"VK_KHR_display".cstring, | 138 requiredExtensions.add("VK_EXT_debug_utils".cstring) |
145 "VK_KHR_surface".cstring, | |
146 "VK_EXT_debug_utils".cstring, | |
147 ] | |
148 | 139 |
149 let availableExtensions = getInstanceExtensions() | 140 let availableExtensions = getInstanceExtensions() |
150 for extension in requiredExtensions: | 141 for extension in requiredExtensions: |
151 assert $extension in availableExtensions, $extension | 142 assert $extension in availableExtensions, $extension |
152 | 143 |
153 let desiredLayers = ["VK_LAYER_KHRONOS_validation".cstring, "VK_LAYER_MESA_overlay".cstring] | |
154 let availableLayers = getValidationLayers() | 144 let availableLayers = getValidationLayers() |
155 var usableLayers = newSeq[cstring]() | 145 var usableLayers = newSeq[cstring]() |
156 | 146 |
157 when ENABLEVULKANVALIDATIONLAYERS: | 147 when ENABLEVULKANVALIDATIONLAYERS: |
148 const desiredLayers = ["VK_LAYER_KHRONOS_validation".cstring, "VK_LAYER_MESA_overlay".cstring] | |
158 for layer in desiredLayers: | 149 for layer in desiredLayers: |
159 if $layer in availableLayers: | 150 if $layer in availableLayers: |
160 usableLayers.add(layer) | 151 usableLayers.add(layer) |
161 | 152 |
162 echo "Available validation layers: ", availableLayers | 153 echo "Available validation layers: ", availableLayers |
174 sType: VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, | 165 sType: VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, |
175 pApplicationInfo: addr(appinfo), | 166 pApplicationInfo: addr(appinfo), |
176 enabledLayerCount: usableLayers.len.uint32, | 167 enabledLayerCount: usableLayers.len.uint32, |
177 ppEnabledLayerNames: cast[ptr UncheckedArray[cstring]](addrOrNil(usableLayers)), | 168 ppEnabledLayerNames: cast[ptr UncheckedArray[cstring]](addrOrNil(usableLayers)), |
178 enabledExtensionCount: requiredExtensions.len.uint32, | 169 enabledExtensionCount: requiredExtensions.len.uint32, |
179 ppEnabledExtensionNames: cast[ptr UncheckedArray[cstring]](addr(requiredExtensions)) | 170 ppEnabledExtensionNames: cast[ptr UncheckedArray[cstring]](addr(requiredExtensions[0])) |
180 ) | 171 ) |
181 checkVkResult vkCreateInstance(addr(createinfo), nil, addr(result)) | 172 checkVkResult vkCreateInstance(addr(createinfo), nil, addr(result)) |
182 | 173 |
183 loadVK_KHR_surface() | 174 loadVK_KHR_surface() |
184 when defined(linux): | 175 when defined(linux): |