51 void copy(
const IMX_VDB &other);
59 openvdb::GridBase::Ptr createVDB()
const;
62 bool save(std::ostream &os)
const;
72 void copyMetadataToOptions(
UT_Options &opt)
const;
74 void updateMetadataFromOptions(
const UT_Options &opt);
79 void copyFromVDB(
const openvdb::GridBase &vdb,
82 bool ontocpu=
true,
bool ontogppu=
true);
86 { copyFromVDB(vdb, voxelsize, indexspace,
true,
false); }
90 { copyFromVDB(vdb, voxelsize, indexspace,
false,
true); }
107 CE_VDBGrid *getGPUBuffer(
bool read,
bool write);
112 int getChannels()
const;
113 bool storesIntegers()
const;
114 static const char *cnanovdbStorageDefine(
UT_VDBType storagetype);
180 bool hasTopology()
const;
182 {
return myTopology ? myTopology->leafCount() : 0; }
184 {
return myTopology ? myTopology->lowerCount() : 0; }
186 {
return myTopology ? myTopology->upperCount() : 0; }
194 if (myTopology) myTopology->voxelBounds(lower, upper);
200 void buildTopology(
const openvdb::GridBase &grid);
203 void buildTopologyFromCPU(
bool denseleaves);
207 {
if (myTopology)
return myTopology->getGPUTileStarts(tilecount);
208 tilecount = 0;
return {}; }
210 {
if (myTopology)
return myTopology->getCPUTileStarts();
217 {
return myTopology ? myTopology->denseLeaves() :
true; }
219 {
UT_ASSERT(myTopology);
if (myTopology) myTopology->setDenseLeaves(dense); }
224 void setConstantI(
int32 i = 0);
227 bool isDirty()
const {
return !myOnGPU && !myOnCPU; }
240 bool allocated()
const {
return myCPUBuffer || myGPUBuffer; }
242 int64 getMemoryUsage()
const;
243 int64 getDeviceMemoryUsage()
const;
246 { myProperties =
props; }
248 {
return myProperties; }
254 template <
typename OP>
256 { myProperties.update(op); }
266 static void unregisterVDBs(
UT_IntArray ®istered);
277 myGPUTileStarts = tilestarts;
278 myGPUTileStartsCount = leafcount;
279 myLeafCount = leafcount;
280 myLowerCount = lowercount;
281 myUpperCount = uppercount;
283 Topology(
const openvdb::GridBase &grid);
300 int64 getMemoryUsage()
const;
301 int64 getDeviceMemoryUsage()
const;
315 bool myDenseLeaves =
false;
320 fpreal64 computeMin(
int channel = 0)
const;
321 fpreal64 computeMax(
int channel = 0)
const;
322 fpreal64 computeAverage(
int channel = 0)
const;
341 return myGPUBuffer.get() ==
nullptr;
346 return myGPUBuffer.get() && myGPUBuffer->isValid();
397 bool myOnCPU =
false;
398 bool myOnGPU =
false;
402 mutable bool myStealable =
true;
bool poolIsGPUBufferEmpty() const override
True if the gpu buffer is null.
void setDenseLeaves(bool dense)
std::string upper(string_view a)
Return an all-upper case version of a (locale-independent).
UT_SharedPtr< Topology > myTopology
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.
void gpuCopyFromVDB(const openvdb::GridBase &vdb, const UT_Vector3 &voxelsize, const GA_PrimVolumeXform &indexspace)
void setConstantF(fpreal32 f=0.0f)
UT_SharedPtr< CE_BufferHostByte > myCPUBuffer
UT_Vector3T< float > UT_Vector3
IMX_VDB & operator=(IMX_VDB &&other)
IMX_API size_t UTformatBuffer(char *buffer, size_t buffer_size, const IMX_VDB &v)
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)
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.
bool poolSwapGPUBuffer(CE_HotSwapPoolEntry *otherbase) override
True if the swap does something.
IMX_TypeInfo typeInfo() const
UT_SharedPtr< CE_VDBGrid > myGPUBuffer
void poolShallowCopyGPUBuffer(const CE_HotSwapPoolEntry *srcbase) override
Shallow copy.
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
EntryType
To avoid the need for dynamic casts:
IMX_VDB(const IMX_VDB &other)
UT_SharedPtr< UT_Array< UT_Vector3i > > myCPUTileStarts
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.
std::string lower(string_view a)
Return an all-upper case version of a (locale-independent).
UT_OptionsHolder properties() const
UT_OptionsHolder myProperties
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()
void setProperties(const UT_OptionsHolder &props)
void voxelBounds(UT_Vector3i &lower, UT_Vector3i &upper) const
UT_SharedPtr< IMX_VDB > IMX_VDBPtr
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)
virtual void unloadFromGPU()=0
void updateProperties(const OP &op)
void swap(IMX_VDB &other)
UT_Vector3 voxelSize() const
GLenum GLuint GLsizei const GLenum * props