QOpenGLTexture: don't allocate immutable multisample storage if not supported
Multisample textures may be supported without multisample texture storage (e.g. from GL 3.2 to 4.2). And, immutable storage may be present, but not supporting multisample textures (GL 4.3 - 4.4). Thus, we must properly check if we can allocate immutable multisample storage, falling back to mutable multisample storage if we're lacking the feature. Task-number: QTBUG-42643 Change-Id: I1f3d5a9b4296626e40b69a06710331e49c2d1a33 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>bb10
parent
f29e4ef1a6
commit
766775f6a0
|
|
@ -412,13 +412,45 @@ static bool isSizedTextureFormat(QOpenGLTexture::TextureFormat internalFormat)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool isTextureTargetMultisample(QOpenGLTexture::Target target)
|
||||
{
|
||||
switch (target) {
|
||||
case QOpenGLTexture::Target1D:
|
||||
case QOpenGLTexture::Target1DArray:
|
||||
case QOpenGLTexture::Target2D:
|
||||
case QOpenGLTexture::Target2DArray:
|
||||
case QOpenGLTexture::Target3D:
|
||||
case QOpenGLTexture::TargetCubeMap:
|
||||
case QOpenGLTexture::TargetCubeMapArray:
|
||||
return false;
|
||||
|
||||
case QOpenGLTexture::Target2DMultisample:
|
||||
case QOpenGLTexture::Target2DMultisampleArray:
|
||||
return true;
|
||||
|
||||
case QOpenGLTexture::TargetRectangle:
|
||||
case QOpenGLTexture::TargetBuffer:
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
|
||||
void QOpenGLTexturePrivate::allocateStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType)
|
||||
{
|
||||
// Resolve the actual number of mipmap levels we can use
|
||||
mipLevels = evaluateMipLevels();
|
||||
|
||||
// Use immutable storage whenever possible, falling back to mutable
|
||||
if (features.testFlag(QOpenGLTexture::ImmutableStorage) && isSizedTextureFormat(format))
|
||||
// Note that if multisample textures are not supported at all, we'll still fail into
|
||||
// the mutable storage allocation
|
||||
const bool useImmutableStorage = isSizedTextureFormat(format)
|
||||
&& (isTextureTargetMultisample(target)
|
||||
? features.testFlag(QOpenGLTexture::ImmutableMultisampleStorage)
|
||||
: features.testFlag(QOpenGLTexture::ImmutableStorage));
|
||||
|
||||
if (useImmutableStorage)
|
||||
allocateImmutableStorage();
|
||||
else
|
||||
allocateMutableStorage(pixelFormat, pixelType);
|
||||
|
|
@ -1028,7 +1060,7 @@ void QOpenGLTexturePrivate::allocateImmutableStorage()
|
|||
break;
|
||||
|
||||
case QOpenGLTexture::Target2DMultisample:
|
||||
if (features.testFlag(QOpenGLTexture::TextureMultisample)) {
|
||||
if (features.testFlag(QOpenGLTexture::ImmutableMultisampleStorage)) {
|
||||
texFuncs->glTextureStorage2DMultisample(textureId, target, bindingTarget, samples, format,
|
||||
dimensions[0], dimensions[1],
|
||||
fixedSamplePositions);
|
||||
|
|
@ -1039,7 +1071,7 @@ void QOpenGLTexturePrivate::allocateImmutableStorage()
|
|||
break;
|
||||
|
||||
case QOpenGLTexture::Target2DMultisampleArray:
|
||||
if (features.testFlag(QOpenGLTexture::TextureMultisample)
|
||||
if (features.testFlag(QOpenGLTexture::ImmutableMultisampleStorage)
|
||||
&& features.testFlag(QOpenGLTexture::TextureArrays)) {
|
||||
texFuncs->glTextureStorage3DMultisample(textureId, target, bindingTarget, samples, format,
|
||||
dimensions[0], dimensions[1], layers,
|
||||
|
|
|
|||
Loading…
Reference in New Issue