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 <volker.hilsheimer@qt.io>
This commit is contained in:
Laszlo Agocs 2021-09-22 18:16:20 +02:00
parent e9cef8e7fa
commit e5d65996a9

View File

@ -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 {