From e71a1e73583b359cf14483e3e0b03b24e6236974 Mon Sep 17 00:00:00 2001 From: Johannes Schneider Date: Thu, 11 Apr 2024 19:59:19 +0200 Subject: [PATCH] [*] WIP --- .../render-graph/graphics_pass.hpp | 6 +++--- .../render-graph/graphics_pass_builder.hpp | 8 ++++---- .../render-graph/render_graph.hpp | 4 ++-- .../wrapper/commands/command_buffer.hpp | 18 ++++++++++-------- .../wrapper/commands/command_pool.hpp | 16 +++++++++------- .../inexor/vulkan-renderer/wrapper/device.hpp | 9 +++++---- .../wrapper/pipelines/pipeline.hpp | 8 ++++++-- .../vulkan-renderer/wrapper/swapchain.hpp | 10 +++++++--- .../wrapper/synchronization/fence.hpp | 8 +++++--- .../wrapper/synchronization/semaphore.hpp | 6 ++++-- src/vulkan-renderer/application.cpp | 2 +- src/vulkan-renderer/imgui.cpp | 2 +- .../render-graph/graphics_pass.cpp | 3 ++- .../render-graph/render_graph.cpp | 9 +++++---- .../wrapper/commands/command_buffer.cpp | 8 ++++---- .../wrapper/commands/command_pool.cpp | 10 +++++----- src/vulkan-renderer/wrapper/device.cpp | 10 +++++----- src/vulkan-renderer/wrapper/swapchain.cpp | 3 +-- .../wrapper/synchronization/fence.cpp | 4 ++-- .../wrapper/synchronization/semaphore.cpp | 6 +++--- 20 files changed, 84 insertions(+), 66 deletions(-) diff --git a/include/inexor/vulkan-renderer/render-graph/graphics_pass.hpp b/include/inexor/vulkan-renderer/render-graph/graphics_pass.hpp index 14024e71b..665872ef4 100644 --- a/include/inexor/vulkan-renderer/render-graph/graphics_pass.hpp +++ b/include/inexor/vulkan-renderer/render-graph/graphics_pass.hpp @@ -12,7 +12,7 @@ #include // Forward declaration -namespace inexor::vulkan_renderer::wrapper { +namespace inexor::vulkan_renderer::wrapper::commands { class CommandBuffer; } @@ -38,7 +38,7 @@ class GraphicsPass { /// An optional clear value std::optional m_clear_values{std::nullopt}; /// Add members which describe data related to graphics passes here - std::function m_on_record{[](auto &) {}}; + std::function m_on_record{[](auto &) {}}; /// The buffers the graphics passes reads from /// If the buffer's ``BufferType`` is ``UNIFORM_BUFFER``, a value for the shader stage flag must be specified, @@ -76,7 +76,7 @@ class GraphicsPass { /// which case ``VK_ATTACHMENT_LOAD_OP_LOAD`` is used) /// @exception std::runtime_error More than one index buffer is specified GraphicsPass(std::string name, BufferReads buffer_reads, TextureReads texture_reads, TextureWrites texture_writes, - std::function on_record, + std::function on_record, std::optional clear_values); GraphicsPass(const GraphicsPass &) = delete; diff --git a/include/inexor/vulkan-renderer/render-graph/graphics_pass_builder.hpp b/include/inexor/vulkan-renderer/render-graph/graphics_pass_builder.hpp index d58ebe846..5c6f6efd3 100644 --- a/include/inexor/vulkan-renderer/render-graph/graphics_pass_builder.hpp +++ b/include/inexor/vulkan-renderer/render-graph/graphics_pass_builder.hpp @@ -9,10 +9,10 @@ #include #include +namespace inexor::vulkan_renderer::wrapper::commands { // Forward declaration -namespace inexor::vulkan_renderer::wrapper { class CommandBuffer; -} +} // namespace inexor::vulkan_renderer::wrapper::commands namespace inexor::vulkan_renderer::render_graph { @@ -23,7 +23,7 @@ class GraphicsPassBuilder { /// Indicates if the screen is cleared at the beginning of this stage std::optional m_clear_value; /// Add members which describe data related to graphics stages here - std::function m_on_record; + std::function m_on_record; /// Depth testing bool m_depth_test; @@ -126,7 +126,7 @@ class GraphicsPassBuilder { /// Set the function which will be called when the stage's command buffer is being recorded /// @param on_record The function which will be called when the stage's command buffer is being recorded /// @return A const reference to the this pointer (allowing method calls to be chained) - [[nodiscard]] auto &set_on_record(std::function on_record) { + [[nodiscard]] auto &set_on_record(std::function on_record) { m_on_record = std::move(on_record); return *this; } diff --git a/include/inexor/vulkan-renderer/render-graph/render_graph.hpp b/include/inexor/vulkan-renderer/render-graph/render_graph.hpp index cc708b635..52daa0b2e 100644 --- a/include/inexor/vulkan-renderer/render-graph/render_graph.hpp +++ b/include/inexor/vulkan-renderer/render-graph/render_graph.hpp @@ -136,13 +136,13 @@ class RenderGraph { /// @param is_first_pass ``true`` if this is the first pass in the graphics pass stack /// @param is_last_pass ``true`` if this is the last pass in the graphics pass stack /// @param img_index The swapchain image index - void record_command_buffer_for_pass(const wrapper::CommandBuffer &cmd_buf, const GraphicsPass &pass, + void record_command_buffer_for_pass(const wrapper::commands::CommandBuffer &cmd_buf, const GraphicsPass &pass, bool is_first_pass, bool is_last_pass, std::uint32_t img_index); /// Record all command buffers required for the passes /// @param cmd_buf The command buffer to record all passes with /// @param img_index The swapchain image index - void record_command_buffers(const wrapper::CommandBuffer &cmd_buf, std::uint32_t img_index); + void record_command_buffers(const wrapper::commands::CommandBuffer &cmd_buf, std::uint32_t img_index); /// Update the vertex-, index-, and uniform-buffers /// @note If a uniform buffer has been updated, an update of the associated descriptor set will be performed diff --git a/include/inexor/vulkan-renderer/wrapper/commands/command_buffer.hpp b/include/inexor/vulkan-renderer/wrapper/commands/command_buffer.hpp index c2595d687..705db9201 100644 --- a/include/inexor/vulkan-renderer/wrapper/commands/command_buffer.hpp +++ b/include/inexor/vulkan-renderer/wrapper/commands/command_buffer.hpp @@ -9,6 +9,11 @@ #include #include +namespace inexor::vulkan_renderer::wrapper { +// Forward declaration +class Device; +} // namespace inexor::vulkan_renderer::wrapper + namespace inexor::vulkan_renderer::wrapper::pipelines { // Forward declaration class GraphicsPipeline; @@ -19,10 +24,7 @@ namespace inexor::vulkan_renderer::render_graph { class Buffer; } // namespace inexor::vulkan_renderer::render_graph -namespace inexor::vulkan_renderer::wrapper { - -// Forward declaration -class Device; +namespace inexor::vulkan_renderer::wrapper::commands { /// RAII wrapper class for VkCommandBuffer /// @todo Make trivially copyable (this class doesn't really "own" the command buffer, more just an OOP wrapper). @@ -30,7 +32,7 @@ class CommandBuffer { VkCommandBuffer m_cmd_buf{VK_NULL_HANDLE}; const Device &m_device; std::string m_name; - std::unique_ptr m_wait_fence; + std::unique_ptr m_wait_fence; // The Device wrapper must be able to call begin_command_buffer and end_command_buffer friend class Device; @@ -89,7 +91,7 @@ class CommandBuffer { /// @param device A const reference to the device wrapper class /// @param cmd_pool The command pool from which the command buffer will be allocated /// @param name The internal debug marker name of the command buffer (must not be empty) - CommandBuffer(const Device &device, VkCommandPool cmd_pool, std::string name); + CommandBuffer(const wrapper::Device &device, VkCommandPool cmd_pool, std::string name); CommandBuffer(const CommandBuffer &) = delete; CommandBuffer(CommandBuffer &&) noexcept; @@ -373,7 +375,7 @@ class CommandBuffer { return m_cmd_buf; } - [[nodiscard]] const Fence &get_wait_fence() const { + [[nodiscard]] const synchronization::Fence &get_wait_fence() const { return *m_wait_fence; } @@ -407,4 +409,4 @@ class CommandBuffer { const CommandBuffer &submit_and_wait() const; // NOLINT }; -} // namespace inexor::vulkan_renderer::wrapper +} // namespace inexor::vulkan_renderer::wrapper::commands diff --git a/include/inexor/vulkan-renderer/wrapper/commands/command_pool.hpp b/include/inexor/vulkan-renderer/wrapper/commands/command_pool.hpp index 44456e9f5..afd69479b 100644 --- a/include/inexor/vulkan-renderer/wrapper/commands/command_pool.hpp +++ b/include/inexor/vulkan-renderer/wrapper/commands/command_pool.hpp @@ -8,24 +8,26 @@ #include namespace inexor::vulkan_renderer::wrapper { - // Forward declaration class Device; +} // namespace inexor::vulkan_renderer::wrapper -/// @brief RAII wrapper class for VkCommandPool. +namespace inexor::vulkan_renderer::wrapper::commands { + +/// RAII wrapper class for VkCommandPool class CommandPool { std::string m_name; - const Device &m_device; + const wrapper::Device &m_device; VkCommandPool m_cmd_pool{VK_NULL_HANDLE}; /// The command buffers which can be requested by the current thread - std::vector> m_cmd_bufs; + std::vector> m_cmd_bufs; public: /// Default constructor /// @param device The device wrapper instance /// @param name The internal debug marker name which will be assigned to this command pool - CommandPool(const Device &device, std::string name); + CommandPool(const wrapper::Device &device, std::string name); CommandPool(const CommandPool &) = delete; CommandPool(CommandPool &&) noexcept; @@ -46,7 +48,7 @@ class CommandPool { /// Request a command buffer /// @param name The internal debug name which will be assigned to this command buffer (must not be empty) /// @return A command buffer handle instance which allows access to the requested command buffer - [[nodiscard]] const CommandBuffer &request_command_buffer(const std::string &name); + [[nodiscard]] const commands::CommandBuffer &request_command_buffer(const std::string &name); }; -} // namespace inexor::vulkan_renderer::wrapper +} // namespace inexor::vulkan_renderer::wrapper::commands diff --git a/include/inexor/vulkan-renderer/wrapper/device.hpp b/include/inexor/vulkan-renderer/wrapper/device.hpp index 980f3b472..dcdb8ea7a 100644 --- a/include/inexor/vulkan-renderer/wrapper/device.hpp +++ b/include/inexor/vulkan-renderer/wrapper/device.hpp @@ -52,7 +52,7 @@ class Device { /// According to NVidia, we should aim for one command pool per thread /// https://developer.nvidia.com/blog/vulkan-dos-donts/ - mutable std::vector> m_cmd_pools; + mutable std::vector> m_cmd_pools; mutable std::mutex m_mutex; /// Set the debug name of a Vulkan object using debug utils extension (VK_EXT_debug_utils) @@ -66,7 +66,7 @@ class Device { /// Get the thread_local command pool /// @note This method will create a command pool for the thread if it doesn't already exist - CommandPool &thread_graphics_pool() const; + commands::CommandPool &thread_graphics_pool() const; public: /// Pick the best physical device automatically @@ -144,7 +144,8 @@ class Device { /// submits it and waits for it. /// @param name The internal debug name of the command buffer (must not be empty) /// @param cmd_lambda The command lambda to execute - void execute(const std::string &name, const std::function &cmd_lambda) const; + void execute(const std::string &name, + const std::function &cmd_lambda) const; /// Find a queue family index that suits a specific criteria /// @param criteria_lambda The lambda to sort out unsuitable queue families @@ -203,7 +204,7 @@ class Device { /// Request a command buffer from the thread_local command pool /// @param name The name which will be assigned to the command buffer /// @return A command buffer from the thread_local command pool - [[nodiscard]] const CommandBuffer &request_command_buffer(const std::string &name); + [[nodiscard]] const commands::CommandBuffer &request_command_buffer(const std::string &name); template void set_debug_name(const VulkanObjectType vk_object, const std::string &name) const { diff --git a/include/inexor/vulkan-renderer/wrapper/pipelines/pipeline.hpp b/include/inexor/vulkan-renderer/wrapper/pipelines/pipeline.hpp index d4ad2bb2a..4947d993a 100644 --- a/include/inexor/vulkan-renderer/wrapper/pipelines/pipeline.hpp +++ b/include/inexor/vulkan-renderer/wrapper/pipelines/pipeline.hpp @@ -7,10 +7,14 @@ namespace inexor::vulkan_renderer::wrapper { // Forward declarations -class CommandBuffer; class Device; } // namespace inexor::vulkan_renderer::wrapper +namespace inexor::vulkan_renderer::wrapper::commands { +// Forward declarations +class CommandBuffer; +} // namespace inexor::vulkan_renderer::wrapper::commands + namespace inexor::vulkan_renderer::render_graph { // Forward declaration class RenderGraph; @@ -22,7 +26,7 @@ namespace inexor::vulkan_renderer::wrapper::pipelines { // TODO: Compute pipelines class GraphicsPipeline { // The CommandBuffer wrapper needs to access m_pipeline - friend CommandBuffer; + friend commands::CommandBuffer; friend render_graph::RenderGraph; private: diff --git a/include/inexor/vulkan-renderer/wrapper/swapchain.hpp b/include/inexor/vulkan-renderer/wrapper/swapchain.hpp index a86438f95..f33c9817c 100644 --- a/include/inexor/vulkan-renderer/wrapper/swapchain.hpp +++ b/include/inexor/vulkan-renderer/wrapper/swapchain.hpp @@ -8,11 +8,15 @@ #include #include +namespace inexor::vulkan_renderer::wrapper::synchronization { +// Forward declaration +class Semaphore; +} // namespace inexor::vulkan_renderer::wrapper::synchronization + namespace inexor::vulkan_renderer::wrapper { -// Forward declarations +// Forward declaration class Device; -class Semaphore; /// RAII wrapper class for swapchains class Swapchain { @@ -24,7 +28,7 @@ class Swapchain { std::vector m_imgs; std::vector m_img_views; VkExtent2D m_extent{}; - std::unique_ptr m_img_available; + std::unique_ptr m_img_available; bool m_vsync_enabled{false}; std::uint32_t m_img_index; diff --git a/include/inexor/vulkan-renderer/wrapper/synchronization/fence.hpp b/include/inexor/vulkan-renderer/wrapper/synchronization/fence.hpp index 8b2a49866..16fce92a4 100644 --- a/include/inexor/vulkan-renderer/wrapper/synchronization/fence.hpp +++ b/include/inexor/vulkan-renderer/wrapper/synchronization/fence.hpp @@ -7,9 +7,11 @@ #include namespace inexor::vulkan_renderer::wrapper { - // Forward declaration class Device; +} // namespace inexor::vulkan_renderer::wrapper + +namespace inexor::vulkan_renderer::wrapper::synchronization { /// A RAII wrapper for VkFence class Fence { @@ -23,7 +25,7 @@ class Fence { /// @param name The internal debug marker name of the VkFence. /// @param in_signaled_state True if the VkFence will be constructed in signaled state, false otherwise. /// @warning Make sure to specify in_signaled_state correctly as needed, otherwise synchronization problems occur. - Fence(const Device &device, const std::string &name, bool in_signaled_state); + Fence(const wrapper::Device &device, const std::string &name, bool in_signaled_state); Fence(const Fence &) = delete; Fence(Fence &&) noexcept; @@ -49,4 +51,4 @@ class Fence { [[nodiscard]] VkResult status() const; }; -} // namespace inexor::vulkan_renderer::wrapper +} // namespace inexor::vulkan_renderer::wrapper::synchronization diff --git a/include/inexor/vulkan-renderer/wrapper/synchronization/semaphore.hpp b/include/inexor/vulkan-renderer/wrapper/synchronization/semaphore.hpp index e55b48d51..509c28a78 100644 --- a/include/inexor/vulkan-renderer/wrapper/synchronization/semaphore.hpp +++ b/include/inexor/vulkan-renderer/wrapper/synchronization/semaphore.hpp @@ -5,9 +5,11 @@ #include namespace inexor::vulkan_renderer::wrapper { - // Forward declaration class Device; +} // namespace inexor::vulkan_renderer::wrapper + +namespace inexor::vulkan_renderer::wrapper::synchronization { /// RAII wrapper class for VkSemaphore class Semaphore { @@ -34,4 +36,4 @@ class Semaphore { } }; -} // namespace inexor::vulkan_renderer::wrapper +} // namespace inexor::vulkan_renderer::wrapper::synchronization diff --git a/src/vulkan-renderer/application.cpp b/src/vulkan-renderer/application.cpp index 92b384d7e..57c556e5d 100644 --- a/src/vulkan-renderer/application.cpp +++ b/src/vulkan-renderer/application.cpp @@ -514,7 +514,7 @@ void Application::setup_render_graph() { .color = {1.0f, 0.0f, 0.0f}, }) .set_depth_test(true) - .set_on_record([&](const wrapper::CommandBuffer &cmd_buf) { + .set_on_record([&](const wrapper::commands::CommandBuffer &cmd_buf) { cmd_buf.bind_pipeline(*m_octree_pipeline) .bind_vertex_buffer(m_vertex_buffer) .bind_index_buffer(m_index_buffer) diff --git a/src/vulkan-renderer/imgui.cpp b/src/vulkan-renderer/imgui.cpp index b1d388a93..65bddfcc2 100644 --- a/src/vulkan-renderer/imgui.cpp +++ b/src/vulkan-renderer/imgui.cpp @@ -139,7 +139,7 @@ ImGuiOverlay::ImGuiOverlay(const wrapper::Device &device, render_graph::RenderGr m_push_const_block.scale = glm::vec2(2.0f / io.DisplaySize.x, 2.0f / io.DisplaySize.y); }) - .set_on_record([&](const wrapper::CommandBuffer &cmd_buf) { + .set_on_record([&](const wrapper::commands::CommandBuffer &cmd_buf) { cmd_buf.bind_pipeline(*m_imgui_pipeline); ImDrawData *draw_data = ImGui::GetDrawData(); if (draw_data == nullptr) { diff --git a/src/vulkan-renderer/render-graph/graphics_pass.cpp b/src/vulkan-renderer/render-graph/graphics_pass.cpp index cfe950c50..df1e2a1b3 100644 --- a/src/vulkan-renderer/render-graph/graphics_pass.cpp +++ b/src/vulkan-renderer/render-graph/graphics_pass.cpp @@ -6,7 +6,8 @@ namespace inexor::vulkan_renderer::render_graph { GraphicsPass::GraphicsPass(std::string name, BufferReads buffer_reads, TextureReads texture_reads, - TextureWrites texture_writes, std::function on_record, + TextureWrites texture_writes, + std::function on_record, std::optional clear_values) : m_name(std::move(name)), m_buffer_reads(std::move(buffer_reads)), m_texture_reads(std::move(texture_reads)), m_texture_writes(std::move(texture_writes)), m_on_record(std::move(on_record)), diff --git a/src/vulkan-renderer/render-graph/render_graph.cpp b/src/vulkan-renderer/render-graph/render_graph.cpp index 64bed9da9..4ad73b9b3 100644 --- a/src/vulkan-renderer/render-graph/render_graph.cpp +++ b/src/vulkan-renderer/render-graph/render_graph.cpp @@ -181,9 +181,9 @@ void RenderGraph::determine_pass_order() { // TODO: Implement dfs } -void RenderGraph::record_command_buffer_for_pass(const wrapper::CommandBuffer &cmd_buf, const GraphicsPass &pass, - const bool is_first_pass, const bool is_last_pass, - const std::uint32_t img_index) { +void RenderGraph::record_command_buffer_for_pass(const wrapper::commands::CommandBuffer &cmd_buf, + const GraphicsPass &pass, const bool is_first_pass, + const bool is_last_pass, const std::uint32_t img_index) { // Start a new debug label for this graphics pass // These debug labels are visible in RenderDoc // TODO: Generate color gradient depending on the number of passes? (Interpolate e.g. in 12 steps for 12 passes) @@ -283,7 +283,8 @@ void RenderGraph::record_command_buffer_for_pass(const wrapper::CommandBuffer &c cmd_buf.end_debug_label_region(); } -void RenderGraph::record_command_buffers(const wrapper::CommandBuffer &cmd_buf, const std::uint32_t img_index) { +void RenderGraph::record_command_buffers(const wrapper::commands::CommandBuffer &cmd_buf, + const std::uint32_t img_index) { // TODO: Support multiple passes per command buffer, not just recording everything into one command buffer // TODO: Record command buffers in parallel diff --git a/src/vulkan-renderer/wrapper/commands/command_buffer.cpp b/src/vulkan-renderer/wrapper/commands/command_buffer.cpp index 34579b4cd..d6f040f0f 100644 --- a/src/vulkan-renderer/wrapper/commands/command_buffer.cpp +++ b/src/vulkan-renderer/wrapper/commands/command_buffer.cpp @@ -10,9 +10,9 @@ #include #include -namespace inexor::vulkan_renderer::wrapper { +namespace inexor::vulkan_renderer::wrapper::commands { -CommandBuffer::CommandBuffer(const Device &device, const VkCommandPool cmd_pool, std::string name) +CommandBuffer::CommandBuffer(const wrapper::Device &device, const VkCommandPool cmd_pool, std::string name) : m_device(device), m_name(std::move(name)) { const auto cmd_buf_ai = make_info({ .commandPool = cmd_pool, @@ -29,7 +29,7 @@ CommandBuffer::CommandBuffer(const Device &device, const VkCommandPool cmd_pool, m_device.set_debug_name(m_cmd_buf, m_name); - m_wait_fence = std::make_unique(m_device, m_name, false); + m_wait_fence = std::make_unique(m_device, m_name, false); } CommandBuffer::CommandBuffer(CommandBuffer &&other) noexcept : m_device(other.m_device) { @@ -362,4 +362,4 @@ const CommandBuffer &CommandBuffer::submit_and_wait() const { })); } -} // namespace inexor::vulkan_renderer::wrapper +} // namespace inexor::vulkan_renderer::wrapper::commands diff --git a/src/vulkan-renderer/wrapper/commands/command_pool.cpp b/src/vulkan-renderer/wrapper/commands/command_pool.cpp index 9c82ceaaa..bc95f299d 100644 --- a/src/vulkan-renderer/wrapper/commands/command_pool.cpp +++ b/src/vulkan-renderer/wrapper/commands/command_pool.cpp @@ -8,9 +8,9 @@ #include -namespace inexor::vulkan_renderer::wrapper { +namespace inexor::vulkan_renderer::wrapper::commands { -CommandPool::CommandPool(const Device &device, std::string name) : m_device(device), m_name(std::move(name)) { +CommandPool::CommandPool(const wrapper::Device &device, std::string name) : m_device(device), m_name(std::move(name)) { const auto cmd_pool_ci = make_info({ .flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT | VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, .queueFamilyIndex = device.graphics_queue_family_index(), @@ -37,7 +37,7 @@ CommandPool::~CommandPool() { vkDestroyCommandPool(m_device.device(), m_cmd_pool, nullptr); } -const CommandBuffer &CommandPool::request_command_buffer(const std::string &name) { +const commands::CommandBuffer &CommandPool::request_command_buffer(const std::string &name) { // Try to find a command buffer which is currently not used for (const auto &cmd_buf : m_cmd_bufs) { if (cmd_buf->fence_status() == VK_SUCCESS) { @@ -51,7 +51,7 @@ const CommandBuffer &CommandPool::request_command_buffer(const std::string &name // We need to create a new command buffer because no free one was found // Note that there is currently no method for shrinking m_cmd_bufs, but this should not be a problem - m_cmd_bufs.emplace_back(std::make_unique(m_device, m_cmd_pool, "command buffer")); + m_cmd_bufs.emplace_back(std::make_unique(m_device, m_cmd_pool, "command buffer")); spdlog::trace("Creating new command buffer #{}", m_cmd_bufs.size()); @@ -59,4 +59,4 @@ const CommandBuffer &CommandPool::request_command_buffer(const std::string &name return *m_cmd_bufs.back(); } -} // namespace inexor::vulkan_renderer::wrapper +} // namespace inexor::vulkan_renderer::wrapper::commands diff --git a/src/vulkan-renderer/wrapper/device.cpp b/src/vulkan-renderer/wrapper/device.cpp index 3d18a08b1..cb601471b 100644 --- a/src/vulkan-renderer/wrapper/device.cpp +++ b/src/vulkan-renderer/wrapper/device.cpp @@ -455,7 +455,7 @@ bool Device::surface_supports_usage(const VkSurfaceKHR surface, const VkImageUsa } void Device::execute(const std::string &name, - const std::function &cmd_lambda) const { + const std::function &cmd_lambda) const { // TODO: Support other queues, not just graphics queue const auto &cmd_buf = thread_graphics_pool().request_command_buffer(name); cmd_lambda(cmd_buf); @@ -473,18 +473,18 @@ std::optional Device::find_queue_family_index_if( return std::nullopt; } -CommandPool &Device::thread_graphics_pool() const { +commands::CommandPool &Device::thread_graphics_pool() const { // Note that thread_graphics_pool is implicitely static! - thread_local CommandPool *thread_graphics_pool = nullptr; // NOLINT + thread_local commands::CommandPool *thread_graphics_pool = nullptr; // NOLINT if (thread_graphics_pool == nullptr) { - auto cmd_pool = std::make_unique(*this, "Graphics Pool"); + auto cmd_pool = std::make_unique(*this, "Graphics Pool"); std::scoped_lock locker(m_mutex); thread_graphics_pool = m_cmd_pools.emplace_back(std::move(cmd_pool)).get(); } return *thread_graphics_pool; } -const CommandBuffer &Device::request_command_buffer(const std::string &name) { +const commands::CommandBuffer &Device::request_command_buffer(const std::string &name) { return thread_graphics_pool().request_command_buffer(name); } diff --git a/src/vulkan-renderer/wrapper/swapchain.cpp b/src/vulkan-renderer/wrapper/swapchain.cpp index 0a698f6b5..17a1a128b 100644 --- a/src/vulkan-renderer/wrapper/swapchain.cpp +++ b/src/vulkan-renderer/wrapper/swapchain.cpp @@ -5,7 +5,6 @@ #include "inexor/vulkan-renderer/vk_tools/representation.hpp" #include "inexor/vulkan-renderer/wrapper/device.hpp" #include "inexor/vulkan-renderer/wrapper/make_info.hpp" -#include "inexor/vulkan-renderer/wrapper/synchronization/semaphore.hpp" #include @@ -20,7 +19,7 @@ namespace inexor::vulkan_renderer::wrapper { Swapchain::Swapchain(Device &device, const VkSurfaceKHR surface, const std::uint32_t width, const std::uint32_t height, const bool vsync_enabled) : m_device(device), m_surface(surface), m_vsync_enabled(vsync_enabled) { - m_img_available = std::make_unique(m_device, "Swapchain image available"); + m_img_available = std::make_unique(m_device, "Swapchain image available"); setup_swapchain(width, height, vsync_enabled); } diff --git a/src/vulkan-renderer/wrapper/synchronization/fence.cpp b/src/vulkan-renderer/wrapper/synchronization/fence.cpp index 05fcec4c8..d76cda901 100644 --- a/src/vulkan-renderer/wrapper/synchronization/fence.cpp +++ b/src/vulkan-renderer/wrapper/synchronization/fence.cpp @@ -8,7 +8,7 @@ #include #include -namespace inexor::vulkan_renderer::wrapper { +namespace inexor::vulkan_renderer::wrapper::synchronization { Fence::Fence(const Device &device, const std::string &name, const bool in_signaled_state) : m_device(device), m_name(name) { @@ -45,4 +45,4 @@ VkResult Fence::status() const { return vkGetFenceStatus(m_device.device(), m_fence); } -} // namespace inexor::vulkan_renderer::wrapper +} // namespace inexor::vulkan_renderer::wrapper::synchronization diff --git a/src/vulkan-renderer/wrapper/synchronization/semaphore.cpp b/src/vulkan-renderer/wrapper/synchronization/semaphore.cpp index f340d8ee3..41cee8ed7 100644 --- a/src/vulkan-renderer/wrapper/synchronization/semaphore.cpp +++ b/src/vulkan-renderer/wrapper/synchronization/semaphore.cpp @@ -1,4 +1,4 @@ -#include "inexor/vulkan-renderer/wrapper/semaphore.hpp" +#include "inexor/vulkan-renderer/wrapper/synchronization/semaphore.hpp" #include "inexor/vulkan-renderer/exception.hpp" #include "inexor/vulkan-renderer/wrapper/device.hpp" @@ -7,7 +7,7 @@ #include #include -namespace inexor::vulkan_renderer::wrapper { +namespace inexor::vulkan_renderer::wrapper::synchronization { Semaphore::Semaphore(const Device &device, const std::string &name) : m_device(device), m_name(name) { assert(!name.empty()); @@ -30,4 +30,4 @@ Semaphore::~Semaphore() { vkDestroySemaphore(m_device.device(), m_semaphore, nullptr); } -} // namespace inexor::vulkan_renderer::wrapper +} // namespace inexor::vulkan_renderer::wrapper::synchronization