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

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. 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 ()
 Waits until all outstanding operations on the GPU are complete and destroys any pending resources and GPU objects.
 
const xiiGALDeviceCreationDescriptionGetDescription () const
 Returns the creation description for this device.
 
virtual xiiGALCommandQueueGetDefaultCommandQueue (xiiBitflags< xiiGALCommandQueueType > queueType=xiiGALCommandQueueType::Graphics) const =0
 Retrieves a pointer to the compute queue if available, null otherwise.
 
const xiiGALGraphicsDeviceAdapterDescriptionGetGraphicsDeviceAdapterProperties () const
 This retrieves the device properties. See xiiGraphicsDeviceAdapterDescription.
 
const xiiGALDeviceFeaturesGetFeatures () const
 This retrieves the device feature states. See xiiGALDeviceFeatures.
 
xiiEnum< xiiGALGraphicsDeviceTypeGetGraphicsDeviceType () const
 This retrieves the device graphics API type. See xiiGALGraphicsDeviceType.
 
xiiMutexGetMutex () const
 This returns critical section lock.
 
Factory Methods.
xiiSharedPtr< xiiGALSwapChainCreateSwapChain (const xiiGALSwapChainCreationDescription &description)
 This creates a swap chain object.
 
xiiSharedPtr< xiiGALBlendStateCreateBlendState (const xiiGALBlendStateCreationDescription &description)
 This creates a new blend state object.
 
xiiSharedPtr< xiiGALDepthStencilStateCreateDepthStencilState (const xiiGALDepthStencilStateCreationDescription &description)
 This creates a new depth stencil state object.
 
xiiSharedPtr< xiiGALRasterizerStateCreateRasterizerState (const xiiGALRasterizerStateCreationDescription &description)
 This creates a new rasterizer state object.
 
xiiSharedPtr< xiiGALShaderCreateShader (const xiiGALShaderCreationDescription &description)
 This creates a new shader object.
 
xiiSharedPtr< xiiGALBufferCreateBuffer (const xiiGALBufferCreationDescription &description, const xiiGALBufferData *pInitialData=nullptr)
 This creates a new buffer object.
 
xiiSharedPtr< xiiGALTextureCreateTexture (const xiiGALTextureCreationDescription &description, const xiiGALTextureData *pInitialData=nullptr)
 This creates a new texture object.
 
xiiSharedPtr< xiiGALSamplerCreateSampler (const xiiGALSamplerCreationDescription &description)
 This creates a new sampler object.
 
xiiSharedPtr< xiiGALQueryCreateQuery (const xiiGALQueryCreationDescription &description)
 This creates a new query object.
 
xiiSharedPtr< xiiGALFenceCreateFence (const xiiGALFenceCreationDescription &description)
 This creates a new fence object.
 
xiiSharedPtr< xiiGALRenderPassCreateRenderPass (const xiiGALRenderPassCreationDescription &description)
 This creates a new render pass object.
 
xiiSharedPtr< xiiGALFramebufferCreateFramebuffer (const xiiGALFramebufferCreationDescription &description)
 This creates a new frame buffer object.
 
xiiSharedPtr< xiiGALBottomLevelASCreateBottomLevelAS (const xiiGALBottomLevelASCreationDescription &description)
 This creates a new bottom-level acceleration structure object.
 
xiiSharedPtr< xiiGALTopLevelASCreateTopLevelAS (const xiiGALTopLevelASCreationDescription &description)
 This creates a new top-level acceleration structure object.
 
xiiSharedPtr< xiiGALPipelineResourceSignatureCreatePipelineResourceSignature (xiiGALPipelineResourceSignatureCreationDescription &description)
 This creates a new pipeline resource signature object.
 
xiiSharedPtr< xiiGALGraphicsPipelineStateCreateGraphicsPipelineState (const xiiGALGraphicsPipelineStateCreationDescription &description)
 This creates a new graphics pipeline state object.
 
xiiSharedPtr< xiiGALComputePipelineStateCreateComputePipelineState (const xiiGALComputePipelineStateCreationDescription &description)
 This creates a new compute pipeline state object.
 
xiiSharedPtr< xiiGALRayTracingPipelineStateCreateRayTracingPipelineState (const xiiGALRayTracingPipelineStateCreationDescription &description)
 This creates a new ray tracing pipeline state object.
 
xiiSharedPtr< xiiGALTilePipelineStateCreateTilePipelineState (const xiiGALTilePipelineStateCreationDescription &description)
 This creates a new tile pipeline state object.
 
- 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 xiiRTTIGetDynamicRTTI () 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.
 
xiiUInt32 ReleaseRef () const
 Decrements the reference counter. Returns the new reference count.
 
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 void SetDefaultDevice (xiiSharedPtr< xiiGALDevice > pDefaultDevice)
 Sets a default graphics device.
 
static xiiSharedPtr< xiiGALDeviceGetDefaultDevice ()
 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 xiiRTTIGetStaticRTTI ()
 

Static Public Attributes

static xiiEvent< const xiiGALDeviceEvent &, xiiMutexs_Events
 Registers event handlers.
 

Protected Member Functions

 xiiGALDevice (xiiAllocatorBase *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.
 
void FinalizeTextureInternal (const xiiGALTextureCreationDescription &description, xiiSharedPtr< xiiGALTexture > &pTexture)
 
void FinalizeBufferInternal (const xiiGALBufferCreationDescription &description, xiiSharedPtr< xiiGALBuffer > &pBuffer)
 
- Protected Member Functions inherited from xiiGALObject
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

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 )
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.
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).

◆ 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.
Todo
GraphicsFoundation: Check render pass dependency source and destination stage mask is set to the undefined pipeline stage.

◆ 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 )
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.
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.

◆ GetDefaultCommandQueue()

virtual xiiGALCommandQueue * xiiGALDevice::GetDefaultCommandQueue ( xiiBitflags< xiiGALCommandQueueType > queueType = xiiGALCommandQueueType::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 xiiGALDeviceVulkan.

◆ SetDefaultDevice()

XII_ALWAYS_INLINE void xiiGALDevice::SetDefaultDevice ( xiiSharedPtr< xiiGALDevice > pDefaultDevice)
static

Sets a default graphics device.

Remarks
This does not increase the reference count on the device.

◆ 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: