8
votes

I have multiple meshes with different textures/ pipeline constructs such as depth test/ blending functions to render with vulkan. What are the best practices for rendering them in terms of performance.

  1. One option is create n command buffers with n threads for n meshes with nothing is shared between them, layout, descriptors, samplers, or anything. if i go with this should i be using n secondary command buffers and 1 primary or all of them would be secondary ?

  2. Use the same command buffer to render n meshes, create n pipelines, n buffers for uniforms and vertex data. start recording command buffer and then in the loop, call vkcmdDraw for n meshes with different pipeline, buffers. I am able to render with this approach. but how do i use multithreading to make it faster?

Or any other approach?

1
Guess it's time to start upvoting Vulkan questions. - Krythic
Well, one has to be primary CB to be used with vkQueueSubmit() - krOoze
What kind of "properties" are we talking about? There is a distinction between pipeline constructs (depth tests) and descriptor data (textures). The former cannot be shared between two objects, while the latter could be. Also: "if we are going to share anything between rendering of 2 meshes, then we need synchronization." Why would you need synchronization to share anything? - Nicol Bolas
@NicolBolas I updated the question. - debonair
@debonair: You cannot modify pipeline state. Once a pipeline object is created, it is immutable. So again, it's not clear where any such synchronization would be necessary or even possible. Perhaps some pseudo-code to explain the approaches you're trying to use would be helpful. - Nicol Bolas

1 Answers

1
votes
  1. if we are going to share anything between rendering of 2 meshes, then we need synchronization.

You don't; if everything you share is read-only then you don't need synchronization. The only time you need sync between meshes is if one writes to memory and another mesh reads from it. The state of the pipeline and the color attachments are synchronized by the implementation so you don't have to worry about that.