XII Release 0.1.0
Loading...
Searching...
No Matches
xiiGALDevice Class Referenceabstract

Copyright (c) Theophilus Eriata. All Rights Reserved. More...

#include <Device.h>

Inheritance diagram for xiiGALDevice:
[legend]

Public Member Functions

xiiResult Initialize ()
 Initialize device.
void BeginFrame ()
 Begins a render frame.
void EndFrame ()
 Ends a render frame.
void WaitIdle ()
const xiiGALDeviceCreationDescription & GetDescription () const
 Returns the creation description for this device.
XII_ALWAYS_INLINE xiiAllocator * GetAllocator ()
virtual xiiGALCommandQueue * GetCommandQueue (xiiBitflags< xiiGALCommandQueueFlags > queueFlags=xiiGALCommandQueueFlags::Graphics) const =0
const xiiGALGraphicsDeviceAdapterDescription & GetGraphicsDeviceAdapterProperties () const
 This retrieves the device properties. See xiiGraphicsDeviceAdapterDescription.
const xiiGALDeviceFeatures & GetFeatures () const
 This retrieves the device feature states. See xiiGALDeviceFeatures.
const xiiGALDeviceLimits & GetLimits () const
 This retrieves the device limits. See xiiGALDeviceLimits.
xiiEnum< xiiGALGraphicsDeviceType > GetGraphicsDeviceType () const
 This retrieves the device graphics API type. See xiiGALGraphicsDeviceType.
xiiMutex & GetMutex () const
 This returns critical section lock.
Factory Methods.
xiiSharedPtr< xiiGALSwapChain > CreateSwapChain (const xiiGALSwapChainCreationDescription &description)
xiiSharedPtr< xiiGALCommandList > CreateCommandList (const xiiGALCommandListCreationDescription &description)
xiiSharedPtr< xiiGALBlendState > CreateBlendState (const xiiGALBlendStateCreationDescription &description)
xiiSharedPtr< xiiGALDepthStencilState > CreateDepthStencilState (const xiiGALDepthStencilStateCreationDescription &description)
xiiSharedPtr< xiiGALRasterizerState > CreateRasterizerState (const xiiGALRasterizerStateCreationDescription &description)
xiiSharedPtr< xiiGALShader > CreateShader (const xiiGALShaderCreationDescription &description)
xiiSharedPtr< xiiGALBuffer > CreateBuffer (const xiiGALBufferCreationDescription &description, const xiiGALBufferData *pInitialData=nullptr, xiiBitflags< xiiGALExternalMemoryKind > externalMemoryKind=xiiGALExternalMemoryKind::None)
xiiSharedPtr< xiiGALTexture > CreateTexture (const xiiGALTextureCreationDescription &description, const xiiGALTextureData *pInitialData=nullptr, xiiBitflags< xiiGALExternalMemoryKind > externalMemoryKind=xiiGALExternalMemoryKind::None)
xiiSharedPtr< xiiGALSampler > CreateSampler (const xiiGALSamplerCreationDescription &description)
xiiSharedPtr< xiiGALQuery > CreateQuery (const xiiGALQueryCreationDescription &description)
xiiSharedPtr< xiiGALFence > CreateFence (const xiiGALFenceCreationDescription &description)
xiiSharedPtr< xiiGALRenderPass > CreateRenderPass (const xiiGALRenderPassCreationDescription &description)
xiiSharedPtr< xiiGALFramebuffer > CreateFramebuffer (const xiiGALFramebufferCreationDescription &description)
xiiSharedPtr< xiiGALBottomLevelAS > CreateBottomLevelAS (const xiiGALBottomLevelASCreationDescription &description)
xiiSharedPtr< xiiGALTopLevelAS > CreateTopLevelAS (const xiiGALTopLevelASCreationDescription &description)
xiiSharedPtr< xiiGALPipelineResourceSignature > CreatePipelineResourceSignature (xiiGALPipelineResourceSignatureCreationDescription &description)
xiiSharedPtr< xiiGALGraphicsPipelineState > CreateGraphicsPipelineState (const xiiGALGraphicsPipelineStateCreationDescription &description)
xiiSharedPtr< xiiGALComputePipelineState > CreateComputePipelineState (const xiiGALComputePipelineStateCreationDescription &description)
xiiSharedPtr< xiiGALRayTracingPipelineState > CreateRayTracingPipelineState (const xiiGALRayTracingPipelineStateCreationDescription &description)
xiiSharedPtr< xiiGALTilePipelineState > CreateTilePipelineState (const xiiGALTilePipelineStateCreationDescription &description)
Public Member Functions inherited from xiiGALObject
XII_ALWAYS_INLINE xiiStringView GetDebugName () const
 Returns the debug name of this resource.
void SetDebugName (xiiStringView sDebugName) const
 Sets the debug name for this resource.
Public Member Functions inherited from xiiReflectedClass
virtual const xiiRTTI * GetDynamicRTTI () const
bool IsInstanceOf (const xiiRTTI *pType) const
 Returns whether the type of this instance is of the given type or derived from it.
template<typename T>
XII_ALWAYS_INLINE bool IsInstanceOf () const
 Returns whether the type of this instance is of the given type or derived from it.
Public Member Functions inherited from xiiRefCounted
virtual ~xiiRefCounted ()=default
 Adds a virtual destructor.
Public Member Functions inherited from xiiRefCountingImpl
 xiiRefCountingImpl ()=default
 Constructor.
 xiiRefCountingImpl (const xiiRefCountingImpl &rhs)
void operator= (const xiiRefCountingImpl &rhs)
xiiUInt32 AddRef () const
 Increments the reference counter. Returns the new reference count.
bool TryAddRef () const
xiiUInt32 ReleaseRef () const
 Decrements the reference counter. Returns the new reference count.ywat.
bool IsReferenced () const
 Returns true if the reference count is greater than 0, false otherwise.
xiiUInt32 GetRefCount () const
 Returns the current reference count.

Static Public Member Functions

static xiiEvent< const xiiGALDeviceEvent &, xiiMutex > & GetEvents ()
 Registers event handlers.
static bool IsRegistryInitialized ()
 Returns whether the process-wide device registry is owned by a running subsystem.
static void SetDefaultDevice (xiiSharedPtr< xiiGALDevice > pDefaultDevice)
 Sets a default graphics device.
static xiiSharedPtr< xiiGALDevice > GetDefaultDevice ()
 Retrieves the default device. This will be nullptr if none is set.
static bool HasDefaultDevice ()
 This returns true if there is a set default device.
Static Public Member Functions inherited from xiiNoBase
static const xiiRTTI * GetStaticRTTI ()

Protected Member Functions

 xiiGALDevice (xiiAllocator *pAllocator, const xiiGALDeviceCreationDescription &creationDescription)
xiiResult PostInitialize ()
 Initialization after device capabilities are known.
void VerifyMultithreadedAccess () const
 Asserts that either this device supports multi-threaded resource creation, or that this function is executed on the main thread.
Protected Member Functions inherited from xiiGALObject
 xiiGALObject ()
 Copyright (c) Theophilus Eriata. All Rights Reserved.
virtual XII_ALWAYS_INLINE void SetDebugNamePlatform (xiiStringView sName) const

Protected Attributes

xiiGALDeviceCreationDescription m_Description
xiiProxyAllocator m_Allocator
xiiLocalAllocatorWrapper m_AllocatorWrapper
xiiMutex m_Mutex
xiiGALGraphicsDeviceAdapterDescription m_AdapterDescription

Detailed Description

Copyright (c) Theophilus Eriata. All Rights Reserved.

The xiiGALDevice 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

◆ CreateBlendState()

xiiSharedPtr< xiiGALBlendState > xiiGALDevice::CreateBlendState ( const xiiGALBlendStateCreationDescription & description)
nodiscard

This creates a new blend state object.

Parameters
description- The blend state description. See xiiGALBlendStateCreationDescription.
Returns
The reference-counted pointer to the created blend state object.

◆ CreateBottomLevelAS()

xiiSharedPtr< xiiGALBottomLevelAS > xiiGALDevice::CreateBottomLevelAS ( const xiiGALBottomLevelASCreationDescription & description)
nodiscard

This creates a new bottom-level acceleration structure object.

Parameters
description- The bottom-level acceleration structure description. See xiiGALBottomLevelASCreationDescription.
Returns
The reference-counted pointer to the created bottom-level acceleration structure object.

◆ CreateBuffer()

xiiSharedPtr< xiiGALBuffer > xiiGALDevice::CreateBuffer ( const xiiGALBufferCreationDescription & description,
const xiiGALBufferData * pInitialData = nullptr,
xiiBitflags< xiiGALExternalMemoryKind > externalMemoryKind = xiiGALExternalMemoryKind::None )
nodiscard

This creates a new buffer object.

Parameters
description- The buffer description. See xiiGALBufferCreationDescription.
pInitialData- The pointer to the xiiGALBufferData structure that describes the initial buffer data or nullptr if no data is provided. Immutable buffers (xiiGALResourceUsage::Immutable) must be initialized during creation.
externalMemoryKind- The kind of external memory, if the buffer is to be created with externally allocated memory.
Returns
The reference-counted pointer to the created buffer object.
Remarks
Size of a uniform buffer (xiiGALBindFlags::UniformBuffer) must be multiple of 16.
Stride of a formatted buffer will be computed automatically from the format if the m_uiElementByteStride member of buffer description is set to default value (0).

◆ CreateCommandList()

xiiSharedPtr< xiiGALCommandList > xiiGALDevice::CreateCommandList ( const xiiGALCommandListCreationDescription & description)
nodiscard

This creates a command list object.

Parameters
description- The command list description. See xiiGALCommandListCreationDescription.
Returns
The reference-counted pointer to the created command list object.

◆ CreateComputePipelineState()

xiiSharedPtr< xiiGALComputePipelineState > xiiGALDevice::CreateComputePipelineState ( const xiiGALComputePipelineStateCreationDescription & description)
nodiscard

This creates a new compute pipeline state object.

Parameters
description- The compute pipeline state description. See xiiGALComputePipelineStateCreationDescription.
Returns
The reference-counted pointer to the created compute pipeline state object.

◆ CreateDepthStencilState()

xiiSharedPtr< xiiGALDepthStencilState > xiiGALDevice::CreateDepthStencilState ( const xiiGALDepthStencilStateCreationDescription & description)
nodiscard

This creates a new depth stencil state object.

Parameters
description- The depth stencil state description. See xiiGALDepthStencilStateCreationDescription.
Returns
The reference-counted pointer to the created depth stencil state object.

◆ CreateFence()

xiiSharedPtr< xiiGALFence > xiiGALDevice::CreateFence ( const xiiGALFenceCreationDescription & description)
nodiscard

This creates a new fence object.

Parameters
description- The fence description. See xiiGALFenceCreationDescription.
Returns
The reference-counted pointer to the created fence object.

◆ CreateFramebuffer()

xiiSharedPtr< xiiGALFramebuffer > xiiGALDevice::CreateFramebuffer ( const xiiGALFramebufferCreationDescription & description)
nodiscard

This creates a new frame buffer object.

Parameters
description- The frame buffer description. See xiiGALFramebufferCreationDescription.
Returns
The reference-counted pointer to the created frame buffer object.

◆ CreateGraphicsPipelineState()

xiiSharedPtr< xiiGALGraphicsPipelineState > xiiGALDevice::CreateGraphicsPipelineState ( const xiiGALGraphicsPipelineStateCreationDescription & description)
nodiscard

This creates a new graphics pipeline state object.

Parameters
description- The graphics pipeline state description. See xiiGALGraphicsPipelineStateCreationDescription.
Returns
The reference-counted pointer to the created graphics pipeline state object.

◆ CreatePipelineResourceSignature()

xiiSharedPtr< xiiGALPipelineResourceSignature > xiiGALDevice::CreatePipelineResourceSignature ( xiiGALPipelineResourceSignatureCreationDescription & description)
nodiscard

This creates a new pipeline resource signature object.

Parameters
description- The pipeline resource signature description. See xiiGALPipelineResourceSignatureCreationDescription.
Returns
The reference-counted pointer to the created pipeline resource signature object.
Todo
Verify combined texture samplers, all samplers should be assigned to textures when combined texture samplers are used, all immutable samplers should be assigned to textures or samplers when combined texture samplers are used.

◆ CreateQuery()

xiiSharedPtr< xiiGALQuery > xiiGALDevice::CreateQuery ( const xiiGALQueryCreationDescription & description)
nodiscard

This creates a new query object.

Parameters
description- The query description. See xiiGALQueryCreationDescription.
Returns
The reference-counted pointer to the created query object.

◆ CreateRasterizerState()

xiiSharedPtr< xiiGALRasterizerState > xiiGALDevice::CreateRasterizerState ( const xiiGALRasterizerStateCreationDescription & description)
nodiscard

This creates a new rasterizer state object.

Parameters
description- The rasterizer state description. See xiiGALRasterizerStateCreationDescription.
Returns
The reference-counted pointer to the created rasterizer state object.

◆ CreateRayTracingPipelineState()

xiiSharedPtr< xiiGALRayTracingPipelineState > xiiGALDevice::CreateRayTracingPipelineState ( const xiiGALRayTracingPipelineStateCreationDescription & description)
nodiscard

This creates a new ray tracing pipeline state object.

Parameters
description- The ray tracing pipeline state description. See xiiGALRayTracingPipelineStateCreationDescription.
Returns
The reference-counted pointer to the created ray tracing pipeline state object.

◆ CreateRenderPass()

xiiSharedPtr< xiiGALRenderPass > xiiGALDevice::CreateRenderPass ( const xiiGALRenderPassCreationDescription & description)
nodiscard

This creates a new render pass object.

Parameters
description- The render pass description. See xiiGALRenderPassCreationDescription.
Returns
The reference-counted pointer to the created render pass object.
Todo
GraphicsFoundation: Use VkPhysicalDeviceFragmentShadingRatePropertiesKHR::maxFragmentShadingRateAttachmentTexelSizeAspectRatio.

◆ CreateSampler()

xiiSharedPtr< xiiGALSampler > xiiGALDevice::CreateSampler ( const xiiGALSamplerCreationDescription & description)
nodiscard

This creates a new sampler object.

Parameters
description- The sampler description. See xiiGALSamplerCreationDescription.
Returns
The reference-counted pointer to the created sampler object.
Remarks
If an application attempts to create a sampler interface with the same attributes as an existing interface, the same interface will be returned.

◆ CreateShader()

xiiSharedPtr< xiiGALShader > xiiGALDevice::CreateShader ( const xiiGALShaderCreationDescription & description)
nodiscard

This creates a new shader object.

Parameters
description- The shader description. See xiiGALShaderCreationDescription.
Returns
The reference-counted pointer to the created shader object.

◆ CreateSwapChain()

xiiSharedPtr< xiiGALSwapChain > xiiGALDevice::CreateSwapChain ( const xiiGALSwapChainCreationDescription & description)
nodiscard

This creates a swap chain object.

Parameters
description- The swap chain description. See xiiGALSwapChainCreationDescription.
Returns
The reference-counted pointer to the created swap chain object.

◆ CreateTexture()

xiiSharedPtr< xiiGALTexture > xiiGALDevice::CreateTexture ( const xiiGALTextureCreationDescription & description,
const xiiGALTextureData * pInitialData = nullptr,
xiiBitflags< xiiGALExternalMemoryKind > externalMemoryKind = xiiGALExternalMemoryKind::None )
nodiscard

This creates a new texture object.

Parameters
description- The texture description. See xiiGALTextureCreationDescription.
pInitialData- The pointer to the xiiGALTextureData structure that describes the initial texture data or nullptr if no data is provided. Immutable textures (xiiGALResourceUsage::Immutable) must be initialized during creation.
externalMemoryKind- The kind of external memory, if the texture is to be created with externally allocated memory.
Returns
The reference-counted pointer to the created texture object.
Remarks
To create all mip levels, set the description.m_uiMipLevels to zero.
Multi-sampled resources cannot be initialized with data when they are created.
If initial data is provided, number of sub-resources must exactly match the number of sub-resources in the texture (which is the number of mip levels times the number of array slices. For a 3D texture, this is just the number of mip levels).

For example, for a 15 x 6 x 2 2D texture array, the following array of sub-resources should be provided:
15x6, 7x3, 3x1, 1x1, 15x6, 7x3, 3x1, 1x1.
For a 15 x 6 x 4 3D texture, the following array of sub-resources should be provided:
15x6x4, 7x3x2, 3x1x1, 1x1x1

Todo
GraphicsFoundation: Vulkan allows the creation of 2D texture arrays, and using a single slice for view even if xiiGALShadingRateCapabilityFlags::TextureArray is not supported by the device.
Todo
GraphicsFoundation: Validate texture mip size to the tile size property.

◆ CreateTilePipelineState()

xiiSharedPtr< xiiGALTilePipelineState > xiiGALDevice::CreateTilePipelineState ( const xiiGALTilePipelineStateCreationDescription & description)
nodiscard

This creates a new tile pipeline state object.

Parameters
description- The tile pipeline state description. See xiiGALTilePipelineStateCreationDescription.
Returns
The reference-counted pointer to the created tile pipeline state object.

◆ CreateTopLevelAS()

xiiSharedPtr< xiiGALTopLevelAS > xiiGALDevice::CreateTopLevelAS ( const xiiGALTopLevelASCreationDescription & description)
nodiscard

This creates a new top-level acceleration structure object.

Parameters
description- The top-level acceleration structure description. See xiiGALTopLevelASCreationDescription.
Returns
The reference-counted pointer to the created top-level acceleration structure object.

◆ GetAllocator()

XII_ALWAYS_INLINE xiiAllocator * xiiGALDevice::GetAllocator ( )
inlinenodiscard

Allocator used for independently reference-counted GAL objects. It must outlive this device. Device-owned helpers use the internal tracking allocator instead.

◆ GetCommandQueue()

virtual xiiGALCommandQueue * xiiGALDevice::GetCommandQueue ( xiiBitflags< xiiGALCommandQueueFlags > queueFlags = xiiGALCommandQueueFlags::Graphics) const
nodiscardpure virtual

Retrieves a pointer to the compute queue if available, null otherwise.

Parameters
queueType- The queue type that has the required feature.
Note
The default graphics queue is guaranteed to exist, for a successful device initialization.

Implemented in xiiGALDeviceD3D12, and xiiGALDeviceVulkan.

◆ WaitIdle()

void xiiGALDevice::WaitIdle ( )

Waits until all outstanding operations on the GPU are complete and destroys any pending resources and GPU objects.

Note
The method blocks the execution of the calling thread until the GPU is idle.
Remarks
The method does not flush command queues, so it will only wait for commands that have been previously submitted for execution. An application should explicitly flush the contexts using xiiGALCommandList::Flush() if it needs to make sure all recorded commands are complete when the method returns.

The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Engine/GraphicsFoundation/Device/Device.h
  • /home/runner/work/XII/XII/Source/Engine/GraphicsFoundation/Device/Implementation/Device.cpp
  • /home/runner/work/XII/XII/Source/Engine/GraphicsFoundation/Device/Implementation/Device_inl.h