20 using namespace RenderCore;
43 .enablePresent =
true,
44 .numRenderThreads = std::max(1u, std::thread::hardware_concurrency() - 1)
68 using FTick = glm::vec<2, size_t>;
234 CHECK_MSG(
mSwapchain,
"No swapchain created. Did you initialize the application with present=true?");
#define CHECK_MSG(expr, format_str,...)
Definition Logging.hpp:31
General Purpose Allocator (GPA) interface.
Definition Allocator.hpp:24
Allocator * Ptr()
Definition Allocator.hpp:38
General purpose heap allocator.
Definition HeapAllocator.hpp:11
Application base class. Handles initialization and shutdown of the native platform,...
Definition Application.hpp:48
Class representing a window for the platform.
Definition Application.hpp:15
Pair< uint32_t, uint32_t > GetFramebufferSize() const
Definition Application.cpp:28
Definition Swapchain.hpp:19
Renderer implementing a Frame Graph system with automatic resource tracking and synchronization.
Definition Renderer.hpp:78
Template base class for rendering applications.
Definition Application.hpp:51
Async::Thread mRenderThread
Definition Application.hpp:108
Allocator * GetAllocator()
Retrieve the allocator used for general application allocations.
Definition Application.hpp:244
void ResetRendererOnNextFrame()
Reset the renderer on the next frame, calling OnRendererSetup internally.
Definition Application.cpp:151
virtual void OnApplicationTick()
Action to take on every application tick.
Definition Application.hpp:196
ApplicationInitDesc mDesc
Definition Application.hpp:93
RHISwapchain * GetSwapchain() const
Retrieve the current RHISwapchain instance.
Definition Application.hpp:232
void Initialize(ApplicationInitDesc const &desc={}, Args &&... args)
Initialize the application with the specified RHI backend.
Definition Application.hpp:205
RHIExtent2D GetFramebufferSize() const
Retrieve the framebuffer size of the current window.
Definition Application.hpp:216
void WaitForFrame()
Wait for the render thread to start, or the next frame to be rendered.
Definition Application.cpp:146
FrameTiming mTiming
Definition Application.hpp:103
virtual void OnAfterFrame()
Action to take after each frame is executed.
Definition Application.hpp:154
void InitializeRenderer()
Definition Application.cpp:36
void CreateSwapchain()
Definition Application.cpp:17
void Shutdown()
Flag the application to exit.
Definition Application.cpp:152
virtual void OnRendererPostSetup()
Action to take after the renderer has been set up.
Definition Application.hpp:180
Renderer * GetRenderer() const
Retrieve the underlying Renderer instance.
Definition Application.hpp:228
bool mRenderThreadStarted
Definition Application.hpp:115
RHIApplicationScopedObjectHandle< RHIDevice > mDevice
Definition Application.hpp:99
virtual void OnRendererSetup()=0
Set up the renderer by creating passes, resources, and other configurations.
Async::Mutex mRenderMutex
Definition Application.hpp:110
virtual void OnDeviceSetup()
Actions to take after device specific resources has been set up.
Definition Application.hpp:128
Native::NativeWindow * GetNativeWindow()
Retrieve the current NativeWindow instance.
Definition Application.hpp:240
RHIDeviceScopedObjectHandle< RHISwapchain > mSwapchain
Definition Application.hpp:100
Allocator * GetRendererAllocator()
Retrieve the allocator used for renderer allocations.
Definition Application.hpp:248
DefaultAllocator mAlloc
Definition Application.hpp:95
void Execute()
Definition Application.cpp:64
UniquePtr< Renderer > mRenderer
Definition Application.hpp:102
bool mRenderThreadReset
Definition Application.hpp:113
bool mAppShouldClose
Definition Application.hpp:117
Native::NativeWindow mWindow
Definition Application.hpp:96
UniquePtr< RHIApplication > mRHI
Definition Application.hpp:97
void RunForever()
Start the Render thread and run the application loop indefinitely, until the window is closed or the ...
Definition Application.cpp:127
Async::Condition mRenderFrame
Definition Application.hpp:109
void RenderWorker()
Definition Application.cpp:80
virtual void OnBeforeFrame()
Action to take before each frame is executed.
Definition Application.hpp:141
void InitializeInternal()
Definition Application.cpp:49
DefaultAllocator mAllocRenderer
Definition Application.hpp:95
FrameTiming GetTiming() const
Retrieve the timing information of the last frame.
Definition Application.hpp:224
std::condition_variable Condition
Definition Future.hpp:14
std::jthread Thread
Alias of std::jthread.
Definition Thread.hpp:10
std::mutex Mutex
Definition Future.hpp:15
std::basic_string< char > String
Alias for std::basic_string<char>, without an explicit allocator constructor.
Definition Container.hpp:141
std::unique_ptr< T, StlDeleter< T > > UniquePtr
std::unique_ptr with custom deleter that uses a Foundation::Core::Allocator to deallocate memory.
Definition Allocator.hpp:161
glm::vec< 2, uint32_t > RHIExtent2D
Definition Common.hpp:10
Reference implementations of real-time rendering routines.
Definition Application.hpp:18
Parameters for Renderer creation.
Definition Renderer.hpp:17
bool enableAsyncCompute
Enable Async Compute support.
Definition Renderer.hpp:32
Initialization parameters for RenderApplication.
Definition Application.hpp:25
RHIExtent2D windowSize
Definition Application.hpp:28
size_t deviceIndex
Definition Application.hpp:26
RendererDesc renderer
Parameters for the initializing the underlying Renderer.
Definition Application.hpp:41
String windowTitle
Definition Application.hpp:27
bool initOnResize
Reinitialize the renderer when the window is resized.
Definition Application.hpp:37
Rolling frame timing information for performance measurements.
Definition Application.hpp:66
glm::vec< 2, size_t > FTick
Definition Application.hpp:68
size_t GetFPS() const
Definition Application.hpp:83
FTick begin
Definition Application.hpp:70
const size_t kTimingSampleDuration
Definition Application.hpp:89
FTick delta
Definition Application.hpp:70
FTick Tick(FTick const &t)
Definition Application.hpp:71