From d217b09383ecf58202f4e64758c870f7a243a01e Mon Sep 17 00:00:00 2001 From: FakeMichau <49685661+FakeMichau@users.noreply.github.com> Date: Wed, 4 Nov 2026 18:51:19 +0100 Subject: [PATCH] Correctly enable dp4a support on Vulkan --- OptiScaler/hooks/Vulkan_Hooks.cpp | 14 ++++++++------ OptiScaler/spoofing/Vulkan_Spoofing.cpp | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/OptiScaler/hooks/Vulkan_Hooks.cpp b/OptiScaler/hooks/Vulkan_Hooks.cpp index 343bfb3c..70c8b578 100644 --- a/OptiScaler/hooks/Vulkan_Hooks.cpp +++ b/OptiScaler/hooks/Vulkan_Hooks.cpp @@ -519,7 +519,7 @@ static VkResult hkvkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, cons VulkanSpoofing::hkvkCreateInstance(&localCreateInfo, pAllocator, pInstance); // FFX and Streamline use Vulkan 1.2 core functions like vkWaitSemaphores. Wine only provides those to 1.2 apps, - // older ones crash calling them, Streamline's own vkCreateInstance raises the version too. + // older ones crash calling them. Streamline's own vkCreateInstance raises the version to 1.3 VkApplicationInfo appInfo { VK_STRUCTURE_TYPE_APPLICATION_INFO }; const auto fgOutput = State::Instance().activeFgOutput; @@ -528,12 +528,14 @@ static VkResult hkvkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, cons if (localCreateInfo.pApplicationInfo != nullptr) appInfo = *localCreateInfo.pApplicationInfo; - if (appInfo.apiVersion < VK_API_VERSION_1_2) - { - LOG_INFO("Raising the API version from {}.{} to 1.2 for FG", VK_API_VERSION_MAJOR(appInfo.apiVersion), - VK_API_VERSION_MINOR(appInfo.apiVersion)); + const uint32_t fgApiVersion = fgOutput == FGOutput::DLSSG ? VK_API_VERSION_1_3 : VK_API_VERSION_1_2; - appInfo.apiVersion = VK_API_VERSION_1_2; + if (appInfo.apiVersion < fgApiVersion) + { + LOG_INFO("Raising the API version from {}.{} to 1.{} for FG", VK_API_VERSION_MAJOR(appInfo.apiVersion), + VK_API_VERSION_MINOR(appInfo.apiVersion), VK_API_VERSION_MINOR(fgApiVersion)); + + appInfo.apiVersion = fgApiVersion; localCreateInfo.pApplicationInfo = &appInfo; } } diff --git a/OptiScaler/spoofing/Vulkan_Spoofing.cpp b/OptiScaler/spoofing/Vulkan_Spoofing.cpp index ce3f01ed..a894d7ea 100644 --- a/OptiScaler/spoofing/Vulkan_Spoofing.cpp +++ b/OptiScaler/spoofing/Vulkan_Spoofing.cpp @@ -561,6 +561,9 @@ struct VulkanDeviceFeatureState::Impl VkPhysicalDeviceComputeShaderDerivativesFeaturesKHR computeShaderDerivatives { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_KHR }; + VkPhysicalDeviceShaderIntegerDotProductFeatures integerDotProduct { + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES + }; Impl(VkDeviceCreateInfo* pCreateInfo, PFN_vkGetPhysicalDeviceFeatures2 getFeatures2) : pCreateInfo(pCreateInfo), getFeatures2(getFeatures2) @@ -580,7 +583,7 @@ struct VulkanDeviceFeatureState::Impl CopyFeatureChain(pCreateInfo->pNext, features2, vulkan12Features, vulkan13Features, shaderFloat16Int8, storage8Bit, descriptorIndexing, bufferDeviceAddress, vulkanMemoryModel, synchronization2, subgroupSizeControl, timelineSemaphore, descriptorBuffer, shaderFloat8, cooperativeMatrix, - cooperativeMatrix2, computeShaderDerivatives); + cooperativeMatrix2, computeShaderDerivatives, integerDotProduct); } bool CanUpgradeExtBufferDeviceAddress(VkPhysicalDevice physicalDevice) @@ -769,10 +772,17 @@ struct VulkanDeviceFeatureState::Impl EnableExistingFeature(modifiedFeatures, features, vulkan13Features, &VkPhysicalDeviceVulkan13Features::computeFullSubgroups, supported.computeFullSubgroups); + EnableExistingFeature(modifiedFeatures, features, vulkan13Features, + &VkPhysicalDeviceVulkan13Features::shaderIntegerDotProduct, + supported.shaderIntegerDotProduct); return; } + EnableSupportedFeature(pCreateInfo, modifiedFeatures, integerDotProduct, + &VkPhysicalDeviceShaderIntegerDotProductFeatures::shaderIntegerDotProduct, + supported.shaderIntegerDotProduct); + EnableSupportedFeature(pCreateInfo, modifiedFeatures, synchronization2, &VkPhysicalDeviceSynchronization2Features::synchronization2, supported.synchronization2); @@ -793,6 +803,11 @@ struct VulkanDeviceFeatureState::Impl EnableFeatureStruct(pCreateInfo, getFeatures2, physicalDevice, modifiedFeatures, subgroupSizeControl, &VkPhysicalDeviceSubgroupSizeControlFeatures::subgroupSizeControl, &VkPhysicalDeviceSubgroupSizeControlFeatures::computeFullSubgroups); + + // Added for XeSS, its DP4a path and DLSSG replacements running D3D12 on Vulkan use it + if (HasExtension(pCreateInfo, VK_KHR_SHADER_INTEGER_DOT_PRODUCT_EXTENSION_NAME)) + EnableFeatureStruct(pCreateInfo, getFeatures2, physicalDevice, modifiedFeatures, integerDotProduct, + &VkPhysicalDeviceShaderIntegerDotProductFeatures::shaderIntegerDotProduct); } void EnableVulkan14Features(VkPhysicalDevice physicalDevice)