HDK
|
#include <IMX_VDB.h>
Classes | |
class | Topology |
Public Member Functions | |
IMX_VDB () | |
An un-allocated null-VDB, but with default meta data. More... | |
IMX_VDB (const IMX_VDB &other) | |
IMX_VDB (IMX_VDB &&other) noexcept | |
~IMX_VDB () override | |
EntryType | poolTypeID () const override |
void | copy (const IMX_VDB &other) |
Assignment operators. More... | |
IMX_VDB & | operator= (const IMX_VDB &other) |
void | swap (IMX_VDB &other) |
IMX_VDB & | operator= (IMX_VDB &&other) |
openvdb::GridBase::Ptr | createVDB () const |
bool | save (std::ostream &os) const |
Returns true for successful save. More... | |
bool | saveJSON (UT_JSONWriter &w) const |
void | copyMetadataToOptions (UT_Options &opt) const |
void | updateMetadataFromOptions (const UT_Options &opt) |
Load ourselves from the options, ignoring fields we don't know. More... | |
void | copyFromVDB (const openvdb::GridBase &vdb, const UT_Vector3 &voxelsize, const GA_PrimVolumeXform &indexspace, bool ontocpu=true, bool ontogppu=true) |
void | cpuCopyFromVDB (const openvdb::GridBase &vdb, const UT_Vector3 &voxelsize, const GA_PrimVolumeXform &indexspace) |
void | gpuCopyFromVDB (const openvdb::GridBase &vdb, const UT_Vector3 &voxelsize, const GA_PrimVolumeXform &indexspace) |
void | buildFromTopology (UT_VDBType storage, const IMX_VDB *refvdb) |
CE_VDBGrid * | getGPUBuffer (bool read, bool write) |
const CE_VDBGrid * | getGPUBufferR () const |
CE_VDBGrid * | getGPUBufferW () |
UT_VDBType | storageType () const |
int | getChannels () const |
void | setTypeInfo (IMX_TypeInfo typeinfo) |
IMX_TypeInfo | typeInfo () const |
UT_Vector3 | voxelSize () const |
UT_Vector3 | origin () const |
GA_PrimVolumeXform | indexSpace () const |
bool | isAligned (const IMX_VDB *vdb) const |
True if the two vdbs map the same indices to the same positions. More... | |
void | transform (const UT_Matrix4D &m) |
void | adoptGrid (UT_UniquePtr< CE_VDBGrid > grid, cl::Buffer tilestarts, exint leafcount, exint lowercount, exint uppercount, const UT_Vector3 &voxelsize, const GA_PrimVolumeXform &indexspace) |
UT_SharedPtr< CE_BufferHostByte > | getCPUBufferR () const |
CE_BufferHostByte * | getCPUBufferRW () |
bool | isOnGPU () const |
Returns true if this vdb's data is currently on the GPU. More... | |
bool | isOnCPU () const |
bool | stealable () const |
void | setStealable (bool v) const |
bool | hasTopology () const |
exint | leafCount () const |
exint | lowerCount () const |
exint | upperCount () const |
void | buildTopology (const openvdb::GridBase &grid) |
void | buildTopologyFromCPU (bool denseleaves) |
Build topology from our own cpu buffer. More... | |
cl::Buffer | getGPUTileStarts (exint &tilecount) const |
Return a gpu version. More... | |
UT_SharedPtr< UT_Array < UT_Vector3i > > | getCPUTileStarts () const |
bool | denseLeaves () const |
void | setDenseLeaves (bool dense) |
bool | isDirty () const |
True if there are no VDB grids on GPU or CPU. More... | |
void | setDirty () |
Flag all grids as dirty without freeing them. More... | |
void | freeBuffers () |
Frees all buffers and marks dirty. More... | |
void | destroy () |
Frees all the memory. More... | |
bool | allocated () const |
int64 | getMemoryUsage () const |
int64 | getDeviceMemoryUsage () const |
void | setAttributes (const UT_OptionsHolder &attrib) |
UT_OptionsHolder | attributes () const |
template<typename OP > | |
void | updateAttributes (const OP &op) |
![]() | |
IMX_PoolEntry () | |
Creates a new buffer. You must call setSize to make this buffer usable. More... | |
virtual | ~IMX_PoolEntry () |
IMX_PoolEntry (const IMX_PoolEntry &)=delete | |
IMX_PoolEntry & | operator= (const IMX_PoolEntry &)=delete |
bool | isInUseGPU () const |
void | setInUseGPUFlag () const |
void | clearInUseGPUFlag () const |
Static Public Member Functions | |
static IMX_VDBPtr | load (UT_IStream &is) |
static IMX_VDBPtr | loadJSON (UT_JSONParser &p) |
static const char * | cnanovdbStorageDefine (UT_VDBType storagetype) |
static int | registerVDB (IMX_VDBConstPtr vdb, UT_IntArray ®istered) |
static void | unregisterVDBs (UT_IntArray ®istered) |
static IMX_VDBConstPtr | lookupVDB (int handle) |
Look up a registered vdb by handle. More... | |
Protected Member Functions | |
void | poolResetGPUBuffer () override |
void | poolSetOnGPU (bool ongpu) override |
Update OnGPU. More... | |
bool | poolIsGPUBufferEmpty () const override |
True if the gpu buffer is null. More... | |
bool | poolIsGPUBufferValid () const override |
True if the gpu buffer is not null and valid. More... | |
bool | poolSwapGPUBuffer (IMX_PoolEntry *otherbase) override |
True if the swap does something. More... | |
void | poolShallowCopyGPUBuffer (const IMX_PoolEntry *srcbase) override |
Shallow copy. More... | |
void | unloadFromGPU () override |
UT_SharedPtr< CE_BufferHostByte > | getCPUBufferRInternal () |
Protected Attributes | |
UT_SharedPtr< CE_BufferHostByte > | myCPUBuffer |
UT_SharedPtr< Topology > | myTopology |
UT_Vector3 | myVoxelSize |
GA_PrimVolumeXform | myIndexSpace |
UT_SharedPtr< CE_VDBGrid > | myGPUBuffer |
UT_OptionsHolder | myAttributes |
IMX_TypeInfo | myTypeInfo = IMX_TypeInfo::IMX_NONE |
UT_VDBType | myStorageType = UT_VDB_INVALID |
bool | myOnCPU = false |
bool | myOnGPU = false |
bool | myStealable = true |
![]() | |
int | myGPUInUseCount = 0 |
Friends | |
IMX_API size_t | format (char *buffer, size_t buffer_size, const IMX_VDB &v) |
Additional Inherited Members | |
![]() | |
enum | EntryType { EntryType::BUFFER = 0, EntryType::VDB } |
To avoid the need for dynamic casts: More... | |
IMX_VDB::IMX_VDB | ( | ) |
An un-allocated null-VDB, but with default meta data.
|
override |
void IMX_VDB::adoptGrid | ( | UT_UniquePtr< CE_VDBGrid > | grid, |
cl::Buffer | tilestarts, | ||
exint | leafcount, | ||
exint | lowercount, | ||
exint | uppercount, | ||
const UT_Vector3 & | voxelsize, | ||
const GA_PrimVolumeXform & | indexspace | ||
) |
Sets the underlying GPU buffer to provided grid, taking ownership of it.
|
inline |
|
inline |
void IMX_VDB::buildFromTopology | ( | UT_VDBType | storage, |
const IMX_VDB * | refvdb | ||
) |
Replaces self with a vdb using the provided source's topology. If same type this is just a copy(). Otherewise it is zeroed. Copies transform & metadata options.
void IMX_VDB::buildTopology | ( | const openvdb::GridBase & | grid | ) |
Build topology from provided grid. These are built onto the GPU & CPU. This could be delayed since we share the topology pointer so would only upload once.
void IMX_VDB::buildTopologyFromCPU | ( | bool | denseleaves | ) |
Build topology from our own cpu buffer.
|
static |
void IMX_VDB::copyFromVDB | ( | const openvdb::GridBase & | vdb, |
const UT_Vector3 & | voxelsize, | ||
const GA_PrimVolumeXform & | indexspace, | ||
bool | ontocpu = true , |
||
bool | ontogppu = true |
||
) |
Copies a VDB into ourselves, creating both CPU and GPU buffers by default. Can throw CE exceptions.
void IMX_VDB::copyMetadataToOptions | ( | UT_Options & | opt | ) | const |
Write our fields into the provided options: THis does not include attributes.
|
inline |
openvdb::GridBase::Ptr IMX_VDB::createVDB | ( | ) | const |
Conversion to/from openvdb. Can throw CE exceptions.
|
inline |
void IMX_VDB::destroy | ( | ) |
Frees all the memory.
void IMX_VDB::freeBuffers | ( | ) |
Frees all buffers and marks dirty.
int IMX_VDB::getChannels | ( | ) | const |
UT_SharedPtr<CE_BufferHostByte> IMX_VDB::getCPUBufferR | ( | ) | const |
If onCPU, returns a shared pointer to the cpu buffer If onGPU, copy to CPU and return the shared pointer, keeping GPU copy. If dirty, return null. Can throw CE exceptions.
|
protected |
CE_BufferHostByte* IMX_VDB::getCPUBufferRW | ( | ) |
If onCPU, ensure unique and return the raw pointer that is our own buffer. If onGPU, copies to the CPU and returns that, resetting onGPU to false If dirty, return null.
|
inline |
int64 IMX_VDB::getDeviceMemoryUsage | ( | ) | const |
CE_VDBGrid* IMX_VDB::getGPUBuffer | ( | bool | read, |
bool | write | ||
) |
Returns this vdb's GPU storage object. If read is true, isDirty must be false. If write is true then it turns off isDirty by setting isOnGPU() and turning off isOnCPU() (it is assuming caller will actually write the buffer) When using one of these methods, this buffer must be guarded with the in-use GPU flag. See setInUseGPUFlag() documentation for more information. Can throw CE exceptions.
const CE_VDBGrid* IMX_VDB::getGPUBufferR | ( | ) | const |
|
inline |
|
inline |
int64 IMX_VDB::getMemoryUsage | ( | ) | const |
|
inline |
bool IMX_VDB::hasTopology | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
Returns a newly created VDB loaded from the stream, or null if load failure.
|
static |
|
static |
Look up a registered vdb by handle.
|
inline |
|
inlineoverrideprotectedvirtual |
|
inlineoverrideprotectedvirtual |
True if the gpu buffer is not null and valid.
Implements IMX_PoolEntry.
|
inlineoverrideprotectedvirtual |
These implement methods required by the pool. Resets the GPU Buffer pointer.
Implements IMX_PoolEntry.
|
inlineoverrideprotectedvirtual |
|
inlineoverrideprotectedvirtual |
|
inlineoverrideprotectedvirtual |
True if the swap does something.
Implements IMX_PoolEntry.
|
inlineoverridevirtual |
Implements IMX_PoolEntry.
|
static |
VDB registration to allow vdbs to be converted to integers across HOM boundaries. Registers & returns the handle, adding the handle to the registered list
bool IMX_VDB::save | ( | std::ostream & | os | ) | const |
Returns true for successful save.
bool IMX_VDB::saveJSON | ( | UT_JSONWriter & | w | ) | const |
|
inline |
|
inline |
|
inline |
Can be used to control what stealable() subsequently returns. If set to true, indicates to the verbs that this buffer may be stolen from.
|
inline |
|
inline |
|
inline |
void IMX_VDB::transform | ( | const UT_Matrix4D & | m | ) |
Transform the vdb, this REQUIRES updating the nanovdb structure so will run OpenCL.
|
inline |
|
overrideprotectedvirtual |
Queues up commands that transfer this buffer's GPU storage to main memory.
Implements IMX_PoolEntry.
|
static |
Unregister all vdbs corresponding to the provided list, erase the list afterwards. Assertion if handle wasn't regsitered
|
inline |
Updates the contents of the attributes, first making sure it is unique. The provided operator should take a reference to a UT_Options that it will update. this->update([](UT_Options &opt) { opt.setOptionS("test", "bar"); });
void IMX_VDB::updateMetadataFromOptions | ( | const UT_Options & | opt | ) |
Load ourselves from the options, ignoring fields we don't know.
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
protected |
The type of the grid so we can avoid unpacking it to find out. Note this is ALSO on the CE_VDBGrid, but that might not exist for CPU buffers so it is duplicated here.
|
protected |
|
protected |
|
protected |