Tracy MVP integration

This commit is contained in:
WiggleWizard
2024-09-02 20:37:47 +01:00
parent d20847b4e3
commit 5a801e642c
23 changed files with 202 additions and 30 deletions

3
.gitmodules vendored
View File

@@ -22,3 +22,6 @@
[submodule "Nuake/dependencies/recastnavigation"]
path = Nuake/dependencies/recastnavigation
url = https://github.com/antopilo/recastnavigation.git
[submodule "Nuake/dependencies/tracy"]
path = Nuake/dependencies/tracy
url = https://github.com/wolfpld/tracy.git

View File

@@ -5,6 +5,7 @@
#include <src/Resource/ResourceLoader.h>
#include <glad/glad.h>
#include <src/Resource/Prefab.h>
#include <Tracy.hpp>
ThumbnailManager::ThumbnailManager()
@@ -39,6 +40,8 @@ bool ThumbnailManager::IsThumbnailLoaded(const std::string& path) const
Ref<Nuake::Texture> ThumbnailManager::GetThumbnail(const std::string& path)
{
ZoneScoped;
if (IsThumbnailLoaded(path))
{
return m_Thumbnails[path];
@@ -71,6 +74,9 @@ void ThumbnailManager::MarkThumbnailAsDirty(const std::string & path)
Ref<Nuake::Texture> ThumbnailManager::GenerateThumbnail(const std::string& path, Ref<Nuake::Texture> texture)
{
ZoneScopedN("GenerateThumbnail");
ZoneText(path.c_str(), path.size());
using namespace Nuake;
const Matrix4 ortho = glm::orthoLH(-0.6f, 0.6f, -0.6f, 0.6f, -100.0f, 100.0f);

View File

@@ -56,6 +56,7 @@
#include <src/Resource/ModelLoader.h>
#include "../ScriptingContext/ScriptingContext.h"
#include <src/Scene/Components/BSPBrushComponent.h>
#include <Tracy.hpp>
namespace Nuake {
@@ -2900,6 +2901,8 @@ namespace Nuake {
int frameCount = 2;
void EditorInterface::Draw()
{
ZoneScoped;
Init();
if (isCreatingNewProject && !_NewProjectWindow->HasCreatedProject())
@@ -3014,6 +3017,8 @@ namespace Nuake {
void EditorInterface::Update(float ts)
{
ZoneScoped;
if (!Engine::GetCurrentScene() || Engine::IsPlayMode())
{
return;

View File

@@ -15,6 +15,7 @@
#include "src/Scene/Systems/WadConverter.h"
#include "../Misc/ThumbnailManager.h"
#include <Tracy.hpp>
namespace Nuake
{
@@ -64,6 +65,8 @@ namespace Nuake
void FileSystemUI::DrawDirectory(Ref<Directory> directory, uint32_t drawId)
{
ZoneScoped;
ImGui::PushFont(FontManager::GetFont(Icons));
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
const char* icon = ICON_FA_FOLDER;
@@ -226,6 +229,8 @@ namespace Nuake
void FileSystemUI::DrawFile(Ref<File> file, uint32_t drawId)
{
ZoneScoped;
ImGui::PushFont(EditorInterface::bigIconFont);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, {0.f, 0.f});

View File

@@ -15,6 +15,7 @@
#include <imgui/imgui_impl_glfw.h>
#include <imgui/imgui_impl_opengl3.h>
#include <Tracy.hpp>
namespace Nuake
{
@@ -49,6 +50,8 @@ namespace Nuake
void Engine::Tick()
{
ZoneScoped;
JobSystem::Get().Update();
@@ -120,12 +123,18 @@ namespace Nuake
void Engine::Draw()
{
ZoneScoped;
RenderCommand::Clear();
// Start imgui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
{
ZoneScopedN("ImGui New Frame");
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
}
// Draw scene
Window::Get()->Draw();
@@ -133,6 +142,7 @@ namespace Nuake
void Engine::EndDraw()
{
ZoneScoped;
Window::Get()->EndDraw();
}

View File

@@ -0,0 +1,30 @@
group "Dependencies"
project 'Tracy'
location "tracy"
kind "StaticLib"
staticruntime "on"
warnings 'Off'
includedirs {
"tracy/public/tracy"
}
files {
"tracy/public/tracy/Tracy.hpp",
"tracy/public/TracyClient.cpp"
}
defines {
"TRACY_ENABLE",
"TRACY_ON_DEMAND",
}
filter "configurations:Debug"
runtime "Debug"
symbols "on"
filter "configurations:Release"
runtime "Release"
optimize "on"
group ""

View File

@@ -3,6 +3,8 @@
#include <filesystem>
#include <Tracy.hpp>
namespace Nuake {
Application::Application(const ApplicationSpecification& appSpecification)
@@ -33,8 +35,11 @@ namespace Nuake {
{
while (!m_Window->ShouldClose())
{
ZoneScoped;
for (auto& layer : m_LayerStack)
{
ZoneScopedN("Layer Update");
layer->OnUpdate();
}
@@ -42,9 +47,12 @@ namespace Nuake {
{
for (auto& layer : m_LayerStack)
{
ZoneScopedN("Layer Draw");
layer->OnDraw();
}
}
FrameMark;
}
}

View File

@@ -3,6 +3,7 @@
#include <imgui/imgui_impl_glfw.h>
#include <GLFW/glfw3.h>
#include <Tracy.hpp>
namespace Nuake
{
@@ -167,6 +168,8 @@ namespace Nuake
void Input::Update()
{
ZoneScoped;
// Reset all input to false.
for (auto& k : m_Keys)
{

View File

@@ -1,5 +1,6 @@
#include "Framebuffer.h"
#include <glad/glad.h>
#include <Tracy.hpp>
namespace Nuake
{
@@ -84,6 +85,8 @@ namespace Nuake
void FrameBuffer::QueueResize(Vector2 size)
{
ZoneScoped;
if (size == m_Size)
return;

View File

@@ -9,6 +9,7 @@
#include <random>
#include <src/Vendors/imgui/imgui.h>
#include <Tracy.hpp>
namespace Nuake
{
@@ -32,6 +33,8 @@ namespace Nuake
void SSAO::Resize(const Vector2& size)
{
ZoneScoped;
if (_size == size)
return;
@@ -42,6 +45,8 @@ namespace Nuake
void SSAO::Clear()
{
ZoneScoped;
_ssaoBlurFramebuffer->Bind();
{
RenderCommand::SetClearColor({ 1, 1, 1, 1});
@@ -96,6 +101,8 @@ namespace Nuake
void SSAO::Draw(FrameBuffer* gBuffer, const Matrix4& projection, const Matrix4& view)
{
ZoneScoped;
_ssaoFramebuffer->Bind();
{
_ssaoFramebuffer->Clear();

View File

@@ -3,6 +3,7 @@
#include "src/Rendering/Renderer.h"
#include <glad/glad.h>
#include <src/Vendors/imgui/imgui.h>
#include <Tracy.hpp>
namespace Nuake {
Volumetric::Volumetric()
{
@@ -37,6 +38,8 @@ namespace Nuake {
void Volumetric::Draw(Matrix4 projection, Matrix4 view, const Vector3& camPos, std::vector<LightComponent>& lights)
{
ZoneScoped;
mVolumetricFramebuffer->Bind();
{
mVolumetricFramebuffer->Clear();

View File

@@ -17,6 +17,7 @@
#include "src/Rendering/Textures/MaterialManager.h"
#include "src/Rendering/Vertex.h"
#include <imgui/imgui.h>
#include <Tracy.hpp>
namespace Nuake
{
@@ -254,6 +255,8 @@ namespace Nuake
int spotShadowMapCount = 0;
void Renderer::EndDraw()
{
ZoneScoped;
Shader* deferredShader = ShaderManager::GetShader("Resources/Shaders/deferred.shader");
deferredShader->Bind();
deferredShader->SetUniform1i("LightCount", 0);
@@ -418,6 +421,8 @@ namespace Nuake
void Renderer::DrawQuad(Matrix4 transform)
{
ZoneScoped;
QuadMesh->Bind();
RenderCommand::DrawArrays(0, 6);
}

View File

@@ -8,6 +8,7 @@
#include <glad/glad.h>
#include <src/Scene/Components/SkinnedModelComponent.h>
#include <src/Vendors/imgui/imgui.h>
#include <Tracy.hpp>
namespace Nuake
@@ -128,6 +129,8 @@ namespace Nuake
/// <param name="framebuffer">Framebuffer to render the scene to. Should be in the right size</param>
void SceneRenderer::RenderScene(Scene& scene, FrameBuffer& framebuffer)
{
ZoneScoped;
// Renders all shadow maps
ShadowPass(scene);
@@ -483,6 +486,8 @@ namespace Nuake
void SceneRenderer::ShadowPass(Scene& scene)
{
ZoneScoped;
RenderCommand::Enable(RendererEnum::DEPTH_TEST);
Shader* shader = ShaderManager::GetShader("Resources/Shaders/shadowMap.shader");
@@ -729,6 +734,8 @@ namespace Nuake
void SceneRenderer::GBufferPass(Scene& scene)
{
ZoneScoped;
mGBuffer->Bind();
mGBuffer->Clear();
{
@@ -933,6 +940,8 @@ namespace Nuake
void SceneRenderer::ShadingPass(Scene& scene)
{
ZoneScoped;
mShadingBuffer->Bind();
mShadingBuffer->Clear();
{
@@ -1035,6 +1044,8 @@ namespace Nuake
void SceneRenderer::DebugRendererPass(Scene& scene)
{
ZoneScoped;
mShadingBuffer->Bind();
{
// Lines

View File

@@ -2,6 +2,7 @@
#include "src/Core/Logger.h"
#include "src/Resource/StaticResources.h"
#include <Tracy.hpp>
#define LoadEmbeddedShader(file) \
m_Shaders[file##_path] = CreateScope<Shader>(file##_path, std::string(reinterpret_cast<const char*>(file), reinterpret_cast<const char*>(file) + file##_len));
@@ -48,6 +49,8 @@ namespace Nuake
Shader* ShaderManager::GetShader(const std::string& path)
{
ZoneScoped;
if (m_Shaders.find(path) == m_Shaders.end())
{
m_Shaders[path] = CreateScope<Shader>(path);

View File

@@ -34,6 +34,7 @@
#include <future>
#include <streambuf>
#include <chrono>
#include <Tracy.hpp>
namespace Nuake
@@ -261,6 +262,8 @@ namespace Nuake
void Scene::Update(Timestep ts)
{
ZoneScoped;
const auto& view = m_Registry.view<QuakeMapComponent>();
for (const auto& e : view)
{
@@ -280,6 +283,7 @@ namespace Nuake
for (auto& system : m_Systems)
{
ZoneScopedN("System Update");
system->Update(ts);
}
@@ -301,6 +305,8 @@ namespace Nuake
void Scene::Draw(FrameBuffer& framebuffer)
{
ZoneScoped;
Ref<Camera> cam = nullptr;
const auto& view = m_Registry.view<TransformComponent, CameraComponent, ParentComponent>();
for (const auto& e : view)

View File

@@ -1,4 +1,5 @@
#include "Job.h"
#include <Tracy.hpp>
namespace Nuake {
@@ -10,6 +11,7 @@ namespace Nuake {
m_Thread = std::thread([this, job]()
{
ZoneScoped;
job();
m_IsDone = true;
});

View File

@@ -0,0 +1,26 @@
#include "JobSystem.h"
#include <Tracy.hpp>
namespace Nuake {
void JobSystem::Update()
{
ZoneScoped;
for(auto it = m_Jobs.begin(); it != m_Jobs.end();)
{
if(it->get()->IsDone())
{
it->get()->End();
it = m_Jobs.erase(it);
}
else
{
++it;
}
}
}
}

View File

@@ -24,20 +24,6 @@ namespace Nuake {
m_Jobs.push_back(std::make_unique<Job>(job, end));
}
void Update()
{
for (auto it = m_Jobs.begin(); it != m_Jobs.end();)
{
if (it->get()->IsDone())
{
it->get()->End();
it = m_Jobs.erase(it);
}
else
{
++it;
}
}
}
void Update();
};
}

View File

@@ -17,6 +17,7 @@
#include <imgui/imgui.h>
#include <imgui/imgui_impl_glfw.h>
#include <imgui/imgui_impl_opengl3.h>
#include <Tracy.hpp>
namespace Nuake
{
@@ -127,6 +128,8 @@ namespace Nuake
void Window::Draw()
{
ZoneScoped;
// Dont render if no scene is loaded.
if (!m_Scene)
{
@@ -152,10 +155,12 @@ namespace Nuake
if (Engine::IsPlayMode())
{
ZoneScopedN("PIE Draw");
m_Scene->Draw(*m_Framebuffer.get());
}
else
{
ZoneScopedN("Non-playmode Draw");
m_Scene->Draw(*m_Framebuffer.get(), m_Scene->m_EditorCamera->GetPerspective(), m_Scene->m_EditorCamera->GetTransform());
}
@@ -165,8 +170,15 @@ namespace Nuake
void Window::EndDraw()
{
ImGui::EndFrame();
ImGui::Render();
{
ZoneScopedN("ImGui::EndFrame");
ImGui::EndFrame();
}
{
ZoneScopedN("ImGui::Render");
ImGui::Render();
}
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
@@ -178,8 +190,12 @@ namespace Nuake
glfwMakeContextCurrent(backup_current_context);
}
{
ZoneScopedN("SwapBuffers");
glfwSwapBuffers(m_Window);
}
glfwSwapBuffers(m_Window);
ZoneScopedN("glfwPollEvents");
glfwPollEvents();
}

View File

@@ -3,6 +3,7 @@
//#include <dependencies/GLEW/include/GL/glew.h>
#include <src/Vendors/imgui/imgui.h>
#include <Tracy.hpp>
#include <string>
#include <src/Rendering/Renderer2D.h>
@@ -158,6 +159,8 @@ int ApplicationMain(int argc, char* argv[])
ImGui::PopStyleVar(2);
Engine::EndDraw();
FrameMark;
}
}

View File

@@ -43,6 +43,10 @@ workspace "Nuake"
architecture "x64"
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
local globalDefines = {
"TRACY_ENABLE",
"TRACY_ON_DEMAND"
}
group "Dependencies"
include "Nuake/dependencies/glfw_p5.lua"
@@ -52,6 +56,7 @@ group "Dependencies"
include "Nuake/dependencies/soloud_p5.lua"
include "Nuake/dependencies/coral_p5.lua"
include "Nuake/dependencies/recastnavigation_p5.lua"
include "Nuake/dependencies/tracy_p5.lua"
group ""
include "NuakeNet/premake5.lua"
@@ -79,8 +84,10 @@ project "Nuake"
defines
{
table.unpack(globalDefines),
"_MBCS",
"IMGUI_DEFINE_MATH_OPERATORS"
"IMGUI_DEFINE_MATH_OPERATORS",
}
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
@@ -152,12 +159,15 @@ project "Nuake"
"%{prj.name}/dependencies/recastnavigation/Detour/Include",
"%{prj.name}/dependencies/recastnavigation/DetourCrowd/Include",
"%{prj.name}/dependencies/recastnavigation/DetourTileCache/Include",
"%{prj.name}/dependencies/recastnavigation/Recast/Include"
"%{prj.name}/dependencies/recastnavigation/Recast/Include",
"%{prj.name}/../Nuake/dependencies/tracy/public/tracy",
}
links
{
"soloud"
"soloud",
"tracy"
}
filter "system:linux"
@@ -194,6 +204,8 @@ project "Nuake"
runtime "Debug"
symbols "on"
buildoptions { "/Zi" }
filter "configurations:Release"
runtime "Release"
optimize "on"
@@ -231,7 +243,9 @@ project "NuakeRuntime"
"%{prj.name}/../Nuake/dependencies/recastnavigation/Detour/Include",
"%{prj.name}/../Nuake/dependencies/recastnavigation/DetourCrowd/Include",
"%{prj.name}/../Nuake/dependencies/recastnavigation/DetourTileCache/Include",
"%{prj.name}/../Nuake/dependencies/recastnavigation/Recast/Include"
"%{prj.name}/../Nuake/dependencies/recastnavigation/Recast/Include",
"%{prj.name}/../Nuake/dependencies/tracy/public/tracy",
}
libdirs
@@ -257,7 +271,12 @@ project "NuakeRuntime"
"Detour",
"DetourCrowd",
"DetourTileCache",
"Recast"
"Recast",
"tracy",
}
defines {
table.unpack(globalDefines)
}
filter "system:windows"
@@ -309,6 +328,8 @@ project "NuakeRuntime"
"NK_DEBUG"
}
buildoptions { "/Zi" }
filter "configurations:Release"
kind "WindowedApp"
runtime "Release"
@@ -365,7 +386,9 @@ project "Editor"
"%{prj.name}/../Nuake/dependencies/recastnavigation/Detour/Include",
"%{prj.name}/../Nuake/dependencies/recastnavigation/DetourCrowd/Include",
"%{prj.name}/../Nuake/dependencies/recastnavigation/DetourTileCache/Include",
"%{prj.name}/../Nuake/dependencies/recastnavigation/Recast/Include"
"%{prj.name}/../Nuake/dependencies/recastnavigation/Recast/Include",
"%{prj.name}/../Nuake/dependencies/tracy/public/tracy",
}
libdirs
@@ -392,7 +415,12 @@ project "Editor"
"Detour",
"DetourCrowd",
"DetourTileCache",
"Recast"
"Recast",
"tracy",
}
defines {
table.unpack(globalDefines)
}
filter "system:Windows"
@@ -461,6 +489,8 @@ project "Editor"
"IMGUI_DEFINE_MATH_OPERATORS"
}
buildoptions { "/Zi" }
filter "configurations:Release"
runtime "Release"
optimize "on"