Changeset fa9fa1c in opengl-game
- Timestamp:
- Sep 27, 2019, 8:53:27 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 7563b8a, a0da009
- Parents:
- 0e09340
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
r0e09340 rfa9fa1c 104 104 createImageViews(); 105 105 createRenderPass(); 106 createCommandPool(); 106 107 } 107 108 … … 167 168 cleanupSwapChain(); 168 169 170 vkDestroyCommandPool(device, commandPool, nullptr); 169 171 vkDestroyDevice(device, nullptr); 170 172 vkDestroySurfaceKHR(instance, surface, nullptr); … … 293 295 } 294 296 295 bool VulkanGame::isDeviceSuitable(VkPhysicalDevice device, const vector<const char*>& deviceExtensions) { 297 bool VulkanGame::isDeviceSuitable(VkPhysicalDevice physicalDevice, 298 const vector<const char*>& deviceExtensions) { 296 299 VkPhysicalDeviceProperties deviceProperties; 297 vkGetPhysicalDeviceProperties( device, &deviceProperties);300 vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties); 298 301 299 302 cout << "Device: " << deviceProperties.deviceName << endl; 300 303 301 QueueFamilyIndices indices = VulkanUtils::findQueueFamilies( device, surface);302 bool extensionsSupported = VulkanUtils::checkDeviceExtensionSupport( device, deviceExtensions);304 QueueFamilyIndices indices = VulkanUtils::findQueueFamilies(physicalDevice, surface); 305 bool extensionsSupported = VulkanUtils::checkDeviceExtensionSupport(physicalDevice, deviceExtensions); 303 306 bool swapChainAdequate = false; 304 307 305 308 if (extensionsSupported) { 306 SwapChainSupportDetails swapChainSupport = VulkanUtils::querySwapChainSupport( device, surface);309 SwapChainSupportDetails swapChainSupport = VulkanUtils::querySwapChainSupport(physicalDevice, surface); 307 310 swapChainAdequate = !swapChainSupport.formats.empty() && !swapChainSupport.presentModes.empty(); 308 311 } 309 312 310 313 VkPhysicalDeviceFeatures supportedFeatures; 311 vkGetPhysicalDeviceFeatures( device, &supportedFeatures);314 vkGetPhysicalDeviceFeatures(physicalDevice, &supportedFeatures); 312 315 313 316 return indices.isComplete() && extensionsSupported && swapChainAdequate && supportedFeatures.samplerAnisotropy; … … 492 495 } 493 496 497 void VulkanGame::createCommandPool() { 498 QueueFamilyIndices queueFamilyIndices = VulkanUtils::findQueueFamilies(physicalDevice, surface);; 499 500 VkCommandPoolCreateInfo poolInfo = {}; 501 poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; 502 poolInfo.queueFamilyIndex = queueFamilyIndices.graphicsFamily.value(); 503 poolInfo.flags = 0; 504 505 if (vkCreateCommandPool(device, &poolInfo, nullptr, &commandPool) != VK_SUCCESS) { 506 throw runtime_error("failed to create graphics command pool!"); 507 } 508 } 509 494 510 void VulkanGame::cleanupSwapChain() { 495 511 vkDestroyRenderPass(device, renderPass, nullptr); -
vulkan-game.hpp
r0e09340 rfa9fa1c 38 38 VkExtent2D swapChainExtent; 39 39 vector<VkImageView> swapChainImageViews; 40 40 41 VkRenderPass renderPass; 42 VkCommandPool commandPool; 41 43 42 44 bool framebufferResized = false; … … 54 56 void createVulkanSurface(); 55 57 void pickPhysicalDevice(const vector<const char*>& deviceExtensions); 56 bool isDeviceSuitable(VkPhysicalDevice device, const vector<const char*>& deviceExtensions);58 bool isDeviceSuitable(VkPhysicalDevice physicalDevice, const vector<const char*>& deviceExtensions); 57 59 void createLogicalDevice( 58 60 const vector<const char*> validationLayers, … … 62 64 void createRenderPass(); 63 65 VkFormat findDepthFormat(); 66 void createCommandPool(); 64 67 65 68 void cleanupSwapChain(); -
vulkan-ref.cpp
r0e09340 rfa9fa1c 179 179 /*** START OF REFACTORED CODE ***/ 180 180 VkRenderPass renderPass; 181 182 VkCommandPool commandPool; 181 183 /*** END OF REFACTORED CODE ***/ 182 183 VkCommandPool commandPool;184 184 vector<VkCommandBuffer> commandBuffers; 185 185 … … 322 322 createImageViews(); 323 323 createRenderPass(); 324 325 createCommandPool(); 324 326 /*** END OF REFACTORED CODE ***/ 325 326 createCommandPool();327 327 328 328 createImageResources("textures/texture.jpg", textureImage, textureImageMemory, textureImageView); … … 1025 1025 } 1026 1026 1027 /*** START OF REFACTORED CODE ***/ 1027 1028 void createCommandPool() { 1028 1029 QueueFamilyIndices queueFamilyIndices = findQueueFamilies(physicalDevice); … … 1038 1039 } 1039 1040 1040 /*** START OF REFACTORED CODE ***/1041 1041 QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device) { 1042 1042 QueueFamilyIndices indices; … … 1893 1893 } 1894 1894 1895 /*** START OF REFACTORED CODE ***/ 1895 1896 vkDestroyCommandPool(device, commandPool, nullptr); 1896 /*** START OF REFACTORED CODE ***/1897 1897 vkDestroyDevice(device, nullptr); 1898 1898 vkDestroySurfaceKHR(instance, surface, nullptr);
Note:
See TracChangeset
for help on using the changeset viewer.