77 for (
int i = 0; i < 4; i++)
116 return !(*
this == other);
134 , myStorageMode(StorageMode::STORE_ALIGNED)
142 memcpy(myData, other.myData, other.myDataSize);
146 : myData(other.myData)
147 , myDataSize(other.myDataSize)
148 , myStorageMode(other.myStorageMode)
150 other.myData =
nullptr;
151 other.myDataSize = 0;
159 memcpy(myData, other.myData, other.myDataSize);
167 myData = (
uint8*)data;
176 myData = (
uint8*)data;
185 myData = (
uint8*)data;
198 void *
data()
const {
return myData; }
203 const int ALIGNMENT = 64;
205 enum class StorageMode
218 switch (myStorageMode)
224 default:
UT_ASSERT(0 &&
"Unknown storage mode");
232 uint8 *myData =
nullptr;
233 exint myDataSize = 0;
257 friend class COP_OpenFXImage;
281 void setStorageBytes(
int);
300 int64 getBufferSize()
const;
303 void setBufferXforms(
360 void makeBufferUnique();
385 setPixelV4Internal(x, y, c,
true);
389 setPixelV4Internal(x, y,
UT_Vector4F(i, i, i, i),
true);
393 setPixelIInternal(x, y, i,
true);
398 int getPixelI(
int x,
int y)
const;
410 const unsigned char*
getCPUBufferRI8()
const {
return getCPUBufferR<CE_Image::INT8>(); }
421 {
return getCPUBufferInternal(read, write, write); }
425 template <CE_Image::StorageType STORAGE>
428 return cast<STORAGE>(getCPUBufferRInternal());
438 template <CE_Image::StorageType STORAGE>
441 return cast<STORAGE>(getCPUBufferInternal(read, write, write));
452 CE_Image &getGPUBuffer(
bool read,
bool write);
453 const CE_Image &getGPUBufferR()
const;
473 return myGPUInUseCount.relaxedLoad() != 0;
489 myGPUInUseCount.add(1);
496 void clearInUseGPUFlag()
const;
503 bool isDirty()
const {
return !myOnGPU && !myOnCPU; }
505 void setDirty() { myOnGPU = myOnCPU = myIsConstant =
false; }
511 bool allocated()
const {
return myCPUBuffer || myGPUBuffer; }
518 void setConstantI(
int32 i = 0);
535 template <
typename T>
545 void *getCPUBufferInternal(
bool read,
bool write,
bool expand_constant);
546 void *getCPUBufferRInternal()
const;
547 void *getCPUBufferW()
549 return getCPUBufferInternal(
false,
true,
true);
555 bool expand_constant);
556 void setPixelIInternal(
int x,
int y,
int val,
bool expand_constant);
560 void unloadFromGPU();
564 template <CE_Image::StorageType STORAGE>
568 UT_ASSERT(STORAGE == myCPUStat.myStorage);
571 template <CE_Image::StorageType STORAGE>
573 cast(
const void *p)
const
575 UT_ASSERT(STORAGE == myCPUStat.myStorage);
588 mutable bool myGPUStatClean =
false;
592 bool myOnCPU =
false;
593 bool myOnGPU =
false;
599 bool myIsConstant =
false;
602 bool myIsUninitialized =
false;
605 mutable bool myStealable =
true;
607 friend class IMX_CEMemoryPool;
IMX_Buffer & operator=(const IMX_Buffer &other)
fpreal16 * getCPUBufferWF16()
CE_Image & getGPUBufferW()
CE_StorageTypeTraits< STORAGE >::DataType * getCPUBuffer(bool read, bool write)
static bool storesIntegers(StorageType t)
bool operator==(const IMX_Stat &other) const
const UT_SharedPtr< CE_Image > & GPUBufferPtr() const
CEfloatD< CE_32 > myImageToBuffer[4]
getFileOption("OpenEXR:storage") storage
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
IMX_Buffer(const IMX_Buffer &other)
const unsigned char * getCPUBufferRI8() const
CEfloatD< CE_32 > myBufferToImage[4]
void swap(T &lhs, T &rhs)
void * SYSamalloc(size_t b)
void setStealable(bool v) const
void adoptFromMalloc(void *data, const exint size)
void * getCPUBuffer(bool read, bool write)
int16 * getCPUBufferWI16()
IMX_CPU_Image(const IMX_CPU_Image &other)
void setPixelF(int x, int y, fpreal32 i)
IMX_CPU_Image & operator=(const IMX_CPU_Image &other)
IMX_API size_t format(char *buffer, size_t buffer_size, const IMX_BorderType &v)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
int bufferHeight() const
Get height (number of rows) of the buffer.
CE_Image::StorageType getStorageType() const
Get the data type used to store pixel data for each channel.
UT_Matrix4F myWorldToImage
GLint GLsizei GLsizei height
IMX_BorderType
Controls returned values for coordinates that fall outside the image.
SYS_FORCE_INLINE const X * cast(const InstancablePtr *o)
void setDirty()
Turn on isDirty(). It is turned off by getCPU/GPUBuffer with write=true.
fpreal32 * getCPUBufferWF32()
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
IMX_Buffer & operator=(IMX_Buffer &&other)
void setPixelV4(int x, int y, const UT_Vector4F &c)
Sets an individual pixel.
void adoptFromAlignedMalloc(void *data, const exint size)
CEintD< CE_32 > myResolution[2]
GLsizei GLsizei GLchar * source
exint size() const
The size of the buffer data in bytes.
int getChannels() const
Get the number of channels per pixel.
HUSD_API const char * raster()
IMX_API const char * COPgetBorderTypeString(const IMX_BorderType &border)
Returns the label for the supplied border type.
const int32 * getCPUBufferRI32() const
IMX_CPU_Image(IMX_CPU_Image &&other) noexcept
bool isDirty() const
False if there are computed pixels in the CPU or GPU buffer.
const fpreal32 * getCPUBufferRF32() const
void setConstantV3(const UT_Vector3F &i)
bool isOnGPU() const
Returns true if this buffer's data is currently on the GPU.
void setConstantF(fpreal32 i=0.0f)
void copyStorageType(const IMX_Buffer &i)
Set storesIntegers, bytes, channels.
const UT_SharedPtr< IMX_CPU_Image > & CPUBufferPtr() const
for debugging
const fpreal16 * getCPUBufferRF16() const
GLint GLint GLsizei GLint border
UT_Vector4T< fpreal32 > UT_Vector4F
void adoptFromNew(void *data, const exint size)
const CE_StorageTypeTraits< STORAGE >::DataType * getCPUBufferR() const
IMX_CPU_Image(const exint size)
void setInUseGPUFlag() const
bool operator!=(const IMX_Stat &other) const
int getStorageBytes() const
Number of bytes per channel.
bool allocated() const
True if getCPU/GPUBuffer has been done since last freeBuffers()
static int getBytes(StorageType t)
int bufferWidth() const
Get width (number of columns in a row) of the buffer.
UT_Matrix4F myImageToWorld
typename CE_PrecisionResolver< P >::device_float_type CEfloatD
bool storesIntegers() const
Does this buffer store integers?
int32 * getCPUBufferWI32()
void setPixelI(int x, int y, int i)
CEfloatD< CE_32 > myBufferToPixel[4]
IMX_Buffer(IMX_Buffer &&other) noexcept
unsigned char * getCPUBufferWI8()
CEfloatD< CE_32 > myDefaultFColor[4]
const int16 * getCPUBufferRI16() const
CEintD< CE_32 > myDefaultIColor[4]
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
typename CE_PrecisionResolver< P >::device_int_type CEintD
CE_Image::StorageType myStorage