| 450 | ScreenshotThreadCleanup screenshot_thread_cleanup; |
| 451 | |
| 452 | VkQueue getQueueForScreenshot(VkDevice device) { |
| 453 | // Find a queue that we can use for taking a screenshot |
| 454 | VkQueue queue = VK_NULL_HANDLE; |
| 455 | uint32_t count; |
| 456 | VkBool32 graphicsCapable = VK_FALSE; |
| 457 | VkBool32 presentCapable = VK_FALSE; |
| 458 | VkuInstanceDispatchTable *pInstanceTable; |
| 459 | DeviceMapStruct *devMap = get_device_info(device); |
| 460 | if (NULL == devMap) { |
| 461 | assert(0); |
| 462 | return queue; |
| 463 | } |
| 464 | |
| 465 | pInstanceTable = instance_dispatch_table(physDeviceMap[devMap->physicalDevice].instance); |
| 466 | assert(pInstanceTable); |
| 467 | pInstanceTable->GetPhysicalDeviceQueueFamilyProperties(devMap->physicalDevice, &count, NULL); |
| 468 | |
| 469 | std::vector<VkQueueFamilyProperties> queueProps(count); |
| 470 | |
| 471 | #if defined(__ANDROID__) |
| 472 | // On Android, all physical devices and queue families must be capable of presentation with any native window |
| 473 | presentCapable = VK_TRUE; |
| 474 | #endif |
| 475 | |
| 476 | if (queueProps.size() > 0) { |
| 477 | pInstanceTable->GetPhysicalDeviceQueueFamilyProperties(devMap->physicalDevice, &count, queueProps.data()); |
| 478 | |
| 479 | // Iterate over all queues for this device, searching for a queue that is graphics and present capable |
| 480 | for (auto it = deviceMap[device]->queues.begin(); it != deviceMap[device]->queues.end(); it++) { |
| 481 | queue = *it; |
| 482 | graphicsCapable = ((queueProps[deviceMap[device]->queueIndexMap[queue]].queueFlags & VK_QUEUE_GRAPHICS_BIT) != 0); |
| 483 | #if defined(_WIN32) |
| 484 | presentCapable = |
| 485 | instance_dispatch_table(devMap->physicalDevice) |
| 486 | ->GetPhysicalDeviceWin32PresentationSupportKHR(devMap->physicalDevice, deviceMap[device]->queueIndexMap[queue]); |
| 487 | #elif not defined(__ANDROID__) |
| 488 | // Everything else not Windows or Android |
| 489 | // TODO: Make a function call to get present support from vkGetPhysicalDeviceXlibPresentationSupportKHR, |
| 490 | // vkGetPhysicalDeviceXcbPresentationSupportKHR, etc |
| 491 | presentCapable = graphicsCapable; |
| 492 | #endif |
| 493 | if (graphicsCapable && presentCapable) break; |
| 494 | } |
| 495 | } |
| 496 | return queue; |
| 497 | } |
| 498 | |
| 499 | // Writes image to a PAM file. |
| 500 | bool writePAM(const char *filename, const char *pixels, uint32_t width, uint32_t height, uint32_t numChannels, uint32_t rowPitch) { |
no test coverage detected