Different behaviour of QPainter on QOpenGLWidget using different graphics cards - how to debug
-
Hello,
I am currently developing an application with an OpenGL scene and I am about to introduce 2D overlays on top of that.I evaluated two options to do that: Using OpenGL directly and using a QPainter. I would prefer using a QPainter but I found on problem so far with this approach:
I tested a very simple application on two different systems: an nividia quadro and on my Surface Pro 3 Intel Core i5-4300U that just draw a red square on top of of a QOpenGLWidget:
GLWidget::GLWidget(QWidget *parent) : QOpenGLWidget(parent) {} GLWidget::~GLWidget() {} void GLWidget::paintGL() { QPainter p(this); p.setBrush(Qt::red); p.drawRect(10,10,100,100); }
In my main.cpp I tried different OpenGL-Context-Versions:
#include "GLWidget.h" #include <QApplication> #include <QSurfaceFormat> int main(int argc, char *argv[]) { QApplication a(argc, argv); QSurfaceFormat format; format.setDepthBufferSize(24); format.setStencilBufferSize(8); format.setSamples(4); format.setVersion(4, 3); // Commented out for some of the tests format.setProfile(QSurfaceFormat::CompatibilityProfile); QSurfaceFormat::setDefaultFormat(format); GLWidget w; w.show(); return a.exec(); }
I tried the 4.3 context and the default context which is a 2.0 OpenGL-Context I think. The result is:
- Quadro shows the red square in both cases
- Intel shows the red square only with the default version, the window remains pure black when requesting a 4.3 context.
There is no error message in case of 4.3 on intel. In my main application I am perfectly fine to draw the real OpenGL-stuff using my intel graphics including shaders etc. Also intel states that the 4300U does indeed support OpenGL 4.3.
Does anyone has an idea on how to further debug this? The problem might get resolved using 5.9 with QPainter support on core opengl profiles so I will try in two weeks as soon as the TP is out.
Best regards
Axel
-
Hi,
Did you check that you are getting the context you are asking for ? And that you are indeed using the desktop OpenGL and not falling back to Angle in the case of the Intel card ?
-
Hello,
thank you for your answer. Here is what I get when setting QT_LOGGING_RUILE to qt.qpa.gl=true when requesting the 4.3 context on intel:qt.qpa.gl: createPlatformOpenGLContext QSurfaceFormat(version 4.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples 4, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile)) qt.qpa.gl: Basic wglCreateContext gives version 4.3 qt.qpa.gl: OpenGL 2.0 entry points available qt.qpa.gl: GPU features: QSet() qt.qpa.gl: supportedRenderers GpuDescription(vendorId=0x8086, deviceId=0xa16, subSysId=0x51414, revision=11, driver: "igdumdim32.dll", version=20.19.15.4568, "Intel(R) HD Graphics Family") renderer: QFlags(0x1|0x2|0x4|0x8|0x20) qt.qpa.gl: Qt: Using WGL and OpenGL from "opengl32.dll" qt.qpa.gl: create OpenGL: "Intel","Intel(R) HD Graphics 4400" default ContextFormat: v4.3 profile: QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile) options: QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions),SampleBuffers, Extension-API present Extensions: 200 qt.qpa.gl: "choosePixelFormat samples= 4 Attributes: 0x2003 , 0x2027 , 0x2010 , 0x1 , 0x2001 , 0x1 , 0x2014 , 0x18 , 0x2011 , 0x1 , 0x2022 , 0x18 , 0x2013 , 0x202b , 0x201b , 0x8 , 0x2023 , 0x8 , 0x2041 , 0x1 , 0x2042 , 0x4 , \n obtained px # 22 of 1 \n PIXELFORMATDESCRIPTOR dwFlags=0x8205 PFD_DRAW_TO_WINDOW PFD_SUPPORT_COMPOSITION PFD_DOUBLEBUFFER iPixelType=0 cColorBits=32 cRedBits=8 cRedShift=16 cGreenBits=8 cGreenShift=8 cBlueBits=8 cBlueShift=0 cDepthBits=24 cStencilBits=8 iLayerType=0 cAlphaBits=8 cAlphaShift=24 cAccumBits=64 cAccumRedBits=16 cAccumGreenBits=16 cAccumBlueBits=16 cAccumAlphaBits=16 " qt.qpa.gl: createContext Creating context version 4 . 3 4 attributes qt.qpa.gl: QWindowsGLContext 0x1eca9fb8 ARB requested: QSurfaceFormat(version 4.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples 4, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile)) obtained # 22 ARB QSurfaceFormat(version 4.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples 4, swapBehavior QSurfaceFormat::SwapBehavior(DoubleBuffer), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile)) PIXELFORMATDESCRIPTOR dwFlags=0x8205 PFD_DRAW_TO_WINDOW PFD_SUPPORT_COMPOSITION PFD_DOUBLEBUFFER iPixelType=0 cColorBits=32 cRedBits=8 cRedShift=16 cGreenBits=8 cGreenShift=8 cBlueBits=8 cBlueShift=0 cDepthBits=24 cStencilBits=8 iLayerType=0 cAlphaBits=8 cAlphaShift=24 cAccumBits=64 cAccumRedBits=16 cAccumGreenBits=16 cAccumBlueBits=16 cAccumAlphaBits=16 swap interval: 1 default: ContextFormat: v4.3 profile: QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile) options: QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions) HGLRC= 0x30000 qt.qpa.gl: createPlatformOpenGLContext QSurfaceFormat(version 4.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile)) qt.qpa.gl: "choosePixelFormat Attributes: 0x2003 , 0x2027 , 0x2010 , 0x1 , 0x2001 , 0x1 , 0x2014 , 0x18 , 0x2011 , 0x1 , 0x2022 , 0x18 , 0x2013 , 0x202b , 0x201b , 0x8 , 0x2023 , 0x8 , 0x2041 , 0x0 , \n obtained px # 5 of 1 \n PIXELFORMATDESCRIPTOR dwFlags=0x8225 PFD_DRAW_TO_WINDOW PFD_SUPPORT_OPENGL PFD_SUPPORT_COMPOSITION PFD_DOUBLEBUFFER iPixelType=0 cColorBits=32 cRedBits=8 cRedShift=16 cGreenBits=8 cGreenShift=8 cBlueBits=8 cBlueShift=0 cDepthBits=24 cStencilBits=8 iLayerType=0 cAlphaBits=8 cAlphaShift=24 cAccumBits=64 cAccumRedBits=16 cAccumGreenBits=16 cAccumBlueBits=16 cAccumAlphaBits=16 " qt.qpa.gl: createContext Creating context version 4 . 3 4 attributes qt.qpa.gl: QWindowsGLContext 0x1eca9378 ARB requested: QSurfaceFormat(version 4.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile)) obtained # 5 ARB QSurfaceFormat(version 4.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::SwapBehavior(DoubleBuffer), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile)) PIXELFORMATDESCRIPTOR dwFlags=0x8225 PFD_DRAW_TO_WINDOW PFD_SUPPORT_OPENGL PFD_SUPPORT_COMPOSITION PFD_DOUBLEBUFFER iPixelType=0 cColorBits=32 cRedBits=8 cRedShift=16 cGreenBits=8 cGreenShift=8 cBlueBits=8 cBlueShift=0 cDepthBits=24 cStencilBits=8 iLayerType=0 cAlphaBits=8 cAlphaShift=24 cAccumBits=64 cAccumRedBits=16 cAccumGreenBits=16 cAccumBlueBits=16 cAccumAlphaBits=16 swap interval: 1 default: ContextFormat: v4.3 profile: QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile) options: QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions) HGLRC= 0x10001
As far as I see, I get the correct context. When forcing ANGLE by setting Qt::AA_UseSoftwareOpenGL to true, I get a different behaviour: (White window instead of black window, this output and everytime the window has to be drawn "composeAndFlush: makeCurrent() failed" and the following output during startup:
qt.qpa.gl: createPlatformOpenGLContext QSurfaceFormat(version 4.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples 4, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile)) qt.qpa.gl: Qt: Using WGL and OpenGL from "opengl32sw.dll" qt.qpa.gl: create OpenGL: "VMware, Inc.","Gallium 0.4 on llvmpipe (LLVM 3.6, 256 bits)" default ContextFormat: v3.0 profile: QSurfaceFormat::OpenGLContextProfile(NoProfile) options: QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions),SampleBuffers, Extension-API present Extensions: 207 qt.qpa.gl: "choosePixelFormat samples= 0 Attributes: 0x2003 , 0x2027 , 0x2010 , 0x1 , 0x2001 , 0x1 , 0x2014 , 0x18 , 0x2011 , 0x1 , 0x2022 , 0x18 , 0x2013 , 0x202b , 0x201b , 0x8 , 0x2023 , 0x8 , 0x2041 , 0x1 , 0x0 , 0x0 , \n obtained px # 0 of 0 \n PIXELFORMATDESCRIPTOR dwFlags=0x0 iPixelType=0 cColorBits=0 cRedBits=0 cRedShift=0 cGreenBits=0 cGreenShift=0 cBlueBits=0 cBlueShift=0 cDepthBits=0 iLayerType=0 " Attempted to use GDI functions with a non-opengl32.dll library QWindowsGLContext: Unable find a suitable pixel format. qt.qpa.gl: QWindowsGLContext 0x165394c8 ARB requested: QSurfaceFormat(version 4.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples 4, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile)) obtained # 0 GDI QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(NoProfile)) PIXELFORMATDESCRIPTOR dwFlags=0x0 iPixelType=0 cColorBits=0 cRedBits=0 cRedShift=0 cGreenBits=0 cGreenShift=0 cBlueBits=0 cBlueShift=0 cDepthBits=0 iLayerType=0 swap interval: -1 default: ContextFormat: v3.0 profile: QSurfaceFormat::OpenGLContextProfile(NoProfile) options: QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions) HGLRC= 0x0 qt.qpa.gl: createPlatformOpenGLContext QSurfaceFormat(version 4.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile)) qt.qpa.gl: "choosePixelFormat Attributes: 0x2003 , 0x2027 , 0x2010 , 0x1 , 0x2001 , 0x1 , 0x2014 , 0x18 , 0x2011 , 0x1 , 0x2022 , 0x18 , 0x2013 , 0x202b , 0x201b , 0x8 , 0x2023 , 0x8 , 0x2041 , 0x0 , \n obtained px # 45 of 1 \n PIXELFORMATDESCRIPTOR dwFlags=0x807c PFD_DRAW_TO_WINDOW PFD_DRAW_TO_BITMAP PFD_SUPPORT_GDI PFD_SUPPORT_OPENGL PFD_SUPPORT_COMPOSITION PFD_GENERIC_FORMAT iPixelType=1 cColorBits=32 cRedBits=8 cRedShift=16 cGreenBits=8 cGreenShift=8 cBlueBits=8 cBlueShift=0 cDepthBits=16 cStencilBits=8 iLayerType=0 " qt.qpa.gl: createContext Creating context version 3 . 0 3 attributes qt.qpa.gl: QWindowsGLContext 0x16539a08 ARB requested: QSurfaceFormat(version 4.3, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::SwapBehavior(DefaultSwapBehavior), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(CompatibilityProfile)) obtained # 45 ARB QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::SwapBehavior(DoubleBuffer), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(NoProfile)) PIXELFORMATDESCRIPTOR dwFlags=0x807c PFD_DRAW_TO_WINDOW PFD_DRAW_TO_BITMAP PFD_SUPPORT_GDI PFD_SUPPORT_OPENGL PFD_SUPPORT_COMPOSITION PFD_GENERIC_FORMAT iPixelType=1 cColorBits=32 cRedBits=8 cRedShift=16 cGreenBits=8 cGreenShift=8 cBlueBits=8 cBlueShift=0 cDepthBits=16 cStencilBits=8 iLayerType=0 swap interval: 0 default: ContextFormat: v3.0 profile: QSurfaceFormat::OpenGLContextProfile(NoProfile) options: QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions) HGLRC= 0x1
-
Indeed, it looks like you are getting the correct context, so I wonder whether it's a driver problem.
-
I did another test on an Intel i5-3470 and got the same behaviour. I think I have to report a bug here.
I dont see a way to upload files here. I would like to share my testcase so other people could confirm the behaviour.
Best regards,
Axel
-
Since you have precise spec that ends in failure, you should go directly to the bug report system. First check if there's already something related, if so, you can add your findings and sample test case to that report. If not then please open a new report providing as much details as you can as well as your sample application.
-
-
Nice to see it's already fixed for 5.9 !
Thanks for the link :)