MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / imageGetSize

Function imageGetSize

Source/3rdParty/bimg/src/image.cpp:319–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317 }
318
319 uint32_t imageGetSize(TextureInfo* _info, uint16_t _width, uint16_t _height, uint16_t _depth, bool _cubeMap, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format)
320 {
321 const ImageBlockInfo& blockInfo = getBlockInfo(_format);
322 const uint8_t bpp = blockInfo.bitsPerPixel;
323 const uint16_t blockWidth = blockInfo.blockWidth;
324 const uint16_t blockHeight = blockInfo.blockHeight;
325 const uint16_t minBlockX = blockInfo.minBlockX;
326 const uint16_t minBlockY = blockInfo.minBlockY;
327 const uint8_t blockSize = blockInfo.blockSize;
328
329 _width = bx::max<uint16_t>(blockWidth * minBlockX, ( (_width + blockWidth - 1) / blockWidth)*blockWidth);
330 _height = bx::max<uint16_t>(blockHeight * minBlockY, ( (_height + blockHeight - 1) / blockHeight)*blockHeight);
331 _depth = bx::max<uint16_t>(1, _depth);
332 const uint8_t numMips = calcNumMips(_hasMips, _width, _height, _depth);
333 const uint32_t sides = _cubeMap ? 6 : 1;
334
335 uint32_t width = _width;
336 uint32_t height = _height;
337 uint32_t depth = _depth;
338 uint32_t size = 0;
339
340 for (uint32_t lod = 0; lod < numMips; ++lod)
341 {
342 width = bx::max<uint32_t>(blockWidth * minBlockX, ( (width + blockWidth - 1) / blockWidth )*blockWidth);
343 height = bx::max<uint32_t>(blockHeight * minBlockY, ( (height + blockHeight - 1) / blockHeight)*blockHeight);
344 depth = bx::max<uint32_t>(1, depth);
345
346 size += uint32_t(uint64_t(width/blockWidth * height/blockHeight * depth)*blockSize * sides);
347
348 width >>= 1;
349 height >>= 1;
350 depth >>= 1;
351 }
352
353 size *= _numLayers;
354
355 if (NULL != _info)
356 {
357 _info->format = _format;
358 _info->width = _width;
359 _info->height = _height;
360 _info->depth = _depth;
361 _info->numMips = numMips;
362 _info->numLayers = _numLayers;
363 _info->cubeMap = _cubeMap;
364 _info->storageSize = size;
365 _info->bitsPerPixel = bpp;
366 }
367
368 return size;
369 }
370
371 BX_NO_INLINE void imageSolid(void* _dst, uint32_t _width, uint32_t _height, uint32_t _solid)
372 {

Callers 9

imageAllocFunction · 0.85
imageDecodeToR8Function · 0.85
imageDecodeToRgba8Function · 0.85
imageDecodeToRgba32fFunction · 0.85
createMethod · 0.85
calcTextureSizeFunction · 0.85
createMethod · 0.85
createMethod · 0.85
createMethod · 0.85

Calls 1

calcNumMipsFunction · 0.70

Tested by

no test coverage detected