-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[renderer] Integrate ImGUI with render graph
- Loading branch information
Showing
14 changed files
with
187 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,67 @@ | ||
#pragma once | ||
|
||
#include "inexor/vulkan-renderer/wrapper/command_buffer.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/command_pool.hpp" | ||
#include "inexor/vulkan-renderer/render_graph.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/descriptor.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/device.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/fence.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/framebuffer.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/gpu_texture.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/graphics_pipeline.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/make_info.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/mesh_buffer.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/renderpass.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/shader.hpp" | ||
#include "inexor/vulkan-renderer/wrapper/swapchain.hpp" | ||
|
||
#include <glm/vec2.hpp> | ||
#include <imgui.h> | ||
#include <vulkan/vulkan.h> | ||
#include <vulkan/vulkan_core.h> | ||
|
||
#include <memory> | ||
#include <vector> | ||
|
||
namespace inexor::vulkan_renderer::wrapper { | ||
|
||
class Device; | ||
class Swapchain; | ||
|
||
} // namespace inexor::vulkan_renderer::wrapper | ||
|
||
namespace inexor::vulkan_renderer { | ||
|
||
class ImGUIOverlay { | ||
const wrapper::Device &m_device; | ||
const wrapper::Swapchain &m_swapchain; | ||
VkPipelineLayout m_pipeline_layout{VK_NULL_HANDLE}; | ||
|
||
float m_scale{1.0f}; | ||
|
||
std::unique_ptr<wrapper::MeshBuffer<ImDrawVert, ImDrawIdx>> m_imgui_mesh; | ||
BufferResource *m_index_buffer{nullptr}; | ||
BufferResource *m_vertex_buffer{nullptr}; | ||
GraphicsStage *m_stage{nullptr}; | ||
|
||
std::unique_ptr<wrapper::GpuTexture> m_imgui_texture; | ||
std::unique_ptr<wrapper::RenderPass> m_renderpass; | ||
std::unique_ptr<wrapper::Shader> m_vert_shader; | ||
std::unique_ptr<wrapper::Shader> m_frag_shader; | ||
std::unique_ptr<wrapper::CommandPool> m_command_pool; | ||
std::unique_ptr<wrapper::Shader> m_vertex_shader; | ||
std::unique_ptr<wrapper::Shader> m_fragment_shader; | ||
std::unique_ptr<wrapper::ResourceDescriptor> m_descriptor; | ||
std::unique_ptr<wrapper::GraphicsPipeline> m_pipeline; | ||
std::unique_ptr<wrapper::Fence> m_ui_rendering_finished; | ||
|
||
std::uint32_t m_subpass{0}; | ||
std::uint32_t m_vertex_count{0}; | ||
std::uint32_t m_index_count{0}; | ||
std::vector<std::uint32_t> m_index_data; | ||
std::vector<ImDrawVert> m_vertex_data; | ||
|
||
std::vector<VkPipelineShaderStageCreateInfo> m_shaders; | ||
std::vector<std::unique_ptr<wrapper::CommandBuffer>> m_command_buffers; | ||
std::vector<std::unique_ptr<wrapper::Framebuffer>> m_framebuffers; | ||
|
||
// TODO: Implement an RAII wrapper for push constants! | ||
struct PushConstBlock { | ||
glm::vec2 scale; | ||
glm::vec2 translate; | ||
} m_push_const_block{}; | ||
|
||
public: | ||
/// @brief Default constructor | ||
/// @param device A reference to the device wrapper. | ||
/// @param swapchain A reference to the swapchain. | ||
ImGUIOverlay(const wrapper::Device &device, const wrapper::Swapchain &swapchain); | ||
/// @brief Construct a new ImGUI overlay. | ||
/// @param device A reference to the device wrapper | ||
/// @param swapchain A reference to the swapchain | ||
/// @param render_graph A pointer to the render graph | ||
/// @param back_buffer A pointer to the target of the ImGUI rendering | ||
ImGUIOverlay(const wrapper::Device &device, const wrapper::Swapchain &swapchain, RenderGraph *render_graph, | ||
TextureResource *back_buffer); | ||
ImGUIOverlay(const ImGUIOverlay &) = delete; | ||
ImGUIOverlay(ImGUIOverlay &&) noexcept = delete; | ||
ImGUIOverlay(ImGUIOverlay &&) = delete; | ||
~ImGUIOverlay(); | ||
|
||
ImGUIOverlay &operator=(const ImGUIOverlay &) = delete; | ||
ImGUIOverlay &operator=(ImGUIOverlay &&) = delete; | ||
|
||
[[nodiscard]] float get_scale() const { | ||
void update(); | ||
|
||
[[nodiscard]] float scale() const { | ||
return m_scale; | ||
} | ||
|
||
void update(); | ||
void render(std::uint32_t image_index); | ||
}; | ||
|
||
} // namespace inexor::vulkan_renderer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
include/inexor/vulkan-renderer/wrapper/graphics_pipeline.hpp
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.