9

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?

debonair
  • 2,505
  • 4
  • 33
  • 73
  • 1
    Guess it's time to start upvoting Vulkan questions. – Krythic Sep 16 '16 at 02:04
  • 1
    Well, one has to be primary CB to be used with `vkQueueSubmit()` – krOoze Sep 16 '16 at 10:14
  • 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 Sep 16 '16 at 13:56
  • @NicolBolas I updated the question. – debonair Sep 16 '16 at 16:51
  • 1
    @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 Sep 16 '16 at 18:26
  • Have you tried timing each approach? – Pablo H Jul 02 '18 at 21:08

1 Answers1

1
  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.

ratchet freak
  • 47,288
  • 5
  • 68
  • 106