Implementing Frames in Flight with gfx-hal

Hey all!

I'm currently learning gfx-hal and graphics programming in general and followed this guide rendering my first triangle (CODE). Now I tried to implement Frames in Flight explained in this Vulkan guide.

I did that by using Vectors of Semaphores, Fences and Command_Buffers instead of single ones like in the original Code (All have some constant size, for example just 2).
I found one major problem though, the original code resets the whole command pool every draw cycle (line 532), which resets ALL command buffers. As I'm using multiple buffers now I can't do that. Instead I tried to reset the current command_buffer. While the program indeed seems to work, I get memory leaks every draw cycle that way, which I don't get when using command_pool.reset().

Is there some other resource I need to manually clean up, which gets cleaned up by resetting the command_pool, but not the command_buffers?

Days of looking at this, then I finally decide to ask on a forum. 60 minutes later I found the answer myself, hooray ^^

When creating a command_pool you have to enable resetting individual command buffers with the CommandPoolCreateFlags::RESET_INDIVIDUAL flag. Hope this helps someone else at some point!

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.