Class BufferExtensions
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
bufferBufferThe buffer to write to.
commandListCommandListThe command list that performs the upload.
dataReadOnlySpan<T>The data to upload. An empty span uploads nothing.
offsetInBytesintWhere in the buffer the data is written. Supported for buffers of default usage only, as for SetData<TData>(CommandList, ReadOnlySpan<TData>, int).
Type Parameters
TThe 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
bufferorcommandListis null.