Struct IndexBufferHelper
public readonly struct IndexBufferHelper
- Inherited Members
Examples
Reading the indices of a mesh:
Model.Meshes[0].Draw.IndexBuffer.AsReadable(Services, out IndexBufferHelper helper, out int count)
var indices = helper.To32Bit();
Constructors
IndexBufferHelper(IndexBufferBinding, IServiceRegistry, out int)
Fetch this buffer and create a helper to read from it.
public IndexBufferHelper(IndexBufferBinding binding, IServiceRegistry services, out int count)
Parameters
bindingIndexBufferBindingThe bindings for this buffer
servicesIServiceRegistryThe service used to retrieve the buffer from disk/GPU if it wasn't found through other means
countintThe amount of indices this buffer holds
Examples
Reading the indices of a mesh:
Model.Meshes[0].Draw.IndexBuffer.AsReadable(Services, out IndexBufferHelper helper, out int count)
var indices = helper.To32Bit();
Remarks
This operation loads the buffer from disk, or directly from the gpu. It is very slow, avoid calling this too often if at all possible.
IndexBufferHelper(IndexBufferBinding, byte[], out int)
Fetch this buffer and create a helper to read from it.
public IndexBufferHelper(IndexBufferBinding binding, byte[] dataOuter, out int count)
Parameters
bindingIndexBufferBindingThe bindings for this buffer
dataOuterbyte[]countintThe amount of indices this buffer holds
Examples
Reading the indices of a mesh:
Model.Meshes[0].Draw.IndexBuffer.AsReadable(Services, out IndexBufferHelper helper, out int count)
var indices = helper.To32Bit();
Remarks
This operation loads the buffer from disk, or directly from the gpu. It is very slow, avoid calling this too often if at all possible.
Fields
Binding
public readonly IndexBufferBinding Binding
Field Value
DataOuter
Full index buffer, does not account for the binding offset or length
public readonly byte[] DataOuter
Field Value
- byte[]
Properties
DataInner
Effective index buffer, handles the binding offset
public Span<byte> DataInner { get; }
Property Value
Methods
CopyTo(Span<int>)
public void CopyTo(Span<int> dest)
Parameters
CopyTo(Span<ushort>)
public void CopyTo(Span<ushort> dest)
Parameters
Is32Bit(out Span<int>, out Span<ushort>)
Branch to read the buffer as a 16 or 32 bit buffer, does not allocate
public bool Is32Bit(out Span<int> data32, out Span<ushort> data16)
Parameters
Returns
Examples
if (Is32Bit(out var d32, out var d16))
{
foreach (var value in d32)
{
// Your logic for 32 bit
}
}
else
{
foreach (var value in d16)
{
// Your logic for 16bit
}
}
To16Bit()
Does not allocate if the buffer is already 16 bit, otherwise allocates a new ushort[] and copies the data into it
public Span<ushort> To16Bit()
Returns
To32Bit()
Does not allocate if the buffer is already 32 bit, otherwise allocates a new int[] and copies the data into it
public Span<int> To32Bit()