Skip to content

Class CommandRecorder

Namespace: Apogee.Graphics
Assembly: Apogee.Graphics.dll

A command buffer being recorded, with the operations the engine needs on it. Everything here is on the one queue family the device uses.

public abstract class CommandRecorder

Inheritance

object ← CommandRecorder

Derived

MetalCommandRecorder, VulkanCommandRecorder

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Constructors

CommandRecorder(GraphicsDevice)

protected CommandRecorder(GraphicsDevice device)

Parameters

device GraphicsDevice

Fields

WholeSize

For : from the offset to the end of the buffer.

public const ulong WholeSize = 18446744073709551615

Field Value

ulong

Properties

Device

public GraphicsDevice Device { get; }

Property Value

GraphicsDevice

Methods

Barrier(in ImageBarrier)

public void Barrier(in ImageBarrier barrier)

Parameters

barrier ImageBarrier

Barriers(ReadOnlySpan<ImageBarrier>, ReadOnlySpan<BufferBarrier>)

Records the barriers in one call; a state that only reads after a read needs none and is skipped by the caller (the render graph).

public abstract void Barriers(ReadOnlySpan<ImageBarrier> images, ReadOnlySpan<BufferBarrier> buffers = default)

Parameters

images ReadOnlySpan<ImageBarrier>

buffers ReadOnlySpan<BufferBarrier>

BeginLabel(string, float, float, float)

protected abstract void BeginLabel(string name, float r, float g, float b)

Parameters

name string

r float

g float

b float

BeginRendering(uint, uint, ReadOnlySpan<ColorTarget>, DepthTarget?)

Starts a dynamic-rendering pass over the whole of the given size. The viewport and scissor are set to it too.

public abstract void BeginRendering(uint width, uint height, ReadOnlySpan<ColorTarget> colors, DepthTarget? depth = null)

Parameters

width uint

height uint

colors ReadOnlySpan<ColorTarget>

depth DepthTarget?

BindIndexBuffer(GpuBuffer, IndexFormat, ulong)

public abstract void BindIndexBuffer(GpuBuffer buffer, IndexFormat format = IndexFormat.Index32, ulong offset = 0)

Parameters

buffer GpuBuffer

format IndexFormat

offset ulong

BindPipeline(Pipeline)

Binds the pipeline, and the bindless heap with it.

public abstract void BindPipeline(Pipeline pipeline)

Parameters

pipeline Pipeline

ClearDepthImage(GpuImage, float, uint, uint, uint, uint)

Sets mips and layers of a depth image to one value (the stencil, if there is one, to zero); the image must be in and not inside a rendering pass. Counts as in . Metal needs on the image.

public abstract void ClearDepthImage(GpuImage image, float depth = 0, uint baseMip = 0, uint mipCount = 4294967295, uint baseLayer = 0, uint layerCount = 4294967295)

Parameters

image GpuImage

depth float

baseMip uint

mipCount uint

baseLayer uint

layerCount uint

ClearImage(GpuImage, Vector4, uint, uint, uint, uint)

Sets mips and layers of a color image to one color (for float, normalized and sRGB formats); the image must be in and not inside a rendering pass. A count of means every remaining mip or layer. Metal has no such command and clears with a render pass, so there the image needs .

public abstract void ClearImage(GpuImage image, Vector4 color, uint baseMip = 0, uint mipCount = 4294967295, uint baseLayer = 0, uint layerCount = 4294967295)

Parameters

image GpuImage

color Vector4

baseMip uint

mipCount uint

baseLayer uint

layerCount uint

CopyBuffer(GpuBuffer, GpuBuffer, ulong, ulong, ulong)

public abstract void CopyBuffer(GpuBuffer source, GpuBuffer destination, ulong size, ulong sourceOffset = 0, ulong destinationOffset = 0)

Parameters

source GpuBuffer

destination GpuBuffer

size ulong

sourceOffset ulong

destinationOffset ulong

CopyBufferToImage(GpuBuffer, GpuImage, ReadOnlySpan<ImageRegion>)

Copies tightly packed texels from a buffer into subresources of an image that is in .

public abstract void CopyBufferToImage(GpuBuffer source, GpuImage destination, ReadOnlySpan<ImageRegion> regions)

Parameters

source GpuBuffer

destination GpuImage

regions ReadOnlySpan<ImageRegion>

CopyImageToBuffer(GpuImage, GpuBuffer, ReadOnlySpan<ImageRegion>)

Copies subresources of an image in into a buffer, tightly packed.

public abstract void CopyImageToBuffer(GpuImage source, GpuBuffer destination, ReadOnlySpan<ImageRegion> regions)

Parameters

source GpuImage

destination GpuBuffer

regions ReadOnlySpan<ImageRegion>

Dispatch(uint, uint, uint)

public abstract void Dispatch(uint groupsX, uint groupsY = 1, uint groupsZ = 1)

Parameters

groupsX uint

groupsY uint

groupsZ uint

DispatchIndirect(GpuBuffer, ulong)

Dispatches with the group counts in a buffer (a at offset, four-byte aligned) that is in : the output of a culling or compaction pass that decided how much work there is.

public abstract void DispatchIndirect(GpuBuffer arguments, ulong offset = 0)

Parameters

arguments GpuBuffer

offset ulong

Draw(uint, uint, uint, uint)

public abstract void Draw(uint vertexCount, uint instanceCount = 1, uint firstVertex = 0, uint firstInstance = 0)

Parameters

vertexCount uint

instanceCount uint

firstVertex uint

firstInstance uint

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

public abstract void DrawIndexed(uint indexCount, uint instanceCount = 1, uint firstIndex = 0, int vertexOffset = 0, uint firstInstance = 0)

Parameters

indexCount uint

instanceCount uint

firstIndex uint

vertexOffset int

firstInstance uint

DrawIndexedIndirect(GpuBuffer, ulong, uint, uint)

Draws with the arguments in a buffer in : drawCount s, stride bytes apart, from offset. Commands with an instance count of 0 draw nothing, which is how a culling pass removes a draw. The first instance of a command is honoured.

public abstract void DrawIndexedIndirect(GpuBuffer commands, ulong offset, uint drawCount, uint stride = 20)

Parameters

commands GpuBuffer

offset ulong

drawCount uint

stride uint

DrawIndexedIndirectCount(GpuBuffer, ulong, GpuBuffer, ulong, uint, uint)

Like , with the number of draws in a buffer too (a uint at countOffset, written by the pass that filled the commands), capped at maxDrawCount. Needs ; without it, call with the maximum and zero the instance count of the unused commands.

public abstract void DrawIndexedIndirectCount(GpuBuffer commands, ulong offset, GpuBuffer count, ulong countOffset, uint maxDrawCount, uint stride = 20)

Parameters

commands GpuBuffer

offset ulong

count GpuBuffer

countOffset ulong

maxDrawCount uint

stride uint

EndRendering()

public abstract void EndRendering()

FillBuffer(GpuBuffer, uint, ulong, ulong)

Fills a range of a buffer that is in with a 32-bit pattern (zero by default: a counter or a histogram that is about to be written). The offset and the size are multiples of four; means the rest of the buffer. Metal fills bytes, so there the four bytes of value must be equal (0, 0xFFFFFFFF, 0x01010101, ...).

public abstract void FillBuffer(GpuBuffer buffer, uint value = 0, ulong offset = 0, ulong size = 18446744073709551615)

Parameters

buffer GpuBuffer

value uint

offset ulong

size ulong

Label(string, float, float, float)

Opens a named, coloured group in RenderDoc and the validation layer's messages. Dispose the result to close it.

public DebugLabelScope Label(string name, float r = 0.5, float g = 0.5, float b = 0.5)

Parameters

name string

r float

g float

b float

Returns

DebugLabelScope

PushBytes(ReadOnlySpan<byte>)

protected abstract void PushBytes(ReadOnlySpan<byte> data)

Parameters

data ReadOnlySpan<byte>

PushConstants<T>(in T)

Sets the push constants (at most bytes) every stage can read: texture indices, buffer addresses, small parameters.

public void PushConstants<T>(in T data) where T : unmanaged

Parameters

data T

Type Parameters

T

SetScissor(int, int, uint, uint)

Restricts drawing to a rectangle of the target, in pixels (the viewport is left as it is).

public abstract void SetScissor(int x, int y, uint width, uint height)

Parameters

x int

y int

width uint

height uint

SetViewport(uint, uint)

Sets viewport and scissor to the whole target. The viewport is not flipped: clip-space +Y is down in the image.

public abstract void SetViewport(uint width, uint height)

Parameters

width uint

height uint