Zebrafish
Zebrafish

Reputation: 14352

Why is there a VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT and do I have to use it?

According to the docs at Khronos.org the PIPELINE_STAGE_VERTEX_INPUT_BIT is:

VK_PIPELINE_STAGE_VERTEX_INPUT_BIT specifies the stage of the pipeline where vertex and index buffers are consumed

So that flag covers both vertex input and index input. However I've seen a:

VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT

in my Vulkan header. Have they now been separated into two separate flags? And do I have to use them to flush of invalidate caches with respect to indices?

Upvotes: 1

Views: 136

Answers (1)

Jherico
Jherico

Reputation: 29240

VK_PIPELINE_STAGE_VERTEX_INPUT_BIT is part of VkPipelineStageFlagBits. It covers both vertex and index buffers.

VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT is part of VkPipelineStageFlagBits2. It covers only index buffers.

Have they now been separated into two separate flags?

enter image description here

There are two flags in the new structure, one for index and one for vertex. They are, respectively

  • VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT for vertex buffers only
  • VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT for index buffers only

However, there is also a VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT definition which is their bitwise or, so it acts just like VK_PIPELINE_STAGE_VERTEX_INPUT_BIT in the older versions of the barrier functions.

do I have to use them to flush of invalidate caches with respect to indices?

It depends on what function you're calling. If you're calling vkCmdPipelineBarrier, you don't need to think about any of this, because it still uses VkPipelineStageFlagBits.

If you're calling vkCmdPipelineBarrier2 then you need to use the newer VkPipelineStageFlagBits2. But if you don't care about the distinction between the index and vertex buffers in the pipeline, then you could just swap out VK_PIPELINE_STAGE_VERTEX_INPUT_BIT with VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT directly and everything should work the same as before, because VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT intentionally covers both vertex and index buffers.

Upvotes: 3

Related Questions