Skip to content

Commit

Permalink
Fixed: Build with profiler enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
richardbiely committed Mar 12, 2024
1 parent 0fad530 commit dd6c809
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 64 deletions.
9 changes: 8 additions & 1 deletion include/gaia/config/profiler.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#pragma once
#include "config.h"

#ifndef GAIA_PROFILER_CPU
#define GAIA_PROFILER_CPU 0
#endif
#ifndef GAIA_PROFILER_MEM
#define GAIA_PROFILER_MEM 0
#endif

#if GAIA_PROFILER_CPU || GAIA_PROFILER_MEM
// Keep it small on Windows
// TODO: What if user doesn't want this?
Expand Down Expand Up @@ -91,7 +98,7 @@ namespace tracy {
// Tracy profiler GAIA implementation
//------------------------------------------------------------------------

//! Marks the end of frame
//! Marks the end of frame
#if !defined(GAIA_PROF_FRAME)
#define GAIA_PROF_FRAME() FrameMark
#endif
Expand Down
4 changes: 2 additions & 2 deletions include/gaia/ecs/system_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ namespace gaia {
if (name == nullptr) {
constexpr auto ct_name = meta::type_info::name<T>();
const size_t len = ct_name.size() >= MaxSystemNameLength ? MaxSystemNameLength : ct_name.size() + 1;
GAIA_SETSTR(pSystem->m_name, ct_name.data(), len);
GAIA_STRCPY(pSystem->m_name, len, ct_name.data());
} else {
GAIA_SETSTR(pSystem->m_name, name, MaxSystemNameLength);
GAIA_STRCPY(pSystem->m_name, MaxSystemNameLength, name);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion include/gaia/ecs/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@ namespace gaia {
unreg_archetype_raw(pArchetype);
}

#if GAIA_DEBUG
#if GAIA_ASSERT_ENABLED
static void print_archetype_entities(const World& world, const Archetype& archetype, Entity entity, bool adding) {
const auto& ids = archetype.ids();

Expand Down
15 changes: 11 additions & 4 deletions single_include/gaia.h
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,13 @@ namespace gaia {
}
#endif

#ifndef GAIA_PROFILER_CPU
#define GAIA_PROFILER_CPU 0
#endif
#ifndef GAIA_PROFILER_MEM
#define GAIA_PROFILER_MEM 0
#endif

#if GAIA_PROFILER_CPU || GAIA_PROFILER_MEM
// Keep it small on Windows
// TODO: What if user doesn't want this?
Expand Down Expand Up @@ -973,7 +980,7 @@ namespace tracy {
// Tracy profiler GAIA implementation
//------------------------------------------------------------------------

//! Marks the end of frame
//! Marks the end of frame
#if !defined(GAIA_PROF_FRAME)
#define GAIA_PROF_FRAME() FrameMark
#endif
Expand Down Expand Up @@ -23849,7 +23856,7 @@ namespace gaia {
unreg_archetype_raw(pArchetype);
}

#if GAIA_DEBUG
#if GAIA_ASSERT_ENABLED
static void print_archetype_entities(const World& world, const Archetype& archetype, Entity entity, bool adding) {
const auto& ids = archetype.ids();

Expand Down Expand Up @@ -25827,9 +25834,9 @@ namespace gaia {
if (name == nullptr) {
constexpr auto ct_name = meta::type_info::name<T>();
const size_t len = ct_name.size() >= MaxSystemNameLength ? MaxSystemNameLength : ct_name.size() + 1;
GAIA_SETSTR(pSystem->m_name, ct_name.data(), len);
GAIA_STRCPY(pSystem->m_name, len, ct_name.data());
} else {
GAIA_SETSTR(pSystem->m_name, name, MaxSystemNameLength);
GAIA_STRCPY(pSystem->m_name, MaxSystemNameLength, name);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ if(GAIA_PROFILER_CPU OR GAIA_PROFILER_MEM)

set(TRACY_ENABLE ON CACHE BOOL "TRACY_ENABLE override")
set(TRACY_ON_DEMAND ON CACHE BOOL "TRACY_ON_DEMAND override")

FetchContent_MakeAvailable(tracy)
endif()
else()
Expand Down
28 changes: 18 additions & 10 deletions src/perf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
add_subdirectory(iter)
add_subdirectory(duel)
add_subdirectory(entity)
add_subdirectory(mt)
add_subdirectory(app)

# Preprocessor
add_definitions(-DGAIA_DEBUG=0)
add_compile_definitions(GAIA_DEBUG=0)

# Profiler
if(GAIA_PROFILER_CPU OR GAIA_PROFILER_MEM)
if(GAIA_PROFILER_CPU)
add_compile_definitions(PRIVATE GAIA_PROFILER_CPU=1)
add_compile_definitions(GAIA_PROFILER_CPU=1)
endif()

if(GAIA_PROFILER_MEM)
add_compile_definitions(PRIVATE GAIA_PROFILER_MEM=1)
add_compile_definitions(GAIA_PROFILER_MEM=1)
endif()

link_libraries(PRIVATE TracyClient)
link_libraries(TracyClient)
endif()

include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${picobench_SOURCE_DIR}/include)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
link_libraries(Threads::Threads)
link_libraries(picobench::picobench)

add_subdirectory(iter)
add_subdirectory(duel)
add_subdirectory(entity)
add_subdirectory(mt)
add_subdirectory(app)
8 changes: 0 additions & 8 deletions src/perf/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
set(PROJ_NAME "gaia_perf_app")
add_executable(${PROJ_NAME} src/main.cpp)

target_include_directories(${PROJ_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_include_directories(${PROJ_NAME} PRIVATE ${picobench_SOURCE_DIR}/include)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${PROJ_NAME} PRIVATE Threads::Threads)
target_link_libraries(${PROJ_NAME} PRIVATE picobench::picobench)
8 changes: 0 additions & 8 deletions src/perf/duel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
set(PROJ_NAME "gaia_perf_duel")
add_executable(${PROJ_NAME} src/main.cpp)

target_include_directories(${PROJ_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_include_directories(${PROJ_NAME} PRIVATE ${picobench_SOURCE_DIR}/include)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${PROJ_NAME} PRIVATE Threads::Threads)
target_link_libraries(${PROJ_NAME} PRIVATE picobench::picobench)
13 changes: 0 additions & 13 deletions src/perf/entity/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,2 @@
set(PROJ_NAME "gaia_perf_entity")
add_executable(${PROJ_NAME} src/main.cpp)

if(MSVC)
# Necessary because VS might complain about too many sections used in debug builds
target_compile_options(${PROJ_NAME} PRIVATE /bigobj)
endif()

target_include_directories(${PROJ_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_include_directories(${PROJ_NAME} PRIVATE ${picobench_SOURCE_DIR}/include)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${PROJ_NAME} PRIVATE Threads::Threads)
target_link_libraries(${PROJ_NAME} PRIVATE picobench::picobench)
8 changes: 0 additions & 8 deletions src/perf/iter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
set(PROJ_NAME "gaia_perf_iter")
add_executable(${PROJ_NAME} src/main.cpp)

target_include_directories(${PROJ_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_include_directories(${PROJ_NAME} PRIVATE ${picobench_SOURCE_DIR}/include)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${PROJ_NAME} PRIVATE Threads::Threads)
target_link_libraries(${PROJ_NAME} PRIVATE picobench::picobench)
8 changes: 0 additions & 8 deletions src/perf/mt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
set(PROJ_NAME "gaia_perf_mt")
add_executable(${PROJ_NAME} src/main.cpp)

target_include_directories(${PROJ_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_include_directories(${PROJ_NAME} PRIVATE ${picobench_SOURCE_DIR}/include)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${PROJ_NAME} PRIVATE Threads::Threads)
target_link_libraries(${PROJ_NAME} PRIVATE picobench::picobench)

0 comments on commit dd6c809

Please sign in to comment.