Changeset fe5c3ba in opengl-game
- Timestamp:
- Sep 22, 2019, 2:28:22 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- a0c5f28
- Parents:
- 90a424f
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
r90a424f rfe5c3ba 90 90 "VK_LAYER_KHRONOS_validation" 91 91 }; 92 const vector<const char*> deviceExtensions = { 93 VK_KHR_SWAPCHAIN_EXTENSION_NAME 94 }; 92 95 93 96 createVulkanInstance(validationLayers); 94 97 setupDebugMessenger(); 95 98 createVulkanSurface(); 96 pickPhysicalDevice( );99 pickPhysicalDevice(deviceExtensions); 97 100 } 98 101 … … 239 242 } 240 243 241 void VulkanGame::pickPhysicalDevice( ) {244 void VulkanGame::pickPhysicalDevice(const vector<const char*>& deviceExtensions) { 242 245 uint32_t deviceCount = 0; 243 246 vkEnumeratePhysicalDevices(instance, &deviceCount, nullptr); … … 252 255 cout << endl << "Graphics cards:" << endl; 253 256 for (const VkPhysicalDevice& device : devices) { 254 if (isDeviceSuitable(device )) {257 if (isDeviceSuitable(device, deviceExtensions)) { 255 258 physicalDevice = device; 256 259 break; … … 264 267 } 265 268 266 bool VulkanGame::isDeviceSuitable(VkPhysicalDevice device) { 267 const vector<const char*> deviceExtensions = { 268 VK_KHR_SWAPCHAIN_EXTENSION_NAME 269 }; 270 269 bool VulkanGame::isDeviceSuitable(VkPhysicalDevice device, const vector<const char*>& deviceExtensions) { 271 270 VkPhysicalDeviceProperties deviceProperties; 272 271 vkGetPhysicalDeviceProperties(device, &deviceProperties); -
vulkan-game.hpp
r90a424f rfe5c3ba 26 26 VkInstance instance; 27 27 VkDebugUtilsMessengerEXT debugMessenger; 28 VkSurfaceKHR surface; 28 VkSurfaceKHR surface; // TODO: Change the variable name to vulkanSurface 29 29 VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; 30 30 … … 38 38 void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo); 39 39 void createVulkanSurface(); 40 void pickPhysicalDevice( );41 bool isDeviceSuitable(VkPhysicalDevice device );40 void pickPhysicalDevice(const vector<const char*>& deviceExtensions); 41 bool isDeviceSuitable(VkPhysicalDevice device, const vector<const char*>& deviceExtensions); 42 42 43 43 static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback( -
vulkan-utils.cpp
r90a424f rfe5c3ba 1 1 #include "vulkan-utils.hpp" 2 2 3 #include <algorithm> 3 4 #include <set> 5 #include <stdexcept> 4 6 #include <string> 5 7 … … 52 54 } 53 55 54 QueueFamilyIndices VulkanUtils::findQueueFamilies(VkPhysicalDevice device, VkSurfaceKHR surface) {56 QueueFamilyIndices VulkanUtils::findQueueFamilies(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface) { 55 57 QueueFamilyIndices indices; 56 58 57 59 uint32_t queueFamilyCount = 0; 58 vkGetPhysicalDeviceQueueFamilyProperties( device, &queueFamilyCount, nullptr);60 vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, nullptr); 59 61 60 62 vector<VkQueueFamilyProperties> queueFamilies(queueFamilyCount); 61 vkGetPhysicalDeviceQueueFamilyProperties( device, &queueFamilyCount, queueFamilies.data());63 vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, queueFamilies.data()); 62 64 63 65 int i = 0; … … 68 70 69 71 VkBool32 presentSupport = false; 70 vkGetPhysicalDeviceSurfaceSupportKHR( device, i, surface, &presentSupport);72 vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, i, surface, &presentSupport); 71 73 72 74 if (queueFamily.queueCount > 0 && presentSupport) { … … 84 86 } 85 87 86 bool VulkanUtils::checkDeviceExtensionSupport(VkPhysicalDevice device, const vector<const char*>& deviceExtensions) {88 bool VulkanUtils::checkDeviceExtensionSupport(VkPhysicalDevice physicalDevice, const vector<const char*>& deviceExtensions) { 87 89 uint32_t extensionCount; 88 vkEnumerateDeviceExtensionProperties( device, nullptr, &extensionCount, nullptr);90 vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &extensionCount, nullptr); 89 91 90 92 vector<VkExtensionProperties> availableExtensions(extensionCount); 91 vkEnumerateDeviceExtensionProperties( device, nullptr, &extensionCount, availableExtensions.data());93 vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &extensionCount, availableExtensions.data()); 92 94 93 95 set<string> requiredExtensions(deviceExtensions.begin(), deviceExtensions.end()); … … 100 102 } 101 103 102 SwapChainSupportDetails VulkanUtils::querySwapChainSupport(VkPhysicalDevice device, VkSurfaceKHR surface) {104 SwapChainSupportDetails VulkanUtils::querySwapChainSupport(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface) { 103 105 SwapChainSupportDetails details; 104 106 105 vkGetPhysicalDeviceSurfaceCapabilitiesKHR( device, surface, &details.capabilities);107 vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, surface, &details.capabilities); 106 108 107 109 uint32_t formatCount; 108 vkGetPhysicalDeviceSurfaceFormatsKHR( device, surface, &formatCount, nullptr);110 vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, &formatCount, nullptr); 109 111 110 112 if (formatCount != 0) { 111 113 details.formats.resize(formatCount); 112 vkGetPhysicalDeviceSurfaceFormatsKHR( device, surface, &formatCount, details.formats.data());114 vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, &formatCount, details.formats.data()); 113 115 } 114 116 115 117 uint32_t presentModeCount; 116 vkGetPhysicalDeviceSurfacePresentModesKHR( device, surface, &presentModeCount, nullptr);118 vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, &presentModeCount, nullptr); 117 119 118 120 if (presentModeCount != 0) { 119 121 details.presentModes.resize(presentModeCount); 120 vkGetPhysicalDeviceSurfacePresentModesKHR( device, surface, &presentModeCount, details.presentModes.data());122 vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, &presentModeCount, details.presentModes.data()); 121 123 } 122 124 -
vulkan-utils.hpp
r90a424f rfe5c3ba 37 37 const VkAllocationCallbacks* pAllocator); 38 38 39 static QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device, VkSurfaceKHR surface);40 static bool checkDeviceExtensionSupport(VkPhysicalDevice device, const vector<const char*>& deviceExtensions);41 static SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device, VkSurfaceKHR surface);39 static QueueFamilyIndices findQueueFamilies(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface); 40 static bool checkDeviceExtensionSupport(VkPhysicalDevice physicalDevice, const vector<const char*>& deviceExtensions); 41 static SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface); 42 42 }; 43 43
Note:
See TracChangeset
for help on using the changeset viewer.