vkDevice
This commit is contained in:
parent
64621b5cbf
commit
39cf0ffbd6
1 changed files with 25 additions and 0 deletions
|
@ -63,8 +63,11 @@ private:
|
|||
VkInstance instance;
|
||||
//Vulkan variables
|
||||
VkDebugUtilsMessengerEXT debugMessenger;
|
||||
|
||||
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
||||
|
||||
VkDevice device;
|
||||
VkQueue graphicsQueue;
|
||||
|
||||
void initWindow() {
|
||||
glfwInit();
|
||||
|
@ -91,6 +94,7 @@ private:
|
|||
if (enableValidationLayers) {
|
||||
DestroyDebugUtilsMessengerEXT(instance, debugMessenger, nullptr);
|
||||
}
|
||||
vkDestroyDevice(device,nullptr);
|
||||
vkDestroyInstance(instance, nullptr);
|
||||
glfwDestroyWindow(window);
|
||||
|
||||
|
@ -275,6 +279,27 @@ private:
|
|||
queueCreateInfo.queueCount = 1;
|
||||
float queuePriority = 1.0f;
|
||||
queueCreateInfo.pQueuePriorities = &queuePriority;
|
||||
|
||||
VkPhysicalDeviceFeatures deviceFeatures = {};
|
||||
|
||||
VkDeviceCreateInfo createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
||||
createInfo.pQueueCreateInfos = &queueCreateInfo;
|
||||
createInfo.queueCreateInfoCount = 1;
|
||||
|
||||
createInfo.pEnabledFeatures = &deviceFeatures;
|
||||
createInfo.enabledLayerCount = 0;
|
||||
if (enableValidationLayers) {
|
||||
createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
|
||||
createInfo.ppEnabledLayerNames = validationLayers.data();
|
||||
}
|
||||
else {
|
||||
createInfo.enabledLayerCount = 0;
|
||||
}
|
||||
if (vkCreateDevice(physicalDevice, &createInfo, nullptr, &device) != VK_SUCCESS) {
|
||||
throw std::runtime_error("Error creating logical device!");
|
||||
}
|
||||
vkGetDeviceQueue(device, indices.graphicsFamily.value(), 0, &graphicsQueue);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue