XLE  v0.02.0
Namespaces | Classes | Typedefs | Functions | Variables
RenderCore Namespace Reference

Main interface for controlling rendering behaviour. More...

Namespaces

 Metal
 Low level interface for rendering.
 
 Metal_DX11
 This is the implementation of RenderCore::Metal for DX11 platforms.
 
 ShaderStage
 Container for ShaderStage::Enum.
 

Classes

class  CompiledShaderByteCode
 Represents a chunk of compiled shader code More...
 
class  Device
 
class  DeviceDX11
 
class  IDevice
 Represents a hardware device capable of rendering More...
 
class  IDeviceDX11
 IDevice extension for DX11 More...
 
class  IPresentationChain
 Represents a set of back buffer for rendering to a window More...
 
class  IThreadContext
 Represents the context state of a particular thread while rendering More...
 
class  IThreadContextDX11
 IThreadContext extension for DX11 More...
 
class  PresentationChain
 
class  ResourceList
 Used by the Metal interface to set many objects at once More...
 
class  ResourceList< Type, 0 >
 
class  ShaderService
 
class  SharedPkt
 A reference counted packet for small allocations More...
 
class  ThreadContext
 
class  ThreadContextDX11
 
class  ThreadContextStateDesc
 
class  ViewportContext
 

Typedefs

typedef IDeviceDX11 Base_DeviceDX11
 
typedef IThreadContext FLEX_MAKE_BASE_NAME(ThreadContext)
 
typedef IThreadContextDX11 Base_ThreadContextDX11
 
typedef IPresentationChain Base_PresentationChain
 
typedef IDevice Base_Device
 

Functions

intrusive_ptr< IDXGI::Adapter > SelectAdapter ()
 
template<typename DestinationType , typename SourceType >
intrusive_ptr< DestinationType > GetParent (intrusive_ptr< SourceType > child)
 
ID3D::Device * GetDefaultUnderlyingDevice ()
 
render_dll_export std::shared_ptr< IDeviceCreateDevice ()
 
SharedPkt MakeSharedPktSize (size_t size)
 
SharedPkt MakeSharedPkt (const void *begin, const void *end)
 
template<typename T >
SharedPkt MakeSharedPkt (const T &input)
 
unsigned ARGBtoABGR (unsigned input)
 
template<typename Type >
ResourceList< Type, 1 > MakeResourceList (const Type &zero)
 Constructs a new ResourceList object More...
 
template<typename Type >
ResourceList< Type, 2 > MakeResourceList (const Type &zero, const Type &one)
 
template<typename Type >
ResourceList< Type, 3 > MakeResourceList (const Type &zero, const Type &one, const Type &two)
 
template<typename Type >
ResourceList< Type, 4 > MakeResourceList (const Type &zero, const Type &one, const Type &two, const Type &three)
 
template<typename Type >
ResourceList< Type, 5 > MakeResourceList (const Type &zero, const Type &one, const Type &two, const Type &three, const Type &four)
 
template<typename Type >
ResourceList< Type, 6 > MakeResourceList (const Type &zero, const Type &one, const Type &two, const Type &three, const Type &four, const Type &five)
 
template<typename Type >
ResourceList< Type, 7 > MakeResourceList (const Type &zero, const Type &one, const Type &two, const Type &three, const Type &four, const Type &five, const Type &six)
 
template<typename Type >
ResourceList< Type, 8 > MakeResourceList (const Type &zero, const Type &one, const Type &two, const Type &three, const Type &four, const Type &five, const Type &six, const Type &seven)
 
template<typename Type >
ResourceList< Type, 1 > MakeResourceList (unsigned offset, const Type &zero)
 
template<typename Type >
ResourceList< Type, 2 > MakeResourceList (unsigned offset, const Type &zero, const Type &one)
 
template<typename Type >
ResourceList< Type, 3 > MakeResourceList (unsigned offset, const Type &zero, const Type &one, const Type &two)
 
template<typename Type >
ResourceList< Type, 4 > MakeResourceList (unsigned offset, const Type &zero, const Type &one, const Type &two, const Type &three)
 
template<typename Type >
ResourceList< Type, 5 > MakeResourceList (unsigned offset, const Type &zero, const Type &one, const Type &two, const Type &three, const Type &four)
 
template<typename Type >
ResourceList< Type, 6 > MakeResourceList (unsigned offset, const Type &zero, const Type &one, const Type &two, const Type &three, const Type &four, const Type &five)
 
template<typename Type >
ResourceList< Type, 7 > MakeResourceList (unsigned offset, const Type &zero, const Type &one, const Type &two, const Type &three, const Type &four, const Type &five, const Type &six)
 
template<typename Type >
ResourceList< Type, 8 > MakeResourceList (unsigned offset, const Type &zero, const Type &one, const Type &two, const Type &three, const Type &four, const Type &five, const Type &six, const Type &seven)
 
template<typename Type >
ResourceList< Type, 9 > MakeResourceList (unsigned offset, const Type &zero, const Type &one, const Type &two, const Type &three, const Type &four, const Type &five, const Type &six, const Type &seven, const Type &eight)
 

Variables

char VersionString [] = "v0.0.0"
 
char BuildDateString [] = ""
 

Detailed Description

Main interface for controlling rendering behaviour.

Fundamental Rendering

RenderCore is used to manage basic rendering behaviour. RenderCore always runs on top of another API, called the "low-level API." Normally this will be DirectX or OpenGL.

Responsibilities for RenderCore include:

Interfaces

Note that there are 2 interfaces to RenderCore. This is because RenderCore is used in 2 very different ways.

  1. There are some clients that are not "graphics-aware." These clients don't want to implement any new rendering behaviour, they just want to integrate rendering within a large game. These clients just want to set settings like screen size and rendering settings, loading and destroying rendering assets, and sometimes integrate with third party rendering (like Scaleform)
  2. Other clients are "graphics-aware." These clients want to create rendering behaviour (for example, implementing some rendering technique.)

In other words, most clients will use interface 1. Only clients that want to create new rendering behaviour will use interface 2.

The advantage is we don't need to centralise all rendering behaviour is a single place. Instead of having 1 library that does all of the rendering, it's better to have many small libraries that each implement only a single rendering feature.

Non graphics-aware interface

The first interface is the main "RenderCore" interface. This is the non "graphics aware" interface:

This interface can be exported from a DLL. It will insulate clients from the details of the low level API.

RenderCore::IDevice::QueryInterface can be used to access extension interfaces for the device. For example, this might include platform-specific interfaces like RenderCore::IDeviceDX11.

Graphics-aware interface

The second interface is RenderCore::Metal. This is the low level interface that can be used to create new rendering behaviour.

RenderCore::Metal is a non-centralised rendering interface. This means that there are many objects to interact with, and each one as a small set of interface functions.

In DirectX7/8/9 era rendering engines often had a giant "device" interface, with behaviour for every aspect of rendering. But RenderCore::Metal attempts to avoid centralising interface methods in a single place.

RenderCore::Metal is mostly a thin layer over the low-level API. The interface for RenderCore::Metal is platform-independent, but the implementation is very platform dependent.

The implementation for RenderCore::Metal is in the following (platform specific) directories:

However, when including headers, don't include from these directories. Instead, include headers from:

These will redirect to the correct platform header. For example, in DirectX mode, RenderCore/Metal/DeviceContext.h will automatically include RenderCore/DX11/Metal/DeviceContext.h.

Likewise, the platform specific implementations are in the following namespaces:

But don't use these namespaces directly. Instead use RenderCore::Metal. This will contain the symbols from whatever platform is currently active.

Good starting places for RenderCore::Metal are:

Example code

IDevice example code:

auto renderDevice = RenderCore::CreateDevice();
auto presentationChain = renderDevice->CreatePresentationChain(
window.GetHWND(),
clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);
for (;;) {
renderDevice->BeginFrame(presentationChain.get());
DoRender();
presentationChain->Present();
}

RenderCore::Metal example code:

using namespace RenderCore;
auto& debuggingShader = Assets::GetAssetDep<Metal::ShaderProgram>(
"game/xleres/deferred/debugging/beams.vsh:main:vs_*",
"game/xleres/deferred/debugging/beams.gsh:main:gs_*",
"game/xleres/deferred/debugging/beams.psh:main:ps_*",
shadowProjectionConstants?"SHADOWS=1":"");
Metal::BoundUniforms uniforms(debuggingShader);
uniforms.BindConstantBuffer("RecordedTransform", 0, nullptr, 0);
uniforms.BindConstantBuffer("GlobalTransform", 1, nullptr, 0);
uniforms.BindConstantBuffer("$Globals", 2, nullptr, 0);
uniforms.BindConstantBuffer("ShadowProjection", 3, nullptr, 0);
const unsigned TileWidth = 16, TileHeight = 16;
uint32 shaderGlobals[4] = { (mainViewportWidth + TileWidth - 1) / TileWidth,
(mainViewportHeight + TileHeight + 1) / TileHeight,
0, 0 };
std::shared_ptr<std::vector<uint8>> constants[]
= { nullptr, nullptr, MakeSharedPacket(shaderGlobals), nullptr };
const Metal::ConstantBuffer* prebuiltBuffers[]
= { &savedGlobalTransform, &lightingParserContext.GetGlobalTransformCB(), nullptr, shadowProjectionConstants };
uniforms.Apply(*context, constants, prebuiltBuffers, dimof(constants), nullptr, 0);
context->BindVS(MakeResourceList( tileLightingResources._debuggingTextureSRV[0],
tileLightingResources._debuggingTextureSRV[1]));
context->Bind(Metal::DepthStencilState());
SetupVertexGeneratorShader(context);
context->Bind(Metal::Topology::PointList);
context->Bind(debuggingShader);
context->Draw(shaderGlobals[0]*shaderGlobals[1]);

So, while RenderCore::IDevice can be used by anyone, RenderCore::Metal requires some knowledge of rendering basics.

Function Documentation

template<typename Type >
ResourceList<Type,1> RenderCore::MakeResourceList ( const Type &  zero)

Constructs a new ResourceList object

See also
RenderCore::ResourceList