16 unsigned int numDimensions,
unsigned int dim0,
unsigned int dim1,
17 unsigned int dim2,
bool hasMipmaps,
bool createStorage)
19 Resource(GetTotalElements(numItems, dim0, dim1, dim2, hasMipmaps),
20 DataFormat::GetNumBytesPerStruct(format), createStorage),
23 mNumDimensions(numDimensions),
26 mHasMipmaps(hasMipmaps),
27 mAutogenerateMipmaps(false)
31 if (mNumDimensions < 1 || mNumDimensions > 3)
33 LogError(
"Invalid number of dimensions.");
46 for (
unsigned int item = 0; item <
mNumItems; ++item)
65 mNumLevels = 1 + std::max(log0, std::max(log1, log2));
68 if (dim0 > 1) { dim0 >>= 1; }
69 if (dim1 > 1) { dim1 >>= 1; }
70 if (dim2 > 1) { dim2 >>= 1; }
78 unsigned int numBytes = 0;
79 for (
unsigned int item = 0; item <
mNumItems; ++item)
90 for (
unsigned int item = 1; item <
mNumItems; ++item)
143 unsigned int dim0,
unsigned int dim1,
unsigned int dim2,
bool hasMipmaps)
145 unsigned int numElementsPerItem = dim0 * dim1 * dim2;
151 unsigned int numLevels = 1 + std::max(log0, std::max(log1, log2));
154 if (dim0 > 1) { dim0 >>= 1; }
155 if (dim1 > 1) { dim1 >>= 1; }
156 if (dim2 > 1) { dim2 >>= 1; }
158 numElementsPerItem += dim0*dim1*dim2;
161 return numItems*numElementsPerItem;
std::array< unsigned int, MAX_MIPMAP_LEVELS > mLNumBytes
unsigned int GetIndex(unsigned int item, unsigned int level) const
unsigned int mNumDimensions
bool mAutogenerateMipmaps
GTE_IMPEXP uint32_t RoundDownToPowerOfTwo(uint32_t value)
Texture(unsigned int numItems, DFType format, unsigned int numDimensions, unsigned int dim0, unsigned int dim1, unsigned int dim2, bool hasMipmaps, bool createStorage)
std::vector< std::array< unsigned int, MAX_MIPMAP_LEVELS > > mLOffset
char const * GetDataFor(unsigned int item, unsigned int level) const
unsigned int mElementSize
#define LogError(message)
GLint GLint GLsizei GLint GLenum format
static unsigned int GetTotalElements(unsigned int numItems, unsigned int dim0, unsigned int dim1, unsigned int dim2, bool hasMipmaps)
Subresource GetSubresource(unsigned int index) const
GTE_IMPEXP uint32_t Log2OfPowerOfTwo(uint32_t powerOfTwo)
void AutogenerateMipmaps()
unsigned int GetNumSubresources() const
std::array< std::array< unsigned int, 3 >, MAX_MIPMAP_LEVELS > mLDimension