Class GPUDevice
Graphics device object for rendering on GPU.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Graphics/GPUDevice.h
Syntax
public class GPUDevice : public ScriptingObject
Constructors
~GPUDevice()
GPUDevice(RendererType type, ShaderProfile profile)
Initializes a new instance of the GPUDevice class.
Declaration
protected GPUDevice(RendererType type, ShaderProfile profile)
Parameters
|
RendererType
type
The renderer type. |
|
ShaderProfile
profile
The shader profile. |
Fields
_drawGpuEventIndex
Declaration
protected int32 _drawGpuEventIndex
Field Value
|
int32
|
_featureLevel
_isRendering
Declaration
protected bool _isRendering
Field Value
|
bool
|
_rendererType
_res
Declaration
protected PrivateData* _res
Field Value
|
PrivateData
|
_resources
Declaration
protected Array<GPUResource* > _resources
Field Value
|
Array<GPUResource >
|
_resourcesLock
Declaration
protected CriticalSection _resourcesLock
Field Value
|
CriticalSection
|
_shaderProfile
_state
Declaration
protected DeviceState _state
Field Value
|
DeviceState
|
_wasVSyncUsed
Declaration
protected bool _wasVSyncUsed
Field Value
|
bool
|
CurrentTask
FeaturesPerFormat[static_cast<int32>(PixelFormat::MAX)
The supported features for the specified format (index is the pixel format value).
Declaration
public FormatFeatures FeaturesPerFormat[static_cast<int32>(PixelFormat::MAX)]
Field Value
|
FormatFeatures
|
Instance
The singleton instance of the graphics device.
Declaration
public static GPUDevice* Instance
Field Value
|
GPUDevice
|
IsDebugToolAttached
Indicates that debug tool is profiling device (eg. RenderDoc).
Declaration
public bool IsDebugToolAttached
Field Value
|
bool
|
Limits
Locker
The graphics device locking mutex.
Declaration
public CriticalSection Locker
Field Value
|
CriticalSection
|
QuadShader
TotalGraphicsMemory
The total amount of graphics memory in bytes.
Declaration
public uint64 TotalGraphicsMemory
Field Value
|
uint64
|
VideoOutputModes
The available video output modes.
Declaration
public Array<VideoOutputMode> VideoOutputModes
Field Value
|
Array<VideoOutputMode>
|
VideoOutputs
The available video outputs (monitors).
Declaration
public Array<VideoOutput> VideoOutputs
Field Value
|
Array<VideoOutput>
|
Methods
AddResource(GPUResource* resource)
CanDraw()
Checks if GPU can render frame now (all data is ready), otherwise will skip frame rendering.
Declaration
public virtual bool CanDraw()
Returns
|
bool
True if skip rendering, otherwise false. |
CreateBuffer(const StringView& name=StringView::Empty)
Creates the buffer.
Declaration
public virtual GPUBuffer* CreateBuffer(const StringView& name=StringView::Empty) = 0
Parameters
|
StringView
name
The resource name. |
Returns
|
GPUBuffer
The buffer. |
CreateConstantBuffer(uint32 size, const StringView& name=StringView::Empty)
Creates the constant buffer.
Declaration
public virtual GPUConstantBuffer* CreateConstantBuffer(uint32 size, const StringView& name=StringView::Empty) = 0
Parameters
|
uint32
size
The buffer size (in bytes). |
|
StringView
name
The resource name. |
Returns
|
GPUConstantBuffer
The constant buffer. |
CreatePipelineState()
Creates the GPU pipeline state object.
Declaration
public virtual GPUPipelineState* CreatePipelineState() = 0
Returns
|
GPUPipelineState
The pipeline state. |
CreateSampler()
Creates the texture sampler.
Declaration
public virtual GPUSampler* CreateSampler() = 0
Returns
|
GPUSampler
The sampler. |
CreateShader(const StringView& name=StringView::Empty)
Creates the shader.
Declaration
public virtual GPUShader* CreateShader(const StringView& name=StringView::Empty) = 0
Parameters
|
StringView
name
The resource name. |
Returns
|
GPUShader
The shader. |
CreateSwapChain(Window* window)
Creates the native window swap chain.
Declaration
public virtual GPUSwapChain* CreateSwapChain(Window* window) = 0
Parameters
|
Window
window
The output window. |
Returns
|
GPUSwapChain
The native window swap chain. |
CreateTasksContext()
Creates the GPU tasks context.
Declaration
public virtual GPUTasksContext* CreateTasksContext()
Returns
|
GPUTasksContext
The GPU tasks context. |
CreateTasksExecutor()
Creates the GPU tasks executor.
Declaration
public virtual GPUTasksExecutor* CreateTasksExecutor()
Returns
|
GPUTasksExecutor
The GPU tasks executor. |
CreateTexture(const StringView& name=StringView::Empty)
Creates the texture.
Declaration
public virtual GPUTexture* CreateTexture(const StringView& name=StringView::Empty) = 0
Parameters
|
StringView
name
The resource name. |
Returns
|
GPUTexture
The texture. |
CreateTimerQuery()
Creates the timer query object.
Declaration
public virtual GPUTimerQuery* CreateTimerQuery() = 0
Returns
|
GPUTimerQuery
The timer query. |
CreateVertexLayout(const Array<struct VertexElement, FixedAllocation<GPU_MAX_VS_ELEMENTS>>& elements, bool explicitOffsets=false)
Creates the vertex buffer layout.
Declaration
public virtual GPUVertexLayout* CreateVertexLayout(const Array<struct VertexElement, FixedAllocation<GPU_MAX_VS_ELEMENTS>>& elements, bool explicitOffsets=false) = 0
Parameters
|
Array<struct VertexElement, FixedAllocation<GPU_MAX_VS_ELEMENTS>>
elements
|
|
bool
explicitOffsets
|
Returns
|
GPUVertexLayout
The vertex buffer layout. |
Dispose()
Clean all allocated data by device
Declaration
public virtual void Dispose()
Draw()
Call frame rendering and process data using GPU
Declaration
public virtual void Draw()
DrawBegin()
Called during Draw method before any frame rendering initialization. Cannot be used to submit commands to GPU.
Declaration
protected virtual void DrawBegin()
DrawEnd()
Called during Draw method after rendering. Cannot be used to submit commands to GPU.
Declaration
protected virtual void DrawEnd()
DumpResourcesToLog()
Dumps all GPU resources information to the log.
Declaration
public void DumpResourcesToLog() const
GetAdapter()
Gets the adapter device.
Declaration
public virtual GPUAdapter* GetAdapter() const = 0
Returns
|
GPUAdapter
|
GetClearPS()
Gets the shader pipeline state object for solid-color texture clear.
Declaration
public GPUPipelineState* GetClearPS() const
Returns
|
GPUPipelineState
|
GetCopyLinearPS()
Gets the shader pipeline state object for linear, fullscreen texture copy.
Declaration
public GPUPipelineState* GetCopyLinearPS() const
Returns
|
GPUPipelineState
|
GetDecodeNV12PS()
Gets the shader pipeline state object for NV12 frame decoding to RGBA.
Declaration
public GPUPipelineState* GetDecodeNV12PS() const
Returns
|
GPUPipelineState
|
GetDecodeYUY2PS()
Gets the shader pipeline state object for YUY2 frame decoding to RGBA.
Declaration
public GPUPipelineState* GetDecodeYUY2PS() const
Returns
|
GPUPipelineState
|
GetDefaultBlackTexture()
Gets the default solid black texture.
Declaration
public GPUTexture* GetDefaultBlackTexture() const
Returns
|
GPUTexture
|
GetDefaultDeformableMaterial()
Gets the default material (Deformable domain).
Declaration
public MaterialBase* GetDefaultDeformableMaterial() const
Returns
|
MaterialBase
|
GetDefaultMaterial()
Gets the default material.
Declaration
public MaterialBase* GetDefaultMaterial() const
Returns
|
MaterialBase
|
GetDefaultNormalMap()
Gets the default normal map texture.
Declaration
public GPUTexture* GetDefaultNormalMap() const
Returns
|
GPUTexture
|
GetDefaultWhiteTexture()
Gets the default solid white texture.
Declaration
public GPUTexture* GetDefaultWhiteTexture() const
Returns
|
GPUTexture
|
GetFeatureLevel()
Gets device feature level type.
Declaration
public FeatureLevel GetFeatureLevel() const
Returns
|
FeatureLevel
|
GetFormatFeatures(const PixelFormat format)
Gets the supported features for the specified format (index is the pixel format value).
Declaration
public FormatFeatures GetFormatFeatures(const PixelFormat format) const
Parameters
|
PixelFormat
format
The format. |
Returns
|
FormatFeatures
The format features flags. |
GetFullscreenTriangleVB()
Gets the fullscreen-triangle vertex buffer.
Declaration
public GPUBuffer* GetFullscreenTriangleVB() const
Returns
|
GPUBuffer
|
GetMainContext()
Gets the main GPU context.
Declaration
public virtual GPUContext* GetMainContext() = 0
Returns
|
GPUContext
|
GetMemoryUsage()
Gets the amount of memory usage by all the GPU resources (in bytes).
Declaration
public uint64 GetMemoryUsage() const
Returns
|
uint64
|
GetNativePtr()
Gets the native pointer to the underlying graphics device. It's a low-level platform-specific handle.
Declaration
public virtual void* GetNativePtr() const = 0
Returns
|
void
|
GetRendererType()
Gets the device renderer type.
Declaration
public RendererType GetRendererType() const
Returns
|
RendererType
|
GetResources()
Gets the list with all active GPU resources.
Declaration
public Array<GPUResource* > GetResources() const
Returns
|
Array<GPUResource >
|
GetShaderProfile()
Gets device shader profile type.
Declaration
public ShaderProfile GetShaderProfile() const
Returns
|
ShaderProfile
|
GetState()
Gets current device state.
Declaration
public DeviceState GetState() const
Returns
|
DeviceState
|
GetTasksManager()
Gets the GPU asynchronous work manager.
Declaration
public GPUTasksManager* GetTasksManager() const
Returns
|
GPUTasksManager
|
Init()
Init device resources
Declaration
public virtual bool Init()
Returns
|
bool
True if cannot init, otherwise false. |
IsRendering()
Returns true if device is during rendering state, otherwise false.
Declaration
public bool IsRendering() const
Returns
|
bool
|
LoadContent()
Load private device content (called when Content Pool is created)
Declaration
public virtual bool LoadContent()
Returns
|
bool
True if cannot load data in a proper way, otherwise false. |
OnRequestingExit()
Declaration
protected void OnRequestingExit()
preDispose()
Declaration
protected virtual void preDispose()
RemoveResource(GPUResource* resource)
RenderBegin()
Called during Draw method after rendering begin. Can be used to submit commands to the GPU after opening GPU command list.
Declaration
protected virtual void RenderBegin()
RenderEnd()
Called during Draw method before rendering end. Can be used to submit commands to the GPU before closing GPU command list.
Declaration
protected virtual void RenderEnd()
WaitForGPU()
Wait for GPU end doing submitted work
Declaration
public virtual void WaitForGPU() = 0
WasVSyncUsed()
Returns true if VSync was used during the last frame present.
Declaration
public bool WasVSyncUsed() const
Returns
|
bool
|