2
3
4
5
9#include "Systems/SlateSystem.h"
10#include "Debugger/Perf/NsightPerfGPUProfilerHUD.h"
11#include "Core/Library/FileLibrary.h"
18 const std::string& rendererName ,
24 :
Renderer(rendererName
, vulkanState
, descriptorPool
, device
, rendererResourcePool
)
28 m_SlatePipelinesPtr = &m_Pipelines;
36 RendererPassBuilder{
"Slate",
this }
38 .AddSwapChainAttachment([](VkAttachmentDescription& description) {
39 description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
40 description.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
48 DescriptorSetBuilder{
"Slate",
this }
50 .AddTexture<Texture2D>(0, 0, VK_SHADER_STAGE_FRAGMENT_BIT, {
"default.jpg"})
56 VkPipelineLayout& layout ,
60 PipelineBuilder{ subPass, material,
this }
62 .SetBindingDescriptions(InputAssembly::GetSlateBindingDescriptions())
63 .SetAttributeDescriptions(InputAssembly::GetSlateAttributeDescriptions())
66 .SetPipelineLayout(layout)
67 .SetCullMode(VK_CULL_MODE_NONE)
68 .SetColorAttachments()
77
78
82
83
92
93
102
103
104
105 ImGui::CreateContext();
108
109
110 ImPlot::CreateContext();
113
114
115
116 ImGuiIO& io = ImGui::GetIO();
118 FileLibrary::FileLibrary_CopyFile(
119 SPICES_ENGINE_ASSETS_PATH +
"SlateLayout/DefaultLayout.ini",
124
125
126
127 io.IniFilename =
"DefaultLayout.ini";
128 io.LogFilename =
nullptr;
129 io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
130 io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
131 io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
137
138
142
143
144 ImGui_ImplVulkan_InitInfo init_info = {};
145 init_info.Instance = m_VulkanState.m_Instance;
146 init_info.PhysicalDevice = m_VulkanState.m_PhysicalDevice;
147 init_info.Device = m_VulkanState.m_Device;
148 init_info.QueueFamily = m_VulkanState.m_GraphicQueueFamily;
149 init_info.Queue = m_VulkanState.m_GraphicQueue;
150 init_info.PipelineCache = VK_NULL_HANDLE;
151 init_info.DescriptorPool = m_DescriptorPool->GetPool();
152 init_info.RenderPass = m_Pass->Get();
153 init_info.Subpass = 0;
154 init_info.MinImageCount = MaxFrameInFlight;
155 init_info.ImageCount = MaxFrameInFlight;
156 init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
157 init_info.Allocator = VK_NULL_HANDLE;
158 init_info.CheckVkResultFn = [](VkResult result) {
VK_CHECK(result); };
161
162
163 ImGui_ImplVulkan_Init(&init_info);
166
167
168 ImGui_ImplVulkan_CreateFontsTexture();
171
172
173 NSIGHTPERF_GPUPROFILERHUD_INITHUDRENDERER;
182 NSIGHTPERF_GPUPROFILERHUD_RESET
184 ImGui_ImplVulkan_Shutdown();
185 ImGui_ImplGlfw_Shutdown();
186 ImPlot::DestroyContext();
187 ImGui::DestroyContext();
197 ImGui_ImplVulkan_NewFrame();
203 ImGui_ImplGlfw_NewFrame();
216 ImGuizmo::BeginFrame();
222 NSIGHTPERF_GPUPROFILERHUD_FRAMECONSUME
230 const ImGuiIO& io = ImGui::GetIO();
233 ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), m_VulkanState.m_GraphicCommandBuffer[index]);
235 if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
237 ImGui::UpdatePlatformWindows();
238 ImGui::RenderPlatformWindowsDefault();
246 const ImGuiIO& io = ImGui::GetIO();
250 SubmitCmdsParallel(
m_VulkanState.m_GraphicCommandBuffer[index], 0, [&](VkCommandBuffer cmdBuffer) {
251 ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), cmdBuffer);
254 if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
256 ImGui::UpdatePlatformWindows();
257 ImGui::RenderPlatformWindowsDefault();
269 SlateSystem::GetRegister()->OnRender();
282 return m_SlatePipelinesPtr->Find(name);
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
#define VK_CHECK(expr)
Vulkan Check macro. Verify Vulkan API Effectiveness.
This Class manages all descriptor sets this project.
uint32_t m_FrameIndex
FrameIndex, varying during 0 - (MaxFrameInFlight - 1). Used almost anywhere.
uint32_t m_ImageIndex
ImageIndex, varying during 0 - (MaxFrameInFlight - 1). Used in swapchain index and framebuffer index.
FrameInfo Class. This class defines the FrameInfo data.
static void SetFonts(FontMode fontmode=FontMode::FONT_PROPORTIONAL_SCALED)
Looking for TTF fonts, first on the VULKAN SDK, then Windows default fonts.
static void SetStyle()
Setting common style across samples.
static void MainDockSpace(Side side=Side::Scene, float alpha=1.0f)
Begin a docking space.
The ImGuiH Class. This class defines helper function for slate render.
Material Class. This class contains a branch of parameter and shader, also descriptor.
RendererResourcePool Class. This class is a pool of all framebuffer's attachment.
This Class Combines some data relative to sub pass. Usually as a member variable of RendererPass.
virtual void BeginRenderPass()
Begin this Renderer's RenderPass.
virtual void EndRenderPass()
End this Renderer's RenderPass.
This class helps to bind pipeline and bind buffer. Only instanced during Render().
RendererPassBuilder & EndSubPass()
End recording a sub pass.
void Build() const
Build the RendererPass.
RendererPassBuilder & AddSubPass(const std::string &subPassName, Querier::StatisticsFlags flags=Querier::ALL)
Add a new SubPass to Renderer Pass.
virtual void OnSlateResize()
Renderer(const std::string &rendererName, VulkanState &vulkanState, const std::shared_ptr< VulkanDescriptorPool > &DescriptorPool, const std::shared_ptr< VulkanDevice > &device, const std::shared_ptr< RendererResourcePool > &rendererResourcePool, bool isLoadDefaultMaterial=true)
Constructor Function. Init member variables.
DescriptorSetManager::DescriptorSetCombineFlags m_DescriptorSetCombine
Combination of DescriptorSet.
virtual void OnSystemInitialize()
This interface is called on render system is registered. Initialize the specific renderer's pipeline,...
VulkanState & m_VulkanState
This variable is passed while renderer instanced.
Renderer Class. This class defines the basic behaves of renderer. When we add an new Renderer,...
void InitImgui() const
Init Imgui.
virtual void OnWindowResizeOver() override
This interface is called on Window resized over (registry by swapchain). If the specific renderer use...
virtual void CreatePipeline(std::shared_ptr< Material > material, VkPipelineLayout &layout, std::shared_ptr< RendererSubPass > subPass) override
The interface is inherited from Renderer. Create Material Specific Pipeline.
void BeginImguiFrame()
Begin Imgui frame.
virtual void CreateRendererPass() override
The interface is inherited from Renderer. Create specific render pass.
SlateRenderer(const std::string &rendererName, VulkanState &vulkanState, const std::shared_ptr< VulkanDescriptorPool > &descriptorPool, const std::shared_ptr< VulkanDevice > &device, const std::shared_ptr< RendererResourcePool > &rendererResourcePool)
Constructor Function. Init member variables.
virtual void OnSystemInitialize() override
Rewrite Renderer OnSystemInitialize to add other code.
void ShutdownImgui()
Shutdown Imgui.
virtual void CreateDescriptorSet() override
The interface is inherited from Renderer. Create specific descriptor set for sub pass.
void EndImguiFrame(uint32_t index) const
End Imgui frame.
virtual void Render(TimeStep &ts, FrameInfo &frameInfo) override
The interface is inherited from Renderer.
static std::shared_ptr< VulkanPipeline > GetPipeline(const std::string &name)
Get slate material pipeline.
void EndImguiFrameAsync(uint32_t index)
End Imgui frame.
SlateRenderer Class. This class defines the imgui render behaves.
This Class handles our engine time step during frames. Global Unique.
VulkanDescriptorPool Class. This class is the wrapper of VkDescriptorPool.
VulkanInstance Class. This class defines the VulkanDevice behave. This class is just a wrapper of vkd...
This class is a wrapper of VkPipelineLayout and VkPipeline.
Thread safe unordered_map.
static scl::thread_unordered_map< std::string, std::shared_ptr< VulkanPipeline > > * m_SlatePipelinesPtr
This struct contains all Vulkan object in used global.