63 for (
int i = 0; i < 4; i++)
75 for (
int i = 0; i < 3; ++i)
112 return !(*
this == other);
190 void setBufferXforms(
276 int dstchannels)
const;
296 setPixelV4Internal(x, y, c,
true);
300 setPixelV4Internal(x, y,
UT_Vector4F(i, i, i, i),
true);
304 setPixelIInternal(x, y, i,
true);
327 const unsigned char*
getCPUBufferRI8()
const {
return getCPUBufferR<CE_Image::INT8>(); }
338 {
return getCPUBufferInternal(read, write, write); }
344 template <CE_Image::StorageType STORAGE>
347 return cast<STORAGE>(getCPUBufferRInternal());
357 template <CE_Image::StorageType STORAGE>
360 return cast<STORAGE>(getCPUBufferInternal(read, write, write));
393 bool isDirty()
const {
return !myOnGPU && !myOnCPU; }
398 void setDirty() { myOnGPU = myOnCPU = myIsConstant =
false; }
405 bool allocated()
const {
return myCPUBuffer || myGPUBuffer; }
431 template <
typename T>
453 return myGPUBuffer.get() ==
nullptr;
458 return myGPUBuffer.get() && myGPUBuffer->isValid();
465 if (myGPUBuffer == other->myGPUBuffer)
468 myGPUBuffer.
swap(other->myGPUBuffer);
476 myGPUBuffer = src->myGPUBuffer;
491 void *getCPUBufferInternal(
bool read,
bool write,
bool expand_constant);
492 void *getCPUBufferRInternal()
const;
498 bool expand_constant);
499 void setPixelIInternal(
int x,
int y,
int val,
bool expand_constant);
507 template <CE_Image::StorageType STORAGE>
511 UT_ASSERT(STORAGE == myCPUStat.myStorage);
514 template <CE_Image::StorageType STORAGE>
516 cast(
const void *p)
const
518 UT_ASSERT(STORAGE == myCPUStat.myStorage);
532 mutable bool myGPUStatClean =
false;
536 bool myOnCPU =
false;
537 bool myOnGPU =
false;
540 bool myIsConstant =
false;
543 bool myIsUninitialized =
false;
546 mutable bool myStealable =
true;
548 friend class IMX_CEMemoryPool;
IMX_Buffer & operator=(const IMX_Buffer &other)
void setStorageType(CE_Image::StorageType storage, int channels)
Set storesIntegers, isFixedPoint, bytes, channels.
fpreal16 * getCPUBufferWF16()
void copyBuffer(const IMX_Buffer &other)
Only copy the buffer pointers, the stat data is left unchanged.
CE_Image & getGPUBufferW()
CE_StorageTypeTraits< STORAGE >::DataType * getCPUBuffer(bool read, bool write)
static bool storesIntegers(StorageType t)
bool isAligned(const IMX_Buffer &src) const
True if the buffer pixels line up: width and the transforms from image space match.
bool operator==(const IMX_Stat &other) const
static bool isFixedPoint(StorageType t)
IMX_BorderType getBorderType() const
Returns type of the border.
const UT_SharedPtr< CE_Image > & GPUBufferPtr() const
UT_Matrix4F myCameraToWorld
void moveBuffer(IMX_Buffer &src)
Move the buffer to this from src, src is left dirty.
CEfloatD< CE_32 > myImageToBuffer[4]
const uint8 * getCPUBufferRFixed8() const
int64 getBufferSize() const
Returns the number of bytes required to store the entire buffer.
getFileOption("OpenEXR:storage") storage
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
IMX_Buffer(const IMX_Buffer &other)
void setStorageBytes(int)
UT_Vector4F getDefaultColor() const
void setTypeInfo(IMX_TypeInfo typeinfo)
Sets the semantic type info of this image.
const unsigned char * getCPUBufferRI8() const
CEfloatD< CE_32 > myBufferToImage[4]
void swap(T &lhs, T &rhs)
void destroy()
Frees all the memory used by buffer.
EntryType
To avoid the need for dynamic casts:
void setStealable(bool v) const
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
CE_Image & getGPUBuffer(bool read, bool write)
void swap(IMX_Buffer &other)
void copyOrConvert(const IMX_Buffer &other)
bool isFixedPoint() const
Does this buffer use fixed point to store non-integer data?
OIIO_FORCEINLINE vbool4 insert(const vbool4 &a, bool val)
Helper: substitute val for a[i].
void * getCPUBuffer(bool read, bool write)
int16 * getCPUBufferWI16()
void freeBuffers()
Frees the pixel memory (also does setDirty())
void setPixelF(int x, int y, fpreal32 i)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
void setConstantI(int32 i=0)
OIIO_FORCEINLINE bool extract(const vbool4 &a)
CE_Image::StorageType getStorageType() const
Get the data type used to store pixel data for each channel.
void copyMetadata(const IMX_Layer &a)
void setChannels(int channels)
Set channels, don't change storesIntegers, isFixedPoint, or bytes.
UT_Matrix4F myWorldToImage
GLint GLsizei GLsizei height
void setBorder(IMX_BorderType border)
Sets the border type of this image. Constant means it is zero.
UT_UniquePtr< TIL_Raster > buildRaster() const
SYS_FORCE_INLINE const X * cast(const InstancablePtr *o)
fpreal32 * getCPUBufferWF32()
void matchAndCopyToVoxels(UT_VoxelArray< T > &dest) const
int getPixelI(int x, int y) const
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
IMX_Buffer & operator=(IMX_Buffer &&other)
IMX_Projection statProjection() const
Returns the projection type.
void setPixelV4(int x, int y, const UT_Vector4F &c)
Sets an individual pixel.
int64 getDeviceMemoryUsage() const
void poolSetOnGPU(bool ongpu) override
Update OnGPU.
bool validateBuffer() const
bool poolIsGPUBufferEmpty() const override
True if the gpu buffer is null.
CEintD< CE_32 > myResolution[2]
IMX_Projection myProjection
bool poolSwapGPUBuffer(IMX_PoolEntry *otherbase) override
True if the swap does something.
GLsizei GLsizei GLchar * source
UT_Vector4I getDefaultColorI() const
return the current integer value, which might be different
IMX_Buffer()
Creates a new buffer. You must call setSize to make this buffer usable.
int getChannels() const
Get the number of channels per pixel.
virtual void unloadFromGPU()=0
HUSD_API const char * raster()
IMX_API const char * COPgetBorderTypeString(const IMX_BorderType &border)
Returns the label for the supplied border type.
int16 * getCPUBufferWFixed16()
exint bufferHeight() const
Get height (number of rows) of the buffer.
uint8 * getCPUBufferWFixed8()
const int32 * getCPUBufferRI32() const
const CE_Image & getGPUBufferR() const
bool isDirty() const
False if there are computed pixels in the CPU or GPU buffer.
IMX_TypeInfo getTypeInfo() const
Returns the semantic type.
const fpreal32 * getCPUBufferRF32() const
const UT_SharedPtr< CE_BufferHostByte > & CPUBufferPtr() const
for debugging
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 getPixelRaw(UT_Array< uint8 > &dest, int x, int y) const
void copyStorageType(const IMX_Buffer &i)
Set storesIntegers, isFixedPoint, bytes, channels.
void poolShallowCopyGPUBuffer(const IMX_PoolEntry *srcbase) override
Shallow copy.
void * getCPUBufferR() const
A map of string to various well defined value types.
const fpreal16 * getCPUBufferRF16() const
GLint GLint GLsizei GLint border
UT_Vector4T< fpreal32 > UT_Vector4F
const CE_StorageTypeTraits< STORAGE >::DataType * getCPUBufferR() const
cl::Buffer getGPUStat() const
IMX_BorderType
Controls returned values for coordinates that fall outside the image.
bool operator!=(const IMX_Stat &other) const
exint bufferWidth() const
Get width (number of columns in a row) of the buffer.
void updateFromOptions(const UT_Options &opt)
Load ourselves from the options, ignoring fields we don't know.
const int16 * getCPUBufferRFixed16() const
int getStorageBytes() const
Number of bytes per channel.
bool allocated() const
True if getCPU/GPUBuffer has been done since last freeBuffers()
UT_Vector4F getPixelV4(int x, int y) const
Fetches the value of an individual pixel.
void copyToOptions(UT_Options &opt) const
Write our fields into the provided options:
static int getBytes(StorageType t)
UT_Matrix4F myImageToWorld
void setBufferSize(int w, int h)
typename CE_PrecisionResolver< P >::device_float_type CEfloatD
bool storesIntegers() const
Does this buffer store integers?
int32 * getCPUBufferWI32()
IMX_API CE_Image::StorageType IMXgetStorageTypeFromRaster(const PXL_Raster &rp)
IMX_Projection projection() const
Camera.
void setPixelI(int x, int y, int i)
CEfloatD< CE_32 > myBufferToPixel[4]
void adoptRaster(PXL_Raster &raster, bool convert_colorspace)
void setConstantV4(const UT_Vector4F &i)
CEfloatD< CE_32 > myCameraImagePos[4]
EntryType poolTypeID() const override
IMX_Buffer(IMX_Buffer &&other) noexcept
unsigned char * getCPUBufferWI8()
void setDefaultColor(const UT_Vector4F &)
CEfloatD< CE_32 > myDefaultFColor[4]
int64 getMemoryUsage() const
void setStatProjection(IMX_Projection projection)
const int16 * getCPUBufferRI16() const
bool poolIsGPUBufferValid() const override
True if the gpu buffer is not null and valid.
CEintD< CE_32 > myDefaultIColor[4]
void poolResetGPUBuffer() override
These implement methods required by the pool.
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
void deepCopy(const IMX_Buffer &other)
CE_Image::StorageType myStorage