整理卡死的问题

This commit is contained in:
xsl
2026-04-21 00:03:27 +08:00
parent 5d8e108306
commit 7ab4274e4f
9 changed files with 31 additions and 42 deletions
+14 -17
View File
@@ -582,23 +582,20 @@ void Application::drawFrame(long long frameTime)
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = signalSemaphores;
// graphicsQueue 与主线程 drawFrame、FaceApp::endSingleTimeCommandsJNI/worker 线程)共用,必须串行
{
std::lock_guard<std::mutex> lock(mtx);
if (vkQueueSubmit(graphicsQueue, 1, &submitInfo, inFlightFences[currentFrame]) != VK_SUCCESS) {
throw std::runtime_error("failed to submit draw command buffer!");
}
// 7. 呈现图像
VkPresentInfoKHR presentInfo{};
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
presentInfo.waitSemaphoreCount = 1;
presentInfo.pWaitSemaphores = signalSemaphores;
VkSwapchainKHR swapChains[] = { swapChain };
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = swapChains;
presentInfo.pImageIndices = &imageIndex;
result = vkQueuePresentKHR(presentQueue, &presentInfo);
if (vkQueueSubmit(graphicsQueue, 1, &submitInfo, inFlightFences[currentFrame]) != VK_SUCCESS) {
throw std::runtime_error("failed to submit draw command buffer!");
}
// 7. 呈现图像
VkPresentInfoKHR presentInfo{};
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
presentInfo.waitSemaphoreCount = 1;
presentInfo.pWaitSemaphores = signalSemaphores;
VkSwapchainKHR swapChains[] = { swapChain };
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = swapChains;
presentInfo.pImageIndices = &imageIndex;
result = vkQueuePresentKHR(presentQueue, &presentInfo);
if (result != VK_SUCCESS) {
throw std::runtime_error("failed to present swap chain image!");
}
@@ -854,7 +851,7 @@ void Application::createTexture(VkDevice device, VkPhysicalDevice physicalDevice
void Application::processWithVulkan(uint8_t* data, int width, int height, int rowStride, size_t dataSize, Texture& texture, bool srgb, VkCommandPool pool, std::string tex_path)
{
std::unique_lock<std::mutex> lock(mtx);
std::unique_lock<std::mutex> lock(createTextureMtx);
if (texture.image == VK_NULL_HANDLE)
{
createTexture(device, physicalDevice, width, height, texture, srgb, tex_path, dataSize);