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

Method update

3rdparty/bgfx/src/renderer_gl.cpp:5984–6102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5982 }
5983
5984 void TextureGL::update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem)
5985 {
5986 const uint32_t bpp = bimg::getBitsPerPixel(bimg::TextureFormat::Enum(m_textureFormat) );
5987 const uint32_t rectpitch = _rect.m_width*bpp/8;
5988 uint32_t srcpitch = UINT16_MAX == _pitch ? rectpitch : _pitch;
5989
5990 GL_CHECK(glBindTexture(m_target, m_id) );
5991 GL_CHECK(glPixelStorei(GL_UNPACK_ALIGNMENT, 1) );
5992
5993 GLenum target = isCubeMap()
5994 ? GL_TEXTURE_CUBE_MAP_POSITIVE_X
5995 : m_target
5996 ;
5997
5998 const bool swizzle = true
5999 && TextureFormat::BGRA8 == m_requestedFormat
6000 && !s_textureFormat[m_requestedFormat].m_supported
6001 && !s_renderGL->m_textureSwizzleSupport
6002 ;
6003 const bool unpackRowLength = !!BGFX_CONFIG_RENDERER_OPENGL || s_extension[Extension::EXT_unpack_subimage].m_supported;
6004 const bool compressed = bimg::isCompressed(bimg::TextureFormat::Enum(m_requestedFormat) );
6005 const bool convert = false
6006 || (compressed && m_textureFormat != m_requestedFormat)
6007 || swizzle
6008 ;
6009
6010 Rect rect;
6011 rect.setIntersect(_rect
6012 , {
6013 0, 0,
6014 uint16_t(bx::max(1u, m_width >> _mip) ),
6015 uint16_t(bx::max(1u, m_height >> _mip) ),
6016 });
6017
6018 uint32_t width = rect.m_width;
6019 uint32_t height = rect.m_height;
6020
6021 uint8_t* temp = NULL;
6022 if (convert
6023 || !unpackRowLength)
6024 {
6025 temp = (uint8_t*)bx::alloc(g_allocator, rectpitch*height);
6026 }
6027 else if (unpackRowLength)
6028 {
6029 GL_CHECK(glPixelStorei(GL_UNPACK_ROW_LENGTH, srcpitch*8/bpp) );
6030 }
6031
6032 if (compressed
6033 && !convert)
6034 {
6035 const uint8_t* data = _mem->data;
6036
6037 if (!unpackRowLength)
6038 {
6039 bimg::imageCopy(temp, width, height, 1, bpp, srcpitch, data);
6040 data = temp;
6041 }

Callers 5

updateTextureMethod · 0.45
blitRenderMethod · 0.45
submitMethod · 0.45

Calls 11

getBitsPerPixelFunction · 0.85
isCompressedFunction · 0.85
allocFunction · 0.85
imageCopyFunction · 0.85
compressedTexSubImageFunction · 0.85
imageDecodeToRgba8Function · 0.85
texSubImageFunction · 0.85
setIntersectMethod · 0.80
EnumEnum · 0.70
freeFunction · 0.70
maxFunction · 0.50

Tested by

no test coverage detected