fix commandPool error
parent
b9294307a6
commit
5c80c2b603
|
@ -100,24 +100,18 @@ namespace vks
|
||||||
*/
|
*/
|
||||||
uint32_t getMemoryType(uint32_t typeBits, VkMemoryPropertyFlags properties, VkBool32 *memTypeFound = nullptr)
|
uint32_t getMemoryType(uint32_t typeBits, VkMemoryPropertyFlags properties, VkBool32 *memTypeFound = nullptr)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < memoryProperties.memoryTypeCount; i++) {
|
VkPhysicalDeviceMemoryProperties deviceMemoryProperties;
|
||||||
|
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &deviceMemoryProperties);
|
||||||
|
for (uint32_t j = 0; j < deviceMemoryProperties.memoryTypeCount; j++) {
|
||||||
if ((typeBits & 1) == 1) {
|
if ((typeBits & 1) == 1) {
|
||||||
if ((memoryProperties.memoryTypes[i].propertyFlags & properties) == properties) {
|
if ((deviceMemoryProperties.memoryTypes[j].propertyFlags & properties) == properties) {
|
||||||
if (memTypeFound) {
|
return j;
|
||||||
*memTypeFound = true;
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
typeBits >>= 1;
|
typeBits >>= 1;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
if (memTypeFound) {
|
|
||||||
*memTypeFound = false;
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
throw std::runtime_error("Could not find a matching memory type");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,9 +30,15 @@ void PlumageRender::initVulkan()
|
||||||
{
|
{
|
||||||
createInstance();
|
createInstance();
|
||||||
|
|
||||||
|
setupDebugMessager();
|
||||||
|
|
||||||
//createSurface();
|
//createSurface();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pickupPhysicalDevice();
|
pickupPhysicalDevice();
|
||||||
|
|
||||||
|
createLogicalDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult PlumageRender::createInstance()
|
VkResult PlumageRender::createInstance()
|
||||||
|
@ -63,14 +69,13 @@ VkResult PlumageRender::createInstance()
|
||||||
instanceCreateInfo.pNext = NULL;
|
instanceCreateInfo.pNext = NULL;
|
||||||
instanceCreateInfo.pApplicationInfo = &appInfo;
|
instanceCreateInfo.pApplicationInfo = &appInfo;
|
||||||
|
|
||||||
if (instanceExtensions.size() > 0)
|
if (settings.validation) {
|
||||||
{
|
instanceExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
|
||||||
if (settings.validation) {
|
instanceExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||||
instanceExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
|
|
||||||
}
|
|
||||||
instanceCreateInfo.enabledExtensionCount = (uint32_t)instanceExtensions.size();
|
|
||||||
instanceCreateInfo.ppEnabledExtensionNames = instanceExtensions.data();
|
|
||||||
}
|
}
|
||||||
|
instanceCreateInfo.enabledExtensionCount = (uint32_t)instanceExtensions.size();
|
||||||
|
instanceCreateInfo.ppEnabledExtensionNames = instanceExtensions.data();
|
||||||
|
|
||||||
std::vector<const char*> validationLayerNames;
|
std::vector<const char*> validationLayerNames;
|
||||||
if (settings.validation) {
|
if (settings.validation) {
|
||||||
validationLayerNames.push_back("VK_LAYER_KHRONOS_validation");
|
validationLayerNames.push_back("VK_LAYER_KHRONOS_validation");
|
||||||
|
@ -141,55 +146,28 @@ void PlumageRender::setupDebugMessager()
|
||||||
debugCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
|
debugCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
|
||||||
debugCreateInfo.pfnCallback = (PFN_vkDebugReportCallbackEXT)debugMessageCallback;
|
debugCreateInfo.pfnCallback = (PFN_vkDebugReportCallbackEXT)debugMessageCallback;
|
||||||
debugCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT;
|
debugCreateInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT;
|
||||||
|
debugCreateInfo.pUserData = NULL;
|
||||||
VK_CHECK_RESULT(vkCreateDebugReportCallback(instance, &debugCreateInfo, nullptr, &debugReportCallback));
|
VK_CHECK_RESULT(vkCreateDebugReportCallback(instance, &debugCreateInfo, nullptr, &debugReportCallback));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlumageRender::populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& debugCreateInfo)
|
|
||||||
|
VKAPI_ATTR VkBool32 VKAPI_CALL PlumageRender::debugMessageCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t srcObject, size_t location, int32_t msgCode, const char* pLayerPrefix, const char* pMsg, void* pUserData)
|
||||||
{
|
{
|
||||||
debugCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
|
std::string prefix("");
|
||||||
|
if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
|
||||||
debugCreateInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |
|
prefix += "ERROR:";
|
||||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
|
};
|
||||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT) {
|
||||||
debugCreateInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT |
|
prefix += "WARNING:";
|
||||||
VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
|
};
|
||||||
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
if (flags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) {
|
||||||
debugCreateInfo.pfnUserCallback = &debugCallback;
|
prefix += "DEBUG:";
|
||||||
debugCreateInfo.pUserData = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
VKAPI_ATTR VkBool32 VKAPI_CALL PlumageRender::debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
std::cerr << "validation layer: " << pCallbackData->pMessage << std::endl;
|
|
||||||
|
|
||||||
return VK_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VkResult PlumageRender::CreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger)
|
|
||||||
{
|
|
||||||
auto func = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT");
|
|
||||||
|
|
||||||
if (func != nullptr)
|
|
||||||
{
|
|
||||||
return func(instance, pCreateInfo, pAllocator, pDebugMessenger);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlumageRender::DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator)
|
|
||||||
{
|
|
||||||
auto func = (PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT");
|
|
||||||
|
|
||||||
if (func != nullptr)
|
|
||||||
{
|
|
||||||
func(instance, debugMessenger, pAllocator);
|
|
||||||
}
|
}
|
||||||
|
std::stringstream debugMessage;
|
||||||
|
debugMessage << prefix << " [" << pLayerPrefix << "] Code " << msgCode << " : " << pMsg;
|
||||||
|
fflush(stdout);
|
||||||
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlumageRender::createSurface()
|
void PlumageRender::createSurface()
|
||||||
|
@ -243,17 +221,6 @@ bool PlumageRender::isDeviceSuitable(VkPhysicalDevice device)
|
||||||
bool extensionsSupported = checkDeviceExtensionSupport(device);
|
bool extensionsSupported = checkDeviceExtensionSupport(device);
|
||||||
return extensionsSupported;
|
return extensionsSupported;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{ // 非无头下在检查扩展支持的同时要检查swapchain
|
|
||||||
bool extensionsSupported = checkDeviceExtensionSupport(device);
|
|
||||||
bool swapChainAdequate = false;
|
|
||||||
QueueFamilyIndices indices = findQueueFamilies(device);
|
|
||||||
if (extensionsSupported)
|
|
||||||
{
|
|
||||||
SwapChainSupportDetails swapChainSupport = querySwapChainSupport(device);
|
|
||||||
swapChainAdequate = !swapChainSupport.formats.empty() && !swapChainSupport.presentModes.empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlumageRender::checkDeviceExtensionSupport(VkPhysicalDevice device)
|
bool PlumageRender::checkDeviceExtensionSupport(VkPhysicalDevice device)
|
||||||
|
@ -274,54 +241,7 @@ bool PlumageRender::checkDeviceExtensionSupport(VkPhysicalDevice device)
|
||||||
return requiredExtensions.empty();
|
return requiredExtensions.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlumageRender::QueueFamilyIndices PlumageRender::findQueueFamilies(VkPhysicalDevice device)
|
|
||||||
{
|
|
||||||
QueueFamilyIndices indices;
|
|
||||||
|
|
||||||
uint32_t queueFamilyCount = 0;
|
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, nullptr);
|
|
||||||
|
|
||||||
std::vector<VkQueueFamilyProperties> queueFamilies(queueFamilyCount);
|
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(device, &queueFamilyCount, queueFamilies.data());
|
|
||||||
|
|
||||||
VkBool32 presentSupport = false;
|
|
||||||
|
|
||||||
// 检查显示队列支持
|
|
||||||
int i = 0;
|
|
||||||
if (!settings.headless)
|
|
||||||
{
|
|
||||||
vkGetPhysicalDeviceSurfaceSupportKHR(device, i, surface, &presentSupport);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& queueFamily : queueFamilies)
|
|
||||||
{
|
|
||||||
if (queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT) {
|
|
||||||
indices.graphicsFamily = i;
|
|
||||||
}
|
|
||||||
// 无头下不需要检查present queue
|
|
||||||
if (settings.headless)
|
|
||||||
{
|
|
||||||
if (indices.isGraphicsFamilyComplete())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (indices.isGraphicsFamilyComplete() && indices.isPresentFamilyComplete())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (presentSupport)
|
|
||||||
{
|
|
||||||
indices.presentFamily = i;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return indices;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlumageRender::SwapChainSupportDetails PlumageRender::querySwapChainSupport(VkPhysicalDevice device)
|
PlumageRender::SwapChainSupportDetails PlumageRender::querySwapChainSupport(VkPhysicalDevice device)
|
||||||
{
|
{
|
||||||
|
@ -353,35 +273,20 @@ PlumageRender::SwapChainSupportDetails PlumageRender::querySwapChainSupport(VkPh
|
||||||
|
|
||||||
void PlumageRender::createLogicalDevice()
|
void PlumageRender::createLogicalDevice()
|
||||||
{
|
{
|
||||||
QueueFamilyIndices indices = findQueueFamilies(physicalDevice);
|
|
||||||
std::vector<VkDeviceQueueCreateInfo> queueCreateInfos;
|
std::vector<VkDeviceQueueCreateInfo> queueCreateInfos;
|
||||||
|
|
||||||
if (settings.headless)
|
if (settings.headless)
|
||||||
{
|
{
|
||||||
VkDeviceQueueCreateInfo queueCreateInfo{};
|
VkDeviceQueueCreateInfo queueCreateInfo{};
|
||||||
queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
||||||
queueCreateInfo.queueFamilyIndex = indices.graphicsFamily.value();
|
queueCreateInfo.queueFamilyIndex = vulkanDevice->queueFamilyIndices.graphics;
|
||||||
queueCreateInfo.queueCount = 1;
|
queueCreateInfo.queueCount = 1;
|
||||||
float queuePriority = 1.0f;
|
float queuePriority = 1.0f;
|
||||||
queueCreateInfo.pQueuePriorities = &queuePriority;
|
queueCreateInfo.pQueuePriorities = &queuePriority;
|
||||||
queueCreateInfos.push_back(queueCreateInfo);
|
queueCreateInfos.push_back(queueCreateInfo);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
std::set<uint32_t> uniqueQueueFamilies = { indices.graphicsFamily.value(),indices.presentFamily.value() };
|
|
||||||
|
|
||||||
float queuePriority = 1.0f;
|
|
||||||
for (uint32_t queueFamily : uniqueQueueFamilies)
|
|
||||||
{
|
|
||||||
VkDeviceQueueCreateInfo queueCreateInfo{};
|
|
||||||
queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
|
||||||
queueCreateInfo.queueFamilyIndex = queueFamily;
|
|
||||||
queueCreateInfo.queueCount = 1;
|
|
||||||
queueCreateInfo.pQueuePriorities = &queuePriority;
|
|
||||||
queueCreateInfos.push_back(queueCreateInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VkPhysicalDeviceFeatures enableFeatures{};
|
VkPhysicalDeviceFeatures enableFeatures{};
|
||||||
if (deviceFeatures.samplerAnisotropy) {
|
if (deviceFeatures.samplerAnisotropy) {
|
||||||
|
@ -421,173 +326,19 @@ void PlumageRender::createLogicalDevice()
|
||||||
throw std::runtime_error("failed to create logical device");
|
throw std::runtime_error("failed to create logical device");
|
||||||
}
|
}
|
||||||
|
|
||||||
vkGetDeviceQueue(device, indices.graphicsFamily.value(), 0, &graphicQueue);
|
vkGetDeviceQueue(device, vulkanDevice->queueFamilyIndices.graphics, 0, &graphicQueue);
|
||||||
if (!settings.headless)
|
|
||||||
{
|
|
||||||
vkGetDeviceQueue(device, indices.presentFamily.value(), 0, &presentQueue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlumageRender::createSwapChain()
|
|
||||||
{
|
|
||||||
if (settings.headless)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SwapChainSupportDetails swapChainSupport = querySwapChainSupport(physicalDevice);
|
|
||||||
|
|
||||||
VkSurfaceFormatKHR surfaceFormat = chooseSwapSurfaceFormat(swapChainSupport.formats);
|
|
||||||
VkPresentModeKHR presentMode = chooseSwapPresentMode(swapChainSupport.presentModes);
|
|
||||||
VkExtent2D extent = chooseSwapExtent(swapChainSupport.capabilities);
|
|
||||||
|
|
||||||
uint32_t imageCount = swapChainSupport.capabilities.minImageCount + 1;
|
|
||||||
|
|
||||||
if (swapChainSupport.capabilities.maxImageCount > 0 && imageCount > swapChainSupport.capabilities.maxImageCount)
|
|
||||||
{
|
|
||||||
imageCount = swapChainSupport.capabilities.maxImageCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
VkSwapchainCreateInfoKHR createInfo{};
|
|
||||||
createInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
|
|
||||||
createInfo.surface = surface;
|
|
||||||
|
|
||||||
createInfo.minImageCount = imageCount;
|
|
||||||
createInfo.imageFormat = surfaceFormat.format;
|
|
||||||
createInfo.imageColorSpace = surfaceFormat.colorSpace;
|
|
||||||
createInfo.imageExtent = extent;
|
|
||||||
createInfo.imageArrayLayers = 1;
|
|
||||||
createInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
|
||||||
|
|
||||||
QueueFamilyIndices indices = findQueueFamilies(physicalDevice);
|
|
||||||
uint32_t queueFamilyIndices[] = { indices.graphicsFamily.value(),indices.presentFamily.value() };
|
|
||||||
if (indices.graphicsFamily != indices.presentFamily)
|
|
||||||
{
|
|
||||||
createInfo.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
|
|
||||||
createInfo.queueFamilyIndexCount = 2;
|
|
||||||
createInfo.pQueueFamilyIndices = queueFamilyIndices;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
|
||||||
createInfo.queueFamilyIndexCount = 0;
|
|
||||||
createInfo.pQueueFamilyIndices = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
createInfo.preTransform = swapChainSupport.capabilities.currentTransform;
|
|
||||||
createInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
|
||||||
createInfo.presentMode = presentMode;
|
|
||||||
createInfo.clipped = VK_TRUE;
|
|
||||||
createInfo.oldSwapchain = VK_NULL_HANDLE;
|
|
||||||
|
|
||||||
|
|
||||||
if (vkCreateSwapchainKHR(device, &createInfo, nullptr, &swapChainKHR) != VK_SUCCESS)
|
|
||||||
{
|
|
||||||
throw std::runtime_error("failed to create swap chain !");
|
|
||||||
}
|
|
||||||
|
|
||||||
vkGetSwapchainImagesKHR(device, swapChainKHR, &imageCount, nullptr);
|
|
||||||
swapChainImages.resize(imageCount);
|
|
||||||
vkGetSwapchainImagesKHR(device, swapChainKHR, &imageCount, swapChainImages.data());
|
|
||||||
// store swap format and swap extent to member variable
|
|
||||||
swapChainImageFormat = surfaceFormat.format;
|
|
||||||
swapChainExtent = extent;
|
|
||||||
}
|
|
||||||
|
|
||||||
VkSurfaceFormatKHR PlumageRender::chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats)
|
|
||||||
{
|
|
||||||
for (const auto& availableFormat : availableFormats) {
|
|
||||||
if (availableFormat.format == VK_FORMAT_B8G8R8_SRGB && availableFormat.colorSpace == VK_COLORSPACE_SRGB_NONLINEAR_KHR)
|
|
||||||
{
|
|
||||||
return availableFormat;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return availableFormats[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
VkPresentModeKHR PlumageRender::chooseSwapPresentMode(const std::vector<VkPresentModeKHR>& availablePresentModes)
|
|
||||||
{
|
|
||||||
// Get available present modes
|
|
||||||
uint32_t presentModeCount;
|
|
||||||
VK_CHECK_RESULT(fpGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, &presentModeCount, NULL));
|
|
||||||
assert(presentModeCount > 0);
|
|
||||||
|
|
||||||
std::vector<VkPresentModeKHR> presentModes(presentModeCount);
|
|
||||||
VK_CHECK_RESULT(fpGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, &presentModeCount, presentModes.data()));
|
|
||||||
// The VK_PRESENT_MODE_FIFO_KHR mode must always be present as per spec
|
|
||||||
// This mode waits for the vertical blank ("v-sync")
|
|
||||||
// 垂直同步模式
|
|
||||||
VkPresentModeKHR swapchainPresentMode = VK_PRESENT_MODE_FIFO_KHR;
|
|
||||||
|
|
||||||
// If v-sync is not requested, try to find a mailbox mode
|
|
||||||
// It's the lowest latency non-tearing present mode available
|
|
||||||
if (!settings.vsync)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < presentModeCount; i++)
|
|
||||||
{
|
|
||||||
if (presentModes[i] == VK_PRESENT_MODE_MAILBOX_KHR)
|
|
||||||
{
|
|
||||||
swapchainPresentMode = VK_PRESENT_MODE_MAILBOX_KHR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((swapchainPresentMode != VK_PRESENT_MODE_MAILBOX_KHR) && (presentModes[i] == VK_PRESENT_MODE_IMMEDIATE_KHR))
|
|
||||||
{
|
|
||||||
swapchainPresentMode = VK_PRESENT_MODE_IMMEDIATE_KHR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VkExtent2D PlumageRender::chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities)
|
|
||||||
{
|
|
||||||
if (capabilities.currentExtent.width != std::numeric_limits<uint32_t>::max())
|
|
||||||
{
|
|
||||||
return capabilities.currentExtent;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int width, height;
|
|
||||||
//glfwGetFramebufferSize(window, &width, &height);
|
|
||||||
|
|
||||||
VkExtent2D actualExtent = {
|
|
||||||
static_cast<uint32_t>(width),
|
|
||||||
static_cast<uint32_t>(height)
|
|
||||||
};
|
|
||||||
|
|
||||||
actualExtent.width = std::clamp(actualExtent.width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width);
|
|
||||||
actualExtent.height = std::clamp(actualExtent.height, capabilities.minImageExtent.height, capabilities.maxImageExtent.height);
|
|
||||||
|
|
||||||
return actualExtent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlumageRender::cleanupSwapChain()
|
|
||||||
{
|
|
||||||
for (auto framebuffer : framebuffers)
|
|
||||||
{
|
|
||||||
vkDestroyFramebuffer(device, framebuffer, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto imageView : swapChainImageViews)
|
|
||||||
{
|
|
||||||
vkDestroyImageView(device, imageView, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
vkDestroySwapchainKHR(device, swapChainKHR, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlumageRender::createCommandPool()
|
void PlumageRender::createCommandPool()
|
||||||
{
|
{
|
||||||
QueueFamilyIndices queueFamilyIndices = findQueueFamilies(physicalDevice);
|
|
||||||
|
|
||||||
VkCommandPoolCreateInfo poolInfo{};
|
VkCommandPoolCreateInfo poolInfo{};
|
||||||
poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||||
poolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
poolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
||||||
poolInfo.queueFamilyIndex = queueFamilyIndices.graphicsFamily.value();
|
poolInfo.queueFamilyIndex = vulkanDevice->queueFamilyIndices.graphics;
|
||||||
|
|
||||||
|
|
||||||
if (vkCreateCommandPool(device, &poolInfo, nullptr, &commandPool) != VK_SUCCESS)
|
if (vkCreateCommandPool(device, &poolInfo, nullptr, &commandPool) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("failed to create command pool in createCommandpool");
|
throw std::runtime_error("failed to create command pool in createCommandpool");
|
||||||
|
@ -818,25 +569,29 @@ void PlumageRender::createFramebuffer()
|
||||||
{
|
{
|
||||||
if (settings.headless)
|
if (settings.headless)
|
||||||
{
|
{
|
||||||
auto frameRange = settings.endFrameIndex - settings.startFrameCount;
|
auto frameRange = settings.endFrameIndex - settings.startFrameCount + 1;
|
||||||
|
framebuffers.resize(frameRange);
|
||||||
if (settings.multiSampling)
|
if (settings.multiSampling)
|
||||||
{
|
{
|
||||||
|
VkImageView attachments[4];
|
||||||
|
attachments[0] = multisampleTarget.colorAttachment.view;
|
||||||
|
attachments[1] = multisampleTarget.depthAttachment.view;
|
||||||
|
attachments[2] = depthAttachment.view;
|
||||||
|
attachments[3] = colorAttachment.view;
|
||||||
|
|
||||||
|
VkFramebufferCreateInfo framebufferCreateInfo = vks::initializers::framebufferCreateInfo();
|
||||||
|
framebufferCreateInfo.renderPass = renderPass;
|
||||||
|
framebufferCreateInfo.attachmentCount = 4;
|
||||||
|
framebufferCreateInfo.pAttachments = attachments;
|
||||||
|
framebufferCreateInfo.width = settings.width;
|
||||||
|
framebufferCreateInfo.height = settings.height;
|
||||||
|
framebufferCreateInfo.layers = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < frameRange; i++)
|
for (int i = 0; i < frameRange; i++)
|
||||||
{
|
{
|
||||||
VkImageView attachments[4];
|
|
||||||
attachments[0] = multisampleTarget.colorAttachment.view;
|
|
||||||
attachments[1] = multisampleTarget.depthAttachment.view;
|
|
||||||
attachments[2] = depthAttachment.view;
|
|
||||||
attachments[3] = colorAttachment.view;
|
|
||||||
|
|
||||||
VkFramebufferCreateInfo framebufferCreateInfo = vks::initializers::framebufferCreateInfo();
|
|
||||||
framebufferCreateInfo.renderPass = renderPass;
|
|
||||||
framebufferCreateInfo.attachmentCount = 4;
|
|
||||||
framebufferCreateInfo.pAttachments = attachments;
|
|
||||||
framebufferCreateInfo.width = settings.width;
|
|
||||||
framebufferCreateInfo.height = settings.height;
|
|
||||||
framebufferCreateInfo.layers = 1;
|
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkCreateFramebuffer(device, &framebufferCreateInfo, nullptr, &framebuffers[i]));
|
VK_CHECK_RESULT(vkCreateFramebuffer(device, &framebufferCreateInfo, nullptr, &framebuffers[i]));
|
||||||
}
|
}
|
||||||
|
@ -862,12 +617,7 @@ void PlumageRender::createFramebuffer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createImageView();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
createSwapChainFramebuffer();
|
|
||||||
createImageView();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -913,6 +663,8 @@ void PlumageRender::createSwapChainFramebuffer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PlumageRender::createImageView()
|
void PlumageRender::createImageView()
|
||||||
{
|
{
|
||||||
VkFormat colorAttachmentFormat = VK_FORMAT_R8G8B8A8_UNORM;
|
VkFormat colorAttachmentFormat = VK_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
@ -1018,7 +770,7 @@ void PlumageRender::createImageView()
|
||||||
imageCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
imageCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
imageCI.tiling = VK_IMAGE_TILING_OPTIMAL;
|
imageCI.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||||
imageCI.samples = VK_SAMPLE_COUNT_1_BIT;
|
imageCI.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
imageCI.usage = VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
imageCI.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||||
imageCI.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
imageCI.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkCreateImage(device, &imageCI, nullptr, &colorAttachment.image));
|
VK_CHECK_RESULT(vkCreateImage(device, &imageCI, nullptr, &colorAttachment.image));
|
||||||
|
@ -1029,14 +781,10 @@ void PlumageRender::createImageView()
|
||||||
VkMemoryAllocateInfo memAllocInfo{};
|
VkMemoryAllocateInfo memAllocInfo{};
|
||||||
memAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
memAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||||
memAllocInfo.allocationSize = memReqs.size;
|
memAllocInfo.allocationSize = memReqs.size;
|
||||||
VkBool32 lazyMemTypePresent;
|
memAllocInfo.memoryTypeIndex = getMemoryTypeIndex(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||||
memAllocInfo.memoryTypeIndex = vulkanDevice->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT, &lazyMemTypePresent);
|
|
||||||
if (!lazyMemTypePresent) {
|
|
||||||
memAllocInfo.memoryTypeIndex = vulkanDevice->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
|
||||||
}
|
|
||||||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &colorAttachment.memory));
|
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &colorAttachment.memory));
|
||||||
|
|
||||||
vkBindImageMemory(device, multisampleTarget.colorAttachment.image, colorAttachment.memory, 0);
|
vkBindImageMemory(device, colorAttachment.image, colorAttachment.memory, 0);
|
||||||
|
|
||||||
// Create image view for the color image
|
// Create image view for the color image
|
||||||
VkImageViewCreateInfo imageViewCI{};
|
VkImageViewCreateInfo imageViewCI{};
|
||||||
|
@ -1079,7 +827,7 @@ void PlumageRender::createImageView()
|
||||||
VkMemoryRequirements depthAttachmentMemReqs;
|
VkMemoryRequirements depthAttachmentMemReqs;
|
||||||
vkGetImageMemoryRequirements(device, depthAttachment.image, &memReqs);
|
vkGetImageMemoryRequirements(device, depthAttachment.image, &memReqs);
|
||||||
memAlloc.allocationSize = depthAttachmentMemReqs.size;
|
memAlloc.allocationSize = depthAttachmentMemReqs.size;
|
||||||
memAlloc.memoryTypeIndex = vulkanDevice->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
memAlloc.memoryTypeIndex = getMemoryTypeIndex(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAlloc, nullptr, &depthAttachment.memory));
|
VK_CHECK_RESULT(vkAllocateMemory(device, &memAlloc, nullptr, &depthAttachment.memory));
|
||||||
VK_CHECK_RESULT(vkBindImageMemory(device, depthAttachment.image, depthAttachment.memory, 0));
|
VK_CHECK_RESULT(vkBindImageMemory(device, depthAttachment.image, depthAttachment.memory, 0));
|
||||||
|
|
||||||
|
@ -2793,19 +2541,25 @@ void PlumageRender::prepare()
|
||||||
|
|
||||||
createRenderPass();
|
createRenderPass();
|
||||||
|
|
||||||
|
createPipelineCache();
|
||||||
|
|
||||||
|
createImageView();
|
||||||
|
|
||||||
|
createFramebuffer();
|
||||||
|
|
||||||
camera.type = Camera::CameraType::lookat;
|
camera.type = Camera::CameraType::lookat;
|
||||||
|
|
||||||
camera.setPerspective(45.0f, (float)settings.width / (float)settings.height, 0.1f, 256.0f);
|
camera.setPerspective(45.0f, (float)settings.width / (float)settings.height, 0.1f, 256.0f);
|
||||||
camera.rotationSpeed = 0.25f;
|
camera.rotationSpeed = 0.25f;
|
||||||
camera.movementSpeed = 0.1f;
|
camera.movementSpeed = 0.1f;
|
||||||
|
|
||||||
|
auto frameRanges = settings.endFrameIndex - settings.startFrameCount + 1;
|
||||||
waitFences.resize(renderAhead);
|
waitFences.resize(renderAhead);
|
||||||
presentCompleteSemaphores.resize(renderAhead);
|
presentCompleteSemaphores.resize(renderAhead);
|
||||||
renderCompleteSemaphores.resize(renderAhead);
|
renderCompleteSemaphores.resize(renderAhead);
|
||||||
commandBuffers.resize(renderAhead);
|
commandBuffers.resize(frameRanges);
|
||||||
uniformBuffers.resize(renderAhead);
|
uniformBuffers.resize(frameRanges);
|
||||||
descriptorSets.resize(renderAhead);
|
descriptorSets.resize(frameRanges);
|
||||||
// Command buffer execution fences
|
// Command buffer execution fences
|
||||||
for (auto& waitFence : waitFences) {
|
for (auto& waitFence : waitFences) {
|
||||||
VkFenceCreateInfo fenceCI{ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, VK_FENCE_CREATE_SIGNALED_BIT };
|
VkFenceCreateInfo fenceCI{ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, VK_FENCE_CREATE_SIGNALED_BIT };
|
||||||
|
@ -2829,6 +2583,7 @@ void PlumageRender::prepare()
|
||||||
cmdBufAllocateInfo.commandBufferCount = static_cast<uint32_t>(commandBuffers.size());
|
cmdBufAllocateInfo.commandBufferCount = static_cast<uint32_t>(commandBuffers.size());
|
||||||
VK_CHECK_RESULT(vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, commandBuffers.data()));
|
VK_CHECK_RESULT(vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, commandBuffers.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
loadAssets();
|
loadAssets();
|
||||||
generateBRDFLUT();
|
generateBRDFLUT();
|
||||||
|
@ -2845,18 +2600,7 @@ void PlumageRender::prepare()
|
||||||
prepared = true;
|
prepared = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlumageRender::submitWork(VkCommandBuffer cmdBuffer, VkQueue queue)
|
|
||||||
{
|
|
||||||
VkSubmitInfo submitInfo = vks::initializers::submitInfo();
|
|
||||||
submitInfo.commandBufferCount = 1;
|
|
||||||
submitInfo.pCommandBuffers = &cmdBuffer;
|
|
||||||
VkFenceCreateInfo fenceInfo = vks::initializers::fenceCreateInfo();
|
|
||||||
VkFence fence;
|
|
||||||
VK_CHECK_RESULT(vkCreateFence(device, &fenceInfo, nullptr, &fence));
|
|
||||||
VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, fence));
|
|
||||||
VK_CHECK_RESULT(vkWaitForFences(device, 1, &fence, VK_TRUE, UINT64_MAX));
|
|
||||||
vkDestroyFence(device, fence, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo :根据physicalDeviceIndex确定子文件夹路径,frameIndex确定fileName
|
// todo :根据physicalDeviceIndex确定子文件夹路径,frameIndex确定fileName
|
||||||
void PlumageRender::writeImageToFile(std::string filePath)
|
void PlumageRender::writeImageToFile(std::string filePath)
|
||||||
|
@ -2883,11 +2627,10 @@ void PlumageRender::writeImageToFile(std::string filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Source for the copy is the last rendered swapchain image
|
// Source for the copy is the last rendered swapchain image
|
||||||
if (settings.headless)
|
|
||||||
{
|
VkImage srcImage = colorAttachment.image;
|
||||||
VkImage srcImage = colorAttachment.image;
|
|
||||||
}
|
//VkImage srcImage = swapChainImages[currentBuffer];
|
||||||
VkImage srcImage = swapChainImages[currentBuffer];
|
|
||||||
|
|
||||||
// Create the linear tiled destination image to copy to and to read the memory from
|
// Create the linear tiled destination image to copy to and to read the memory from
|
||||||
VkImageCreateInfo imageCreateCI(vks::initializers::imageCreateInfo());
|
VkImageCreateInfo imageCreateCI(vks::initializers::imageCreateInfo());
|
||||||
|
@ -3240,10 +2983,11 @@ void PlumageRender::render()
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkWaitForFences(device, 1, &waitFences[frameIndex], VK_TRUE, UINT64_MAX));
|
VK_CHECK_RESULT(vkWaitForFences(device, 1, &waitFences[frameIndex], VK_TRUE, UINT64_MAX));
|
||||||
|
|
||||||
framebufferResized = swapChainAcquireNextImage(framebufferResized, imageIndex, frameIndex);
|
//framebufferResized = swapChainAcquireNextImage(framebufferResized, imageIndex, frameIndex);
|
||||||
|
outputImageSequence();
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkResetFences(device, 1, &waitFences[frameIndex]));
|
VK_CHECK_RESULT(vkResetFences(device, 1, &waitFences[frameIndex]));
|
||||||
outputImageSequence();
|
|
||||||
imageSequenceToVideo();
|
imageSequenceToVideo();
|
||||||
|
|
||||||
// Update UBOs
|
// Update UBOs
|
||||||
|
@ -3255,7 +2999,7 @@ void PlumageRender::render()
|
||||||
|
|
||||||
submitToGraphicQueue(frameIndex,currentBuffer);
|
submitToGraphicQueue(frameIndex,currentBuffer);
|
||||||
|
|
||||||
imageToQueuePresent(frameIndex, imageIndex, framebufferResized);
|
//imageToQueuePresent(frameIndex, imageIndex, framebufferResized);
|
||||||
|
|
||||||
|
|
||||||
frameIndex += 1;
|
frameIndex += 1;
|
||||||
|
@ -3334,7 +3078,7 @@ void PlumageRender::destroyVulkan()
|
||||||
textures.empty.destroy();
|
textures.empty.destroy();
|
||||||
delete gui;
|
delete gui;
|
||||||
// Clean up Vulkan resources
|
// Clean up Vulkan resources
|
||||||
cleanupSwapChain();
|
|
||||||
vkDestroyDescriptorPool(device, descriptorPool, nullptr);
|
vkDestroyDescriptorPool(device, descriptorPool, nullptr);
|
||||||
vkDestroyRenderPass(device, renderPass, nullptr);
|
vkDestroyRenderPass(device, renderPass, nullptr);
|
||||||
for (uint32_t i = 0; i < framebuffers.size(); i++) {
|
for (uint32_t i = 0; i < framebuffers.size(); i++) {
|
||||||
|
@ -3358,7 +3102,7 @@ void PlumageRender::destroyVulkan()
|
||||||
}
|
}
|
||||||
delete vulkanDevice;
|
delete vulkanDevice;
|
||||||
if (settings.validation) {
|
if (settings.validation) {
|
||||||
DestroyDebugUtilsMessengerEXT(instance, debugMessenger, nullptr);
|
vkDestroyDebugReportCallback(instance, debugReportCallback, nullptr);
|
||||||
}
|
}
|
||||||
vkDestroyInstance(instance, nullptr);
|
vkDestroyInstance(instance, nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,10 @@ public:
|
||||||
bool ToneMapping = true;
|
bool ToneMapping = true;
|
||||||
bool pbrEnabled = true;
|
bool pbrEnabled = true;
|
||||||
|
|
||||||
|
PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallback;
|
||||||
|
PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallback;
|
||||||
|
VkDebugReportCallbackEXT debugReportCallback;
|
||||||
|
|
||||||
std::vector<const char*> args;
|
std::vector<const char*> args;
|
||||||
|
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
|
@ -246,7 +250,7 @@ public:
|
||||||
bool validation = true; // 校验层开关
|
bool validation = true; // 校验层开关
|
||||||
bool fullscreen = false; // 全屏开关
|
bool fullscreen = false; // 全屏开关
|
||||||
bool vsync = false; // 垂直同步开关
|
bool vsync = false; // 垂直同步开关
|
||||||
bool multiSampling = true; // 多重采样
|
bool multiSampling = false; // 多重采样
|
||||||
bool rotateModel = true; // 模型自旋转(暂时失效)
|
bool rotateModel = true; // 模型自旋转(暂时失效)
|
||||||
bool headless = true; // 无头开关
|
bool headless = true; // 无头开关
|
||||||
bool outputPNGimage = false;
|
bool outputPNGimage = false;
|
||||||
|
@ -390,20 +394,7 @@ public:
|
||||||
|
|
||||||
VkCommandPool commandPool;
|
VkCommandPool commandPool;
|
||||||
|
|
||||||
struct QueueFamilyIndices
|
|
||||||
{
|
|
||||||
std::optional<uint32_t> graphicsFamily;
|
|
||||||
std::optional<uint32_t> presentFamily;
|
|
||||||
|
|
||||||
bool isGraphicsFamilyComplete()
|
|
||||||
{
|
|
||||||
return graphicsFamily.has_value();
|
|
||||||
}
|
|
||||||
bool isPresentFamilyComplete()
|
|
||||||
{
|
|
||||||
return presentFamily.has_value();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SwapChainSupportDetails
|
struct SwapChainSupportDetails
|
||||||
{
|
{
|
||||||
|
@ -469,25 +460,21 @@ public:
|
||||||
std::vector<const char*> getRequiredExtensions();
|
std::vector<const char*> getRequiredExtensions();
|
||||||
void setupDebugMessager();
|
void setupDebugMessager();
|
||||||
void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& debugCreateInfo);
|
void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& debugCreateInfo);
|
||||||
static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
|
static VKAPI_ATTR VkBool32 VKAPI_CALL debugMessageCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t srcObject, size_t location, int32_t msgCode, const char* pLayerPrefix, const char* pMsg, void* pUserData);
|
||||||
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
|
||||||
VkDebugUtilsMessageTypeFlagsEXT messageTypes,
|
|
||||||
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
|
||||||
void* pUserData);
|
|
||||||
VkResult CreateDebugUtilsMessengerEXT(
|
VkResult CreateDebugUtilsMessengerEXT(
|
||||||
VkInstance instance,
|
VkInstance instance,
|
||||||
const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
|
const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
|
||||||
const VkAllocationCallbacks* pAllocator,
|
const VkAllocationCallbacks* pAllocator,
|
||||||
VkDebugUtilsMessengerEXT* pDebugMessenger);
|
VkDebugUtilsMessengerEXT* pDebugMessenger);
|
||||||
|
|
||||||
void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator);
|
|
||||||
|
|
||||||
void createSurface();
|
void createSurface();
|
||||||
|
|
||||||
void pickupPhysicalDevice();
|
void pickupPhysicalDevice();
|
||||||
bool isDeviceSuitable(VkPhysicalDevice device);
|
bool isDeviceSuitable(VkPhysicalDevice device);
|
||||||
bool checkDeviceExtensionSupport(VkPhysicalDevice device);
|
bool checkDeviceExtensionSupport(VkPhysicalDevice device);
|
||||||
QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device);
|
|
||||||
SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device);
|
SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice device);
|
||||||
|
|
||||||
// 创建程序使用的逻辑设备
|
// 创建程序使用的逻辑设备
|
||||||
|
@ -500,7 +487,7 @@ public:
|
||||||
VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats);
|
VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats);
|
||||||
VkPresentModeKHR chooseSwapPresentMode(const std::vector<VkPresentModeKHR>& availablePresentModes);
|
VkPresentModeKHR chooseSwapPresentMode(const std::vector<VkPresentModeKHR>& availablePresentModes);
|
||||||
VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities);
|
VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities);
|
||||||
void cleanupSwapChain();
|
|
||||||
|
|
||||||
void createCommandPool();
|
void createCommandPool();
|
||||||
|
|
||||||
|
@ -511,6 +498,9 @@ public:
|
||||||
|
|
||||||
void createPipelineCache();
|
void createPipelineCache();
|
||||||
|
|
||||||
|
uint32_t getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties);
|
||||||
|
|
||||||
|
|
||||||
void createFramebuffer();
|
void createFramebuffer();
|
||||||
void createSwapChainFramebuffer();
|
void createSwapChainFramebuffer();
|
||||||
void createImageView();
|
void createImageView();
|
||||||
|
@ -543,8 +533,7 @@ public:
|
||||||
void updateUniformBuffers();
|
void updateUniformBuffers();
|
||||||
void updateShaderData();
|
void updateShaderData();
|
||||||
void initWindow(int Width,int Height);
|
void initWindow(int Width,int Height);
|
||||||
static void framebufferResizeCallback(GLFWwindow* window, int width, int height);
|
|
||||||
|
|
||||||
void windowResized();
|
void windowResized();
|
||||||
void submitWork(VkCommandBuffer cmdBuffer, VkQueue queue);
|
void submitWork(VkCommandBuffer cmdBuffer, VkQueue queue);
|
||||||
|
|
||||||
|
@ -553,7 +542,7 @@ public:
|
||||||
void imageSequenceToVideo();
|
void imageSequenceToVideo();
|
||||||
void removeImageSequence();
|
void removeImageSequence();
|
||||||
//void outputScreenShot();
|
//void outputScreenShot();
|
||||||
uint32_t getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties);
|
|
||||||
virtual void render();
|
virtual void render();
|
||||||
virtual void updateUIOverlay();
|
virtual void updateUIOverlay();
|
||||||
virtual void fileDropped(std::string filename);
|
virtual void fileDropped(std::string filename);
|
||||||
|
|
Loading…
Reference in New Issue