Compare commits
2 Commits
f14add70b6
...
a5e32c414e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5e32c414e | ||
|
|
a3e22b7b05 |
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -5,3 +5,4 @@
|
||||
*.jpg filter=lfs diff=lfs merge=lfs -text
|
||||
*.blend filter=lfs diff=lfs merge=lfs -text
|
||||
*.pzl filter=lfs diff=lfs merge=lfs -text
|
||||
*.exe filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -11,3 +11,6 @@
|
||||
path = src/dependency/imgui
|
||||
url = https://github.com/ocornut/imgui
|
||||
branch = docking
|
||||
[submodule "src/dependency/tracy"]
|
||||
path = src/dependency/tracy
|
||||
url = https://github.com/wolfpld/tracy
|
||||
|
||||
@@ -12,6 +12,7 @@ endif()
|
||||
# This makes sure that the dynamic library goes into the build directory automatically.
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<CONFIGURATION>")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<CONFIGURATION>")
|
||||
set(PROFILE ON)
|
||||
|
||||
# Imgui
|
||||
file(GLOB imgui_sources dependency/imgui/*.h dependency/imgui/*.cpp)
|
||||
@@ -25,7 +26,7 @@ add_subdirectory("${CMAKE_SOURCE_DIR}/dependency/minidef")
|
||||
file(GLOB_RECURSE sources_engine engine/*.cpp engine/*.h)
|
||||
add_executable(PuzGameEngine ${sources_engine})
|
||||
set_property(TARGET PuzGameEngine PROPERTY CXX_STANDARD 17)
|
||||
target_include_directories(PuzGameEngine PUBLIC)
|
||||
target_include_directories(PuzGameEngine PUBLIC dependency/tracy/public/)
|
||||
|
||||
# Game
|
||||
add_custom_command(
|
||||
@@ -41,6 +42,15 @@ add_library(PuzGame SHARED ${sources_game} ${source_singleheader} ${imgui_source
|
||||
set_property(TARGET PuzGame PROPERTY CXX_STANDARD 17)
|
||||
target_include_directories(PuzGame PUBLIC dependency/imgui)
|
||||
|
||||
# Profiling
|
||||
if (PROFILE)
|
||||
option(TRACY_ENABLE "" ON)
|
||||
option(TRACY_ON_DEMAND "" ON)
|
||||
set(TRACY_DELAYED_INIT ON)
|
||||
set(TRACY_MANUAL_LIFETIME ON)
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/dependency/tracy")
|
||||
endif()
|
||||
|
||||
# SDL
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/dependency/SDL" EXCLUDE_FROM_ALL)
|
||||
|
||||
@@ -50,6 +60,6 @@ SET(BGFX_BUILD_EXAMPLES OFF)
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/dependency/bgfx.cmake")
|
||||
|
||||
# Link
|
||||
target_link_libraries(PuzGame bx bimg bgfx SDL3::SDL3)
|
||||
target_link_libraries(PuzGameEngine bx SDL3::SDL3)
|
||||
target_link_libraries(PuzGame bx bimg bgfx SDL3::SDL3 Tracy::TracyClient)
|
||||
target_link_libraries(PuzGameEngine bx SDL3::SDL3 Tracy::TracyClient)
|
||||
set_target_properties(PuzGame PROPERTIES OUTPUT_NAME "PuzGame2")
|
||||
|
||||
1
src/dependency/tracy
Submodule
1
src/dependency/tracy
Submodule
Submodule src/dependency/tracy added at 5d542dc09f
@@ -15,6 +15,7 @@
|
||||
#include <SDL3/SDL.h>
|
||||
#include <bx/math.h>
|
||||
#include <cstdint>
|
||||
#include <tracy/tracy.hpp>
|
||||
|
||||
namespace Game
|
||||
{
|
||||
@@ -160,6 +161,7 @@ namespace Game
|
||||
|
||||
void Level::Update()
|
||||
{
|
||||
ZoneScopedN("Level update");
|
||||
START_PERF();
|
||||
PlayerData& player = GetInstance().Player;
|
||||
|
||||
@@ -237,6 +239,7 @@ namespace Game
|
||||
|
||||
void Level::Render(uint16_t viewId, const Model* models, const Material* materials)
|
||||
{
|
||||
ZoneScopedN("Level Render");
|
||||
auto& shared = GetShared();
|
||||
|
||||
float proj[16];
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
#include "Instance.h"
|
||||
#include "Log.h"
|
||||
#include "Setup.h"
|
||||
#include "rendering/Rendering.h"
|
||||
|
||||
#include "bx/bx.h"
|
||||
#include "bx/timer.h"
|
||||
#include "rendering/Rendering.h"
|
||||
#include <client/TracyProfiler.hpp>
|
||||
#include <tracy/tracy.hpp>
|
||||
|
||||
namespace Game
|
||||
{
|
||||
@@ -23,6 +26,7 @@ namespace Game
|
||||
void Setup(SharedData& shared)
|
||||
{
|
||||
LOG("Game Setup Start!");
|
||||
tracy::StartupProfiler();
|
||||
|
||||
if (shared.Game.PermanentStorage == nullptr)
|
||||
{
|
||||
@@ -56,6 +60,8 @@ namespace Game
|
||||
|
||||
void Update()
|
||||
{
|
||||
{
|
||||
ZoneScopedN("TimeUpdate");
|
||||
auto& inst = GetInstance();
|
||||
int64_t newNowHP = bx::getHPCounter() - inst.Time.StartTime;
|
||||
inst.Time.DeltaHP = newNowHP - inst.Time.NowHP;
|
||||
@@ -64,25 +70,25 @@ namespace Game
|
||||
inst.Time.Delta = (double)inst.Time.DeltaHP / bx::getHPFrequency();
|
||||
GetShared().Window.PerfCounters[(int32_t)PerfCounterType::GameDelta].Write(inst.Time.DeltaHP,
|
||||
GetShared().Window.FrameCounter);
|
||||
|
||||
if (GetKeyPressedNow(ScanCode::R))
|
||||
{
|
||||
GetInstance().Size = 0;
|
||||
Shutdown();
|
||||
Setup(GetShared());
|
||||
}
|
||||
|
||||
SetupInstance.Rendering.Update();
|
||||
|
||||
{
|
||||
ZoneScopedN("MouseDeltaUpdate");
|
||||
auto& win = GetShared().Window;
|
||||
win.MouseDeltaX = 0.0f;
|
||||
win.MouseDeltaY = 0.0f;
|
||||
bx::memCopy(win.LastHeldScanCodes, win.HeldScanCodes, sizeof(win.HeldScanCodes));
|
||||
bx::memCopy(win.LastHeldMouseButtons, win.HeldMouseButtons, sizeof(win.HeldMouseButtons));
|
||||
}
|
||||
FrameMark;
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
LOG("Shutdown");
|
||||
SetupInstance.Rendering.Shutdown();
|
||||
tracy::ShutdownProfiler();
|
||||
}
|
||||
} // namespace Game
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <thread>
|
||||
#include <tracy/Tracy.hpp>
|
||||
|
||||
#include "imgui-helper.h"
|
||||
#include "imgui-style.h"
|
||||
#include "imgui.h"
|
||||
#include "imgui_internal.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
@@ -333,6 +333,8 @@ namespace Game
|
||||
void GameRendering::Setup()
|
||||
{
|
||||
LOG("--- RENDERING STARTUP ---");
|
||||
ZoneScopedN("Setup");
|
||||
|
||||
if (Instance != nullptr) LOG_WARN("old rendering wasn't destroyed!");
|
||||
Instance = this;
|
||||
SharedData& shared = GetShared();
|
||||
@@ -407,11 +409,11 @@ namespace Game
|
||||
DitherGen(DitherTextures, DitherRecursion);
|
||||
}
|
||||
|
||||
void GameRendering::Update()
|
||||
void GameRendering::HandleEvents()
|
||||
{
|
||||
ZoneScopedN("Handle Events");
|
||||
SharedData& shared = GetShared();
|
||||
|
||||
// Handle events
|
||||
for (uint16_t i = 0; i < shared.Window.SDLEventCount; ++i)
|
||||
{
|
||||
ImGui_ImplSDL3_ProcessEvent(&shared.Window.SDLEvents[i]);
|
||||
@@ -453,16 +455,16 @@ namespace Game
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start Rendering
|
||||
imguiBeginFrame(20);
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
ImGui::DockSpaceOverViewport(0, 0, ImGuiDockNodeFlags_PassthruCentralNode);
|
||||
|
||||
auto& level = GetInstance().GameLevel;
|
||||
auto& debug = GetInstance().DebugData;
|
||||
if (UIVisible == UIVisibilityState::Debug)
|
||||
void GameRendering::RenderDebugUI()
|
||||
{
|
||||
ZoneScopedN("DebugUI");
|
||||
|
||||
auto& shared = GetShared();
|
||||
auto& debug = GetInstance().DebugData;
|
||||
auto& level = GetInstance().GameLevel;
|
||||
|
||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
|
||||
{
|
||||
debug.DebugCardRotation++;
|
||||
@@ -646,25 +648,53 @@ namespace Game
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void GameRendering::Update()
|
||||
{
|
||||
ZoneScopedN("Rendering");
|
||||
SharedData& shared = GetShared();
|
||||
|
||||
HandleEvents();
|
||||
|
||||
// Start Rendering
|
||||
{
|
||||
ZoneScopedN("Imgui Start Frame");
|
||||
imguiBeginFrame(20);
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
ImGui::DockSpaceOverViewport(0, 0, ImGuiDockNodeFlags_PassthruCentralNode);
|
||||
}
|
||||
|
||||
if (UIVisible == UIVisibilityState::Debug)
|
||||
{
|
||||
RenderDebugUI();
|
||||
}
|
||||
|
||||
GetInstance().GameLevel.Update();
|
||||
GetInstance().GameLevel.Render(MainViewID, Models, Materials);
|
||||
|
||||
// Finish Frame
|
||||
{
|
||||
ZoneScopedN("Imgui End Frame");
|
||||
imguiEndFrame();
|
||||
}
|
||||
|
||||
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||
{
|
||||
ZoneScopedN("Imgui Platform Update");
|
||||
ImGui::UpdatePlatformWindows();
|
||||
ImGui::RenderPlatformWindowsDefault();
|
||||
}
|
||||
|
||||
{
|
||||
ZoneScopedN("BGFX Frame");
|
||||
START_PERF();
|
||||
bgfx::frame();
|
||||
END_PERF(shared.Window.PerfCounters, PerfCounterType::Submit, shared.Window.FrameCounter);
|
||||
}
|
||||
}
|
||||
|
||||
void GameRendering::Shutdown()
|
||||
{
|
||||
ZoneScopedN("Shutdown");
|
||||
LOG("--- RENDERING_SHUTDOWN ---");
|
||||
ImGui::SaveIniSettingsToDisk("imgui.ini");
|
||||
auto& debug = GetInstance().DebugData;
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Game
|
||||
Model Models[MaxModels];
|
||||
int32_t LastWidth = 0;
|
||||
int32_t LastHeight = 0;
|
||||
uint32_t ResetFlags = BGFX_RESET_VSYNC;
|
||||
uint32_t ResetFlags = 0; // BGFX_RESET_VSYNC;
|
||||
uint16_t MainViewID = 10;
|
||||
float LastShaderLoadTime = 0.0f;
|
||||
int32_t DitherRecursion = 1;
|
||||
@@ -115,6 +115,8 @@ namespace Game
|
||||
public:
|
||||
void Setup();
|
||||
void Update();
|
||||
void HandleEvents();
|
||||
void RenderDebugUI();
|
||||
void Shutdown();
|
||||
uint16_t GetModelHandleFromPath(const char* path);
|
||||
};
|
||||
|
||||
BIN
tools/tracy/tracy-capture.exe
LFS
Normal file
BIN
tools/tracy/tracy-capture.exe
LFS
Normal file
Binary file not shown.
BIN
tools/tracy/tracy-csvexport.exe
LFS
Normal file
BIN
tools/tracy/tracy-csvexport.exe
LFS
Normal file
Binary file not shown.
BIN
tools/tracy/tracy-import-chrome.exe
LFS
Normal file
BIN
tools/tracy/tracy-import-chrome.exe
LFS
Normal file
Binary file not shown.
BIN
tools/tracy/tracy-profiler.exe
LFS
Normal file
BIN
tools/tracy/tracy-profiler.exe
LFS
Normal file
Binary file not shown.
BIN
tools/tracy/tracy-update.exe
LFS
Normal file
BIN
tools/tracy/tracy-update.exe
LFS
Normal file
Binary file not shown.
Reference in New Issue
Block a user