Merge branch 'SP3-4-editor' into SP3-1-Rendering
This commit is contained in:
commit
a85df55fc9
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#define SHEDITOR
|
#define SHEDITOR
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
//#include "Editor/SHEditor.h"
|
#include "Editor/SHEditor.h"
|
||||||
//#include "Scenes/SBEditorScene.h"
|
//#include "Scenes/SBEditorScene.h"
|
||||||
#endif // SHEDITOR
|
#endif // SHEDITOR
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <ratio>
|
#include <ratio>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#define SDL_HINT_VIDEO_FOREIGN_WINDOW_VULKAN 1
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include "Scripting/SHScriptEngine.h"
|
#include "Scripting/SHScriptEngine.h"
|
||||||
|
@ -32,7 +33,7 @@ namespace Sandbox
|
||||||
// Set working directory
|
// Set working directory
|
||||||
SHADE::SHFileUtilities::SetWorkDirToExecDir();
|
SHADE::SHFileUtilities::SetWorkDirToExecDir();
|
||||||
|
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
SDL_Init(SDL_INIT_EVERYTHING);
|
||||||
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
||||||
SHADE::SHSystemManager::CreateSystem<SHADE::SHGraphicsSystem>();
|
SHADE::SHSystemManager::CreateSystem<SHADE::SHGraphicsSystem>();
|
||||||
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
|
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
|
||||||
|
@ -40,11 +41,13 @@ namespace Sandbox
|
||||||
|
|
||||||
|
|
||||||
graphicsSystem->SetWindow(&window);
|
graphicsSystem->SetWindow(&window);
|
||||||
SDL_CreateWindowFrom(window.GetHWND());
|
sdlWindow = SDL_CreateWindowFrom(window.GetHWND());
|
||||||
|
//auto [w, h] = window.GetWindowSize();
|
||||||
|
//SDL_SetWindowSize(sdlWindow, w, h);
|
||||||
|
|
||||||
SHADE::SHSystemManager::Init();
|
SHADE::SHSystemManager::Init();
|
||||||
#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
//SHADE::SHEditor::Initialize(window.GetHWND());
|
SHADE::SHEditor::Initialise(sdlWindow);
|
||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -60,15 +63,18 @@ namespace Sandbox
|
||||||
while (!window.WindowShouldClose())
|
while (!window.WindowShouldClose())
|
||||||
{
|
{
|
||||||
//#ifdef SHEDITOR
|
//#ifdef SHEDITOR
|
||||||
//SHADE::SHEditor::PreRender();
|
|
||||||
//#endif
|
//#endif
|
||||||
graphicsSystem->BeginRender();
|
graphicsSystem->BeginRender();
|
||||||
graphicsSystem->Run(1.0f);
|
|
||||||
//#ifdef SHEDITOR
|
#ifdef SHEDITOR
|
||||||
//SHADE::SHEditor::PreRender();
|
SHADE::SHEditor::PreRender();
|
||||||
//SHADE::SHEditor::Update();
|
|
||||||
//SHADE::SHEditor::Render();
|
//SHADE::SHEditor::Render();
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SHEDITOR
|
||||||
|
SHADE::SHEditor::Render();
|
||||||
|
#endif
|
||||||
|
graphicsSystem->Run(1.0f);
|
||||||
graphicsSystem->EndRender();
|
graphicsSystem->EndRender();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,12 +82,14 @@ namespace Sandbox
|
||||||
|
|
||||||
void SBApplication::Exit(void)
|
void SBApplication::Exit(void)
|
||||||
{
|
{
|
||||||
|
#ifdef SHEDITOR
|
||||||
|
SHADE::SHEditor::Exit();
|
||||||
|
#endif
|
||||||
|
|
||||||
SHADE::SHScriptEngine::Exit();
|
SHADE::SHScriptEngine::Exit();
|
||||||
SHADE::SHSystemManager::Exit();
|
SHADE::SHSystemManager::Exit();
|
||||||
SDL_DestroyWindow(sdlWindow);
|
SDL_DestroyWindow(sdlWindow);
|
||||||
#ifdef SHEDITOR
|
SDL_Quit();
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
#include "SHpch.h"
|
||||||
|
#include "SHEditor.h"
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
|
#include "Graphics/Instance/SHVkInstance.h"
|
||||||
|
#include "Graphics/MiddleEnd/Interface/SHGraphicsSystem.h"
|
||||||
|
#include "Graphics/Swapchain/SHVkSwapchain.h"
|
||||||
|
|
||||||
|
//IMGUI Backend includes
|
||||||
|
#include <backends/imgui_impl_sdl.h>
|
||||||
|
#include <backends/imgui_impl_vulkan.h>
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
Handle<SHVkCommandPool> SHEditor::imguiCommandPool;
|
||||||
|
Handle<SHVkCommandBuffer> SHEditor::imguiCommandBuffer;
|
||||||
|
|
||||||
|
void SHEditor::Initialise(SDL_Window* sdlWindow)
|
||||||
|
{
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
ImGui::CreateContext();
|
||||||
|
|
||||||
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
|
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||||
|
|
||||||
|
ImGui_ImplSDL2_InitForVulkan(sdlWindow);
|
||||||
|
|
||||||
|
auto* gfxSystem = reinterpret_cast<SHGraphicsSystem*>(SHSystemManager::GetSystem<SHGraphicsSystem>());
|
||||||
|
|
||||||
|
ImGui_ImplVulkan_InitInfo initInfo{};
|
||||||
|
initInfo.Instance = SHVkInstance::GetVkInstance();
|
||||||
|
initInfo.PhysicalDevice = gfxSystem->GetPhysicalDevice()->GetVkPhysicalDevice();
|
||||||
|
initInfo.Device = gfxSystem->GetDevice()->GetVkLogicalDevice();
|
||||||
|
initInfo.Queue = gfxSystem->GetQueue()->GetVkQueue();
|
||||||
|
initInfo.DescriptorPool = gfxSystem->GetDescriptorPool()->GetVkHandle();
|
||||||
|
initInfo.MinImageCount = initInfo.ImageCount = gfxSystem->GetSwapchain()->GetNumImages();
|
||||||
|
initInfo.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
|
|
||||||
|
imguiCommandPool = gfxSystem->GetDevice()->CreateCommandPool(SH_QUEUE_FAMILY_ARRAY_INDEX::GRAPHICS, SH_CMD_POOL_RESET::POOL_BASED, true);
|
||||||
|
imguiCommandBuffer = imguiCommandPool->RequestCommandBuffer(SH_CMD_BUFFER_TYPE::PRIMARY);
|
||||||
|
|
||||||
|
auto renderPass = gfxSystem->GetRenderGraph().GetNode("ImGui Node")->GetRenderpass();
|
||||||
|
ImGui_ImplVulkan_Init(&initInfo, renderPass->GetVkRenderpass());
|
||||||
|
|
||||||
|
imguiCommandBuffer->BeginRecording();
|
||||||
|
ImGui_ImplVulkan_CreateFontsTexture(imguiCommandBuffer->GetVkCommandBuffer());
|
||||||
|
imguiCommandBuffer->EndRecording();
|
||||||
|
gfxSystem->GetQueue()->SubmitCommandBuffer({imguiCommandBuffer}, {}, {}, vk::PipelineStageFlagBits::eNone, {});
|
||||||
|
|
||||||
|
ImGui_ImplVulkan_DestroyFontUploadObjects();
|
||||||
|
|
||||||
|
gfxSystem->GetRenderGraph().GetNode("ImGui Node")->GetSubpass("ImGui Draw")->AddExteriorDrawCalls([](Handle<SHVkCommandBuffer>& cmd) {
|
||||||
|
ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), cmd->GetVkCommandBuffer());
|
||||||
|
});
|
||||||
|
|
||||||
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
|
//int w, h;
|
||||||
|
//SDL_GetWindowSize(sdlWindow, &w, &h);
|
||||||
|
//io.DisplaySize = { static_cast<float>(w),static_cast<float>(h)};
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditor::PreRender()
|
||||||
|
{
|
||||||
|
NewFrame();
|
||||||
|
|
||||||
|
ImGui::ShowDemoWindow();
|
||||||
|
ImGui::Begin("Your mom");
|
||||||
|
if (ImGui::Button("OP"))
|
||||||
|
{
|
||||||
|
std::cout << "HEHEHEOHEIOHIEOH\n";
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditor::Render()
|
||||||
|
{
|
||||||
|
ImGui::Render();
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
|
{
|
||||||
|
ImGui::UpdatePlatformWindows();
|
||||||
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditor::Exit()
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_Shutdown();
|
||||||
|
ImGui_ImplSDL2_Shutdown();
|
||||||
|
ImGui::DestroyContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SHEditor::InitBackend()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditor::NewFrame()
|
||||||
|
{
|
||||||
|
ImGui_ImplVulkan_NewFrame();
|
||||||
|
ImGui_ImplSDL2_NewFrame();
|
||||||
|
ImGui::NewFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditor::EndFrame()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SH_API.h"
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include "Resource/Handle.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
class SHVkCommandBuffer;
|
||||||
|
class SHVkCommandPool;
|
||||||
|
|
||||||
|
class SH_API SHEditor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void Initialise(SDL_Window* sdlWindow);
|
||||||
|
static void PreRender();
|
||||||
|
static void Render();
|
||||||
|
static void Exit();
|
||||||
|
private:
|
||||||
|
static void InitBackend();
|
||||||
|
static void NewFrame();
|
||||||
|
static void EndFrame();
|
||||||
|
|
||||||
|
static Handle<SHVkCommandPool> imguiCommandPool;
|
||||||
|
static Handle<SHVkCommandBuffer> imguiCommandBuffer;
|
||||||
|
};
|
||||||
|
}
|
|
@ -104,13 +104,17 @@ namespace SHADE
|
||||||
// First subpass to write to G-Buffer
|
// First subpass to write to G-Buffer
|
||||||
auto writeSubpass = node->AddSubpass("G-Buffer Write");
|
auto writeSubpass = node->AddSubpass("G-Buffer Write");
|
||||||
writeSubpass->AddColorOutput("Position");
|
writeSubpass->AddColorOutput("Position");
|
||||||
writeSubpass->AddColorOutput("Present");
|
//writeSubpass->AddColorOutput("Present");
|
||||||
|
|
||||||
// Second subpass to read from G-Buffer
|
// Second subpass to read from G-Buffer
|
||||||
auto compositeSubpass = node->AddSubpass("G-Buffer Composite");
|
//auto compositeSubpass = node->AddSubpass("G-Buffer Composite");
|
||||||
compositeSubpass->AddColorOutput("Composite");
|
// compositeSubpass->AddColorOutput("Composite");
|
||||||
compositeSubpass->AddInput("Normals");
|
// compositeSubpass->AddInput("Normals");
|
||||||
compositeSubpass->AddInput("Position");
|
// compositeSubpass->AddInput("Position");
|
||||||
|
|
||||||
|
auto imguiNode = renderGraph.AddNode("ImGui Node", { "Present" }, {}); // no predecessors
|
||||||
|
auto imguiSubpass = imguiNode->AddSubpass("ImGui Draw");
|
||||||
|
imguiSubpass->AddColorOutput("Present");
|
||||||
|
|
||||||
//auto compositeNode = renderGraph.AddNode("Bloom", { "Composite", "Downscale", "Present" }, { "G-Buffer" });
|
//auto compositeNode = renderGraph.AddNode("Bloom", { "Composite", "Downscale", "Present" }, { "G-Buffer" });
|
||||||
//auto bloomSubpass = compositeNode->AddSubpass("Downsample");
|
//auto bloomSubpass = compositeNode->AddSubpass("Downsample");
|
||||||
|
|
|
@ -147,6 +147,7 @@ namespace SHADE
|
||||||
SHRenderContext renderContext;
|
SHRenderContext renderContext;
|
||||||
//std::array<Handle<SHVkFramebuffer>, NUM_FRAME_BUFFERS> frameBuffers;
|
//std::array<Handle<SHVkFramebuffer>, NUM_FRAME_BUFFERS> frameBuffers;
|
||||||
//std::array<Handle<SHVkCommandBuffer>, NUM_FRAME_BUFFERS> commandBuffers;
|
//std::array<Handle<SHVkCommandBuffer>, NUM_FRAME_BUFFERS> commandBuffers;
|
||||||
|
|
||||||
// Not Owned Resources
|
// Not Owned Resources
|
||||||
SHWindow* window;
|
SHWindow* window;
|
||||||
// Renderers
|
// Renderers
|
||||||
|
|
|
@ -124,4 +124,9 @@ namespace SHADE
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vk::Queue SHVkQueue::GetVkQueue() noexcept
|
||||||
|
{
|
||||||
|
return vkQueue;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -49,6 +49,7 @@ namespace SHADE
|
||||||
|
|
||||||
void SubmitCommandBuffer (std::initializer_list<Handle<SHVkCommandBuffer>> cmdBuffers, std::initializer_list<Handle<SHVkSemaphore>> signalSems = {}, std::initializer_list<Handle<SHVkSemaphore>> waitSems = {}, vk::PipelineStageFlags waitDstStageMask = {}, Handle<SHVkFence> const& fence = {}) noexcept;
|
void SubmitCommandBuffer (std::initializer_list<Handle<SHVkCommandBuffer>> cmdBuffers, std::initializer_list<Handle<SHVkSemaphore>> signalSems = {}, std::initializer_list<Handle<SHVkSemaphore>> waitSems = {}, vk::PipelineStageFlags waitDstStageMask = {}, Handle<SHVkFence> const& fence = {}) noexcept;
|
||||||
vk::Result Present (Handle<SHVkSwapchain> const& swapchain, std::initializer_list<Handle<SHVkSemaphore>> waitSems, uint32_t frameIndex) noexcept;
|
vk::Result Present (Handle<SHVkSwapchain> const& swapchain, std::initializer_list<Handle<SHVkSemaphore>> waitSems, uint32_t frameIndex) noexcept;
|
||||||
|
vk::Queue GetVkQueue() noexcept;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -583,6 +583,11 @@ namespace SHADE
|
||||||
return renderpass;
|
return renderpass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Handle<SHRenderGraphNode::SHSubpass> SHRenderGraphNode::GetSubpass(std::string_view subpassName) const noexcept
|
||||||
|
{
|
||||||
|
return subpasses[subpassIndexing.at(subpassName.data())];
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ namespace SHADE
|
||||||
/* SETTERS AND GETTERS */
|
/* SETTERS AND GETTERS */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
Handle<SHVkRenderpass> GetRenderpass (void) const noexcept;
|
Handle<SHVkRenderpass> GetRenderpass (void) const noexcept;
|
||||||
|
Handle<SHSubpass> GetSubpass(std::string_view subpassName) const noexcept;
|
||||||
friend class SHRenderGraph;
|
friend class SHRenderGraph;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue