diff --git a/documentation/source/development/engine-design/labeling.rst b/documentation/source/development/engine-design/labeling.rst index 972e0da8b..1118e42b7 100644 --- a/documentation/source/development/engine-design/labeling.rst +++ b/documentation/source/development/engine-design/labeling.rst @@ -80,7 +80,7 @@ Some labels are mutual to each other like ``org:in progress`` and ``org:on hold` +---------------------+----------+---------------+------------------------------------------------------------------------------------+---------+ | |feat:concurrency| | feat | concurrency | multithreading, asynchronous events, concurrency | #D4C5F9 | +---------------------+----------+---------------+------------------------------------------------------------------------------------+---------+ -| |feat:frame graph| | feat | frame graph | frame graph | #D4C5F9 | +| |feat:render graph| | feat | render graph | render graph | #D4C5F9 | +---------------------+----------+---------------+------------------------------------------------------------------------------------+---------+ | |feat:gui| | feat | gui | graphical user interface | #D4C5F9 | +---------------------+----------+---------------+------------------------------------------------------------------------------------+---------+ @@ -144,7 +144,7 @@ Some labels are mutual to each other like ``org:in progress`` and ``org:on hold` .. |org:wontfix| image:: https://img.shields.io/badge/-org:wontfix-DDDDDD .. |feat:ci| image:: https://img.shields.io/badge/-feat:ci-D4C5F9 .. |feat:concurrency| image:: https://img.shields.io/badge/-feat:concurrency-D4C5F9 -.. |feat:frame graph| image:: https://img.shields.io/badge/-feat:frame_graph-D4C5F9 +.. |feat:render graph| image:: https://img.shields.io/badge/-feat:render_graph-D4C5F9 .. |feat:gui| image:: https://img.shields.io/badge/-feat:gui-D4C5F9 .. |feat:input| image:: https://img.shields.io/badge/-feat:input-D4C5F9 .. |feat:lightning| image:: https://img.shields.io/badge/-feat:lightning-D4C5F9 diff --git a/include/inexor/vulkan-renderer/frame_graph.hpp b/include/inexor/vulkan-renderer/render_graph.hpp similarity index 89% rename from include/inexor/vulkan-renderer/frame_graph.hpp rename to include/inexor/vulkan-renderer/render_graph.hpp index 3cf2694f1..4c29296e3 100644 --- a/include/inexor/vulkan-renderer/frame_graph.hpp +++ b/include/inexor/vulkan-renderer/render_graph.hpp @@ -25,18 +25,18 @@ namespace inexor::vulkan_renderer { -class FrameGraph; +class RenderGraph; -/// @brief Base class of all frame graph objects (resources and stages) +/// @brief Base class of all render graph objects (resources and stages) /// @note This is just for internal use -struct FrameGraphObject { - FrameGraphObject() = default; - FrameGraphObject(const FrameGraphObject &) = delete; - FrameGraphObject(FrameGraphObject &&) = delete; - virtual ~FrameGraphObject() = default; +struct RenderGraphObject { + RenderGraphObject() = default; + RenderGraphObject(const RenderGraphObject &) = delete; + RenderGraphObject(RenderGraphObject &&) = delete; + virtual ~RenderGraphObject() = default; - FrameGraphObject &operator=(const FrameGraphObject &) = delete; - FrameGraphObject &operator=(FrameGraphObject &&) = delete; + RenderGraphObject &operator=(const RenderGraphObject &) = delete; + RenderGraphObject &operator=(RenderGraphObject &&) = delete; /// @brief Casts this object to type `T` /// @return The object as type `T` or `nullptr` if the cast failed @@ -48,10 +48,10 @@ struct FrameGraphObject { const T *as() const; }; -/// @brief A single resource in the frame graph -/// @note May become multiple physical (vulkan) resources during frame graph compilation -class RenderResource : public FrameGraphObject { - friend FrameGraph; +/// @brief A single resource in the render graph +/// @note May become multiple physical (vulkan) resources during render graph compilation +class RenderResource : public RenderGraphObject { + friend RenderGraph; private: const std::string m_name; @@ -70,7 +70,7 @@ class RenderResource : public FrameGraphObject { enum class BufferUsage { /// @brief Invalid buffer usage - /// @note Leaving a buffer as this usage will cause frame graph compilation to fail! + /// @note Leaving a buffer as this usage will cause render graph compilation to fail! INVALID, /// @brief Specifies that the buffer will be used to input index data @@ -81,13 +81,13 @@ enum class BufferUsage { }; class BufferResource : public RenderResource { - friend FrameGraph; + friend RenderGraph; private: BufferUsage m_usage{BufferUsage::INVALID}; std::vector m_vertex_attributes; - // Data to upload during frame graph compilation. + // Data to upload during render graph compilation. const void *m_data{nullptr}; std::size_t m_data_size{0}; std::size_t m_element_size{0}; @@ -106,7 +106,7 @@ class BufferResource : public RenderResource { /// @note Calling this function is only valid on buffers of type BufferUsage::VERTEX_BUFFER! void add_vertex_attribute(VkFormat format, std::uint32_t offset); - /// @brief Specifies that data should be uploaded to this buffer during frame graph compilation + /// @brief Specifies that data should be uploaded to this buffer during render graph compilation /// @param count The number of elements (not bytes) to upload from CPU memory to GPU memory /// @param data A pointer to a contiguous block of memory that is at least `count * sizeof(T)` bytes long // TODO: Use std::span when we switch to C++ 20. @@ -122,10 +122,10 @@ class BufferResource : public RenderResource { enum class TextureUsage { /// @brief Invalid texture usage - /// @note Leaving a texture as this usage will cause frame graph compilation to fail! + /// @note Leaving a texture as this usage will cause render graph compilation to fail! INVALID, - /// @brief Specifies that this texture is the result of the frame graph + /// @brief Specifies that this texture is the result of the render graph // TODO: Refactor back buffer system more (remove need for BACK_BUFFER texture usage) BACK_BUFFER, @@ -138,7 +138,7 @@ enum class TextureUsage { }; class TextureResource : public RenderResource { - friend FrameGraph; + friend RenderGraph; private: VkFormat m_format{VK_FORMAT_UNDEFINED}; @@ -161,10 +161,10 @@ class TextureResource : public RenderResource { } }; -/// @brief A single render stage in the frame graph +/// @brief A single render stage in the render graph /// @note Not to be confused with a vulkan render pass! -class RenderStage : public FrameGraphObject { - friend FrameGraph; +class RenderStage : public RenderGraphObject { + friend RenderGraph; private: const std::string m_name; @@ -193,7 +193,7 @@ class RenderStage : public FrameGraphObject { /// @brief Binds a descriptor set layout to this render stage /// @note This function will soon be removed - // TODO: Refactor descriptor management in the frame graph + // TODO: Refactor descriptor management in the render graph void add_descriptor_layout(VkDescriptorSetLayout layout) { m_descriptor_layouts.push_back(layout); } @@ -207,7 +207,7 @@ class RenderStage : public FrameGraphObject { }; class GraphicsStage : public RenderStage { - friend FrameGraph; + friend RenderGraph; private: bool m_clears_screen{false}; @@ -237,8 +237,8 @@ class GraphicsStage : public RenderStage { }; // TODO: Add wrapper::Allocation that can be made by doing `device->make(...)`. -class PhysicalResource : public FrameGraphObject { - friend FrameGraph; +class PhysicalResource : public RenderGraphObject { + friend RenderGraph; protected: // TODO: Add OOP device functions (see above todo) and only store a wrapper::Device here. @@ -258,7 +258,7 @@ class PhysicalResource : public FrameGraphObject { }; class PhysicalBuffer : public PhysicalResource { - friend FrameGraph; + friend RenderGraph; private: VkBuffer m_buffer{VK_NULL_HANDLE}; @@ -274,7 +274,7 @@ class PhysicalBuffer : public PhysicalResource { }; class PhysicalImage : public PhysicalResource { - friend FrameGraph; + friend RenderGraph; private: VkImage m_image{VK_NULL_HANDLE}; @@ -291,7 +291,7 @@ class PhysicalImage : public PhysicalResource { }; class PhysicalBackBuffer : public PhysicalResource { - friend FrameGraph; + friend RenderGraph; private: const wrapper::Swapchain &m_swapchain; @@ -307,8 +307,8 @@ class PhysicalBackBuffer : public PhysicalResource { PhysicalBackBuffer &operator=(PhysicalBackBuffer &&) = delete; }; -class PhysicalStage : public FrameGraphObject { - friend FrameGraph; +class PhysicalStage : public RenderGraphObject { + friend RenderGraph; private: std::vector m_command_buffers; @@ -331,14 +331,14 @@ class PhysicalStage : public FrameGraphObject { PhysicalStage &operator=(PhysicalStage &&) = delete; /// @brief Retrieve the pipeline layout of this physical stage - // TODO: This can be removed once descriptors are properly implemented in the frame graph. + // TODO: This can be removed once descriptors are properly implemented in the render graph. [[nodiscard]] VkPipelineLayout pipeline_layout() const { return m_pipeline_layout; } }; class PhysicalGraphicsStage : public PhysicalStage { - friend FrameGraph; + friend RenderGraph; private: VkRenderPass m_render_pass{VK_NULL_HANDLE}; @@ -354,12 +354,12 @@ class PhysicalGraphicsStage : public PhysicalStage { PhysicalGraphicsStage &operator=(PhysicalGraphicsStage &&) = delete; }; -class FrameGraph { +class RenderGraph { private: const wrapper::Device &m_device; VkCommandPool m_command_pool{VK_NULL_HANDLE}; const wrapper::Swapchain &m_swapchain; - std::shared_ptr m_log{spdlog::default_logger()->clone("frame-graph")}; + std::shared_ptr m_log{spdlog::default_logger()->clone("render-graph")}; // Vectors of render resources and stages. These own the memory. Note that unique_ptr must be used as Render* is // just an inheritable base class. @@ -376,7 +376,7 @@ class FrameGraph { // Stage to physical stage map. std::unordered_map> m_stage_map; - // Helper function used to create a physical resource during frame graph compilation. + // Helper function used to create a physical resource during render graph compilation. // TODO: Use concepts when we switch to C++ 20. template , int> = 0> T *create(const RenderResource *resource, Args &&... args) { @@ -386,7 +386,7 @@ class FrameGraph { return ret; } - // Helper function used to create a physical stage during frame graph compilation. + // Helper function used to create a physical stage during render graph compilation. // TODO: Use concepts when we switch to C++ 20. template , int> = 0> T *create(const RenderStage *stage, Args &&... args) { @@ -411,10 +411,10 @@ class FrameGraph { void build_graphics_pipeline(const GraphicsStage *, PhysicalGraphicsStage *) const; public: - FrameGraph(const wrapper::Device &device, VkCommandPool command_pool, const wrapper::Swapchain &swapchain) + RenderGraph(const wrapper::Device &device, VkCommandPool command_pool, const wrapper::Swapchain &swapchain) : m_device(device), m_command_pool(command_pool), m_swapchain(swapchain) {} - /// @brief Adds either a render resource or render stage to the frame graph + /// @brief Adds either a render resource or render stage to the render graph /// @return A mutable reference to the just-added resource or stage template T &add(Args &&... args) { @@ -430,7 +430,7 @@ class FrameGraph { return ret; } - /// @brief Compiles the frame graph resources/stages into physical vulkan objects + /// @brief Compiles the render graph resources/stages into physical vulkan objects /// @param target The resource to start the depth first search from void compile(const RenderResource &target); @@ -441,12 +441,12 @@ class FrameGraph { }; template -T *FrameGraphObject::as() { +T *RenderGraphObject::as() { return dynamic_cast(this); } template -const T *FrameGraphObject::as() const { +const T *RenderGraphObject::as() const { return dynamic_cast(this); } diff --git a/include/inexor/vulkan-renderer/renderer.hpp b/include/inexor/vulkan-renderer/renderer.hpp index bd064c3b9..078c8d249 100644 --- a/include/inexor/vulkan-renderer/renderer.hpp +++ b/include/inexor/vulkan-renderer/renderer.hpp @@ -2,10 +2,10 @@ #include "inexor/vulkan-renderer/camera.hpp" #include "inexor/vulkan-renderer/fps_counter.hpp" -#include "inexor/vulkan-renderer/frame_graph.hpp" #include "inexor/vulkan-renderer/imgui.hpp" #include "inexor/vulkan-renderer/msaa_target.hpp" #include "inexor/vulkan-renderer/octree_gpu_vertex.hpp" +#include "inexor/vulkan-renderer/render_graph.hpp" #include "inexor/vulkan-renderer/settings_decision_maker.hpp" #include "inexor/vulkan-renderer/time_step.hpp" #include "inexor/vulkan-renderer/vk_tools/gpu_info.hpp" @@ -72,7 +72,7 @@ class VulkanRenderer { std::unique_ptr m_imgui_overlay; std::unique_ptr m_image_available_semaphore; std::unique_ptr m_rendering_finished_semaphore; - std::unique_ptr m_frame_graph; + std::unique_ptr m_render_graph; std::vector m_shaders; std::vector m_textures; @@ -81,7 +81,7 @@ class VulkanRenderer { std::vector m_octree_vertices; std::vector m_octree_indices; - void setup_frame_graph(); + void setup_render_graph(); void generate_octree_indices(); void recreate_swapchain(); void render_frame(); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index faea05735..32c003b2b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,8 +4,8 @@ set(INEXOR_SOURCE_FILES vulkan-renderer/camera.cpp vulkan-renderer/exception.cpp vulkan-renderer/fps_counter.cpp - vulkan-renderer/frame_graph.cpp vulkan-renderer/imgui.cpp + vulkan-renderer/render_graph.cpp vulkan-renderer/renderer.cpp vulkan-renderer/settings_decision_maker.cpp vulkan-renderer/time_step.cpp diff --git a/src/vulkan-renderer/application.cpp b/src/vulkan-renderer/application.cpp index df95f96a6..6df0b120c 100644 --- a/src/vulkan-renderer/application.cpp +++ b/src/vulkan-renderer/application.cpp @@ -512,7 +512,7 @@ void Application::update_uniform_buffers() { ubo.proj = m_camera->perspective_matrix(); ubo.proj[1][1] *= -1; - // TODO: Refactoring: Embedd this into frame graph. + // TODO: Embed this into the render graph. m_uniform_buffers[0].update(&ubo, sizeof(ubo)); } diff --git a/src/vulkan-renderer/frame_graph.cpp b/src/vulkan-renderer/render_graph.cpp similarity index 95% rename from src/vulkan-renderer/frame_graph.cpp rename to src/vulkan-renderer/render_graph.cpp index aba7466ca..61efd048a 100644 --- a/src/vulkan-renderer/frame_graph.cpp +++ b/src/vulkan-renderer/render_graph.cpp @@ -1,4 +1,4 @@ -#include "inexor/vulkan-renderer/frame_graph.hpp" +#include "inexor/vulkan-renderer/render_graph.hpp" #include "inexor/vulkan-renderer/exception.hpp" #include "inexor/vulkan-renderer/wrapper/make_info.hpp" @@ -62,8 +62,8 @@ PhysicalGraphicsStage::~PhysicalGraphicsStage() { vkDestroyRenderPass(device(), m_render_pass, nullptr); } -void FrameGraph::build_image(const TextureResource *resource, PhysicalImage *phys, - VmaAllocationCreateInfo *alloc_ci) const { +void RenderGraph::build_image(const TextureResource *resource, PhysicalImage *phys, + VmaAllocationCreateInfo *alloc_ci) const { auto image_ci = wrapper::make_info(); image_ci.imageType = VK_IMAGE_TYPE_2D; @@ -91,7 +91,7 @@ void FrameGraph::build_image(const TextureResource *resource, PhysicalImage *phy } } -void FrameGraph::build_image_view(const TextureResource *resource, PhysicalImage *phys) const { +void RenderGraph::build_image_view(const TextureResource *resource, PhysicalImage *phys) const { auto image_view_ci = wrapper::make_info(); image_view_ci.format = resource->m_format; image_view_ci.image = phys->m_image; @@ -108,14 +108,14 @@ void FrameGraph::build_image_view(const TextureResource *resource, PhysicalImage } } -void FrameGraph::alloc_command_buffers(const RenderStage *stage, PhysicalStage *phys) const { +void RenderGraph::alloc_command_buffers(const RenderStage *stage, PhysicalStage *phys) const { m_log->trace("Allocating command buffers for stage '{}'", stage->m_name); for (std::uint32_t i = 0; i < m_swapchain.image_count(); i++) { phys->m_command_buffers.emplace_back(m_device, m_command_pool, "Command buffer for stage " + stage->m_name); } } -void FrameGraph::build_pipeline_layout(const RenderStage *stage, PhysicalStage *phys) const { +void RenderGraph::build_pipeline_layout(const RenderStage *stage, PhysicalStage *phys) const { auto pipeline_layout_ci = wrapper::make_info(); pipeline_layout_ci.setLayoutCount = static_cast(stage->m_descriptor_layouts.size()); pipeline_layout_ci.pSetLayouts = stage->m_descriptor_layouts.data(); @@ -129,7 +129,7 @@ void FrameGraph::build_pipeline_layout(const RenderStage *stage, PhysicalStage * stage->m_name + " pipeline layout"); } -void FrameGraph::record_command_buffers(const RenderStage *stage, PhysicalStage *phys) const { +void RenderGraph::record_command_buffers(const RenderStage *stage, PhysicalStage *phys) const { for (std::size_t i = 0; i < phys->m_command_buffers.size(); i++) { // TODO: Remove simultaneous usage once we have proper max frames in flight control. auto &cmd_buf = phys->m_command_buffers[i]; @@ -186,7 +186,7 @@ void FrameGraph::record_command_buffers(const RenderStage *stage, PhysicalStage } } -void FrameGraph::build_render_pass(const GraphicsStage *stage, PhysicalGraphicsStage *phys) const { +void RenderGraph::build_render_pass(const GraphicsStage *stage, PhysicalGraphicsStage *phys) const { std::vector attachments; std::vector colour_refs; std::vector depth_refs; @@ -255,7 +255,7 @@ void FrameGraph::build_render_pass(const GraphicsStage *stage, PhysicalGraphicsS } } -void FrameGraph::build_graphics_pipeline(const GraphicsStage *stage, PhysicalGraphicsStage *phys) const { +void RenderGraph::build_graphics_pipeline(const GraphicsStage *stage, PhysicalGraphicsStage *phys) const { // Build buffer and vertex layout bindings. For every buffer resource that stage reads from, we create a // corresponding attribute binding and vertex binding description. std::vector attribute_bindings; @@ -352,7 +352,7 @@ void FrameGraph::build_graphics_pipeline(const GraphicsStage *stage, PhysicalGra pipeline_ci.stageCount = static_cast(stage->m_shaders.size()); pipeline_ci.pStages = stage->m_shaders.data(); - // TODO: Pipeline caching (basically load the frame graph from a file) + // TODO: Pipeline caching (basically load the render graph from a file) if (const auto result = vkCreateGraphicsPipelines(m_device.device(), nullptr, 1, &pipeline_ci, nullptr, &phys->m_pipeline); result != VK_SUCCESS) { @@ -360,7 +360,7 @@ void FrameGraph::build_graphics_pipeline(const GraphicsStage *stage, PhysicalGra } } -void FrameGraph::compile(const RenderResource &target) { +void RenderGraph::compile(const RenderResource &target) { // TODO(GH-204): Better logging and input validation. // TODO: Many opportunities for optimisation. @@ -508,8 +508,8 @@ void FrameGraph::compile(const RenderResource &target) { } } -void FrameGraph::render(int image_index, VkSemaphore signal_semaphore, VkSemaphore wait_semaphore, - VkQueue graphics_queue) const { +void RenderGraph::render(int image_index, VkSemaphore signal_semaphore, VkSemaphore wait_semaphore, + VkQueue graphics_queue) const { auto submit_info = wrapper::make_info(); submit_info.commandBufferCount = 1; submit_info.signalSemaphoreCount = 1; diff --git a/src/vulkan-renderer/renderer.cpp b/src/vulkan-renderer/renderer.cpp index 82379335e..014c45382 100644 --- a/src/vulkan-renderer/renderer.cpp +++ b/src/vulkan-renderer/renderer.cpp @@ -15,26 +15,26 @@ namespace inexor::vulkan_renderer { -void VulkanRenderer::setup_frame_graph() { - auto &back_buffer = m_frame_graph->add("back buffer"); +void VulkanRenderer::setup_render_graph() { + auto &back_buffer = m_render_graph->add("back buffer"); back_buffer.set_format(m_swapchain->image_format()); back_buffer.set_usage(TextureUsage::BACK_BUFFER); - auto &depth_buffer = m_frame_graph->add("depth buffer"); + auto &depth_buffer = m_render_graph->add("depth buffer"); depth_buffer.set_format(VK_FORMAT_D32_SFLOAT_S8_UINT); depth_buffer.set_usage(TextureUsage::DEPTH_STENCIL_BUFFER); - auto &index_buffer = m_frame_graph->add("index buffer"); + auto &index_buffer = m_render_graph->add("index buffer"); index_buffer.set_usage(BufferUsage::INDEX_BUFFER); index_buffer.upload_data(m_octree_indices); - auto &vertex_buffer = m_frame_graph->add("vertex buffer"); + auto &vertex_buffer = m_render_graph->add("vertex buffer"); vertex_buffer.set_usage(BufferUsage::VERTEX_BUFFER); vertex_buffer.add_vertex_attribute(VK_FORMAT_R32G32B32_SFLOAT, offsetof(OctreeGpuVertex, position)); vertex_buffer.add_vertex_attribute(VK_FORMAT_R32G32B32_SFLOAT, offsetof(OctreeGpuVertex, color)); vertex_buffer.upload_data(m_octree_vertices); - auto &main_stage = m_frame_graph->add("main stage"); + auto &main_stage = m_render_graph->add("main stage"); main_stage.writes_to(back_buffer); main_stage.writes_to(depth_buffer); main_stage.reads_from(index_buffer); @@ -51,7 +51,7 @@ void VulkanRenderer::setup_frame_graph() { } main_stage.add_descriptor_layout(m_descriptors[0].descriptor_set_layout()); - m_frame_graph->compile(back_buffer); + m_render_graph->compile(back_buffer); } void VulkanRenderer::generate_octree_indices() { @@ -73,11 +73,11 @@ void VulkanRenderer::recreate_swapchain() { m_window->wait_for_focus(); vkDeviceWaitIdle(m_device->device()); - // TODO(): This is quite naive, we don't need to recompile the whole frame graph on swapchain invalidation - m_frame_graph.reset(); + // TODO: This is quite naive, we don't need to recompile the whole render graph on swapchain invalidation. + m_render_graph.reset(); m_swapchain->recreate(m_window->width(), m_window->height()); - m_frame_graph = std::make_unique(*m_device, m_command_pool->get(), *m_swapchain); - setup_frame_graph(); + m_render_graph = std::make_unique(*m_device, m_command_pool->get(), *m_swapchain); + setup_render_graph(); m_image_available_semaphore.reset(); m_rendering_finished_semaphore.reset(); @@ -99,8 +99,8 @@ void VulkanRenderer::render_frame() { } const auto image_index = m_swapchain->acquire_next_image(*m_image_available_semaphore); - m_frame_graph->render(image_index, m_rendering_finished_semaphore->get(), m_image_available_semaphore->get(), - m_device->graphics_queue()); + m_render_graph->render(image_index, m_rendering_finished_semaphore->get(), m_image_available_semaphore->get(), + m_device->graphics_queue()); m_imgui_overlay->render(image_index);