Graphics Problem when running Qt-5/OpenCASCADE linux application in Windows-10/WSL with VcXsrv X-server

Hello everyone,

I recently came across a graphics problem, when I tried to run my linux application with Qt (5.15) and OpenCASCASE (7.4) on a Windows-10 system inside the Windows Subsystem for Linux (WSL) system.

I create the viewer widget very much like in the OCC C++ sample. This works very nicely in Linux. In Windows/WSL on the other hand, I see a lot of artifacts. Not in the OCC viewer. The image there is without errors. But everywhere across the other Qt-controls and widgets nasty rectangular black artifacts appear.

In the WSL X-server I have disabled native OpenGL and software rendering is used:

$ glxinfo -B
name of display: localhost:0
display: localhost:0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: VMware, Inc. (0xffffffff)
    Device: llvmpipe (LLVM 10.0.0, 256 bits) (0xffffffff)
    Version: 20.0.8
    Accelerated: no
    Video memory: 2047MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 3.3
    Max compat profile version: 3.1
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.1
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: llvmpipe (LLVM 10.0.0, 256 bits)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 20.0.8
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 3.1 Mesa 20.0.8
OpenGL shading language version string: 1.40
OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.1 Mesa 20.0.8
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10

on the linux machine:

$ glxinfo -B
name of display: :0
display: :0  screen: 0
direct rendering: Yes
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 2048 MB
    Total available memory: 2048 MB
    Currently available dedicated video memory: 1108 MB
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: Quadro M600M/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 460.73.01
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.6.0 NVIDIA 460.73.01
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)

OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 460.73.01
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

I'm a bit lost about how to proceed in this case. Do you have any hints what to attempt to remove these artifacts?

Note: I have also used programs with VTK-9 (paraview) in this environment and works without artifacts.

Thanks for any hints and

Regards, Hannes

Hannes Kroeger's picture

and here is a little minimum example

Attachments: 
Kirill Gavrilov's picture

Don't know where to look at, just curious if the same problem occurs when using other X-servers - like remote connection to a real Linux workstation or using WSLg (the latter requires Windows 10 Insiders preview build 21364 or higher and pretends to provide GPU-accelerated OpenGL experience, although I would expect it to be castrated, as it is implemented using DirectX drivers).

Hannes Kroeger's picture

Hi Kirill,

thanks for your feedback.

I tried other X-servers which I could access: Xming, MobaXterm with various settings, but without difference (Probably these implementations are too similar).

Also, I run my Linux version through a SSH tunnel with the DISPLAY directed to VcXsrv. It shows the same behaviour.

WSLg seems a little experimental(?) I did not find the time to test this.

So what I actually look for is a workaround to make things run in VcXsrv. Performance is not an issue. As I understood (maybe wrong, I'im not very experienced in OpenGL programming), Qt uses the current context to draw things. Maybe either Qt or OCC does something, which makes it invalid. I stumbled across a QPainter::beginNativePainting() function which I guess is there to handle some shared usage of contexts. Maybe this should be applied somehow.

Regards, Hannes

Kirill Gavrilov's picture

As I understood (maybe wrong, I'im not very experienced in OpenGL programming), Qt uses the current context to draw things.

Sorry, I don't know much how Qt works underhood.
I guess (unlike QtQuick) Qt Widgets don't use OpenGL for rendering, so I don't quite understand how OpenGL state may affect Qt rendering at all.

Hannes Kroeger's picture

Ok, thanks for your comments anyway.

Maybe it has nothing to do with OpenGL at all. This was just my first assumption. I will investigate further...

Hannes Kroeger's picture

By the way: I can also replicate the problem on my linux machine only by directing the display output through an SSH-connection to localhost:

ssh -X localhost

and then run my test app. The artifacts appear as well.