private void GrowBuffers(VkCommandBufferLevel level, uint numBuffers) { NativeList <VkCommandBuffer> buffers = level == VkCommandBufferLevel.Primary ? primaryCmdBuffers : secondaryCmdBuffers; uint oldBuffers = buffers.Count; if (numBuffers <= oldBuffers) { return; } // Create one command buffer for each swap chain image and reuse for rendering buffers.Resize(numBuffers); buffers.Count = numBuffers; if (buffers.Count > MAX_BUFFERS) { throw new InvalidOperationException("Hit max buffer amount. Please check if buffers are not being reused correctly."); } VkCommandBufferAllocateInfo cmdBufAllocateInfo = Initializers.CommandBufferAllocateInfo(vkCmdPool, level, buffers.Count - oldBuffers); Util.CheckResult(vkAllocateCommandBuffers(device.device, ref cmdBufAllocateInfo, (VkCommandBuffer *)buffers.GetAddress(oldBuffers))); var queue = level == VkCommandBufferLevel.Primary ? freePrimaryBuffers : freeSecondaryBuffers; for (uint i = oldBuffers; i < buffers.Count; i++) { queue.Enqueue(buffers[i]); } }