Table of Contents

Class BufferExtensions

Namespace
Stride.CommunityToolkit.Rendering
Assembly
Stride.CommunityToolkit.dll

Provides extension methods for Buffer.

public static class BufferExtensions
Inheritance
BufferExtensions

Methods

SetDataPinned<T>(Buffer, CommandList, ReadOnlySpan<T>, int)

Uploads a span to the buffer with the span's memory pinned for the duration of the call.

public static void SetDataPinned<T>(this Buffer buffer, CommandList commandList, ReadOnlySpan<T> data, int offsetInBytes = 0) where T : unmanaged

Parameters

buffer Buffer

The buffer to write to.

commandList CommandList

The command list that performs the upload.

data ReadOnlySpan<T>

The data to upload. An empty span uploads nothing.

offsetInBytes int

Where in the buffer the data is written. Supported for buffers of default usage only, as for SetData<TData>(CommandList, ReadOnlySpan<TData>, int).

Type Parameters

T

The element type of the data.

Remarks

Use it for a span over managed memory, such as an array or a List<T>. On Direct3D 11 the engine's upload of a default-usage buffer hands the span's address to native code without pinning it, in Stride 4.4.0 and earlier. A garbage collection during that call may move the array, and the upload then reads the wrong memory. The other backends pin the span themselves, where pinning again costs nothing.

Exceptions

ArgumentNullException

buffer or commandList is null.