0

I'm currently working on a graphics engine and I wish to update the pipeline state at runtime. Creating a new pipeline for each single resource update (ie: enabling depth clamp, enabling color blend) at runtime and then re-binding everything to the command buffer takes up a considerable amount of performance.

So what I planned on doing was, to create a single pipeline and store all the attributes needed for its creation (ie: Rasterizer state, Multisampling state, Color blend state, etc..) and update those individual structs at runtime. After all we are passing in the address of the structs, not by value.

This brings me to my question, does the updates to a struct which is passed on in the pipeline creation, reflect on the actual draw call at runtime, without the need for recreating the pipeline again?

Thank you!

D-RAJ
  • 3,263
  • 2
  • 6
  • 24
  • Does this answer your question? [When can I free resources and structures passed to a vulkan vkCreateXXX function?](https://stackoverflow.com/questions/51391163/when-can-i-free-resources-and-structures-passed-to-a-vulkan-vkcreatexxx-function) – krOoze Feb 27 '21 at 16:10

2 Answers2

2

No, this does not work that way. The structures that specify pipeline creation state information (like blending, multi sampling, vertex input state, etc.) are consumed at pipeline creation time and baked into the pipeline. So changing these after the pipeline has been created, won't update the pipeline at all.

This means that you have to rebuild the pipeline and also rebuild all command buffers using this.

One exception though are the dynamic states (see spec) that allow you to change certain pipeline state related values at runtime during command buffer creation.

Sascha Willems
  • 5,280
  • 1
  • 14
  • 21
  • Note that this is true of *all* Vulkan objects; changing the `CreateInfo` structures after creation time affects nothing about the object itself. – Nicol Bolas Feb 27 '21 at 16:09
2

Conceptually, you are not "passing an address", you are lending a value by reference. In virtually all Vulkan commands the ownership returns to the caller as soon as the command returns. After that you can do whatever you want with it, or delete\deallocate it, and it has no effect on Vulkan.

krOoze
  • 12,301
  • 1
  • 20
  • 34