Skip to content

Commit

Permalink
[merge] Merge pull request #326 from yeetari/rename-render-graph
Browse files Browse the repository at this point in the history
  • Loading branch information
yeetari authored and IAmNotHanni committed Apr 6, 2021
1 parent 1e5a21b commit 06e2aca
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 76 deletions.
4 changes: 2 additions & 2 deletions documentation/source/development/engine-design/labeling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
+---------------------+----------+---------------+------------------------------------------------------------------------------------+---------+
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -81,13 +81,13 @@ enum class BufferUsage {
};

class BufferResource : public RenderResource {
friend FrameGraph;
friend RenderGraph;

private:
BufferUsage m_usage{BufferUsage::INVALID};
std::vector<VkVertexInputAttributeDescription> 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};
Expand All @@ -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.
Expand All @@ -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,

Expand All @@ -138,7 +138,7 @@ enum class TextureUsage {
};

class TextureResource : public RenderResource {
friend FrameGraph;
friend RenderGraph;

private:
VkFormat m_format{VK_FORMAT_UNDEFINED};
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -207,7 +207,7 @@ class RenderStage : public FrameGraphObject {
};

class GraphicsStage : public RenderStage {
friend FrameGraph;
friend RenderGraph;

private:
bool m_clears_screen{false};
Expand Down Expand Up @@ -237,8 +237,8 @@ class GraphicsStage : public RenderStage {
};

// TODO: Add wrapper::Allocation that can be made by doing `device->make<Allocation>(...)`.
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.
Expand All @@ -258,7 +258,7 @@ class PhysicalResource : public FrameGraphObject {
};

class PhysicalBuffer : public PhysicalResource {
friend FrameGraph;
friend RenderGraph;

private:
VkBuffer m_buffer{VK_NULL_HANDLE};
Expand All @@ -274,7 +274,7 @@ class PhysicalBuffer : public PhysicalResource {
};

class PhysicalImage : public PhysicalResource {
friend FrameGraph;
friend RenderGraph;

private:
VkImage m_image{VK_NULL_HANDLE};
Expand All @@ -291,7 +291,7 @@ class PhysicalImage : public PhysicalResource {
};

class PhysicalBackBuffer : public PhysicalResource {
friend FrameGraph;
friend RenderGraph;

private:
const wrapper::Swapchain &m_swapchain;
Expand All @@ -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<wrapper::CommandBuffer> m_command_buffers;
Expand All @@ -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};
Expand All @@ -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<spdlog::logger> m_log{spdlog::default_logger()->clone("frame-graph")};
std::shared_ptr<spdlog::logger> 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.
Expand All @@ -376,7 +376,7 @@ class FrameGraph {
// Stage to physical stage map.
std::unordered_map<const RenderStage *, std::unique_ptr<PhysicalStage>> 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 <typename T, typename... Args, std::enable_if_t<std::is_base_of_v<PhysicalResource, T>, int> = 0>
T *create(const RenderResource *resource, Args &&... args) {
Expand All @@ -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 <typename T, typename... Args, std::enable_if_t<std::is_base_of_v<PhysicalStage, T>, int> = 0>
T *create(const RenderStage *stage, Args &&... args) {
Expand All @@ -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 <typename T, typename... Args>
T &add(Args &&... args) {
Expand All @@ -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);

Expand All @@ -441,12 +441,12 @@ class FrameGraph {
};

template <typename T>
T *FrameGraphObject::as() {
T *RenderGraphObject::as() {
return dynamic_cast<T *>(this);
}

template <typename T>
const T *FrameGraphObject::as() const {
const T *RenderGraphObject::as() const {
return dynamic_cast<const T *>(this);
}

Expand Down
6 changes: 3 additions & 3 deletions include/inexor/vulkan-renderer/renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -72,7 +72,7 @@ class VulkanRenderer {
std::unique_ptr<ImGUIOverlay> m_imgui_overlay;
std::unique_ptr<wrapper::Semaphore> m_image_available_semaphore;
std::unique_ptr<wrapper::Semaphore> m_rendering_finished_semaphore;
std::unique_ptr<FrameGraph> m_frame_graph;
std::unique_ptr<RenderGraph> m_render_graph;

std::vector<wrapper::Shader> m_shaders;
std::vector<wrapper::GpuTexture> m_textures;
Expand All @@ -81,7 +81,7 @@ class VulkanRenderer {
std::vector<OctreeGpuVertex> m_octree_vertices;
std::vector<std::uint16_t> m_octree_indices;

void setup_frame_graph();
void setup_render_graph();
void generate_octree_indices();
void recreate_swapchain();
void render_frame();
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/vulkan-renderer/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
Loading

0 comments on commit 06e2aca

Please sign in to comment.