Closed Bug 2081590 Opened 1 month ago Closed 1 month ago

Combine accelerated Canvas2D solid-color and image/mask draws in the image shader program

Categories

(Core :: Graphics: Canvas2D, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: perf-ai-bot, Assigned: lsalzman)

References

(Blocks 1 open bug)

Details

(Whiteboard: [foofrix:279efb95-81e8-4e86-a73c-0d4afcbd5923])

Attachments

(1 external file, 1 obsolete file)

Combine accelerated Canvas2D solid-color and image/mask draws in the image shader program. A negative swizzle selects solid mode, bypassing the image-sampling branch and preserving the previous solid fragment calculation algebraically; image and A8-mask modes retain their existing swizzle calculation. UseImageProgram caches program selection and sampler/swizzle uniforms, directing the unused image sampler to the clip-mask texture unit during solid draws to avoid feedback validation against a render target bound on unit 0. DrawRectAccel and DrawStrokeMask share the image uniform cache, and the separate solid program is removed. Solid draws still execute the image vertex shader's texture-coordinate calculations. Supplied NVIDIA/Linux comparisons report approximately 0.33% and 1.165% end-to-end gains, with score granularity comparable to the smaller effect. These measurements and the reported pixel/test results were not independently reproduced in this audit; they do not establish cross-driver performance or bit-identical rendering.

Problem

Alternating eligible solid-color and image/mask draws previously switched between separate WebGL programs. Supplied NVIDIA/Linux profiles attribute substantial driver time to those switches. Sharing the program removes these transitions while retaining separate blur and filter programs. The tradeoff includes sampler/swizzle updates, potentially more updates to other shared uniforms, and additional shader and sampler-validation work for solids. The net benefit depends on workload and driver.

Performance

  • Benchmark: speedometer4-scrollytelling-scrollama
  • Test: sp4-scrollytelling-scrollama
  • Component: Graphics
  • Local Improvement: 0.33%

Validation

Blocks: speedometer3

Please move this bug to the correct component.

Once the Phabricator patch is ready for review, please commandeer it.

Flags: needinfo?(lsalzman)
Flags: needinfo?(lsalzman)
Summary: Combine accelerated Canvas2D solid-color and image/mask draws in the image shader program. A negative swizzle selects solid mode, bypassing the image-sampling branch and preserving the previous solid fragment calculation algebraically; image and A8-mask m → Combine accelerated Canvas2D solid-color and image/mask draws in the image shader program
Severity: -- → N/A
Type: defect → enhancement
Component: Performance: Automated Findings → Graphics: Canvas2D

Combine accelerated Canvas2D solid-color and image/mask draws in the image shader program. A negative swizzle selects solid mode, bypassing the image-sampling branch and preserving the previous solid fragment calculation algebraically; image and A8-mask m

Attachment #9659171 - Attachment is obsolete: true

Foofrix suggests that the costs of switching shaders between a solid color program and an
image program in mixed workloads leads to a much higher cost switching changes than the
small instruction saving of the solid color program versus the image program can compensate
for.

Overall, we are better off combining them into one program with a uniform branch to toggle
sampling from the image texture. This also results in a substantial reduction in the amount
of shader program code.

Assignee: nobody → lsalzman
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
QA Whiteboard: [qa-triage-done-c161/b160]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: