ezEngine  Milestone 7
ezGALDeviceGL Class Reference

The GL device implementation of the graphics abstraction layer. More...

#include <DeviceGL.h>

Inheritance diagram for ezGALDeviceGL:

Classes

struct  DebugMessageSeverity
 

Public Member Functions

 ezGALDeviceGL (const ezGALDeviceCreationDescription &Description)
 
EZ_FORCE_INLINE const
ezGALFormatLookupTableGL
GetFormatLookupTable () const
 
void SetupDebugOutput (DebugMessageSeverity::Enum minMessageSeverity=DebugMessageSeverity::MEDIUM)
 Activates the OpenGL debug output using KHR_DEBUG. More...
 
glBufferId GetUnusedGLBufferId ()
 Returns a yet unused buffer id and removes it from the internal pool. More...
 
void EnsureGLBufferPoolSize (ezUInt32 uiPoolSize=128)
 Will ensure that the internal buffer-pool meets the given requirements. More...
 
glBufferId GetUnusedGLTextureId ()
 Returns a yet unused texture id and removes it from the internal pool. More...
 
void EnsureGLTexturePoolSize (ezUInt32 uiPoolSize=128)
 Will ensure that the internal texture-pool meets the given requirements. More...
 
- Public Member Functions inherited from ezGALDevice
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
 

Protected Member Functions

virtual ezResult InitPlatform () override
 
virtual ezResult ShutdownPlatform () override
 
virtual ezGALBlendStateCreateBlendStatePlatform (const ezGALBlendStateCreationDescription &Description) override
 
virtual void DestroyBlendStatePlatform (ezGALBlendState *pBlendState) override
 
virtual ezGALDepthStencilStateCreateDepthStencilStatePlatform (const ezGALDepthStencilStateCreationDescription &Description) override
 
virtual void DestroyDepthStencilStatePlatform (ezGALDepthStencilState *pDepthStencilState) override
 
virtual ezGALRasterizerStateCreateRasterizerStatePlatform (const ezGALRasterizerStateCreationDescription &Description) override
 
virtual void DestroyRasterizerStatePlatform (ezGALRasterizerState *pRasterizerState) override
 
virtual ezGALSamplerStateCreateSamplerStatePlatform (const ezGALSamplerStateCreationDescription &Description) override
 
virtual void DestroySamplerStatePlatform (ezGALSamplerState *pSamplerState) override
 
virtual ezGALShaderCreateShaderPlatform (const ezGALShaderCreationDescription &Description) override
 
virtual void DestroyShaderPlatform (ezGALShader *pShader) override
 
virtual ezGALBufferCreateBufferPlatform (const ezGALBufferCreationDescription &Description, const void *pInitialData) override
 
virtual void DestroyBufferPlatform (ezGALBuffer *pBuffer) override
 
virtual ezGALTextureCreateTexturePlatform (const ezGALTextureCreationDescription &Description, const ezArrayPtr< ezGALSystemMemoryDescription > *pInitialData) override
 
virtual void DestroyTexturePlatform (ezGALTexture *pTexture) override
 
virtual ezGALResourceViewCreateResourceViewPlatform (const ezGALResourceViewCreationDescription &Description) override
 
virtual void DestroyResourceViewPlatform (ezGALResourceView *pResourceView) override
 
virtual ezGALRenderTargetViewCreateRenderTargetViewPlatform (const ezGALRenderTargetViewCreationDescription &Description) override
 
virtual void DestroyRenderTargetViewPlatform (ezGALRenderTargetView *pRenderTargetView) override
 
virtual ezGALSwapChainCreateSwapChainPlatform (const ezGALSwapChainCreationDescription &Description) override
 
virtual void DestroySwapChainPlatform (ezGALSwapChain *pSwapChain) override
 
virtual ezGALFence * CreateFencePlatform () override
 
virtual void DestroyFencePlatform (ezGALFence *pFence) override
 
virtual ezGALQuery * CreateQueryPlatform (const ezGALQueryCreationDescription &Description) override
 
virtual void DestroyQueryPlatform (ezGALQuery *pQuery) override
 
virtual ezGALVertexDeclarationCreateVertexDeclarationPlatform (const ezGALVertexDeclarationCreationDescription &Description) override
 
virtual void DestroyVertexDeclarationPlatform (ezGALVertexDeclaration *pVertexDeclaration) override
 
virtual void GetQueryDataPlatform (ezGALQuery *pQuery, ezUInt64 *puiRendererdPixels) override
 
virtual void PresentPlatform (ezGALSwapChain *pSwapChain) override
 
virtual void BeginFramePlatform () override
 
virtual void EndFramePlatform () override
 
virtual void FlushPlatform () override
 
virtual void FinishPlatform () override
 
virtual void SetPrimarySwapChainPlatform (ezGALSwapChain *pSwapChain) override
 
virtual void FillCapabilitiesPlatform () override
 
- Protected Member Functions inherited from ezGALDevice
template<typename IdTableType , typename ReturnType >
ReturnType * Get (typename IdTableType::TypeOfId hHandle, const IdTableType &IdTable) const
 
 ezGALDevice (const ezGALDeviceCreationDescription &Description)
 

Private Member Functions

ezResult EnsureInternOpenGLInit ()
 Intern init method which should be called by the first ezGALSwapChainGL since a RenderContext is needed to init glew and the like. More...
 
void FillFormatLookupTable ()
 
template<typename ResourceType , typename DescriptionType >
ResourceType * DefaultCreate (const DescriptionType &Description)
 Default method for resource/state-object creation.
 
template<typename ResourceType , typename DescriptionType , typename DataPtr >
ResourceType * DefaultCreate (const DescriptionType &Description, DataPtr pInitialData)
 
template<typename ResourceType , typename ResourceTypeBaseClass >
void DefaultDestroy (ResourceTypeBaseClass *pResource)
 Default method for resource/state-object destruction.
 

Private Attributes

ezGALFormatLookupTableGL m_FormatLookupTable
 
ezDynamicArray< glBufferId > m_BufferHandlePool
 
ezDynamicArray< glTextureId > m_TextureHandlePool
 
bool m_bGLInitialized
 

Friends

class ezGALSwapChainGL
 

Additional Inherited Members

- Static Public Member Functions inherited from ezGALDevice
static void SetDefaultDevice (ezGALDevice *pDefaultDevice)
 
static ezGALDeviceGetDefaultDevice ()
 
- Protected Types inherited from ezGALDevice
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 Attributes inherited from ezGALDevice
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
 

Detailed Description

The GL device implementation of the graphics abstraction layer.

Constructor & Destructor Documentation

ezGALDeviceGL::ezGALDeviceGL ( const ezGALDeviceCreationDescription Description)
Todo:
This shouldn't be accessible, there should be a factory instantiating the correct renderer class via RTTI for example

Member Function Documentation

void ezGALDeviceGL::EnsureGLBufferPoolSize ( ezUInt32  uiPoolSize = 128)

Will ensure that the internal buffer-pool meets the given requirements.

Will call glGenBuffers if not enough glBufferIds are available. If the pool is greater equal uiPoolSize nothing will happen.

See Also
GetUnusedGLBufferId
void ezGALDeviceGL::EnsureGLTexturePoolSize ( ezUInt32  uiPoolSize = 128)

Will ensure that the internal texture-pool meets the given requirements.

Will call glGenBuffers if not enough glBufferIds are available. If the pool is greater equal uiPoolSize nothing will happen.

See Also
GetUnusedGLTextureId
ezResult ezGALDeviceGL::EnsureInternOpenGLInit ( )
private

Intern init method which should be called by the first ezGALSwapChainGL since a RenderContext is needed to init glew and the like.

Todo:
Get features of the device (depending on feature level, CheckFormat* functions etc.)
void ezGALDeviceGL::FillFormatLookupTable ( )
private
Todo:
glEnable(GL_FRAMEBUFFER_SRGB) should be called to guarantee that all writes to framebuffers with sRGB formats are handled properly
Todo:
fill out formats.
glBufferId ezGALDeviceGL::GetUnusedGLBufferId ( )

Returns a yet unused buffer id and removes it from the internal pool.

The callee is responsible for destroying the returned buffer! Will cause a call to EnsureGLBufferPoolSize with its default parameter if not enough buffers are available.

See Also
EnsureGLBufferPoolSize
glTextureId ezGALDeviceGL::GetUnusedGLTextureId ( )

Returns a yet unused texture id and removes it from the internal pool.

The callee is responsible for destroying the returned texture! Will cause a call to EnsureGLBufferPoolSize with its default parameter if not enough textures are available.

See Also
EnsureGLTexturePoolSize
void ezGALDeviceGL::SetupDebugOutput ( DebugMessageSeverity::Enum  minMessageSeverity = DebugMessageSeverity::MEDIUM)

Activates the OpenGL debug output using KHR_DEBUG.

GL-Devices created with the DebugDevice options will automatically call this function with its default arguments.

Parameters
minMessageSeverityDetermines the minimum severity of message must have to be logged.

Member Data Documentation

bool ezGALDeviceGL::m_bGLInitialized
private
ezDynamicArray<glBufferId> ezGALDeviceGL::m_BufferHandlePool
private
ezDynamicArray<glTextureId> ezGALDeviceGL::m_TextureHandlePool
private

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