Skip to content

Fix backdrop-filter: blur generating excessive mipmap levels (#10340)#10370

Closed
Infiland wants to merge 1 commit intoFacepunch:masterfrom
Infiland:issue-10340
Closed

Fix backdrop-filter: blur generating excessive mipmap levels (#10340)#10370
Infiland wants to merge 1 commit intoFacepunch:masterfrom
Infiland:issue-10340

Conversation

@Infiland
Copy link
Copy Markdown
Contributor

@Infiland Infiland commented Apr 5, 2026

Summary

Backdrop-filter blur panels were generating the full mipmap chain (~11 levels) regardless of the actual blur amount needed. The shader only samples at MIP level sqrt(BlurScale / 2) (typically 2-5 for normal values), so most compute dispatches were wasted. This change limits mipmap generation to only the levels the shader will actually sample, and skips it entirely when no blur is applied (e.g. backdrop-filter: brightness only).

Motivation & Context

Since version 26.04.01, panels with backdrop-filter: blur cause significant FPS drops around 50%. Each backdrop panel triggers a full framebuffer copy + Gaussian blur compute shader dispatch and GPU barrier for every mip level. With ~11 levels generated but only 2-5 needed

Fixes: #10340

Implementation Details

  • Graphics.GrabFrameTexture: Added optional maxMips parameter (default 0 = all mips for backward compatibility). When maxMips > 0, the render target is created with fewer mip levels, so GenerateMipMaps naturally processes fewer levels.
  • CommandList.Attributes.GrabFrameTexture: Threads maxMips through the deferred command system via the unused Data1.y component, following the existing float-to-int packing convention.
  • PanelRenderer.Backdrop.cs: Computes needed mip count as ceil(sqrt(blurScale / 2)) + 2 (+2 for trilinear filtering safety margin). Rounds up to even for render target pool stability. Uses DownsampleMethod.None when blur is 0.

Existing callers (Bloom, SSR, Highlight, BasePostProcess) are unaffected by the default maxMips = 0.

Screenshots / Videos (if applicable)

</>

Checklist

  • Code follows existing style and conventions
  • No unnecessary formatting or unrelated changes
  • Public APIs are documented (if applicable)
  • Unit tests added where applicable and all passing
  • I’m okay with this PR being rejected or requested to change 🙂

…ch#10340)

The backdrop blur shader samples at MIP level sqrt(BlurScale / 2), which
is typically 2-5 for normal blur values, but GrabFrameTexture was always
generating the full mipmap chain (~11 levels). Each level requires a
Gaussian blur compute shader dispatch and GPU barrier.

Now only the mip levels the shader will actually sample are generated.
When no blur is applied (e.g. backdrop-filter: brightness only), mipmap
generation is skipped entirely.
@handsomematt handsomematt added the triaged triaged pull-requests are replicated on the internal sbox repo label Apr 5, 2026
@sboxbot sboxbot added the accepted this pull request was accepted, hurrah! label Apr 7, 2026
@sboxbot
Copy link
Copy Markdown
Contributor

sboxbot commented Apr 7, 2026

This PR has been merged upstream.

@sboxbot sboxbot closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted this pull request was accepted, hurrah! triaged triaged pull-requests are replicated on the internal sbox repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

backdrop-filter: blur drains 50% of FPS

3 participants