From b2a53a2413e0323faf3d30b361dd4a4ec3c90930 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 2 Jul 2019 20:25:06 +0200 Subject: [PATCH] [dxvk] Enable VK_EXT_shader_demote_to_helper_invocation if available --- src/dxvk/dxvk_adapter.cpp | 14 +++++++++++- src/dxvk/dxvk_device_info.h | 15 +++++++------ src/dxvk/dxvk_extensions.h | 43 +++++++++++++++++++------------------ 3 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/dxvk/dxvk_adapter.cpp b/src/dxvk/dxvk_adapter.cpp index 748aa6b2f..48364df02 100644 --- a/src/dxvk/dxvk_adapter.cpp +++ b/src/dxvk/dxvk_adapter.cpp @@ -245,7 +245,7 @@ namespace dxvk { Rc DxvkAdapter::createDevice(std::string clientApi, DxvkDeviceFeatures enabledFeatures) { DxvkDeviceExtensions devExtensions; - std::array devExtensionList = {{ + std::array devExtensionList = {{ &devExtensions.amdMemoryOverallocationBehaviour, &devExtensions.amdShaderFragmentMask, &devExtensions.extConditionalRendering, @@ -253,6 +253,7 @@ namespace dxvk { &devExtensions.extHostQueryReset, &devExtensions.extMemoryBudget, &devExtensions.extMemoryPriority, + &devExtensions.extShaderDemoteToHelperInvocation, &devExtensions.extShaderViewportIndexLayer, &devExtensions.extTransformFeedback, &devExtensions.extVertexAttributeDivisor, @@ -312,6 +313,12 @@ namespace dxvk { enabledFeatures.core.pNext = &enabledFeatures.extMemoryPriority; } + if (devExtensions.extShaderDemoteToHelperInvocation) { + enabledFeatures.extShaderDemoteToHelperInvocation.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT; + enabledFeatures.extShaderDemoteToHelperInvocation.pNext = enabledFeatures.core.pNext; + enabledFeatures.core.pNext = &enabledFeatures.extShaderDemoteToHelperInvocation; + } + if (devExtensions.extTransformFeedback) { enabledFeatures.extTransformFeedback.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT; enabledFeatures.extTransformFeedback.pNext = enabledFeatures.core.pNext; @@ -523,6 +530,11 @@ namespace dxvk { m_deviceFeatures.extMemoryPriority.pNext = std::exchange(m_deviceFeatures.core.pNext, &m_deviceFeatures.extMemoryPriority); } + if (m_deviceExtensions.supports(VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME)) { + m_deviceFeatures.extShaderDemoteToHelperInvocation.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT; + m_deviceFeatures.extShaderDemoteToHelperInvocation.pNext = std::exchange(m_deviceFeatures.core.pNext, &m_deviceFeatures.extShaderDemoteToHelperInvocation); + } + 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 74d806783..0f12ac77f 100644 --- a/src/dxvk/dxvk_device_info.h +++ b/src/dxvk/dxvk_device_info.h @@ -30,13 +30,14 @@ namespace dxvk { * extended features will be marked as unsupported. */ struct DxvkDeviceFeatures { - VkPhysicalDeviceFeatures2KHR core; - VkPhysicalDeviceConditionalRenderingFeaturesEXT extConditionalRendering; - VkPhysicalDeviceDepthClipEnableFeaturesEXT extDepthClipEnable; - VkPhysicalDeviceHostQueryResetFeaturesEXT extHostQueryReset; - VkPhysicalDeviceMemoryPriorityFeaturesEXT extMemoryPriority; - VkPhysicalDeviceTransformFeedbackFeaturesEXT extTransformFeedback; - VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT extVertexAttributeDivisor; + VkPhysicalDeviceFeatures2KHR core; + VkPhysicalDeviceConditionalRenderingFeaturesEXT extConditionalRendering; + VkPhysicalDeviceDepthClipEnableFeaturesEXT extDepthClipEnable; + VkPhysicalDeviceHostQueryResetFeaturesEXT extHostQueryReset; + VkPhysicalDeviceMemoryPriorityFeaturesEXT extMemoryPriority; + VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT extShaderDemoteToHelperInvocation; + VkPhysicalDeviceTransformFeedbackFeaturesEXT extTransformFeedback; + VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT extVertexAttributeDivisor; }; } \ No newline at end of file diff --git a/src/dxvk/dxvk_extensions.h b/src/dxvk/dxvk_extensions.h index 3e6ef6677..12e331ed5 100644 --- a/src/dxvk/dxvk_extensions.h +++ b/src/dxvk/dxvk_extensions.h @@ -258,27 +258,28 @@ namespace dxvk { * used by DXVK if supported by the implementation. */ struct DxvkDeviceExtensions { - DxvkExt amdMemoryOverallocationBehaviour= { VK_AMD_MEMORY_OVERALLOCATION_BEHAVIOR_EXTENSION_NAME, DxvkExtMode::Optional }; - DxvkExt amdShaderFragmentMask = { VK_AMD_SHADER_FRAGMENT_MASK_EXTENSION_NAME, DxvkExtMode::Optional }; - DxvkExt extConditionalRendering = { VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME, DxvkExtMode::Optional }; - DxvkExt extDepthClipEnable = { VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME, DxvkExtMode::Optional }; - DxvkExt extHostQueryReset = { VK_EXT_HOST_QUERY_RESET_EXTENSION_NAME, DxvkExtMode::Optional }; - DxvkExt extMemoryBudget = { VK_EXT_MEMORY_BUDGET_EXTENSION_NAME, DxvkExtMode::Passive }; - 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 }; - DxvkExt khrDedicatedAllocation = { VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, DxvkExtMode::Required }; - DxvkExt khrDescriptorUpdateTemplate = { VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME, DxvkExtMode::Required }; - DxvkExt khrDrawIndirectCount = { VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, DxvkExtMode::Optional }; - DxvkExt khrDriverProperties = { VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME, DxvkExtMode::Optional }; - DxvkExt khrGetMemoryRequirements2 = { VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, DxvkExtMode::Required }; - DxvkExt khrImageFormatList = { VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME, DxvkExtMode::Required }; - DxvkExt khrMaintenance1 = { VK_KHR_MAINTENANCE1_EXTENSION_NAME, DxvkExtMode::Required }; - DxvkExt khrMaintenance2 = { VK_KHR_MAINTENANCE2_EXTENSION_NAME, DxvkExtMode::Required }; - DxvkExt khrSamplerMirrorClampToEdge = { VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, DxvkExtMode::Optional }; - DxvkExt khrShaderDrawParameters = { VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, DxvkExtMode::Required }; - DxvkExt khrSwapchain = { VK_KHR_SWAPCHAIN_EXTENSION_NAME, DxvkExtMode::Required }; + DxvkExt amdMemoryOverallocationBehaviour = { VK_AMD_MEMORY_OVERALLOCATION_BEHAVIOR_EXTENSION_NAME, DxvkExtMode::Optional }; + DxvkExt amdShaderFragmentMask = { VK_AMD_SHADER_FRAGMENT_MASK_EXTENSION_NAME, DxvkExtMode::Optional }; + DxvkExt extConditionalRendering = { VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME, DxvkExtMode::Optional }; + DxvkExt extDepthClipEnable = { VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME, DxvkExtMode::Optional }; + DxvkExt extHostQueryReset = { VK_EXT_HOST_QUERY_RESET_EXTENSION_NAME, DxvkExtMode::Optional }; + DxvkExt extMemoryBudget = { VK_EXT_MEMORY_BUDGET_EXTENSION_NAME, DxvkExtMode::Passive }; + DxvkExt extMemoryPriority = { VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME, DxvkExtMode::Optional }; + DxvkExt extShaderDemoteToHelperInvocation = { VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_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 }; + DxvkExt khrDedicatedAllocation = { VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, DxvkExtMode::Required }; + DxvkExt khrDescriptorUpdateTemplate = { VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME, DxvkExtMode::Required }; + DxvkExt khrDrawIndirectCount = { VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, DxvkExtMode::Optional }; + DxvkExt khrDriverProperties = { VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME, DxvkExtMode::Optional }; + DxvkExt khrGetMemoryRequirements2 = { VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, DxvkExtMode::Required }; + DxvkExt khrImageFormatList = { VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME, DxvkExtMode::Required }; + DxvkExt khrMaintenance1 = { VK_KHR_MAINTENANCE1_EXTENSION_NAME, DxvkExtMode::Required }; + DxvkExt khrMaintenance2 = { VK_KHR_MAINTENANCE2_EXTENSION_NAME, DxvkExtMode::Required }; + DxvkExt khrSamplerMirrorClampToEdge = { VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, DxvkExtMode::Optional }; + DxvkExt khrShaderDrawParameters = { VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, DxvkExtMode::Required }; + DxvkExt khrSwapchain = { VK_KHR_SWAPCHAIN_EXTENSION_NAME, DxvkExtMode::Required }; }; /**