diff options
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp | 12 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgopenglatlastexture.cpp | 12 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp index d3dc4978f2..46b2c6386c 100644 --- a/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp +++ b/src/quick/scenegraph/compressedtexture/qsgcompressedatlastexture.cpp @@ -88,10 +88,20 @@ Texture *Atlas::create(const QByteArray &data, int dataLength, int dataOffset, c void Atlas::generateTexture() { + int bytesPerBlock = 8; + switch (m_format) { + case QOpenGLTexture::RGBA8_ETC2_EAC: + case QOpenGLTexture::RGBA_DXT3: + case QOpenGLTexture::RGBA_DXT5: + bytesPerBlock = 16; + default: + break; + } + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); funcs->glCompressedTexImage2D(GL_TEXTURE_2D, 0, m_format, m_size.width(), m_size.height(), 0, - (m_size.width() * m_size.height()) / 2, + (m_size.width() / 4 * m_size.height() / 4) * bytesPerBlock, nullptr); } diff --git a/src/quick/scenegraph/util/qsgopenglatlastexture.cpp b/src/quick/scenegraph/util/qsgopenglatlastexture.cpp index ae7d9cf8cc..75a874424a 100644 --- a/src/quick/scenegraph/util/qsgopenglatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgopenglatlastexture.cpp @@ -150,6 +150,10 @@ QSGTexture *Manager::create(const QSGCompressedTextureFactory *factory) case QOpenGLTexture::RGB8_ETC2: case QOpenGLTexture::RGBA8_ETC2_EAC: case QOpenGLTexture::RGB8_PunchThrough_Alpha1_ETC2: + case QOpenGLTexture::RGB_DXT1: + case QOpenGLTexture::RGBA_DXT1: + case QOpenGLTexture::RGBA_DXT3: + case QOpenGLTexture::RGBA_DXT5: break; default: return t; @@ -158,8 +162,12 @@ QSGTexture *Manager::create(const QSGCompressedTextureFactory *factory) QSize size = factory->m_textureData.size(); if (size.width() < m_atlas_size_limit && size.height() < m_atlas_size_limit) { QHash<unsigned int, QSGCompressedAtlasTexture::Atlas*>::iterator i = m_atlases.find(format); - if (i == m_atlases.end()) - i = m_atlases.insert(format, new QSGCompressedAtlasTexture::Atlas(m_atlas_size, format)); + if (i == m_atlases.end()) { + // must be multiple of 4 + QSize paddedSize(((m_atlas_size.width() + 3) / 4) * 4, ((m_atlas_size.height() + 3) / 4) * 4); + i = m_atlases.insert(format, new QSGCompressedAtlasTexture::Atlas(paddedSize, format)); + } + // must be multiple of 4 QSize paddedSize(((size.width() + 3) / 4) * 4, ((size.height() + 3) / 4) * 4); QByteArray data = factory->m_textureData.data(); |