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

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")


else() 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() endif()


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

+ 24
- 8
src/main.cc View File

int fcount = 0; int fcount = 0;
int slow_frames = 0; int slow_frames = 0;
while (1) { while (1) {
ZoneScopedN("game loop");
RTClock total_time_clock; RTClock total_time_clock;


SDL_Event evt; SDL_Event evt;
// Simple case: we can keep up, only need one physics update // Simple case: we can keep up, only need one physics update
RTClock update_clock; RTClock update_clock;
if (dt <= 1 / 25.0) { if (dt <= 1 / 25.0) {
ZoneScopedN("game update");
pcounter.countGameUpdatesPerFrame(1); pcounter.countGameUpdatesPerFrame(1);
game.update(dt); game.update(dt);


int count = (int)ceil(dt / (1/30.0)); int count = (int)ceil(dt / (1/30.0));
pcounter.countGameUpdatesPerFrame(count); pcounter.countGameUpdatesPerFrame(count);
float delta = dt / (float)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); game.update(delta);
}
} }
pcounter.countGameUpdate(update_clock.duration()); pcounter.countGameUpdate(update_clock.duration());


// Tick at a consistent TICK_RATE // Tick at a consistent TICK_RATE
tick_acc += dt; tick_acc += dt;
while (tick_acc >= 1.0 / TICK_RATE) { while (tick_acc >= 1.0 / TICK_RATE) {
ZoneScopedN("game tick");
tick_acc -= 1.0 / TICK_RATE; tick_acc -= 1.0 / TICK_RATE;
RTClock tick_clock; RTClock tick_clock;
game.tick(1.0 / TICK_RATE); game.tick(1.0 / TICK_RATE);
imgui_io.DeltaTime = dt; imgui_io.DeltaTime = dt;
ImGui::NewFrame(); 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.countFrameTime(total_time_clock.duration());
pcounter.render(); pcounter.render();


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


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



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

find_package(glfw3) find_package(glfw3)
find_package(GTK2 REQUIRED COMPONENTS gtk) find_package(GTK2 REQUIRED COMPONENTS gtk)


#add_library(tracy-stuff OBJECT

add_library(tracy-libs-unix OBJECT EXCLUDE_FROM_ALL 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/nfd/nfd_gtk.c
${PROJECT_SOURCE_DIR}/third-party/tracy/libbacktrace/posix.cpp) ${PROJECT_SOURCE_DIR}/third-party/tracy/libbacktrace/posix.cpp)
target_link_libraries(tracy-libs tracy-libs-unix target_link_libraries(tracy-libs tracy-libs-unix
pthread dl Freetype::Freetype glfw GL) pthread dl Freetype::Freetype glfw GL)
target_compile_options(tracy-libs PUBLIC 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 -DTRACY_FILESELECTOR -DTRACY_EXTENDED_FONT -DTRACY_ROOT_WINDOW
-DIMGUI_IMPL_OPENGL_LOADER_GL3W) -DIMGUI_IMPL_OPENGL_LOADER_GL3W)



Loading…
Cancel
Save