Command buffer bit

Hi every one,

I’m not sure that this is the right place but,
I want to know what bit to choose when I begin a command buffer bit :

VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT
VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT

I’m searching the minimal configuration to have a triangle animation at the screen.

So I created vulkan instance, device, queue and a primary buffer.
I’m a little bit lost, thanks by advance.

Hi,

you should use VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT if you only want to submit the command buffer once. For example, every command buffer you record once per frame, submit, and then reset its command pool after waiting for the fence, should have this flag. On the other hand, command buffers you record once but submit multiple times, for example post processing, should not have this flag.

VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT is only useful for secondary command buffers, it is ignored for primary ones. For secondary command buffers this specifies execution inside a renderpass and you need to specify renderpass inheritance if you specify this flag. Its usage is pretty specific, so generally you do not need this flag.

VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT says that you can submit the command buffer multiple times without waiting for the previous submit to finish via a fence. Normally you should at least double-buffer your multi-use command buffers so that you would not need this flag.

If you just want to render a static triangle on your screen, you can create one command pool and two command buffers without any flags at app-startup, record the rendering, and then ping-pong: fence-wait, submit.
Or, you could have two command pools with one command buffer each with flag VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, and then ping pong: fence-wait, reset pool, record, submit.

Regards

Thanks for the precise reply, good to know that I don’t need any render pass buffer to submit
to have something on screen (if I understand).

For the ping pong fence wait submit, it looks like I have to record the whole buffer for each frame…
Is there no way to change only a part of it without charging processor at each frame?

By part of it I mean some coordinate or color, but not rewrite all the scene each time.

Ho, I had to say, I’m a very very newbie, I know that my questions may be irrelevant,
do not hesitate to correct me on the way I think vulkan, thanks.

And also, is there any way to get fence notified by a file descriptor.

I mean, without thread or fork.

If it isn’t possible, I’ll fork, no probs for me.

Hi,

you do not need to have a separate command buffer for a render pass, but you need a render pass if you want to use any rasterization. So if you have any Draw command, you need a render pass. If you are new to Vulkan, try to get a solid color window via vkCmdClearColorImage first, so you can see if your command buffers and fences etc work, because you do not need render passes, pipelines or descriptor sets for that.

Vulkan is very flexible. A lot of the data is actually in buffers, not in command buffers. For example, the world-to-camera matrix would be in a buffer, so you can actually reuse the same command buffer and just change the matrix data in the buffer to move the camera. Note: you should double buffer any data you write from the CPU, just like command buffers. This also applies to non-static descriptor sets. Basically anything that you touch during rendering on the CPU needs to be double-buffered.
You only need to change the command buffer if you need to execute different commands on the GPU. And even then there is stuff like conditional rendering or indirect rendering (or NVIDIA only DGC) to reduce the need to rewrite your command buffers.
Last but def. not least, you can submit multiple command buffers per frame (with one or more submits) and you do NOT need to submit them in the order you generated them. You can mix and match freely.
You can think of command buffers a bit like scripts you write on a remote server. In old interfaces like OpenGL or DirectX11, you only have a console that executes every command the moment you press enter. In Vulkan, you write script files (recording a command buffer) and can then execute scripts on the console (submitting command buffers).

Not sure what you mean by file descriptor in this context. You can either block on a fence until it gets signaled, or query its status without blocking. Since Vulkan is OS-agnostic, you cannot use Vulkan objects with system calls, you need to use the specific Vulkan functions.

Regards