Started work on a GPU picker
This commit is contained in:
parent
1c32991ee6
commit
15dde5dc91
1 changed files with 31 additions and 4 deletions
35
src/main.c
35
src/main.c
|
|
@ -125,11 +125,10 @@ void createInstance(Application *app) {
|
||||||
VkExtensionProperties extensions[extensionCount];
|
VkExtensionProperties extensions[extensionCount];
|
||||||
vkEnumerateInstanceExtensionProperties(NULL, &extensionCount, extensions);
|
vkEnumerateInstanceExtensionProperties(NULL, &extensionCount, extensions);
|
||||||
|
|
||||||
// VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo = {0};
|
VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo = {0};
|
||||||
if (enableValidationLayers) {
|
if (enableValidationLayers) {
|
||||||
// populateDebugMessengerCreateInfo(&debugCreateInfo);
|
populateDebugMessengerCreateInfo(&debugCreateInfo);
|
||||||
// createInfo.pNext = (VkDebugUtilsMessengerCreateInfoEXT
|
createInfo.pNext = (VkDebugUtilsMessengerCreateInfoEXT *)&debugCreateInfo;
|
||||||
// *)&debugCreateInfo;
|
|
||||||
|
|
||||||
createInfo.enabledLayerCount = validationLayerCount;
|
createInfo.enabledLayerCount = validationLayerCount;
|
||||||
createInfo.ppEnabledLayerNames = validationLayers;
|
createInfo.ppEnabledLayerNames = validationLayers;
|
||||||
|
|
@ -217,9 +216,37 @@ void DestroyDebugUtilsMessengerEXT(VkInstance instance,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isDeviceSuitable(VkPhysicalDevice device) { return true; }
|
||||||
|
|
||||||
|
void pickPhysicalDevice(Application *app) {
|
||||||
|
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
||||||
|
|
||||||
|
uint32_t physicalDeviceCount;
|
||||||
|
vkEnumeratePhysicalDevices(app->instance, &physicalDeviceCount, NULL);
|
||||||
|
if (physicalDeviceCount == 0) {
|
||||||
|
fprintf(stderr, "Failed to find GPU with vulkan support!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
VkPhysicalDevice physicalDevices[physicalDeviceCount];
|
||||||
|
vkEnumeratePhysicalDevices(app->instance, &physicalDeviceCount,
|
||||||
|
physicalDevices);
|
||||||
|
|
||||||
|
for (int i = 0; i < physicalDeviceCount; i++) {
|
||||||
|
if (isDeviceSuitable(physicalDevices[i])) {
|
||||||
|
physicalDevice = physicalDevices[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (physicalDevice == VK_NULL_HANDLE){
|
||||||
|
fprintf(stderr, "Failed to find suitable GPU\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void initVulkan(Application *app) {
|
void initVulkan(Application *app) {
|
||||||
createInstance(app);
|
createInstance(app);
|
||||||
setupDebugMessenger(app);
|
setupDebugMessenger(app);
|
||||||
|
pickPhysicalDevice(app);
|
||||||
}
|
}
|
||||||
void mainLoop(Application *app) {
|
void mainLoop(Application *app) {
|
||||||
while (!glfwWindowShouldClose(app->window)) {
|
while (!glfwWindowShouldClose(app->window)) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue