Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGLBackground: Split adding to render list and clearing of buffers #28118

Merged
merged 1 commit into from
Apr 13, 2024

Conversation

mrxz
Copy link
Contributor

@mrxz mrxz commented Apr 11, 2024

Related issue: #28078

Description
At the start of the frame the WebXR framebuffer is bound. When rendering transmission pass(es) or shadow maps, a switch happens to a different render target. This is basically free, unless something has been written to the WebXR framebuffer already. Meaning the contents need to be stored and later loaded again.

The WebGLBackground handles various kinds of backgrounds. Some of which induce a clear, others insert themselves into the render list. To avoid the above mentioned overhead, any clear operation should happen after the transmission pass, at the same time the transmission pass expects backgrounds to be in the render list. This PR splits these two background paths so the render list is complete before the transmission pass and any applicable clears happens after it.

Compare the following outputs of ovrgpuprofiler before and after:

Surface 0    | 3360x1760 | color 32bit, depth 24bit, stencil 0 bit, MSAA 4, Mode: 2 (SwBinning) | 72  288x320 bins ( 57  rendered) |  2.69 ms | 171 stages : Render : 0.27ms StoreColor : 0.415ms Blit : 0.005ms Preempt : 0.823ms StoreDepthStencil : 0.532ms
Surface 1    | 1680x1760 | color 64bit, depth 24bit, stencil 0 bit, MSAA 4, Mode: 1 (HwBinning) | 48  288x224 bins ( 48  rendered) |  3.38 ms | 148 stages : Binning : 0.063ms Render : 1.212ms StoreColor : 0.624ms Blit : 0.372ms Preempt : 0.387ms StoreDepthStencil : 0.099ms
Surface 2    | 1680x1760 | color 64bit, depth 24bit, stencil 0 bit, MSAA 4, Mode: 1 (HwBinning) | 48  288x224 bins ( 48  rendered) |  2.92 ms | 147 stages : Binning : 0.06ms Render : 1.218ms StoreColor : 0.623ms Blit : 0.337ms StoreDepthStencil : 0.104ms
Surface 3    | 3360x1760 | color 32bit, depth 24bit, stencil 0 bit, MSAA 4, Mode: 1 (HwBinning) | 72  288x320 bins ( 72  rendered) |  5.70 ms | 292 stages : Binning : 0.125ms LoadColor : 0.157ms Render : 3.061ms StoreColor : 0.155ms Preempt : 1.216ms LoadDepthStencil : 0.163ms

Notice the StoreColor, StoreDepthStencil on surface 0 and LoadColor and LoadDepthStencil on surface 3. Which are gone when looking at the output with this PR in place:

Surface 0    | 3360x1760 | color 32bit, depth 24bit, stencil 0 bit, MSAA 4, Mode: 0 (Direct)    | 1   3360x1760 bins ( 1   rendered) |  0.00 ms | 1   stages : Render : 0.002ms
Surface 1    | 1680x1760 | color 64bit, depth 24bit, stencil 0 bit, MSAA 4, Mode: 1 (HwBinning) | 48  288x224 bins ( 48  rendered) |  3.54 ms | 148 stages : Binning : 0.063ms Render : 1.224ms StoreColor : 0.63ms Blit : 0.372ms Preempt : 0.494ms StoreDepthStencil : 0.102ms
Surface 2    | 1680x1760 | color 64bit, depth 24bit, stencil 0 bit, MSAA 4, Mode: 1 (HwBinning) | 48  288x224 bins ( 48  rendered) |  5.03 ms | 150 stages : Binning : 0.062ms Render : 1.228ms StoreColor : 0.639ms Blit : 0.502ms Preempt : 1.677ms StoreDepthStencil : 0.103ms
Surface 3    | 3360x1760 | color 32bit, depth 24bit, stencil 0 bit, MSAA 4, Mode: 1 (HwBinning) | 72  288x320 bins ( 46  rendered) |  2.65 ms | 94  stages : Binning : 0.127ms Render : 1.945ms StoreColor : 0.336ms Blit : 0.004ms

This contribution is funded by Fern Solutions

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
673.3 kB (166.9 kB) 673.4 kB (166.9 kB) +133 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
453 kB (109.4 kB) 453.1 kB (109.4 kB) +133 B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants