diff --git a/src/modules/graphics/vulkan/Graphics.cpp b/src/modules/graphics/vulkan/Graphics.cpp index 065add298..abe12ed1a 100644 --- a/src/modules/graphics/vulkan/Graphics.cpp +++ b/src/modules/graphics/vulkan/Graphics.cpp @@ -82,7 +82,7 @@ Graphics::Graphics() volkInitializeCustom((PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr()); - vulkanApiVersion = volkGetInstanceVersion(); + instanceVersion = volkGetInstanceVersion(); } Graphics::~Graphics() @@ -1295,7 +1295,7 @@ void Graphics::createVulkanInstance() appInfo.applicationVersion = VK_MAKE_API_VERSION(0, 1, 0, 0); // get this version from somewhere else? appInfo.pEngineName = "LOVE Game Framework"; appInfo.engineVersion = VK_MAKE_API_VERSION(0, VERSION_MAJOR, VERSION_MINOR, VERSION_REV); - appInfo.apiVersion = vulkanApiVersion; + appInfo.apiVersion = instanceVersion; VkInstanceCreateInfo createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; @@ -1330,11 +1330,6 @@ void Graphics::createVulkanInstance() createInfo.enabledLayerCount = static_cast(validationLayers.size()); createInfo.ppEnabledLayerNames = validationLayers.data(); } - else - { - createInfo.enabledLayerCount = 0; - createInfo.ppEnabledLayerNames = nullptr; - } if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) throw love::Exception("couldn't create vulkan instance"); @@ -1354,12 +1349,14 @@ bool Graphics::checkValidationSupport() { bool layerFound = false; - for (const auto &layerProperties : availableLayers) + for (const auto& layerProperties : availableLayers) + { if (strcmp(layerName, layerProperties.layerName) == 0) { layerFound = true; break; } + } if (!layerFound) return false; @@ -1395,6 +1392,7 @@ void Graphics::pickPhysicalDevice() VkPhysicalDeviceProperties properties; vkGetPhysicalDeviceProperties(physicalDevice, &properties); minUniformBufferOffsetAlignment = properties.limits.minUniformBufferOffsetAlignment; + deviceApiVersion = properties.apiVersion; msaaSamples = getMsaaCount(requestedMsaa); } @@ -1556,7 +1554,7 @@ void Graphics::createLogicalDevice() optionalDeviceFeatures.memoryBudget = false; if (optionalDeviceFeatures.spirv14 && !optionalDeviceFeatures.shaderFloatControls) optionalDeviceFeatures.spirv14 = false; - if (optionalDeviceFeatures.spirv14 && vulkanApiVersion < VK_API_VERSION_1_1) + if (optionalDeviceFeatures.spirv14 && deviceApiVersion < VK_API_VERSION_1_1) optionalDeviceFeatures.spirv14 = false; VkPhysicalDeviceFeatures deviceFeatures{}; @@ -1584,7 +1582,7 @@ void Graphics::createLogicalDevice() enabledExtensions.push_back(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME); if (optionalDeviceFeatures.spirv14) enabledExtensions.push_back(VK_KHR_SPIRV_1_4_EXTENSION_NAME); - if (vulkanApiVersion >= VK_API_VERSION_1_1) + if (deviceApiVersion >= VK_API_VERSION_1_1) enabledExtensions.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); createInfo.enabledExtensionCount = static_cast(enabledExtensions.size()); @@ -1595,8 +1593,6 @@ void Graphics::createLogicalDevice() createInfo.enabledLayerCount = static_cast(validationLayers.size()); createInfo.ppEnabledLayerNames = validationLayers.data(); } - else - createInfo.enabledLayerCount = 0; VkPhysicalDeviceExtendedDynamicStateFeaturesEXT extendedDynamicStateFeatures{}; extendedDynamicStateFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT; @@ -1617,7 +1613,7 @@ void Graphics::createLogicalDevice() void Graphics::initVMA() { VmaAllocatorCreateInfo allocatorCreateInfo = {}; - allocatorCreateInfo.vulkanApiVersion = vulkanApiVersion; + allocatorCreateInfo.vulkanApiVersion = deviceApiVersion; allocatorCreateInfo.physicalDevice = physicalDevice; allocatorCreateInfo.device = device; allocatorCreateInfo.instance = instance; diff --git a/src/modules/graphics/vulkan/Graphics.h b/src/modules/graphics/vulkan/Graphics.h index 4f547735e..34f276fd6 100644 --- a/src/modules/graphics/vulkan/Graphics.h +++ b/src/modules/graphics/vulkan/Graphics.h @@ -365,9 +365,10 @@ private: VkSampler createSampler(const SamplerState &sampler); void cleanupUnusedObjects(); - uint32_t vulkanApiVersion = VK_VERSION_1_0; + uint32_t instanceVersion = VK_API_VERSION_1_0; VkInstance instance = VK_NULL_HANDLE; VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; + uint32_t deviceApiVersion = VK_API_VERSION_1_0; bool windowHasStencil = false; int requestedMsaa = 0; VkDevice device = VK_NULL_HANDLE;