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 OnceCommandBuffer wrapper so it is part of device wrapper #461

Closed IAmNotHanni closed 2 years ago

IAmNotHanni commented 2 years ago

Is your feature request related to a problem?

We are using one command pool per OnceCommandBuffer. That's very bad.

Description

Currently we have a OnceCommandBuffer wrapper which has its own CommandPool which is bad. I refactored part of it so it can be used in a lambda style in the hanni/gltf_support branch, so it would currently be used like this:

wrapper::OnceCommandBuffer copy_command(m_device, m_device.graphics_queue(), m_device.graphics_queue_family_index(),
                                        [&](const wrapper::CommandBuffer &cmd_buf) {
                                            change_image_layout(cmd_buf, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
                                            copy_from_buffer(cmd_buf, texture_staging_buffer.buffer(),
                                                             m_image_ci.extent.width, m_image_ci.extent.height);
                                            change_image_layout(cmd_buf, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
                                        });

Wouldn't it make more sense to integrate the OnceCommandBuffer wrapper entirely into the device wrapper?

m_device->once_command([&](const wrapper::CommandBuffer &cmd_buf){ /* ... */});

Operating System

all systems

IAmNotHanni commented 2 years ago

This issue will be closed, because it is part of this bigger issue here: https://github.com/inexorgame/vulkan-renderer/issues/465.