Table of Contents

Class Buffer<T>

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

A buffer with typed information.

public class Buffer<T> : Buffer, IDisposable, IComponent, IReferencable, ICollectorHolder where T : unmanaged

Type Parameters

T

Type of an element of this buffer.

Inheritance
Buffer<T>
Implements
Inherited Members
Extension Methods

Constructors

Buffer(GraphicsDevice, BufferDescription, BufferFlags, PixelFormat, IntPtr)

protected Buffer(GraphicsDevice device, BufferDescription description, BufferFlags viewFlags, PixelFormat viewFormat, IntPtr dataPointer)

Parameters

device GraphicsDevice
description BufferDescription
viewFlags BufferFlags
viewFormat PixelFormat
dataPointer IntPtr

Fields

ElementSize

Gets the size of element T.

public readonly int ElementSize

Field Value

int

Methods

GetData(CommandList)

Gets the content of this texture to an array of data.

public T[] GetData(CommandList commandList)

Parameters

commandList CommandList

Returns

T[]

An array of data.

Remarks

This method is only working when called from the main thread that is accessing the main GraphicsDevice. This method creates internally a stagging resource if this texture is not already a stagging resouce, copies to it and map it to memory. Use method with explicit staging resource for optimal performances.

SetData(CommandList, ref T, int)

Copies the content of a single structure data from CPU memory to this buffer into GPU memory.

public void SetData(CommandList commandList, ref T fromData, int offsetInBytes = 0)

Parameters

commandList CommandList
fromData T

The data to copy from.

offsetInBytes int

The offset in bytes to write to.

Remarks

This method is only working when called from the main thread that is accessing the main GraphicsDevice. See the unmanaged documentation about Map/UnMap for usage and restrictions.

Exceptions

ArgumentException

SetData(CommandList, T[], int)

Copies the content an array of data from CPU memory to this buffer into GPU memory.

public void SetData(CommandList commandList, T[] fromData, int offsetInBytes = 0)

Parameters

commandList CommandList
fromData T[]

The data to copy from.

offsetInBytes int

The offset in bytes to write to.

Remarks

This method is only working when called from the main thread that is accessing the main GraphicsDevice. See the unmanaged documentation about Map/UnMap for usage and restrictions.