Browse Source

some tracy stuff

opengl-renderer-broken
Martin Dørum 3 years ago
parent
commit
ca56ba165b
3 changed files with 26 additions and 16 deletions
  1. 1
    1
      CMakeLists.txt
  2. 24
    8
      src/main.cc
  3. 1
    7
      tracy-tools/CMakeLists.txt

+ 1
- 1
CMakeLists.txt View File

@@ -49,7 +49,7 @@ elseif(CMAKE_BUILD_TYPE STREQUAL Release)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")

else()
message(FATAL_ERROR "CMAKE_BUILD_TYPE must be Debug or Release.")
message(FATAL_ERROR "CMAKE_BUILD_TYPE must be Sanitize, Debug, DebugRelease, Tracy or Release.")
endif()

# We want to be able to use C++20 designated initializers,

+ 24
- 8
src/main.cc View File

@@ -123,6 +123,7 @@ int main(int argc, char **argv) {
int fcount = 0;
int slow_frames = 0;
while (1) {
ZoneScopedN("game loop");
RTClock total_time_clock;

SDL_Event evt;
@@ -208,6 +209,7 @@ int main(int argc, char **argv) {
// Simple case: we can keep up, only need one physics update
RTClock update_clock;
if (dt <= 1 / 25.0) {
ZoneScopedN("game update");
pcounter.countGameUpdatesPerFrame(1);
game.update(dt);

@@ -216,15 +218,20 @@ int main(int argc, char **argv) {
int count = (int)ceil(dt / (1/30.0));
pcounter.countGameUpdatesPerFrame(count);
float delta = dt / (float)count;
info << "Delta time " << dt << "s. Running " << count << " updates in one frame, with a delta as if we had " << 1.0 / delta << " FPS.";
for (int i = 0; i < count; ++i)
info << "Delta time " << dt << "s. Running " << count
<< " updates in one frame, with a delta as if we had "
<< 1.0 / delta << " FPS.";
for (int i = 0; i < count; ++i) {
ZoneScopedN("game update");
game.update(delta);
}
}
pcounter.countGameUpdate(update_clock.duration());

// Tick at a consistent TICK_RATE
tick_acc += dt;
while (tick_acc >= 1.0 / TICK_RATE) {
ZoneScopedN("game tick");
tick_acc -= 1.0 / TICK_RATE;
RTClock tick_clock;
game.tick(1.0 / TICK_RATE);
@@ -241,19 +248,28 @@ int main(int argc, char **argv) {
imgui_io.DeltaTime = dt;
ImGui::NewFrame();

RTClock draw_clock;
game.draw();
pcounter.countGameDraw(draw_clock.duration());
{
ZoneScopedN("game draw");
RTClock draw_clock;
game.draw();
pcounter.countGameDraw(draw_clock.duration());
}

pcounter.countFrameTime(total_time_clock.duration());
pcounter.render();

// Render ImGUI
ImGui::Render();
ImGuiSDL::Render(ImGui::GetDrawData());
{
ZoneScopedN("imgui render");
ImGui::Render();
ImGuiSDL::Render(ImGui::GetDrawData());
}

RTClock present_clock;
SDL_RenderPresent(renderer.get());
{
ZoneScopedN("render present");
SDL_RenderPresent(renderer.get());
}
FrameMark
pcounter.countRenderPresent(present_clock.duration());


+ 1
- 7
tracy-tools/CMakeLists.txt View File

@@ -2,8 +2,6 @@ find_package(Freetype)
find_package(glfw3)
find_package(GTK2 REQUIRED COMPONENTS gtk)

#add_library(tracy-stuff OBJECT

add_library(tracy-libs-unix OBJECT EXCLUDE_FROM_ALL
${PROJECT_SOURCE_DIR}/third-party/tracy/nfd/nfd_gtk.c
${PROJECT_SOURCE_DIR}/third-party/tracy/libbacktrace/posix.cpp)
@@ -81,11 +79,7 @@ target_include_directories(tracy-libs PUBLIC
target_link_libraries(tracy-libs tracy-libs-unix
pthread dl Freetype::Freetype glfw GL)
target_compile_options(tracy-libs PUBLIC
-UTRACY_ENABLE
-Wno-class-memaccess -Wno-unused-variable -Wno-pedantic -Wno-ignored-qualifiers
-Wno-missing-field-initializers -Wno-unused-result -Wno-sign-compare
-Wno-reorder -Wno-sequence-point -Wno-enum-compare -Wno-unused-function
-Wno-deprecated-decleration
-w -UTRACY_ENABLE
-DTRACY_FILESELECTOR -DTRACY_EXTENDED_FONT -DTRACY_ROOT_WINDOW
-DIMGUI_IMPL_OPENGL_LOADER_GL3W)


Loading…
Cancel
Save