Is it possible to reuse command buffers and render command encoders?

So far I read chapter 1 to 5 and almost all the draw calls are repeating the same commands over and over. So I modified the code for Chapter 5 so that the command buffer only gets to be created once and encoder only encodes once. But the draw call only successfully ran once and, for the second time, the program said:
"failed assertion `Scheduled handler provided after commit call'".

It seems that I do need to create and encode command buffers every frame. But why is that the case? Since encoding render commands is so repetitive, why does not the API allow us to reuse command buffers to save time?

A command buffer holds the instructions for the GPU to render one frame. It isn’t reusable.

Because you don’t have control over when the GPU processes the command buffer, you can’t really assume control of it over multiple frames.

I just found this new article from Apple - they have pretty pictures:

One of the pictures shows a command queue with several command buffers all queued up waiting for the GPU to operate on them.

And welcome to the forum :smiley: !