From aa41a7a35121e6bf660e6e9a21ef54f13c433aa3 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 23 Aug 2023 14:42:03 +0200 Subject: [PATCH] [dxvk] Enable VK_KHR_maintenance5 if available. --- src/dxvk/dxvk_adapter.cpp | 32 +++++++++++++++++++++++++++++--- src/dxvk/dxvk_device_info.h | 2 ++ src/dxvk/dxvk_extensions.h | 3 ++- src/vulkan/vulkan_loader.h | 9 ++++++++- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/dxvk/dxvk_adapter.cpp b/src/dxvk/dxvk_adapter.cpp index 8cf2e0e3a..cf4c3cce6 100644 --- a/src/dxvk/dxvk_adapter.cpp +++ b/src/dxvk/dxvk_adapter.cpp @@ -398,6 +398,10 @@ namespace dxvk { m_deviceFeatures.extSwapchainMaintenance1.swapchainMaintenance1 && instance->extensions().extSurfaceMaintenance1; + // Enable maintenance5 if supported + enabledFeatures.khrMaintenance5.maintenance5 = + m_deviceFeatures.khrMaintenance5.maintenance5; + // Enable present id and present wait together, if possible enabledFeatures.khrPresentId.presentId = m_deviceFeatures.khrPresentId.presentId; @@ -590,6 +594,10 @@ namespace dxvk { enabledFeatures.extVertexAttributeDivisor = *reinterpret_cast(f); break; + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR: + enabledFeatures.khrMaintenance5 = *reinterpret_cast(f); + break; + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR: enabledFeatures.khrPresentId = *reinterpret_cast(f); break; @@ -760,6 +768,11 @@ namespace dxvk { m_deviceInfo.extVertexAttributeDivisor.pNext = std::exchange(m_deviceInfo.core.pNext, &m_deviceInfo.extVertexAttributeDivisor); } + if (m_deviceExtensions.supports(VK_KHR_MAINTENANCE_5_EXTENSION_NAME)) { + m_deviceInfo.khrMaintenance5.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR; + m_deviceInfo.khrMaintenance5.pNext = std::exchange(m_deviceInfo.core.pNext, &m_deviceInfo.khrMaintenance5); + } + // Query full device properties for all enabled extensions m_vki->vkGetPhysicalDeviceProperties2(m_handle, &m_deviceInfo.core); @@ -899,6 +912,11 @@ namespace dxvk { if (m_deviceExtensions.supports(VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME)) m_deviceFeatures.khrExternalSemaphoreWin32 = VK_TRUE; + if (m_deviceExtensions.supports(VK_KHR_MAINTENANCE_5_EXTENSION_NAME)) { + m_deviceFeatures.khrMaintenance5.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR; + m_deviceFeatures.khrMaintenance5.pNext = std::exchange(m_deviceFeatures.core.pNext, &m_deviceFeatures.khrMaintenance5); + } + if (m_deviceExtensions.supports(VK_KHR_PRESENT_ID_EXTENSION_NAME)) { m_deviceFeatures.khrPresentId.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR; m_deviceFeatures.khrPresentId.pNext = std::exchange(m_deviceFeatures.core.pNext, &m_deviceFeatures.khrPresentId); @@ -970,11 +988,12 @@ namespace dxvk { &devExtensions.extVertexAttributeDivisor, &devExtensions.khrExternalMemoryWin32, &devExtensions.khrExternalSemaphoreWin32, - &devExtensions.khrWin32KeyedMutex, + &devExtensions.khrMaintenance5, &devExtensions.khrPipelineLibrary, &devExtensions.khrPresentId, &devExtensions.khrPresentWait, &devExtensions.khrSwapchain, + &devExtensions.khrWin32KeyedMutex, &devExtensions.nvxBinaryImport, &devExtensions.nvxImageViewHandle, }}; @@ -1099,8 +1118,10 @@ namespace dxvk { if (devExtensions.khrExternalSemaphoreWin32) enabledFeatures.khrExternalSemaphoreWin32 = VK_TRUE; - if (devExtensions.nvxBinaryImport) - enabledFeatures.nvxBinaryImport = VK_TRUE; + if (devExtensions.khrMaintenance5) { + enabledFeatures.khrMaintenance5.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR; + enabledFeatures.khrMaintenance5.pNext = std::exchange(enabledFeatures.core.pNext, &enabledFeatures.khrMaintenance5); + } if (devExtensions.khrPresentId) { enabledFeatures.khrPresentId.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR; @@ -1112,6 +1133,9 @@ namespace dxvk { enabledFeatures.khrPresentWait.pNext = std::exchange(enabledFeatures.core.pNext, &enabledFeatures.khrPresentWait); } + if (devExtensions.nvxBinaryImport) + enabledFeatures.nvxBinaryImport = VK_TRUE; + if (devExtensions.nvxImageViewHandle) enabledFeatures.nvxImageViewHandle = VK_TRUE; @@ -1249,6 +1273,8 @@ namespace dxvk { "\n extension supported : ", features.khrExternalMemoryWin32 ? "1" : "0", "\n", VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME, "\n extension supported : ", features.khrExternalSemaphoreWin32 ? "1" : "0", + "\n", VK_KHR_MAINTENANCE_5_EXTENSION_NAME, + "\n maintenance5 : ", features.khrMaintenance5.maintenance5 ? "1" : "0", "\n", VK_KHR_PRESENT_ID_EXTENSION_NAME, "\n presentId : ", features.khrPresentId.presentId ? "1" : "0", "\n", VK_KHR_PRESENT_WAIT_EXTENSION_NAME, diff --git a/src/dxvk/dxvk_device_info.h b/src/dxvk/dxvk_device_info.h index 1eb1b1dd3..e23a0e181 100644 --- a/src/dxvk/dxvk_device_info.h +++ b/src/dxvk/dxvk_device_info.h @@ -25,6 +25,7 @@ namespace dxvk { VkPhysicalDeviceRobustness2PropertiesEXT extRobustness2; VkPhysicalDeviceTransformFeedbackPropertiesEXT extTransformFeedback; VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT extVertexAttributeDivisor; + VkPhysicalDeviceMaintenance5PropertiesKHR khrMaintenance5; }; @@ -64,6 +65,7 @@ namespace dxvk { VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT extVertexAttributeDivisor; VkBool32 khrExternalMemoryWin32; VkBool32 khrExternalSemaphoreWin32; + VkPhysicalDeviceMaintenance5FeaturesKHR khrMaintenance5; VkPhysicalDevicePresentIdFeaturesKHR khrPresentId; VkPhysicalDevicePresentWaitFeaturesKHR khrPresentWait; VkBool32 nvxBinaryImport; diff --git a/src/dxvk/dxvk_extensions.h b/src/dxvk/dxvk_extensions.h index d8c7e0c49..8164ccf6a 100644 --- a/src/dxvk/dxvk_extensions.h +++ b/src/dxvk/dxvk_extensions.h @@ -319,11 +319,12 @@ namespace dxvk { DxvkExt extVertexAttributeDivisor = { VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME, DxvkExtMode::Optional }; DxvkExt khrExternalMemoryWin32 = { VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME, DxvkExtMode::Optional }; DxvkExt khrExternalSemaphoreWin32 = { VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME, DxvkExtMode::Optional }; - DxvkExt khrWin32KeyedMutex = { VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME, DxvkExtMode::Optional }; + DxvkExt khrMaintenance5 = { VK_KHR_MAINTENANCE_5_EXTENSION_NAME, DxvkExtMode::Optional }; DxvkExt khrPipelineLibrary = { VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME, DxvkExtMode::Optional }; DxvkExt khrPresentId = { VK_KHR_PRESENT_ID_EXTENSION_NAME, DxvkExtMode::Optional }; DxvkExt khrPresentWait = { VK_KHR_PRESENT_WAIT_EXTENSION_NAME, DxvkExtMode::Optional }; DxvkExt khrSwapchain = { VK_KHR_SWAPCHAIN_EXTENSION_NAME, DxvkExtMode::Required }; + DxvkExt khrWin32KeyedMutex = { VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME, DxvkExtMode::Optional }; DxvkExt nvxBinaryImport = { VK_NVX_BINARY_IMPORT_EXTENSION_NAME, DxvkExtMode::Disabled }; DxvkExt nvxImageViewHandle = { VK_NVX_IMAGE_VIEW_HANDLE_EXTENSION_NAME, DxvkExtMode::Disabled }; }; diff --git a/src/vulkan/vulkan_loader.h b/src/vulkan/vulkan_loader.h index 185779e52..1741ccb87 100644 --- a/src/vulkan/vulkan_loader.h +++ b/src/vulkan/vulkan_loader.h @@ -436,7 +436,14 @@ namespace dxvk::vk { VULKAN_FN(vkImportSemaphoreWin32HandleKHR); #endif - #ifdef VK_KHR_PRESENT_WAIT_EXTENSION_NAME + #ifdef VK_KHR_maintenance5 + VULKAN_FN(vkCmdBindIndexBuffer2KHR); + VULKAN_FN(vkGetRenderingAreaGranularityKHR); + VULKAN_FN(vkGetDeviceImageSubresourceLayoutKHR); + VULKAN_FN(vkGetImageSubresourceLayout2KHR); + #endif + + #ifdef VK_KHR_present_wait VULKAN_FN(vkWaitForPresentKHR); #endif