Repository navigation
feat(webgpu): pipelines can be created without holding up the browser's GPU thread - #7
Closed
MichaelBradetLegris wants to merge 1 commit into
Closed
MichaelBradetLegris wants to merge 1 commit into
MichaelBradetLegris wants to merge 1 commit into
Conversation
…'s GPU thread `Device::create_render_pipeline_async` and `Device::create_compute_pipeline_async` resolve to the pipeline once it is ready, or to the error its creation reports. The WebGPU backend creates it with `createRenderPipelineAsync` or `createComputePipelineAsync`, so the browser compiles it off the thread that serves the page's other GPU calls. A synchronously created pipeline compiles on that thread, and Chrome on Direct3D, which compiles with DXC, drew nothing in any tab until a compile of up to tens of seconds ended. Every other backend creates the pipeline before the call returns, as the synchronous methods do, through default methods on `DeviceInterface`, so a custom backend needs no change. A rejected creation's `GPUPipelineError` becomes `Error::Validation` or `Error::Internal` by its reason. The WebGPU backend maps both descriptors once for both paths.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Author
|
Closed for https://github.com/fslabs/fsl_libs/pull/4798 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connections
An alternative to #6, which adds the same render pipeline call for the browser only. This is the dependency of fslabs/fsl_libs#4801, whose vendored
bevy_rendercreates every pipeline this way in a browser. fslabs/fsl_libs#4798 takes the other route, with #6.Description
Device::create_render_pipeline_asyncandDevice::create_compute_pipeline_asyncresolve to the pipeline once it is ready, or to the error its creation reports. The WebGPU backend creates the pipeline withcreateRenderPipelineAsyncorcreateComputePipelineAsync, so the browser compiles it off the thread that serves the page's other GPU calls. Chrome on Direct3D compiles with DXC on that thread. A synchronously created pipeline held every tab's drawing for as long as its compile took, which was tens of seconds for the SpatialEngine map and atmosphere shaders.Every other backend creates the pipeline before the call returns, as the synchronous methods do, through default methods on
DeviceInterface. Callers need nocfg, and a custom backend needs no change. A rejected creation'sGPUPipelineErrorbecomesError::ValidationorError::Internal, depending on itsreason. The WebGPU backend maps each descriptor once for both paths.Compared with #6, this also covers compute pipelines, is available on every backend, and reports a
wgpu::Errorrather than aString. The two touch the same functions, so only one should land.Testing
I built it into SpatialEngine and ran Geoid in Chrome 156 on Windows (Ryzen 9 5950X, RTX 3050). The engine created 70 pipelines this way, and the longest startup frame went from 29 s to 1.2 s with no WebGPU errors. Check, clippy and fmt for wgpu on wasm32-unknown-unknown pass, and clippy's three warnings are in code this change doesn't touch.
I did not run it against wgpu's own test suite. Native backends only gain the default methods, which call the synchronous ones.
Squash or Rebase?
Single commit, ready to rebase.