inexorgame / vulkan-renderer

A new 3D game engine for Linux and Windows using C++20 and Vulkan API 1.3, in very early but ongoing development
https://inexor.org
MIT License
777 stars 34 forks source link

Refactor command pool and command buffer management #465

Closed IAmNotHanni closed 1 year ago

IAmNotHanni commented 2 years ago

Is your feature request related to a problem?

There is a lot wrong with the command pool and command buffer code I wrote.

Description

First of all, according to NVidia Vulkan tips, we should aim for only one command pool per thread! We have several currently. Even worse, we have one per OnceCommandBuffer. That's not good at all. Furthermore, we should reuse command buffers. We should get rid of the OnceCommandBuffer wrapper and introduce a pool of command buffers from which we can request one.

Affected Code

The entire code base.

Operating System

All operating systems.

IAmNotHanni commented 2 years ago

We should also remove wrapper::StagingBuffer entirely and implement a method upload_data_to_gpu_buffer into wrapper::Device. This also solves the question of how to manage transfer queues in the device wrapper. We simply keep another command pool which is bound to the queue family index of the transfer queue.

IAmNotHanni commented 2 years ago

I moved the TODO list to the pull request.