2.9.16
Coherent GT
A modern user interface library for games
renoir::RendererBackend Class Referenceabstract

A Renoir renderer backend implements API or engine-specific rendering. Ready-made backends are provided and can be directly used or modified to fit engine needs. The backend has two logical types of operations. There are resource operations (create vertex buffer, index buffer, texture etc.) and actual rendering state commands (set pixel shader, draw etc.). The Renoir Core will call BeginCommands() before starting a batch for drawing and EndCommands() when it's finished. The commands can encompass multiple scenes and even frames. All resource commands happen vefore all state commands. This means that all resources will be created and/or updated and then ExecuteRendering() will be called with all the actual rendering on those resources. This behaviour is guaranteed, makes resource management much simpler and allow for easier parallelization of the backend. The backend also implements the "click-through" functionality. More...

#include <Coherent/renoir/include/RenoirBackend/RendererBackend.h>

Classes

struct  BackendCommandsBuffer
 Structure that holds a rendering commands list. More...
 
struct  ConstantBufferUpdateData
 Represents the full data for a frame of a constant buffer for bulk update. More...
 

Public Member Functions

virtual void FillCaps (RendererCaps &outCaps)=0
 Sets the "caps" flags of the backend. It's important to correctly set these flags for maximum performance.
 
virtual void BeginCommands ()=0
 Called when a new list of commands will be executed. You can put state-setting code here.
 
virtual void WrapUserRenderTarget (void *userObject, const Texture2D &description, Texture2DObject object, void *depthStencil, const DepthStencilTexture &dsDescription, DepthStencilTextureObject dsObject)=0
 Called to wrap a user-supplied RenderTarget in a handle used by Renoir. More...
 
virtual void WrapUserTexture (void *userObject, const Texture2D &description, Texture2DObject object)=0
 Called to wrap a user texture in a Renoir handle. More...
 
virtual bool CreatePipelineState (const PipelineState &state, PipelineStateObject object)=0
 Reqests the creation of a Pipeline state. The PSO contains shaders and blend, ds states. More...
 
virtual void DestroyPipelineState (PipelineStateObject object)=0
 Requests the destruction of a PSO.
 
virtual bool CreateVertexBuffer (VertexType type, unsigned count, VertexBufferObject object, bool changesOften)=0
 Create a vertex buffer with the specified format and size. More...
 
virtual void DestroyVertexBuffer (VertexBufferObject object)=0
 Requests the destruction of a VB.
 
virtual void * MapVertexBuffer (VertexBufferObject object)=0
 Map VB to RAM for update.
 
virtual void UnmapVertexBuffer (VertexBufferObject object, unsigned elementCount)=0
 Unmap vertex buffer. More...
 
virtual bool CreateIndexBuffer (IndexBufferType format, unsigned count, IndexBufferObject object, bool changesOften)=0
 Create an index buffer on the GPU. More...
 
virtual void DestroyIndexBuffer (IndexBufferObject object)=0
 Destroy index buffer.
 
virtual void * MapIndexBuffer (IndexBufferObject object)=0
 Maps an index buffer for update from the CPU.
 
virtual void UnmapIndexBuffer (IndexBufferObject object, unsigned elementCount)=0
 Unmaps an index buffer. More...
 
virtual bool CreateConstantBuffer (CBType type, ConstantBufferObject object, unsigned size)=0
 Creates a constant (uniform) buffer object. More...
 
virtual void DestroyConstantBuffer (ConstantBufferObject object)=0
 Requests the destruction of a constant buffer.
 
virtual bool CreateTexture (Texture2DObject texture, const Texture2D &description, const void *data, unsigned dataLen)=0
 Create a texture object. More...
 
virtual void DestroyTexture (Texture2DObject texture)=0
 Destroy a texture.
 
virtual void UpdateTexture (Texture2DObject texture, const Texture2D &description, UpdateBox *boxes, const void **newBytes, unsigned count, bool willOverwrite)=0
 Update the contents of a texture. More...
 
virtual bool CreateDepthStencilTexture (DepthStencilTextureObject object, const DepthStencilTexture &description)=0
 Create a depth-stencil texture. More...
 
virtual void DestroyDepthStencilTexture (DepthStencilTextureObject object)=0
 Destroy a DS texture.
 
virtual bool CreateSampler2D (Sampler2DObject sampler, const Sampler2D &description)=0
 Create a sampler object for 2D textures.
 
virtual void DestroySampler2D (Sampler2DObject sampler)=0
 Destroy sampler.
 
virtual void ExecuteRendering (const BackendCommandsBuffer *buffers, unsigned buffersCount, const ConstantBufferUpdateData *CBOUpdates, unsigned CBOUpdatesCount)=0
 Actual rendering commands that operate on updated and ready resources. More...
 
virtual void EndCommands ()=0
 Called when a list buffers is executed.
 
virtual class DynamicRendererBackend * GetDynamicInterface ()
 Tells if the backend is a special "dynamic" type that allows additional runtime operations like creating shaders on runtime.
 
virtual bool ReadTexture (TextureObject, const UpdateBox &, void *)
 Reads texture from GPU memory to data Used for capturing command buffers for replay Returns wheather it read the texture.
 

Detailed Description

A Renoir renderer backend implements API or engine-specific rendering. Ready-made backends are provided and can be directly used or modified to fit engine needs. The backend has two logical types of operations. There are resource operations (create vertex buffer, index buffer, texture etc.) and actual rendering state commands (set pixel shader, draw etc.). The Renoir Core will call BeginCommands() before starting a batch for drawing and EndCommands() when it's finished. The commands can encompass multiple scenes and even frames. All resource commands happen vefore all state commands. This means that all resources will be created and/or updated and then ExecuteRendering() will be called with all the actual rendering on those resources. This behaviour is guaranteed, makes resource management much simpler and allow for easier parallelization of the backend. The backend also implements the "click-through" functionality.

Member Function Documentation

◆ CreateConstantBuffer()

virtual bool renoir::RendererBackend::CreateConstantBuffer ( CBType  type,
ConstantBufferObject  object,
unsigned  size 
)
pure virtual

Creates a constant (uniform) buffer object.

Parameters
typeIndicates the type of the constant buffer object
objectRenoir handle
sizerequested byte size of the constant buffer

◆ CreateDepthStencilTexture()

virtual bool renoir::RendererBackend::CreateDepthStencilTexture ( DepthStencilTextureObject  object,
const DepthStencilTexture description 
)
pure virtual

Create a depth-stencil texture.

Parameters
objectRenoir handle
descriptionDescription of the DS texture

◆ CreateIndexBuffer()

virtual bool renoir::RendererBackend::CreateIndexBuffer ( IndexBufferType  format,
unsigned  count,
IndexBufferObject  object,
bool  changesOften 
)
pure virtual

Create an index buffer on the GPU.

Parameters
countcount of indices in the buffer
objectRenoir handle
changesOftenIndicates that the buffer will be mapped/unmapped often

◆ CreatePipelineState()

virtual bool renoir::RendererBackend::CreatePipelineState ( const PipelineState state,
PipelineStateObject  object 
)
pure virtual

Reqests the creation of a Pipeline state. The PSO contains shaders and blend, ds states.

Parameters
statedescription of the required state
objectRenoir handle to the PSO

◆ CreateTexture()

virtual bool renoir::RendererBackend::CreateTexture ( Texture2DObject  texture,
const Texture2D description,
const void *  data,
unsigned  dataLen 
)
pure virtual

Create a texture object.

Parameters
textureRenoir handle
descriptionDescription of the texture to create
dataInital content of the texture (could be nullptr)
dataLenSize in bytes of the inital data

◆ CreateVertexBuffer()

virtual bool renoir::RendererBackend::CreateVertexBuffer ( VertexType  type,
unsigned  count,
VertexBufferObject  object,
bool  changesOften 
)
pure virtual

Create a vertex buffer with the specified format and size.

Parameters
typeThe type of the vertices in the buffer
countthe elements count in the buffer
objectRenoir handle to the VB
changesOftenIndicates that the buffer will be mapped/unmapped often

◆ ExecuteRendering()

virtual void renoir::RendererBackend::ExecuteRendering ( const BackendCommandsBuffer buffers,
unsigned  buffersCount,
const ConstantBufferUpdateData CBOUpdates,
unsigned  CBOUpdatesCount 
)
pure virtual

Actual rendering commands that operate on updated and ready resources.

Parameters
buffersList of command buffer to execute
buffersCountCount of buffers to execute

◆ UnmapIndexBuffer()

virtual void renoir::RendererBackend::UnmapIndexBuffer ( IndexBufferObject  object,
unsigned  elementCount 
)
pure virtual

Unmaps an index buffer.

Parameters
objectRenoir handle
elementCountcount of elements that were "touched" during the update

◆ UnmapVertexBuffer()

virtual void renoir::RendererBackend::UnmapVertexBuffer ( VertexBufferObject  object,
unsigned  elementCount 
)
pure virtual

Unmap vertex buffer.

Parameters
objectRenoir handle
countof elements that were actually "touched" during the update

◆ UpdateTexture()

virtual void renoir::RendererBackend::UpdateTexture ( Texture2DObject  texture,
const Texture2D description,
UpdateBox boxes,
const void **  newBytes,
unsigned  count,
bool  willOverwrite 
)
pure virtual

Update the contents of a texture.

Parameters
textureRenoir handle
descriptionThe description of the texture to update
boxesList of boxes to update
newBytesList of pointers with the new data
countCount of regions (boxes) to update
willOverwriteIndicates if the update operation will potentially overwrite a region that is in-use. Some textures never update previous regions and this can be used as an optimization.

◆ WrapUserRenderTarget()

virtual void renoir::RendererBackend::WrapUserRenderTarget ( void *  userObject,
const Texture2D description,
Texture2DObject  object,
void *  depthStencil,
const DepthStencilTexture dsDescription,
DepthStencilTextureObject  dsObject 
)
pure virtual

Called to wrap a user-supplied RenderTarget in a handle used by Renoir.

Parameters
userObjectOpaque object that contains the user-supplied RT
descriptionDescription of the RT
objectRenoir handle to the object
depthStencilopaque object that contains the user-supplied DS texture dsDescription Depth-stencil texture description
dsObjectRenoir handle to the DS texture

◆ WrapUserTexture()

virtual void renoir::RendererBackend::WrapUserTexture ( void *  userObject,
const Texture2D description,
Texture2DObject  object 
)
pure virtual

Called to wrap a user texture in a Renoir handle.

Parameters
userObjectopaque object that contains the user-supplied Texture
descriptionDescription of the Texture
objectRenoir handle to the Texture