summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2023-02-08 09:05:44 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2023-02-08 09:30:21 +0100
commit8f1d8139c40d8b050ac606c3d62eee7f1f37410f (patch)
treef0f3f2483bde03cd41f235ba204b4e6686cc5d8b /src/gui/rhi
parent44933343937d7a6d9f6afe1f8e0b0f93a387b100 (diff)
Avoid glDrawBuffers on ES 2.0 / WebGL 1
Fixes: QTBUG-111007 Pick-to: 6.5 Change-Id: If1d84df56ad47ac89ea43ad5091392416fe9fc5f Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src/gui/rhi')
-rw-r--r--src/gui/rhi/qrhigles2.cpp14
-rw-r--r--src/gui/rhi/qrhigles2_p_p.h4
2 files changed, 14 insertions, 4 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index 11b1b965b8..77448a8b21 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -766,12 +766,20 @@ bool QRhiGles2::create(QRhi::Flags flags)
f->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &caps.maxTextureSize);
- if (caps.ctxMajor >= 3 || actualFormat.renderableType() == QSurfaceFormat::OpenGL) {
+ caps.gles = actualFormat.renderableType() == QSurfaceFormat::OpenGLES;
+
+ if (!caps.gles || caps.ctxMajor >= 3) {
+ // non-ES or ES 3.0+
f->glGetIntegerv(GL_MAX_DRAW_BUFFERS, &caps.maxDrawBuffers);
+ caps.hasDrawBuffersFunc = true;
f->glGetIntegerv(GL_MAX_SAMPLES, &caps.maxSamples);
caps.maxSamples = qMax(1, caps.maxSamples);
} else {
+ // ES 2.0 / WebGL 1
caps.maxDrawBuffers = 1;
+ caps.hasDrawBuffersFunc = false;
+ // This does not mean MSAA is not supported, just that we cannot query
+ // the supported sample counts.
caps.maxSamples = 1;
}
@@ -781,7 +789,6 @@ bool QRhiGles2::create(QRhi::Flags flags)
caps.npotTextureFull = f->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures)
&& f->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat);
- caps.gles = actualFormat.renderableType() == QSurfaceFormat::OpenGLES;
if (caps.gles)
caps.fixedIndexPrimitiveRestart = caps.ctxMajor >= 3; // ES 3.0
else
@@ -3073,7 +3080,8 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
else
bufs.append(caps.gles ? GL_BACK : GL_BACK_LEFT);
}
- f->glDrawBuffers(bufs.count(), bufs.constData());
+ if (caps.hasDrawBuffersFunc)
+ f->glDrawBuffers(bufs.count(), bufs.constData());
if (caps.srgbCapableDefaultFramebuffer) {
if (cmd.args.bindFramebuffer.srgb)
f->glEnable(GL_FRAMEBUFFER_SRGB);
diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h
index f27320cab5..7caec5f7d5 100644
--- a/src/gui/rhi/qrhigles2_p_p.h
+++ b/src/gui/rhi/qrhigles2_p_p.h
@@ -960,7 +960,8 @@ public:
texture3D(false),
tessellation(false),
geometryShader(false),
- texture1D(false)
+ texture1D(false),
+ hasDrawBuffersFunc(false)
{ }
int ctxMajor;
int ctxMinor;
@@ -1012,6 +1013,7 @@ public:
uint tessellation : 1;
uint geometryShader : 1;
uint texture1D : 1;
+ uint hasDrawBuffersFunc : 1;
} caps;
QGles2SwapChain *currentSwapChain = nullptr;
QSet<GLint> supportedCompressedFormats;