Use glRenderbufferStorageMultisampleEXT when available on GLES

Important for Mali in particular. This GLES implementation seems
to choke when using a glRenderbufferStorageMultisample-allocated
renderbuffer with a texture attached via
glFramebufferTexture2DMultisampleEXT.

Amends 590c85c80b5e84f20282256f64662da8a25d51a9

Change-Id: Ied1cbbd2525a22088d54c1130a2f830a5133eb83
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2024-10-01 16:09:21 +02:00
parent 6b66bb9a21
commit 38caabed3f
2 changed files with 12 additions and 2 deletions

View File

@ -1103,6 +1103,8 @@ bool QRhiGles2::create(QRhi::Flags flags)
if (caps.glesMultisampleRenderToTexture) { if (caps.glesMultisampleRenderToTexture) {
glFramebufferTexture2DMultisampleEXT = reinterpret_cast<void(QOPENGLF_APIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint, GLsizei)>( glFramebufferTexture2DMultisampleEXT = reinterpret_cast<void(QOPENGLF_APIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint, GLsizei)>(
ctx->getProcAddress(QByteArrayLiteral("glFramebufferTexture2DMultisampleEXT"))); ctx->getProcAddress(QByteArrayLiteral("glFramebufferTexture2DMultisampleEXT")));
glRenderbufferStorageMultisampleEXT = reinterpret_cast<void(QOPENGLF_APIENTRYP)(GLenum, GLsizei, GLenum, GLsizei, GLsizei)>(
ctx->getProcAddress(QByteArrayLiteral("glRenderbufferStorageMultisampleEXT")));
} }
caps.glesMultiviewMultisampleRenderToTexture = ctx->hasExtension("GL_OVR_multiview_multisampled_render_to_texture"); caps.glesMultiviewMultisampleRenderToTexture = ctx->hasExtension("GL_OVR_multiview_multisampled_render_to_texture");
if (caps.glesMultiviewMultisampleRenderToTexture) { if (caps.glesMultiviewMultisampleRenderToTexture) {
@ -5488,8 +5490,15 @@ bool QGles2RenderBuffer::create()
switch (m_type) { switch (m_type) {
case QRhiRenderBuffer::DepthStencil: case QRhiRenderBuffer::DepthStencil:
if (rhiD->caps.msaaRenderBuffer && samples > 1) { if (rhiD->caps.msaaRenderBuffer && samples > 1) {
rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_DEPTH24_STENCIL8, if (rhiD->caps.glesMultisampleRenderToTexture) {
size.width(), size.height()); // Must match the logic in QGles2TextureRenderTarget::create().
// EXT and non-EXT are not the same thing.
rhiD->glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, samples, GL_DEPTH24_STENCIL8,
size.width(), size.height());
} else {
rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_DEPTH24_STENCIL8,
size.width(), size.height());
}
stencilRenderbuffer = 0; stencilRenderbuffer = 0;
} else if (rhiD->caps.packedDepthStencil || rhiD->caps.needsDepthStencilCombinedAttach) { } else if (rhiD->caps.packedDepthStencil || rhiD->caps.needsDepthStencilCombinedAttach) {
const GLenum storage = rhiD->caps.needsDepthStencilCombinedAttach ? GL_DEPTH_STENCIL : GL_DEPTH24_STENCIL8; const GLenum storage = rhiD->caps.needsDepthStencilCombinedAttach ? GL_DEPTH_STENCIL : GL_DEPTH24_STENCIL8;

View File

@ -966,6 +966,7 @@ public:
void (QOPENGLF_APIENTRYP glObjectLabel)(GLenum, GLuint, GLsizei, const GLchar *) = nullptr; void (QOPENGLF_APIENTRYP glObjectLabel)(GLenum, GLuint, GLsizei, const GLchar *) = nullptr;
void (QOPENGLF_APIENTRYP glFramebufferTexture2DMultisampleEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLsizei) = nullptr; void (QOPENGLF_APIENTRYP glFramebufferTexture2DMultisampleEXT)(GLenum, GLenum, GLenum, GLuint, GLint, GLsizei) = nullptr;
void (QOPENGLF_APIENTRYP glFramebufferTextureMultisampleMultiviewOVR)(GLenum, GLenum, GLuint, GLint, GLsizei, GLint, GLsizei) = nullptr; void (QOPENGLF_APIENTRYP glFramebufferTextureMultisampleMultiviewOVR)(GLenum, GLenum, GLuint, GLint, GLsizei, GLint, GLsizei) = nullptr;
void (QOPENGLF_APIENTRYP glRenderbufferStorageMultisampleEXT)(GLenum, GLsizei, GLenum, GLsizei, GLsizei) = nullptr;
uint vao = 0; uint vao = 0;
struct Caps { struct Caps {
Caps() Caps()