Class ConstantBuffer
Represents a constant buffer.
Namespace: Evergine.Framework.Graphics
Assembly: Evergine.Framework.dll
Syntax
public class ConstantBuffer
Constructors
ConstantBuffer(Buffer, ConstantBufferInfo)
Initializes a new instance of the ConstantBuffer class.
Declaration
public ConstantBuffer(Buffer buffer, ConstantBufferInfo cbufferInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| Buffer | buffer | The buffer. |
| ConstantBufferInfo | cbufferInfo | The constant buffer information. |
ConstantBuffer(GraphicsContext, ConstantBuffer)
Initializes a new instance of the ConstantBuffer class.
Declaration
public ConstantBuffer(GraphicsContext graphicsContext, ConstantBuffer proxyCBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| GraphicsContext | graphicsContext | The graphics context. |
| ConstantBuffer | proxyCBuffer | The proxy constant buffer. |
ConstantBuffer(GraphicsContext, ConstantBufferInfo, bool)
Initializes a new instance of the ConstantBuffer class.
Declaration
public ConstantBuffer(GraphicsContext graphicsContext, ConstantBufferInfo cbufferInfo, bool setDefaultValues = true)
Parameters
| Type | Name | Description |
|---|---|---|
| GraphicsContext | graphicsContext | The graphics context. |
| ConstantBufferInfo | cbufferInfo | The constant buffer info. |
| bool | setDefaultValues | If true, the default values specified in cbufferInfo will be applied. |
ConstantBuffer(ConstantBufferInfo, bool)
Initializes a new instance of the ConstantBuffer class.
Declaration
public ConstantBuffer(ConstantBufferInfo cbufferInfo, bool setDefaultValues = true)
Parameters
| Type | Name | Description |
|---|---|---|
| ConstantBufferInfo | cbufferInfo | The constant buffer information. |
| bool | setDefaultValues | Sets the default values. |
Fields
AllowDynamicOffset
Indicates if this buffer allows dynamic offsets.
Declaration
public readonly bool AllowDynamicOffset
Field Value
| Type | Description |
|---|---|
| bool |
CBufferInfo
Constant buffer information.
Declaration
public readonly ConstantBufferInfo CBufferInfo
Field Value
| Type | Description |
|---|---|
| ConstantBufferInfo |
Capacity
The capacity of the constant buffer.
Declaration
public uint Capacity
Field Value
| Type | Description |
|---|---|
| uint |
Data
The staging buffer.
Declaration
public nint Data
Field Value
| Type | Description |
|---|---|
| nint |
Dirty
Indicates whether it is necessary to update the graphics card buffer.
Declaration
public bool Dirty
Field Value
| Type | Description |
|---|---|
| bool |
Size
The constant buffer size in bytes.
Declaration
public uint Size
Field Value
| Type | Description |
|---|---|
| uint |
StartOffset
The starting offset in bytes.
Declaration
public uint StartOffset
Field Value
| Type | Description |
|---|---|
| uint |
UpdatePolicy
Indicates the constant buffer type by its field tags (PerFrame, PerCamera, PerPass, PerDrawCall).
Declaration
public UpdatePolicy UpdatePolicy
Field Value
| Type | Description |
|---|---|
| UpdatePolicy |
Properties
Buffer
Gets the buffer.
Declaration
public Buffer Buffer { get; }
Property Value
| Type | Description |
|---|---|
| Buffer |
ProxyCBuffer
Gets the proxy constant buffer.
Declaration
public ConstantBuffer ProxyCBuffer { get; }
Property Value
| Type | Description |
|---|---|
| ConstantBuffer |
Methods
Dispose()
Public implementation of the Dispose pattern, callable by consumers.
Declaration
public void Dispose()
Dispose(bool)
Protected implementation of the Dispose pattern.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | Disposes of native elements. |
EnsureBufferCapacity(uint)
Ensures the capacity of this constant buffer.
Declaration
public void EnsureBufferCapacity(uint newCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | newCapacity | The new capacity. |
~ConstantBuffer()
Finalizes an instance of the ConstantBuffer class.
Declaration
protected ~ConstantBuffer()
GetBufferData<T>(int)
Gets buffer data.
Declaration
public T GetBufferData<T>(int offset = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | offset | The offset in the buffer. |
Returns
| Type | Description |
|---|---|
| T | The read data. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of data to read. |
Prepare(CommandBuffer)
Prepares this buffer.
Declaration
public void Prepare(CommandBuffer commandBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | commandBuffer | The command buffer. |
Reset()
Resets this buffer.
Declaration
public void Reset()
SetBufferData(void*, uint, int)
Sets buffer content using the data pointer.
Declaration
public void SetBufferData(void* data, uint byteCount, int offset = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| void* | data | The data. |
| uint | byteCount | The number of bytes to copy. |
| int | offset | The offset. |
SetBufferData<T>(T, int)
Sets the buffer with a struct.
Declaration
public void SetBufferData<T>(T instance, int offset = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| T | instance | The struct instance. |
| int | offset | The offset. |
Type Parameters
| Name | Description |
|---|---|
| T | The struct type. |
SetDefaultParameters()
Sets the default parameters.
Declaration
public void SetDefaultParameters()
Update(CBufferEngineData, IEngineShaderParameters, bool, bool)
Sets the engine shader parameters in the constant buffers of the material.
Declaration
public void Update(CBufferEngineData cBufferEngineData, IEngineShaderParameters engineShaderParameters, bool append = false, bool align = true)
Parameters
| Type | Name | Description |
|---|---|---|
| CBufferEngineData | cBufferEngineData | The constant buffer engine data. |
| IEngineShaderParameters | engineShaderParameters | Parameters provided by the engine. |
| bool | append | Appends the buffer to the end of the buffer. |
| bool | align | Aligns the buffer offset. |
Events
BufferRefreshed
Event that is fired when the buffer is refreshed.
Declaration
public event EventHandler<Buffer> BufferRefreshed
Event Type
| Type | Description |
|---|---|
| EventHandler<Buffer> |