ezEngine  Milestone 7
ezGALDevice Class Reference

The ezRenderDevice class is the primary interface for interactions with rendering APIs It contains a set of (non-virtual) functions to set state, create resources etc. which rely on API specific implementations provided by protected virtual functions. Redundant state changes are prevented at the platform independent level in the non-virtual functions. More...

#include <Device.h>

Inheritance diagram for ezGALDevice:

Public Member Functions

ezResult Init ()
 
ezResult Shutdown ()
 
ezGALBlendStateHandle CreateBlendState (const ezGALBlendStateCreationDescription &Description)
 
void DestroyBlendState (ezGALBlendStateHandle hBlendState)
 
ezGALDepthStencilStateHandle CreateDepthStencilState (const ezGALDepthStencilStateCreationDescription &Description)
 
void DestroyDepthStencilState (ezGALDepthStencilStateHandle hDepthStencilState)
 
ezGALRasterizerStateHandle CreateRasterizerState (const ezGALRasterizerStateCreationDescription &Description)
 
void DestroyRasterizerState (ezGALRasterizerStateHandle hRasterizerState)
 
ezGALSamplerStateHandle CreateSamplerState (const ezGALSamplerStateCreationDescription &Description)
 
void DestroySamplerState (ezGALSamplerStateHandle hSamplerState)
 
ezGALShaderHandle CreateShader (const ezGALShaderCreationDescription &Description)
 
void DestroyShader (ezGALShaderHandle hShader)
 
ezGALBufferHandle CreateBuffer (const ezGALBufferCreationDescription &Description, const void *pInitialData)
 
void DestroyBuffer (ezGALBufferHandle hBuffer)
 
ezGALBufferHandle CreateVertexBuffer (ezUInt32 uiVertexSize, ezUInt32 uiVertexCount, const void *pInitialData=nullptr)
 
ezGALBufferHandle CreateIndexBuffer (ezGALIndexType::Enum IndexType, ezUInt32 uiIndexCount, const void *pInitialData=nullptr)
 
ezGALBufferHandle CreateConstantBuffer (ezUInt32 uiBufferSize)
 
ezGALTextureHandle CreateTexture (const ezGALTextureCreationDescription &Description, const ezArrayPtr< ezGALSystemMemoryDescription > *pInitialData=nullptr)
 
void DestroyTexture (ezGALTextureHandle hTexture)
 
ezGALResourceViewHandle CreateResourceView (const ezGALResourceViewCreationDescription &Description)
 
void DestroyResourceView (ezGALResourceViewHandle hResourceView)
 
ezGALRenderTargetViewHandle CreateRenderTargetView (const ezGALRenderTargetViewCreationDescription &Description)
 
void DestroyRenderTargetView (ezGALRenderTargetViewHandle hRenderTargetView)
 
ezGALSwapChainHandle CreateSwapChain (const ezGALSwapChainCreationDescription &Description)
 
void DestroySwapChain (ezGALSwapChainHandle hSwapChain)
 
ezGALFenceHandle CreateFence ()
 
void DestroyFence (ezGALFenceHandle &hFence)
 
ezGALQueryHandle CreateQuery (const ezGALQueryCreationDescription &Description)
 
void DestroyQuery (ezGALQueryHandle hQuery)
 
ezGALVertexDeclarationHandle CreateVertexDeclaration (const ezGALVertexDeclarationCreationDescription &Description)
 
void DestroyVertexDeclaration (ezGALVertexDeclarationHandle hVertexDeclaration)
 
void GetQueryData (ezGALQueryHandle hQuery, ezUInt64 *puiRendererdPixels)
 
void Present (ezGALSwapChainHandle hSwapChain)
 
ezGALTextureHandle GetBackBufferTextureFromSwapChain (ezGALSwapChainHandle hSwapChain)
 
void BeginFrame ()
 
void EndFrame ()
 
void Flush ()
 
void Finish ()
 
void SetPrimarySwapChain (ezGALSwapChainHandle hSwapChain)
 
ezGALSwapChainHandle GetPrimarySwapChain () const
 
ezGALContextGetPrimaryContext () const
 
template<typename T >
T * GetPrimaryContext () const
 
const
ezGALDeviceCreationDescription
GetDescription () const
 
const ezGALSwapChainGetSwapChain (ezGALSwapChainHandle hSwapChain) const
 
const ezGALShaderGetShader (ezGALShaderHandle hShader) const
 
const ezGALTextureGetTexture (ezGALTextureHandle hTexture) const
 
const ezGALBufferGetBuffer (ezGALBufferHandle hBuffer) const
 
const ezGALDepthStencilStateGetDepthStencilState (ezGALDepthStencilStateHandle hDepthStencilState) const
 
const ezGALBlendStateGetBlendState (ezGALBlendStateHandle hBlendState) const
 
const ezGALRasterizerStateGetRasterizerState (ezGALRasterizerStateHandle hRasterizerState) const
 
const ezGALVertexDeclarationGetVertexDeclaration (ezGALVertexDeclarationHandle hVertexDeclaration) const
 
const ezGALQuery * GetQuery (ezGALQueryHandle hQuery) const
 
const ezGALSamplerStateGetSamplerState (ezGALSamplerStateHandle hSamplerState) const
 
const ezGALResourceViewGetResourceView (ezGALResourceViewHandle hResourceView) const
 
const ezGALRenderTargetViewGetRenderTargetView (ezGALRenderTargetViewHandle hRenderTargetView) const
 
const ezGALDeviceCapabilitiesGetCapabilities () const
 
virtual ezUInt64 GetMemoryConsumptionForTexture (const ezGALTextureCreationDescription &Description) const
 
virtual ezUInt64 GetMemoryConsumptionForBuffer (const ezGALBufferCreationDescription &Description) const
 
template<typename IdTableType , typename ReturnType >
EZ_FORCE_INLINE ReturnType * Get (typename IdTableType::TypeOfId hHandle, const IdTableType &IdTable) const
 

Static Public Member Functions

static void SetDefaultDevice (ezGALDevice *pDefaultDevice)
 
static ezGALDeviceGetDefaultDevice ()
 

Protected Types

typedef ezIdTable
< ezGALShaderHandle::IdType,
ezGALShader
*, ezLocalAllocatorWrapper
ShaderTable
 
typedef ezIdTable
< ezGALBlendStateHandle::IdType,
ezGALBlendState
*, ezLocalAllocatorWrapper
BlendStateTable
 
typedef ezIdTable
< ezGALDepthStencilStateHandle::IdType,
ezGALDepthStencilState
*, ezLocalAllocatorWrapper
DepthStencilStateTable
 
typedef ezIdTable
< ezGALRasterizerStateHandle::IdType,
ezGALRasterizerState
*, ezLocalAllocatorWrapper
RasterizerStateTable
 
typedef ezIdTable
< ezGALBufferHandle::IdType,
ezGALBuffer
*, ezLocalAllocatorWrapper
BufferTable
 
typedef ezIdTable
< ezGALTextureHandle::IdType,
ezGALTexture
*, ezLocalAllocatorWrapper
TextureTable
 
typedef ezIdTable
< ezGALResourceViewHandle::IdType,
ezGALResourceView
*, ezLocalAllocatorWrapper
ResourceViewTable
 
typedef ezIdTable
< ezGALSamplerStateHandle::IdType,
ezGALSamplerState
*, ezLocalAllocatorWrapper
SamplerStateTable
 
typedef ezIdTable
< ezGALRenderTargetViewHandle::IdType,
ezGALRenderTargetView
*, ezLocalAllocatorWrapper
RenderTargetViewTable
 
typedef ezIdTable
< ezGALSwapChainHandle::IdType,
ezGALSwapChain
*, ezLocalAllocatorWrapper
SwapChainTable
 
typedef ezIdTable
< ezGALFenceHandle::IdType,
ezGALFence
*, ezLocalAllocatorWrapper
FenceTable
 
typedef ezIdTable
< ezGALQueryHandle::IdType,
ezGALQuery
*, ezLocalAllocatorWrapper
QueryTable
 
typedef ezIdTable
< ezGALVertexDeclarationHandle::IdType,
ezGALVertexDeclaration
*, ezLocalAllocatorWrapper
VertexDeclarationTable
 

Protected Member Functions

template<typename IdTableType , typename ReturnType >
ReturnType * Get (typename IdTableType::TypeOfId hHandle, const IdTableType &IdTable) const
 
 ezGALDevice (const ezGALDeviceCreationDescription &Description)
 

Protected Attributes

ezProxyAllocator m_Allocator
 
ezLocalAllocatorWrapper m_AllocatorWrapper
 
ShaderTable m_Shaders
 
BlendStateTable m_BlendStates
 
DepthStencilStateTable m_DepthStencilStates
 
RasterizerStateTable m_RasterizerStates
 
BufferTable m_Buffers
 
TextureTable m_Textures
 
ResourceViewTable m_ResourceViews
 
SamplerStateTable m_SamplerStates
 
RenderTargetViewTable m_RenderTargetViews
 
SwapChainTable m_SwapChains
 
FenceTable m_Fences
 
QueryTable m_Queries
 
VertexDeclarationTable m_VertexDeclarations
 
ezMap< ezUInt32,
ezGALBlendStateHandle,
ezCompareHelper< ezUInt32 >
, ezLocalAllocatorWrapper
m_BlendStateMap
 
ezMap< ezUInt32,
ezGALDepthStencilStateHandle,
ezCompareHelper< ezUInt32 >
, ezLocalAllocatorWrapper
m_DepthStencilStateMap
 
ezMap< ezUInt32,
ezGALRasterizerStateHandle,
ezCompareHelper< ezUInt32 >
, ezLocalAllocatorWrapper
m_RasterizerStateMap
 
ezMap< ezUInt32,
ezGALResourceViewHandle,
ezCompareHelper< ezUInt32 >
, ezLocalAllocatorWrapper
m_ResourceViewMap
 
ezMap< ezUInt32,
ezGALSamplerStateHandle,
ezCompareHelper< ezUInt32 >
, ezLocalAllocatorWrapper
m_SamplerStateMap
 
ezMap< ezUInt32,
ezGALRenderTargetViewHandle,
ezCompareHelper< ezUInt32 >
, ezLocalAllocatorWrapper
m_RenderTargetViewMap
 
ezMap< ezUInt32,
ezGALVertexDeclarationHandle,
ezCompareHelper< ezUInt32 >
, ezLocalAllocatorWrapper
m_VertexDeclarationMap
 
ezGALDeviceCreationDescription m_Description
 
ezGALSwapChainHandle m_hPrimarySwapChain
 
ezGALContextm_pPrimaryContext
 
ezGALDeviceCapabilities m_Capabilities
 

Private Attributes

bool m_bFrameBeginCalled
 

Static Private Attributes

static ezGALDevices_pDefaultDevice = nullptr
 

Friends

class ezGALContext
 

Detailed Description

The ezRenderDevice class is the primary interface for interactions with rendering APIs It contains a set of (non-virtual) functions to set state, create resources etc. which rely on API specific implementations provided by protected virtual functions. Redundant state changes are prevented at the platform independent level in the non-virtual functions.

Member Function Documentation

ezGALBlendStateHandle ezGALDevice::CreateBlendState ( const ezGALBlendStateCreationDescription Description)
Todo:
State / resource creation needs to check if multithreaded resource creation is allowed and if not if it is in the render thread
ezGALBufferHandle ezGALDevice::CreateBuffer ( const ezGALBufferCreationDescription Description,
const void *  pInitialData 
)
Todo:
Platform independent validation (buffer type supported)
ezGALDepthStencilStateHandle ezGALDevice::CreateDepthStencilState ( const ezGALDepthStencilStateCreationDescription Description)
Todo:
Hash description and return potential existing one (including inc. refcount)
ezGALFenceHandle ezGALDevice::CreateFence ( )
Todo:
Platform independent validation
ezGALQueryHandle ezGALDevice::CreateQuery ( const ezGALQueryCreationDescription &  Description)
Todo:
Platform independent validation
ezGALRasterizerStateHandle ezGALDevice::CreateRasterizerState ( const ezGALRasterizerStateCreationDescription Description)
Todo:
Hash description and return potential existing one (including inc. refcount)
ezGALRenderTargetViewHandle ezGALDevice::CreateRenderTargetView ( const ezGALRenderTargetViewCreationDescription Description)
Todo:
Platform independent validation
Todo:
Hash description and return potential existing one (including inc. refcount)
ezGALResourceViewHandle ezGALDevice::CreateResourceView ( const ezGALResourceViewCreationDescription Description)
Todo:
Platform independent validation
Todo:
Hash description and return potential existing one (including inc. refcount)
ezGALSamplerStateHandle ezGALDevice::CreateSamplerState ( const ezGALSamplerStateCreationDescription Description)
Todo:
Platform independent validation
Todo:
Hash description and return potential existing one (including inc. refcount)
ezGALSwapChainHandle ezGALDevice::CreateSwapChain ( const ezGALSwapChainCreationDescription Description)
Todo:
Platform independent validation
ezGALTextureHandle ezGALDevice::CreateTexture ( const ezGALTextureCreationDescription Description,
const ezArrayPtr< ezGALSystemMemoryDescription > *  pInitialData = nullptr 
)
Todo:
Platform independent validation (desc width & height < platform maximum, format, etc.)
ezGALVertexDeclarationHandle ezGALDevice::CreateVertexDeclaration ( const ezGALVertexDeclarationCreationDescription Description)
Todo:
Platform independent validation
Todo:
Hash description and return potential existing one (including inc. refcount)
void ezGALDevice::DestroyDepthStencilState ( ezGALDepthStencilStateHandle  hDepthStencilState)
Todo:
Only remove if refcount = 0
void ezGALDevice::DestroyRasterizerState ( ezGALRasterizerStateHandle  hRasterizerState)
Todo:
Only remove if refcount = 0
void ezGALDevice::DestroyRenderTargetView ( ezGALRenderTargetViewHandle  hRenderTargetView)
Todo:
Only remove if refcount = 0
void ezGALDevice::DestroyResourceView ( ezGALResourceViewHandle  hResourceView)
Todo:
Only remove if refcount = 0
void ezGALDevice::DestroySamplerState ( ezGALSamplerStateHandle  hSamplerState)
Todo:
Only remove if refcount = 0
template<typename IdTableType , typename ReturnType >
EZ_FORCE_INLINE ReturnType* ezGALDevice::Get ( typename IdTableType::TypeOfId  hHandle,
const IdTableType &  IdTable 
) const
Todo:
typeid of incomplete types not allowed. Fix includes or move this away from the inline file.
void ezGALDevice::GetQueryData ( ezGALQueryHandle  hQuery,
ezUInt64 *  puiRendererdPixels 
)
Todo:
Assert on query support?
void ezGALDevice::Present ( ezGALSwapChainHandle  hSwapChain)
Todo:
Map functions to save on memcpys

The documentation for this class was generated from the following files: