|
|
@ -146,10 +146,10 @@ VkApplicationInfo ComputeAndGraphics::createInstanceAppInfo() |
|
|
|
VkApplicationInfo appInfo{}; |
|
|
|
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
|
|
|
appInfo.pApplicationName = "Vulkan App"; |
|
|
|
appInfo.applicationVersion = VK_MAKE_VERSION(1, 3, 0); |
|
|
|
appInfo.applicationVersion = VK_MAKE_VERSION(1, 1, 0); |
|
|
|
appInfo.pEngineName = "No Engine"; |
|
|
|
appInfo.engineVersion = VK_MAKE_VERSION(1, 3, 0); |
|
|
|
appInfo.apiVersion = VK_API_VERSION_1_3; |
|
|
|
appInfo.engineVersion = VK_MAKE_VERSION(1, 1, 0); |
|
|
|
appInfo.apiVersion = VK_API_VERSION_1_1; |
|
|
|
|
|
|
|
return appInfo; |
|
|
|
} |
|
|
@ -211,10 +211,11 @@ std::vector<const char*> ComputeAndGraphics::getRequiredExtensions() |
|
|
|
std::vector<const char*> extensions; |
|
|
|
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME); |
|
|
|
|
|
|
|
#ifdef Q_OS_LINUX |
|
|
|
extensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); |
|
|
|
#elif Q_OS_ANDROID |
|
|
|
|
|
|
|
#if defined(Q_OS_ANDROID) |
|
|
|
extensions.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); |
|
|
|
#elif defined(Q_OS_LINUX) |
|
|
|
extensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); |
|
|
|
#endif |
|
|
|
|
|
|
|
if (enableValidationLayers) { |
|
|
@ -387,11 +388,11 @@ void ComputeAndGraphics::createLogicalDevice() |
|
|
|
|
|
|
|
VkPhysicalDeviceFeatures deviceFeatures = createDeviceCoreFeatures(); |
|
|
|
|
|
|
|
VkPhysicalDeviceVulkan12Features deviceFeatures12 = createDeviceVulkan12Features(nullptr); |
|
|
|
// VkPhysicalDeviceVulkan12Features deviceFeatures12 = createDeviceVulkan12Features(nullptr);
|
|
|
|
// VkPhysicalDevice8BitStorageFeaturesKHR device8BitStorageFeatures2Info = createDevice8BitStorageFeatures2Info();
|
|
|
|
// VkPhysicalDeviceFeatures2 deviceCoreFeatures2 = createDeviceCoreFeatures2(&device8BitStorageFeatures2Info);
|
|
|
|
|
|
|
|
VkDeviceCreateInfo createInfo = createLogicalDeviceInfo(queueCreateInfos, &deviceFeatures, &deviceFeatures12); |
|
|
|
VkDeviceCreateInfo createInfo = createLogicalDeviceInfo(queueCreateInfos, &deviceFeatures, nullptr); |
|
|
|
|
|
|
|
if (vkCreateDevice(_physicalDevice, &createInfo, nullptr, &_device) != VK_SUCCESS) { |
|
|
|
throw std::runtime_error("failed to create logical device!"); |
|
|
@ -420,48 +421,48 @@ VkPhysicalDeviceFeatures ComputeAndGraphics::createDeviceCoreFeatures() |
|
|
|
return deviceFeatures; |
|
|
|
} |
|
|
|
|
|
|
|
VkPhysicalDeviceVulkan12Features ComputeAndGraphics::createDeviceVulkan12Features(void* pNext) |
|
|
|
{ |
|
|
|
VkPhysicalDeviceVulkan12Features deviceFeatures12{}; |
|
|
|
deviceFeatures12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; |
|
|
|
deviceFeatures12.scalarBlockLayout = VK_TRUE; |
|
|
|
deviceFeatures12.shaderInt8 = VK_TRUE; |
|
|
|
deviceFeatures12.uniformAndStorageBuffer8BitAccess = VK_TRUE; |
|
|
|
// deviceFeatures12.storageBuffer8BitAccess = VK_TRUE;
|
|
|
|
// deviceFeatures12.storagePushConstant8 = VK_TRUE;
|
|
|
|
deviceFeatures12.pNext = pNext; |
|
|
|
//VkPhysicalDeviceVulkan12Features ComputeAndGraphics::createDeviceVulkan12Features(void* pNext)
|
|
|
|
//{
|
|
|
|
// VkPhysicalDeviceVulkan12Features deviceFeatures12{};
|
|
|
|
// deviceFeatures12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
|
|
|
|
// deviceFeatures12.scalarBlockLayout = VK_TRUE;
|
|
|
|
// deviceFeatures12.shaderInt8 = VK_TRUE;
|
|
|
|
// deviceFeatures12.uniformAndStorageBuffer8BitAccess = VK_TRUE;
|
|
|
|
//// deviceFeatures12.storageBuffer8BitAccess = VK_TRUE;
|
|
|
|
//// deviceFeatures12.storagePushConstant8 = VK_TRUE;
|
|
|
|
// deviceFeatures12.pNext = pNext;
|
|
|
|
|
|
|
|
return deviceFeatures12; |
|
|
|
} |
|
|
|
// return deviceFeatures12;
|
|
|
|
//}
|
|
|
|
|
|
|
|
VkPhysicalDeviceVulkan13Features ComputeAndGraphics::createDeviceVulkan13Features(void* pNext) |
|
|
|
{ |
|
|
|
VkPhysicalDeviceVulkan13Features deviceFeatures13{}; |
|
|
|
deviceFeatures13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES; |
|
|
|
deviceFeatures13.pNext = pNext; |
|
|
|
//VkPhysicalDeviceVulkan13Features ComputeAndGraphics::createDeviceVulkan13Features(void* pNext)
|
|
|
|
//{
|
|
|
|
// VkPhysicalDeviceVulkan13Features deviceFeatures13{};
|
|
|
|
// deviceFeatures13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
|
|
|
|
// deviceFeatures13.pNext = pNext;
|
|
|
|
|
|
|
|
return deviceFeatures13; |
|
|
|
} |
|
|
|
// return deviceFeatures13;
|
|
|
|
//}
|
|
|
|
|
|
|
|
VkPhysicalDeviceFeatures2 ComputeAndGraphics::createDeviceCoreFeatures2(VkPhysicalDevice8BitStorageFeatures* pNext) |
|
|
|
{ |
|
|
|
VkPhysicalDeviceFeatures2 deviceFeatures2{}; |
|
|
|
deviceFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; |
|
|
|
deviceFeatures2.pNext = pNext; |
|
|
|
//VkPhysicalDeviceFeatures2 ComputeAndGraphics::createDeviceCoreFeatures2(VkPhysicalDevice8BitStorageFeatures* pNext)
|
|
|
|
//{
|
|
|
|
// VkPhysicalDeviceFeatures2 deviceFeatures2{};
|
|
|
|
// deviceFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
|
|
|
// deviceFeatures2.pNext = pNext;
|
|
|
|
|
|
|
|
return deviceFeatures2; |
|
|
|
} |
|
|
|
// return deviceFeatures2;
|
|
|
|
//}
|
|
|
|
|
|
|
|
VkPhysicalDevice8BitStorageFeaturesKHR ComputeAndGraphics::createDevice8BitStorageFeatures2Info() |
|
|
|
{ |
|
|
|
VkPhysicalDevice8BitStorageFeatures storage8BitFeatures{}; |
|
|
|
storage8BitFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES; |
|
|
|
storage8BitFeatures.uniformAndStorageBuffer8BitAccess = VK_TRUE; |
|
|
|
storage8BitFeatures.storagePushConstant8 = VK_TRUE; |
|
|
|
storage8BitFeatures.storageBuffer8BitAccess = VK_TRUE; |
|
|
|
//VkPhysicalDevice8BitStorageFeaturesKHR ComputeAndGraphics::createDevice8BitStorageFeatures2Info()
|
|
|
|
//{
|
|
|
|
// VkPhysicalDevice8BitStorageFeatures storage8BitFeatures{};
|
|
|
|
// storage8BitFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES;
|
|
|
|
// storage8BitFeatures.uniformAndStorageBuffer8BitAccess = VK_TRUE;
|
|
|
|
// storage8BitFeatures.storagePushConstant8 = VK_TRUE;
|
|
|
|
// storage8BitFeatures.storageBuffer8BitAccess = VK_TRUE;
|
|
|
|
|
|
|
|
return storage8BitFeatures; |
|
|
|
} |
|
|
|
// return storage8BitFeatures;
|
|
|
|
//}
|
|
|
|
|
|
|
|
VkDeviceCreateInfo ComputeAndGraphics::createLogicalDeviceInfo(std::vector<VkDeviceQueueCreateInfo>& queueCreateInfos |
|
|
|
, VkPhysicalDeviceFeatures* deviceFeatures, void* pNext) |
|
|
@ -2164,7 +2165,12 @@ void ComputeAndGraphics::updateComputeUniformBuffer(uint32_t currentImage) |
|
|
|
} |
|
|
|
|
|
|
|
void ComputeAndGraphics::recreateSwapChain() { |
|
|
|
int width = 800, height = 600; |
|
|
|
int width = 0, height = 0; |
|
|
|
_windowQt->getWindowSize(width, height); |
|
|
|
while (width == 0 || height == 0) { |
|
|
|
_windowQt->getWindowSize(width, height); |
|
|
|
} |
|
|
|
|
|
|
|
// glfwGetFramebufferSize(_window, &width, &height);
|
|
|
|
// while (width == 0 || height == 0) {
|
|
|
|
// glfwGetFramebufferSize(_window, &width, &height);
|
|
|
|