Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 56 additions & 28 deletions Source/Game-Lib/Game-Lib/Application/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ void Application::Run()
ECS::Singletons::FrameTimes timings;
while (true)
{
ZoneScoped;
f32 deltaTime = timer.GetDeltaTime();
timer.Tick();

Expand All @@ -192,42 +193,48 @@ void Application::Run()
if (!Render(deltaTime, timeSpentWaiting))
break;

timings.renderFrameTimeS = renderTimer.GetLifeTime() - timeSpentWaiting;
timings.renderWaitTimeS = timeSpentWaiting;
{
ZoneScopedN("TimeQueries");
timings.renderFrameTimeS = renderTimer.GetLifeTime() - timeSpentWaiting;
timings.renderWaitTimeS = timeSpentWaiting;

// Get last GPU Frame time
Renderer::Renderer* renderer = _gameRenderer->GetRenderer();
// Get last GPU Frame time
Renderer::Renderer* renderer = _gameRenderer->GetRenderer();

const std::vector<Renderer::TimeQueryID> frameTimeQueries = renderer->GetFrameTimeQueries();
if (frameTimeQueries.size() > 0)
{
for (Renderer::TimeQueryID timeQueryID : frameTimeQueries)
const std::vector<Renderer::TimeQueryID> frameTimeQueries = renderer->GetFrameTimeQueries();
if (frameTimeQueries.size() > 0)
{
const std::string& name = renderer->GetTimeQueryName(timeQueryID);
f32 durationMS = renderer->GetLastTimeQueryDuration(timeQueryID);
for (Renderer::TimeQueryID timeQueryID : frameTimeQueries)
{
const std::string& name = renderer->GetTimeQueryName(timeQueryID);
f32 durationMS = renderer->GetLastTimeQueryDuration(timeQueryID);

engineStats.AddNamedStat(name, durationMS);
}

engineStats.AddNamedStat(name, durationMS);
Renderer::TimeQueryID totalTimeQuery = frameTimeQueries[0];
timings.gpuFrameTimeMS = renderer->GetLastTimeQueryDuration(totalTimeQuery);
}
else
{
timings.gpuFrameTimeMS = 0;
}

Renderer::TimeQueryID totalTimeQuery = frameTimeQueries[0];
timings.gpuFrameTimeMS = renderer->GetLastTimeQueryDuration(totalTimeQuery);
engineStats.AddTimings(timings.deltaTimeS, timings.simulationFrameTimeS, timings.renderFrameTimeS, timings.renderWaitTimeS, timings.gpuFrameTimeMS);
}
else
{
timings.gpuFrameTimeMS = 0;
}

engineStats.AddTimings(timings.deltaTimeS, timings.simulationFrameTimeS, timings.renderFrameTimeS, timings.renderWaitTimeS, timings.gpuFrameTimeMS);

bool limitFrameRate = CVAR_FramerateLimit.Get() == 1;
if (limitFrameRate)
{
f32 targetFramerate = Math::Max(static_cast<f32>(CVAR_FramerateLimitTarget.Get()), 10.0f);
f32 targetDelta = 1.0f / targetFramerate;

for (deltaTime = timer.GetDeltaTime(); deltaTime < targetDelta; deltaTime = timer.GetDeltaTime())
ZoneScopedN("Framerate Limit");
bool limitFrameRate = CVAR_FramerateLimit.Get() == 1;
if (limitFrameRate)
{
std::this_thread::yield();
f32 targetFramerate = Math::Max(static_cast<f32>(CVAR_FramerateLimitTarget.Get()), 10.0f);
f32 targetDelta = 1.0f / targetFramerate;

for (deltaTime = timer.GetDeltaTime(); deltaTime < targetDelta; deltaTime = timer.GetDeltaTime())
{
std::this_thread::yield();
}
}
}

Expand Down Expand Up @@ -362,12 +369,26 @@ bool Application::Init()

bool Application::Tick(f32 deltaTime)
{
ZoneScoped;
// Imgui New Frame
{
ZoneScopedN("_editorHandler->NewFrame");
_editorHandler->NewFrame();
}
{
ZoneScopedN("ImGui_ImplVulkan_NewFrame");
ImGui_ImplVulkan_NewFrame();
}
{
ZoneScopedN("ImGui_ImplGlfw_NewFrame");
ImGui_ImplGlfw_NewFrame();
}
{
ZoneScopedN("ImGui::NewFrame");
ImGui::NewFrame();
}
{
ZoneScopedN("ImGuizmo::BeginFrame");
ImGuizmo::BeginFrame();
}

Expand Down Expand Up @@ -481,10 +502,17 @@ bool Application::Tick(f32 deltaTime)

bool Application::Render(f32 deltaTime, f32& timeSpentWaiting)
{
ZoneScoped;
timeSpentWaiting = _gameRenderer->Render();

ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
{
ZoneScopedN("ImGui::UpdatePlatformWindows");
ImGui::UpdatePlatformWindows();
}
{
ZoneScopedN("ImGui::RenderPlatformWindowsDefault");
ImGui::RenderPlatformWindowsDefault();
}

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Game-Lib/Game-Lib/Editor/AssetBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ namespace Editor
Renderer::TextureID textureID = _renderer->LoadTexture(textureDesc);
_images[i] = _renderer->GetImguiTextureID(textureID);

Renderer::TextureBaseDesc textureBaseDesc = _renderer->GetTextureDesc(textureID);
Renderer::TextureBaseDesc textureBaseDesc = _renderer->GetDesc(textureID);

_imagesSize[i] = ImVec2(static_cast<f32>(textureBaseDesc.width),
static_cast<f32>(textureBaseDesc.height));
Expand Down
10 changes: 5 additions & 5 deletions Source/Game-Lib/Game-Lib/Editor/MapSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ namespace Editor
textureDesc.path = path.string();
Renderer::TextureID textureID = renderer->LoadTexture(textureDesc);
_mapIcons[0] = renderer->GetImguiTextureID(textureID);
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetTextureDesc(textureID);
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetDesc(textureID);
_mapIconSizes[0] = ImVec2(static_cast<f32>(textureBaseDesc.width), static_cast<f32>(textureBaseDesc.height));
}

Expand All @@ -141,7 +141,7 @@ namespace Editor
textureDesc.path = path.string();
Renderer::TextureID textureID = renderer->LoadTexture(textureDesc);
_mapIcons[1] = renderer->GetImguiTextureID(textureID);
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetTextureDesc(textureID);
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetDesc(textureID);
_mapIconSizes[1] = ImVec2(static_cast<f32>(textureBaseDesc.width), static_cast<f32>(textureBaseDesc.height));
}

Expand All @@ -151,7 +151,7 @@ namespace Editor
textureDesc.path = path.string();
Renderer::TextureID textureID = renderer->LoadTexture(textureDesc);
_mapIcons[2] = renderer->GetImguiTextureID(textureID);
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetTextureDesc(textureID);
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetDesc(textureID);
_mapIconSizes[2] = ImVec2(static_cast<f32>(textureBaseDesc.width), static_cast<f32>(textureBaseDesc.height));
}

Expand All @@ -161,7 +161,7 @@ namespace Editor
textureDesc.path = path.string();
Renderer::TextureID textureID = renderer->LoadTexture(textureDesc);
_mapIcons[3] = renderer->GetImguiTextureID(textureID);
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetTextureDesc(textureID);
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetDesc(textureID);
_mapIconSizes[3] = ImVec2(static_cast<f32>(textureBaseDesc.width), static_cast<f32>(textureBaseDesc.height));
}

Expand All @@ -171,7 +171,7 @@ namespace Editor
textureDesc.path = path.string();
Renderer::TextureID textureID = renderer->LoadTexture(textureDesc);
_mapIcons[4] = renderer->GetImguiTextureID(textureID);
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetTextureDesc(textureID);
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetDesc(textureID);
_mapIconSizes[4] = ImVec2(static_cast<f32>(textureBaseDesc.width), static_cast<f32>(textureBaseDesc.height));
}
}
Expand Down
13 changes: 10 additions & 3 deletions Source/Game-Lib/Game-Lib/Editor/PerformanceDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,21 +433,28 @@ namespace Editor
ImGui::Text("%.3f", average.deltaTimeS * 1000);
ImGui::TableNextColumn();

ImGui::Text("Update");
ImGui::Text(" Update");
ImGui::TableNextColumn();
ImGui::Text("%.3f", average.simulationFrameTimeS * 1000);
ImGui::TableNextColumn();

ImGui::Text("Render CPU");
ImGui::Text(" Render CPU");
ImGui::TableNextColumn();
ImGui::Text("%.3f", average.renderFrameTimeS * 1000);
ImGui::TableNextColumn();

ImGui::Text("CPU wait for GPU");
ImGui::Text(" CPU wait for GPU");
ImGui::TableNextColumn();
ImGui::Text("%.3f", average.renderWaitTimeS * 1000);
ImGui::TableNextColumn();

// Separate GPU from Total above since it does not add to it (it would be a part of CPU wait for GPU)
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, IM_COL32(200, 200, 200, 255));
ImGui::Dummy(vec2(0, 1));
ImGui::TableNextColumn();
ImGui::Dummy(vec2(0, 1));
ImGui::TableNextColumn();

ImGui::Text("GPU frame time");
ImGui::TableNextColumn();
ImGui::Text("%.3f", average.gpuFrameTimeMS);
Expand Down
2 changes: 2 additions & 0 deletions Source/Game-Lib/Game-Lib/Gameplay/GameConsole/GameConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <GLFW/glfw3.h>
#include <imgui_internal.h>
#include <tracy/Tracy.hpp>

AutoCVar_Int CVAR_GameConsoleEnabled(CVarCategory::Client, "consoleEnabled", "enable game console", 1, CVarFlags::Hidden | CVarFlags::DoNotSave);
AutoCVar_Int CVAR_GameConsoleDuplicateToTerminal(CVarCategory::Client, "consoleDuplicateToTerminal", "enable printing to terminal", 1, CVarFlags::EditCheckbox);
Expand Down Expand Up @@ -65,6 +66,7 @@ bool MatchesCommand(const std::string& command, const std::string& _searchText)

void GameConsole::Render(f32 deltaTime)
{
ZoneScoped;
i32* isGameConsoleEnabled = CVAR_GameConsoleEnabled.GetPtr();
if (*isGameConsoleEnabled == 0)
return;
Expand Down
Loading
Loading