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

Spec doesn't specify what dynamic states apply to which state subsets when using pipeline libraries #2504

Open
w-pearson opened this issue Mar 1, 2025 · 2 comments

Comments

@w-pearson
Copy link

For context, I've been working on an analysis tool that needs to link graphics pipeline libraries into a complete graphics pipeline.

Currently, the only information on how dynamic states interact with pipeline libraries is the following (from #1902 I think):

Dynamic state values set via pDynamicState must be ignored if the state they correspond to is not otherwise statically set by one of the state subsets used to create the pipeline. Additionally, setting dynamic state values must not modify whether state in a linked library is static or dynamic; this is set and unchangeable when the library is created. For example, if a pipeline only included pre-rasterization shader state, then any dynamic state value corresponding to depth or stencil testing has no effect. Any linked library that has dynamic state enabled that same dynamic state must also be enabled in all the other linked libraries to which that dynamic state applies.

As far as I can tell, this requires cross-referencing all of the VkDynamicState descriptions with the graphics pipeline subsets, which seems fairly error-prone.

There doesn't seem to be any validation unit for the last sentence (and it also seems to have a grammatical error).

This does seem to beimplemented in XGL here and here (The comment mentions VK_DYNAMIC_STATE_DEPTH_CLAMP_CONTROL_EXT but that's presumably a typo for VK_DYNAMIC_STATE_DEPTH_CLAMP_RANGE_EXT), and in VK-GL-CTS and Vulkan-ValidationLayers, though implementations differ slightly. Here are the disagreements I spotted (which hopefully is exhaustive, but there's a chance I missed or misread something):

  • VK_DYNAMIC_STATE_DISCARD_RECTANGLE_ENABLE_EXT, VK_DYNAMIC_STATE_DISCARD_RECTANGLE_MODE_EXT, and VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_ENABLE_NV aren't listed in any state subset in VK-GL-CTS (though they are used elsewhere); they are all listed as pre-rasterization shader state in Vulkan-ValidationLayers. XGL doesn't implement any of these.
  • VK_DYNAMIC_STATE_ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT is only listed as a fragment output state in VK-GL-CTS, while it's listed as pre-rasterization shader state, fragment shader state, and fragment output state in Vulkan-ValidationLayers. XGL doesn't implement this.
  • VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR is listed as pre-rasterization shader state, fragment shader state, and fragment output state in VK-GL-CTS, while Vulkan-ValidationLayers considers it to only be pre-rasterization shader state and fragment shader state and XGL considers it to only be fragment shader state and fragment output state.
  • VK_DYNAMIC_STATE_REPRESENTATIVE_FRAGMENT_TEST_ENABLE_NV is listed as both fragment shader state and fragment output state by VK-GL-CTS, while Vulkan-ValidationLayers only considers it to be fragment shader state.

As far as I can tell, XGL, VK-GL-CTS, and Vulkan-ValidationLayers agree about all other states (ignoring the ones not listed anywhere in XGL, e.g. NV extensions), including that these multisample states belong to both the fragment shader state and fragment output state.

@spencer-lunarg
Copy link

So Validation Layers had to handle this https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/fa2b6971a022714405d65e6c2157694b9444696d/layers/state_tracker/pipeline_state.cpp#L220

Basically you can have all the dynamic state set at pipeline creation time and layers/drivers should ignore if they are not used. Some dynamic state like VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT will be used for multiple library types

The spec list out which structs map to which library
https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#pipelines-graphics-subsets-vertex-input

I even created this to help cross reference (and the goal is to make it either as a JSON or part of vk.xml to be machine readable)
https://docs.vulkan.org/guide/latest/dynamic_state_map.html

@w-pearson
Copy link
Author

Thanks, https://docs.vulkan.org/guide/latest/dynamic_state_map.html is the kind of reference I was looking for. (I wish I had seen that sooner). Looks like that matches Vulkan-ValidationLayers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants