From b884c566317250f35b900f3610f499f76a3ae831 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 30 Jan 2019 13:04:32 +0100 Subject: [PATCH] [dxvk] Enable VK_EXT_memory_priority and features if available --- src/d3d11/d3d11_device.cpp | 4 ++++ src/dxvk/dxvk_adapter.cpp | 15 ++++++++++++++- src/dxvk/dxvk_device_info.h | 1 + src/dxvk/dxvk_extensions.h | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index d78bde3e..f4799bbf 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -1353,6 +1353,10 @@ namespace dxvk { enabled.core.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR; enabled.core.pNext = nullptr; + enabled.extMemoryPriority.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT; + enabled.extMemoryPriority.pNext = nullptr; + enabled.extMemoryPriority.memoryPriority = supported.extMemoryPriority.memoryPriority; + enabled.extTransformFeedback.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT; enabled.extTransformFeedback.pNext = nullptr; diff --git a/src/dxvk/dxvk_adapter.cpp b/src/dxvk/dxvk_adapter.cpp index 12775c13..4fe653e0 100644 --- a/src/dxvk/dxvk_adapter.cpp +++ b/src/dxvk/dxvk_adapter.cpp @@ -199,6 +199,8 @@ namespace dxvk { || !required.core.features.variableMultisampleRate) && (m_deviceFeatures.core.features.inheritedQueries || !required.core.features.inheritedQueries) + && (m_deviceFeatures.extMemoryPriority.memoryPriority + || !required.extMemoryPriority.memoryPriority) && (m_deviceFeatures.extTransformFeedback.transformFeedback || !required.extTransformFeedback.transformFeedback) && (m_deviceFeatures.extVertexAttributeDivisor.vertexAttributeInstanceRateDivisor @@ -216,8 +218,9 @@ namespace dxvk { Rc DxvkAdapter::createDevice(DxvkDeviceFeatures enabledFeatures) { DxvkDeviceExtensions devExtensions; - std::array devExtensionList = {{ + std::array devExtensionList = {{ &devExtensions.amdMemoryOverallocationBehaviour, + &devExtensions.extMemoryPriority, &devExtensions.extShaderViewportIndexLayer, &devExtensions.extTransformFeedback, &devExtensions.extVertexAttributeDivisor, @@ -251,6 +254,11 @@ namespace dxvk { // Create pNext chain for additional device features enabledFeatures.core.pNext = nullptr; + if (devExtensions.extMemoryPriority) { + enabledFeatures.extMemoryPriority.pNext = enabledFeatures.core.pNext; + enabledFeatures.core.pNext = &enabledFeatures.extMemoryPriority; + } + if (devExtensions.extTransformFeedback) { enabledFeatures.extTransformFeedback.pNext = enabledFeatures.core.pNext; enabledFeatures.core.pNext = &enabledFeatures.extTransformFeedback; @@ -442,6 +450,11 @@ namespace dxvk { m_deviceFeatures.core.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR; m_deviceFeatures.core.pNext = nullptr; + if (m_deviceExtensions.supports(VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME)) { + m_deviceFeatures.extMemoryPriority.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT; + m_deviceFeatures.extMemoryPriority.pNext = std::exchange(m_deviceFeatures.core.pNext, &m_deviceFeatures.extMemoryPriority); + } + if (m_deviceExtensions.supports(VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME)) { m_deviceFeatures.extTransformFeedback.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT; m_deviceFeatures.extTransformFeedback.pNext = std::exchange(m_deviceFeatures.core.pNext, &m_deviceFeatures.extTransformFeedback); diff --git a/src/dxvk/dxvk_device_info.h b/src/dxvk/dxvk_device_info.h index 625a5fc8..673febfb 100644 --- a/src/dxvk/dxvk_device_info.h +++ b/src/dxvk/dxvk_device_info.h @@ -31,6 +31,7 @@ namespace dxvk { */ struct DxvkDeviceFeatures { VkPhysicalDeviceFeatures2KHR core; + VkPhysicalDeviceMemoryPriorityFeaturesEXT extMemoryPriority; VkPhysicalDeviceTransformFeedbackFeaturesEXT extTransformFeedback; VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT extVertexAttributeDivisor; }; diff --git a/src/dxvk/dxvk_extensions.h b/src/dxvk/dxvk_extensions.h index 77bfa1e2..62d5264a 100644 --- a/src/dxvk/dxvk_extensions.h +++ b/src/dxvk/dxvk_extensions.h @@ -258,6 +258,7 @@ namespace dxvk { */ struct DxvkDeviceExtensions { DxvkExt amdMemoryOverallocationBehaviour= { VK_AMD_MEMORY_OVERALLOCATION_BEHAVIOR_EXTENSION_NAME, DxvkExtMode::Optional }; + DxvkExt extMemoryPriority = { VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME, DxvkExtMode::Optional }; DxvkExt extShaderViewportIndexLayer = { VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, DxvkExtMode::Optional }; DxvkExt extTransformFeedback = { VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME, DxvkExtMode::Optional }; DxvkExt extVertexAttributeDivisor = { VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME, DxvkExtMode::Optional };