Using Veldrid, all graphics commands must be executed using a CommandList. A CommandList is a special device resource (created by a GraphicsDevice) that records a variety of commands. These commands can then be submitted for execution on the device using the GraphicsDevice.SubmitCommands method.
Several types of commands are available, depending on what work is being done.
DeviceBuffer objects can be updated directly in a CommandList, using the UpdateBuffer method. When this method is called, the new data is "queued" into the CommandList, and will only be copied into the DeviceBuffer when execution reaches that point in the recorded CommandList. It is also possible to queue up multiple updates to the same DeviceBuffer in the same CommandList. However, it should be noted that there is storage and processing overhead associated with queueing buffer updates in this way, and it should be used sparingly.
Data can be copied between DeviceBuffers or between Texture objects, using one of the CopyBuffer or CopyTexture overloads. In order to read back data stored on the GPU, one of these methods can be used to transfer the desired information into a "staging" resource, which can be directly mapped and read from the CPU.
Multisampled Textures can be resolved down into a regular non-multisampled Texture using the ResolveTexture method.
There are several state-change methods available, which control various pieces of state influencing Draw commands. The following state can be changed:
The DrawIndexed method can be invoked to record an indexed draw command into the CommandList. The effect of this draw is controlled by the active state of the CommandList -- which vertex buffer, index buffer, Pipeline, ResourceSets, and Framebuffer are bound, and what Viewport and scissor rectangles are set. Regular indexed and instanced draw commands are both supported by this method.
The Draw method can be invoked to record a non-indexed draw command into the CommandList. This method can be used without an index buffer bound, and simply selects sequential vertices from the bound vertex buffer, if it exists.
The Dispatch method can be invoked to record a compute dispatch command into the CommandList. The effects of this call depend on the currently-bound compute Pipeline and ResourceSets.
There are also "Indirect" variants of the above draw and compute functions. These "Indirect" variants allow the relevant draw/dispatch parameters to be read from a GPU DeviceBuffer, rather than passed in directly. This "Indirect" buffer must have been created with the BufferUsage.IndirectBuffer flag, and is subject to some other restrictions. The information stored in the buffer should adhere to the format of one of the following structures, depending on the operation being performed: