Class DX12CommandBuffer
This class represents a set of commands.
Implements
Inherited Members
Namespace: Evergine.DirectX12
Assembly: Evergine.DirectX12.dll
Syntax
public class DX12CommandBuffer : CommandBuffer, IGetNativePointers
Constructors
DX12CommandBuffer(DX12GraphicsContext, DX12CommandQueue)
Initializes a new instance of the DX12CommandBuffer class.
Declaration
public DX12CommandBuffer(DX12GraphicsContext context, DX12CommandQueue queue)
Parameters
Type | Name | Description |
---|---|---|
DX12GraphicsContext | context | Graphics context. |
DX12CommandQueue | queue | The command queue for this command buffer. |
Properties
GraphicsContext
Gets the generic graphics context.
Declaration
protected override GraphicsContext GraphicsContext { get; }
Property Value
Type | Description |
---|---|
GraphicsContext |
Overrides
Name
Gets or sets a string identifying this instance. Can be used in graphics debugging tools.
Declaration
public override string Name { get; set; }
Property Value
Type | Description |
---|---|
string |
Overrides
Methods
Begin()
Sets the initial state for this command buffer. This function must be called before other graphics commands can be issued.
Declaration
public override void Begin()
Overrides
BeginDebugMarker(string)
Marks the beginning of a section of event code. This allows subsequent commands to be categorized and filtered when viewed in external debugging tools.
Declaration
public override void BeginDebugMarker(string label)
Parameters
Type | Name | Description |
---|---|---|
string | label | String that contains the name of the event. |
Overrides
Remarks
Call the EndDebugMarker method to mark the end of the section of event code. BeginDebugMarker has no effect if the calling application is not running under an enabled profiling tool.
BeginQuery(QueryHeap, uint)
Begins a GPU query.
Declaration
public override void BeginQuery(QueryHeap heap, uint index)
Parameters
Type | Name | Description |
---|---|---|
QueryHeap | heap | Specifies the query heap containing the query. |
uint | index | The query index. |
Overrides
Remarks
This method works only with occlusion and binaryOcclusion query heap types.
BeginRenderPassInternal(ref RenderPassDescription)
Begins a render pass.
Declaration
protected override void BeginRenderPassInternal(ref RenderPassDescription description)
Parameters
Type | Name | Description |
---|---|---|
RenderPassDescription | description | The render pass description RenderPassDescription. |
Overrides
Blit(Texture, uint, uint, uint, uint, uint, Texture, uint, uint, uint, uint, uint, uint)
Copies all subresources from this texture to another texture with format conversion, preparing it to present in the swapchain.
Declaration
protected override void Blit(Texture source, uint sourceX, uint sourceY, uint sourceZ, uint sourceMipLevel, uint sourceBasedArrayLayer, Texture destination, uint destinationX, uint destinationY, uint destinationZ, uint destinationMipLevel, uint destinationBasedArrayLayer, uint layerCount)
Parameters
Type | Name | Description |
---|---|---|
Texture | source | The source Texture. |
uint | sourceX | The x-coordinate of the upper-left corner of the source region. |
uint | sourceY | The y-coordinate of the upper-left corner of the source region. |
uint | sourceZ | The z-coordinate of the upper-left corner of the source region. |
uint | sourceMipLevel | The mip level to copy from the source texture. |
uint | sourceBasedArrayLayer | The starting array layer to copy from the source texture. |
Texture | destination | The destination Texture into which data is copied. |
uint | destinationX | The x-coordinate of the upper-left corner of the destination region. |
uint | destinationY | The y-coordinate of the upper-left corner of the destination region. |
uint | destinationZ | The z-coordinate of the upper-left corner of the destination region. |
uint | destinationMipLevel | The mip level to copy the data into. |
uint | destinationBasedArrayLayer | The starting array layer to copy data into. |
uint | layerCount | The number of array layers to copy. |
Overrides
BuildRaytracingAccelerationStructure(BottomLevelASDescription)
Performs a bottom level acceleration structure build on the GPU.
Declaration
public override BottomLevelAS BuildRaytracingAccelerationStructure(BottomLevelASDescription description)
Parameters
Type | Name | Description |
---|---|---|
BottomLevelASDescription | description |
Returns
Type | Description |
---|---|
BottomLevelAS | Bottom level acceleration structure. |
Overrides
BuildRaytracingAccelerationStructure(TopLevelASDescription)
Performs a top-level acceleration structure build on the GPU.
Declaration
public override TopLevelAS BuildRaytracingAccelerationStructure(TopLevelASDescription description)
Parameters
Type | Name | Description |
---|---|---|
TopLevelASDescription | description |
Returns
Type | Description |
---|---|
TopLevelAS | Top-level Acceleration Structure. |
Overrides
Commit()
Commits this command buffer to the command queue, waiting to be executed on the GPU after Submit().
Declaration
public override void Commit()
Overrides
CopyBufferDataToInternal(Buffer, Buffer, uint, uint, uint)
Copies this buffer to the destination buffer.
Declaration
protected override void CopyBufferDataToInternal(Buffer buffer, Buffer destination, uint sizeInBytes, uint sourceOffset = 0, uint destinationOffset = 0)
Parameters
Type | Name | Description |
---|---|---|
Buffer | buffer | |
Buffer | destination | The destination buffer. |
uint | sizeInBytes | The data size in bytes to copy. |
uint | sourceOffset | The source buffer offset in bytes. |
uint | destinationOffset | The destination buffer offset in bytes. |
Overrides
CopyTextureDataToInternal(Texture, uint, uint, uint, uint, uint, Texture, uint, uint, uint, uint, uint, uint, uint, uint, uint)
Copies a region from this texture to another texture.
Declaration
protected override void CopyTextureDataToInternal(Texture source, uint sourceX, uint sourceY, uint sourceZ, uint sourceMipLevel, uint sourceBasedArrayLayer, Texture destination, uint destinationX, uint destinationY, uint destinationZ, uint destinationMipLevel, uint destinationBasedArrayLayer, uint width, uint height, uint depth, uint layerCount)
Parameters
Type | Name | Description |
---|---|---|
Texture | source | The source Texture. |
uint | sourceX | The x-coordinate of the upper left corner of the source region. |
uint | sourceY | The y-coordinate of the upper left corner of the source region. |
uint | sourceZ | The z-coordinate of the upper left corner of the source region. |
uint | sourceMipLevel | The mip level to copy from the source texture. |
uint | sourceBasedArrayLayer | The starting array layer to copy from the source texture. |
Texture | destination | The destination Texture into which data is copied. |
uint | destinationX | The x-coordinate of the upper left corner of the destination region. |
uint | destinationY | The y-coordinate of the upper left corner of the destination region. |
uint | destinationZ | The z-coordinate of the upper left corner of the destination region. |
uint | destinationMipLevel | The mip level to copy the data into. |
uint | destinationBasedArrayLayer | The starting array layer to copy data into. |
uint | width | The width in texels of the copy region. |
uint | height | The height in texels of the copy region. |
uint | depth | The depth in texels of the copy region. |
uint | layerCount | The number of array layers to copy. |
Overrides
Dispatch(uint, uint, uint)
Execute commands in a compute shader from a thread group.
Declaration
public override void Dispatch(uint threadGroupCountX, uint threadGroupCountY, uint threadGroupCountZ)
Parameters
Type | Name | Description |
---|---|---|
uint | threadGroupCountX | |
uint | threadGroupCountY | |
uint | threadGroupCountZ |
Overrides
Remarks
You call the Dispatch method to execute commands in a compute shader. A compute shader can be run on many threads in parallel within a thread group. Index a particular thread within a thread group using a 3D vector given by (x, y, z).
DispatchIndirect(Buffer, uint)
Executes a command list over one or more thread groups.
Declaration
public override void DispatchIndirect(Buffer argBuffer, uint offset)
Parameters
Type | Name | Description |
---|---|---|
Buffer | argBuffer | A buffer that must be loaded with data matching the argument list for Dispatch(uint, uint, uint). |
uint | offset | A byte-aligned offset between the start of the buffer and the arguments. |
Overrides
DispatchRays(DispatchRaysDescription)
Launches threads of a ray generation shader. See Initiating Raytracing for an overview. Can be called from graphics or compute command lists and bundles.
Declaration
public override void DispatchRays(DispatchRaysDescription description)
Parameters
Type | Name | Description |
---|---|---|
DispatchRaysDescription | description | Dispatch rays description. |
Overrides
Dispose()
Performs tasks associated with freeing, releasing, or resetting unmanaged resources defined by the application.
Declaration
public override void Dispose()
Overrides
Dispose(bool)
Releases unmanaged and optionally managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
|
Draw(uint, uint)
Draw non-indexed, non-instanced primitives.
Declaration
public override void Draw(uint vertexCount, uint startVertexLocation = 0)
Parameters
Type | Name | Description |
---|---|---|
uint | vertexCount | The number of vertices to draw. |
uint | startVertexLocation | The index of the first vertex, which is usually an offset in a vertex buffer. |
Overrides
DrawIndexed(uint, uint, uint)
Draws indexed, non-instanced primitives.
Declaration
public override void DrawIndexed(uint indexCount, uint startIndexLocation = 0, uint baseVertexLocation = 0)
Parameters
Type | Name | Description |
---|---|---|
uint | indexCount | The number of indices to draw. |
uint | startIndexLocation | The location of the first index read by the GPU from the index buffer. |
uint | baseVertexLocation | A value added to each index before reading a vertex from the vertex buffer. |
Overrides
DrawIndexedInstanced(uint, uint, uint, uint, uint)
Draws indexed, instanced primitives.
Declaration
public override void DrawIndexedInstanced(uint indexCountPerInstance, uint instanceCount, uint startIndexLocation = 0, uint baseVertexLocation = 0, uint startInstanceLocation = 0)
Parameters
Type | Name | Description |
---|---|---|
uint | indexCountPerInstance | The number of indices read from the index buffer for each instance. |
uint | instanceCount | The number of instances to draw. |
uint | startIndexLocation | The location of the first index read by the GPU from the index buffer. |
uint | baseVertexLocation | A value added to each index before reading a vertex from the vertex buffer. |
uint | startInstanceLocation | A value added to each index before reading per-instance data from a vertex buffer. |
Overrides
DrawIndexedInstancedIndirect(Buffer, uint, uint, uint)
Draw indexed, instanced, GPU-generated primitives.
Declaration
public override void DrawIndexedInstancedIndirect(Buffer argBuffer, uint offset, uint drawCount, uint stride)
Parameters
Type | Name | Description |
---|---|---|
Buffer | argBuffer | A buffer containing the GPU-generated primitives. |
uint | offset | Offset to the start of the GPU-generated primitives. |
uint | drawCount | The number of draws to execute, which can be zero. |
uint | stride | The byte stride between successive sets of draw parameters. |
Overrides
DrawInstanced(uint, uint, uint, uint)
Draws non-indexed, instanced primitives.
Declaration
public override void DrawInstanced(uint vertexCountPerInstance, uint instanceCount, uint startVertexLocation = 0, uint startInstanceLocation = 0)
Parameters
Type | Name | Description |
---|---|---|
uint | vertexCountPerInstance | Number of vertices to draw. |
uint | instanceCount | Number of instances to draw. |
uint | startVertexLocation | Index of the first vertex. |
uint | startInstanceLocation | A value added to each index before reading per-instance data from a vertex buffer. |
Overrides
DrawInstancedIndirect(Buffer, uint, uint, uint)
Draws instanced, GPU-generated primitives.
Declaration
public override void DrawInstancedIndirect(Buffer argBuffer, uint offset, uint drawCount, uint stride)
Parameters
Type | Name | Description |
---|---|---|
Buffer | argBuffer | A buffer containing the GPU-generated primitives. |
uint | offset | The offset to the start of the GPU-generated primitives. |
uint | drawCount | The number of draws to execute, which can be zero. |
uint | stride | The byte stride between successive sets of draw parameters. |
Overrides
EndDebugMarker()
Marks the end of a section of event code.
Declaration
public override void EndDebugMarker()
Overrides
Remarks
EndDebugMarker has no effect if the calling application is not running under an enabled profiling tool.
EndInternal()
Finalizes the command buffer.
Declaration
protected override void EndInternal()
Overrides
EndQuery(QueryHeap, uint)
Ends a GPU query.
Declaration
public override void EndQuery(QueryHeap heap, uint index)
Parameters
Type | Name | Description |
---|---|---|
QueryHeap | heap | Specifies the query heap containing the query. |
uint | index | The query index. |
Overrides
Remarks
This method works only with occlusion and binaryOcclusion query heap types.
EndRenderPassInternal()
Ends a render pass.
Declaration
protected override void EndRenderPassInternal()
Overrides
GenerateMipmaps(Texture)
Generates mipmaps for the given Texture. The largest mipmap is used to generate all the lower mipmap levels contained in the Texture.
Declaration
public override void GenerateMipmaps(Texture texture)
Parameters
Type | Name | Description |
---|---|---|
Texture | texture | The Texture to generate mipmaps for. This Texture must have been created with TextureFlags.GenerateMipmaps. |
Overrides
InsertDebugMarker(string)
Marks a single point of execution in the code. This is used by graphics debuggers to identify points of interest in a command stream.
Declaration
public override void InsertDebugMarker(string label)
Parameters
Type | Name | Description |
---|---|---|
string | label | String that contains the name of the event. |
Overrides
Remarks
InsertDebugMarker has no effect if the calling application is not running under an enabled profiling tool.
Reset()
Resets the command buffer to the initial state.
Declaration
public override void Reset()
Overrides
ResolveTexture(Texture, Texture)
Resolve a multisampled texture into a non-multisampled texture.
Declaration
public override void ResolveTexture(Texture source, Texture destination)
Parameters
Type | Name | Description |
---|---|---|
Texture | source | Source multisampled texture. |
Texture | destination | Non-multisampled texture. |
Overrides
ResourceBarrierUnorderedAccessView(Buffer)
Sets a resource barrier for a texture.
Declaration
public override void ResourceBarrierUnorderedAccessView(Buffer buffer)
Parameters
Type | Name | Description |
---|---|---|
Buffer | buffer | The texture's buffer. |
Overrides
ResourceBarrierUnorderedAccessView(Texture)
Sets a resource barrier for a texture.
Declaration
public override void ResourceBarrierUnorderedAccessView(Texture texture)
Parameters
Type | Name | Description |
---|---|---|
Texture | texture | The texture. |
Overrides
SetComputePipelineStateInternal(ComputePipelineState)
Sets the compute pipeline state object for this command buffer.
Declaration
protected override void SetComputePipelineStateInternal(ComputePipelineState pipeline)
Parameters
Type | Name | Description |
---|---|---|
ComputePipelineState | pipeline | The compute pipeline state description. |
Overrides
SetGraphicsPipelineStateInternal(GraphicsPipelineState)
Sets the graphics pipeline state object for this command buffer.
Declaration
protected override void SetGraphicsPipelineStateInternal(GraphicsPipelineState pipeline)
Parameters
Type | Name | Description |
---|---|---|
GraphicsPipelineState | pipeline | The graphics pipeline state description. |
Overrides
SetIndexBufferInternal(Buffer, IndexFormat, uint)
Sets an array of index buffers to the input-assembler stage.
Declaration
protected override void SetIndexBufferInternal(Buffer buffer, IndexFormat format = IndexFormat.UInt16, uint offset = 0)
Parameters
Type | Name | Description |
---|---|---|
Buffer | buffer | The buffer being bound. |
IndexFormat | format | Indices data type (default UInt16). |
uint | offset | Offset (in bytes) from the start of the index buffer to the first index to use. |
Overrides
SetRaytracingPipelineStateInternal(RaytracingPipelineState)
Sets the ray tracing pipeline state object for this command buffer.
Declaration
protected override void SetRaytracingPipelineStateInternal(RaytracingPipelineState pipeline)
Parameters
Type | Name | Description |
---|---|---|
RaytracingPipelineState | pipeline | The ray tracing pipeline state description. |
Overrides
SetResourceSetInternal(ResourceSet, uint, uint[])
Sets the active ResourceSet for the given index.
Declaration
protected override void SetResourceSetInternal(ResourceSet resourceSet, uint index, uint[] offsets)
Parameters
Type | Name | Description |
---|---|---|
ResourceSet | resourceSet | The new ResourceSet. |
uint | index | The resource set index. |
uint[] | offsets |
Overrides
SetScissorRectangles(Rectangle[])
Sets a scissor rectangle in a specific slot.
Declaration
public override void SetScissorRectangles(Rectangle[] rectangles)
Parameters
Type | Name | Description |
---|---|---|
Rectangle[] | rectangles | The array of scissor rectangles. |
Overrides
SetVertexBufferInternal(uint, Buffer, uint)
Sets buffers to the input-assembler stage.
Declaration
protected override void SetVertexBufferInternal(uint slot, Buffer buffer, uint offset = 0)
Parameters
Type | Name | Description |
---|---|---|
uint | slot | The buffer slot. |
Buffer | buffer | The buffer being bound. |
uint | offset | Offset (in bytes) from the start of the buffer to the first vertex to use. |
Overrides
SetVertexBuffersInternal(Buffer[], int[])
Sets an array of buffers to the input-assembler stage.
Declaration
protected override void SetVertexBuffersInternal(Buffer[] vertexBuffers, int[] offsets)
Parameters
Type | Name | Description |
---|---|---|
Buffer[] | vertexBuffers | |
int[] | offsets | Offsets (in bytes) from the start of each vertex buffer to the first vertex to use. |
Overrides
SetViewports(Viewport[])
Sets a viewport in a specific slot.
Declaration
public override void SetViewports(Viewport[] viewports)
Parameters
Type | Name | Description |
---|---|---|
Viewport[] | viewports | An array of viewports. |
Overrides
UpdateBufferDataInternal(Buffer, nint, uint, uint)
Fills the buffer from a pointer.
Declaration
protected override void UpdateBufferDataInternal(Buffer buffer, nint source, uint sourceSizeInBytes, uint destinationOffsetInBytes = 0)
Parameters
Type | Name | Description |
---|---|---|
Buffer | buffer | Buffer instance. |
nint | source | The data pointer. |
uint | sourceSizeInBytes | The size in bytes. |
uint | destinationOffsetInBytes | The offset in bytes. |
Overrides
UpdateRaytracingAccelerationStructure(ref TopLevelAS, TopLevelASDescription)
Refit a top-level acceleration structure built on the GPU.
Declaration
public override void UpdateRaytracingAccelerationStructure(ref TopLevelAS tlas, TopLevelASDescription newDescription)
Parameters
Type | Name | Description |
---|---|---|
TopLevelAS | tlas | Top-level acceleration structure. |
TopLevelASDescription | newDescription | New top-level description. |
Overrides
WriteTimestamp(QueryHeap, uint)
Writes a device timestamp into a query heap.
Declaration
public override void WriteTimestamp(QueryHeap heap, uint index)
Parameters
Type | Name | Description |
---|---|---|
QueryHeap | heap | Specifies the query heap. |
uint | index | The query index. |
Overrides
Remarks
This method works only with timestamp query heap type.