Table of Contents

Class CommandList

Namespace
NeoVeldrid
Assembly
NeoVeldrid.dll

A device resource which allows the recording of graphics commands, which can later be executed by a GraphicsDevice. Before graphics commands can be issued, the Begin() method must be invoked. When the CommandList is ready to be executed, End() must be invoked, and then SubmitCommands(CommandList) should be used. NOTE: The use of CommandList is not thread-safe. Access to the CommandList must be externally synchronized. There are some limitations dictating proper usage and ordering of graphics commands. For example, a Framebuffer, Pipeline, vertex buffer, and index buffer must all be bound before a call to DrawIndexed(uint, uint, uint, int, uint) will succeed. These limitations are described in each function, where applicable. CommandList instances cannot be executed multiple times per-recording. When executed by a GraphicsDevice, they must be reset and commands must be issued again. See CommandListDescription.

public abstract class CommandList : DeviceResource, IDisposable
Inheritance
CommandList
Implements
Inherited Members

Properties

IsDisposed

A bool indicating whether this instance has been disposed.

public abstract bool IsDisposed { get; }

Property Value

bool

Name

A string identifying this instance. Can be used to differentiate between objects in graphics debuggers and other tools.

public abstract string Name { get; set; }

Property Value

string

Methods

Begin()

Puts this CommandList into the initial state. This function must be called before other graphics commands can be issued. Begin must only be called if it has not been previously called, if End() has been called, or if SubmitCommands(CommandList) has been called on this instance.

public abstract void Begin()

ClearColorTarget(uint, RgbaFloat)

Clears the color target at the given index of the active Framebuffer. The index given must be less than the number of color attachments in the active Framebuffer.

public void ClearColorTarget(uint index, RgbaFloat clearColor)

Parameters

index uint

The color target index.

clearColor RgbaFloat

The value to clear the target to.

ClearDepthStencil(float)

Clears the depth-stencil target of the active Framebuffer. The active Framebuffer must have a depth attachment. With this overload, the stencil buffer is cleared to 0.

public void ClearDepthStencil(float depth)

Parameters

depth float

The value to clear the depth buffer to.

ClearDepthStencil(float, byte)

Clears the depth-stencil target of the active Framebuffer. The active Framebuffer must have a depth attachment.

public void ClearDepthStencil(float depth, byte stencil)

Parameters

depth float

The value to clear the depth buffer to.

stencil byte

The value to clear the stencil buffer to.

CopyBuffer(DeviceBuffer, uint, DeviceBuffer, uint, uint)

Copies a region from the source DeviceBuffer to another region in the destination DeviceBuffer.

public void CopyBuffer(DeviceBuffer source, uint sourceOffset, DeviceBuffer destination, uint destinationOffset, uint sizeInBytes)

Parameters

source DeviceBuffer

The source DeviceBuffer from which data will be copied.

sourceOffset uint

An offset into source at which the copy region begins.

destination DeviceBuffer

The destination DeviceBuffer into which data will be copied.

destinationOffset uint

An offset into destination at which the data will be copied.

sizeInBytes uint

The number of bytes to copy.

CopyTexture(Texture, Texture)

Copies all subresources from one Texture to another.

public void CopyTexture(Texture source, Texture destination)

Parameters

source Texture

The source of Texture data.

destination Texture

The destination of Texture data.

CopyTexture(Texture, Texture, uint, uint)

Copies one subresource from one Texture to another.

public void CopyTexture(Texture source, Texture destination, uint mipLevel, uint arrayLayer)

Parameters

source Texture

The source of Texture data.

destination Texture

The destination of Texture data.

mipLevel uint

The mip level to copy.

arrayLayer uint

The array layer to copy.

CopyTexture(Texture, uint, uint, uint, uint, uint, Texture, uint, uint, uint, uint, uint, uint, uint, uint, uint)

Copies a region from one Texture into another.

public void CopyTexture(Texture source, uint srcX, uint srcY, uint srcZ, uint srcMipLevel, uint srcBaseArrayLayer, Texture destination, uint dstX, uint dstY, uint dstZ, uint dstMipLevel, uint dstBaseArrayLayer, uint width, uint height, uint depth, uint layerCount)

Parameters

source Texture

The source Texture from which data is copied.

srcX uint

The X coordinate of the source copy region.

srcY uint

The Y coordinate of the source copy region.

srcZ uint

The Z coordinate of the source copy region.

srcMipLevel uint

The mip level to copy from the source Texture.

srcBaseArrayLayer uint

The starting array layer to copy from the source Texture.

destination Texture

The destination Texture into which data is copied.

dstX uint

The X coordinate of the destination copy region.

dstY uint

The Y coordinate of the destination copy region.

dstZ uint

The Z coordinate of the destination copy region.

dstMipLevel uint

The mip level to copy the data into.

dstBaseArrayLayer uint

The starting array layer to copy data into.

width uint

The width in texels of the copy region.

height uint

The height in texels of the copy region.

depth uint

The depth in texels of the copy region.

layerCount uint

The number of array layers to copy.

Dispatch(uint, uint, uint)

Dispatches a compute operation from the currently-bound compute state of this Pipeline.

public abstract void Dispatch(uint groupCountX, uint groupCountY, uint groupCountZ)

Parameters

groupCountX uint

The X dimension of the compute thread groups that are dispatched.

groupCountY uint

The Y dimension of the compute thread groups that are dispatched.

groupCountZ uint

The Z dimension of the compute thread groups that are dispatched.

DispatchIndirect(DeviceBuffer, uint)

Issues an indirect compute dispatch command based on the information contained in the given indirect DeviceBuffer. The information stored in the indirect Buffer should conform to the structure of IndirectDispatchArguments.

public void DispatchIndirect(DeviceBuffer indirectBuffer, uint offset)

Parameters

indirectBuffer DeviceBuffer

The indirect Buffer to read from. Must have been created with the IndirectBuffer flag.

offset uint

An offset, in bytes, from the start of the indirect buffer from which the draw commands will be read. This value must be a multiple of 4.

Dispose()

Frees unmanaged device resources controlled by this instance.

public abstract void Dispose()

Draw(uint)

Draws primitives from the currently-bound state in this CommandList. An index Buffer is not used.

public void Draw(uint vertexCount)

Parameters

vertexCount uint

The number of vertices.

Draw(uint, uint, uint, uint)

Draws primitives from the currently-bound state in this CommandList. An index Buffer is not used.

public void Draw(uint vertexCount, uint instanceCount, uint vertexStart, uint instanceStart)

Parameters

vertexCount uint

The number of vertices.

instanceCount uint

The number of instances.

vertexStart uint

The first vertex to use when drawing.

instanceStart uint

The starting instance value.

DrawIndexed(uint)

Draws indexed primitives from the currently-bound state in this CommandList.

public void DrawIndexed(uint indexCount)

Parameters

indexCount uint

The number of indices.

DrawIndexed(uint, uint, uint, int, uint)

Draws indexed primitives from the currently-bound state in this CommandList.

public void DrawIndexed(uint indexCount, uint instanceCount, uint indexStart, int vertexOffset, uint instanceStart)

Parameters

indexCount uint

The number of indices.

instanceCount uint

The number of instances.

indexStart uint

The number of indices to skip in the active index buffer.

vertexOffset int

The base vertex value, which is added to each index value read from the index buffer.

instanceStart uint

The starting instance value.

DrawIndexedIndirect(DeviceBuffer, uint, uint, uint)

Issues indirect, indexed draw commands based on the information contained in the given indirect DeviceBuffer. The information stored in the indirect Buffer should conform to the structure of IndirectDrawIndexedArguments.

public void DrawIndexedIndirect(DeviceBuffer indirectBuffer, uint offset, uint drawCount, uint stride)

Parameters

indirectBuffer DeviceBuffer

The indirect Buffer to read from. Must have been created with the IndirectBuffer flag.

offset uint

An offset, in bytes, from the start of the indirect buffer from which the draw commands will be read. This value must be a multiple of 4.

drawCount uint

The number of draw commands to read and issue from the indirect Buffer.

stride uint

The stride, in bytes, between consecutive draw commands in the indirect Buffer. This value must be a multiple of four, and must be larger than the size of IndirectDrawIndexedArguments.

DrawIndirect(DeviceBuffer, uint, uint, uint)

Issues indirect draw commands based on the information contained in the given indirect DeviceBuffer. The information stored in the indirect Buffer should conform to the structure of IndirectDrawArguments.

public void DrawIndirect(DeviceBuffer indirectBuffer, uint offset, uint drawCount, uint stride)

Parameters

indirectBuffer DeviceBuffer

The indirect Buffer to read from. Must have been created with the IndirectBuffer flag.

offset uint

An offset, in bytes, from the start of the indirect buffer from which the draw commands will be read. This value must be a multiple of 4.

drawCount uint

The number of draw commands to read and issue from the indirect Buffer.

stride uint

The stride, in bytes, between consecutive draw commands in the indirect Buffer. This value must be a multiple of four, and must be larger than the size of IndirectDrawArguments.

End()

Completes this list of graphics commands, putting it into an executable state for a GraphicsDevice. This function must only be called after Begin() has been called. It is an error to call this function in succession, unless Begin() has been called in between invocations.

public abstract void End()

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. The previous contents of all lower mipmap levels are overwritten by this operation. The target Texture must have been created with TextureUsage.GenerateMipmaps.

public void GenerateMipmaps(Texture texture)

Parameters

texture Texture

The Texture to generate mipmaps for. This Texture must have been created with TextureUsage.GenerateMipmaps.

InsertDebugMarker(string)

Inserts a debug marker into the CommandList at the current position. This is used by graphics debuggers to identify points of interest in a command stream.

public void InsertDebugMarker(string name)

Parameters

name string

The name of the marker. This is an opaque identifier used for display by graphics debuggers.

PopDebugGroup()

Pops the current debug group. This method must only be called after PushDebugGroup(string) has been called on this instance.

public void PopDebugGroup()

PushDebugGroup(string)

Pushes a debug group at the current position in the CommandList. This allows subsequent commands to be categorized and filtered when viewed in external debugging tools. This method can be called multiple times in order to create nested debug groupings. Each call to PushDebugGroup must be followed by a matching call to PopDebugGroup().

public void PushDebugGroup(string name)

Parameters

name string

The name of the group. This is an opaque identifier used for display by graphics debuggers.

ResolveTexture(Texture, Texture)

Resolves a multisampled source Texture into a non-multisampled destination Texture.

public void ResolveTexture(Texture source, Texture destination)

Parameters

source Texture

The source of the resolve operation. Must be a multisampled Texture (SampleCount > 1).

destination Texture

The destination of the resolve operation. Must be a non-multisampled Texture (SampleCount == 1).

ResolveTextureCore(Texture, Texture)

Resolves a multisampled source Texture into a non-multisampled destination Texture.

protected abstract void ResolveTextureCore(Texture source, Texture destination)

Parameters

source Texture

The source of the resolve operation. Must be a multisampled Texture (SampleCount > 1).

destination Texture

The destination of the resolve operation. Must be a non-multisampled Texture (SampleCount == 1).

SetComputeResourceSet(uint, ResourceSet)

Sets the active ResourceSet for the given index. This ResourceSet is only active for the compute Pipeline.

public void SetComputeResourceSet(uint slot, ResourceSet rs)

Parameters

slot uint

The resource slot.

rs ResourceSet

The new ResourceSet.

SetComputeResourceSet(uint, ResourceSet, uint, ref uint)

Sets the active ResourceSet for the given index. This ResourceSet is only active for the compute Pipeline.

public void SetComputeResourceSet(uint slot, ResourceSet rs, uint dynamicOffsetsCount, ref uint dynamicOffsets)

Parameters

slot uint

The resource slot.

rs ResourceSet

The new ResourceSet.

dynamicOffsetsCount uint

The number of dynamic offsets being used. This must be equal to the number of dynamic buffers (DynamicBinding) contained in the ResourceSet.

dynamicOffsets uint

A reference to the first of a series of offsets which will be applied to the dynamic buffers contained in the ResourceSet. These offsets are applied in the order that dynamic buffer elements appear in the ResourceSet. Each of these offsets must be a multiple of either UniformBufferMinOffsetAlignment or StructuredBufferMinOffsetAlignment, depending on the kind of resource.

SetComputeResourceSet(uint, ResourceSet, uint[])

Sets the active ResourceSet for the given index. This ResourceSet is only active for the compute Pipeline.

public void SetComputeResourceSet(uint slot, ResourceSet rs, uint[] dynamicOffsets)

Parameters

slot uint

The resource slot.

rs ResourceSet

The new ResourceSet.

dynamicOffsets uint[]

An array containing the offsets to apply to the dynamic buffers contained in the ResourceSet. The number of elements in this array must be equal to the number of dynamic buffers (DynamicBinding) contained in the ResourceSet. These offsets are applied in the order that dynamic buffer elements appear in the ResourceSet.

SetFramebuffer(Framebuffer)

Sets the active Framebuffer which will be rendered to. When drawing, the active Framebuffer must be compatible with the active Pipeline. A compatible Pipeline has the same number of output attachments with matching formats.

public void SetFramebuffer(Framebuffer fb)

Parameters

fb Framebuffer

The new Framebuffer.

SetFullScissorRect(uint)

Sets the active scissor rectangle at the given index to cover the active Framebuffer.

public void SetFullScissorRect(uint index)

Parameters

index uint

The color target index.

SetFullScissorRects()

Sets all active scissor rectangles to cover the active Framebuffer.

public void SetFullScissorRects()

SetFullViewport(uint)

Sets the active viewport at the given index to cover the entire active Framebuffer.

public void SetFullViewport(uint index)

Parameters

index uint

The color target index.

SetFullViewports()

Sets all active viewports to cover the entire active Framebuffer.

public void SetFullViewports()

SetGraphicsResourceSet(uint, ResourceSet)

Sets the active ResourceSet for the given index. This ResourceSet is only active for the graphics Pipeline.

public void SetGraphicsResourceSet(uint slot, ResourceSet rs)

Parameters

slot uint

The resource slot.

rs ResourceSet

The new ResourceSet.

SetGraphicsResourceSet(uint, ResourceSet, uint, ref uint)

Sets the active ResourceSet for the given index. This ResourceSet is only active for the graphics Pipeline.

public void SetGraphicsResourceSet(uint slot, ResourceSet rs, uint dynamicOffsetsCount, ref uint dynamicOffsets)

Parameters

slot uint

The resource slot.

rs ResourceSet

The new ResourceSet.

dynamicOffsetsCount uint

The number of dynamic offsets being used. This must be equal to the number of dynamic buffers (DynamicBinding) contained in the ResourceSet.

dynamicOffsets uint

A reference to the first of a series of offsets which will be applied to the dynamic buffers contained in the ResourceSet. These offsets are applied in the order that dynamic buffer elements appear in the ResourceSet. Each of these offsets must be a multiple of either UniformBufferMinOffsetAlignment or StructuredBufferMinOffsetAlignment, depending on the kind of resource.

SetGraphicsResourceSet(uint, ResourceSet, uint[])

Sets the active ResourceSet for the given index. This ResourceSet is only active for the graphics Pipeline.

public void SetGraphicsResourceSet(uint slot, ResourceSet rs, uint[] dynamicOffsets)

Parameters

slot uint

The resource slot.

rs ResourceSet

The new ResourceSet.

dynamicOffsets uint[]

An array containing the offsets to apply to the dynamic buffers contained in the ResourceSet. The number of elements in this array must be equal to the number of dynamic buffers (DynamicBinding) contained in the ResourceSet. These offsets are applied in the order that dynamic buffer elements appear in the ResourceSet. Each of these offsets must be a multiple of either UniformBufferMinOffsetAlignment or StructuredBufferMinOffsetAlignment, depending on the kind of resource.

SetIndexBuffer(DeviceBuffer, IndexFormat)

Sets the active DeviceBuffer. When drawing, an DeviceBuffer must be bound.

public void SetIndexBuffer(DeviceBuffer buffer, IndexFormat format)

Parameters

buffer DeviceBuffer

The new DeviceBuffer.

format IndexFormat

The format of data in the DeviceBuffer.

SetIndexBuffer(DeviceBuffer, IndexFormat, uint)

Sets the active DeviceBuffer. When drawing, an DeviceBuffer must be bound.

public void SetIndexBuffer(DeviceBuffer buffer, IndexFormat format, uint offset)

Parameters

buffer DeviceBuffer

The new DeviceBuffer.

format IndexFormat

The format of data in the DeviceBuffer.

offset uint

The offset from the start of the buffer, in bytes, from which data will start to be read.

SetPipeline(Pipeline)

Sets the active Pipeline used for rendering. When drawing, the active Pipeline must be compatible with the bound Framebuffer, ResourceSet, and DeviceBuffer objects. When a new Pipeline is set, the previously-bound ResourceSets on this CommandList become invalidated and must be re-bound.

public void SetPipeline(Pipeline pipeline)

Parameters

pipeline Pipeline

The new Pipeline object.

SetScissorRect(uint, uint, uint, uint, uint)

Sets the active scissor rectangle at the given index. The index given must be less than the number of color attachments in the active Framebuffer.

public abstract void SetScissorRect(uint index, uint x, uint y, uint width, uint height)

Parameters

index uint

The color target index.

x uint

The X value of the scissor rectangle.

y uint

The Y value of the scissor rectangle.

width uint

The width of the scissor rectangle.

height uint

The height of the scissor rectangle.

SetVertexBuffer(uint, DeviceBuffer)

Sets the active DeviceBuffer for the given index. When drawing, the bound DeviceBuffer objects must be compatible with the bound Pipeline. The given buffer must be non-null. It is not necessary to un-bind vertex buffers for Pipelines which will not use them. All extra vertex buffers are simply ignored.

public void SetVertexBuffer(uint index, DeviceBuffer buffer)

Parameters

index uint

The buffer slot.

buffer DeviceBuffer

The new DeviceBuffer.

SetVertexBuffer(uint, DeviceBuffer, uint)

Sets the active DeviceBuffer for the given index. When drawing, the bound DeviceBuffer objects must be compatible with the bound Pipeline. The given buffer must be non-null. It is not necessary to un-bind vertex buffers for Pipelines which will not use them. All extra vertex buffers are simply ignored.

public void SetVertexBuffer(uint index, DeviceBuffer buffer, uint offset)

Parameters

index uint

The buffer slot.

buffer DeviceBuffer

The new DeviceBuffer.

offset uint

The offset from the start of the buffer, in bytes, from which data will start to be read.

SetViewport(uint, Viewport)

Sets the active Viewport at the given index. The index given must be less than the number of color attachments in the active Framebuffer.

public void SetViewport(uint index, Viewport viewport)

Parameters

index uint

The color target index.

viewport Viewport

The new Viewport.

SetViewport(uint, ref Viewport)

Sets the active Viewport at the given index. The index given must be less than the number of color attachments in the active Framebuffer.

public abstract void SetViewport(uint index, ref Viewport viewport)

Parameters

index uint

The color target index.

viewport Viewport

The new Viewport.

UpdateBuffer(DeviceBuffer, uint, nint, uint)

Updates a DeviceBuffer region with new data.

public void UpdateBuffer(DeviceBuffer buffer, uint bufferOffsetInBytes, nint source, uint sizeInBytes)

Parameters

buffer DeviceBuffer

The resource to update.

bufferOffsetInBytes uint

An offset, in bytes, from the beginning of the DeviceBuffer's storage, at which new data will be uploaded.

source nint

A pointer to the start of the data to upload.

sizeInBytes uint

The total size of the uploaded data, in bytes.

UpdateBuffer<T>(DeviceBuffer, uint, ReadOnlySpan<T>)

Updates a DeviceBuffer region with new data. This function must be used with a blittable value type T.

public void UpdateBuffer<T>(DeviceBuffer buffer, uint bufferOffsetInBytes, ReadOnlySpan<T> source) where T : unmanaged

Parameters

buffer DeviceBuffer

The resource to update.

bufferOffsetInBytes uint

An offset, in bytes, from the beginning of the DeviceBuffer's storage, at which new data will be uploaded.

source ReadOnlySpan<T>

An readonly span containing the data to upload.

Type Parameters

T

The type of data to upload.

UpdateBuffer<T>(DeviceBuffer, uint, Span<T>)

Updates a DeviceBuffer region with new data. This function must be used with a blittable value type T.

public void UpdateBuffer<T>(DeviceBuffer buffer, uint bufferOffsetInBytes, Span<T> source) where T : unmanaged

Parameters

buffer DeviceBuffer

The resource to update.

bufferOffsetInBytes uint

An offset, in bytes, from the beginning of the DeviceBuffer's storage, at which new data will be uploaded.

source Span<T>

An span containing the data to upload.

Type Parameters

T

The type of data to upload.

UpdateBuffer<T>(DeviceBuffer, uint, T)

Updates a DeviceBuffer region with new data. This function must be used with a blittable value type T.

public void UpdateBuffer<T>(DeviceBuffer buffer, uint bufferOffsetInBytes, T source) where T : unmanaged

Parameters

buffer DeviceBuffer

The resource to update.

bufferOffsetInBytes uint

An offset, in bytes, from the beginning of the DeviceBuffer storage, at which new data will be uploaded.

source T

The value to upload.

Type Parameters

T

The type of data to upload.

UpdateBuffer<T>(DeviceBuffer, uint, ref T)

Updates a DeviceBuffer region with new data. This function must be used with a blittable value type T.

public void UpdateBuffer<T>(DeviceBuffer buffer, uint bufferOffsetInBytes, ref T source) where T : unmanaged

Parameters

buffer DeviceBuffer

The resource to update.

bufferOffsetInBytes uint

An offset, in bytes, from the beginning of the DeviceBuffer's storage, at which new data will be uploaded.

source T

A reference to the single value to upload.

Type Parameters

T

The type of data to upload.

UpdateBuffer<T>(DeviceBuffer, uint, ref T, uint)

Updates a DeviceBuffer region with new data. This function must be used with a blittable value type T.

public void UpdateBuffer<T>(DeviceBuffer buffer, uint bufferOffsetInBytes, ref T source, uint sizeInBytes) where T : unmanaged

Parameters

buffer DeviceBuffer

The resource to update.

bufferOffsetInBytes uint

An offset, in bytes, from the beginning of the DeviceBuffer's storage, at which new data will be uploaded.

source T

A reference to the first of a series of values to upload.

sizeInBytes uint

The total size of the uploaded data, in bytes.

Type Parameters

T

The type of data to upload.

UpdateBuffer<T>(DeviceBuffer, uint, T[])

Updates a DeviceBuffer region with new data. This function must be used with a blittable value type T.

public void UpdateBuffer<T>(DeviceBuffer buffer, uint bufferOffsetInBytes, T[] source) where T : unmanaged

Parameters

buffer DeviceBuffer

The resource to update.

bufferOffsetInBytes uint

An offset, in bytes, from the beginning of the DeviceBuffer's storage, at which new data will be uploaded.

source T[]

An array containing the data to upload.

Type Parameters

T

The type of data to upload.