![]() |
LLGL 0.05 Beta
|
Render system interface. More...
#include <RenderSystem.h>
Public Member Functions | |
| ~RenderSystem () | |
| Releases the internal data. | |
| int | GetRendererID () const |
| Rendering API identification number. | |
| const char * | GetName () const |
| Returns the name of this render system, e.g. "Direct3D 12". | |
| const RendererInfo & | GetRendererInfo () |
| Returns basic renderer information. | |
| const RenderingCapabilities & | GetRenderingCaps () |
| Returns the rendering capabilities. | |
| const Report * | GetReport () const |
| Returns a pointer to the report or null if there is none. | |
| virtual SwapChain * | CreateSwapChain (const SwapChainDescriptor &swapChainDesc, const std::shared_ptr< Surface > &surface={})=0 |
| Creates a new swap-chain. At least one swap-chain is required to render into an output surface. | |
| virtual void | Release (SwapChain &swapChain)=0 |
| Releases the specified swap-chain. After this call, the specified object must no longer be used. | |
| virtual CommandQueue * | GetCommandQueue ()=0 |
| Returns the single instance of the command queue. | |
| virtual CommandBuffer * | CreateCommandBuffer (const CommandBufferDescriptor &commandBufferDesc={})=0 |
| Creates a new command buffer. | |
| virtual void | Release (CommandBuffer &commandBuffer)=0 |
| Releases the specified command buffer. After this call, the specified object must no longer be used. | |
| virtual Buffer * | CreateBuffer (const BufferDescriptor &bufferDesc, const void *initialData=nullptr)=0 |
| Creates a new generic hardware buffer. | |
| virtual BufferArray * | CreateBufferArray (ArrayView< VertexBufferView > bufferViews)=0 |
| Creates a new buffer array. | |
| virtual void | Release (Buffer &buffer)=0 |
| Releases the specified buffer object. After this call, the specified object must no longer be used. | |
| virtual void | Release (BufferArray &bufferArray)=0 |
| Releases the specified buffer array object. After this call, the specified object must no longer be used. | |
| virtual void | WriteBuffer (Buffer &buffer, std::uint64_t offset, const void *data, std::uint64_t dataSize)=0 |
| Updates the data of the specified buffer. | |
| virtual void | ReadBuffer (Buffer &buffer, std::uint64_t offset, void *data, std::uint64_t dataSize)=0 |
| Reads the data from the specified buffer. | |
| virtual void * | MapBuffer (Buffer &buffer, const CPUAccess access)=0 |
| Maps the specified buffer from GPU to CPU memory space. | |
| virtual void * | MapBuffer (Buffer &buffer, const CPUAccess access, std::uint64_t offset, std::uint64_t length)=0 |
| Maps the specified buffer range from GPU to CPU memory space. | |
| virtual void | UnmapBuffer (Buffer &buffer)=0 |
| Unmaps the specified buffer. | |
| virtual Texture * | CreateTexture (const TextureDescriptor &textureDesc, const ImageView *initialImage=nullptr)=0 |
| Creates a new texture. | |
| virtual void | Release (Texture &texture)=0 |
| Releases the specified texture object. After this call, the specified object must no longer be used. | |
| virtual void | WriteTexture (Texture &texture, const TextureRegion &textureRegion, const ImageView &srcImageView)=0 |
| Updates the image data of the specified texture. | |
| virtual void | ReadTexture (Texture &texture, const TextureRegion &textureRegion, const MutableImageView &dstImageView)=0 |
| Reads the image data from the specified texture. | |
| virtual Sampler * | CreateSampler (const SamplerDescriptor &samplerDesc)=0 |
| Creates a new Sampler object. | |
| virtual void | Release (Sampler &sampler)=0 |
| Releases the specified Sampler object. After this call, the specified object must no longer be used. | |
| virtual ResourceHeap * | CreateResourceHeap (const ResourceHeapDescriptor &resourceHeapDesc, ArrayView< ResourceViewDescriptor > initialResourceViews={})=0 |
| Creates a new resource heap. | |
| virtual void | Release (ResourceHeap &resourceHeap)=0 |
| Releases the specified ResourceHeap object. After this call, the specified object must no longer be used. | |
| virtual std::uint32_t | WriteResourceHeap (ResourceHeap &resourceHeap, std::uint32_t firstDescriptor, ArrayView< ResourceViewDescriptor > resourceViews)=0 |
| Writes new resource view descriptors into the specified resource heap. | |
| virtual RenderPass * | CreateRenderPass (const RenderPassDescriptor &renderPassDesc)=0 |
| Creates a new RenderPass object. | |
| virtual void | Release (RenderPass &renderPass)=0 |
| Releases the specified RenderPass object. After this call, the specified object must no longer be used. | |
| virtual RenderTarget * | CreateRenderTarget (const RenderTargetDescriptor &renderTargetDesc)=0 |
| Creates a new RenderTarget object. | |
| virtual void | Release (RenderTarget &renderTarget)=0 |
| Releases the specified RenderTarget object. After this call, the specified object must no longer be used. | |
| virtual Shader * | CreateShader (const ShaderDescriptor &shaderDesc)=0 |
| Creates a new and Shader object and compiles the specified source. | |
| virtual void | Release (Shader &shader)=0 |
| Releases the specified Shader object. After this call, the specified object must no longer be used. | |
| virtual PipelineLayout * | CreatePipelineLayout (const PipelineLayoutDescriptor &pipelineLayoutDesc)=0 |
| Creates a new and initialized pipeline layout object, if and only if the renderer supports pipeline layouts. | |
| virtual void | Release (PipelineLayout &pipelineLayout)=0 |
| Releases the specified PipelineLayout object. After this call, the specified object must no longer be used. | |
| virtual PipelineCache * | CreatePipelineCache (const Blob &initialBlob={})=0 |
| Creates a new pipeline cache with optional initial data. | |
| virtual void | Release (PipelineCache &pipelineCache)=0 |
| Releases the specified PipelineCache object. After this call, the specified object must no longer be used. | |
| virtual PipelineState * | CreatePipelineState (const GraphicsPipelineDescriptor &pipelineStateDesc, PipelineCache *pipelineCache=nullptr)=0 |
| Creates a new graphics pipeline state object (PSO). | |
| virtual PipelineState * | CreatePipelineState (const ComputePipelineDescriptor &pipelineStateDesc, PipelineCache *pipelineCache=nullptr)=0 |
| Creates a new compute pipeline state object (PSO). | |
| virtual PipelineState * | CreatePipelineState (const MeshPipelineDescriptor &pipelineStateDesc, PipelineCache *pipelineCache=nullptr)=0 |
| Creates a new mesh pipeline state object (PSO) if supported. | |
| virtual void | Release (PipelineState &pipelineState)=0 |
| Releases the specified PipelineState object. After this call, the specified object must no longer be used. | |
| virtual QueryHeap * | CreateQueryHeap (const QueryHeapDescriptor &queryHeapDesc)=0 |
| Creates a new query heap. | |
| virtual void | Release (QueryHeap &queryHeap)=0 |
| Releases the specified QueryHeap object. After this call, the specified object must no longer be used. | |
| virtual Fence * | CreateFence ()=0 |
| Creates a new fence (used for CPU/GPU synchronization). | |
| virtual void | Release (Fence &fence)=0 |
| Releases the specified Fence object. After this call, the specified object must no longer be used. | |
| virtual bool | GetNativeHandle (void *nativeHandle, std::size_t nativeHandleSize)=0 |
| Returns the native device handle. | |
| Public Member Functions inherited from LLGL::Interface | |
| virtual bool | IsInstanceOf (int id) const |
| Returns true if this object is an instance of the specified interface. | |
| Public Member Functions inherited from LLGL::NonCopyable | |
| NonCopyable (const NonCopyable &)=delete | |
| NonCopyable & | operator= (const NonCopyable &)=delete |
| virtual | ~NonCopyable ()=default |
Static Public Member Functions | |
| static std::vector< std::string > | FindModules () |
| Returns the list of all available render system modules for the current platform. | |
| static RenderSystemPtr | Load (const RenderSystemDescriptor &renderSystemDesc, Report *report=nullptr) |
| Loads a new render system from the specified module. | |
| static void | Unload (RenderSystemPtr &&renderSystem) |
| Unloads the specified render system and the internal module. | |
Protected Member Functions | |
| RenderSystem () | |
| Allocates the internal data. | |
| Report & | GetMutableReport () |
| Returns the internal report of this render system to be modified by the renderer implementation. | |
| void | Errorf (const char *format,...) |
| Prints a formatted string and replaces the current render system report with it as error. | |
| virtual bool | QueryRendererDetails (RendererInfo *outInfo, RenderingCapabilities *outCaps)=0 |
| Queries the renderer information and capabilities. | |
| Protected Member Functions inherited from LLGL::NonCopyable | |
| NonCopyable ()=default | |
Static Protected Member Functions | |
| static void | AssertCreateBuffer (const BufferDescriptor &bufferDesc, std::uint64_t maxSize) |
| Validates the specified buffer descriptor to be used for buffer creation. | |
| static void | AssertCreateShader (const ShaderDescriptor &shaderDesc) |
| Validates the specified shader descriptor. | |
Render system interface.
Create*, Write*, Read*, Map*, Unmap*, and Release: | LLGL::RenderSystem::~RenderSystem | ( | ) |
Releases the internal data.
|
protected |
Allocates the internal data.
|
staticprotected |
Validates the specified buffer descriptor to be used for buffer creation.
|
staticprotected |
Validates the specified shader descriptor.
|
pure virtual |
Creates a new generic hardware buffer.
| [in] | bufferDesc | Specifies the buffer descriptor. |
| [in] | initialData | Optional raw pointer to the data with which the buffer is to be initialized. This may also be null, to only initialize the size of the buffer. In this case, the buffer must be initialized with the "WriteBuffer" function before it is used for drawing operations. By default null. |
|
pure virtual |
Creates a new buffer array.
| [in] | bufferViews | Array of vertex buffer buffer views with optional strides and offsets. |
|
pure virtual |
Creates a new command buffer.
| [in] | commandBufferDesc | Specifies an optional command buffer descriptor. |
|
pure virtual |
Creates a new fence (used for CPU/GPU synchronization).
|
pure virtual |
Creates a new pipeline cache with optional initial data.
| [in] | initialBlob | Specifies an optional blob to initialize the pipeline cache. If no initial blob is provided, the pipeline cache will be initialized the first time it is used to create a PSO. If the backend does not support pipeline caching, the initial blob may be ignored and the pipeline cache cannot be used to store arbitrary blobs of data. |
|
pure virtual |
Creates a new and initialized pipeline layout object, if and only if the renderer supports pipeline layouts.
| [in] | pipelineLayoutDesc | Specifies the pipeline layout descriptor with all layout bindings. |
|
pure virtual |
Creates a new compute pipeline state object (PSO).
| [in] | pipelineStateDesc | Specifies the compute PSO descriptor. This will describe the entire pipeline state. The computeShader member of the descriptor must never be null! |
| [out] | pipelineCache | Optional pointer to pipeline cache. |
|
pure virtual |
Creates a new graphics pipeline state object (PSO).
| [in] | pipelineStateDesc | Specifies the graphics PSO descriptor. This will describe the entire pipeline state, i.e. the blending-, rasterizer-, depth-, stencil- and shader states. The vertexShader member of the descriptor must never be null! |
| [out] | pipelineCache | Optional pointer to pipeline cache. |
|
pure virtual |
Creates a new mesh pipeline state object (PSO) if supported.
| [in] | pipelineStateDesc | Specifies the mesh PSO descriptor. The meshShader member of the descriptor must never be null! |
| [out] | pipelineCache | Optional pointer to pipeline cache. |
|
pure virtual |
Creates a new query heap.
|
pure virtual |
Creates a new RenderPass object.
|
pure virtual |
Creates a new RenderTarget object.
|
pure virtual |
Creates a new resource heap.
| [in] | resourceHeapDesc | Specifies the descriptor for the resource heap. If the numResourceViews field is zero, the initialResourceViews parameter will determine the number of resources, it must not be empty and it must be a multiple of the number of bindings in the pipeline layout. |
| [in] | initialResourceViews | Specifies an optional array of initial resource views. If this is non-null, the array pointed to must have enough elements to initialize the entire resource heap. Uninitialized resource views must be written with a call to WriteResourceHeap before the resource heap can be used in a command buffer. |
|
pure virtual |
Creates a new Sampler object.
|
pure virtual |
Creates a new and Shader object and compiles the specified source.
HasErrors and GetReport functions of the Shader interface.
|
pure virtual |
Creates a new swap-chain. At least one swap-chain is required to render into an output surface.
| [in] | swapChainDesc | Specifies the swap-chain descriptor, which contains resolution, bit depth, multi-sampling settings etc. |
| [in] | surface | Optional shared pointer to a surface for the swap-chain. If this is null, the swap-chain will create its own platform specific surface, which can be accessed by SwapChain::GetSurface. The default surface on desktop platforms (i.e. Window interface) is not shown automatically, i.e. the Window::Show function has to be invoked to show the surface. |
|
pure virtual |
Creates a new texture.
| [in] | textureDesc | Specifies the texture descriptor. |
| [in] | initialImage | Optional pointer to an image view that provides the initial image data. If this is null, the texture will be initialized with the currently configured default image color (if this feature is enabled). If this is non-null, it is used to initialize the texture data. This parameter will be ignored if the texture type is a multi-sampled texture (i.e. TextureType::Texture2DMS or TextureType::Texture2DMSArray). |
|
protected |
Prints a formatted string and replaces the current render system report with it as error.
|
static |
Returns the list of all available render system modules for the current platform.
{ "Direct3D12", "Direct3D11", "OpenGL" }, but on MacOS it might be { "Metal", "OpenGL" }.
|
pure virtual |
Returns the single instance of the command queue.
|
protected |
Returns the internal report of this render system to be modified by the renderer implementation.
| const char * LLGL::RenderSystem::GetName | ( | ) | const |
Returns the name of this render system, e.g. "Direct3D 12".
|
pure virtual |
Returns the native device handle.
| [out] | nativeHandle | Raw pointer to the backend specific structure to store the native handle. Obtain the respective structure from #include <LLGL/Backend/BACKEND/NativeHandle.h> where BACKEND must be either Direct3D12, Direct3D11, Vulkan, Metal, or OpenGL. |
| [in] | nativeHandleSize | Specifies the size (in bytes) of the native handle structure for robustness. This must be sizeof(STRUCT) where STRUCT is the respective backend specific structure such as LLGL::Direct3D12::RenderSystemNativeHandle. |
nativeHandleSize specifies an incompatible structure size.IUnknown::Release is required to each of the objects returned by this function. NSObject instances will have their retain counter incremented and the user is responsible for releasing those objects, i.e. a call to -(oneway void)release is required to each of the objects returned by this function. nativeHandle is null or nativeHandleSize is 0. | int LLGL::RenderSystem::GetRendererID | ( | ) | const |
Rendering API identification number.
| const RendererInfo & LLGL::RenderSystem::GetRendererInfo | ( | ) |
Returns basic renderer information.
| const RenderingCapabilities & LLGL::RenderSystem::GetRenderingCaps | ( | ) |
Returns the rendering capabilities.
| const Report * LLGL::RenderSystem::GetReport | ( | ) | const |
Returns a pointer to the report or null if there is none.
::GetLastError() from the Windows API.
|
static |
Loads a new render system from the specified module.
| [in] | renderSystemDesc | Specifies the render system descriptor structure. The 'moduleName' member of this structure must not be empty. |
| [out] | report | Optional pointer to a report on potential failure of loading the specified module. |
report if it's a valid pointer.
|
pure virtual |
Maps the specified buffer from GPU to CPU memory space.
| [in] | buffer | Specifies the buffer which is to be mapped. Depending on the CPU access type (see access parameter), this buffer must have been created with the corresponding CPU access flag, i.e. CPUAccessFlags::Read and/or CPUAccessFlags::Write. |
| [in] | access | Specifies the CPU buffer access requirement, i.e. if the CPU can read and/or write the mapped memory. |
|
pure virtual |
Maps the specified buffer range from GPU to CPU memory space.
| [in] | buffer | Specifies the buffer which is to be mapped. Depending on the CPU access type (see access parameter), this buffer must have been created with the corresponding CPU access flag, i.e. CPUAccessFlags::Read and/or CPUAccessFlags::Write. |
| [in] | access | Specifies the CPU buffer access requirement, i.e. if the CPU can read and/or write the mapped memory. |
| [in] | offset | Specifies the memory offset (in bytes) from the GPU buffer. |
| [in] | length | Specifies the length of the memory block (in bytes) that is to be mapped. |
|
protectedpure virtual |
Queries the renderer information and capabilities.
| [out] | outInfo | Specifies the output parameter for the renderer info. This may be null. |
| [out] | outCaps | Specifies the output parameter for the renderer capabilities. This may be null. |
|
pure virtual |
Reads the data from the specified buffer.
| [in] | buffer | Specifies the buffer which is to be read. |
| [in] | offset | Specifies the offset (in bytes) at which the buffer is to be read. |
| [out] | data | Raw pointer to a memory block in CPU memory space where the data will be written to. |
| [in] | dataSize | Specifies the size (in bytes) of the data block given by the data parameter. |
|
pure virtual |
Reads the image data from the specified texture.
| [in] | texture | Specifies the texture object to read from. |
| [in] | textureRegion | Specifies the region where the texture data is to be read. |
| [out] | dstImageView | Specifies the destination image view to write the texture data to. |
dstImageView.data points to an invalid buffer, or dstImageView.data points to a buffer that is smaller than specified by dstImageView.dataSize, or dstImageView.dataSize is less than the required size.| std::invalid_argument | If dstImageView.data is null. |
|
pure virtual |
Releases the specified buffer object. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified buffer array object. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified command buffer. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified Fence object. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified PipelineCache object. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified PipelineLayout object. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified PipelineState object. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified QueryHeap object. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified RenderPass object. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified RenderTarget object. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified ResourceHeap object. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified Sampler object. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified Shader object. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified swap-chain. After this call, the specified object must no longer be used.
|
pure virtual |
Releases the specified texture object. After this call, the specified object must no longer be used.
|
static |
Unloads the specified render system and the internal module.
|
pure virtual |
Unmaps the specified buffer.
|
pure virtual |
Updates the data of the specified buffer.
| [in] | buffer | Specifies the destination buffer whose data is to be updated. |
| [in] | offset | Specifies the offset (in bytes) at which the buffer is to be updated. This offset plus the data block size (i.e. offset + dataSize) must be less than or equal to the size of the buffer. |
| [in] | data | Raw pointer to the data with which the buffer is to be updated. This must not be null! |
| [in] | dataSize | Specifies the size (in bytes) of the data block which is to be updated. This must be less then or equal to the size of the buffer. |
|
pure virtual |
Writes new resource view descriptors into the specified resource heap.
| [in] | resourceHeap | Specifies the resource heap that is to be updated. |
| [in] | firstDescriptor | Zero-based index to the first descriptor that is to be updated. This must be less than the number of bindings in the resource heap's pipeline layout (PipelineLayout::GetNumHeapBindings) multiplied by the number of descriptor sets in the resource heap (ResourceHeap::GetNumDescriptorSets). |
| [in] | resourceViews | Array of resource view descriptors. |
resource field that is null will be ignored silently.
|
pure virtual |
Updates the image data of the specified texture.
| [in] | texture | Specifies the texture whose data is to be updated. |
| [in] | textureRegion | Specifies the region where the texture is to be updated. The field TextureRegion::numMipLevels must be 1. |
| [in] | srcImageView | Specifies the source image view. Its data member must not be null! |