![]() |
Ultralight C++ API 1.4.0
|
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().
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).
When using Renderer::Create(), you can provide your own implementation of this class via Platform::set_gpu_driver().
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.
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.
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.
Public Member Functions | |
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. | |
|
virtual |
|
pure virtual |
Called before any state (eg, CreateTexture(), UpdateTexture(), DestroyTexture(), etc.) is updated during a call to Renderer::Render().
This is a good time to prepare the GPU for any state updates.
|
pure virtual |
Create geometry with certain ID and vertex/index data.
geometry_id | The geometry ID to use for the new geometry. |
vertices | The vertex buffer data. |
indices | The index buffer data. |
|
pure virtual |
Create a render buffer with certain ID and buffer description.
render_buffer_id | The render buffer ID to use for the new render buffer. |
buffer | The render buffer description. |
Create a texture with a certain ID and optional bitmap.
texture_id | The texture ID to use for the new texture. |
bitmap | The bitmap to initialize the texture with (can be empty). |
|
pure virtual |
Destroy geometry.
geometry_id | The geometry to destroy. |
|
pure virtual |
Destroy a render buffer.
render_buffer_id | The render buffer to destroy. |
|
pure virtual |
Destroy a texture.
texture_id | The texture to destroy. |
|
pure virtual |
Called after all state has been updated during a call to Renderer::Render().
|
pure virtual |
Get the next available geometry ID.
This is used to generate a unique geometry ID for each geometry created by the library. The GPU driver implementation is responsible for mapping these IDs to a native ID.
|
pure virtual |
Get the next available render buffer ID.
This is used to generate a unique render buffer ID for each render buffer created by the library. The GPU driver implementation is responsible for mapping these IDs to a native ID.
|
pure virtual |
Get the next available texture ID.
This is used to generate a unique texture ID for each texture created by the library. The GPU driver implementation is responsible for mapping these IDs to a native ID.
|
pure virtual |
Update the pending command list with commands to execute on the GPU.
Commands are dispatched to the GPU driver asynchronously via this method. The GPU driver implementation should consume these commands and execute them at an appropriate time.
list | The list of commands to execute. |
|
pure virtual |
Update existing geometry with new vertex/index data.
geometry_id | The geometry to update. |
vertices | The new vertex buffer data. |
indices | The new index buffer data. |
Update an existing non-RTT texture with new bitmap data.
texture_id | The texture to update. |
bitmap | The new bitmap data. |