Webgpu + Qt

536 views
Skip to first unread message

Edward Boszczowski

unread,
Jun 17, 2024, 3:52:24 AM6/17/24
to Dawn Graphics
Can anyone give me a hint in how to integrate Webgu in a Qt application? 
I know that I can use WGPUSurfaceDescriptorFromWindowsHWND and pass as argument the HWND that I can get from a Qt Widget. I had tried to overwrite the paint event to be the content of the graphical render loop. But for some reasn nothing is painted. I need to configure some attribute related to HWND to integration between WebGPU and native handle work?

Corentin Wallez

unread,
Jun 17, 2024, 5:14:46 AM6/17/24
to Edward Boszczowski, Dawn Graphics
Hey Edward,

Unfortunately I don't know of anyone that did this previously. We use GLFW extensively in tests to create the windows and what we found is that we must tell it to not initialize an OpenGL context on the window, or bad things happen. IDK how much Qt would be willing to relinquish control and painting of a window. IDK of any HWND attributes that must be configured for D3D11/D3D12 to work on them.

Cheers,

Corentin

On Mon, Jun 17, 2024 at 9:52 AM Edward Boszczowski <deva...@gmail.com> wrote:
Can anyone give me a hint in how to integrate Webgu in a Qt application? 
I know that I can use WGPUSurfaceDescriptorFromWindowsHWND and pass as argument the HWND that I can get from a Qt Widget. I had tried to overwrite the paint event to be the content of the graphical render loop. But for some reasn nothing is painted. I need to configure some attribute related to HWND to integration between WebGPU and native handle work?

--
You received this message because you are subscribed to the Google Groups "Dawn Graphics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dawn-graphic...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dawn-graphics/d6059b02-4ed1-4db7-a28c-90fad555d509n%40googlegroups.com.

Jaswant Panchumarti

unread,
Jun 18, 2024, 1:38:43 PM6/18/24
to Dawn Graphics
Just want to chime in and say that this is of eventual importance for us at Kitware. After VTK is upgraded to use Dawn, ParaView and friends (which use Qt and VTK) will need looked at. I will post updates here when I've a minimal POC with Qt and dawn.

Akash Garg

unread,
Aug 19, 2024, 4:05:09 AM8/19/24
to Dawn Graphics
I've tried this on MacOS 13.6.7 with Qt 6.7.2 without luck. 

I created a custom QWidget and get the `winId` (an NSView*), for which I can configure the CAMetalLayer using this: 
```
    CAMetalLayer* metalLayer = [CAMetalLayer layer];
    [view setWantsLayer:YES];
    [view setLayer:metalLayer];
```
I can then set the `metalLayer` as the compatibleSurface in the adapter options.

To render I overwrite the paintEvent() but nothing gets rendered. I also see a warning on my console: 
` CoreAnimation: setting `contents' on CAMetalLayer may result in undefined behavior` - unclear where that is coming from. 

Ken Russell

unread,
Aug 20, 2024, 1:04:34 AM8/20/24
to Akash Garg, Dawn Graphics
Hi Akash,

Qt is probably assuming that it is receiving a bare CALayer, and is trying to set its contents to an IOSurface for display. CAMetalLayer behaves differently and you will probably need to work with the Qt developers to support it on macOS.

-Ken



Gareth C

unread,
Jun 30, 2025, 3:03:44 PMJun 30
to Dawn Graphics
For others who (like myself) stumble on this thread looking for a Qt+WebGPU example: have implemented a minimal example here (at least for OSX and Windows): https://github.com/gareth-cross/qt-wgpu
Reply all
Reply to author
Forward
0 new messages