Closed Bug 1799402 Opened 3 months ago Closed 3 months ago

Add GPU acceleration of path rasterization for accelerated Canvas2D

Categories

(Core :: Graphics: Canvas2D, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
108 Branch
Tracking Status
firefox108 --- fixed

People

(Reporter: lsalzman, Assigned: lsalzman)

References

(Blocks 1 open bug, Regressed 1 open bug)

Details

Attachments

(3 files)

We want to use wpf-gpu-raster (https://github.com/FirefoxGraphics/wpf-gpu-raster) to add GPU acceleration of path rasterization to accelerated Canvas2D. Currently we rasterize paths in software and then upload them in a texture. In situations where the path has a lot of empty/filled interior and we have to regenerate it frequently, software rasterization can bog down quickly. GPU acceleration would allow us to do better in this case.

This adds the wpf-gpu-raster Rust crate so we can use it for the accelerated
Canvas2D project.

This adds a path vertex buffer where triangle list output from WGR is stored.
Each PathCacheEntry can potentially reference a range of vertexes in this buffer
corresponding to triangles for that entry. When this buffer is full, it gets
orphaned and clears corresponding cache entries, so that it can start anew.

Depends on D161478

Pushed by lsalzman@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9cfa7581565e
Vendor wpf-gpu-raster Rust crate. r=jrmuizel,supply-chain-reviewers
https://hg.mozilla.org/integration/autoland/rev/3ff660b475ff
Add header for accessing WGR Rust crate from C++. r=jrmuizel
https://hg.mozilla.org/integration/autoland/rev/e51cd76008ef
Use WGR to rasterize paths in DrawTargetWebgl. r=jrmuizel

Backed out for causing windows build bustages. Later, this also happened for Android 4.1 x86 opt.

Push with failures

Failure log

Backout link

[task 2022-11-12T06:22:20.180Z] 06:22:20     INFO -  [glslopt 0.1.9] cargo:warning=In file included from glsl-optimizer/src/compiler/glsl/glsl_parser_extras.cpp:41:
[task 2022-11-12T06:22:20.180Z] 06:22:20  WARNING -  [glslopt 0.1.9] cargo:warning=glsl-optimizer/src/compiler/glsl/loop_analysis.h:125:4: warning: builtin __has_trivial_destructor is deprecated; use __is_trivially_destructible instead [-Wdeprecated-builtins]
[task 2022-11-12T06:22:20.180Z] 06:22:20     INFO -  [glslopt 0.1.9] cargo:warning=glsl-optimizer/src/util/ralloc.h:524:4: note: expanded from macro 'DECLARE_RALLOC_CXX_OPERATORS'
[task 2022-11-12T06:22:20.180Z] 06:22:20     INFO -  [glslopt 0.1.9] cargo:warning=   DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE(type, ralloc_size)
[task 2022-11-12T06:22:20.180Z] 06:22:20     INFO -  [glslopt 0.1.9] cargo:warning=   ^
[task 2022-11-12T06:22:20.181Z] 06:22:20     INFO -  [glslopt 0.1.9] cargo:warning=glsl-optimizer/src/util/ralloc.h:518:12: note: expanded from macro 'DECLARE_ALLOC_CXX_OPERATORS_TEMPLATE'
[task 2022-11-12T06:22:20.181Z] 06:22:20     INFO -  [glslopt 0.1.9] cargo:warning=      if (!HAS_TRIVIAL_DESTRUCTOR(TYPE))                                 \
[task 2022-11-12T06:22:20.181Z] 06:22:20     INFO -  [glslopt 0.1.9] cargo:warning=           ^
[task 2022-11-12T06:22:20.181Z] 06:22:20     INFO -  [glslopt 0.1.9] cargo:warning=glsl-optimizer/src/util/macros.h:195:44: note: expanded from macro 'HAS_TRIVIAL_DESTRUCTOR'
[task 2022-11-12T06:22:20.181Z] 06:22:20     INFO -  [glslopt 0.1.9] cargo:warning=#         define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
[task 2022-11-12T06:22:20.181Z] 06:22:20     INFO -  [glslopt 0.1.9] cargo:warning=                                           ^
[task 2022-11-12T06:22:20.181Z] 06:22:20     INFO -  [glslopt 0.1.9] cargo:warning=14 warnings generated.
[task 2022-11-12T06:22:20.181Z] 06:22:20     INFO -  [glslopt 0.1.9] exit status: 0
[task 2022-11-12T06:22:20.182Z] 06:22:20     INFO -  [glslopt 0.1.9] running: "/builds/worker/fetches/sccache/sccache" "/builds/worker/fetches/clang/bin/clang++" "-O1" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=x86_64-unknown-linux-gnu" "--sysroot" "/builds/worker/fetches/sysroot-x86_64-linux-gnu" "-Qunused-arguments" "-std=gnu++17" "-O3" "-DNDEBUG=1" "-DTRIMMED=1" "-I/builds/worker/checkouts/gecko/toolkit/library/gtest/rust" "-I/builds/worker/workspace/obj-build/toolkit/library/gtest/rust" "-I/builds/worker/workspace/obj-build/dist/include" "-DMOZILLA_CONFIG_H" "-I" "glsl-optimizer/include" "-I" "glsl-optimizer/src/mesa" "-I" "glsl-optimizer/src/mapi" "-I" "glsl-optimizer/src/compiler" "-I" "glsl-optimizer/src/compiler/glsl" "-I" "glsl-optimizer/src/gallium/auxiliary" "-I" "glsl-optimizer/src/gallium/include" "-I" "glsl-optimizer/src" "-I" "glsl-optimizer/src/util" "-D__STDC_FORMAT_MACROS" "-D_GNU_SOURCE" "-DHAVE_ENDIAN_H" "-DHAVE_PTHREAD" "-DHAVE_TIMESPEC_GET" "-DMOZ_INCLUDE_MOZALLOC_H" "-Dmozilla_throw_gcc_h" "-o" "/builds/worker/workspace/obj-build/release/build/glslopt-f2b6604f04a18673/out/glsl-optimizer/src/compiler/glsl/glsl_parser.o" "-c" "glsl-optimizer/src/compiler/glsl/glsl_parser.cpp"
[task 2022-11-12T06:22:20.182Z] 06:22:20     INFO -     Compiling cose-c v0.1.5
[task 2022-11-12T06:22:20.182Z] 06:22:20     INFO -     Compiling midir_impl v0.1.0 (/builds/worker/checkouts/gecko/dom/midi/midir_impl)
[task 2022-11-12T06:22:20.183Z] 06:22:20     INFO -       Running `CARGO=/builds/worker/fetches/rustc/bin/cargo CARGO_CRATE_NAME=cosec CARGO_MANIFEST_DIR=/builds/worker/checkouts/gecko/third_party/rust/cose-c CARGO_PKG_AUTHORS='Franziskus Kiefer <franziskuskiefer@gmail.com>' CARGO_PKG_DESCRIPTION='C API for the cose crate' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=MPL-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=cose-c CARGO_PKG_REPOSITORY='https://github.com/franziskuskiefer/cose-c-api' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.5 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=5 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/builds/worker/workspace/obj-build/release/deps:/builds/worker/fetches/rustc/lib' /builds/worker/fetches/sccache/sccache /builds/worker/fetches/rustc/bin/rustc --crate-name cosec /builds/worker/checkouts/gecko/third_party/rust/cose-c/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=2 -C panic=abort -C embed-bitcode=no -C metadata=296b82032869f986 -C extra-filename=-296b82032869f986 --out-dir /builds/worker/workspace/obj-build/i686-pc-windows-msvc/release/deps --target i686-pc-windows-msvc -C linker=/builds/worker/checkouts/gecko/build/cargo-linker -L dependency=/builds/worker/workspace/obj-build/i686-pc-windows-msvc/release/deps -L dependency=/builds/worker/workspace/obj-build/release/deps --extern cose=/builds/worker/workspace/obj-build/i686-pc-windows-msvc/release/deps/libcose-87ad3146b265aa80.rmeta --cap-lints warn -C debuginfo=2 -C force-frame-pointers=yes -C control-flow-guard=yes -Dwarnings -Aproc-macro-back-compat -Cembed-bitcode=yes -C codegen-units=1`
[task 2022-11-12T06:22:20.184Z] 06:22:20     INFO -       Running `CARGO=/builds/worker/fetches/rustc/bin/cargo CARGO_CRATE_NAME=midir_impl CARGO_MANIFEST_DIR=/builds/worker/checkouts/gecko/dom/midi/midir_impl CARGO_PKG_AUTHORS='Gabriele Svelto' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=midir_impl CARGO_PKG_REPOSITORY='' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/builds/worker/workspace/obj-build/release/deps:/builds/worker/fetches/rustc/lib' /builds/worker/fetches/sccache/sccache /builds/worker/fetches/rustc/bin/rustc --crate-name midir_impl --edition=2018 dom/midi/midir_impl/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=2 -C panic=abort -C embed-bitcode=no -C metadata=606ed22f9beb90b2 -C extra-filename=-606ed22f9beb90b2 --out-dir /builds/worker/workspace/obj-build/i686-pc-windows-msvc/release/deps --target i686-pc-windows-msvc -C linker=/builds/worker/checkouts/gecko/build/cargo-linker -L dependency=/builds/worker/workspace/obj-build/i686-pc-windows-msvc/release/deps -L dependency=/builds/worker/workspace/obj-build/release/deps --extern midir=/builds/worker/workspace/obj-build/i686-pc-windows-msvc/release/deps/libmidir-c142c2588cbbd18f.rmeta --extern nsstring=/builds/worker/workspace/obj-build/i686-pc-windows-msvc/release/deps/libnsstring-d5216eda961c588a.rmeta --extern thin_vec=/builds/worker/workspace/obj-build/i686-pc-windows-msvc/release/deps/libthin_vec-e2fe05670b990c88.rmeta --extern uuid=/builds/worker/workspace/obj-build/i686-pc-windows-msvc/release/deps/libuuid-85ea55bac4a60604.rmeta -C debuginfo=2 -C force-frame-pointers=yes -C control-flow-guard=yes -Dwarnings -Aproc-macro-back-compat -Cembed-bitcode=yes -C codegen-units=1`
[task 2022-11-12T06:22:20.184Z] 06:22:20    ERROR -  error[E0432]: unresolved import `std::arch::x86_64`
[task 2022-11-12T06:22:20.185Z] 06:22:20     INFO -    --> /builds/worker/checkouts/gecko/third_party/rust/wpf-gpu-raster/src/real.rs:12:28
[task 2022-11-12T06:22:20.185Z] 06:22:20     INFO -     |
[task 2022-11-12T06:22:20.185Z] 06:22:20     INFO -  12 | ...   use std::arch::x86_64::{__m128, _mm_set_ss, _mm_cvtss_si32, _mm_cvtsi32_ss, _mm_sub_ss, _mm_cmple_ss, _mm_store_ss, _mm_setzero_ps};
[task 2022-11-12T06:22:20.185Z] 06:22:20     INFO -     |                      ^^^^^^ could not find `x86_64` in `arch`
[task 2022-11-12T06:22:20.185Z] 06:22:20     INFO -  warning: ignoring -C extra-filename flag due to -o flag
[task 2022-11-12T06:22:20.185Z] 06:22:20     INFO -  For more information about this error, try `rustc --explain E0432`.
[task 2022-11-12T06:22:20.185Z] 06:22:20     INFO -  warning: `wpf-gpu-raster` (lib) generated 1 warning
[task 2022-11-12T06:22:20.185Z] 06:22:20     INFO -  error: could not compile `wpf-gpu-raster` due to previous error; 1 warning emitted
[task 2022-11-12T06:22:20.185Z] 06:22:20     INFO -  Caused by:
[task 2022-11-12T06:22:20.186Z] 06:22:20     INFO -    process didn't exit successfully: `CARGO=/builds/worker/fetches/rustc/bin/cargo CARGO_CRATE_NAME=wpf_gpu_raster CARGO_MANIFEST_DIR=/builds/worker/checkouts/gecko/third_party/rust/wpf-gpu-raster CARGO_PKG_AUTHORS='' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=MIT CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=wpf-gpu-raster CARGO_PKG_REPOSITORY='' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/builds/worker/workspace/obj-build/release/deps:/builds/worker/fetches/rustc/lib' /builds/worker/fetches/sccache/sccache /builds/worker/fetches/rustc/bin/rustc --crate-name wpf_gpu_raster --edition=2021 /builds/worker/checkouts/gecko/third_party/rust/wpf-gpu-raster/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=2 -C panic=abort -C embed-bitcode=no --cfg 'feature="c_bindings"' --cfg 'feature="default"' -C metadata=4c6c978ce9854863 -C extra-filename=-4c6c978ce9854863 --out-dir /builds/worker/workspace/obj-build/i686-pc-windows-msvc/release/deps --target i686-pc-windows-msvc -C linker=/builds/worker/checkouts/gecko/build/cargo-linker -L dependency=/builds/worker/workspace/obj-build/i686-pc-windows-msvc/release/deps -L dependency=/builds/worker/workspace/obj-build/release/deps --extern typed_arena_nomut=/builds/worker/workspace/obj-build/i686-pc-windows-msvc/release/deps/libtyped_arena_nomut-b8c88a5e91d42a80.rmeta --cap-lints warn -C debuginfo=2 -C force-frame-pointers=yes -C control-flow-guard=yes -Dwarnings -Aproc-macro-back-compat -Cembed-bitcode=yes -C codegen-units=1` (exit status: 1)
[task 2022-11-12T06:22:20.186Z] 06:22:20     INFO -  warning: build failed, waiting for other jobs to finish...
[task 2022-11-12T06:22:20.186Z] 06:22:20     INFO -  warning: unused return value of `Box::<T>::from_raw` that must be used
[task 2022-11-12T06:22:20.186Z] 06:22:20     INFO -    --> /builds/worker/checkouts/gecko/third_party/rust/mapped_hyph/src/ffi.rs:72:5
[task 2022-11-12T06:22:20.186Z] 06:22:20     INFO -     |
<...>
Flags: needinfo?(lsalzman)
Pushed by lsalzman@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c7929716f859
Vendor wpf-gpu-raster Rust crate. r=jrmuizel,supply-chain-reviewers
https://hg.mozilla.org/integration/autoland/rev/b7497066ee4a
Add header for accessing WGR Rust crate from C++. r=jrmuizel
https://hg.mozilla.org/integration/autoland/rev/4245b2413dcc
Use WGR to rasterize paths in DrawTargetWebgl. r=jrmuizel
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 108 Branch
Regressions: 1800363
Flags: needinfo?(lsalzman)

(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #8)

Did this regress MotionMark Animometer?

https://treeherder.mozilla.org/perfherder/graphs?highlightAlerts=1&highlightChangelogData=1&highlightCommonAlerts=0&series=autoland,3923540,1,13&timerange=604800

https://arewefastyet.com/linux64/benchmarks/overview?numDays=60
https://arewefastyet.com/mac/benchmarks/overview?numDays=60

The profile does not show any time being spent in Canvas2D of note, so superficially this bug does not seem like the cause.

(In reply to Lee Salzman [:lsalzman] from comment #9)

The profile does not show any time being spent in Canvas2D of note, so superficially this bug does not seem like the cause.

The profile only includes time being spent in the "Multiply" test.

Here's the comparison:
https://treeherder.mozilla.org/perfherder/comparesubtest?originalProject=autoland&newProject=autoland&originalRevision=88ff674216266947f95c594f8598b9f4f88537b9&newRevision=4245b2413dcc4cd27fe3a16b1af01d557ac934cd&originalSignature=3923540&newSignature=3923540&framework=13&page=1

It is just that both times when the regression happened, perfherder points to this bug. And then it un-regressed for a short while
in https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=e51cd76008ef273e01c4b9c30c16d061e5955f13&tochange=c671a799829d029e89c7aa4a4f5a59b425ad2e58

We seem to regress the "Paths" sub test a lot. This is not that surprising. Implementing bug 1800570 would help.

Regressions: 1801731
Regressions: 1800471
You need to log in before you can comment on or make changes to this bug.