Changeset 90a424f in opengl-game for vulkan-utils.cpp
- Timestamp:
- Sep 16, 2019, 7:04:53 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- fe5c3ba
- Parents:
- c6fec84
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-utils.cpp
rc6fec84 r90a424f 1 1 #include "vulkan-utils.hpp" 2 3 #include <set> 4 #include <string> 2 5 3 6 bool VulkanUtils::checkValidationLayerSupport(const vector<const char*> &validationLayers) { … … 48 51 } 49 52 } 53 54 QueueFamilyIndices VulkanUtils::findQueueFamilies(VkPhysicalDevice device, VkSurfaceKHR surface) { 55 QueueFamilyIndices indices; 56 57 uint32_t queueFamilyCount = 0; 58 vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, nullptr); 59 60 vector<VkQueueFamilyProperties> queueFamilies(queueFamilyCount); 61 vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, queueFamilies.data()); 62 63 int i = 0; 64 for (const auto& queueFamily : queueFamilies) { 65 if (queueFamily.queueCount > 0 && queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT) { 66 indices.graphicsFamily = i; 67 } 68 69 VkBool32 presentSupport = false; 70 vkGetPhysicalDeviceSurfaceSupportKHR(device, i, surface, &presentSupport); 71 72 if (queueFamily.queueCount > 0 && presentSupport) { 73 indices.presentFamily = i; 74 } 75 76 if (indices.isComplete()) { 77 break; 78 } 79 80 i++; 81 } 82 83 return indices; 84 } 85 86 bool VulkanUtils::checkDeviceExtensionSupport(VkPhysicalDevice device, const vector<const char*>& deviceExtensions) { 87 uint32_t extensionCount; 88 vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionCount, nullptr); 89 90 vector<VkExtensionProperties> availableExtensions(extensionCount); 91 vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionCount, availableExtensions.data()); 92 93 set<string> requiredExtensions(deviceExtensions.begin(), deviceExtensions.end()); 94 95 for (const auto& extension : availableExtensions) { 96 requiredExtensions.erase(extension.extensionName); 97 } 98 99 return requiredExtensions.empty(); 100 } 101 102 SwapChainSupportDetails VulkanUtils::querySwapChainSupport(VkPhysicalDevice device, VkSurfaceKHR surface) { 103 SwapChainSupportDetails details; 104 105 vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device, surface, &details.capabilities); 106 107 uint32_t formatCount; 108 vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &formatCount, nullptr); 109 110 if (formatCount != 0) { 111 details.formats.resize(formatCount); 112 vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &formatCount, details.formats.data()); 113 } 114 115 uint32_t presentModeCount; 116 vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface, &presentModeCount, nullptr); 117 118 if (presentModeCount != 0) { 119 details.presentModes.resize(presentModeCount); 120 vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface, &presentModeCount, details.presentModes.data()); 121 } 122 123 return details; 124 }
Note:
See TracChangeset
for help on using the changeset viewer.