Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU: Add support for extended pipeline dynamic states where available #6831

Closed

Conversation

sunshineinabox
Copy link
Contributor

@sunshineinabox sunshineinabox commented May 18, 2024

This PR adds more pipeline dynamic state usage. In theory this should reduce the number of pipelines created and should not have any consequences on desktop hardware.

Standard:

  • VK_DYNAMIC_STATE_LINE_WIDTH

VK_EXT_extended_dynamic_state:

  • All other than VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT

VK_EXT_extended_dynamic_state2:

  • VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT
  • VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT
  • VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT

The following two are not supported on all devices that support VK_EXT_extended_dynamic_state2

  • VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT
  • VK_DYNAMIC_STATE_LOGIC_OP_EXT

VK_EXT_extended_dynamic_state3:
(exposure of this extension does not guarantee support for all features)

  • VK_DYNAMIC_STATE_DEPTH_CLAMP_ENABLE_EXT
  • VK_DYNAMIC_STATE_ALPHA_TO_COVERAGE_ENABLE_EXT
  • VK_DYNAMIC_STATE_ALPHA_TO_ONE_ENABLE_EXT
  • VK_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT
  • VK_DYNAMIC_STATE_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE_EXT

Notes:

  • The state VertexInputBindingStrideExt is dependent on the availability of Metal 3.1.
  • widelines feature is not available on MacOS without using a private Metal API and newer MoltenVK.
  • VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY requires that topology only be set to one that is the same class as the currently bound pipeline so is not currently included.
  • Not tested thoroughly as I am still actively working on this and ensuring everything is spec compliant.

…cStateCreateInfo as the command to set them is never called.

Do not pass pointer to viewport and scissor as those dynamic states should be supported on all devices.

Same as above for DepthBias values.
…ertex Input Binding Stride dynamic state from enabling with MoltenVK.
Flags are not set for deriving pipelines so remove unnecessary basePipelineIndex value.
Topology Dynamic State is not working as intended. Need to add check to set correct Topology class. Circle back to this later. For now revert it.

Some minor fixes.
@github-actions github-actions bot added gpu Related to Ryujinx.Graphics infra Related to the project infrastructure graphics-backend:vulkan Graphical bugs when using the Vulkan API labels May 18, 2024
VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442(ERROR / SPEC): msgNum: 1313692360 - Validation Error: [ VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442 ] | MessageID = 0x4e4d5ac8 | vkCreateGraphicsPipelines(): pCreateInfos[0].pDynamicState has VK_DYNAMIC_STATE_VIEWPORT at pDynamicStates[0] and pDynamicStates[28]. The Vulkan spec states: Each element of pDynamicStates must be unique (https://vulkan.lunarg.com/doc/view/1.3.283.0/windows/1.3-extensions/vkspec.html#VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442)
    Objects: 0
VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132(ERROR / SPEC): msgNum: -206448348 - Validation Error: [ VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132 ] | MessageID = 0xf3b1d924 | vkCreateGraphicsPipelines(): pCreateInfos[0].pDynamicState pDynamicStates[15] is VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT and pDynamicStates[28] is VK_DYNAMIC_STATE_VIEWPORT. The Vulkan spec states: If the pipeline requires pre-rasterization shader state, and VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT is included in the pDynamicStates array then VK_DYNAMIC_STATE_VIEWPORT must not be present (https://vulkan.lunarg.com/doc/view/1.3.283.0/windows/1.3-extensions/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04132)
    Objects: 0

VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133(ERROR / SPEC): msgNum: -858144982 - Validation Error: [ VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133 ] | MessageID = 0xccd9bf2a | vkCreateGraphicsPipelines(): pCreateInfos[0].pDynamicState pDynamicStates[16] is VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT and pDynamicStates[1] is VK_DYNAMIC_STATE_SCISSOR. The Vulkan spec states: If the pipeline requires pre-rasterization shader state, and VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT is included in the pDynamicStates array then VK_DYNAMIC_STATE_SCISSOR must not be present (https://vulkan.lunarg.com/doc/view/1.3.283.0/windows/1.3-extensions/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04133)
    Objects: 0
VUID-vkCmdDraw-logicOp-04878(ERROR / SPEC): msgNum: 282117419 - Validation Error: [ VUID-vkCmdDraw-logicOp-04878 ] Object 0: handle = 0x2db247c7370, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x81dc7e0000000305, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0x10d0c52b | vkCmdDraw():  VK_DYNAMIC_STATE_LOGIC_OP_EXT state not set for this command buffer. The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_LOGIC_OP_EXT dynamic state enabled then vkCmdSetLogicOpEXT must have been called in the current command buffer prior to this drawing command and the logicOp must be a valid VkLogicOp value (https://vulkan.lunarg.com/doc/view/1.3.283.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDraw-logicOp-04878)
    Objects: 2
        [0] 0x2db247c7370, type: 6, name: NULL
        [1] 0x81dc7e0000000305, type: 19, name: NULL
VUID-vkCmdSetPatchControlPointsEXT-None-09422(ERROR / SPEC): msgNum: -1559328192 - Validation Error: [ VUID-vkCmdSetPatchControlPointsEXT-None-09422 ] Object 0: handle = 0x25f0eb40170, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0xa30e8a40 | vkCmdSetPatchControlPointsEXT():   extendedDynamicState2PatchControlPoints or shaderObject feature is not enabled. The Vulkan spec states: At least one of the following must be true: The extendedDynamicState2PatchControlPoints feature is enabled The shaderObject feature is enabled (https://vulkan.lunarg.com/doc/view/1.3.283.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdSetPatchControlPointsEXT-None-09422)
    Objects: 1
        [0] 0x25f0eb40170, type: 6, name: NULL
@gdkchan
Copy link
Member

gdkchan commented May 23, 2024

Just FYI, #6852 affects those changes (the logic op workaround needs to be applied when vkCmdSetLogicOp is called too).

@sunshineinabox
Copy link
Contributor Author

sunshineinabox commented May 23, 2024

Thank you for the heads up!

@sunshineinabox
Copy link
Contributor Author

I will split this into two PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gpu Related to Ryujinx.Graphics graphics-backend:vulkan Graphical bugs when using the Vulkan API infra Related to the project infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants