| 249 | |
| 250 | void initVulkan(); |
| 251 | void vk_CreateInstance(CPU* cpu) { |
| 252 | initVulkan(); |
| 253 | MarshalVkInstanceCreateInfo local_pCreateInfo(nullptr, cpu->memory, ARG1); |
| 254 | VkInstanceCreateInfo* pCreateInfo = &local_pCreateInfo.s; |
| 255 | static bool shown; if (!shown && ARG2) { klog("vkCreateInstance:VkAllocationCallbacks not implemented"); shown = true; } |
| 256 | VkAllocationCallbacks* pAllocator = NULL; |
| 257 | VkInstance pInstance; |
| 258 | bool containsDebug = false; |
| 259 | for (U32 i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 260 | if (strstr(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_DEBUG_UTILS_EXTENSION_NAME)) { |
| 261 | containsDebug = true; |
| 262 | } else if (strstr(pCreateInfo->ppEnabledExtensionNames[i], "VK_KHR_xlib_surface")) { |
| 263 | delete[] pCreateInfo->ppEnabledExtensionNames[i]; |
| 264 | #ifdef __MACH__ |
| 265 | const char* platformSurface = "VK_MVK_macos_surface"; |
| 266 | #else |
| 267 | const char* platformSurface = "VK_KHR_win32_surface"; |
| 268 | #endif |
| 269 | char** p = new char* [pCreateInfo->enabledExtensionCount]; |
| 270 | memcpy(p, pCreateInfo->ppEnabledExtensionNames, sizeof(char*) * (pCreateInfo->enabledExtensionCount)); |
| 271 | p[i] = new char[strlen(platformSurface) + 1]; |
| 272 | strcpy(p[i], platformSurface); |
| 273 | delete[] pCreateInfo->ppEnabledExtensionNames; |
| 274 | pCreateInfo->ppEnabledExtensionNames = p; |
| 275 | } |
| 276 | } |
| 277 | #ifdef _DEBUG1 |
| 278 | if (!containsDebug) { |
| 279 | char** p = new char*[pCreateInfo->enabledExtensionCount + 1]; |
| 280 | memcpy(p, pCreateInfo->ppEnabledExtensionNames, sizeof(char*) * (pCreateInfo->enabledExtensionCount)); |
| 281 | p[pCreateInfo->enabledExtensionCount] = new char[strlen(VK_EXT_DEBUG_UTILS_EXTENSION_NAME) + 1]; |
| 282 | strcpy(p[pCreateInfo->enabledExtensionCount], VK_EXT_DEBUG_UTILS_EXTENSION_NAME); |
| 283 | delete[] pCreateInfo->ppEnabledExtensionNames; |
| 284 | pCreateInfo->ppEnabledExtensionNames = p; |
| 285 | pCreateInfo->enabledExtensionCount++; |
| 286 | } |
| 287 | pCreateInfo->enabledLayerCount = 1; |
| 288 | char** names = new char*[2]; |
| 289 | names[0] = (char*)"VK_LAYER_KHRONOS_validation"; |
| 290 | names[1] = (char*)"VK_LAYER_LUNARG_api_dump"; |
| 291 | pCreateInfo->ppEnabledLayerNames = names; |
| 292 | #endif |
| 293 | EAX = pvkCreateInstance(pCreateInfo, pAllocator, &pInstance); |
| 294 | if (EAX == VK_SUCCESS) { |
| 295 | cpu->memory->writed(ARG3, createVulkanPtr(cpu->memory, pInstance, NULL)); |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | void vk_DestroyInstance2(CPU* cpu) { |
| 300 | if (!ARG1) { |
nothing calls this directly
no test coverage detected