When we draw we draw in RenderPass.
But if we want draw from two thread how we need do ?
I mean RenderPass from thread one cleared\spoiled render from second thread. And we see only trees or only text.
And first thread have own RenderPass and second thread have own RenderPass.
For example first thread draw trees and second thread draw dynamic text (print FPS)
How to do it correctly and see trees and text on screen ?
Define “draw from two thread”? Are you trying to submit to the same queue from different threads, which requires synchronization? Are you talking about submitting work to different queues that write to the same image? Or are you talking about building command buffers from different threads, which will then be submitted to a queue as part of a batch, that write to the same image?
If you’re talking about the latter, this is pretty obvious stuff. A render pass instance cannot persist between command buffers. However, you can execute secondary command buffers within a primary command buffer and its render pass instance. The secondary CBs inherit the primary CB’s render pass instance. That’s generally how you would build two command buffers in different threads which render to the same stuff.
This requires each thread to have its own CB allocator (aka: a command pool).
Are you talking about submitting work to different queues that write to the same image?
YES ! Bingo !
Write to one SwapChain.
O ! And interesting if i create two queues in one thread. And submit queue1 then queue2 (they must render in one SwapChain), do i see render two queues on screen ?
Or only render from last queue ?
(Almost) all objects in Vulkan have to be (externally) synchronized.
That being said, there’s not much to parallelize on submision time in your example – it’s a sequential job. You want to draw your trees and THEN draw your FPS. (Or in reverse order for other types of GUI or HUD – to save on discarded pixels.)
And submit [to] queue1 then [to] queue2 (they must render in one SwapChain [Image]), do i see render two queues on screen ? Or only render from last queue ?
It is an undefied behavior. Again, needs to be synchronized. Separate queues are completely independent form each other (except user synchronization). And submission to a queue is (on most implementations) non-blocking.