| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- // Copyright (C) 2009-2023, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- #pragma once
- #include <AnKi/Core/Common.h>
- #include <AnKi/Util/String.h>
- #include <AnKi/Util/Ptr.h>
- #include <AnKi/Ui/UiImmediateModeBuilder.h>
- namespace anki {
- // Forward
- class CoreTracer;
- class ThreadHive;
- class NativeWindow;
- class Input;
- class GrManager;
- class MainRenderer;
- class SceneGraph;
- class ScriptManager;
- class ResourceManager;
- class ResourceFilesystem;
- class RebarStagingGpuMemoryPool;
- class UnifiedGeometryMemoryPool;
- class UiManager;
- class UiQueueElement;
- class RenderQueue;
- class MaliHwCounters;
- class GpuSceneMemoryPool;
- class GpuSceneMicroPatcher;
- /// The core class of the engine.
- class App
- {
- public:
- App();
- virtual ~App();
- /// Initialize the application.
- Error init(AllocAlignedCallback allocCb, void* allocCbUserData);
- const String& getSettingsDirectory() const
- {
- return m_settingsDir;
- }
- const String& getCacheDirectory() const
- {
- return m_cacheDir;
- }
- ThreadHive& getThreadHive()
- {
- return *m_threadHive;
- }
- HeapMemoryPool& getMemoryPool()
- {
- return m_mainPool;
- }
- Timestamp getGlobalTimestamp() const
- {
- return m_globalTimestamp;
- }
- /// Run the main loop.
- Error mainLoop();
- /// The user code to run along with the other main loop code.
- virtual Error userMainLoop([[maybe_unused]] Bool& quit, [[maybe_unused]] Second elapsedTime)
- {
- // Do nothing
- return Error::kNone;
- }
- Input& getInput()
- {
- return *m_input;
- }
- SceneGraph& getSceneGraph()
- {
- return *m_scene;
- }
- MainRenderer& getMainRenderer()
- {
- return *m_renderer;
- }
- ResourceManager& getResourceManager()
- {
- return *m_resources;
- }
- ScriptManager& getScriptManager()
- {
- return *m_script;
- }
- NativeWindow& getWindow()
- {
- return *m_window;
- }
- void setDisplayDeveloperConsole(Bool display)
- {
- m_consoleEnabled = display;
- }
- Bool getDisplayDeveloperConsole() const
- {
- return m_consoleEnabled;
- }
- private:
- HeapMemoryPool m_mainPool;
- // Sybsystems
- #if ANKI_ENABLE_TRACE
- CoreTracer* m_coreTracer = nullptr;
- #endif
- NativeWindow* m_window = nullptr;
- Input* m_input = nullptr;
- ThreadHive* m_threadHive = nullptr;
- GrManager* m_gr = nullptr;
- MaliHwCounters* m_maliHwCounters = nullptr;
- UnifiedGeometryMemoryPool* m_unifiedGometryMemPool = nullptr;
- GpuSceneMemoryPool* m_gpuSceneMemPool = nullptr;
- GpuSceneMicroPatcher* m_gpuSceneMicroPatcher = nullptr;
- RebarStagingGpuMemoryPool* m_rebarPool = nullptr;
- ResourceFilesystem* m_resourceFs = nullptr;
- ResourceManager* m_resources = nullptr;
- UiManager* m_ui = nullptr;
- MainRenderer* m_renderer = nullptr;
- SceneGraph* m_scene = nullptr;
- ScriptManager* m_script = nullptr;
- // Misc
- UiImmediateModeBuilderPtr m_statsUi;
- UiImmediateModeBuilderPtr m_console;
- Bool m_consoleEnabled = false;
- Timestamp m_globalTimestamp = 1;
- String m_settingsDir; ///< The path that holds the configuration
- String m_cacheDir; ///< This is used as a cache
- U64 m_resourceCompletedAsyncTaskCount = 0;
- class MemStats
- {
- public:
- Atomic<PtrSize> m_allocatedMem = {0};
- Atomic<U64> m_allocCount = {0};
- Atomic<U64> m_freeCount = {0};
- void* m_originalUserData = nullptr;
- AllocAlignedCallback m_originalAllocCallback = nullptr;
- static void* allocCallback(void* userData, void* ptr, PtrSize size, PtrSize alignment);
- } m_memStats;
- void initMemoryCallbacks(AllocAlignedCallback& allocCb, void*& allocCbUserData);
- Error initInternal(AllocAlignedCallback allocCb, void* allocCbUserData);
- Error initDirs();
- void cleanup();
- /// Inject a new UI element in the render queue for displaying various stuff.
- void injectUiElements(DynamicArrayRaii<UiQueueElement>& elements, RenderQueue& rqueue);
- void setSignalHandlers();
- };
- } // end namespace anki
|