From e5d65996a93bbf4cbc8a155887def6efa3ad73de Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 22 Sep 2021 18:16:20 +0200 Subject: [PATCH] Add some debug warnings to the GL paint engine regarding stencil There is absolutely nothing we can do if the render target has no stencil buffer, but print at least a warning in debug builds to give a hint to the developer. Pick-to: 6.2 Task-number: QTBUG-96786 Change-Id: If7f84f28f9bc9b3dadd01d0816c8db4015a1db0b Reviewed-by: Volker Hilsheimer --- src/opengl/qopenglpaintengine.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/opengl/qopenglpaintengine.cpp b/src/opengl/qopenglpaintengine.cpp index 8606a2e7ef..c385b4c62b 100644 --- a/src/opengl/qopenglpaintengine.cpp +++ b/src/opengl/qopenglpaintengine.cpp @@ -1124,6 +1124,10 @@ void QOpenGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, funcs.glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // Disable color writes useSimpleShader(); +#ifndef QT_NO_DEBUG + if (ctx->format().stencilBufferSize() <= 0) + qWarning("OpenGL paint engine: attempted to use stencil test without requesting a stencil buffer."); +#endif funcs.glEnable(GL_STENCIL_TEST); // For some reason, this has to happen _after_ the simple shader is use()'d if (mode == WindingFillMode) { @@ -2346,6 +2350,10 @@ void QOpenGL2PaintEngineExPrivate::updateClipScissorTest() { Q_Q(QOpenGL2PaintEngineEx); if (q->state()->clipTestEnabled) { +#ifndef QT_NO_DEBUG + if (ctx->format().stencilBufferSize() <= 0) + qWarning("OpenGL paint engine: attempted to use stencil test for clipping without requesting a stencil buffer."); +#endif funcs.glEnable(GL_STENCIL_TEST); funcs.glStencilFunc(GL_LEQUAL, q->state()->currentClip, ~GL_STENCIL_HIGH_BIT); } else {