KhronosGroup / Vulkan-Docs

The Vulkan API Specification and related tools
Other
2.77k stars 465 forks source link

Clarify behaviour of some dynamic states when corresponding pipeline create info is missing #2344

Closed Rua closed 5 months ago

Rua commented 5 months ago

The documentation of VkPipelineRasterizationConservativeStateCreateInfoEXT states that when this struct is not present in the pNext chain of VkPipelineRasterizationStateCreateInfo, conservative rasterization is considered disabled. However, there is also VK_DYNAMIC_STATE_CONSERVATIVE_RASTERIZATION_MODE_EXT, which allows dynamically enabling and disabling conservative rasterization. In this combination, it's possible to dynamically enable conservative rasterization, yet without specifying the remaining fixed state via the struct (the flags and extraPrimitiveOverestimationSize fields in this case).

I can think of two possible ways this could be clarified:

  1. This combination is disallowed; it's not valid to enable a dynamic state if the corresponding CreateInfo struct is missing.
  2. Every member of the CreateInfo struct is considered to have a default value, which is used when the struct hasn't been provided.

The same kind of issue may exist with other combinations of a pipeline CreateInfo struct and a dynamic state. One I have already spotted is VkPipelineRasterizationLineStateCreateInfoKHR being missing with VK_DYNAMIC_STATE_LINE_STIPPLE_ENABLE_EXT enabled; this leaves the lineStippleFactor and lineStipplePattern fields unspecified when dynamically enabling via vkCmdSetLineStippleEnableEXT.

EDIT: Another case is VkPipelineDiscardRectangleStateCreateInfoEXT and VK_DYNAMIC_STATE_DISCARD_RECTANGLE_ENABLE_EXT.

pdaniell-nv commented 5 months ago

FWIW, NVIDIA's implementation assumes extraPrimitiveOverestimationSize=0.0 if the struct is missing and VK_DYNAMIC_STATE_CONSERVATIVE_RASTERIZATION_MODE_EXT is enabled but __VK_DYNAMIC_STATE_EXTRA_PRIMITIVE_OVERESTIMATION_SIZE_EXT is not enabled.

HansKristian-Work commented 5 months ago

I think this becomes 1.

If DYNAMIC_STATE_CONSERVATIVE_RASTERIZATION_MODE is used, extraPrimitiveOverestimationSize may be read, so it cannot be undefined (default). So pNext must be provided in that case.

I'll try something.

Rua commented 5 months ago

I suppose there's also a third possibility:

  1. The dynamic state is ignored.
oddhack commented 5 months ago

This should be fixed in the 1.3.283 spec update.

Rua commented 5 months ago

It's fixed for VkPipelineRasterizationConservativeStateCreateInfoEXT, but what about the others mentioned? It's a more general problem.