58 openvdb::GridBase::Ptr createVDB()
const;
61 bool save(std::ostream &os)
const;
71 void copyMetadataToOptions(
UT_Options &opt)
const;
73 void updateMetadataFromOptions(
const UT_Options &opt);
78 void copyFromVDB(
const openvdb::GridBase &vdb,
81 bool ontocpu=
true,
bool ontogppu=
true);
85 { copyFromVDB(vdb, voxelsize, indexspace,
true,
false); }
89 { copyFromVDB(vdb, voxelsize, indexspace,
false,
true); }
106 CE_VDBGrid *getGPUBuffer(
bool read,
bool write);
111 int getChannels()
const;
112 static const char *cnanovdbStorageDefine(
UT_VDBType storagetype);
174 bool hasTopology()
const;
176 {
return myTopology ? myTopology->leafCount() : 0; }
178 {
return myTopology ? myTopology->lowerCount() : 0; }
180 {
return myTopology ? myTopology->upperCount() : 0; }
185 void buildTopology(
const openvdb::GridBase &grid);
188 void buildTopologyFromCPU(
bool denseleaves);
192 {
if (myTopology)
return myTopology->getGPUTileStarts(tilecount);
193 tilecount = 0;
return {}; }
195 {
if (myTopology)
return myTopology->getCPUTileStarts();
202 {
return myTopology ? myTopology->denseLeaves() :
true; }
204 {
UT_ASSERT(myTopology);
if (myTopology) myTopology->setDenseLeaves(dense); }
207 bool isDirty()
const {
return !myOnGPU && !myOnCPU; }
220 bool allocated()
const {
return myCPUBuffer || myGPUBuffer; }
222 int64 getMemoryUsage()
const;
223 int64 getDeviceMemoryUsage()
const;
226 { myAttributes = attrib; }
228 {
return myAttributes; }
234 template <
typename OP>
236 { myAttributes.update(op); }
246 static void unregisterVDBs(
UT_IntArray ®istered);
257 myGPUTileStarts = tilestarts;
258 myGPUTileStartsCount = leafcount;
259 myLeafCount = leafcount;
260 myLowerCount = lowercount;
261 myUpperCount = uppercount;
263 Topology(
const openvdb::GridBase &grid);
278 int64 getMemoryUsage()
const;
279 int64 getDeviceMemoryUsage()
const;
293 bool myDenseLeaves =
false;
311 return myGPUBuffer.get() ==
nullptr;
316 return myGPUBuffer.get() && myGPUBuffer->isValid();
367 bool myOnCPU =
false;
368 bool myOnGPU =
false;
372 mutable bool myStealable =
true;
bool poolIsGPUBufferEmpty() const override
True if the gpu buffer is null.
void setDenseLeaves(bool dense)
void setAttributes(const UT_OptionsHolder &attrib)
UT_SharedPtr< Topology > myTopology
UT_OptionsHolder attributes() const
void setDenseLeaves(bool isdense)
void cpuCopyFromVDB(const openvdb::GridBase &vdb, const UT_Vector3 &voxelsize, const GA_PrimVolumeXform &indexspace)
void poolResetGPUBuffer() override
GA_PrimVolumeXform indexSpace() const
getFileOption("OpenEXR:storage") storage
bool isDirty() const
True if there are no VDB grids on GPU or CPU.
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
void gpuCopyFromVDB(const openvdb::GridBase &vdb, const UT_Vector3 &voxelsize, const GA_PrimVolumeXform &indexspace)
UT_SharedPtr< CE_BufferHostByte > myCPUBuffer
IMX_VDB & operator=(IMX_VDB &&other)
Topology(cl::Buffer tilestarts, exint leafcount, exint lowercount, exint uppercount)
bool poolIsGPUBufferValid() const override
True if the gpu buffer is not null and valid.
void swap(T &lhs, T &rhs)
EntryType
To avoid the need for dynamic casts:
JSON reader class which handles parsing of JSON or bJSON files.
Class which writes ASCII or binary JSON streams.
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
bool isOnGPU() const
Returns true if this vdb's data is currently on the GPU.
UT_OptionsHolder myAttributes
IMX_TypeInfo typeInfo() const
UT_SharedPtr< CE_VDBGrid > myGPUBuffer
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
void setStealable(bool v) const
void poolSetOnGPU(bool ongpu) override
Update OnGPU.
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
UT_VDBType storageType() const
IMX_VDB(IMX_VDB &&other) noexcept
UT_SharedPtr< const IMX_VDB > IMX_VDBConstPtr
IMX_VDB(const IMX_VDB &other)
UT_SharedPtr< UT_Array< UT_Vector3i > > myCPUTileStarts
virtual void unloadFromGPU()=0
IMX_VDB & operator=(const IMX_VDB &other)
GA_API const UT_StringHolder transform
GA_PrimVolumeXform myIndexSpace
UT_Vector3 origin() const
A map of string to various well defined value types.
EntryType poolTypeID() const override
void setDirty()
Flag all grids as dirty without freeing them.
void poolShallowCopyGPUBuffer(const IMX_PoolEntry *srcbase) override
Shallow copy.
cl::Buffer getGPUTileStarts(exint &tilecount) const
Return a gpu version.
cl::Buffer myGPUTileStarts
Tile starts is a shared buffer, so isn't re-written to.
GLubyte GLubyte GLubyte GLubyte w
CE_VDBGrid * getGPUBufferW()
bool poolSwapGPUBuffer(IMX_PoolEntry *otherbase) override
True if the swap does something.
IMX_API size_t format(char *buffer, size_t buffer_size, const IMX_VDB &v)
UT_SharedPtr< IMX_VDB > IMX_VDBPtr
void updateAttributes(const OP &op)
bool isAligned(const IMX_VDB *vdb) const
True if the two vdbs map the same indices to the same positions.
UT_SharedPtr< UT_Array< UT_Vector3i > > getCPUTileStarts() const
void setTypeInfo(IMX_TypeInfo typeinfo)
void swap(IMX_VDB &other)
UT_Vector3 voxelSize() const