More compute work
This commit is contained in:
parent
9afaf34349
commit
3977329697
1 changed files with 29 additions and 0 deletions
29
compute.cpp
29
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<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();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue