More compute work

This commit is contained in:
Darren VanBuren 2019-10-20 14:55:58 -07:00
parent 9afaf34349
commit 3977329697

View file

@ -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<VkQueueFamilyProperties> 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();
}
};