This function issues commands to copy/convert the swapchain image from whatever compatible format the swapchain image uses to a single format (VK_FORMAT_R8G8B8A8_UNORM) so that the converted result can be easily written to a PPM file. Error handling: If there is a problem, this function should silently fail without affecting the Present operation going on in the caller. The numerous debug asserts
| 1158 | // |
| 1159 | // Returns true if successfull, false otherwise. |
| 1160 | static bool queueScreenshot(ScreenshotQueueData &data, VkImage image1, const VkPresentInfoKHR *presentInfo) { |
| 1161 | PROFILE("screenshot.queue"); |
| 1162 | if (data.device == VK_NULL_HANDLE) { |
| 1163 | if (!prepareScreenshotData(data, image1)) { |
| 1164 | assert(false); |
| 1165 | return false; |
| 1166 | } |
| 1167 | } else { |
| 1168 | if (data.pTableDevice->ResetFences(data.device, 1, &data.fence) != VK_SUCCESS) { |
| 1169 | assert(false); |
| 1170 | return false; |
| 1171 | } |
| 1172 | } |
| 1173 | |
| 1174 | VkSubmitInfo submitInfo; |
| 1175 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1176 | submitInfo.pNext = NULL; |
| 1177 | submitInfo.commandBufferCount = 1; |
| 1178 | submitInfo.pCommandBuffers = &data.commandBuffer; |
| 1179 | VkPipelineStageFlags layerWaitStage = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; |
| 1180 | submitInfo.pWaitDstStageMask = &layerWaitStage; |
| 1181 | submitInfo.pWaitSemaphores = presentInfo->pWaitSemaphores; |
| 1182 | submitInfo.waitSemaphoreCount = presentInfo->waitSemaphoreCount; |
| 1183 | submitInfo.signalSemaphoreCount = 1; |
| 1184 | submitInfo.pSignalSemaphores = &data.semaphore; |
| 1185 | |
| 1186 | VkQueue queue = getQueueForScreenshot(data.device); |
| 1187 | if (!queue) { |
| 1188 | #ifdef ANDROID |
| 1189 | __android_log_print(ANDROID_LOG_ERROR, "screenshot", "Failure - capable queue not found\n"); |
| 1190 | #else |
| 1191 | fprintf(stderr, "screenshot: Could not find a capable queue\n"); |
| 1192 | #endif |
| 1193 | return false; |
| 1194 | } |
| 1195 | |
| 1196 | VkuDeviceDispatchTable *pTableQueue = |
| 1197 | get_dispatch_info(static_cast<VkDevice>(static_cast<void *>(queue)))->device_dispatch_table; |
| 1198 | |
| 1199 | VkResult err = pTableQueue->QueueSubmit(queue, 1, &submitInfo, data.fence); |
| 1200 | assert(!err); |
| 1201 | |
| 1202 | return true; |
| 1203 | } |
| 1204 | |
| 1205 | // Save an image to a PPM image file. |
| 1206 | // Returns true if file is successfully written, false otherwise. |
no test coverage detected