User-defined GPU driver interface.
The library uses this to optionally render Views on the GPU (see ViewConfig::is_accelerated).
You can provide the library with your own GPU driver implementation so that all rendering is performed using an existing GPU context (useful for game engines).
When a View is rendered on the GPU, you can retrieve the backing texture ID via View::render_target().
Default Implementation
A platform-specific implementation of GPUDriver is provided for you when you call App::Create(), (currently D3D11, Metal, and OpenGL). We recommend using these classes as a starting point for your own implementation (available open-source in the AppCore repository on GitHub).
Setting the GPU Driver
When using Renderer::Create(), you can provide your own implementation of this class via Platform::set_gpu_driver().
State Synchronization
During each call to Renderer::Render(), the library will update the state of the GPU driver (textures, render buffers, geometry, command lists, etc.) to match the current state of the library.
Detecting State Changes
The library will call BeginSynchronize() before any state is updated and EndSynchronize() after all state is updated. All Create
/ Update
/ Destroy
calls will be made between these two calls.
This allows the GPU driver implementation to prepare the GPU for any state changes.
Drawing
All drawing is done via command lists (UpdateCommandList()) to allow asynchronous execution of commands on the GPU.
The library will dispatch a list of commands to the GPU driver during state synchronization. The GPU driver implementation should periodically consume the command list and execute the commands at an appropriate time.
- See also
- Platform::set_gpu_driver()
|
virtual | ~GPUDriver () |
|
virtual void | BeginSynchronize ()=0 |
| Called before any state (eg, CreateTexture(), UpdateTexture(), DestroyTexture(), etc.) is updated during a call to Renderer::Render().
|
|
virtual void | EndSynchronize ()=0 |
| Called after all state has been updated during a call to Renderer::Render().
|
|
virtual uint32_t | NextTextureId ()=0 |
| Get the next available texture ID.
|
|
virtual void | CreateTexture (uint32_t texture_id, RefPtr< Bitmap > bitmap)=0 |
| Create a texture with a certain ID and optional bitmap.
|
|
virtual void | UpdateTexture (uint32_t texture_id, RefPtr< Bitmap > bitmap)=0 |
| Update an existing non-RTT texture with new bitmap data.
|
|
virtual void | DestroyTexture (uint32_t texture_id)=0 |
| Destroy a texture.
|
|
virtual uint32_t | NextRenderBufferId ()=0 |
| Get the next available render buffer ID.
|
|
virtual void | CreateRenderBuffer (uint32_t render_buffer_id, const RenderBuffer &buffer)=0 |
| Create a render buffer with certain ID and buffer description.
|
|
virtual void | DestroyRenderBuffer (uint32_t render_buffer_id)=0 |
| Destroy a render buffer.
|
|
virtual uint32_t | NextGeometryId ()=0 |
| Get the next available geometry ID.
|
|
virtual void | CreateGeometry (uint32_t geometry_id, const VertexBuffer &vertices, const IndexBuffer &indices)=0 |
| Create geometry with certain ID and vertex/index data.
|
|
virtual void | UpdateGeometry (uint32_t geometry_id, const VertexBuffer &vertices, const IndexBuffer &indices)=0 |
| Update existing geometry with new vertex/index data.
|
|
virtual void | DestroyGeometry (uint32_t geometry_id)=0 |
| Destroy geometry.
|
|
virtual void | UpdateCommandList (const CommandList &list)=0 |
| Update the pending command list with commands to execute on the GPU.
|
|