KhronosGroup / Vulkan-ValidationLayers

Vulkan Validation Layers (VVL)
https://vulkan.lunarg.com/doc/sdk/latest/linux/khronos_validation_layer.html
Other
751 stars 402 forks source link

Wrong error detection on vkCmdSetPrimitiveTopologyEXT #8597

Open asuessenbach opened 6 days ago

asuessenbach commented 6 days ago

Environment:

Describe the Issue

In the Vulkan-Samples repository, there's a sample extended_dynamic_state2, containing this code sequence:

        vkCmdBindPipeline(draw_cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.baseline);
        vkCmdSetPrimitiveTopologyEXT(draw_cmd_buffer, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);

... draw some triangles here

        vkCmdSetPrimitiveTopologyEXT(draw_cmd_buffer, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP);

... draw some triangle strips here

        vkCmdBindPipeline(draw_cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.tesselation);
        vkCmdSetPrimitiveTopologyEXT(draw_cmd_buffer, VK_PRIMITIVE_TOPOLOGY_PATCH_LIST);

... draw some patches here

The pipeline.tesselation, that is bound here has VK_PRIMITIVE_TOPOLOGY_PATCH_LIST as its input_assembly_state.topology. But on drawing the patches, I get this error: Validation Error: [ VUID-vkCmdDrawIndexed-dynamicPrimitiveTopologyUnrestricted-07500 ] Object 0: handle = 0x1bf164c2290, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0xa182620000000079, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0x66b035ea | vkCmdDrawIndexed(): the last primitive topology VK_PRIMITIVE_TOPOLOGY_PATCH_LIST state set by vkCmdSetPrimitiveTopology is not compatible with the pipeline topology VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP. The Vulkan spec states: If the bound graphics pipeline state was created with the VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY dynamic state enabled and the dynamicPrimitiveTopologyUnrestricted is VK_FALSE, then the primitiveTopology parameter of vkCmdSetPrimitiveTopology must be of the same topology class as the pipeline VkPipelineInputAssemblyStateCreateInfo::topology state (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-dynamicPrimitiveTopologyUnrestricted-07500)

Expected behavior

No error message.

Additional context

In CoreChecks::ValidateGraphicsDynamicStateValue, the pipeline.create_info.pInputAssemblyState->topology is VK_PRIMITIVE_TOPOLOGY_PATCH_LIST. But pipeline.topology_at_rasterizer, which is used to check here, is VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP. It seems, this value is not adjusted on vkCmdBindPipeline.

spencer-lunarg commented 6 days ago

I am 95% sure this is fixed in https://github.com/KhronosGroup/Vulkan-ValidationLayers/pull/8394 and hopefully we can confirm when the next SDK is released in a few days