createRenderPipelineAsync is hard to use correctly #2085
Replies: 1 comment
-
|
Looking at pipelines first. The point of async pipeline creation is that it can take a bunch of time if needed so you can create 1000 pipelines at startup and not block the browser. At first glance seems appear as what you said where you'd have duplicate work between async and sync pipelines. First that's somehow ok because your requirements for the pipeline changed last minute. But also the browser can optimize this case by stealing the async creation task and just execute it immediately. That's ideas we've had floating around for Dawn. We also had some ideas about compiling shader modules asynchronously by default. When a pipeline synchronously needs a shadermodule, the same task stealing can happen. The only difficulty here is that createShaderModule interacts with the error scope and that would mean that error scopes can be delayed much more than what they appear. We could decouple shadermodule creation errors and only surface them in 1) pipeline creation and 2) compilationInfo. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The current behavior of createRenderPipelineAsync is that it uses a Promise. See also #596
This means that even if createRenderPipelineAsync can complete within the same frame immediately, that pipeline can't be used in that frame.
The current split nature of createRenderPipeline vs. createRenderPipelineAsync can lead to wasted work. e.g. I start rendering a frame where some of the objects are missing. But then I realize I need some of these pipelines to successfully complete, since I'm rendering them into a spec probe and I cannot have any objects missing in a spec probe. This means that I might have kicked off a createRenderPipelineAsync, and then need to later directly call createRenderPipeline. aka there's no way to "convert" an async execution into a sync one.
These concerns are amplified for createShaderModule, which has no synchronous equivalent. There's no way, from a frame callback, to ever render an object that requires shader compilation on the same frame it was created, even if the shader has been cached by the browser previously.
Beta Was this translation helpful? Give feedback.
All reactions