Skip to content

Implement Gouraud-based shading using WebGPU.#20885

Merged
calixteman merged 1 commit intomozilla:masterfrom
calixteman:gouraud_gpu
Mar 21, 2026
Merged

Implement Gouraud-based shading using WebGPU.#20885
calixteman merged 1 commit intomozilla:masterfrom
calixteman:gouraud_gpu

Conversation

@calixteman
Copy link
Contributor

The WebGPU feature hasn't been released yet but it's interesting to see how we can use it in order to speed up the rendering of some objects.
This patch allows to render mesh patterns using WebGPU.

I didn't see any significant performance improvement on my machine (mac M2) but it may be different on other platforms.

@codecov-commenter
Copy link

codecov-commenter commented Mar 15, 2026

Codecov Report

❌ Patch coverage is 31.27660% with 323 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.62%. Comparing base (ab228da) to head (86441e9).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
src/display/webgpu_mesh.js 34.81% 249 Missing ⚠️
src/display/pattern_helper.js 2.12% 46 Missing ⚠️
src/core/pattern.js 0.00% 14 Missing ⚠️
src/core/pdf_manager.js 42.85% 8 Missing ⚠️
src/display/api.js 60.00% 4 Missing ⚠️
src/core/evaluator.js 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20885      +/-   ##
==========================================
- Coverage   62.72%   62.62%   -0.10%     
==========================================
  Files         173      174       +1     
  Lines      121500   121930     +430     
==========================================
+ Hits        76205    76353     +148     
- Misses      45295    45577     +282     
Flag Coverage Δ
fonttest 7.66% <ø> (ø)
unittestcli 62.59% <31.27%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@calixteman
Copy link
Contributor Author

And FYI, I've in mind to implement the function-based shading, when it's possible, in using WebGPU api.

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Mar 15, 2026

A couple of quick observations/questions:

  • What's the performance impact of running the init code unconditionally, since most PDFs probably don't have shadings of that type?
  • This really should be an API (i.e. getDocument) option instead, such that it's generally available and not limited to just the viewer.

@timvandermeij
Copy link
Contributor

/botio-linux preview

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.241.84.105:8877/313b63316afb1e9/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/313b63316afb1e9/output.txt

Total script time: 1.93 mins

Published

Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me, with the comment addressed. Let's see how this goes; thanks!

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me, with comment addressed.

The WebGPU feature hasn't been released yet but it's interesting to see how
we can use it in order to speed up the rendering of some objects.
This patch allows to render mesh patterns using WebGPU.

I didn't see any significant performance improvement on my machine (mac M2)
but it may be different on other platforms.
@calixteman calixteman merged commit 918a319 into mozilla:master Mar 21, 2026
15 checks passed
@calixteman calixteman deleted the gouraud_gpu branch March 21, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants