/* * Vulkan device class * * Encapsulates a physical Vulkan device and it's logical representation * * Copyright (C) 2016-2018 by Sascha Willems - www.saschawillems.de * * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) */ #pragma once #include "vke.h" //#include "VulkanBuffer.hpp" namespace vke { struct vkPhyInfo{ VkPhysicalDevice phy; VkPhysicalDeviceMemoryProperties memProps; VkPhysicalDeviceProperties properties; VkPhysicalDeviceFeatures features; VkPhysicalDeviceFeatures enabledFeatures; VkQueueFamilyProperties* queues; uint32_t queueCount; std::vector cQueues;//compute, dedicated first std::vector gQueues;//graphic, idem std::vector tQueues;//transfer, idem int pQueue;//presentation std::vector pQueueInfos; std::vector> qPriorities; vkPhyInfo (){} vkPhyInfo (VkPhysicalDevice _phy, VkSurfaceKHR surface = VK_NULL_HANDLE) { phy = _phy; // cQueues.clear(); // gQueues.clear(); // tQueues.clear(); pQueue = -1; // pQueueInfos.clear(); // qPriorities.clear(); vkGetPhysicalDeviceProperties (phy, &properties); vkGetPhysicalDeviceMemoryProperties (phy, &memProps); vkGetPhysicalDeviceFeatures (phy, &features); vkGetPhysicalDeviceQueueFamilyProperties (phy, &queueCount, NULL); queues = (VkQueueFamilyProperties*)malloc(queueCount * sizeof(VkQueueFamilyProperties)); vkGetPhysicalDeviceQueueFamilyProperties (phy, &queueCount, queues); //identify dedicated queues //try to find dedicated queues first VkBool32 present = VK_FALSE; for (uint j=0; jqueueFamilyProperties; VkCommandPool commandPool = VK_NULL_HANDLE; VkPipelineCache pipelineCache = VK_NULL_HANDLE; bool savePLCache = true; VkQueue queue; struct { uint32_t graphics; uint32_t compute; } queueFamilyIndices; VulkanDevice(vkPhyInfo phyInfos, const std::vector &devLayers); ~VulkanDevice(); uint32_t getMemoryType(uint32_t typeBits, VkMemoryPropertyFlags properties, VkBool32 *memTypeFound = nullptr); VkFormat getSuitableDepthFormat (); uint32_t getQueueFamilyIndex(VkQueueFlagBits queueFlags); VkCommandPool createCommandPool(uint32_t queueFamilyIndex, VkCommandPoolCreateFlags createFlags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); VkCommandBuffer createCommandBuffer(VkCommandBufferLevel level, bool begin = false, bool oneTime = false); void flushCommandBuffer(VkCommandBuffer commandBuffer, VkQueue queue, bool free = true); VkSemaphore createSemaphore (); VkFence createFence (bool signaled = false); void destroyFence (VkFence fence); void destroySemaphore (VkSemaphore semaphore); }; }