diff --git a/compute.cpp b/compute.cpp index ca44de0..9ad9dcd 100644 --- a/compute.cpp +++ b/compute.cpp @@ -64,6 +64,19 @@ class HelloVkCompute return true; } + // Determine if the chosen physical device is suitable for our application. + bool isDeviceSuitable(VkPhysicalDevice device) { + VkPhysicalDeviceProperties deviceProperties; + VkPhysicalDeviceFeatures deviceFeatures; + vkGetPhysicalDeviceProperties(device, &deviceProperties); + vkGetPhysicalDeviceFeatures(device, &deviceFeatures); + + std::cout << "Checking if device: " << deviceProperties.deviceName << " (id " << deviceProperties.deviceID << ") is suitable" << std::endl; + + return deviceFeatures.geometryShader; + + } + // Set up our debug report callback to get information back from the validation layers. void setupDebugCallback() { if (!enableValidationLayers) return; @@ -151,6 +164,21 @@ class HelloVkCompute throw std::runtime_error("Failed to find a suitable device!"); } } + + void createLogicalDevice() { + uint32_t queueFamilyPropertiesCount = 0; + vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyPropertiesCount, nullptr); + + std::vector queueFamilyProperties(queueFamilyPropertiesCount); + + vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyPropertiesCount, queueFamilyProperties.data()); + + for(auto queueFamProp : queueFamilyProperties) { + if(queueFamProp.queueFlags & (VK_QUEUE_COMPUTE_BIT)) { + std::cout << "Found queue with compute flag" << std::endl; + } + } + } public: // our debug callback function, just prints the message from the Validation layer to stderr static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback( VkDebugReportFlagsEXT flags, @@ -164,6 +192,7 @@ public: void run() { initVulkan(); pickDevice(); + createLogicalDevice(); } };