LiteFX 0.4.1.2025
Computer Graphics Engine
Loading...
Searching...
No Matches
LiteFX::Rendering::IGraphicsDevice Class Referenceabstract

The interface for a graphics device that. More...

#include <rendering_api.hpp>

Inherits LiteFX::SharedObject.

Inherited by LiteFX::Rendering::GraphicsDevice< DirectX12GraphicsFactory, DirectX12Surface, DirectX12GraphicsAdapter, DirectX12SwapChain, DirectX12Queue, DirectX12RenderPass, DirectX12RenderPipeline, DirectX12ComputePipeline, DirectX12RayTracingPipeline, DirectX12Barrier >, LiteFX::Rendering::GraphicsDevice< VulkanGraphicsFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass, VulkanRenderPipeline, VulkanComputePipeline, VulkanRayTracingPipeline, VulkanBarrier >, and LiteFX::Rendering::GraphicsDevice< TFactory, TSurface, TGraphicsAdapter, TSwapChain, TCommandQueue, TRenderPass, TRenderPipeline, TComputePipeline, TRayTracingPipeline, TBarrier >.

Public Member Functions

 ~IGraphicsDevice () noexcept override=default
 
virtual DeviceStatestate () const noexcept=0
 Returns the device state that can be used to manage resources.
 
virtual const ISurfacesurface () const noexcept=0
 Returns the surface, the device draws to.
 
virtual const IGraphicsAdapteradapter () const noexcept=0
 Returns the graphics adapter, the device uses for drawing.
 
virtual const ISwapChainswapChain () const noexcept=0
 Returns the swap chain, that contains the back and front buffers used for presentation.
 
virtual ISwapChainswapChain () noexcept=0
 Returns the swap chain, that contains the back and front buffers used for presentation.
 
virtual const IGraphicsFactoryfactory () const noexcept=0
 Returns the factory instance, used to create instances from the device.
 
const ICommandQueuedefaultQueue (QueueType type) const
 Returns the instance of the default ICommandQueue that supports the combination of queue types specified by the type parameter.
 
SharedPtr< const ICommandQueuecreateQueue (QueueType type, QueuePriority priority=QueuePriority::Normal)
 Attempts to create a new queue that supports the combination of queue types specified by the type parameter.
 
UniquePtr< IBarriermakeBarrier (PipelineStage syncBefore, PipelineStage syncAfter) const
 Creates a memory barrier instance.
 
SharedPtr< IFrameBuffermakeFrameBuffer (const Size2d &renderArea) const
 Creates a new frame buffer instance.
 
SharedPtr< IFrameBuffermakeFrameBuffer (StringView name, const Size2d &renderArea) const
 Creates a new frame buffer instance.
 
virtual MultiSamplingLevel maximumMultiSamplingLevel (Format format) const noexcept=0
 Queries the device for the maximum supported number of multi-sampling levels.
 
virtual double ticksPerMillisecond () const noexcept=0
 Returns the number of GPU ticks per milliseconds.
 
void computeAccelerationStructureSizes (const IBottomLevelAccelerationStructure &blas, UInt64 &bufferSize, UInt64 &scratchSize, bool forUpdate=false) const
 Computes the required amount of device memory for an IBottomLevelAccelerationStructure.
 
void computeAccelerationStructureSizes (const ITopLevelAccelerationStructure &tlas, UInt64 &bufferSize, UInt64 &scratchSize, bool forUpdate=false) const
 Computes the required amount of device memory for an ITopLevelAccelerationStructure.
 
virtual void wait () const =0
 Waits until all queues allocated from the device have finished the work issued prior to this point.
 
- Public Member Functions inherited from LiteFX::SharedObject
virtual ~SharedObject () noexcept=default
 Destroys the shared object.
 
template<typename TSelf >
auto shared_from_this (this TSelf &&self) noexcept
 Returns a shared pointer to the current object instance.
 
template<typename TSelf >
auto weak_from_this (this TSelf &&self) noexcept -> WeakPtr< std::remove_reference_t< TSelf > >
 Returns a weak pointer to the current object instance.
 

Protected Member Functions

 IGraphicsDevice () noexcept=default
 
 IGraphicsDevice (IGraphicsDevice &&) noexcept=default
 
 IGraphicsDevice (const IGraphicsDevice &)=default
 
IGraphicsDeviceoperator= (const IGraphicsDevice &)=default
 
IGraphicsDeviceoperator= (IGraphicsDevice &&) noexcept=default
 
- Protected Member Functions inherited from LiteFX::SharedObject
 SharedObject () noexcept=default
 Initializes a new shared object.
 
 SharedObject (SharedObject &&) noexcept=default
 
 SharedObject (const SharedObject &)=default
 
SharedObjectoperator= (SharedObject &&) noexcept=default
 
SharedObjectoperator= (const SharedObject &)=default
 

Additional Inherited Members

- Static Protected Member Functions inherited from LiteFX::SharedObject
template<typename T , typename... TArgs>
static auto create (TArgs &&... args) -> SharedPtr< T >
 Generic factory method used to create instances of the shared object.
 

Detailed Description

The interface for a graphics device that.

Constructor & Destructor Documentation

◆ IGraphicsDevice() [1/3]

LiteFX::Rendering::IGraphicsDevice::IGraphicsDevice ( )
protecteddefaultnoexcept

◆ IGraphicsDevice() [2/3]

LiteFX::Rendering::IGraphicsDevice::IGraphicsDevice ( IGraphicsDevice && )
protecteddefaultnoexcept

◆ IGraphicsDevice() [3/3]

LiteFX::Rendering::IGraphicsDevice::IGraphicsDevice ( const IGraphicsDevice & )
protecteddefault

◆ ~IGraphicsDevice()

LiteFX::Rendering::IGraphicsDevice::~IGraphicsDevice ( )
overridedefaultnoexcept

Member Function Documentation

◆ adapter()

◆ computeAccelerationStructureSizes() [1/2]

void LiteFX::Rendering::IGraphicsDevice::computeAccelerationStructureSizes ( const IBottomLevelAccelerationStructure & blas,
UInt64 & bufferSize,
UInt64 & scratchSize,
bool forUpdate = false ) const
inline

Computes the required amount of device memory for an IBottomLevelAccelerationStructure.

Acceleration structures are built on the GPU, which requires additional memory called scratch memory. When creating an acceleration structure (AS), you have to provide a temporary buffer containing the scratch memory, alongside the actual buffer that stores the AS itself. This method can be used to pre-compute the buffer sizes for both buffers.

This method is only supported, if the GraphicsDeviceFeatures::RayTracing feature is enabled.

Parameters
blasThe bottom-level acceleration structure to compute the memory requirements for.
bufferSizeThe size of the acceleration structure buffer.
scratchSizeThe size of the scratch memory buffer.
forUpdateIf set to true, scratchSize will contain the amount of scratch memory required for an update.

◆ computeAccelerationStructureSizes() [2/2]

void LiteFX::Rendering::IGraphicsDevice::computeAccelerationStructureSizes ( const ITopLevelAccelerationStructure & tlas,
UInt64 & bufferSize,
UInt64 & scratchSize,
bool forUpdate = false ) const
inline

Computes the required amount of device memory for an ITopLevelAccelerationStructure.

Acceleration structures are built on the GPU, which requires additional memory called scratch memory. When creating an acceleration structure (AS), you have to provide a temporary buffer containing the scratch memory, alongside the actual buffer that stores the AS itself. This method can be used to pre-compute the buffer sizes for both buffers.

This method is only supported, if the GraphicsDeviceFeatures::RayTracing feature is enabled.

Parameters
tlasThe top-level acceleration structure to compute the memory requirements for.
bufferSizeThe size of the acceleration structure buffer.
scratchSizeThe size of the scratch memory buffer.
forUpdateIf set to true, scratchSize will contain the amount of scratch memory required for an update.

◆ createQueue()

SharedPtr< const ICommandQueue > LiteFX::Rendering::IGraphicsDevice::createQueue ( QueueType type,
QueuePriority priority = QueuePriority::Normal )
inline

Attempts to create a new queue that supports the combination of queue types specified by the type parameter.

Note that a queue is not guaranteed to represent an actual hardware queue that runs in parallel to other hardware queues. Backends might create virtual queues, that map the same hardware queue. In this case, creating a new queue is always possible but might not yield performance benefits. As a good practice, it is advised to create only as few queues as required.

If this method is not able to create a new queue (i.e., it returns nullptr), you can either fall back to the default queue (defaultQueue) or use any queue that you created earlier instead.

The priority parameter can be specified to request a queue with a certain priority. However, the backend is not required to return a queue with that actual priority. The default queues are always prioritized highest.

Parameters
typeThe type of the queue or a combination of capabilities the queue is required to support.
priorityThe preferred priority of the queue.
Returns
A pointer to the newly created queue, or nullptr, if no queue could be created.
See also
defaultQueue

◆ defaultQueue()

const ICommandQueue & LiteFX::Rendering::IGraphicsDevice::defaultQueue ( QueueType type) const
inline

Returns the instance of the default ICommandQueue that supports the combination of queue types specified by the type parameter.

When the device is created, it attempts to create a queue for each singular queue type. Each GPU is expected to provide at least one queue that is capable of supporting all queue types. This queue is used as a fallback queue, if no dedicated queue for a certain type is supported. For example, if no dedicated QueueType::Transfer queue can be created, calling this method for the default transfer queue will return the same queue instance as the default graphics queue, which implicitly always supports transfer operations. The same is true for compute queues. This default graphics queue is ensured to support presentation and is also created with the highest queue priority.

Parameters
typeThe type or a combination of types that specifies the operation the queue should support.
Exceptions
InvalidArgumentExceptionThrown, if no default queue for the combination of queue types specified with the type parameter has been created.
Returns
The instance of the queue, used to process draw calls.
See also
createQueue

◆ factory()

◆ makeBarrier()

UniquePtr< IBarrier > LiteFX::Rendering::IGraphicsDevice::makeBarrier ( PipelineStage syncBefore,
PipelineStage syncAfter ) const
inlinenodiscard

Creates a memory barrier instance.

Parameters
syncBeforeThe pipeline stage(s) all previous commands have to finish before the barrier is executed.
syncAfterThe pipeline stage(s) all subsequent commands are blocked at until the barrier is executed.
Returns
The instance of the memory barrier.

◆ makeFrameBuffer() [1/2]

SharedPtr< IFrameBuffer > LiteFX::Rendering::IGraphicsDevice::makeFrameBuffer ( const Size2d & renderArea) const
inlinenodiscard

Creates a new frame buffer instance.

Parameters
renderAreaThe initial render area of the frame buffer.
Returns
The instance of the frame buffer.

◆ makeFrameBuffer() [2/2]

SharedPtr< IFrameBuffer > LiteFX::Rendering::IGraphicsDevice::makeFrameBuffer ( StringView name,
const Size2d & renderArea ) const
inlinenodiscard

Creates a new frame buffer instance.

Parameters
nameThe name of the frame buffer.
renderAreaThe initial render area of the frame buffer.
Returns
The instance of the frame buffer.

◆ maximumMultiSamplingLevel()

virtual MultiSamplingLevel LiteFX::Rendering::IGraphicsDevice::maximumMultiSamplingLevel ( Format format) const
pure virtualnoexcept

Queries the device for the maximum supported number of multi-sampling levels.

This method returns the maximum supported multi-sampling level for a certain format. Typically you want to pass a back-buffer format for your swap-chain here. All lower multi-sampling levels are implicitly supported for this format.

Parameters
formatThe target (i.e. back-buffer) format.
Returns
The maximum multi-sampling level.

Implemented in LiteFX::Rendering::Backends::DirectX12Device, and LiteFX::Rendering::Backends::VulkanDevice.

◆ operator=() [1/2]

IGraphicsDevice & LiteFX::Rendering::IGraphicsDevice::operator= ( const IGraphicsDevice & )
protecteddefault

◆ operator=() [2/2]

IGraphicsDevice & LiteFX::Rendering::IGraphicsDevice::operator= ( IGraphicsDevice && )
protecteddefaultnoexcept

◆ state()

virtual DeviceState & LiteFX::Rendering::IGraphicsDevice::state ( ) const
pure virtualnoexcept

Returns the device state that can be used to manage resources.

Returns
A reference of the device state.

Implemented in LiteFX::Rendering::Backends::DirectX12Device, and LiteFX::Rendering::Backends::VulkanDevice.

◆ surface()

◆ swapChain() [1/2]

◆ swapChain() [2/2]

◆ ticksPerMillisecond()

virtual double LiteFX::Rendering::IGraphicsDevice::ticksPerMillisecond ( ) const
pure virtualnoexcept

Returns the number of GPU ticks per milliseconds.

Returns
The number of GPU ticks per milliseconds.
See also
TimingEvent

Implemented in LiteFX::Rendering::Backends::DirectX12Device, and LiteFX::Rendering::Backends::VulkanDevice.

◆ wait()

virtual void LiteFX::Rendering::IGraphicsDevice::wait ( ) const
pure virtual

Waits until all queues allocated from the device have finished the work issued prior to this point.

Note that you must synchronize calls to this method, i.e., you have to ensure no other thread is submitting work on any queue while waiting. Calling this method only guarantees that all prior work is finished after returning. If any other thread submits work to any queue after calling this method, this workload is not waited on.

Implemented in LiteFX::Rendering::Backends::DirectX12Device, and LiteFX::Rendering::Backends::VulkanDevice.