Class GPUContextDX12
GPU Commands Context implementation for DirectX 12
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.h
Syntax
public class GPUContextDX12 : public GPUContext
Constructors
~GPUContextDX12()
Declaration
public ~GPUContextDX12()
GPUContextDX12(GPUDeviceDX12* device, D3D12_COMMAND_LIST_TYPE type)
Declaration
public GPUContextDX12(GPUDeviceDX12* device, D3D12_COMMAND_LIST_TYPE type)
Parameters
GPUDeviceDX12
device
|
D3D12_COMMAND_LIST_TYPE
type
|
Fields
FrameFenceValues
Declaration
public uint64 FrameFenceValues[2]
Field Value
uint64
|
Methods
AddTransitionBarrier(ResourceOwnerDX12* resource, const D3D12_RESOURCE_STATES before, const D3D12_RESOURCE_STATES after, const int32 subresourceIndex)
Adds the transition barrier for the given resource (or subresource). Supports batching barriers.
Declaration
public void AddTransitionBarrier(ResourceOwnerDX12* resource, const D3D12_RESOURCE_STATES before, const D3D12_RESOURCE_STATES after, const int32 subresourceIndex)
Parameters
ResourceOwnerDX12
resource
The resource. |
D3D12_RESOURCE_STATES
before
The 'before' state. |
D3D12_RESOURCE_STATES
after
The 'after' state. |
int32
subresourceIndex
The index of the subresource. |
AddUAVBarrier()
Adds the UAV barrier. Supports batching barriers.
Declaration
public void AddUAVBarrier()
BindCB(int32 slot, GPUConstantBuffer* cb)
Binds the constant buffer to the slot.
Declaration
public virtual void BindCB(int32 slot, GPUConstantBuffer* cb) override
Parameters
int32
slot
The slot index. |
GPUConstantBuffer
cb
The constant buffer. |
Overrides
BindIB(GPUBuffer* indexBuffer)
Binds the index buffer to the pipeline.
Declaration
public virtual void BindIB(GPUBuffer* indexBuffer) override
Parameters
GPUBuffer
indexBuffer
The index buffer. |
Overrides
BindSampler(int32 slot, GPUSampler* sampler)
Binds the texture sampler to the pipeline.
Declaration
public virtual void BindSampler(int32 slot, GPUSampler* sampler) override
Parameters
int32
slot
The slot index. |
GPUSampler
sampler
The sampler. |
Overrides
BindSR(int32 slot, GPUResourceView* view)
Binds the resource view to the shader resource slot (texture view or buffer view).
Declaration
public virtual void BindSR(int32 slot, GPUResourceView* view) override
Parameters
int32
slot
The slot index. |
GPUResourceView
view
The resource view. |
Overrides
BindUA(int32 slot, GPUResourceView* view)
Binds the resource view to the unordered access slot (texture view or buffer view).
Declaration
public virtual void BindUA(int32 slot, GPUResourceView* view) override
Parameters
int32
slot
The slot index. |
GPUResourceView
view
The resource view. |
Overrides
BindVB(const Span<GPUBuffer* >& vertexBuffers, const uint32* vertexBuffersOffsets=nullptr, GPUVertexLayout* vertexLayout=nullptr)
Binds the vertex buffers to the pipeline.
Declaration
public virtual void BindVB(const Span<GPUBuffer* >& vertexBuffers, const uint32* vertexBuffersOffsets=nullptr, GPUVertexLayout* vertexLayout=nullptr) override
Parameters
Span<GPUBuffer >
vertexBuffers
The array of vertex buffers to use. |
uint32
vertexBuffersOffsets
The optional array of byte offsets from the vertex buffers begins. Can be used to offset the vertex data when reusing the same buffer allocation for multiple geometry objects. |
GPUVertexLayout
vertexLayout
The optional vertex layout to use when passing data from vertex buffers to the vertex shader. If null, layout will be automatically extracted from vertex buffers combined. |
Overrides
Clear(GPUTextureView* rt, const Color& color)
Clears texture surface with a color. Supports volumetric textures and texture arrays (including cube textures).
Declaration
public virtual void Clear(GPUTextureView* rt, const Color& color) override
Parameters
GPUTextureView
rt
The target surface. |
Color
color
The clear color. |
Overrides
ClearDepth(GPUTextureView* depthBuffer, float depthValue, uint8 stencilValue)
Clears depth buffer.
Declaration
public virtual void ClearDepth(GPUTextureView* depthBuffer, float depthValue, uint8 stencilValue) override
Parameters
GPUTextureView
depthBuffer
The depth buffer to clear. |
float
depthValue
The clear depth value. |
uint8
stencilValue
The clear stencil value. |
Overrides
ClearState()
Clears the context state.
Declaration
public virtual void ClearState() override
Overrides
ClearUA(GPUBuffer* buf, const Float4& value)
Clears an unordered access buffer with a float value.
Declaration
public virtual void ClearUA(GPUBuffer* buf, const Float4& value) override
Parameters
GPUBuffer
buf
The buffer to clear. |
Float4
value
The clear value. |
Overrides
ClearUA(GPUBuffer* buf, const uint32 value[4])
Clears an unordered access buffer with an unsigned value.
Declaration
public virtual void ClearUA(GPUBuffer* buf, const uint32 value[4]) override
Parameters
GPUBuffer
buf
The buffer to clear. |
uint32
value
The clear value. |
Overrides
ClearUA(GPUTexture* texture, const Float4& value)
Clears an unordered access texture with a float value.
Declaration
public virtual void ClearUA(GPUTexture* texture, const Float4& value) override
Parameters
GPUTexture
texture
The texture to clear. |
Float4
value
The clear value. |
Overrides
ClearUA(GPUTexture* texture, const uint32 value[4])
Clears an unordered access texture with an unsigned value.
Declaration
public virtual void ClearUA(GPUTexture* texture, const uint32 value[4]) override
Parameters
GPUTexture
texture
The texture to clear. |
uint32
value
The clear value. |
Overrides
CopyBuffer(GPUBuffer* dstBuffer, GPUBuffer* srcBuffer, uint32 size, uint32 dstOffset, uint32 srcOffset)
Copies the buffer data.
Declaration
public virtual void CopyBuffer(GPUBuffer* dstBuffer, GPUBuffer* srcBuffer, uint32 size, uint32 dstOffset, uint32 srcOffset) override
Parameters
GPUBuffer
dstBuffer
The destination buffer to write to. |
GPUBuffer
srcBuffer
The source buffer to read from. |
uint32
size
The size of data to copy (in bytes). |
uint32
dstOffset
The offset (in bytes) from the destination buffer start to copy data to. |
uint32
srcOffset
The offset (in bytes) from the source buffer start to copy data from. |
Overrides
CopyCounter(GPUBuffer* dstBuffer, uint32 dstOffset, GPUBuffer* srcBuffer)
Copies the counter buffer value.
Declaration
public virtual void CopyCounter(GPUBuffer* dstBuffer, uint32 dstOffset, GPUBuffer* srcBuffer) override
Parameters
GPUBuffer
dstBuffer
The destination buffer. |
uint32
dstOffset
The destination aligned byte offset. |
GPUBuffer
srcBuffer
The source buffer. |
Overrides
CopyResource(GPUResource* dstResource, GPUResource* srcResource)
Copies the resource data (whole resource).
Declaration
public virtual void CopyResource(GPUResource* dstResource, GPUResource* srcResource) override
Parameters
GPUResource
dstResource
The destination resource. |
GPUResource
srcResource
The source resource. |
Overrides
CopySubresource(GPUResource* dstResource, uint32 dstSubresource, GPUResource* srcResource, uint32 srcSubresource)
Copies the subresource data.
Declaration
public virtual void CopySubresource(GPUResource* dstResource, uint32 dstSubresource, GPUResource* srcResource, uint32 srcSubresource) override
Parameters
GPUResource
dstResource
The destination resource. |
uint32
dstSubresource
The destination subresource index. |
GPUResource
srcResource
The source resource. |
uint32
srcSubresource
The source subresource index. |
Overrides
CopyTexture(GPUTexture* dstResource, uint32 dstSubresource, uint32 dstX, uint32 dstY, uint32 dstZ, GPUTexture* srcResource, uint32 srcSubresource)
Copies region of the texture.
Declaration
public virtual void CopyTexture(GPUTexture* dstResource, uint32 dstSubresource, uint32 dstX, uint32 dstY, uint32 dstZ, GPUTexture* srcResource, uint32 srcSubresource) override
Parameters
GPUTexture
dstResource
The destination resource. |
uint32
dstSubresource
The destination subresource index. |
uint32
dstX
The x-coordinate of the upper left corner of the destination region. |
uint32
dstY
The y-coordinate of the upper left corner of the destination region. |
uint32
dstZ
The z-coordinate of the upper left corner of the destination region. |
GPUTexture
srcResource
The source resource. |
uint32
srcSubresource
The source subresource index. |
Overrides
Dispatch(GPUShaderProgramCS* shader, uint32 threadGroupCountX, uint32 threadGroupCountY, uint32 threadGroupCountZ)
Executes a command list from a thread group.
Declaration
public virtual void Dispatch(GPUShaderProgramCS* shader, uint32 threadGroupCountX, uint32 threadGroupCountY, uint32 threadGroupCountZ) override
Parameters
GPUShaderProgramCS
shader
The compute shader program to execute. |
uint32
threadGroupCountX
The number of groups dispatched in the x direction. |
uint32
threadGroupCountY
The number of groups dispatched in the y direction. |
uint32
threadGroupCountZ
The number of groups dispatched in the z direction. |
Overrides
DispatchIndirect(GPUShaderProgramCS* shader, GPUBuffer* bufferForArgs, uint32 offsetForArgs)
Executes a command list from a thread group. Buffer must contain GPUDispatchIndirectArgs.
Declaration
public virtual void DispatchIndirect(GPUShaderProgramCS* shader, GPUBuffer* bufferForArgs, uint32 offsetForArgs) override
Parameters
GPUShaderProgramCS
shader
The compute shader program to execute. |
GPUBuffer
bufferForArgs
The buffer with drawing arguments. |
uint32
offsetForArgs
The aligned byte offset for arguments. |
Overrides
DrawIndexedInstanced(uint32 indicesCount, uint32 instanceCount, int32 startInstance, int32 startVertex, int32 startIndex)
Draws the indexed, instanced primitives.
Declaration
public virtual void DrawIndexedInstanced(uint32 indicesCount, uint32 instanceCount, int32 startInstance, int32 startVertex, int32 startIndex) override
Parameters
uint32
indicesCount
The indices count. |
uint32
instanceCount
Number of instances to draw. |
int32
startInstance
A value added to each index before reading per-instance data from a vertex buffer. |
int32
startVertex
A value added to each index before reading a vertex from the vertex buffer. |
int32
startIndex
The location of the first index read by the GPU from the index buffer. |
Overrides
DrawIndexedInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs)
Draws the instanced GPU-generated indexed primitives. Buffer must contain GPUDrawIndexedIndirectArgs.
Declaration
public virtual void DrawIndexedInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs) override
Parameters
GPUBuffer
bufferForArgs
The buffer with drawing arguments. |
uint32
offsetForArgs
The aligned byte offset for arguments. |
Overrides
DrawInstanced(uint32 verticesCount, uint32 instanceCount, int32 startInstance, int32 startVertex)
Draws the instanced primitives.
Declaration
public virtual void DrawInstanced(uint32 verticesCount, uint32 instanceCount, int32 startInstance, int32 startVertex) override
Parameters
uint32
verticesCount
The vertices count. |
uint32
instanceCount
Number of instances to draw. |
int32
startInstance
A value added to each index before reading per-instance data from a vertex buffer. |
int32
startVertex
A value added to each index before reading a vertex from the vertex buffer. |
Overrides
DrawInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs)
Draws the instanced GPU-generated primitives. Buffer must contain GPUDrawIndirectArgs.
Declaration
public virtual void DrawInstancedIndirect(GPUBuffer* bufferForArgs, uint32 offsetForArgs) override
Parameters
GPUBuffer
bufferForArgs
The buffer with drawing arguments. |
uint32
offsetForArgs
The aligned byte offset for arguments. |
Overrides
EventBegin(const Char* name)
Begins the profile event.
Declaration
public virtual void EventBegin(const Char* name) override
Parameters
Char
name
The name. |
Overrides
EventEnd()
Ends the last profile event.
Declaration
public virtual void EventEnd() override
Overrides
Execute(bool waitForCompletion=false)
Flush existing commands to the GPU
Declaration
public uint64 Execute(bool waitForCompletion=false)
Parameters
bool
waitForCompletion
True if CPU should wait for GPU to wait job |
Returns
uint64
Next fence value used for CPU/GPU work synchronization |
Flush()
Flushes the command buffer (calls GPU execution).
Declaration
public virtual void Flush() override
Overrides
FlushResourceBarriers()
Flush pending resource barriers
Declaration
public void FlushResourceBarriers()
Returns
void
|
FlushState()
Flushes the internal cached context state with a command buffer.
Declaration
public virtual void FlushState() override
Overrides
ForceRebindDescriptors()
Forces graphics backend to rebind descriptors after command list was used by external graphics library.
Declaration
public virtual void ForceRebindDescriptors() override
Overrides
FrameBegin()
Begins new frame and enters commands collecting mode.
Declaration
public virtual void FrameBegin() override
Overrides
FrameEnd()
Ends the current frame rendering.
Declaration
public virtual void FrameEnd() override
Overrides
GetActiveHeapDescriptor(const D3D12_CPU_DESCRIPTOR_HANDLE& cpuHandle, Descriptor& descriptor)
Declaration
protected void GetActiveHeapDescriptor(const D3D12_CPU_DESCRIPTOR_HANDLE& cpuHandle, Descriptor& descriptor)
Parameters
D3D12_CPU_DESCRIPTOR_HANDLE
cpuHandle
|
Descriptor
descriptor
|
GetCommandList()
Declaration
public ID3D12GraphicsCommandList* GetCommandList() const
Returns
ID3D12GraphicsCommandList
|
GetNativePtr()
Gets the native pointer to the underlying graphics device context. It's a low-level platform-specific handle.
Declaration
public virtual void* GetNativePtr() const override
Returns
void
|
Overrides
GetState()
Gets the current pipeline state binded to the graphics pipeline.
Declaration
public virtual GPUPipelineState* GetState() const override
Returns
GPUPipelineState
The current state. |
Overrides
IsDepthBufferBinded()
Determines whether depth buffer is binded to the pipeline. [Deprecated in v1.10]
Declaration
public virtual bool IsDepthBufferBinded() override
Returns
bool
|
Overrides
OnSwapChainFlush()
External event called by swap chain after using context end
Declaration
public void OnSwapChainFlush()
Reset()
Reset commands list and request new allocator for commands
Declaration
public void Reset()
ResetCB()
Unbinds all constant buffer slots and flushes the change with the driver (used to prevent driver detection of resource hazards, eg. when down-scaling the texture).
Declaration
public virtual void ResetCB() override
Overrides
ResetCounter(GPUBuffer* buffer)
Resets the counter buffer to zero (hidden by the driver).
Declaration
public virtual void ResetCounter(GPUBuffer* buffer) override
Parameters
GPUBuffer
buffer
The buffer. |
Overrides
ResetRenderTarget()
Unbinds all the render targets and flushes the change with the driver (used to prevent driver detection of resource hazards, eg. when down-scaling the texture).
Declaration
public virtual void ResetRenderTarget() override
Overrides
ResetSR()
Unbinds all shader resource slots and flushes the change with the driver (used to prevent driver detection of resource hazards, eg. when down-scaling the texture).
Declaration
public virtual void ResetSR() override
Overrides
ResetUA()
Unbinds all unordered access resource slots and flushes the change with the driver (used to prevent driver detection of resource hazards, eg. when down-scaling the texture).
Declaration
public virtual void ResetUA() override
Overrides
ResolveMultisample(GPUTexture* sourceMultisampleTexture, GPUTexture* destTexture, int32 sourceSubResource, int32 destSubResource, PixelFormat format)
Resolves the multisampled texture by performing a copy of the resource into a non-multisampled resource.
Declaration
public virtual void ResolveMultisample(GPUTexture* sourceMultisampleTexture, GPUTexture* destTexture, int32 sourceSubResource, int32 destSubResource, PixelFormat format) override
Parameters
GPUTexture
sourceMultisampleTexture
The source multisampled texture. Must be multisampled. |
GPUTexture
destTexture
The destination texture. Must be single-sampled. |
int32
sourceSubResource
The source sub-resource index. |
int32
destSubResource
The destination sub-resource index. |
PixelFormat
format
The format. Indicates how the multisampled resource will be resolved to a single-sampled resource. |
Overrides
SetBlendFactor(const Float4& value)
Sets the blend factor that modulate values for a pixel shader, render target, or both.
Declaration
public virtual void SetBlendFactor(const Float4& value) override
Parameters
Float4
value
Blend factors, one for each RGBA component. |
Overrides
SetRenderTarget(GPUTextureView* depthBuffer, const Span<GPUTextureView* >& rts)
Sets the render targets and the depth buffer to the output.
Declaration
public virtual void SetRenderTarget(GPUTextureView* depthBuffer, const Span<GPUTextureView* >& rts) override
Parameters
GPUTextureView
depthBuffer
The depth buffer (can be null). |
Span<GPUTextureView >
rts
The array with render targets to bind. |
Overrides
SetRenderTarget(GPUTextureView* depthBuffer, GPUTextureView* rt)
Sets the render target and the depth buffer to the output.
Declaration
public virtual void SetRenderTarget(GPUTextureView* depthBuffer, GPUTextureView* rt) override
Parameters
GPUTextureView
depthBuffer
The depth buffer. |
GPUTextureView
rt
The render target. |
Overrides
SetRenderTarget(GPUTextureView* rt)
Sets the render target to the output.
Declaration
public virtual void SetRenderTarget(GPUTextureView* rt) override
Parameters
GPUTextureView
rt
The render target. |
Overrides
SetResourceState(GPUResource* resource, uint64 state, int32 subresource)
Sets the state of the resource (or subresource).
Declaration
public virtual void SetResourceState(GPUResource* resource, uint64 state, int32 subresource) override
Parameters
GPUResource
resource
|
uint64
state
|
int32
subresource
|
Overrides
SetResourceState(ResourceOwnerDX12* resource, D3D12_RESOURCE_STATES after, int32 subresourceIndex=-1)
Set DirectX 12 resource state using resource barrier
Declaration
public void SetResourceState(ResourceOwnerDX12* resource, D3D12_RESOURCE_STATES after, int32 subresourceIndex=-1)
Parameters
ResourceOwnerDX12
resource
Resource to use |
D3D12_RESOURCE_STATES
after
The target state to resource have. |
int32
subresourceIndex
The subresource index. Use -1 to apply for the whole resource. |
SetScissor(const Rectangle& scissorRect)
Sets the scissor rectangle.
Declaration
public virtual void SetScissor(const Rectangle& scissorRect) override
Parameters
Rectangle
scissorRect
The scissor rectangle (in pixels). |
Overrides
SetState(GPUPipelineState* state)
Sets the graphics pipeline state.
Declaration
public virtual void SetState(GPUPipelineState* state) override
Parameters
GPUPipelineState
state
The state to bind. |
Overrides
SetStencilRef(uint32 value)
Sets the reference value for depth stencil tests.
Declaration
public virtual void SetStencilRef(uint32 value) override
Parameters
uint32
value
Reference value to perform against when doing a depth-stencil test. |
Overrides
SetViewport(const Viewport& viewport)
Sets the rendering viewport.
Declaration
public virtual void SetViewport(const Viewport& viewport) override
Parameters
Viewport
viewport
The viewport (in pixels). |
Overrides
UpdateBuffer(GPUBuffer* buffer, const void* data, uint32 size, uint32 offset)
Updates the buffer data.
Declaration
public virtual void UpdateBuffer(GPUBuffer* buffer, const void* data, uint32 size, uint32 offset) override
Parameters
GPUBuffer
buffer
The destination buffer to write to. |
void
data
The pointer to the data. |
uint32
size
The data size (in bytes) to write. |
uint32
offset
The offset (in bytes) from the buffer start to copy data to. |
Overrides
UpdateCB(GPUConstantBuffer* cb, const void* data)
Updates the constant buffer data.
Declaration
public virtual void UpdateCB(GPUConstantBuffer* cb, const void* data) override
Parameters
GPUConstantBuffer
cb
The constant buffer. |
void
data
The pointer to the data. |
Overrides
UpdateTexture(GPUTexture* texture, int32 arrayIndex, int32 mipIndex, const void* data, uint32 rowPitch, uint32 slicePitch)
Updates the texture data.
Declaration
public virtual void UpdateTexture(GPUTexture* texture, int32 arrayIndex, int32 mipIndex, const void* data, uint32 rowPitch, uint32 slicePitch) override
Parameters
GPUTexture
texture
The destination texture. |
int32
arrayIndex
The destination surface index in the texture array. |
int32
mipIndex
The absolute index of the mip map to update. |
void
data
The pointer to the data. |
uint32
rowPitch
The row pitch (in bytes) of the input data. |
uint32
slicePitch
The slice pitch (in bytes) of the input data. |