The confusion of multithreaded rendering

84 views
Skip to first unread message

guodong chen

unread,
Sep 28, 2022, 12:48:33 PM9/28/22
to Dawn Graphics
My program will render in 2 threads,

1. Can Dawn's single Queue submit buffers from multiple threads?

2. If different threads create different devices, can resources be shared across different devices?

Corentin Wallez

unread,
Sep 28, 2022, 12:50:00 PM9/28/22
to guodong chen, Dawn Graphics
1) If you externally synchronize access access to the rest of the Dawn resources yes. But in general no. Dawn hasn't been made to work well when used multithreaded yet.

2) no.

--
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/67275ccf-1a4f-4057-9d8d-f10de77a0552n%40googlegroups.com.

Dominic Cerisano

unread,
Sep 28, 2022, 12:55:19 PM9/28/22
to Corentin Wallez, guodong chen, Dawn Graphics
This topic came up when discussing distributed render/compute multiqueues a couple of years ago.

Dominic Cerisano

dcerisano@skype

NOTICE: Confidential message which may be privileged. Unauthorized use/disclosure prohibited. 
AVIS : Message confidentiel dont le contenu peut être privilégié. Utilisation/divulgation interdites sans permission. 


guodong chen

unread,
Sep 28, 2022, 12:58:57 PM9/28/22
to Dawn Graphics
If I wanted to use an Offscreen Canvas style, could Dawn draw the texture in the A thread and then use it in the B thread?

Corentin Wallez

unread,
Sep 28, 2022, 1:00:25 PM9/28/22
to guodong chen, Dawn Graphics
Not at the moment. Dawn is very much single threaded for now. The only thing that's safe multithreaded is command recording. We expect to improve this in the future but it hasn't been necessary for the Web part of WebGPU so it hasn't been the priority.

guodong chen

unread,
Sep 28, 2022, 1:05:40 PM9/28/22
to Dawn Graphics
I checked Dawn's interfaces. Which interfaces are used for recording?

Austin Eng

unread,
Sep 28, 2022, 1:48:12 PM9/28/22
to guodong chen, Dawn Graphics
wgpu::CommandEncoder, wgpu::RenderPassEncoder, wgpu::ComputePassEncoder, wgpu::RenderBundleEncoder are the recording interfaces.

The only thing safe to do multithreaded is after making a command encoder, record certain types of commands on it on another thread, and then call CommandEncoder::Finish() to get a wgpu::CommandBuffer. You need to synchronize access to the queue if you want to submit the wgpu::CommandBuffer on the main thread.

Types of commands you should not record multithreaded:
 - Indirect draw commands - that will not be thread-safe since internally it allocates extra buffers.
 



guodong chen

unread,
Sep 28, 2022, 10:41:57 PM9/28/22
to Dawn Graphics
If different devices cannot share resources, is it safe for a device to allocate resources including the Buffer Texture pipeline in different threads?

Corentin Wallez

unread,
Sep 29, 2022, 8:53:05 AM9/29/22
to guodong chen, Dawn Graphics
Only command encoding is safe, resource creation with buffer/texture/bindgroups etc isn't (unless you manually lock the device), nor is queue submit etc.

guodong chen

unread,
Sep 30, 2022, 9:18:05 AM9/30/22
to Dawn Graphics
It feels like Dawn has been around for a long time, is it stable enough to be used in commercial projects
Reply all
Reply to author
Forward
0 new messages