Changeset 34bdf3a in opengl-game for vulkan-game.cpp
- Timestamp:
- Oct 24, 2019, 3:35:49 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 87c8f1a
- Parents:
- 603b5bc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
r603b5bc r34bdf3a 18 18 }; 19 19 20 VulkanGame::VulkanGame( ) {20 VulkanGame::VulkanGame(int maxFramesInFlight) : MAX_FRAMES_IN_FLIGHT(maxFramesInFlight) { 21 21 gui = nullptr; 22 22 window = nullptr; … … 169 169 graphicsPipelines.back().createDescriptorSets(swapChainImages); 170 170 171 createCommandBuffers();172 173 171 // TODO: Creating the descriptor pool and descriptor sets might need to be redone when the 174 172 // swap chain is recreated 175 173 176 174 cout << "Created " << graphicsPipelines.size() << " graphics pipelines" << endl; 175 176 createCommandBuffers(); 177 178 createSyncObjects(); 177 179 } 178 180 … … 250 252 } 251 253 254 for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) { 255 vkDestroySemaphore(device, renderFinishedSemaphores[i], nullptr); 256 vkDestroySemaphore(device, imageAvailableSemaphores[i], nullptr); 257 vkDestroyFence(device, inFlightFences[i], nullptr); 258 } 259 252 260 vkDestroyCommandPool(device, commandPool, nullptr); 253 261 vkDestroyDevice(device, nullptr); … … 741 749 } 742 750 751 void VulkanGame::createSyncObjects() { 752 imageAvailableSemaphores.resize(MAX_FRAMES_IN_FLIGHT); 753 renderFinishedSemaphores.resize(MAX_FRAMES_IN_FLIGHT); 754 inFlightFences.resize(MAX_FRAMES_IN_FLIGHT); 755 756 VkSemaphoreCreateInfo semaphoreInfo = {}; 757 semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; 758 759 VkFenceCreateInfo fenceInfo = {}; 760 fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; 761 fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; 762 763 for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) { 764 if (vkCreateSemaphore(device, &semaphoreInfo, nullptr, &imageAvailableSemaphores[i]) != VK_SUCCESS || 765 vkCreateSemaphore(device, &semaphoreInfo, nullptr, &renderFinishedSemaphores[i]) != VK_SUCCESS || 766 vkCreateFence(device, &fenceInfo, nullptr, &inFlightFences[i]) != VK_SUCCESS) { 767 throw runtime_error("failed to create synchronization objects for a frame!"); 768 } 769 } 770 } 771 743 772 void VulkanGame::cleanupSwapChain() { 744 773 VulkanUtils::destroyVulkanImage(device, depthImage);
Note:
See TracChangeset
for help on using the changeset viewer.