summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopengltexture.cpp
diff options
context:
space:
mode:
authorBogDan Vatra <bogdan@kdab.com>2016-12-06 11:12:27 +0200
committerBogDan Vatra <bogdan@kdab.com>2017-01-04 15:03:59 +0000
commitd90c234bac556a650a337b91141936124e9ebc03 (patch)
tree8cf711fd75b23f882da0c7e6a60ca51e027adc43 /src/gui/opengl/qopengltexture.cpp
parent80fa5f6e76acf3e2850cac51f91dbfbd96092b72 (diff)
Add new APIs which is useful to upload more than one layer at once
It's useful to upload textures storred in .KTX files without dividing the layers. It's also more efficient than uploading layer by layer. Change-Id: I92d93c57514e2a3637d1202cb83bd72b8d277edf Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/gui/opengl/qopengltexture.cpp')
-rw-r--r--src/gui/opengl/qopengltexture.cpp90
1 files changed, 66 insertions, 24 deletions
diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp
index c9b08f60b1..3696378bd1 100644
--- a/src/gui/opengl/qopengltexture.cpp
+++ b/src/gui/opengl/qopengltexture.cpp
@@ -1351,7 +1351,7 @@ void QOpenGLTexturePrivate::allocateImmutableStorage()
storageAllocated = true;
}
-void QOpenGLTexturePrivate::setData(int mipLevel, int layer, QOpenGLTexture::CubeMapFace cubeFace,
+void QOpenGLTexturePrivate::setData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace,
QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType,
const void *data, const QOpenGLPixelTransferOptions * const options)
{
@@ -1359,6 +1359,7 @@ void QOpenGLTexturePrivate::setData(int mipLevel, int layer, QOpenGLTexture::Cub
case QOpenGLTexture::Target1D:
Q_UNUSED(layer);
Q_UNUSED(cubeFace);
+ Q_UNUSED(layerCount);
texFuncs->glTextureSubImage1D(textureId, target, bindingTarget, mipLevel,
0, mipLevelSize( mipLevel, dimensions[0] ),
sourceFormat, sourceType, data, options);
@@ -1369,13 +1370,14 @@ void QOpenGLTexturePrivate::setData(int mipLevel, int layer, QOpenGLTexture::Cub
texFuncs->glTextureSubImage2D(textureId, target, bindingTarget, mipLevel,
0, layer,
mipLevelSize(mipLevel, dimensions[0]),
- 1,
+ layerCount,
sourceFormat, sourceType, data, options);
break;
case QOpenGLTexture::Target2D:
Q_UNUSED(layer);
Q_UNUSED(cubeFace);
+ Q_UNUSED(layerCount);
texFuncs->glTextureSubImage2D(textureId, target, bindingTarget, mipLevel,
0, 0,
mipLevelSize(mipLevel, dimensions[0]),
@@ -1389,12 +1391,13 @@ void QOpenGLTexturePrivate::setData(int mipLevel, int layer, QOpenGLTexture::Cub
0, 0, layer,
mipLevelSize(mipLevel, dimensions[0]),
mipLevelSize(mipLevel, dimensions[1]),
- 1,
+ layerCount,
sourceFormat, sourceType, data, options);
break;
case QOpenGLTexture::Target3D:
Q_UNUSED(cubeFace);
+ Q_UNUSED(layerCount);
texFuncs->glTextureSubImage3D(textureId, target, bindingTarget, mipLevel,
0, 0, layer,
mipLevelSize(mipLevel, dimensions[0]),
@@ -1405,6 +1408,7 @@ void QOpenGLTexturePrivate::setData(int mipLevel, int layer, QOpenGLTexture::Cub
case QOpenGLTexture::TargetCubeMap:
Q_UNUSED(layer);
+ Q_UNUSED(layerCount);
texFuncs->glTextureSubImage2D(textureId, cubeFace, bindingTarget, mipLevel,
0, 0,
mipLevelSize(mipLevel, dimensions[0]),
@@ -1419,7 +1423,7 @@ void QOpenGLTexturePrivate::setData(int mipLevel, int layer, QOpenGLTexture::Cub
0, 0, layerFace,
mipLevelSize(mipLevel, dimensions[0]),
mipLevelSize(mipLevel, dimensions[1]),
- 1,
+ layerCount,
sourceFormat, sourceType, data, options);
break;
}
@@ -1428,6 +1432,7 @@ void QOpenGLTexturePrivate::setData(int mipLevel, int layer, QOpenGLTexture::Cub
Q_UNUSED(mipLevel);
Q_UNUSED(layer);
Q_UNUSED(cubeFace);
+ Q_UNUSED(layerCount);
texFuncs->glTextureSubImage2D(textureId, target, bindingTarget, 0,
0, 0,
dimensions[0],
@@ -1450,7 +1455,8 @@ void QOpenGLTexturePrivate::setData(int mipLevel, int layer, QOpenGLTexture::Cub
}
}
-void QOpenGLTexturePrivate::setCompressedData(int mipLevel, int layer, QOpenGLTexture::CubeMapFace cubeFace,
+void QOpenGLTexturePrivate::setCompressedData(int mipLevel, int layer, int layerCount,
+ QOpenGLTexture::CubeMapFace cubeFace,
int dataSize, const void *data,
const QOpenGLPixelTransferOptions * const options)
{
@@ -1465,6 +1471,7 @@ void QOpenGLTexturePrivate::setCompressedData(int mipLevel, int layer, QOpenGLTe
case QOpenGLTexture::Target1D:
Q_UNUSED(layer);
Q_UNUSED(cubeFace);
+ Q_UNUSED(layerCount);
if (needsFullSpec) {
texFuncs->glCompressedTextureImage1D(textureId, target, bindingTarget, mipLevel,
format,
@@ -1483,7 +1490,7 @@ void QOpenGLTexturePrivate::setCompressedData(int mipLevel, int layer, QOpenGLTe
texFuncs->glCompressedTextureSubImage2D(textureId, target, bindingTarget, mipLevel,
0, layer,
mipLevelSize(mipLevel, dimensions[0]),
- 1,
+ layerCount,
format, dataSize, data, options);
}
break;
@@ -1491,6 +1498,7 @@ void QOpenGLTexturePrivate::setCompressedData(int mipLevel, int layer, QOpenGLTe
case QOpenGLTexture::Target2D:
Q_UNUSED(layer);
Q_UNUSED(cubeFace);
+ Q_UNUSED(layerCount);
if (needsFullSpec) {
texFuncs->glCompressedTextureImage2D(textureId, target, bindingTarget, mipLevel,
format,
@@ -1513,13 +1521,14 @@ void QOpenGLTexturePrivate::setCompressedData(int mipLevel, int layer, QOpenGLTe
0, 0, layer,
mipLevelSize(mipLevel, dimensions[0]),
mipLevelSize(mipLevel, dimensions[1]),
- 1,
+ layerCount,
format, dataSize, data, options);
}
break;
case QOpenGLTexture::Target3D:
Q_UNUSED(cubeFace);
+ Q_UNUSED(layerCount);
if (needsFullSpec) {
texFuncs->glCompressedTextureImage3D(textureId, target, bindingTarget, mipLevel,
format,
@@ -1539,6 +1548,7 @@ void QOpenGLTexturePrivate::setCompressedData(int mipLevel, int layer, QOpenGLTe
case QOpenGLTexture::TargetCubeMap:
Q_UNUSED(layer);
+ Q_UNUSED(layerCount);
if (needsFullSpec) {
texFuncs->glCompressedTextureImage2D(textureId, cubeFace, bindingTarget, mipLevel,
format,
@@ -1562,7 +1572,7 @@ void QOpenGLTexturePrivate::setCompressedData(int mipLevel, int layer, QOpenGLTe
0, 0, layerFace,
mipLevelSize(mipLevel, dimensions[0]),
mipLevelSize(mipLevel, dimensions[1]),
- 1,
+ layerCount,
format, dataSize, data, options);
}
break;
@@ -3286,7 +3296,23 @@ void QOpenGLTexture::setData(int mipLevel, int layer, CubeMapFace cubeFace,
"To do so call allocateStorage() before this function");
return;
}
- d->setData(mipLevel, layer, cubeFace, sourceFormat, sourceType, data, options);
+ d->setData(mipLevel, layer, 1, cubeFace, sourceFormat, sourceType, data, options);
+}
+
+/*!
+ \since 5.9
+ \overload
+*/
+void QOpenGLTexture::setData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions * const options)
+{
+ Q_D(QOpenGLTexture);
+ Q_ASSERT(d->textureId);
+ if (!isStorageAllocated()) {
+ qWarning("Cannot set data on a texture that does not have storage allocated.\n"
+ "To do so call allocateStorage() before this function");
+ return;
+ }
+ d->setData(mipLevel, layer, layerCount, cubeFace, sourceFormat, sourceType, data, options);
}
/*!
@@ -3299,7 +3325,7 @@ void QOpenGLTexture::setData(int mipLevel, int layer,
{
Q_D(QOpenGLTexture);
Q_ASSERT(d->textureId);
- d->setData(mipLevel, layer, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
+ d->setData(mipLevel, layer, 1, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
}
/*!
@@ -3312,7 +3338,7 @@ void QOpenGLTexture::setData(int mipLevel,
{
Q_D(QOpenGLTexture);
Q_ASSERT(d->textureId);
- d->setData(mipLevel, 0, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
+ d->setData(mipLevel, 0, 1, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
}
/*!
@@ -3324,7 +3350,7 @@ void QOpenGLTexture::setData(PixelFormat sourceFormat, PixelType sourceType,
{
Q_D(QOpenGLTexture);
Q_ASSERT(d->textureId);
- d->setData(0, 0, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
+ d->setData(0, 0, 1, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
}
#if QT_DEPRECATED_SINCE(5, 3)
@@ -3345,7 +3371,7 @@ void QOpenGLTexture::setData(int mipLevel, int layer, CubeMapFace cubeFace,
"To do so call allocateStorage() before this function");
return;
}
- d->setData(mipLevel, layer, cubeFace, sourceFormat, sourceType, data, options);
+ d->setData(mipLevel, layer, 1, cubeFace, sourceFormat, sourceType, data, options);
}
/*!
@@ -3358,7 +3384,7 @@ void QOpenGLTexture::setData(int mipLevel, int layer,
{
Q_D(QOpenGLTexture);
Q_ASSERT(d->textureId);
- d->setData(mipLevel, layer, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
+ d->setData(mipLevel, layer, 1, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
}
/*!
@@ -3371,7 +3397,7 @@ void QOpenGLTexture::setData(int mipLevel,
{
Q_D(QOpenGLTexture);
Q_ASSERT(d->textureId);
- d->setData(mipLevel, 0, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
+ d->setData(mipLevel, 0, 1, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
}
/*!
@@ -3383,7 +3409,7 @@ void QOpenGLTexture::setData(PixelFormat sourceFormat, PixelType sourceType,
{
Q_D(QOpenGLTexture);
Q_ASSERT(d->textureId);
- d->setData(0, 0, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
+ d->setData(0, 0, 1, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options);
}
#endif
@@ -3444,7 +3470,23 @@ void QOpenGLTexture::setCompressedData(int mipLevel, int layer, CubeMapFace cube
"To do so call allocateStorage() before this function");
return;
}
- d->setCompressedData(mipLevel, layer, cubeFace, dataSize, data, options);
+ d->setCompressedData(mipLevel, layer, 1, cubeFace, dataSize, data, options);
+}
+
+/*!
+ \since 5.9
+ \overload
+*/
+void QOpenGLTexture::setCompressedData(int mipLevel, int layer, int layerCount, QOpenGLTexture::CubeMapFace cubeFace, int dataSize, const void *data, const QOpenGLPixelTransferOptions * const options)
+{
+ Q_D(QOpenGLTexture);
+ Q_ASSERT(d->textureId);
+ if (!isStorageAllocated()) {
+ qWarning("Cannot set data on a texture that does not have storage allocated.\n"
+ "To do so call allocateStorage() before this function");
+ return;
+ }
+ d->setCompressedData(mipLevel, layer, layerCount, cubeFace, dataSize, data, options);
}
/*!
@@ -3455,7 +3497,7 @@ void QOpenGLTexture::setCompressedData(int mipLevel, int layer, int dataSize, co
{
Q_D(QOpenGLTexture);
Q_ASSERT(d->textureId);
- d->setCompressedData(mipLevel, layer, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
+ d->setCompressedData(mipLevel, layer, 1, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
}
/*!
@@ -3466,7 +3508,7 @@ void QOpenGLTexture::setCompressedData(int mipLevel, int dataSize, const void *d
{
Q_D(QOpenGLTexture);
Q_ASSERT(d->textureId);
- d->setCompressedData(mipLevel, 0, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
+ d->setCompressedData(mipLevel, 0, 1, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
}
/*!
@@ -3477,7 +3519,7 @@ void QOpenGLTexture::setCompressedData(int dataSize, const void *data,
{
Q_D(QOpenGLTexture);
Q_ASSERT(d->textureId);
- d->setCompressedData(0, 0, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
+ d->setCompressedData(0, 0, 1, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
}
#if QT_DEPRECATED_SINCE(5, 3)
@@ -3496,7 +3538,7 @@ void QOpenGLTexture::setCompressedData(int mipLevel, int layer, CubeMapFace cube
"To do so call allocateStorage() before this function");
return;
}
- d->setCompressedData(mipLevel, layer, cubeFace, dataSize, data, options);
+ d->setCompressedData(mipLevel, layer, 1, cubeFace, dataSize, data, options);
}
/*!
@@ -3508,7 +3550,7 @@ void QOpenGLTexture::setCompressedData(int mipLevel, int layer, int dataSize, vo
{
Q_D(QOpenGLTexture);
Q_ASSERT(d->textureId);
- d->setCompressedData(mipLevel, layer, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
+ d->setCompressedData(mipLevel, layer, 1, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
}
/*!
@@ -3520,7 +3562,7 @@ void QOpenGLTexture::setCompressedData(int mipLevel, int dataSize, void *data,
{
Q_D(QOpenGLTexture);
Q_ASSERT(d->textureId);
- d->setCompressedData(mipLevel, 0, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
+ d->setCompressedData(mipLevel, 0, 1, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
}
/*!
@@ -3532,7 +3574,7 @@ void QOpenGLTexture::setCompressedData(int dataSize, void *data,
{
Q_D(QOpenGLTexture);
Q_ASSERT(d->textureId);
- d->setCompressedData(0, 0, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
+ d->setCompressedData(0, 0, 1, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options);
}
#endif