rhi: gl: Fix multisample texture specification

...so that MSAA is actually effective.

Pick-to: 6.6
Change-Id: I4bf85df1312773ec29154a51c9c8464912e6ef8a
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 46366a14a41ec6db5ab4ab72c473a4a4e187d484)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Laszlo Agocs 2024-02-22 17:26:55 +01:00 committed by Qt Cherry-pick Bot
parent f9557be6f6
commit aaba67eea9

View File

@ -5462,8 +5462,16 @@ bool QGles2Texture::create()
}
}
} else {
rhiD->f->glTexImage2D(target, 0, GLint(glintformat), size.width(), size.height(),
0, glformat, gltype, nullptr);
// 2D texture. For multisample textures the GLES 3.1
// glStorage2DMultisample must be used for portability.
if (m_sampleCount > 1 && rhiD->caps.multisampledTexture) {
// internal format must be sized
rhiD->f->glTexStorage2DMultisample(target, m_sampleCount, glsizedintformat,
size.width(), size.height(), GL_TRUE);
} else {
rhiD->f->glTexImage2D(target, 0, GLint(glintformat), size.width(), size.height(),
0, glformat, gltype, nullptr);
}
}
} else {
// Must be specified with immutable storage functions otherwise
@ -5474,6 +5482,9 @@ bool QGles2Texture::create()
else if (!is1D && (is3D || isArray))
rhiD->f->glTexStorage3D(target, mipLevelCount, glsizedintformat, size.width(), size.height(),
is3D ? qMax(1, m_depth) : qMax(0, m_arraySize));
else if (m_sampleCount > 1)
rhiD->f->glTexStorage2DMultisample(target, m_sampleCount, glsizedintformat,
size.width(), size.height(), GL_TRUE);
else
rhiD->f->glTexStorage2D(target, mipLevelCount, glsizedintformat, size.width(),
is1D ? qMax(0, m_arraySize) : size.height());