Diligent Engine API Reference: Diligent::RenderDeviceBase< BaseInterface > Class Template Reference

Diligent Engine API Reference

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Diligent::RenderDeviceBase< BaseInterface > Class Template Referenceabstract

Base implementation of a render device. More...

Inheritance diagram for Diligent::RenderDeviceBase< BaseInterface >:

## Public Member Functions
| RenderDeviceBase (IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, Uint32 NumDeferredContexts, size_t TextureObjSize, size_t TexViewObjSize, size_t BufferObjSize, size_t BuffViewObjSize, size_t ShaderObjSize, size_t SamplerObjSize, size_t PSOSize, size_t SRBSize)
virtual void | CreateResourceMapping (const ResourceMappingDesc &MappingDesc, IResourceMapping **ppMapping) override final
| Implementation of IRenderDevice::CreateResourceMapping().
virtual const DeviceCaps & | GetDeviceCaps () const override final
| Implementation of IRenderDevice::GetDeviceCaps().
virtual const TextureFormatInfo & | GetTextureFormatInfo (TEXTURE_FORMAT TexFormat) override final
| Implementation of IRenderDevice::GetTextureFormatInfo().
virtual const TextureFormatInfoExt & | GetTextureFormatInfoExt (TEXTURE_FORMAT TexFormat) override final
| Implementation of IRenderDevice::GetTextureFormatInfoExt().
void | SetImmediateContext (IDeviceContext *pImmediateContext)
| Set weak reference to the immediate context.
void | SetDeferredContext (size_t Ctx, IDeviceContext *pDeferredCtx)
| Set weak reference to the deferred context.
size_t | GetNumDeferredContexts () const
| Returns number of deferred contexts.

## Protected Member Functions
template<typename TObjectType , typename TObjectDescType , typename TObjectConstructor >
void | CreateDeviceObject (const Char *ObjectTypeName, const TObjectDescType &Desc, TObjectType **ppObject, TObjectConstructor ConstructObject)
| Helper template function to facilitate device object creation. More...

## Protected Attributes
StateObjectsRegistry< SamplerDesc > | m_SamplersRegistry
| Sampler state registry.
RefCntWeakPtr< IDeviceContext > | m_wpImmediateContext
| Weak reference to the immediate context. Immediate context holds strong reference to the device, so we must use weak reference to avoid circular dependencies.
std::vector< RefCntWeakPtr< IDeviceContext >, STDAllocatorRawMem< RefCntWeakPtr< IDeviceContext > > > | m_wpDeferredContexts
| Weak references to deferred contexts.
FixedBlockMemoryAllocator | m_TexObjAllocator
| Allocator for texture objects.
FixedBlockMemoryAllocator | m_TexViewObjAllocator
| Allocator for texture view objects.
FixedBlockMemoryAllocator | m_BufObjAllocator
| Allocator for buffer objects.
FixedBlockMemoryAllocator | m_BuffViewObjAllocator
| Allocator for buffer view objects.
FixedBlockMemoryAllocator | m_ShaderObjAllocator
| Allocator for shader objects.
FixedBlockMemoryAllocator | m_SamplerObjAllocator
| Allocator for sampler objects.
FixedBlockMemoryAllocator | m_PSOAllocator
| Allocator for pipeline state objects.
FixedBlockMemoryAllocator | m_SRBAllocator
| Allocator for shader resource binding objects.
FixedBlockMemoryAllocator | m_ResMappingAllocator
| Allocator for resource mapping objects.

## Detailed Description

### template<typename BaseInterface>
class Diligent::RenderDeviceBase< BaseInterface >

Base implementation of a render device.

Template Parameters

  BaseInterface | - base interface that this class will inheret.

Warning
  Render device must NOT hold strong references to any object it creates to avoid circular dependencies. Device context, swap chain and all object the device creates keep strong reference to the device. Device only holds weak reference to the immediate context.

## Constructor & Destructor Documentation

## ◆ RenderDeviceBase()

template<typename BaseInterface>

Diligent::RenderDeviceBase< BaseInterface >::RenderDeviceBase | ( | IReferenceCounters * | pRefCounters,
|  | IMemoryAllocator & | RawMemAllocator,
|  | Uint32 | NumDeferredContexts,
|  | size_t | TextureObjSize,
|  | size_t | TexViewObjSize,
|  | size_t | BufferObjSize,
|  | size_t | BuffViewObjSize,
|  | size_t | ShaderObjSize,
|  | size_t | SamplerObjSize,
|  | size_t | PSOSize,
|  | size_t | SRBSize
| ) |  |
| inline

Parameters

  pRefCounters | - reference counters object that controls the lifetime of this render device
  RawMemAllocator | - allocator that will be used to allocate memory for all device objects (including render device itself)
  NumDeferredContexts | - number of deferred device contexts
  TextureObjSize | - size of the texture object, in bytes
  TexViewObjSize | - size of the texture view object, in bytes
  BufferObjSize | - size of the buffer object, in bytes
  BuffViewObjSize | - size of the buffer view object, in bytes
  ShaderObjSize | - size of the shader object, in bytes
  SamplerObjSize | - size of the sampler object, in bytes
  PSOSize | - size of the pipeline state object, in bytes
  SRBSize | - size of the shader resource binding object, in bytes

Remarks
  Render device uses fixed block allocators (see FixedBlockMemoryAllocator) to allocate memory for device objects. The object sizes provided to constructor are used to initialize the allocators.

## Member Function Documentation

## ◆ CreateDeviceObject()

template<typename BaseInterface >
template<typename TObjectType , typename TObjectDescType , typename TObjectConstructor >

void Diligent::RenderDeviceBase< BaseInterface >::CreateDeviceObject | ( | const Char * | ObjectTypeName,
|  | const TObjectDescType & | Desc,
|  | TObjectType ** | ppObject,
|  | TObjectConstructor | ConstructObject
| ) |  |
| protected

Helper template function to facilitate device object creation.

Template Parameters

  TObjectType | - type of the object being created (IBuffer, ITexture, etc.)
  TObjectDescType | - type of the object description structure (BufferDesc, TextureDesc, etc.)
  TObjectConstructor | - type of the function that constructs the object

Parameters

  ObjectTypeName | - string name of the object type ("buffer", "texture", etc.)
  Desc | - object description
  ppObject | - memory address where the pointer to the created object will be stored
  ConstructObject | - function that constructs the object