Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practices for rendering multiple meshes with vulkan

Tags:

vulkan

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?

like image 857
debonair Avatar asked Sep 16 '16 01:09

debonair


1 Answers

  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.

like image 74
ratchet freak Avatar answered Dec 15 '22 01:12

ratchet freak