diff --git a/src/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs b/src/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs index 952867642d..c7df9bafc1 100644 --- a/src/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs +++ b/src/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs @@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Vulkan public readonly bool SupportsShaderStorageImageMultisample; public readonly bool SupportsConditionalRendering; public readonly bool SupportsExtendedDynamicState; - public readonly bool SupportsExtendedDynamicState2; + public readonly PhysicalDeviceExtendedDynamicState2FeaturesEXT SupportsExtendedDynamicState2; public readonly bool SupportsMultiView; public readonly bool SupportsNullDescriptors; public readonly bool SupportsPushDescriptors; @@ -71,7 +71,7 @@ namespace Ryujinx.Graphics.Vulkan bool supportsShaderStorageImageMultisample, bool supportsConditionalRendering, bool supportsExtendedDynamicState, - bool supportsExtendedDynamicState2, + PhysicalDeviceExtendedDynamicState2FeaturesEXT supportsExtendedDynamicState2, bool supportsMultiView, bool supportsNullDescriptors, bool supportsPushDescriptors, diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 257a22fd9a..3ccd82a10e 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -127,7 +127,7 @@ namespace Ryujinx.Graphics.Vulkan _supportExtDynamic = gd.Capabilities.SupportsExtendedDynamicState; - _supportExtDynamic2 = gd.Capabilities.SupportsExtendedDynamicState2; + _supportExtDynamic2 = gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2; _newState.Initialize(); } @@ -970,7 +970,7 @@ namespace Ryujinx.Graphics.Vulkan _newState.LogicOpEnable = logicOpEnable; - if (Gd.ExtendedDynamicState2Features.ExtendedDynamicState2LogicOp) + if (Gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2LogicOp) { DynamicState.SetLogicOp(logicOpEnable ? op.Convert() : default); } @@ -993,7 +993,7 @@ namespace Ryujinx.Graphics.Vulkan public void SetPatchParameters(int vertices, ReadOnlySpan defaultOuterLevel, ReadOnlySpan defaultInnerLevel) { - if (Gd.ExtendedDynamicState2Features.ExtendedDynamicState2PatchControlPoints && _newState.HasTessellationControlShader) + if (Gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2PatchControlPoints && _newState.HasTessellationControlShader) { DynamicState.SetPatchControlPoints((uint)vertices); } diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs index 86939b0bef..66ce0fa1aa 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs @@ -405,7 +405,7 @@ namespace Ryujinx.Graphics.Vulkan } bool supportsExtDynamicState = gd.Capabilities.SupportsExtendedDynamicState; - bool supportsExtDynamicState2 = gd.Capabilities.SupportsExtendedDynamicState2; + bool supportsExtDynamicState2 = gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2; fixed (VertexInputAttributeDescription* pVertexAttributeDescriptions = &Internal.VertexAttributeDescriptions[0]) fixed (VertexInputAttributeDescription* pVertexAttributeDescriptions2 = &_vertexAttributeDescriptions2[0]) @@ -429,7 +429,7 @@ namespace Ryujinx.Graphics.Vulkan PipelineTessellationStateCreateInfo tessellationState; - if (!gd.ExtendedDynamicState2Features.ExtendedDynamicState2PatchControlPoints) + if (!gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2PatchControlPoints) { tessellationState.SType = StructureType.PipelineTessellationStateCreateInfo; tessellationState.PatchControlPoints = PatchControlPoints; @@ -545,7 +545,7 @@ namespace Ryujinx.Graphics.Vulkan LogicOpEnable = LogicOpEnable, }; - if (!gd.ExtendedDynamicState2Features.ExtendedDynamicState2LogicOp) + if (!gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2LogicOp) { colorBlendState.LogicOp = LogicOp; } @@ -609,11 +609,11 @@ namespace Ryujinx.Graphics.Vulkan dynamicStates[currentIndex++] = DynamicState.RasterizerDiscardEnableExt; dynamicStates[currentIndex++] = DynamicState.PrimitiveRestartEnableExt; - if (gd.ExtendedDynamicState2Features.ExtendedDynamicState2LogicOp) + if (gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2LogicOp) { dynamicStates[currentIndex++] = DynamicState.LogicOpExt; } - if (gd.ExtendedDynamicState2Features.ExtendedDynamicState2PatchControlPoints && HasTessellationControlShader) + if (gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2PatchControlPoints && HasTessellationControlShader) { dynamicStates[currentIndex++] = DynamicState.PatchControlPointsExt; } @@ -643,7 +643,7 @@ namespace Ryujinx.Graphics.Vulkan RenderPass = renderPass, }; - if (!gd.ExtendedDynamicState2Features.ExtendedDynamicState2PatchControlPoints) + if (!gd.Capabilities.SupportsExtendedDynamicState2.ExtendedDynamicState2PatchControlPoints) { pipelineCreateInfo.PTessellationState = &tessellationState; } diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanInitialization.cs b/src/Ryujinx.Graphics.Vulkan/VulkanInitialization.cs index 3107dcf300..72aeae3c8c 100644 --- a/src/Ryujinx.Graphics.Vulkan/VulkanInitialization.cs +++ b/src/Ryujinx.Graphics.Vulkan/VulkanInitialization.cs @@ -265,7 +265,7 @@ namespace Ryujinx.Graphics.Vulkan return InvalidIndex; } - internal static Device CreateDevice(Vk api, VulkanPhysicalDevice physicalDevice, uint queueFamilyIndex, uint queueCount, out PhysicalDeviceExtendedDynamicState2FeaturesEXT extendedDynamicState2Features) + internal static Device CreateDevice(Vk api, VulkanPhysicalDevice physicalDevice, uint queueFamilyIndex, uint queueCount) { if (queueCount > QueuesCount) { @@ -472,16 +472,12 @@ namespace Ryujinx.Graphics.Vulkan supportedFeaturesExtExtendedDynamicState2.ExtendedDynamicState2, ExtendedDynamicState2LogicOp = supportedFeaturesExtExtendedDynamicState2.ExtendedDynamicState2LogicOp, - ExtendedDynamicState2PatchControlPoints = supportedFeaturesExtExtendedDynamicState2 - .ExtendedDynamicState2PatchControlPoints, + ExtendedDynamicState2PatchControlPoints = false, }; pExtendedFeatures = &featuresExtendedDynamicState2; } - extendedDynamicState2Features = supportedFeaturesExtExtendedDynamicState2; - - var featuresVk11 = new PhysicalDeviceVulkan11Features { SType = StructureType.PhysicalDeviceVulkan11Features, diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs index b8f50e6a1a..bb6216be77 100644 --- a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs +++ b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs @@ -100,9 +100,6 @@ namespace Ryujinx.Graphics.Vulkan public bool PreferThreading => true; - public PhysicalDeviceExtendedDynamicState2FeaturesEXT ExtendedDynamicState2Features; - - public event EventHandler ScreenCaptured; public VulkanRenderer(Vk api, Func surfaceFunc, Func requiredExtensionsFunc, string preferredGpuId) @@ -232,6 +229,11 @@ namespace Ryujinx.Graphics.Vulkan SType = StructureType.PhysicalDevicePrimitiveTopologyListRestartFeaturesExt, }; + PhysicalDeviceExtendedDynamicState2FeaturesEXT featuresExtendedDynamicState2 = new() + { + SType = StructureType.PhysicalDeviceExtendedDynamicState2FeaturesExt, + }; + PhysicalDeviceRobustness2FeaturesEXT featuresRobustness2 = new() { SType = StructureType.PhysicalDeviceRobustness2FeaturesExt, @@ -262,6 +264,12 @@ namespace Ryujinx.Graphics.Vulkan features2.PNext = &featuresPrimitiveTopologyListRestart; } + if (_physicalDevice.IsDeviceExtensionPresent(ExtExtendedDynamicState2.ExtensionName)) + { + featuresExtendedDynamicState2.PNext = features2.PNext; + features2.PNext = &featuresExtendedDynamicState2; + } + if (_physicalDevice.IsDeviceExtensionPresent("VK_EXT_robustness2")) { featuresRobustness2.PNext = features2.PNext; @@ -395,7 +403,7 @@ namespace Ryujinx.Graphics.Vulkan features2.Features.ShaderStorageImageMultisample, _physicalDevice.IsDeviceExtensionPresent(ExtConditionalRendering.ExtensionName), _physicalDevice.IsDeviceExtensionPresent(ExtExtendedDynamicState.ExtensionName), - _physicalDevice.IsDeviceExtensionPresent(ExtExtendedDynamicState2.ExtensionName), + featuresExtendedDynamicState2, features2.Features.MultiViewport && !(IsMoltenVk && Vendor == Vendor.Amd), // Workaround for AMD on MoltenVK issue featuresRobustness2.NullDescriptor || IsMoltenVk, supportsPushDescriptors && !IsMoltenVk, @@ -460,9 +468,7 @@ namespace Ryujinx.Graphics.Vulkan var queueFamilyIndex = VulkanInitialization.FindSuitableQueueFamily(Api, _physicalDevice, _surface, out uint maxQueueCount); - _device = VulkanInitialization.CreateDevice(Api, _physicalDevice, queueFamilyIndex, maxQueueCount, out PhysicalDeviceExtendedDynamicState2FeaturesEXT extendedDynamicState2Features); - - ExtendedDynamicState2Features = extendedDynamicState2Features; + _device = VulkanInitialization.CreateDevice(Api, _physicalDevice, queueFamilyIndex, maxQueueCount); if (Api.TryGetDeviceExtension(_instance.Instance, _device, out KhrSwapchain swapchainApi)) {