Class GPUManager
Defined in File GPU.hpp
Class Documentation
-
class GPUManager
The centralized GPU interaction system.
Public Types
Public Functions
-
void Start()
Start the GPU manager.
- Throws:
BadInitStateException – If the GPU manager is already running
BadStateException – If the graphics backend and window are not connected
-
inline bool IsRunning() const
Check if the GPU manager is running.
- Returns:
Whether the GPU manager is running
-
std::shared_future<void> Submit(std::unique_ptr<CommandBuffer> cmd)
Submit a task to the GPU for processing.
Warning
Exercise caution when using this API in order to avoid conflicting with other engine systems
- Parameters:
cmd – The CommandBuffer containing the task to execute
- Returns:
A future that will resolve when the task has finished executing
-
void SetVSync(bool newState)
Set the V-Sync state.
Note
Depending on what rendering API is in use, the change may not take effect instantly. However, it is guaranteed to take effect.
- Parameters:
newState – Whether V-Sync should be enabled
- Throws:
BadInitStateException – If the GPU manager is not running
-
bool IsVSynced()
Check the V-Sync state.
Note
If
SetVSynchas just been called, this function will return the new value, even if it has not yet taken effect on the GPU- Throws:
BadInitStateException – If the GPU manager is not running
- Returns:
If V-Sync is currently enabled
-
unsigned int GetCurrentFPS()
Check the current FPS (frames per second) of the engine.
- Returns:
The FPS
-
xg::Guid RegisterRenderingCallback(std::function<void(std::unique_ptr<CommandBuffer>&)> callback, Phase phase, bool runPost)
Register a custom rendering callback.
- Parameters:
callback – The function to run
phase – What rendering phase to run the callback in
runPost – Whether to run the callback post-phase (if true) or pre-phase (if false)
- Returns:
A GUID that can be used to unregister the callback
-
void UnregisterRenderingCallback(const xg::Guid &callbackGUID)
Unregister a custom rendering callback.
- Parameters:
callbackGUID – The GUID returned from the registration function to identify the callback
- Throws:
NonexistentValueException – If no registered callback is associated with the provided GUID
Public Static Functions
-
static GPUManager &Get()
Get the instance and create one if there isn’t one.
- Returns:
The instance
-
void Start()