SoBufferObject Class |
Abstract base class for buffer object management.
Namespace: OIV.Inventor.Devices
The SoBufferObject type exposes the following members.
Name | Description | |
---|---|---|
ClearInstance | Free the memory allocated by the buffer object. | |
CreateInstance | Create a new buffer with the same properties as the current one. | |
Dispose |
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.) | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
FillT |
Convenient method to fill an SoBufferObject with
a default value.
| |
GetContext | Returns the device context where this buffer is valid. | |
GetHashCode |
Overrides GetHashCode().
(Inherited from SoNetBase.) | |
GetMappedBufferObject | Returns a pointer to the buffer object which is mapped by the actual object. | |
GetMappedBufferObjectAccessMode | Returns the access mode used for the buffer mapping. | |
GetMappedBufferObjectPosition | Returns the position in the source buffer mapped in this buffer. | |
GetMappedBufferObjectSize | Returns the size of the mapped area in bytes. | |
GetSize | Returns the size, in bytes, of the buffer object. | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
LockBuffer | Locks the buffer against concurrent calls from different threads. | |
Map(SoBufferObjectAccessModes) | Calls Map(accessMode, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Map(SoBufferObject, SoBufferObjectAccessModes) | Calls Map(targetBufferObject, accessMode, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Map(SoBufferObjectAccessModes, UInt64) | Calls Map(accessMode, offset, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Map(SoBufferObject, SoBufferObjectAccessModes, UInt64) | Calls Map(targetBufferObject, accessMode, startPosition, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Map(SoBufferObjectAccessModes, UInt64, UInt64) | Map the buffer to a system memory address and allows the mapping of a sub part of the buffer object into CPU memory. | |
Map(SoBufferObject, SoBufferObjectAccessModes, UInt64, UInt64) | Maps the current buffer object into the specified buffer object. | |
Memcpy(SoBufferObject) | Calls Memcpy(sourceBufferObject, System.UInt64(0), System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Memcpy(SoBufferObject, UInt64) | Calls Memcpy(sourceBufferObject, destOffset, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Memcpy(SoBufferObject, UInt64, UInt64) | Calls Memcpy(sourceBufferObject, destOffset, sourceOffset, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Memcpy(SoBufferObject, UInt64, UInt64, UInt64) | Copies data from the specified buffer object into this buffer object. | |
Memset(IntPtr) | Calls Memset(value, System.Convert.ToUInt64(1), System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Memset(IntPtr, UInt64) | Calls Memset(value, valueSize, System.UInt64(0), System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Memset(IntPtr, UInt64, UInt64) | Calls Memset(value, valueSize, offset, System.Convert.ToUInt64(SO_BUFFER_SIZE_ALL)). | |
Memset(IntPtr, UInt64, UInt64, UInt64) | This function sets the contents of (or a portion of) this buffer object to the specified value. | |
SetSize | Sets the size in bytes of the buffer object. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
UnlockBuffer | Unlocks the buffer object. | |
Unmap | Unmaps the buffer from CPU address space. | |
Unmap(SoBufferObject) | Unmap this buffer from the specified buffer object. |
Name | Description | |
---|---|---|
IsDisposable | ISafeDisposable interface implementation.
(Inherited from SoDisposable.) |
This class provides generic functions to manage buffer objects.
There are specific implementations of this class for buffer objects on each type of device:
OIV.Inventor.Devices.SoCpuBufferObject: A buffer in CPU system memory.
OIV.Inventor.Devices.SoGpuBufferObject: A buffer in GPU memory.
OIV.Inventor.Devices.SoGLBufferObject: A buffer in GPU memory managed through the OpenGL API.
In many cases the abstract OIV.Inventor.Devices.SoBufferObject methods allow the application to handle buffer objects without knowing the specific type of the buffer. This is very convenient when computation is implemented on multiple devices.
Since version 8.0, some Open Inventor classes take or return data using an OIV.Inventor.Devices.SoBufferObject (or derived class). For example texture images (see OIV.Inventor.Fields.SoSFImage), geometry data (see OIV.Inventor.Nodes.SoBufferedShape) and tiles of volume data (see OIV.LDM.SoLDMDataAccess).
Creating a buffer object
Before creating a non-CPU buffer object you must bind (then unbind) a valid context for the target device. For example, to create a GPU buffer object (OIV.Inventor.Devices.SoGpuBufferObject) you can bind the viewer's context using methods in the view class or you can use the class OIV.Inventor.Devices.SoGLContext. See the example on the SoGpuBuffer page. For an existing buffer object you can use the buffer's Bind()/Unbind()methods or get a valid context to bind using the GetContext()method. Binding this context is necessary before changing buffer properties or calling SetSize(), Memcpy(), Memset(), etc.
Allocating memory in a buffer object:Use the SetSize()method to allocate memory in a buffer object. (Note that you must bind a valid context before calling this method on non-CPU buffer objects.) Generally buffer objects have zero size when created. However some buffer object classes have a constructor that takes an existing block of memory as a parameter. In that case the initial size is non-zero. You must allocate memory before copying data into a buffer object using either the Memcpy()method or a direct reference . Memory is automatically allocated, if necessary, when a buffer object is mapped into another buffer object.
Loading data and retrieving data:Some buffer objects, e.g. OIV.Inventor.Devices.SoCpuBufferObject, have a constructor that takes an existing block of memory as a parameter. In this case the buffer object is automatically set to the necessary size to contain the specified data. Creating an SoCpuBufferObect that "wraps" the existing data is usually the first step in loading data into a non-CPU buffer using Memcpy() or Map().
The Memcpy()methods copy data into a buffer object from another buffer object. For example to copy data into an OpenGL buffer from a CPU buffer. Before using these methods on a non-CPU buffer object, you must bind (then unbind) a valid context for the target device. The buffer object must be large enough (have enough memory allocated) to hold the data. See the allocating memory topic above.
The Memset()methods fill a buffer object with a specified value. Before using these methods on a non-CPU buffer object, you must bind (then unbind) a valid context for the target device. The buffer object must be large enough (have enough memory allocated) to hold the data. See the allocating memory topic above.
The Map()methods that have a buffer object parameter "map" one buffer object into another, usually to allow the data to be accessed on a different device. When the access mode is READ_ONLY or READ_WRITE, the contents of the source buffer are available through the target buffer object after the Map()call. If necessary, Open Inventor will automatically do an inter-device transfer of the data. When the access mode is SET or READ_WRITE, the contents of the modified target buffer object are available through the source buffer object after the Unmap() call. If necessary, Open Inventor will automatically do an inter-device data transfer.
Some buffer object classes provide a Map()method that maps the buffer's data into CPU memory and returns a reference. If necessary, Open Inventor will automatically do an inter-device transfer of the data. While the buffer is mapped the application can directly modify its data using the returned reference. If the access mode is SET or READ_WRITE, the modified data will be available through the buffer object after the Unmap()call. If necessary, Open Inventor will automatically do an inter-device data transfer.