2
0

App.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. // Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <AnKi/Core/App.h>
  6. #include <AnKi/Core/CVarSet.h>
  7. #include <AnKi/Core/GpuMemory/UnifiedGeometryBuffer.h>
  8. #include <AnKi/Util/Logger.h>
  9. #include <AnKi/Util/File.h>
  10. #include <AnKi/Util/Filesystem.h>
  11. #include <AnKi/Util/System.h>
  12. #include <AnKi/Util/Tracer.h>
  13. #include <AnKi/Util/HighRezTimer.h>
  14. #include <AnKi/Core/CoreTracer.h>
  15. #include <AnKi/Core/GpuMemory/RebarTransientMemoryPool.h>
  16. #include <AnKi/Core/GpuMemory/GpuVisibleTransientMemoryPool.h>
  17. #include <AnKi/Core/GpuMemory/GpuReadbackMemoryPool.h>
  18. #include <AnKi/Core/StatsSet.h>
  19. #include <AnKi/Window/NativeWindow.h>
  20. #include <AnKi/Core/MaliHwCounters.h>
  21. #include <AnKi/Window/Input.h>
  22. #include <AnKi/Scene/SceneGraph.h>
  23. #include <AnKi/Resource/ResourceManager.h>
  24. #include <AnKi/Physics/PhysicsWorld.h>
  25. #include <AnKi/Renderer/MainRenderer.h>
  26. #include <AnKi/Script/ScriptManager.h>
  27. #include <AnKi/Resource/ResourceFilesystem.h>
  28. #include <AnKi/Resource/AsyncLoader.h>
  29. #include <AnKi/Ui/UiManager.h>
  30. #include <AnKi/Ui/Canvas.h>
  31. #include <AnKi/Scene/DeveloperConsoleUiNode.h>
  32. #include <csignal>
  33. #if ANKI_OS_ANDROID
  34. # include <android_native_app_glue.h>
  35. #endif
  36. namespace anki {
  37. #if ANKI_OS_ANDROID
  38. /// The one and only android hack
  39. android_app* g_androidApp = nullptr;
  40. #endif
  41. StatCounter g_cpuTotalTimeStatVar(StatCategory::kTime, "CPU total", StatFlag::kMilisecond | StatFlag::kShowAverage | StatFlag::kMainThreadUpdates);
  42. static StatCounter g_cpuAllocatedMemStatVar(StatCategory::kCpuMem, "Total", StatFlag::kBytes);
  43. static StatCounter g_cpuAllocationCountStatVar(StatCategory::kCpuMem, "Allocations/frame", StatFlag::kBytes | StatFlag::kZeroEveryFrame);
  44. static StatCounter g_cpuFreesCountStatVar(StatCategory::kCpuMem, "Frees/frame", StatFlag::kBytes | StatFlag::kZeroEveryFrame);
  45. NumericCVar<U32> g_windowWidthCVar(CVarSubsystem::kCore, "Width", 1920, 16, 16 * 1024, "Width");
  46. NumericCVar<U32> g_windowHeightCVar(CVarSubsystem::kCore, "Height", 1080, 16, 16 * 1024, "Height");
  47. NumericCVar<U32> g_windowFullscreenCVar(CVarSubsystem::kCore, "WindowFullscreen", 1, 0, 2,
  48. "0: windowed, 1: borderless fullscreen, 2: exclusive fullscreen");
  49. NumericCVar<U32> g_targetFpsCVar(CVarSubsystem::kCore, "TargetFps", 60u, 1u, kMaxU32, "Target FPS");
  50. static NumericCVar<U32> g_jobThreadCountCVar(CVarSubsystem::kCore, "JobThreadCount", max(2u, getCpuCoresCount() / 2u), 2u, 1024u,
  51. "Number of job thread");
  52. NumericCVar<U32> g_displayStatsCVar(CVarSubsystem::kCore, "DisplayStats", 0, 0, 2, "Display stats, 0: None, 1: Simple, 2: Detailed");
  53. BoolCVar g_clearCachesCVar(CVarSubsystem::kCore, "ClearCaches", false, "Clear all caches");
  54. BoolCVar g_verboseLogCVar(CVarSubsystem::kCore, "VerboseLog", false, "Verbose logging");
  55. BoolCVar g_benchmarkModeCVar(CVarSubsystem::kCore, "BenchmarkMode", false, "Run in a benchmark mode. Fixed timestep, unlimited target FPS");
  56. NumericCVar<U32> g_benchmarkModeFrameCountCVar(CVarSubsystem::kCore, "BenchmarkModeFrameCount", 60 * 60 * 2, 1, kMaxU32,
  57. "How many frames the benchmark will run before it quits");
  58. #if ANKI_PLATFORM_MOBILE
  59. static StatCounter g_maliGpuActiveStatVar(StatCategory::kGpuMisc, "Mali active cycles", StatFlag::kMainThreadUpdates);
  60. static StatCounter g_maliGpuReadBandwidthStatVar(StatCategory::kGpuMisc, "Mali read bandwidth", StatFlag::kMainThreadUpdates);
  61. static StatCounter g_maliGpuWriteBandwidthStatVar(StatCategory::kGpuMisc, "Mali write bandwidth", StatFlag::kMainThreadUpdates);
  62. static BoolCVar g_maliHwCountersCVar(CVarSubsystem::kCore, "MaliHwCounters", false, "Enable Mali counters");
  63. #endif
  64. void* App::statsAllocCallback(void* userData, void* ptr, PtrSize size, [[maybe_unused]] PtrSize alignment)
  65. {
  66. ANKI_ASSERT(userData);
  67. constexpr PtrSize kMaxAlignment = 64;
  68. struct alignas(kMaxAlignment) Header
  69. {
  70. PtrSize m_allocatedSize;
  71. Array<U8, kMaxAlignment - sizeof(PtrSize)> _m_padding;
  72. };
  73. static_assert(sizeof(Header) == kMaxAlignment, "See file");
  74. static_assert(alignof(Header) == kMaxAlignment, "See file");
  75. void* out = nullptr;
  76. if(ptr == nullptr)
  77. {
  78. // Need to allocate
  79. ANKI_ASSERT(size > 0);
  80. ANKI_ASSERT(alignment > 0 && alignment <= kMaxAlignment);
  81. const PtrSize newAlignment = kMaxAlignment;
  82. const PtrSize newSize = sizeof(Header) + size;
  83. // Allocate
  84. App* self = static_cast<App*>(userData);
  85. Header* allocation = static_cast<Header*>(self->m_originalAllocCallback(self->m_originalAllocUserData, nullptr, newSize, newAlignment));
  86. allocation->m_allocatedSize = size;
  87. ++allocation;
  88. out = static_cast<void*>(allocation);
  89. // Update stats
  90. g_cpuAllocatedMemStatVar.increment(size);
  91. g_cpuAllocationCountStatVar.increment(1);
  92. }
  93. else
  94. {
  95. // Need to free
  96. App* self = static_cast<App*>(userData);
  97. Header* allocation = static_cast<Header*>(ptr);
  98. --allocation;
  99. ANKI_ASSERT(allocation->m_allocatedSize > 0);
  100. // Update stats
  101. g_cpuAllocatedMemStatVar.decrement(allocation->m_allocatedSize);
  102. g_cpuFreesCountStatVar.increment(1);
  103. // Free
  104. self->m_originalAllocCallback(self->m_originalAllocUserData, allocation, 0, 0);
  105. }
  106. return out;
  107. }
  108. App::App(AllocAlignedCallback allocCb, void* allocCbUserData)
  109. {
  110. m_originalAllocCallback = allocCb;
  111. m_originalAllocUserData = allocCbUserData;
  112. }
  113. App::~App()
  114. {
  115. ANKI_CORE_LOGI("Destroying application");
  116. cleanup();
  117. }
  118. void App::cleanup()
  119. {
  120. SceneGraph::freeSingleton();
  121. ScriptManager::freeSingleton();
  122. MainRenderer::freeSingleton();
  123. UiManager::freeSingleton();
  124. GpuSceneMicroPatcher::freeSingleton();
  125. ResourceManager::freeSingleton();
  126. PhysicsWorld::freeSingleton();
  127. RebarTransientMemoryPool::freeSingleton();
  128. GpuVisibleTransientMemoryPool::freeSingleton();
  129. UnifiedGeometryBuffer::freeSingleton();
  130. GpuSceneBuffer::freeSingleton();
  131. GpuReadbackMemoryPool::freeSingleton();
  132. CoreThreadJobManager::freeSingleton();
  133. MaliHwCounters::freeSingleton();
  134. GrManager::freeSingleton();
  135. Input::freeSingleton();
  136. NativeWindow::freeSingleton();
  137. #if ANKI_TRACING_ENABLED
  138. CoreTracer::freeSingleton();
  139. #endif
  140. GlobalFrameIndex::freeSingleton();
  141. m_settingsDir.destroy();
  142. m_cacheDir.destroy();
  143. CoreMemoryPool::freeSingleton();
  144. DefaultMemoryPool::freeSingleton();
  145. }
  146. Error App::init()
  147. {
  148. const Error err = initInternal();
  149. if(err)
  150. {
  151. ANKI_CORE_LOGE("App initialization failed. Shutting down");
  152. cleanup();
  153. }
  154. return err;
  155. }
  156. Error App::initInternal()
  157. {
  158. StatsSet::getSingleton().initFromMainThread();
  159. Logger::getSingleton().enableVerbosity(g_verboseLogCVar.get());
  160. AllocAlignedCallback allocCb = m_originalAllocCallback;
  161. void* allocCbUserData = m_originalAllocUserData;
  162. initMemoryCallbacks(allocCb, allocCbUserData);
  163. DefaultMemoryPool::allocateSingleton(allocCb, allocCbUserData);
  164. CoreMemoryPool::allocateSingleton(allocCb, allocCbUserData);
  165. ANKI_CHECK(initDirs());
  166. // Print a message
  167. const char* buildType =
  168. #if ANKI_OPTIMIZE
  169. "optimized, "
  170. #else
  171. "NOT optimized, "
  172. #endif
  173. #if ANKI_DEBUG_SYMBOLS
  174. "dbg symbols, "
  175. #else
  176. "NO dbg symbols, "
  177. #endif
  178. #if ANKI_EXTRA_CHECKS
  179. "extra checks, "
  180. #else
  181. "NO extra checks, "
  182. #endif
  183. #if ANKI_TRACING_ENABLED
  184. "built with tracing";
  185. #else
  186. "NOT built with tracing";
  187. #endif
  188. ANKI_CORE_LOGI("Initializing application ("
  189. "version %u.%u, "
  190. "%s, "
  191. "compiler %s, "
  192. "build date %s, "
  193. "commit %s)",
  194. ANKI_VERSION_MAJOR, ANKI_VERSION_MINOR, buildType, ANKI_COMPILER_STR, __DATE__, ANKI_REVISION);
  195. // Check SIMD support
  196. #if ANKI_SIMD_SSE && ANKI_COMPILER_GCC_COMPATIBLE
  197. if(!__builtin_cpu_supports("sse4.2"))
  198. {
  199. ANKI_CORE_LOGF("AnKi is built with sse4.2 support but your CPU doesn't support it. Try bulding without SSE support");
  200. }
  201. #endif
  202. ANKI_CORE_LOGI("Number of job threads: %u", g_jobThreadCountCVar.get());
  203. if(g_benchmarkModeCVar.get() && g_vsyncCVar.get())
  204. {
  205. ANKI_CORE_LOGW("Vsync is enabled and benchmark mode as well. Will turn vsync off");
  206. g_vsyncCVar.set(false);
  207. }
  208. GlobalFrameIndex::allocateSingleton();
  209. //
  210. // Core tracer
  211. //
  212. #if ANKI_TRACING_ENABLED
  213. ANKI_CHECK(CoreTracer::allocateSingleton().init(m_settingsDir));
  214. #endif
  215. //
  216. // Window
  217. //
  218. NativeWindowInitInfo nwinit;
  219. nwinit.m_width = g_windowWidthCVar.get();
  220. nwinit.m_height = g_windowHeightCVar.get();
  221. nwinit.m_depthBits = 0;
  222. nwinit.m_stencilBits = 0;
  223. nwinit.m_fullscreenDesktopRez = g_windowFullscreenCVar.get() > 0;
  224. nwinit.m_exclusiveFullscreen = g_windowFullscreenCVar.get() == 2;
  225. nwinit.m_targetFps = g_targetFpsCVar.get();
  226. NativeWindow::allocateSingleton();
  227. ANKI_CHECK(NativeWindow::getSingleton().init(nwinit));
  228. //
  229. // Input
  230. //
  231. Input::allocateSingleton();
  232. ANKI_CHECK(Input::getSingleton().init());
  233. //
  234. // ThreadPool
  235. //
  236. const Bool pinThreads = !ANKI_OS_ANDROID;
  237. CoreThreadJobManager::allocateSingleton(g_jobThreadCountCVar.get(), pinThreads);
  238. //
  239. // Graphics API
  240. //
  241. GrManagerInitInfo grInit;
  242. grInit.m_allocCallback = allocCb;
  243. grInit.m_allocCallbackUserData = allocCbUserData;
  244. grInit.m_cacheDirectory = m_cacheDir.toCString();
  245. ANKI_CHECK(GrManager::allocateSingleton().init(grInit));
  246. //
  247. // Mali HW counters
  248. //
  249. #if ANKI_PLATFORM_MOBILE
  250. if(ANKI_STATS_ENABLED && GrManager::getSingleton().getDeviceCapabilities().m_gpuVendor == GpuVendor::kArm && g_maliHwCountersCVar.get())
  251. {
  252. MaliHwCounters::allocateSingleton();
  253. }
  254. #endif
  255. //
  256. // GPU mem
  257. //
  258. UnifiedGeometryBuffer::allocateSingleton().init();
  259. GpuSceneBuffer::allocateSingleton().init();
  260. RebarTransientMemoryPool::allocateSingleton().init();
  261. GpuVisibleTransientMemoryPool::allocateSingleton();
  262. GpuReadbackMemoryPool::allocateSingleton();
  263. //
  264. // Physics
  265. //
  266. PhysicsWorld::allocateSingleton();
  267. ANKI_CHECK(PhysicsWorld::getSingleton().init(allocCb, allocCbUserData));
  268. //
  269. // Resources
  270. //
  271. #if !ANKI_OS_ANDROID
  272. // Add the location of the executable where the shaders are supposed to be
  273. String executableFname;
  274. ANKI_CHECK(getApplicationPath(executableFname));
  275. ANKI_CORE_LOGI("Executable path is: %s", executableFname.cstr());
  276. String extraPaths;
  277. getParentFilepath(executableFname, extraPaths);
  278. extraPaths += "|ankiprogbin"; // Shaders
  279. extraPaths += ":" ANKI_SOURCE_DIRECTORY "|EngineAssets,!AndroidProject"; // EngineAssets
  280. extraPaths += ":";
  281. extraPaths += g_dataPathsCVar.get();
  282. g_dataPathsCVar.set(extraPaths);
  283. #endif
  284. ANKI_CHECK(ResourceManager::allocateSingleton().init(allocCb, allocCbUserData));
  285. //
  286. // UI
  287. //
  288. ANKI_CHECK(UiManager::allocateSingleton().init(allocCb, allocCbUserData));
  289. //
  290. // GPU scene
  291. //
  292. ANKI_CHECK(GpuSceneMicroPatcher::allocateSingleton().init());
  293. //
  294. // Renderer
  295. //
  296. MainRendererInitInfo renderInit;
  297. renderInit.m_swapchainSize = UVec2(NativeWindow::getSingleton().getWidth(), NativeWindow::getSingleton().getHeight());
  298. renderInit.m_allocCallback = allocCb;
  299. renderInit.m_allocCallbackUserData = allocCbUserData;
  300. ANKI_CHECK(MainRenderer::allocateSingleton().init(renderInit));
  301. //
  302. // Script
  303. //
  304. ScriptManager::allocateSingleton(allocCb, allocCbUserData);
  305. //
  306. // Scene
  307. //
  308. ANKI_CHECK(SceneGraph::allocateSingleton().init(allocCb, allocCbUserData));
  309. ANKI_CORE_LOGI("Application initialized");
  310. return Error::kNone;
  311. }
  312. Error App::initDirs()
  313. {
  314. // Settings path
  315. #if !ANKI_OS_ANDROID
  316. String home;
  317. ANKI_CHECK(getHomeDirectory(home));
  318. m_settingsDir.sprintf("%s/.anki", &home[0]);
  319. #else
  320. m_settingsDir.sprintf("%s/.anki", g_androidApp->activity->internalDataPath);
  321. #endif
  322. if(!directoryExists(m_settingsDir.toCString()))
  323. {
  324. ANKI_CORE_LOGI("Creating settings dir \"%s\"", &m_settingsDir[0]);
  325. ANKI_CHECK(createDirectory(m_settingsDir.toCString()));
  326. }
  327. else
  328. {
  329. ANKI_CORE_LOGI("Using settings dir \"%s\"", &m_settingsDir[0]);
  330. }
  331. // Cache
  332. m_cacheDir.sprintf("%s/cache", &m_settingsDir[0]);
  333. const Bool cacheDirExists = directoryExists(m_cacheDir.toCString());
  334. if(g_clearCachesCVar.get() && cacheDirExists)
  335. {
  336. ANKI_CORE_LOGI("Will delete the cache dir and start fresh: %s", m_cacheDir.cstr());
  337. ANKI_CHECK(removeDirectory(m_cacheDir.toCString()));
  338. ANKI_CHECK(createDirectory(m_cacheDir.toCString()));
  339. }
  340. else if(!cacheDirExists)
  341. {
  342. ANKI_CORE_LOGI("Will create cache dir: %s", m_cacheDir.cstr());
  343. ANKI_CHECK(createDirectory(m_cacheDir.toCString()));
  344. }
  345. return Error::kNone;
  346. }
  347. Error App::mainLoop()
  348. {
  349. ANKI_CORE_LOGI("Entering main loop");
  350. Bool quit = false;
  351. Second prevUpdateTime = HighRezTimer::getCurrentTime();
  352. Second crntTime = prevUpdateTime;
  353. // Benchmark mode stuff:
  354. const Bool benchmarkMode = g_benchmarkModeCVar.get();
  355. Second aggregatedCpuTime = 0.0;
  356. Second aggregatedGpuTime = 0.0;
  357. constexpr U32 kBenchmarkFramesToGatherBeforeFlush = 60;
  358. U32 benchmarkFramesGathered = 0;
  359. File benchmarkCsvFile;
  360. CoreString benchmarkCsvFileFilename;
  361. if(benchmarkMode)
  362. {
  363. benchmarkCsvFileFilename.sprintf("%s/Benchmark.csv", m_settingsDir.cstr());
  364. ANKI_CHECK(benchmarkCsvFile.open(benchmarkCsvFileFilename, FileOpenFlag::kWrite));
  365. ANKI_CHECK(benchmarkCsvFile.writeText("CPU, GPU\n"));
  366. }
  367. while(!quit)
  368. {
  369. {
  370. ANKI_TRACE_SCOPED_EVENT(Frame);
  371. const Second startTime = HighRezTimer::getCurrentTime();
  372. prevUpdateTime = crntTime;
  373. crntTime = (!benchmarkMode) ? HighRezTimer::getCurrentTime() : (prevUpdateTime + 1.0_sec / 60.0_sec);
  374. // Update
  375. ANKI_CHECK(Input::getSingleton().handleEvents());
  376. // User update
  377. ANKI_CHECK(userMainLoop(quit, crntTime - prevUpdateTime));
  378. ANKI_CHECK(SceneGraph::getSingleton().update(prevUpdateTime, crntTime));
  379. // Render
  380. TexturePtr presentableTex = GrManager::getSingleton().acquireNextPresentableTexture();
  381. ANKI_CHECK(MainRenderer::getSingleton().render(presentableTex.get()));
  382. // If we get stats exclude the time of GR because it forces some GPU-CPU serialization. We don't want to count that
  383. Second grTime = 0.0;
  384. if(benchmarkMode || g_displayStatsCVar.get() > 0) [[unlikely]]
  385. {
  386. grTime = HighRezTimer::getCurrentTime();
  387. }
  388. GrManager::getSingleton().swapBuffers();
  389. if(benchmarkMode || g_displayStatsCVar.get() > 0) [[unlikely]]
  390. {
  391. grTime = HighRezTimer::getCurrentTime() - grTime;
  392. }
  393. RebarTransientMemoryPool::getSingleton().endFrame();
  394. UnifiedGeometryBuffer::getSingleton().endFrame();
  395. GpuSceneBuffer::getSingleton().endFrame();
  396. GpuVisibleTransientMemoryPool::getSingleton().endFrame();
  397. GpuReadbackMemoryPool::getSingleton().endFrame();
  398. // Sleep
  399. const Second endTime = HighRezTimer::getCurrentTime();
  400. const Second frameTime = endTime - startTime;
  401. g_cpuTotalTimeStatVar.set((frameTime - grTime) * 1000.0);
  402. if(!benchmarkMode) [[likely]]
  403. {
  404. const Second timerTick = 1.0_sec / Second(g_targetFpsCVar.get());
  405. if(frameTime < timerTick)
  406. {
  407. ANKI_TRACE_SCOPED_EVENT(TimerTickSleep);
  408. HighRezTimer::sleep(timerTick - frameTime);
  409. }
  410. }
  411. // Benchmark stats
  412. else
  413. {
  414. aggregatedCpuTime += frameTime - grTime;
  415. aggregatedGpuTime += 0; // TODO
  416. ++benchmarkFramesGathered;
  417. if(benchmarkFramesGathered >= kBenchmarkFramesToGatherBeforeFlush)
  418. {
  419. aggregatedCpuTime = aggregatedCpuTime / Second(kBenchmarkFramesToGatherBeforeFlush) * 1000.0;
  420. aggregatedGpuTime = aggregatedGpuTime / Second(kBenchmarkFramesToGatherBeforeFlush) * 1000.0;
  421. ANKI_CHECK(benchmarkCsvFile.writeTextf("%f,%f\n", aggregatedCpuTime, aggregatedGpuTime));
  422. benchmarkFramesGathered = 0;
  423. aggregatedCpuTime = 0.0;
  424. aggregatedGpuTime = 0.0;
  425. }
  426. }
  427. // Stats
  428. #if ANKI_PLATFORM_MOBILE
  429. if(MaliHwCounters::isAllocated())
  430. {
  431. MaliHwCountersOut out;
  432. MaliHwCounters::getSingleton().sample(out);
  433. g_maliGpuActiveStatVar.set(out.m_gpuActive);
  434. g_maliGpuReadBandwidthStatVar.set(out.m_readBandwidth);
  435. g_maliGpuWriteBandwidthStatVar.set(out.m_writeBandwidth);
  436. }
  437. #endif
  438. StatsSet::getSingleton().endFrame();
  439. ++GlobalFrameIndex::getSingleton().m_value;
  440. if(benchmarkMode) [[unlikely]]
  441. {
  442. if(GlobalFrameIndex::getSingleton().m_value >= g_benchmarkModeFrameCountCVar.get())
  443. {
  444. quit = true;
  445. }
  446. }
  447. }
  448. #if ANKI_TRACING_ENABLED
  449. static U64 frame = 1;
  450. CoreTracer::getSingleton().flushFrame(frame++);
  451. #endif
  452. }
  453. if(benchmarkMode) [[unlikely]]
  454. {
  455. ANKI_CORE_LOGI("Benchmark file saved in: %s", benchmarkCsvFileFilename.cstr());
  456. }
  457. return Error::kNone;
  458. }
  459. void App::initMemoryCallbacks(AllocAlignedCallback& allocCb, void*& allocCbUserData)
  460. {
  461. if(ANKI_STATS_ENABLED && g_displayStatsCVar.get() > 1)
  462. {
  463. allocCb = statsAllocCallback;
  464. allocCbUserData = this;
  465. }
  466. else
  467. {
  468. // Leave the default
  469. }
  470. }
  471. Bool App::toggleDeveloperConsole()
  472. {
  473. SceneNode& node = SceneGraph::getSingleton().findSceneNode("_DevConsole");
  474. static_cast<DeveloperConsoleUiNode&>(node).toggleConsole();
  475. m_consoleEnabled = static_cast<DeveloperConsoleUiNode&>(node).isConsoleEnabled();
  476. return m_consoleEnabled;
  477. }
  478. } // end namespace anki