MCPcopy Create free account
hub / github.com/crownengine/crown / createTexture3D

Function createTexture3D

3rdparty/bgfx/src/bgfx.cpp:4992–5034  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4990 }
4991
4992 TextureHandle createTexture3D(uint16_t _width, uint16_t _height, uint16_t _depth, bool _hasMips, TextureFormat::Enum _format, uint64_t _flags, const Memory* _mem)
4993 {
4994 bx::ErrorAssert err;
4995 isTextureValid(_width, _height, _depth, false, 1, _format, _flags, &err);
4996
4997 if (!err.isOk() )
4998 {
4999 return BGFX_INVALID_HANDLE;
5000 }
5001
5002 const uint8_t numMips = calcNumMips(_hasMips, _width, _height, _depth);
5003
5004 if (BX_ENABLED(BGFX_CONFIG_DEBUG)
5005 && NULL != _mem)
5006 {
5007 TextureInfo ti;
5008 calcTextureSize(ti, _width, _height, _depth, false, _hasMips, 1, _format);
5009 BX_ASSERT(ti.storageSize == _mem->size
5010 , "createTexture3D: Texture storage size doesn't match passed memory size (storage size: %d, memory size: %d)"
5011 , ti.storageSize
5012 , _mem->size
5013 );
5014 }
5015
5016 uint32_t size = sizeof(uint32_t)+sizeof(TextureCreate);
5017 const Memory* mem = alloc(size);
5018
5019 bx::StaticMemoryBlockWriter writer(mem->data, mem->size);
5020 bx::write(&writer, kChunkMagicTex, bx::ErrorAssert{});
5021
5022 TextureCreate tc;
5023 tc.m_width = _width;
5024 tc.m_height = _height;
5025 tc.m_depth = _depth;
5026 tc.m_numLayers = 1;
5027 tc.m_numMips = numMips;
5028 tc.m_format = _format;
5029 tc.m_cubeMap = false;
5030 tc.m_mem = _mem;
5031 bx::write(&writer, tc, bx::ErrorAssert{});
5032
5033 return s_ctx->createTexture(mem, _flags, 0, NULL, BackbufferRatio::Count, NULL != _mem);
5034 }
5035
5036 TextureHandle createTextureCube(uint16_t _size, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint64_t _flags, const Memory* _mem)
5037 {

Callers

nothing calls this directly

Calls 6

isTextureValidFunction · 0.85
calcTextureSizeFunction · 0.85
allocFunction · 0.85
calcNumMipsFunction · 0.70
writeFunction · 0.70
createTextureMethod · 0.45

Tested by

no test coverage detected