Click or drag to resize
Ab4d.SharpEngine logo

GpuStagingBuffer Class

GpuStagingBuffer is a special buffer in graphics card's memory that can be written by CPU and can be used to copy its content to GPU local memory. GpuStagingBuffer batches the data write commands so that they are executed only once. When AutomaticallyWriteDataWhenFull is true (by default) this happens when the buffer is full. This also happens when WriteToGpu(Boolean, Boolean) method is called.
Inheritance Hierarchy
SystemObject
  Ab4d.SharpEngine.CoreComponentBase
    Ab4d.SharpEngine.CoreGpuDeviceComponent
      Ab4d.SharpEngine.CoreGpuBuffer
        Ab4d.SharpEngine.CoreGpuStagingBuffer

Namespace: Ab4d.SharpEngine.Core
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 3.2.9386+3a404a3e1ebfa4efd231da7fe6f10dfb23b95dc4
Syntax
C#
public class GpuStagingBuffer : GpuBuffer

The GpuStagingBuffer type exposes the following members.

Constructors
 NameDescription
Public methodGpuStagingBuffer Constructor
Top
Properties
 NameDescription
Public propertyAddedDataSize Gets the number of bytes that were added to this GpuStagingBuffer (this may be bigger then the actual number of added bytes because data blocks are aligned to 64 bytes).
Public propertyAutomaticallyWriteDataWhenFull When true (by default), then WriteToGpu(Boolean, Boolean) method is called when the buffer is full. If false and user adds more data that the size of the bufer, then an exception is thrown in AddData method.
Public propertyIsUsingTransferQueue 
Top
Methods
 NameDescription
Public methodAddDataT(T, GpuBuffer, Int32) AddData add the specified data to this GpuStagingBuffer. When AutomaticallyWriteDataWhenFull is true (by default), then this method calls WriteToGpu(Boolean, Boolean) method is called when the buffer is full. If AutomaticallyWriteDataWhenFull is false and user adds more data that the size of the bufer, then an exception is thrown. After calling this method the IsDataWritePostponed on the destinationBuffer is set to true (until the data is actually written to the buffer).
Public methodAddDataT(T, GpuBuffer, Int32) AddData add the specified data to this GpuStagingBuffer. When AutomaticallyWriteDataWhenFull is true (by default), then this method calls WriteToGpu(Boolean, Boolean) method is called when the buffer is full. If AutomaticallyWriteDataWhenFull is false and user adds more data that the size of the bufer, then an exception is thrown. After calling this method the IsDataWritePostponed on the destinationBuffer is set to true (until the data is actually written to the buffer).
Public methodAddDataT(ReadOnlySpan, Void, T) 
Public methodAddDataT(Span, Void, T) 
Public methodAddDataT(T, Int32, GpuBuffer, Int32) AddData add the specified data to this GpuStagingBuffer. When AutomaticallyWriteDataWhenFull is true (by default), then this method calls WriteToGpu(Boolean, Boolean) method is called when the buffer is full. If AutomaticallyWriteDataWhenFull is false and user adds more data that the size of the bufer, then an exception is thrown. After calling this method the IsDataWritePostponed on the destinationBuffer is set to true (until the data is actually written to the buffer).
Protected methodDispose Dispose
(Overrides GpuBufferDispose(Boolean))
Public methodWaitUntilAllDataWritten When WriteToGpu(Boolean, Boolean) is called with waitUntilFinished set to false, then this method can wait until all commands are finished and new data can be added to this GpuStagingBuffer again. This method will also write to GPU all additional data that was added after the call to WriteToGpu.
Public methodWriteToGpu WriteToGpu method fills the command buffer with buffer copy commands, submits it to the queue and waits until all the commands are executed (when waitUntilFinished parameter is true). Note that when waitUntilFinished is false, user must not add new data to this GpuStagingBuffer before the command has finished executing (user can call WaitUntilAllDataWritten to make sure that all the commands have finished executing).
Top
See Also