diff options
author | Michael Brasser <michael.brasser@live.com> | 2019-09-28 21:31:19 -0500 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2019-10-17 08:21:48 -0500 |
commit | 5001f79c4f98e22d9a301ae6519a67d1135f7312 (patch) | |
tree | 8faaa311c7d094feea13320db6720f8d6fd3b630 /src | |
parent | 0c1716e9f61631c67f34bb429611a34c287308ec (diff) |
Support DXT1/3/5 in compressed texture atlasv5.14.0-beta2
Change-Id: I791adbfce96481aea71bb285e48b89cb5db08e1c
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src')
-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(); |