Skip to content

fix(webgpu): Let image sampling use the mip chain - #25584

Merged
ramezgerges merged 2 commits into
unoplatform:masterfrom
ramezgerges:dev/rara/webgpu-sampler-mips
Oct 27, 2026
Merged

ramezgerges merged 2 commits into
unoplatform:masterfrom
ramezgerges:dev/rara/webgpu-sampler-mips

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25583

PR Type:

🐞 Bugfix

What changed? 🚀

The WebGPU image sampler was created from a zero-initialised WGPUSamplerDescriptor that never set LodMaxClamp, so every lookup was clamped to mip level 0. Images do upload a full mip chain, but a downscaled image was always read from its full-resolution level. It aliased, and its GPU cost tracked the texture size instead of the pixels it covered: a 1050² photo cost the same at 23k pixels as at 47k.

This sets LodMinClamp = 0 and LodMaxClamp = 32 (WebGPU's defaults) on that descriptor. The 16 tiled-image samplers copy it, so every image draw is covered. The present-blit sampler in Uno.UI.Composition.WebGpu.Init samples a single-level texture and is unaffected.

Validation

  • Runtime, desktop: a 256×256 image of 1 px black/white columns shown at 30×30.

    • Before: the rendered row ranges from 9 to 246, aliased.
    • After: flat mid-grey.

    That check isn't included as a test: the Skia backend aliases the same way (it samples images with SKFilterMode.Linear and no mipmap mode), which is a separate change.

  • RenderDoc, desktop Vulkan, Chefs home page:

    • image draws 3.96 → 2.7 ns per pixel;
    • the image pipeline's GPU time down ~48%;
    • forcing a coarser mip bias now changes the output, where before it produced byte-identical frames (mips unused).
  • Browser, Chefs home page (UHD 620, Chrome, fixed CPU clock, 120 Hz, full repaint): 104.5 → 115.5 fps.

  • Downscaled images now look different: properly filtered instead of aliased.

PR Checklist ✅

🤖 Generated with Claude Code

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 240241 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • DisplayInformation.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • Examples.png
    • Focus_FocusVisual_Properties.png-dark
  • skia-windows-screenshots: 2458 changed over 2488

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png
    • AnimatedIconPage.png
    • AppBarButtonTest.png
    • AppBar_KeyBoard.png-dark
    • ApplicationViewSizing.png-dark
    • AppWindowFeatures.png-dark
    • AppWindowPresenters.png-dark
    • ArcSegment.png
    • AuthenticationBroker_Demo.png-dark
    • AuthenticationBroker_Demo.png
    • AutomationProperties_AutomationId.png-dark
    • AutomationProperties_AutomationId.png
    • AutoSizedPathCentered.png-dark
    • AutoSizedPathCentered.png
    • AutoSuggestBox_Icons.png-dark
    • AutoSuggestBox_Icons.png
    • BasicEnability.png-dark
    • BasicEnability.png
    • BindableDrawerLayout_ChangePane.png-dark
    • BindableDrawerLayout_ChangePane.png

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 240241 has failed on Uno.UI - CI.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 240354 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • ClipboardTests.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • DropDownButtonPage.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • DisplayInformation.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • ImageBrushAlignmentXY.png-dark
    • ImageBrushAlignmentXY.png
    • ElementLevelTheme.png-dark
  • skia-windows-screenshots: 2458 changed over 2488

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AppBarButtonWithIconTest.png
    • ApplicationViewSizing.png
    • AppWindowPositionAndSize.png-dark
    • AppXamlDefinedResources.png
    • Attributed_text_Supserscript.png
    • AutoBorderStretchwithleftmargin.png-dark
    • AutomationPropertiesExtensions_Role.png-dark
    • AutoSuggestBoxChosenSuggestion.png-dark
    • AutoSuggestBoxChosenSuggestion.png
    • AutoSuggestBox_SoftKeboard.png-dark
    • AutoSuggestBox_SoftKeboard.png
    • Basics.png-dark
    • Basics.png
    • BeginTime_MultipleAnimations.png-dark
    • BeginTime_MultipleAnimations.png
    • BitmapIcon_Foreground.png-dark
    • BitmapIcon_Foreground.png
    • BorderImageBrush.png-dark
    • BorderImageBrush.png

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 241275 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • DynamicFont.png-dark
    • DynamicFont.png
    • Examples.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • DisplayInformation.png-dark
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • ElementLevelTheme.png-dark
  • skia-windows-screenshots: 2458 changed over 2490

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png-dark
    • AndroidWindowInsets.png-dark
    • AnimatedBackVisualSourceSamplePage.png
    • AnimatedIconPage.png-dark
    • AppBarToggleButtonTest.png
    • AnimatedVisualsTestbedPage.png
    • AppBarButtonWithIconTest.png
    • AppBarButtonTest.png-dark
    • Application_DispatcherShutdownMode.png-dark
    • ApplicationViewSizing.png
    • ApplicationViewSizing.png-dark
    • AppBarToggleButtonTest.png-dark
    • AppWindowPositionAndSize.png
    • AppWindowFeatures.png
    • AppWindowPresenters.png
    • ApplicationViewSpanningRectsPage.png
    • Attributed_text_FontSize_Changing.png-dark
    • AppXamlDefinedResources.png
    • Attributed_text_FontSize_Changing.png
    • AppWindowPositionAndSize.png-dark

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 241275 has failed on Uno.UI - CI.

ramezgerges and others added 2 commits October 26, 2026 12:37
The image sampler was built from a zero-initialised descriptor that never
set LodMaxClamp, so it clamped every lookup to level 0. Images upload a
full mip chain, but a downscaled one was always read from its full-size
level: it aliased, and on a large photo every pixel strode across the
whole texture, so the draw cost tracked the texture size instead of the
pixels it covered.

The clamps are now WebGPU's defaults. On the Chefs home page (1050 px
photos shown at about 330 px; UHD 620, fixed clock, 120 Hz) the image
draws' GPU time drops by about half, and the page in the browser goes
from 104.5 to 115.5 fps.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
When_Parent_Has_BorderThickness draws a 500x200 image of colour bands
into 60x60 and pinned each band's exact pixel bounds. With the WebGPU
sampler now using the mip chain, the pixel on an edge between two bands
blends them, so a band can lose a pixel on each side it shares with
another colour (native WinUI shifts them the same way). Each edge is now
checked within one pixel; the 20px border offset the test is about is
still verified.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@ramezgerges
ramezgerges force-pushed the dev/rara/webgpu-sampler-mips branch from b23959b to ea7d522 Compare October 26, 2026 16:37
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 241454 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • DisplayInformation.png-dark
    • Examples.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • DropDownButtonPage.png-dark
    • ImageIconPage.png-dark
    • ImageIconPage.png
  • skia-windows-screenshots: 2458 changed over 2490

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png-dark
    • AnimatedVisualsTestbedPage.png
    • AppBarToggleButtonTest.png-dark
    • ApplicationViewSizing.png-dark
    • Application_DispatcherShutdownMode.png-dark
    • AppWindowPresenters.png-dark
    • ArcSegment.png
    • Attributed_text_Supserscript.png
    • AutoBorderStretchwithbottommargin.png-dark
    • AutoBorderStretchwithbottommargin.png
    • AutomationProperties_AutomationId.png
    • AutomationProperties_Landmark.png-dark
    • AutoSuggestBoxChosenSuggestion.png
    • AutoSuggestBox_BitmapIcon.png-dark
    • BackGesture.png-dark
    • BackGesture.png
    • Basics Pivot Test.png-dark
    • Basics Pivot Test.png
    • BeginTime_MultipleAnimations.png-dark
    • BeginTime_MultipleAnimations.png

@ramezgerges
ramezgerges enabled auto-merge October 27, 2026 00:49
@ajpinedam ajpinedam added the 7.0 PRs only. For issues, use the Release field. label Oct 27, 2026
@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@ramezgerges
ramezgerges merged commit 797cf2e into unoplatform:master Oct 27, 2026
46 checks passed
@ramezgerges
ramezgerges deleted the dev/rara/webgpu-sampler-mips branch October 27, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.0 PRs only. For issues, use the Release field.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebGPU: downscaled images ignore their mip chain (sampler LodMaxClamp is 0)

5 participants