summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuan Casafranca <juan.casafranca@kdab.com>2020-09-25 12:55:37 +0200
committerJuan José Casafranca <juan.casafranca@kdab.com>2020-09-28 11:12:28 +0200
commit1f9162bcd4fc6a3bc90ebcc04e609046e9d191d2 (patch)
tree42c9618c87eb8fe24f1cff9c8eb918a374136ed5
parent5e394262506c30c02b0e4929b2f9d99acbd1e7cd (diff)
Allow to set alignment requirement for an image
Change-Id: Ifffbfd80a3d99b43e348e12bea62e3c90eed80c4 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/plugins/renderers/opengl/textures/gltexture.cpp13
-rw-r--r--src/render/texture/qtextureimagedata.cpp2
-rw-r--r--src/render/texture/qtextureimagedata_p.h1
3 files changed, 10 insertions, 6 deletions
diff --git a/src/plugins/renderers/opengl/textures/gltexture.cpp b/src/plugins/renderers/opengl/textures/gltexture.cpp
index 30247a719..574db94f0 100644
--- a/src/plugins/renderers/opengl/textures/gltexture.cpp
+++ b/src/plugins/renderers/opengl/textures/gltexture.cpp
@@ -76,13 +76,13 @@ void uploadGLData(QOpenGLTexture *glTex,
int level, int layer, QOpenGLTexture::CubeMapFace face,
const QByteArray &bytes, const QTextureImageDataPtr &data)
{
- if (data->isCompressed()) {
+ const auto alignment = QTextureImageDataPrivate::get(data.get())->m_alignment;
+ QOpenGLPixelTransferOptions uploadOptions;
+ uploadOptions.setAlignment(alignment);
+ if (data->isCompressed())
glTex->setCompressedData(level, layer, face, bytes.size(), bytes.constData());
- } else {
- QOpenGLPixelTransferOptions uploadOptions;
- uploadOptions.setAlignment(1);
+ else
glTex->setData(level, layer, face, data->pixelFormat(), data->pixelType(), bytes.constData(), &uploadOptions);
- }
}
// For partial sub image uploads
@@ -94,8 +94,9 @@ void uploadGLData(QOpenGLTexture *glTex,
if (data->isCompressed()) {
qWarning() << Q_FUNC_INFO << "Uploading non full sized Compressed Data not supported yet";
} else {
+ const auto alignment = QTextureImageDataPrivate::get(data.get())->m_alignment;
QOpenGLPixelTransferOptions uploadOptions;
- uploadOptions.setAlignment(1);
+ uploadOptions.setAlignment(alignment);
glTex->setData(xOffset, yOffset, zOffset,
data->width(), data->height(), data->depth(),
mipLevel, layer, cubeFace, data->layers(),
diff --git a/src/render/texture/qtextureimagedata.cpp b/src/render/texture/qtextureimagedata.cpp
index 28d296feb..50a52d90f 100644
--- a/src/render/texture/qtextureimagedata.cpp
+++ b/src/render/texture/qtextureimagedata.cpp
@@ -54,6 +54,7 @@ QTextureImageDataPrivate::QTextureImageDataPrivate()
, m_faces(-1)
, m_mipLevels(-1)
, m_blockSize(-1)
+ , m_alignment(1)
, m_target(QOpenGLTexture::Target2D)
, m_format(QOpenGLTexture::NoFormat)
, m_pixelFormat(QOpenGLTexture::RGBA)
@@ -188,6 +189,7 @@ void QTextureImageData::cleanup() Q_DECL_NOTHROW
d->m_faces = -1;
d->m_mipLevels = -1;
d->m_blockSize = 0;
+ d->m_alignment = 1;
d->m_isCompressed = false;
d->m_data.clear();
}
diff --git a/src/render/texture/qtextureimagedata_p.h b/src/render/texture/qtextureimagedata_p.h
index 14095e2eb..ee12d3387 100644
--- a/src/render/texture/qtextureimagedata_p.h
+++ b/src/render/texture/qtextureimagedata_p.h
@@ -76,6 +76,7 @@ public:
int m_faces;
int m_mipLevels;
int m_blockSize;
+ int m_alignment;
QOpenGLTexture::Target m_target;
QOpenGLTexture::TextureFormat m_format;