Class MTLCommandBuffer
This class represent a set of commands.
Inherited Members
Namespace: Evergine.Metal
Assembly: Evergine.Metal.dll
Syntax
public class MTLCommandBuffer : CommandBuffer, IDisposable, IGetNativePointers
Constructors
MTLCommandBuffer(MTLGraphicsContext, MTLCommandQueue)
Initializes a new instance of the MTLCommandBuffer class.
Declaration
public MTLCommandBuffer(MTLGraphicsContext context, MTLCommandQueue queue)
Parameters
Type | Name | Description |
---|---|---|
MTLGraphicsContext | context | Graphics Context. |
MTLCommandQueue | queue | The commandqueue for this commandbuffer. |
Properties
GraphicsContext
Gets the generic graphicsContext.
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 debuggers tools.
Declaration
public override string Name { get; set; }
Property Value
Type | Description |
---|---|
string |
Overrides
Methods
Begin()
Set the initialize state for this commandbuffer. This function must be called before other graphics commands ca 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
You 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 queryheap containing the query. |
uint | index | The query index. |
Overrides
Remarks
This method works only with occusion and binaryOcclusion queryheap types.
BeginRenderPassInternal(ref RenderPassDescription)
Begin a render pass.
Declaration
protected override void BeginRenderPassInternal(ref RenderPassDescription description)
Parameters
Type | Name | Description |
---|---|---|
RenderPassDescription | description | The renderPass description RenderPassDescription. |
Overrides
Blit(Texture, uint, uint, uint, uint, uint, Texture, uint, uint, uint, uint, uint, uint)
Copies all subresources from this texture in other texture with format conversion and preparing to present in 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)
Perform an 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)
Perform an 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
ClearCache()
Clear all cached values of this command buffer...
Declaration
protected override void ClearCache()
Overrides
Commit()
Commits this command buffer to the command queue waiting to be execute on GPU after Submit().
Declaration
public override void Commit()
Overrides
CopyBufferDataToInternal(Buffer, Buffer, uint, uint, uint)
Copy this buffer in the destination buffer.
Declaration
protected override void CopyBufferDataToInternal(Buffer origin, Buffer destination, uint sizeInBytes, uint sourceOffset = 0, uint destinationOffset = 0)
Parameters
Type | Name | Description |
---|---|---|
Buffer | origin | the origin 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 in other 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)
Execute 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 which must be loaded with data that matches 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)
Launch 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 application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
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 | Number of vertices to draw. |
uint | startVertexLocation | Index of the first vertex, which is usually an offset in a vertex buffer. |
Overrides
DrawIndexed(uint, uint, uint)
Draw indexed, non-instanced primitives.
Declaration
public override void DrawIndexed(uint indexCount, uint startIndexLocation = 0, uint baseVertexLocation = 0)
Parameters
Type | Name | Description |
---|---|---|
uint | indexCount | 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)
Draw 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 | Number of indices read from the index buffer for each instance. |
uint | instanceCount | 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 | It is the number of draws to execute, and can be zero. |
uint | stride | It is the byte stride between succesive sets of draw parameters. |
Overrides
DrawInstanced(uint, uint, uint, uint)
Draw 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)
Draw 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 | Offset to the start of the GPU generated primitives. |
uint | drawCount | It is the number of draws to execute, and can be zero. |
uint | stride | It is the byte stride between succesive 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()
Completes 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 queryheap containing the query. |
uint | index | The query index. |
Overrides
Remarks
This method works only with occusion and binaryOcclusion queryheap types.
EndRenderPassInternal()
End 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 of 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 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()
Reset the command buffer to the initial state.
Declaration
public override void Reset()
Overrides
ResourceBarrierUnorderedAccessView(Buffer)
Sets a resource barrier for a texture.
Declaration
public override void ResourceBarrierUnorderedAccessView(Buffer buffer)
Parameters
Type | Name | Description |
---|---|---|
Buffer | buffer | The 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 commandbuffer.
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 commandbuffer.
Declaration
protected override void SetGraphicsPipelineStateInternal(GraphicsPipelineState pipeline)
Parameters
Type | Name | Description |
---|---|---|
GraphicsPipelineState | pipeline | The graphics pipeline state description. |
Overrides
SetIndexBufferInternal(Buffer, IndexFormat, uint)
Set an array of index buffers to the input-assembler stage.
Declaration
protected override void SetIndexBufferInternal(Buffer buffer, IndexFormat format, uint offset)
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 raytracing pipeline state object for this commandbuffer.
Declaration
protected override void SetRaytracingPipelineStateInternal(RaytracingPipelineState pipeline)
Parameters
Type | Name | Description |
---|---|---|
RaytracingPipelineState | pipeline | The raytracing pipeline state description. |
Overrides
SetResourceSetInternal(ResourceSet, uint, uint[])
Set the active ResourceSet for the given index.
Declaration
protected override void SetResourceSetInternal(ResourceSet resourceSet, uint index, uint[] constantBufferOffsets)
Parameters
Type | Name | Description |
---|---|---|
ResourceSet | resourceSet | The new ResourceSet. |
uint | index | The resourceSet index. |
uint[] | constantBufferOffsets | Array of values specifying the constant buffer offsets. |
Overrides
SetScissorRectangles(Rectangle[])
Set an scissor rectangle in a specific slot.
Declaration
public override void SetScissorRectangles(Rectangle[] rectangles)
Parameters
Type | Name | Description |
---|---|---|
Rectangle[] | rectangles | The array of the scissor rectangles. |
Overrides
SetVertexBufferInternal(uint, Buffer, uint)
Set an 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 buffer to the first vertex to use. |
Overrides
SetVertexBuffersInternal(Buffer[], int[])
Set an array of buffers to the input-assembler stage.
Declaration
protected override void SetVertexBuffersInternal(Buffer[] buffers, int[] offsets)
Parameters
Type | Name | Description |
---|---|---|
Buffer[] | buffers | The array of the vertex buffers being bound. |
int[] | offsets | Offsets (in bytes) from the start of each vertexbuffer to the first vertex to use. |
Overrides
SetViewports(Viewport[])
Set a viewport in a specific slot.
Declaration
public override void SetViewports(Viewport[] viewports)
Parameters
Type | Name | Description |
---|---|---|
Viewport[] | viewports | The array of the viewports. |
Overrides
UpdateBufferDataInternal(Buffer, nint, uint, uint)
Fill 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. |
IntPtr | source | The data pointer. |
uint | sourceSizeInBytes | The size in bytes. |
uint | destinationOffsetInBytes | The offset in bytes. |
Overrides
UpdateRaytracingAccelerationStructure(ref TopLevelAS, TopLevelASDescription)
Refit an top level accelerations structure build 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)
Write a device timestamp into a query heap.
Declaration
public override void WriteTimestamp(QueryHeap heap, uint index)
Parameters
Type | Name | Description |
---|---|---|
QueryHeap | heap | Specifies the queryheap. |
uint | index | The query index. |
Overrides
Remarks
This method works only with timestamp queryheap type.