Skip to content

Commit b760937

Browse files
committed
Refactor DescriptorSets
Refactored DescriptorSets to be way more performant Changed all rendering code to use new method of handling DescriptorSets Change all shaders to .slang extensions Add a few tracy zones Update Engine submodule
1 parent b717f19 commit b760937

File tree

130 files changed

+1533
-1287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+1533
-1287
lines changed

Source/Game-Lib/Game-Lib/Application/Application.cpp

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ void Application::Run()
166166
ECS::Singletons::FrameTimes timings;
167167
while (true)
168168
{
169+
ZoneScoped;
169170
f32 deltaTime = timer.GetDeltaTime();
170171
timer.Tick();
171172

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

195-
timings.renderFrameTimeS = renderTimer.GetLifeTime() - timeSpentWaiting;
196-
timings.renderWaitTimeS = timeSpentWaiting;
196+
{
197+
ZoneScopedN("TimeQueries");
198+
timings.renderFrameTimeS = renderTimer.GetLifeTime() - timeSpentWaiting;
199+
timings.renderWaitTimeS = timeSpentWaiting;
197200

198-
// Get last GPU Frame time
199-
Renderer::Renderer* renderer = _gameRenderer->GetRenderer();
201+
// Get last GPU Frame time
202+
Renderer::Renderer* renderer = _gameRenderer->GetRenderer();
200203

201-
const std::vector<Renderer::TimeQueryID> frameTimeQueries = renderer->GetFrameTimeQueries();
202-
if (frameTimeQueries.size() > 0)
203-
{
204-
for (Renderer::TimeQueryID timeQueryID : frameTimeQueries)
204+
const std::vector<Renderer::TimeQueryID> frameTimeQueries = renderer->GetFrameTimeQueries();
205+
if (frameTimeQueries.size() > 0)
205206
{
206-
const std::string& name = renderer->GetTimeQueryName(timeQueryID);
207-
f32 durationMS = renderer->GetLastTimeQueryDuration(timeQueryID);
207+
for (Renderer::TimeQueryID timeQueryID : frameTimeQueries)
208+
{
209+
const std::string& name = renderer->GetTimeQueryName(timeQueryID);
210+
f32 durationMS = renderer->GetLastTimeQueryDuration(timeQueryID);
211+
212+
engineStats.AddNamedStat(name, durationMS);
213+
}
208214

209-
engineStats.AddNamedStat(name, durationMS);
215+
Renderer::TimeQueryID totalTimeQuery = frameTimeQueries[0];
216+
timings.gpuFrameTimeMS = renderer->GetLastTimeQueryDuration(totalTimeQuery);
217+
}
218+
else
219+
{
220+
timings.gpuFrameTimeMS = 0;
210221
}
211222

212-
Renderer::TimeQueryID totalTimeQuery = frameTimeQueries[0];
213-
timings.gpuFrameTimeMS = renderer->GetLastTimeQueryDuration(totalTimeQuery);
223+
engineStats.AddTimings(timings.deltaTimeS, timings.simulationFrameTimeS, timings.renderFrameTimeS, timings.renderWaitTimeS, timings.gpuFrameTimeMS);
214224
}
215-
else
216-
{
217-
timings.gpuFrameTimeMS = 0;
218-
}
219-
220-
engineStats.AddTimings(timings.deltaTimeS, timings.simulationFrameTimeS, timings.renderFrameTimeS, timings.renderWaitTimeS, timings.gpuFrameTimeMS);
221225

222-
bool limitFrameRate = CVAR_FramerateLimit.Get() == 1;
223-
if (limitFrameRate)
224226
{
225-
f32 targetFramerate = Math::Max(static_cast<f32>(CVAR_FramerateLimitTarget.Get()), 10.0f);
226-
f32 targetDelta = 1.0f / targetFramerate;
227-
228-
for (deltaTime = timer.GetDeltaTime(); deltaTime < targetDelta; deltaTime = timer.GetDeltaTime())
227+
ZoneScopedN("Framerate Limit");
228+
bool limitFrameRate = CVAR_FramerateLimit.Get() == 1;
229+
if (limitFrameRate)
229230
{
230-
std::this_thread::yield();
231+
f32 targetFramerate = Math::Max(static_cast<f32>(CVAR_FramerateLimitTarget.Get()), 10.0f);
232+
f32 targetDelta = 1.0f / targetFramerate;
233+
234+
for (deltaTime = timer.GetDeltaTime(); deltaTime < targetDelta; deltaTime = timer.GetDeltaTime())
235+
{
236+
std::this_thread::yield();
237+
}
231238
}
232239
}
233240

@@ -362,12 +369,26 @@ bool Application::Init()
362369

363370
bool Application::Tick(f32 deltaTime)
364371
{
372+
ZoneScoped;
365373
// Imgui New Frame
366374
{
375+
ZoneScopedN("_editorHandler->NewFrame");
367376
_editorHandler->NewFrame();
377+
}
378+
{
379+
ZoneScopedN("ImGui_ImplVulkan_NewFrame");
368380
ImGui_ImplVulkan_NewFrame();
381+
}
382+
{
383+
ZoneScopedN("ImGui_ImplGlfw_NewFrame");
369384
ImGui_ImplGlfw_NewFrame();
385+
}
386+
{
387+
ZoneScopedN("ImGui::NewFrame");
370388
ImGui::NewFrame();
389+
}
390+
{
391+
ZoneScopedN("ImGuizmo::BeginFrame");
371392
ImGuizmo::BeginFrame();
372393
}
373394

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

482503
bool Application::Render(f32 deltaTime, f32& timeSpentWaiting)
483504
{
505+
ZoneScoped;
484506
timeSpentWaiting = _gameRenderer->Render();
485507

486-
ImGui::UpdatePlatformWindows();
487-
ImGui::RenderPlatformWindowsDefault();
508+
{
509+
ZoneScopedN("ImGui::UpdatePlatformWindows");
510+
ImGui::UpdatePlatformWindows();
511+
}
512+
{
513+
ZoneScopedN("ImGui::RenderPlatformWindowsDefault");
514+
ImGui::RenderPlatformWindowsDefault();
515+
}
488516

489517
return true;
490518
}

Source/Game-Lib/Game-Lib/Editor/AssetBrowser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ namespace Editor
402402
Renderer::TextureID textureID = _renderer->LoadTexture(textureDesc);
403403
_images[i] = _renderer->GetImguiTextureID(textureID);
404404

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

407407
_imagesSize[i] = ImVec2(static_cast<f32>(textureBaseDesc.width),
408408
static_cast<f32>(textureBaseDesc.height));

Source/Game-Lib/Game-Lib/Editor/MapSelector.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ namespace Editor
131131
textureDesc.path = path.string();
132132
Renderer::TextureID textureID = renderer->LoadTexture(textureDesc);
133133
_mapIcons[0] = renderer->GetImguiTextureID(textureID);
134-
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetTextureDesc(textureID);
134+
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetDesc(textureID);
135135
_mapIconSizes[0] = ImVec2(static_cast<f32>(textureBaseDesc.width), static_cast<f32>(textureBaseDesc.height));
136136
}
137137

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

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

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

@@ -171,7 +171,7 @@ namespace Editor
171171
textureDesc.path = path.string();
172172
Renderer::TextureID textureID = renderer->LoadTexture(textureDesc);
173173
_mapIcons[4] = renderer->GetImguiTextureID(textureID);
174-
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetTextureDesc(textureID);
174+
Renderer::TextureBaseDesc textureBaseDesc = renderer->GetDesc(textureID);
175175
_mapIconSizes[4] = ImVec2(static_cast<f32>(textureBaseDesc.width), static_cast<f32>(textureBaseDesc.height));
176176
}
177177
}

Source/Game-Lib/Game-Lib/Editor/PerformanceDiagnostics.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,21 +433,28 @@ namespace Editor
433433
ImGui::Text("%.3f", average.deltaTimeS * 1000);
434434
ImGui::TableNextColumn();
435435

436-
ImGui::Text("Update");
436+
ImGui::Text(" Update");
437437
ImGui::TableNextColumn();
438438
ImGui::Text("%.3f", average.simulationFrameTimeS * 1000);
439439
ImGui::TableNextColumn();
440440

441-
ImGui::Text("Render CPU");
441+
ImGui::Text(" Render CPU");
442442
ImGui::TableNextColumn();
443443
ImGui::Text("%.3f", average.renderFrameTimeS * 1000);
444444
ImGui::TableNextColumn();
445445

446-
ImGui::Text("CPU wait for GPU");
446+
ImGui::Text(" CPU wait for GPU");
447447
ImGui::TableNextColumn();
448448
ImGui::Text("%.3f", average.renderWaitTimeS * 1000);
449449
ImGui::TableNextColumn();
450450

451+
// Separate GPU from Total above since it does not add to it (it would be a part of CPU wait for GPU)
452+
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, IM_COL32(200, 200, 200, 255));
453+
ImGui::Dummy(vec2(0, 1));
454+
ImGui::TableNextColumn();
455+
ImGui::Dummy(vec2(0, 1));
456+
ImGui::TableNextColumn();
457+
451458
ImGui::Text("GPU frame time");
452459
ImGui::TableNextColumn();
453460
ImGui::Text("%.3f", average.gpuFrameTimeMS);

Source/Game-Lib/Game-Lib/Gameplay/GameConsole/GameConsole.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <GLFW/glfw3.h>
1515
#include <imgui_internal.h>
16+
#include <tracy/Tracy.hpp>
1617

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

6667
void GameConsole::Render(f32 deltaTime)
6768
{
69+
ZoneScoped;
6870
i32* isGameConsoleEnabled = CVAR_GameConsoleEnabled.GetPtr();
6971
if (*isGameConsoleEnabled == 0)
7072
return;

0 commit comments

Comments
 (0)