Merge main into fix/title-bar-controls-13577

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
David MannandClaude Opus 5.5 committed 2026-11-18 23:07:17 +01:00
commit 6cbcdc0ad4
154 files changed
+3507 -2584

No files matched your search

+12
View File
@@ -1,2 +1,14 @@
[alias]
xtask = "run -p xtask --"
# wgpu's GL backend (glutin_wgl_sys) imports opengl32.dll, so every binary that links wgpu loads
# it at start, and a process that has loaded it takes about 60 ms longer to exit (#15444): every
# test process and every app exit on DX12 or Vulkan. Delay-loaded, it loads on the first WGL
# call, which only the GL backend makes. Here rather than in a build script, because a link
# argument from a build script reaches only its own package's binaries, and every package whose
# binaries link wgpu would need one. Cargo joins these with `CARGO_TARGET_<triple>_RUSTFLAGS`
# (CI, packaging); only `RUSTFLAGS` replaces them. The print DLLs' delay-loads stay in the app's
# and CLI's build.rs: without those the exe doesn't start on some Windows images (#5884), so
# they must hold for any cargo invocation, also one that never reads this file.
[target.'cfg(all(windows, target_env = "msvc"))']
rustflags = ["-Clink-arg=/DELAYLOAD:opengl32.dll", "-Clink-arg=delayimp.lib"]
+18 -13
View File
@@ -11,12 +11,19 @@ nextest-version = "0.9.150"
#
# GPU tests: each test is its own process here, so the in-process `gpu_lock()` mutexes no longer
# serialize them. Too many concurrent wgpu devices time out (`PollError: ... Wait timed out`), so
# this group caps them at 4. scripts/ci-gpu-lavapipe.py reads this group's filters directly.
# this group caps them at 4. `cargo xtask ci tests --gpu` reads this group's filters directly: the
# Linux gate runs the group in a shard of its own on lavapipe (scripts/ci-gpu-lavapipe.py).
#
# The group is photocraft-gpu and every test in a module named `gpu_tests` or `<name>_gpu_tests`.
# A test that builds a wgpu device (a kittest `.wgpu()` harness, `create_render_state`, its own
# instance, or a harness `.render()`) lives in such a module and takes `gpu_lock()`. Every other
# test runs on the CPU canvas (the app draws on it unless `set_wgpu` hands it a device) at full
# parallelism.
[test-groups]
gpu = { max-threads = 4 }
[[profile.default.overrides]]
filter = 'package(photocraft-gpu) | (package(photocraft-ui-egui) & (kind(test) | test(/canvas|gpu|mip|type_tool|background_redraw::|floating_group_titles|swap_arrow::tests::rendered_glyph/))) | (package(photocraft-automation) & test(/^gpu_backend::/))'
filter = 'package(photocraft-gpu) | test(/(^|::|_)gpu_tests::/)'
test-group = 'gpu'
# CI (`--profile ci`, .github/workflows/ci.yml). Collect all failures in one integration run
@@ -48,11 +55,10 @@ threads-required = 2
# Slowest tests start first. nextest starts higher-priority tests first, so a long test no longer
# begins at the end of the run and extends the job. Every test that took over 60 s on the Windows
# runner in the cold run of #15474 (unit and integration legs); the list names the test, so a test
# that gets faster stays harmless and a new slow one is added here. Priority only orders the
# start; it changes no timeout, group or result.
# runner in the cold run of #15474 (unit and integration legs); the same tests are the slowest on
# Linux. The list names the test, so a test that gets faster stays harmless and a new slow one is
# added here. Priority only orders the start; it changes no timeout, group or result.
[[profile.ci.overrides]]
platform = 'cfg(target_os = "windows")'
# over 200 s
filter = '''
(package(photocraft-ui-egui) & test(=input::shortcut_dispatch::tests::every_displayed_shortcut_dispatches_from_where_focus_usually_is)) |
@@ -64,7 +70,6 @@ filter = '''
priority = 100
[[profile.ci.overrides]]
platform = 'cfg(target_os = "windows")'
# 60 to 200 s
filter = '''
(package(photocraft-gpu) & test(=camera_raw::clarity_texture_and_dehaze_with_shadows_highlights_and_per_pixel_stages)) |
@@ -72,16 +77,16 @@ filter = '''
(package(photocraft-engine) & test(=crop_content_aware_layers::unmeasured_active_targets_and_delete_off_keep_the_legacy_target)) |
(package(photocraft-engine) & test(=cmd::retouch_cmds::content_aware_move::color_tests::a_flat_patch_matches_the_new_surroundings_at_color_ten)) |
(package(photocraft-ui-egui) & test(=tools::type_tool::canvas_tests::every_paragraph_box_handle_resizes_the_box_with_snapping_on)) |
(package(photocraft-ui-egui) & test(=checker_canvas::pixel_grid_is_solid_and_visible_gpu_2x)) |
(package(photocraft-ui-egui) & test(=gpu_tests::checker_canvas::pixel_grid_is_solid_and_visible_gpu_2x)) |
(package(photocraft-engine) & test(=cmd::retouch_cmds::tests::content_aware_move_coarse_preview_handles_transform_extend_and_limits)) |
(package(photocraft-ui-egui) & test(=checker_canvas::pixel_grid_is_solid_and_visible_cpu_2x)) |
(package(photocraft-ui-egui) & test(=drag_preview_canvas::marquee_previews_show_while_dragging_on_white_and_black_at_1x_and_2x)) |
(package(photocraft-ui-egui) & test(=gpu_tests::checker_canvas::pixel_grid_is_solid_and_visible_cpu_2x)) |
(package(photocraft-ui-egui) & test(=gpu_tests::drag_preview_canvas::marquee_previews_show_while_dragging_on_white_and_black_at_1x_and_2x)) |
(package(photocraft-gpu) & test(=camera_raw::shadows_and_highlights_with_per_pixel_stages)) |
(package(photocraft-engine) & test(=cmd::retouch_cmds::content_aware_move::color_tests::a_brightness_change_shifts_the_middle_only_past_color_five)) |
(package(photocraft-engine) & test(=cmd::retouch_cmds::tests::content_aware_move_previews_large_selections_coarse_then_exact_at_all_depths)) |
(package(photocraft-ui-egui) & test(=live_stroke_canvas::live_tool_camera_navigation_is_visible_in_the_input_frame)) |
(package(photocraft-ui-egui) & test(=live_stroke_canvas::the_canvas_shows_the_committed_stroke_part_0)) |
(package(photocraft-ui-egui) & test(=full_res_preview::adjustment_layer_drag_previews_at_full_resolution_when_low_res_is_off)) |
(package(photocraft-ui-egui) & test(=gpu_tests::live_stroke_canvas::live_tool_camera_navigation_is_visible_in_the_input_frame)) |
(package(photocraft-ui-egui) & test(=gpu_tests::live_stroke_canvas::the_canvas_shows_the_committed_stroke_part_0)) |
(package(photocraft-ui-egui) & test(=gpu_tests::full_res_preview::adjustment_layer_drag_previews_at_full_resolution_when_low_res_is_off)) |
(package(photocraft-ui-egui) & test(=input::hold_keys::tests::cmd_gives_the_move_tool_only_where_the_tool_does_not_take_cmd)) |
(package(photocraft-ui-egui) & test(=guide_cursor_tests::command_over_a_guide_takes_it_where_command_is_the_move_tool)) |
(package(photocraft-gpu) & test(=parity::documents_larger_than_the_texture_limit)) |
+86 -213
View File
@@ -1,8 +1,8 @@
name: CI
# Quality gates for every push to main and every pull request. The Linux gate runs through the
# suite's shared gate workflow in craft-common-actions (`cargo xtask ci`); the Windows legs, the
# test variant and the corpus, web and fuzz jobs are PhotoCraft's own.
# Quality gates for every push to main and every pull request. The Linux and Windows tests run
# through the suite's shared gate workflow in craft-common-actions (`cargo xtask ci`, split over the
# gate's jobs); the test variant and the corpus, web and fuzz jobs are PhotoCraft's own.
on:
push:
branches: [main]
@@ -128,17 +128,30 @@ jobs:
else
echo "web=false" >> "$GITHUB_OUTPUT"
fi
if git diff --name-only "$BASE" HEAD | grep -Eq '^(apps/|crates/(ui-egui|text|gpu|tablet|heif|format)/|Cargo\.lock$|craft-i18n\.rev$|(.*/)?build\.rs$|\.github/workflows/ci\.yml$)'; then
if git diff --name-only "$BASE" HEAD | grep -Eq '^(apps/|crates/(ui-egui|text|gpu|tablet|heif|format)/|Cargo\.lock$|craft-i18n\.rev$|(.*/)?build\.rs$|\.cargo/config\.toml$|\.config/nextest\.toml$|xtask/|scripts/ci-test-shard\.sh$|\.github/workflows/ci\.yml$)'; then
echo "windows=true" >> "$GITHUB_OUTPUT"
else
echo "windows=false" >> "$GITHUB_OUTPUT"
fi
gpu=$(python3 scripts/ci-windows-gpu-tests.py "$BASE")
echo "windows_gpu=$gpu" >> "$GITHUB_OUTPUT"
if [ "$gpu" = false ]; then
echo "::notice::photocraft-gpu's tests are skipped on Windows: this pull request changes nothing they are built from (the Linux gate still runs them)."
fi
skip=$(python3 scripts/ci-windows-gpu-tests.py --skip-neutral "$BASE")
echo "windows_skip=$skip" >> "$GITHUB_OUTPUT"
if [ -n "$skip" ]; then
echo "::notice::Tests of platform-neutral packages the pull request does not reach are skipped on Windows (the Linux gate still runs them): $skip"
fi
# The Linux gate. Its rust-cache entry is the one `test (without heif)` restores.
# The Linux gate (craft-common-actions gate.yml). Its `lint` leg runs the checks that need no test
# build; four test shards each build the tests from the restored cache and run their share
# (scripts/ci-test-shard.sh). Shard 1 runs nextest's `gpu` group alone, on lavapipe, and fails on
# a skipped GPU comparison (scripts/ci-gpu-lavapipe.py); shards 2-4 split the other tests, and
# shard 2 runs the doctests. The `gpu` group is ~2400 test-seconds on 4 slots (~12 min with its
# slowest test, ~8 once the five slow UI tests are fixed); the other ~5900 test-seconds over 3
# shards are ~8 min each, so a fifth shard would not shorten the gate. Its rust-cache entry is
# the one `test (without heif)` restores.
gate:
if: github.event.action != 'labeled' || github.event.label.name == 'full-ci'
# Tracks @main so suite-wide CI fixes reach every app without a PR in each repository.
@@ -153,199 +166,70 @@ jobs:
craft-fonts-ref: cc9269cd8d8258785dac603fba3122e5d2556795
# Cargo.toml's dev profile already keeps line tables only.
dev-debug: ""
cache-version: v2
env: |
PHOTOCRAFT_FULL_SWEEP=${{ inputs.full_sweep && '1' || '0' }}
PHOTOCRAFT_NO_PRINT=1
LPDEST=photocraft-no-such-printer
timeout-minutes: 100
# On main, a `cache warm` leg builds the tests and saves the dependency cache as soon as the
# build succeeds; the gate legs then only restore, so a failing test cannot keep the entry
# from being saved (craft-common-actions#270). The same targets as the gate's test step (TEST_TARGETS in xtask/src/main.rs).
warm-command: cargo test --workspace --no-run --locked --features heif --lib --bins --tests
# fmt, clippy, layers, panel-commands, scorecard, tests, panic_hunt, doctests and the wasm32 check, with
# `--locked --features heif`, then the missing-translations report (xtask/src/main.rs).
command: python3 scripts/test-ci-gpu-lavapipe.py && python3 scripts/test-ci-windows-gpu-tests.py && cargo xtask ci && python3 scripts/ci-gpu-lavapipe.py
# On main, a `cache warm` leg builds xtask and the tests, as each shard does, and saves the
# dependency cache as soon as the build succeeds; the shards then only restore, so a failing
# test cannot keep the entry from being saved (craft-common-actions#270). The lint leg keeps
# its own entry.
warm-command: cargo xtask ci build
# fmt, egui-fork, clippy, layers, panel-commands, scorecard, the wasm32 check and the
# missing-translations report (`cargo xtask ci lint`, xtask/src/main.rs), and the CI scripts'
# own tests.
lint-command: python3 scripts/test-ci-gpu-lavapipe.py && python3 scripts/test-ci-windows-gpu-tests.py && cargo xtask ci lint
test-shards: 4
# The tests and panic_hunt with `--locked --features heif` (TEST_TARGETS in xtask/src/main.rs).
shard-command: bash scripts/ci-test-shard.sh --gpu-shard
# Windows tests run as two legs in parallel: the unit tests and the integration tests. As one job
# they took ~28 min on the Windows runner; the legs take ~13 and ~15. Splitting the integration
# tests over a third runner (nextest --partition) saved ~2 min of wall time but cost ~7
# runner-minutes and one more Windows slot per PR. Moving these legs into the shared gate is
# tracked by storytold/craft-common-actions#212.
# The Windows tests and Clippy on the same gate, when `platforms` says the run needs them: a
# `lint` leg runs Clippy, and six shards each build the tests and run their hash partition;
# shard 1 also runs the doctests. Windows runs the tests ~1.75x slower than Linux: ~55 min on
# one runner, ~9 min per shard. A seventh shard would not shorten the slowest one while its
# slowest test alone takes ~9.6 min (the shortcut-dispatch UI test). The browser apps are wasm
# targets, so their native tests are left out;
# pull requests also leave out photocraft-gpu and the platform-neutral packages nothing they change
# reaches (`windows_gpu`, `windows_skip`). The `cache warm` leg (main only) builds what main's
# build job builds.
windows:
needs: platforms
if: needs.platforms.outputs.windows == 'true'
timeout-minutes: 100
name: test (windows-latest, ${{ matrix.part }})
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
# `warm` builds everything the other legs build and saves the dependency cache. Only main
# runs it; the other legs only restore.
part: ${{ fromJSON(github.ref == 'refs/heads/main' && '["unit","integration","clippy","warm"]' || '["unit","integration","clippy"]') }}
env:
# Released sccache expands Cargo's response files and exceeds Windows' rustc spawn limit
# (#13543). Let Cargo handle long commands until a release includes mozilla/sccache#3026.
# The dependency rust-cache below stays enabled; only compiler caching is disabled.
RUSTC_WRAPPER: ""
# Tracks @main so suite-wide CI fixes reach every app without a PR in each repository.
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
with:
os: '["windows-latest"]'
# The all-language UI tests shape real Japanese, Chinese, Korean and Devanagari labels with
# kittest's strict `MissingGlyphPolicy::Panic`, and a hosted Windows image has no guaranteed
# Japanese or Simplified Chinese system font. Same pinned central fonts as Linux and release.
craft-fonts-ref: cc9269cd8d8258785dac603fba3122e5d2556795
# No wasm32 check on Windows: the Linux lint leg runs it.
targets: ""
# No debuginfo on Windows: writing PDBs for ~200 test binaries cost 2.2 of ~21 build minutes.
# A panic still names its file and line; only backtrace frames lose theirs (Linux keeps
# line-tables-only, so a backtrace with lines is one OS away).
CARGO_PROFILE_DEV_DEBUG: "0"
# The Windows compiler command line carries one -L path per built dependency; keep each
# target path short enough for CreateProcess when the graph is large.
CARGO_TARGET_DIR: 'D:\t'
# rust-lld (shipped with the toolchain) links the test binaries instead of link.exe, and the
# test links skip identical-code folding and PDBs. The link arguments in build.rs
# (/DELAYLOAD, delayimp.lib) are lld-link options too.
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: rust-lld
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS: -Clink-arg=/OPT:NOICF -Clink-arg=/DEBUG:NONE
# The all-language UI tests shape real Japanese, Chinese, Korean and Devanagari labels
# with kittest's strict `MissingGlyphPolicy::Panic`. A hosted Windows image has no
# guaranteed Japanese or Simplified Chinese system font, and egui 0.37 panics on a
# missing glyph; the app's lazy system fallback runs after layout, too late for the
# first headless frame. Use the same pinned central fonts as Linux and release, so every
# language is drawn by a real embedded face rather than skipping. Same commit as the gate
# above and release.yml.
CRAFT_FONTS_DIR: ${{ github.workspace }}/craft-fonts
CRAFT_FONTS_REQUIRED: "1"
steps:
- name: Harden runner
uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check out craft-fonts
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: storytold/craft-fonts
ref: cc9269cd8d8258785dac603fba3122e5d2556795
path: craft-fonts
persist-credentials: false
# The translations at the commit in craft-i18n.rev, as the gate and release.yml embed them
# (sets CRAFT_I18N_DIR and CRAFT_I18N_REQUIRED=1).
- name: Check out craft-i18n
uses: storytold/craft-common-actions/actions/checkout-craft-i18n@main
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
components: clippy
# rust-cache only looks at `<workspace>/<target>` (it joins the two), so the short
# CARGO_TARGET_DIR above must be passed as a path relative to the checkout. Without it the
# cache found nothing to restore or save and every run built all dependencies from scratch.
- name: Target directory for the dependency cache
id: cache-target
# An empty path would make rust-cache treat the checkout itself as the target directory,
# which its cleanup then prunes, so stop rather than write one.
run: |
relative=$(realpath -m --relative-to="$(cygpath -u "$GITHUB_WORKSPACE")" "$(cygpath -u "$CARGO_TARGET_DIR")")
if [ -z "$relative" ] || [ "$relative" = . ]; then
echo "::error::no target directory for rust-cache from CARGO_TARGET_DIR='$CARGO_TARGET_DIR'"
exit 1
fi
echo "relative=$relative" >> "$GITHUB_OUTPUT"
shell: bash
# Only main saves caches; PRs restore main's, so the repo's 10 GB cache budget keeps main's.
# All legs share one key (same dependencies). Only the `warm` leg saves it, as soon as the
# build is done and before any test runs, so a failing test never keeps the entry from being
# saved. It also runs Clippy, so the entry holds Clippy's dependency metadata for the `clippy`
# leg. A failed warm run saves nothing: an entry saved from a half-finished build would lack
# dependencies, and rust-cache never replaces an entry with the same key, so every later run
# would restore that half-filled entry until Cargo.lock changes.
# v2.9.1 on purpose: v2.9.2 is an ES-module bundle in which minimatch's `require('path')` fails,
# so it assumes "/" as the path separator and, on Windows, its glob never matches a backslash
# path. The save step then finds no cache paths ("Path Validation Error") and never saves.
# v2.9.1 is the last release with the CommonJS bundle. Move back once a release fixes this.
- uses: step-security/rust-cache@851174d9a2fdc03e0896e02844dcc61d81dd7851 # v2.9.1
with:
workspaces: . -> ${{ steps.cache-target.outputs.relative }}
save-if: ${{ github.ref == 'refs/heads/main' && matrix.part == 'warm' }}
cache-on-failure: false
# Clippy has its own parallel leg: after the test build it ran in the integration leg's
# critical path (#15446).
- name: Clippy
if: matrix.part == 'clippy'
run: cargo clippy --workspace --all-targets --locked --features heif -- -D warnings
- uses: step-security/taiki-e-install-action@76747d22a7567cc4438546a84f11bdf18e670ab8 # v2.87.32
if: matrix.part != 'clippy' && matrix.part != 'warm'
with:
tool: cargo-nextest@0.9.150
# The unit leg runs `--lib --bins` and the integration leg `--test '*'` (every
# integration-test target); the feature selection stays the same, so both legs share the
# dependency cache. photocraft-gpu's tests run when the `platforms` job says they can be
# affected (`windows_gpu`); excluding the package also skips building its test binaries.
- name: Test
if: matrix.part != 'clippy'
env:
PART: ${{ matrix.part }}
GPU: ${{ needs.platforms.outputs.windows_gpu }}
SKIP_NEUTRAL: ${{ needs.platforms.outputs.windows_skip }}
run: |
case "$PART" in
unit) targets=(--lib --bins) ;;
warm) targets=(--lib --bins --test '*') ;;
*) targets=(--test '*') ;;
esac
# The two browser apps are wasm targets; their native test builds check nothing the web job
# (and the Linux gate's wasm32 check) does not. Excluding them changes no other crate's
# features (`cargo tree -e features --workspace` is identical for every other package).
skip=(--exclude photocraft-web --exclude photocraft-web-boot)
# Only an explicit `false` skips them: a missing output runs everything.
if [ "$GPU" = false ]; then
skip+=(--exclude photocraft-gpu)
echo "::notice::photocraft-gpu's tests are skipped on Windows: this pull request changes nothing they are built from (the Linux gate still runs them)."
fi
# nextest reuses this build. The separate step writes cargo's --timings report for it.
# Pull requests without `full-ci` also skip the packages with no platform-specific code
# that nothing in the pull request reaches (scripts/ci-windows-gpu-tests.py); the Linux
# gate runs them. Main and `full-ci` run everything.
if [ -n "$SKIP_NEUTRAL" ]; then
for package in $SKIP_NEUTRAL; do skip+=(--exclude "$package"); done
echo "::notice::Tests of platform-neutral packages the pull request does not reach are skipped on Windows (the Linux gate still runs them): $SKIP_NEUTRAL"
fi
cargo test --no-run --timings --workspace "${skip[@]}" --locked --features heif "${targets[@]}"
if [ "$PART" != warm ]; then
cargo nextest run --profile ci --workspace "${skip[@]}" --locked --features heif "${targets[@]}"
fi
shell: bash
# Fills the cache entry's Clippy metadata (the `clippy` leg only restores it). A Clippy
# failure is the `clippy` leg's to report, not a reason to skip saving the cache.
- name: Clippy dependency metadata
if: matrix.part == 'warm'
continue-on-error: true
run: cargo clippy --workspace --all-targets --locked --features heif -- -D warnings
# Per-crate compile and link times of this leg's build (open the HTML in a browser).
- name: Upload cargo build timings
if: always() && matrix.part != 'clippy'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: cargo-timings-windows-${{ matrix.part }}
# CARGO_TARGET_DIR above; the glob needs forward slashes.
path: D:/t/cargo-timings/*.html
if-no-files-found: ignore
retention-days: 14
- name: Doctests
if: matrix.part == 'unit'
env:
SKIP_NEUTRAL: ${{ needs.platforms.outputs.windows_skip }}
run: |
skip=(--exclude photocraft-web --exclude photocraft-web-boot)
for package in $SKIP_NEUTRAL; do skip+=(--exclude "$package"); done
cargo test --workspace "${skip[@]}" --locked --features heif --doc
shell: bash
dev-debug: "0"
cache-version: v2
# CARGO_TARGET_DIR: the Windows compiler command line carries one -L path per built
# dependency; a short target path keeps it within CreateProcess's limit. rust-lld (shipped
# with the toolchain) links the test binaries instead of link.exe, and the test links skip
# identical-code folding and PDBs; the link arguments in build.rs (/DELAYLOAD, delayimp.lib)
# are lld-link options too.
env: |
PHOTOCRAFT_FULL_SWEEP=${{ inputs.full_sweep && '1' || '0' }}
PHOTOCRAFT_NO_PRINT=1
LPDEST=photocraft-no-such-printer
CARGO_TARGET_DIR=D:\t
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER=rust-lld
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS=-Clink-arg=/OPT:NOICF -Clink-arg=/DEBUG:NONE
PHOTOCRAFT_CI_EXCLUDE=photocraft-web photocraft-web-boot ${{ needs.platforms.outputs.windows_gpu == 'false' && 'photocraft-gpu' || '' }} ${{ needs.platforms.outputs.windows_skip }}
timeout-minutes: 100
warm-command: cargo xtask ci build
lint-command: cargo xtask ci clippy
test-shards: 6
shard-command: bash scripts/ci-test-shard.sh
# The same codecs without the optional decoder: HEIC must stay a clear "not in this build" error
# for distributors who leave it out. Runs beside the gate and restores the gate's dependency
@@ -386,12 +270,14 @@ jobs:
with:
toolchain: stable
# gate.yml keys its cache `<cache-version>-rust-<hash of Cargo.toml>-gate`.
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
# The gate's own key (the shared action computes it), restore only. The toolchain action
# exports CARGO_HOME, which the gate's legs do not have; align-environment leaves it out of
# the key.
- uses: storytold/craft-common-actions/actions/rust-cache@main
with:
prefix-key: v1-rust
shared-key: ${{ hashFiles('Cargo.toml') }}-gate
save-if: false
cache-version: v2
job: gate
align-environment: "true"
- uses: step-security/taiki-e-install-action@76747d22a7567cc4438546a84f11bdf18e670ab8 # v2.87.32
with:
@@ -427,8 +313,9 @@ jobs:
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
prefix-key: v1-rust
key: corpus
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-on-failure: true
@@ -470,8 +357,9 @@ jobs:
with:
toolchain: stable
targets: wasm32-unknown-unknown
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
prefix-key: v1-rust
key: ci-web
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-on-failure: true
@@ -546,9 +434,6 @@ jobs:
with:
toolchain: nightly
- run: rustc -Vv
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
with:
workspaces: crates/${{ matrix.target.crate }}/fuzz
- name: Install cargo-fuzz
run: cargo install cargo-fuzz --locked
- name: Fuzz
@@ -586,9 +471,6 @@ jobs:
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
with:
key: color-range-perf
- name: Compare exact outputs and release timings on 24 MP
run: |
set -o pipefail
@@ -622,9 +504,6 @@ jobs:
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
with:
key: selection-morphology-perf
- name: Compare exact outputs and release timings on 36 MP
run: |
set -o pipefail
@@ -657,9 +536,12 @@ jobs:
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
# perf-nightly.yml's entry (same key and runner); only that job saves it.
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
key: perf-release
prefix-key: v1-rust
shared-key: perf-release
save-if: false
- name: Quick performance suite
run: cargo xtask perf --quick
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
@@ -687,9 +569,6 @@ jobs:
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
with:
key: selection-combining-perf
- name: Compare exact outputs and release timings on 36 MP
run: |
set -o pipefail
@@ -723,12 +602,6 @@ jobs:
- uses: step-security/dtolnay-rust-toolchain@8dd607977d06adf4ed49b190381e74c17a9dd25f # v1.0.0
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
with:
workspaces: |
before -> target
after -> target
key: brush-tip-release
- name: Build the same benchmark against both versions
run: |
cp after/crates/paint/examples/big_dab_bench.rs before/crates/paint/examples/big_dab_bench.rs
+1 -1
View File
@@ -38,5 +38,5 @@ jobs:
free-disk-space: false
# Prebuilt mdBook, the version cargo install built before.
tools: mdbook@0.4.52
cache-version: v1-docs
cache-version: v2-docs
command: mdbook build book
+3 -2
View File
@@ -55,9 +55,10 @@ jobs:
with:
toolchain: stable
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
key: perf-release
prefix-key: v1-rust
shared-key: perf-release
- name: Run benchmarks
id: perf
Generated
+98 -77
View File
@@ -1365,7 +1365,7 @@ dependencies = [
[[package]]
name = "craft"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-automation",
"craft-behavior",
@@ -1391,6 +1391,7 @@ dependencies = [
"craft-table",
"craft-text",
"craft-theme",
"craft-theme-editor",
"craft-theme-store",
"craft-timeline",
"craft-ui",
@@ -1403,7 +1404,7 @@ dependencies = [
[[package]]
name = "craft-affinity"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"crc32fast",
"flate2",
@@ -1424,7 +1425,7 @@ dependencies = [
[[package]]
name = "craft-atomic"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"rustix 1.1.5",
]
@@ -1432,7 +1433,7 @@ dependencies = [
[[package]]
name = "craft-automation"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"base64 0.22.1",
"craft-ai-agents",
@@ -1458,7 +1459,7 @@ dependencies = [
[[package]]
name = "craft-behavior"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"accesskit",
"bitflags 2.13.2",
@@ -1474,7 +1475,7 @@ dependencies = [
[[package]]
name = "craft-browse"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-docpath",
@@ -1489,10 +1490,18 @@ dependencies = [
"serde",
]
[[package]]
name = "craft-cloud-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"egui",
]
[[package]]
name = "craft-cms"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"md-5",
"rayon",
@@ -1501,7 +1510,7 @@ dependencies = [
[[package]]
name = "craft-color-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-cms",
@@ -1521,7 +1530,7 @@ dependencies = [
[[package]]
name = "craft-crs"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-metadata",
"craft-xml",
@@ -1531,7 +1540,7 @@ dependencies = [
[[package]]
name = "craft-crw"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"thiserror 2.0.21",
]
@@ -1539,7 +1548,7 @@ dependencies = [
[[package]]
name = "craft-dds"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"rayon",
]
@@ -1547,7 +1556,7 @@ dependencies = [
[[package]]
name = "craft-dialogs"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"block2 0.6.2",
"craft-atomic",
@@ -1570,7 +1579,7 @@ dependencies = [
[[package]]
name = "craft-docpath"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"serde",
]
@@ -1578,7 +1587,7 @@ dependencies = [
[[package]]
name = "craft-draw"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-color-ui",
@@ -1597,12 +1606,12 @@ dependencies = [
[[package]]
name = "craft-eps"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
[[package]]
name = "craft-file-formats"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-eps",
"craft-idml",
@@ -1620,7 +1629,7 @@ dependencies = [
[[package]]
name = "craft-flags"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-atomic",
"dirs",
@@ -1630,7 +1639,7 @@ dependencies = [
[[package]]
name = "craft-font-catalog"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"fontique",
"harfrust 0.13.3",
@@ -1645,7 +1654,7 @@ dependencies = [
[[package]]
name = "craft-font-manager"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-font-catalog",
@@ -1664,7 +1673,7 @@ dependencies = [
[[package]]
name = "craft-font-store"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"cap-primitives",
"craft-atomic",
@@ -1685,12 +1694,12 @@ dependencies = [
[[package]]
name = "craft-fonts-build"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
[[package]]
name = "craft-heif"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"heic-rs",
"rayon",
@@ -1699,7 +1708,7 @@ dependencies = [
[[package]]
name = "craft-host"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"bitflags 2.13.2",
"craft-i18n",
@@ -1712,7 +1721,7 @@ dependencies = [
[[package]]
name = "craft-i18n"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"chrono",
"fixed_decimal",
@@ -1740,7 +1749,7 @@ dependencies = [
[[package]]
name = "craft-idml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-xml",
"craft-zip",
@@ -1750,7 +1759,7 @@ dependencies = [
[[package]]
name = "craft-image-codecs"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-dds",
"craft-heif",
@@ -1778,7 +1787,7 @@ dependencies = [
[[package]]
name = "craft-imaging"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-color-ui",
@@ -1796,7 +1805,7 @@ dependencies = [
[[package]]
name = "craft-jpeg"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"thiserror 2.0.21",
]
@@ -1804,7 +1813,7 @@ dependencies = [
[[package]]
name = "craft-keymap"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-host",
"craft-i18n",
@@ -1817,7 +1826,7 @@ dependencies = [
[[package]]
name = "craft-kra"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-xml",
"craft-zip",
@@ -1827,7 +1836,7 @@ dependencies = [
[[package]]
name = "craft-layers"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-i18n",
@@ -1841,7 +1850,7 @@ dependencies = [
[[package]]
name = "craft-menu"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-host",
@@ -1859,7 +1868,7 @@ dependencies = [
[[package]]
name = "craft-metadata"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"brotli-decompressor 6.3.2",
"chrono",
@@ -1871,7 +1880,7 @@ dependencies = [
[[package]]
name = "craft-ora"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-xml",
"craft-zip",
@@ -1881,7 +1890,7 @@ dependencies = [
[[package]]
name = "craft-pages"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-text",
@@ -1895,7 +1904,7 @@ dependencies = [
[[package]]
name = "craft-pcraft-bundle"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"blake3",
"craft-atomic",
@@ -1908,7 +1917,7 @@ dependencies = [
[[package]]
name = "craft-pcraft-format"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"flate2",
"serde",
@@ -1919,7 +1928,7 @@ dependencies = [
[[package]]
name = "craft-pdf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"bytemuck",
"flate2",
@@ -1934,7 +1943,7 @@ dependencies = [
[[package]]
name = "craft-pdn"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -1943,7 +1952,7 @@ dependencies = [
[[package]]
name = "craft-platform"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"async-channel",
"async-io",
@@ -1969,7 +1978,7 @@ dependencies = [
[[package]]
name = "craft-plist"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"thiserror 2.0.21",
]
@@ -1977,7 +1986,7 @@ dependencies = [
[[package]]
name = "craft-print"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-ui",
@@ -1995,7 +2004,7 @@ dependencies = [
[[package]]
name = "craft-psd"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"encoding_rs",
"flate2",
@@ -2006,7 +2015,7 @@ dependencies = [
[[package]]
name = "craft-quit"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"dispatch2",
"egui",
@@ -2017,7 +2026,7 @@ dependencies = [
[[package]]
name = "craft-raw"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"chrono",
"craft-crw",
@@ -2035,7 +2044,7 @@ dependencies = [
[[package]]
name = "craft-review"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2052,7 +2061,7 @@ dependencies = [
[[package]]
name = "craft-settings"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-atomic",
"craft-host",
@@ -2066,7 +2075,7 @@ dependencies = [
[[package]]
name = "craft-svg"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-image-codecs",
"craft-xml",
@@ -2085,7 +2094,7 @@ dependencies = [
[[package]]
name = "craft-table"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-keymap",
@@ -2097,7 +2106,7 @@ dependencies = [
[[package]]
name = "craft-text"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-font-manager",
@@ -2120,7 +2129,7 @@ dependencies = [
[[package]]
name = "craft-theme"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"bitflags 2.13.2",
"ecolor",
@@ -2130,10 +2139,21 @@ dependencies = [
"smallvec",
]
[[package]]
name = "craft-theme-editor"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-theme",
"craft-ui",
"egui",
]
[[package]]
name = "craft-theme-store"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-atomic",
"craft-behavior",
@@ -2148,7 +2168,7 @@ dependencies = [
[[package]]
name = "craft-tiff"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"serde",
"thiserror 2.0.21",
@@ -2157,7 +2177,7 @@ dependencies = [
[[package]]
name = "craft-time"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"serde",
"thiserror 2.0.21",
@@ -2166,7 +2186,7 @@ dependencies = [
[[package]]
name = "craft-timeline"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-keymap",
@@ -2181,8 +2201,9 @@ dependencies = [
[[package]]
name = "craft-ui"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-cloud-ui",
"craft-ui-canvas",
"craft-ui-contract",
"craft-ui-panels",
@@ -2194,7 +2215,7 @@ dependencies = [
[[package]]
name = "craft-ui-canvas"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-i18n",
@@ -2210,7 +2231,7 @@ dependencies = [
[[package]]
name = "craft-ui-contract"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"accesskit",
"craft-behavior",
@@ -2244,7 +2265,7 @@ dependencies = [
[[package]]
name = "craft-ui-macros"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@@ -2255,7 +2276,7 @@ dependencies = [
[[package]]
name = "craft-ui-panels"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2273,7 +2294,7 @@ dependencies = [
[[package]]
name = "craft-ui-patterns"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2294,7 +2315,7 @@ dependencies = [
[[package]]
name = "craft-ui-shell"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2313,7 +2334,7 @@ dependencies = [
[[package]]
name = "craft-ui-widgets"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-behavior",
"craft-host",
@@ -2330,7 +2351,7 @@ dependencies = [
[[package]]
name = "craft-update"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"chrono",
"craft-host",
@@ -2359,7 +2380,7 @@ dependencies = [
[[package]]
name = "craft-win32"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"winsafe",
]
@@ -2367,7 +2388,7 @@ dependencies = [
[[package]]
name = "craft-window"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"craft-atomic",
"craft-behavior",
@@ -2397,7 +2418,7 @@ dependencies = [
[[package]]
name = "craft-xcf"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -2406,7 +2427,7 @@ dependencies = [
[[package]]
name = "craft-xml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"quick-xml 0.41.0",
"serde",
@@ -2416,7 +2437,7 @@ dependencies = [
[[package]]
name = "craft-zip"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -3879,7 +3900,7 @@ dependencies = [
[[package]]
name = "hayro"
version = "0.7.1"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"bytemuck",
"hayro-interpret",
@@ -3909,7 +3930,7 @@ dependencies = [
[[package]]
name = "hayro-interpret"
version = "0.7.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"bitflags 2.13.2",
"hayro-cmap",
@@ -3927,7 +3948,7 @@ dependencies = [
[[package]]
name = "hayro-jbig2"
version = "0.3.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"fearless_simd",
"hayro-ccitt",
@@ -3951,7 +3972,7 @@ checksum = "bc2d80da85f31c3fdc0366431f44cfd645a9da1e242ed1f4a61f213d9765660f"
[[package]]
name = "hayro-syntax"
version = "0.7.2"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"flate2",
"hayro-ccitt",
@@ -5035,7 +5056,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4"
[[package]]
name = "linesweeper"
version = "0.5.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
dependencies = [
"arrayvec",
"kurbo 0.13.1",
@@ -11095,14 +11116,14 @@ source = "git+https://github.com/storytold/egui.git?rev=e9711ca9b69772f875ae0d1c
[[patch.unused]]
name = "hayro-cmap"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
[[patch.unused]]
name = "hayro-postscript"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
[[patch.unused]]
name = "krilla"
version = "0.8.2"
source = "git+https://github.com/storytold/craft-libs?rev=a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9#a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9"
source = "git+https://github.com/storytold/craft-libs?rev=18ffc07519b15f5ef39e752aa0f405261fec8ebb#18ffc07519b15f5ef39e752aa0f405261fec8ebb"
+35 -35
View File
@@ -12,19 +12,19 @@ rust-version = "1.95"
[workspace.dependencies]
# The craft framework through its facade (`craft::ui::…`). The egui `[patch]` below must match
# `craft::egui_fork::REV` (checked by `cargo xtask ci`).
craft = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9", default-features = false }
craft = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb", default-features = false }
# internal
photocraft-geom = { path = "crates/geom" }
photocraft-color = { path = "crates/color" }
photocraft-raster = { path = "crates/raster" }
photocraft-doc = { path = "crates/doc" }
photocraft-ops = { path = "crates/ops" }
craft-plist = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] }
craft-plist = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] }
photocraft-raw = { path = "crates/raw" }
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
photocraft-compose = { path = "crates/compose" }
photocraft-gpu = { path = "crates/gpu" }
photocraft-paint = { path = "crates/paint" }
@@ -43,33 +43,33 @@ photocraft-ipp = { path = "crates/ipp" }
# external
# ICC colour management: the shared crate (replaces crates/cms; craft-libs#779).
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-print = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-print = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
# HEIC/HEIF: the shared decoder (replaces crates/heif; craft-libs#784).
craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9", features = ["raster", "write-raster"] }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9", features = ["tree-render", "tree-render-system-fonts"] }
craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb", features = ["raster", "write-raster"] }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb", features = ["tree-render", "tree-render-system-fonts"] }
craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
# Camera-field EXIF reader/writer, shared prerequisite craft-libs#1563.
craft-metadata = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-crs = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-metadata = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
craft-crs = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
# Interface translations: lookup, fallback, CLDR plurals and language names over the craft-i18n
# catalogs that `crates/ui-egui/build.rs` embeds from `CRAFT_I18N_DIR` (storytold/craft-i18n, at
# the commit in `craft-i18n.rev`). Already in the tree through craft.
craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
# craft-update: app-specific pretend versions apply to startup and manual checks.
craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9", features = ["ui"] }
craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb", features = ["ui"] }
thiserror = "2"
serde = { version = "1", features = ["derive", "rc"] }
serde_json = "1"
@@ -321,14 +321,14 @@ opt-level = 3
# Keep the complete egui family and native event bridge on reviewed fork commits.
[patch.crates-io]
krilla = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
hayro = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
krilla = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
hayro = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
ecolor = { git = "https://github.com/storytold/egui.git", rev = "e9711ca9b69772f875ae0d1cef1977ff8c16234d" }
emath = { git = "https://github.com/storytold/egui.git", rev = "e9711ca9b69772f875ae0d1cef1977ff8c16234d" }
epaint = { git = "https://github.com/storytold/egui.git", rev = "e9711ca9b69772f875ae0d1cef1977ff8c16234d" }
@@ -19,27 +19,30 @@ fn edited_psd_roundtrip_is_checked_and_bad_expectations_fail() {
.unwrap();
assert!(made.status.success(), "{}", String::from_utf8_lossy(&made.stderr));
let hash = xtask::sha256::hex(&fs::read(&base).unwrap());
let mut recipe = json!({"version":1,"corpus_revision":"synthetic","cases":[{
"id":"style", "base":"base.psd", "base_sha256":hash, "target":{"kind":"Type","name":"Oracle"},
"commands":[{"command":"type.antiAlias.crisp","params":{}}],
"checks":[{"op":"changed_to","path":"/text/antialias","value":"Crisp"},{"op":"unchanged","path":"/text/text"}]
}]});
// One run with a right and a wrong expectation of the same edit: the runner hashes the CLI,
// asks git and makes its output directory once, and still has to report the first case as
// passing and the second as failing (and fail itself).
let case = |id: &str, value: &str| {
json!({
"id":id, "base":"base.psd", "base_sha256":hash, "target":{"kind":"Type","name":"Oracle"},
"commands":[{"command":"type.antiAlias.crisp","params":{}}],
"checks":[{"op":"changed_to","path":"/text/antialias","value":value},{"op":"unchanged","path":"/text/text"}]
})
};
let recipe = json!({"version":1,"corpus_revision":"synthetic","cases":[case("style", "Crisp"), case("wrong", "Sharp")]});
let recipe_path = root.join("recipes.json");
let src = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
fs::write(&recipe_path, serde_json::to_vec(&recipe).unwrap()).unwrap();
let cli_path = Path::new(&cli).to_str().unwrap();
let corpus = root.to_str().unwrap();
let recipe_name = recipe_path.to_str().unwrap();
let output = root.join("success");
let output = root.join("report");
let args = [recipe_name, corpus, cli_path, output.to_str().unwrap()];
xtask::psd_write_oracle::run(&src, &args).unwrap();
assert!(xtask::psd_write_oracle::run(&src, &args).is_err(), "a failing case fails the run");
let report: Value = serde_json::from_slice(&fs::read(output.join("report.json")).unwrap()).unwrap();
assert_eq!(report["cases"][0]["id"], "style");
assert_eq!(report["cases"][0]["status"], "pass");
assert_eq!(report["cases"][0]["photoshop"]["opens"], "not_run");
recipe["cases"][0]["checks"][0]["value"] = json!("Sharp");
fs::write(&recipe_path, serde_json::to_vec(&recipe).unwrap()).unwrap();
let bad_output = root.join("failure");
assert!(xtask::psd_write_oracle::run(&src, &[recipe_name, corpus, cli_path, bad_output.to_str().unwrap()]).is_err());
let bad: Value = serde_json::from_slice(&fs::read(bad_output.join("report.json")).unwrap()).unwrap();
assert_eq!(bad["cases"][0]["status"], "fail");
assert_eq!(report["cases"][1]["id"], "wrong");
assert_eq!(report["cases"][1]["status"], "fail");
}
+1 -1
View File
@@ -1,7 +1,7 @@
//! Tests for the headless GPU backend, capability isolation, cache mutation, and CPU/GPU parity.
#[cfg(all(feature = "gpu", not(target_arch = "wasm32")))]
mod tests {
mod gpu_tests {
use std::fs;
use photocraft_codecs::decode;
+9
View File
@@ -11,6 +11,8 @@ mod krita;
mod layered_save_dirty;
mod linked_save_bytes;
mod mcp;
mod mcp_live;
mod mcp_wait;
mod mcp_wire;
mod missing_font_warnings;
mod native_full_composite;
@@ -19,4 +21,11 @@ mod openraster;
mod raw_defaults;
mod read_roots;
mod renderer_save;
mod save_snapshot;
mod scratch_save;
mod smart_filter_authorization;
mod smart_filter_stack_cache;
// Shared by smart_filter_authorization and smart_filter_stack_cache.
#[path = "../support/smart_filter_fixture.rs"]
mod smart_filter_fixture;
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,5 @@
//! A scripted `.pcraft` save refuses to write previews or a full-size composite rendered from
//! scratch tiles that could not be read. Its own test binary: the scratch store is per process.
//! scratch tiles that could not be read. The scratch store is per process, so the test needs its own (nextest runs every test in one).
#![cfg(not(target_arch = "wasm32"))]
use photocraft_automation::{AutomationError, files};
@@ -2,8 +2,7 @@
use std::path::Path;
use std::sync::Arc;
#[path = "../support/smart_filter_fixture.rs"]
mod fixture;
use crate::smart_filter_fixture as fixture;
use fixture::{Fixture, assert_denied, cube, path_params};
use photocraft_automation::{Headless, workspace::authorize_desktop_engine_step};
@@ -4,8 +4,7 @@ use photocraft_automation::workspace::authorize_desktop_engine_step;
use photocraft_engine::{Session, smart_cmds};
use serde_json::json;
#[path = "support/smart_filter_fixture.rs"]
mod fixture;
use crate::smart_filter_fixture as fixture;
use fixture::{Fixture, assert_denied};
@@ -1,6 +1,6 @@
//! The smart filter authorization tests' fixture: a workspace with a striped image to place and
//! maps and LUTs outside it (`#[path]`-included by `it/smart_filter_authorization.rs` and
//! `smart_filter_stack_cache.rs`).
//! maps and LUTs outside it (`#[path]`-included once by `it/main.rs`, used by
//! `smart_filter_authorization` and `smart_filter_stack_cache`).
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicU64, Ordering};
File renamed without changes.
@@ -11,7 +11,7 @@ impl Drop for IdleReleaseOff {
}
}
/// Runs in its own binary so other compositor tests cannot consume the pooled allocation.
/// Needs its own process (nextest runs every test in one) so other compositor tests cannot consume the pooled allocation.
#[test]
fn dropped_buffer_storage_is_reused() {
scratch::set_idle_release(false);
+9
View File
@@ -0,0 +1,9 @@
//! The crate's integration tests, linked into one test binary.
mod artboard;
mod buffer_reuse;
mod interrupt_surface;
mod scratch_retry;
mod shape_split_cache;
mod shape_split_source_budget;
mod spot_dot_gain;
@@ -1,6 +1,6 @@
//! Edit › Color Settings › Spot drives the ink preview of Multichannel documents and the saved
//! thumbnail. The setting is process-wide (`multichannel::set_spot_dot_gain`), so this test has its
//! own binary, and it is one test: changing it here can't race other tests that render inks.
//! thumbnail. The setting is process-wide (`multichannel::set_spot_dot_gain`), so this test needs its
//! own process (nextest runs every test in one): changing it can't race other tests that render inks.
use photocraft_color::{Color, ColorMode, PixelFormat, SampleType};
use photocraft_compose::multichannel::{SPOT_DOT_GAIN, dot_gain, set_spot_dot_gain, spot_dot_gain};
+1 -1
View File
@@ -16,7 +16,7 @@ photocraft-geom = { workspace = true }
photocraft-color = { workspace = true }
craft-cms = { workspace = true }
# PCTIP codec from craft-libs#1564; isolated pin until the shared revision is adopted workspace-wide.
craft-pcraft-tip = { package = "craft-pcraft-format", git = "https://github.com/storytold/craft-libs", rev = "a6b9d9c986f7c4c399632d72d9a4a8c8ea0b86e9" }
craft-pcraft-tip = { package = "craft-pcraft-format", git = "https://github.com/storytold/craft-libs", rev = "18ffc07519b15f5ef39e752aa0f405261fec8ebb" }
photocraft-raster = { workspace = true }
photocraft-doc = { workspace = true }
photocraft-ops = { workspace = true }
@@ -891,7 +891,9 @@ mod tests {
let b = got.bounds();
let before = s.active().unwrap().doc.layers[0].surface().unwrap().read_region(b);
assert!(got.layers[0].surface().unwrap().read_region(b) != before, "the preview moves something");
s.execute("paint.contentAwareMove", p).unwrap();
// That the command takes this selection too is shown by `preview` above: it runs the
// command's own `plan`, which rejects an empty selection, at full resolution. The
// command's full-resolution solve is left out: nothing here checked its result.
}
}
@@ -115,8 +115,10 @@ fn the_core_fit_shifts_brightness_and_leaves_a_hue_alone() {
#[test]
fn color_ten_on_green_leaves_the_middle_and_blends_the_edge() {
// Selection 120,120 40×40 dragged (140,140) → (600,420). Row y 420 is the middle of the landing.
// Color 0 is only read at the landing, which Extend makes as Move does (`run_move` step 1),
// without Move's second fill of the old place.
let mut kept = green_doc();
select_and_move(&mut kept, [120, 120, 40, 40], [460, 280], 0, "move");
select_and_move(&mut kept, [120, 120, 40, 40], [460, 280], 0, "extend");
let mut fitted = green_doc();
select_and_move(&mut fitted, [120, 120, 40, 40], [460, 280], 10, "move");
@@ -144,9 +146,12 @@ fn color_ten_on_green_leaves_the_middle_and_blends_the_edge() {
#[test]
fn a_brightness_change_shifts_the_middle_only_past_color_five() {
// Every check reads the landing, which Move and Extend make with the same code (`run_move`
// step 1); Extend skips Move's fill of the old place, which nothing here reads. The drop
// straight down below stays a Move.
let row = |color: u64| {
let mut s = ramp_doc();
select_and_move(&mut s, [120, 120, 40, 40], [460, 280], color, "move");
select_and_move(&mut s, [120, 120, 40, 40], [460, 280], color, "extend");
(levels(&s, 590, 420), levels(&s, 600, 420))
};
let (light, dark) = row(0);
@@ -171,21 +176,23 @@ fn a_brightness_change_shifts_the_middle_only_past_color_five() {
#[test]
fn a_flat_patch_matches_the_new_surroundings_at_color_ten() {
let middle = |color: u64, mode: &str| {
let moved_with = |color: u64, mode: &str| {
let mut s = flat_doc();
select_and_move(&mut s, [150, 250, 100, 100], [400, 0], color, mode);
levels(&s, 600, 300)
s
};
for mode in ["move", "extend"] {
assert_eq!(middle(0, mode), [204, 204, 204], "{mode} color 0 keeps 204");
assert_eq!(middle(3, mode), [204, 204, 204], "{mode} color 3 leaves the middle");
assert_eq!(middle(10, mode), [51, 51, 51], "{mode} color 10 becomes 51");
// Move and Extend land the content with the same code (`run_move` step 1); Move only adds
// the fill of the old place, away from the landing. So Colors 0 and 3 run once (Extend, one
// fill instead of two), and Color 10 runs in both modes, whose landings are compared pixel
// by pixel below.
assert_eq!(levels(&moved_with(0, "extend"), 600, 300), [204, 204, 204], "color 0 keeps 204");
assert_eq!(levels(&moved_with(3, "extend"), 600, 300), [204, 204, 204], "color 3 leaves the middle");
let moved = moved_with(10, "move");
let extended = moved_with(10, "extend");
for (mode, s) in [("move", &moved), ("extend", &extended)] {
assert_eq!(levels(s, 600, 300), [51, 51, 51], "{mode} color 10 becomes 51");
}
// The landing itself agrees; the old place is the part Move refills and Extend keeps.
let mut moved = flat_doc();
select_and_move(&mut moved, [150, 250, 100, 100], [400, 0], 10, "move");
let mut extended = flat_doc();
select_and_move(&mut extended, [150, 250, 100, 100], [400, 0], 10, "extend");
for y in [256, 300, 340] {
for x in [556, 600, 640] {
assert_eq!(levels(&moved, x, y), levels(&extended, x, y), "move and extend agree at {x},{y}");
+49
View File
@@ -339,4 +339,53 @@ mod tests {
assert!(c.covered(6, 0, m, None), "x = 4");
assert!(!c.covered(7, 0, m, None), "x = 5");
}
/// The active layer is a second fill target only as a visible, unlocked pixel layer with
/// visible, unlocked ancestors: each unmeasured state keeps the Background alone. Every state
/// here is a pure function of the layer tree; `crop_content_aware_layers.rs` runs a few of them
/// through `image.crop`.
#[test]
fn only_a_visible_unlocked_active_raster_adds_a_target() {
use photocraft_doc::{Layer, LayerContent, TextLayer};
let mut s = crate::Session::new();
s.execute("file.new", serde_json::json!({"width": 8, "height": 8, "background": "white"})).unwrap();
let base = (*s.active().unwrap().doc).clone();
let fmt = base.pixel_format();
let background = base.background().unwrap().id;
// The active layer `layer`, at the root or inside a group that `ancestor` edits.
let with = |layer: Layer, ancestor: Option<fn(&mut Layer)>| {
let mut d = base.clone();
let id = layer.id;
match ancestor {
None => d.layers.push(layer),
Some(edit) => {
let mut group = Layer::group("Ancestor", vec![layer]);
edit(&mut group);
d.layers.push(group);
}
}
(additional_target(&d, Some(id)), id)
};
let (got, id) = with(Layer::raster("Active", fmt), None);
assert_eq!(got, Some(id), "a visible, unlocked raster");
let plain_group: fn(&mut Layer) = |_| {};
let (got, id) = with(Layer::raster("Active", fmt), Some(plain_group));
assert_eq!(got, Some(id), "inside a visible, unlocked group");
let text = Layer::new("T", LayerContent::Text(TextLayer { text: "T".into(), ..Default::default() }));
assert_eq!(with(text, None).0, None, "a type layer");
let mut hidden = Layer::raster("Active", fmt);
hidden.visible = false;
assert_eq!(with(hidden, None).0, None, "a hidden layer");
for lock in ["all", "pixels", "transparency", "position", "artboard"] {
let mut locked = Layer::raster("Active", fmt);
assert!(locked.locks.set(lock, true));
assert_eq!(with(locked, None).0, None, "lock {lock}");
}
let hidden_group: fn(&mut Layer) = |g| g.visible = false;
assert_eq!(with(Layer::raster("Active", fmt), Some(hidden_group)).0, None, "a hidden ancestor");
let locked_group: fn(&mut Layer) = |g| assert!(g.locks.set("pixels", true));
assert_eq!(with(Layer::raster("Active", fmt), Some(locked_group)).0, None, "a locked ancestor");
assert_eq!(additional_target(&base, Some(background)), None, "the Background itself");
assert_eq!(additional_target(&base, None), None, "no active layer");
}
}
+2 -2
View File
@@ -1413,8 +1413,8 @@ impl ToolbarCustomization {
/// works with or without "Tool". `None` for a name that isn't a tool.
pub fn tool_name(name: &str) -> Option<String> {
let canonical = |key: &str| -> String { key.chars().take(1).flat_map(char::to_uppercase).chain(key.chars().skip(1)).collect() };
// Stored layouts hold canonical names: find those without allocating (the toolbar
// resolves its layout every frame).
// Stored layouts hold canonical names: find those without allocating (every layout
// resolves each of its names here).
if let Some(key) = crate::shell_commands::TOOLS.iter().filter_map(|(id, _, _)| id.strip_prefix("tools.select.")).find(|k| k.eq_ignore_ascii_case(name))
{
return Some(canonical(key));
+9 -3
View File
@@ -123,7 +123,8 @@ impl Session {
/// [`Self::is_enabled`] for a call with `params`: their `"target"` can enable a command, as a
/// targeted layer mask enables Image › Adjustments › Invert on an adjustment layer (#780).
pub fn is_enabled_with(&self, id: &str, params: &Value) -> bool {
self.disabled_reason_with(id, params).is_none()
// An unknown id is disabled; its reason would rank every command id for "did you mean".
commands::find(id).is_some_and(|spec| self.spec_disabled_reason(spec, id, params).is_none())
}
/// Why the command can't run now (None = it can): its own precondition, or a background job
@@ -134,8 +135,13 @@ impl Session {
/// [`Self::disabled_reason`] for a call with `params`.
pub fn disabled_reason_with(&self, id: &str, params: &Value) -> Option<String> {
let Some(s) = commands::find(id) else { return Some(EngineError::UnknownCommand(id.into()).to_string()) };
self.precondition(s, &channel_cmds::inject_target(self, id, params.clone())).err().or_else(|| self.job_conflict(id, s.journal))
let Some(spec) = commands::find(id) else { return Some(EngineError::UnknownCommand(id.into()).to_string()) };
self.spec_disabled_reason(spec, id, params)
}
/// [`Self::disabled_reason_with`] for the catalogue entry `spec` of `id`.
fn spec_disabled_reason(&self, spec: &commands::CommandSpec, id: &str, params: &Value) -> Option<String> {
self.precondition(spec, &channel_cmds::inject_target(self, id, params.clone())).err().or_else(|| self.job_conflict(id, spec.journal))
}
/// The command's own precondition for a call with `params` (their target filled in).
@@ -1,11 +1,13 @@
//! One integration-test process keeps its global adjustment-table cache isolated from parallel
//! unit tests.
//! The global adjustment-table cache is isolated from parallel unit tests; the tests that count
//! it take turns.
use photocraft_compose::lut_rows::{self, ROW_LEN};
use photocraft_engine::Session;
use serde_json::json;
#[test]
fn purge_all_is_enabled_by_cached_adjustment_tables_and_releases_them() {
let _caches = crate::lock(&crate::PROCESS);
crate::purge_all_caches();
let mut session = Session::new();
assert!(!session.is_enabled("edit.purge.all"));
let rows = lut_rows::cached(7, || vec![[0.5; ROW_LEN]; 3]);
+36
View File
@@ -0,0 +1,36 @@
//! Tests that assert on process-wide state the rest of the engine's tests change (the scratch pool,
//! spill configuration, simulated memory, global caches, compositor settings). They live apart from
//! `it` so plain `cargo test` runs them without the rest of the suite.
mod lut_row_cache_purge;
mod mask_cache_purge;
mod memory_gate;
mod scratch_disk;
mod scratch_pause;
mod scratch_release;
mod shape_kernel_budget;
mod smart_source_cache;
mod smart_source_peak;
mod spot_dot_gain;
mod text_gamma;
use std::sync::{Mutex, MutexGuard, PoisonError};
/// Every test here changes or asserts on process-wide state (scratch pool, spill configuration,
/// simulated memory, global caches, compositor settings) that the others touch too, so the tests
/// take turns.
pub(crate) static PROCESS: Mutex<()> = Mutex::new(());
/// Takes the lock; a failed test that held it does not fail the next.
pub(crate) fn lock(lock: &'static Mutex<()>) -> MutexGuard<'static, ()> {
lock.lock().unwrap_or_else(PoisonError::into_inner)
}
/// Empties every global cache that Purge All reports, so a test that asserts on what Purge All
/// finds starts from nothing whatever ran before it in this process.
pub(crate) fn purge_all_caches() {
let mut session = photocraft_engine::Session::new();
if session.is_enabled("edit.purge.all") {
let _ = session.execute("edit.purge.all", serde_json::json!({}));
}
}
@@ -1,4 +1,4 @@
//! One integration-test process keeps its global mask cache isolated from parallel unit tests.
//! The global mask cache is isolated from parallel unit tests; the tests that count it take turns.
use std::sync::Arc;
use photocraft_color::{ColorMode, PixelFormat, SampleType};
@@ -11,6 +11,8 @@ use serde_json::json;
#[test]
fn purge_all_is_enabled_by_cached_masks_and_releases_them_at_every_depth() {
let _caches = crate::lock(&crate::PROCESS);
crate::purge_all_caches();
let mut session = Session::new();
assert!(!session.is_enabled("edit.purge.all"));
let canvas = Rect::new(0, 0, 32, 32);
@@ -3,21 +3,19 @@
//! an error when their estimated need won't fit (#10024). The simulation switch is process-wide,
//! so every test here holds `LOCK` and resets it when it ends.
use std::sync::{Mutex, MutexGuard, PoisonError};
use std::sync::MutexGuard;
use photocraft_color::{ColorMode, PixelFormat, SampleType};
use photocraft_engine::Session;
use photocraft_raster::headroom;
use serde_json::json;
static LOCK: Mutex<()> = Mutex::new(());
/// Holds the lock and the simulated room; resets the simulation when dropped.
struct Room(#[allow(dead_code)] MutexGuard<'static, ()>);
impl Room {
fn new(bytes: Option<u64>) -> Room {
let guard = Room(LOCK.lock().unwrap_or_else(PoisonError::into_inner));
let guard = Room(crate::lock(&crate::PROCESS));
headroom::simulate_available(bytes);
guard
}
@@ -9,6 +9,7 @@ use std::sync::Arc;
#[test]
fn scratch_pixels_history_and_failed_save_are_transactional() {
let _scratch = crate::lock(&crate::PROCESS);
let dir = std::env::temp_dir().join(format!("photocraft-engine-scratch-{}", std::process::id()));
let mut session = Session::new();
session.edit_prefs(|p| {
@@ -9,6 +9,7 @@ use serde_json::json;
#[test]
fn paused_scratch_disk_restores_the_history_limit() {
let _scratch = crate::lock(&crate::PROCESS);
let dir = std::env::temp_dir().join(format!("photocraft-engine-scratch-pause-{}", std::process::id()));
let mut session = Session::new();
session.edit_prefs(|p| {
@@ -1,12 +1,9 @@
//! One integration-test process keeps the process-wide scratch pool isolated from parallel unit
//! tests (#10479).
//! The process-wide scratch pool is isolated from parallel unit tests (#10479); these tests take
//! turns on it.
use photocraft_engine::Session;
use photocraft_engine::jobs::Started;
use photocraft_raster::scratch;
use serde_json::json;
use std::sync::{Mutex, PoisonError};
static SERIAL: Mutex<()> = Mutex::new(());
/// Holds the test lock with the pool's idle release off, so a slow runner can't empty the pool
/// between a command and the check after it; the release comes back on when dropped.
@@ -17,7 +14,7 @@ struct Quiet {
impl Quiet {
/// Locks the test process and disables idle pool release for this guard's lifetime.
fn new() -> Self {
let _serial = SERIAL.lock().unwrap_or_else(PoisonError::into_inner);
let _serial = crate::lock(&crate::PROCESS);
scratch::set_idle_release(false);
Quiet { _serial }
}
@@ -1,6 +1,6 @@
//! A custom Shape Blur kernel is admitted against the working-memory budget before its coverage
//! buffer is allocated, also when a smart filter re-renders it. Its own binary: the budget is
//! process-wide.
//! buffer is allocated, also when a smart filter re-renders it. The budget is
//! process-wide, so this test needs its own process (nextest runs every test in one).
use photocraft_geom::Rect;
use photocraft_raster::memory::{self, Policy};
@@ -8,6 +8,7 @@ use serde_json::json;
#[test]
fn custom_shape_kernel_is_admitted_before_allocation() {
let _process = crate::lock(&crate::PROCESS);
let knots = json!([[0, 0], [10, 0], [10, 10], [0, 10]]);
let params = json!({"radius":1000,"shapePath":{"subpaths":[{"closed":true,"knots":knots}]}});
let mut surface = photocraft_raster::Surface::new(photocraft_color::PixelFormat::RGBA8);
@@ -1,14 +1,10 @@
//! #10030: the decoded-source cache counts the bytes it holds, and Purge All and closing a
//! document with smart objects release them. One integration-test process keeps the global
//! cache isolated from parallel unit tests; the tests here take turns on it.
use std::sync::Mutex;
//! document with smart objects release them. The global cache is
//! isolated from parallel unit tests; the tests here take turns on it.
use photocraft_codecs::{ChannelLayout, EncodeOptions, Format, Image, SampleType};
use photocraft_engine::{Session, file_cmds, smart_cmds};
use serde_json::json;
static TURN: Mutex<()> = Mutex::new(());
const SIDE: u32 = 256;
fn png() -> Vec<u8> {
@@ -24,6 +20,7 @@ fn empty_caches() {
photocraft_compose::purge_effect_cache();
photocraft_compose::masks::purge_cache();
photocraft_compose::shape_split::purge_cache();
crate::purge_all_caches();
}
fn session_with_smart_object(bytes: &[u8]) -> Session {
@@ -39,7 +36,7 @@ fn decode(s: &Session, bytes: &[u8]) {
#[test]
fn the_cache_counts_real_tile_bytes() {
let _turn = TURN.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
let _turn = crate::lock(&crate::PROCESS);
empty_caches();
let bytes = png();
let s = session_with_smart_object(&bytes);
@@ -53,7 +50,7 @@ fn the_cache_counts_real_tile_bytes() {
#[test]
fn purge_all_reports_and_empties_the_source_cache() {
let _turn = TURN.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
let _turn = crate::lock(&crate::PROCESS);
empty_caches();
let bytes = png();
let mut s = session_with_smart_object(&bytes);
@@ -72,7 +69,7 @@ fn purge_all_reports_and_empties_the_source_cache() {
#[test]
fn closing_a_document_with_a_smart_object_empties_the_source_cache() {
let _turn = TURN.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
let _turn = crate::lock(&crate::PROCESS);
empty_caches();
let bytes = png();
let mut s = session_with_smart_object(&bytes);
@@ -2,7 +2,7 @@
//! tile-aligned blocks, so the peak memory growth stays a small multiple of the source's pixels, not the 32
//! bytes a pixel the full-size RGBA buffer and its f32 copy took on top of the decoded document.
//!
//! The one test here runs in its own process: it reads the process's peak RSS (`VmHWM`, Linux
//! The one test here needs its own process (nextest runs every test in one): it reads the process's peak RSS (`VmHWM`, Linux
//! only) and nothing else may allocate meanwhile.
#![cfg(target_os = "linux")]
@@ -31,6 +31,7 @@ fn png() -> Vec<u8> {
#[test]
fn decoding_a_smart_object_source_stays_within_16_bytes_a_source_pixel() {
let _process = crate::lock(&crate::PROCESS);
let bytes = png();
let mut s = Session::new();
s.execute("file.new", json!({"width": 8, "height": 8})).unwrap();
@@ -2,7 +2,7 @@
//! (`photocraft_compose::multichannel::spot_dot_gain`), which the ink preview of Multichannel
//! documents adds to every channel.
//!
//! This test has its own integration-test binary (its own process) for the same reason as
//! This test needs its own process (nextest runs every test in one) for the same reason as
//! `text_gamma.rs`: changing the gain changes how every Multichannel document composites, so a
//! concurrent test could flatten one document under two settings. Keep any other test that
//! changes the spot dot gain in this file.
@@ -20,6 +20,7 @@ fn half_tint(s: &mut Session) {
#[test]
fn spot_dot_gain_setting() {
let _process = crate::lock(&crate::PROCESS);
let mut s = Session::new();
assert_eq!(s.color.settings.spot_dot_gain, SPOT_DOT_GAIN, "Photoshop's default Spot working space: Dot Gain 20 %");
for bad in [json!(-1), json!(50), json!("20%"), json!(true)] {
@@ -1,7 +1,7 @@
//! Edit › Color Settings › "Blend Text Colors Using Gamma" drives the compositor's
//! application-wide text gamma (`photocraft_compose::psblend::text_gamma`).
//!
//! This test lives in its own integration-test binary (its own process) on purpose: switching
//! This test needs its own process (nextest runs every test in one): switching
//! the gamma away from the default changes how every type layer composites, so running it next
//! to the engine's unit tests let a concurrent test flatten one document under two gammas
//! (`canvas_geom::tests::turns_at_every_depth_and_mode` compares the composite before an edit
@@ -13,6 +13,7 @@ use serde_json::json;
#[test]
fn blend_text_gamma_setting() {
let _process = crate::lock(&crate::PROCESS);
let mut s = Session::new();
assert!((s.color.settings.blend_text_gamma - 1.45).abs() < 1e-6);
assert!(s.execute("edit.colorSettings", json!({"blendTextGamma": 3.0})).is_err());
+1 -2
View File
@@ -5,8 +5,7 @@ use photocraft_engine::actions_cmds::{ActionList, ActionsFile};
use photocraft_engine::{Session, atn_cmds};
use serde_json::json;
#[path = "../common/csh_fixture.rs"]
mod csh_fixture;
use crate::csh_fixture;
const SHAPE_ID: &str = "original-fixture-square";
@@ -236,34 +236,24 @@ fn background_active_is_not_a_second_target() {
}
/// Verifies Background-only fill for ineligible active layers and Delete Cropped Pixels off.
/// Which active layers are a second target is a pure function of the layer tree, checked for every
/// unmeasured state (type, hidden, each lock, hidden or locked ancestor) by `crop_fill`'s
/// `only_a_visible_unlocked_active_raster_adds_a_target`. Through the command, straight and
/// turned, run one state the layer itself rules out (type), one an ancestor rules out (a locked
/// group) and Delete Cropped Pixels off, its own branch of `fill_uncovered`.
#[test]
fn unmeasured_active_targets_and_delete_off_keep_the_legacy_target() {
for turned in [false, true] {
let (x, y) = extension_sample(turned);
for case in 0..10 {
for (text, locked_group, delete) in [(true, false, true), (false, true, true), (false, false, false)] {
let (mut s, ids) = scene(turned);
let active = match case {
0 => ids.text,
1 => ids.hidden,
_ => ids.quads,
};
if (2..7).contains(&case) {
s.edit("Lock active", |d, _| {
assert!(d.layer_mut(active).unwrap().locks.set(["all", "pixels", "transparency", "position", "artboard"][case - 2], true));
Ok(())
})
.unwrap();
}
if case >= 8 {
let active = if text { ids.text } else { ids.quads };
if locked_group {
s.edit("Group active", |d, _| {
let i = d.layers.iter().position(|layer| layer.id == active).unwrap();
let child = d.layers.remove(i);
let mut group = Layer::group("Ancestor", vec![child]);
if case == 8 {
group.visible = false;
} else {
assert!(group.locks.set("pixels", true));
}
assert!(group.locks.set("pixels", true));
d.layers.insert(i, group);
Ok(())
})
@@ -271,9 +261,7 @@ fn unmeasured_active_targets_and_delete_off_keep_the_legacy_target() {
}
select(&mut s, active);
let mut p = frame(turned);
if case == 7 {
p["deleteCroppedPixels"] = json!(false);
}
p["deleteCroppedPixels"] = json!(delete);
let plain = plain_control(&mut s, &p);
crop(&mut s, p, true);
pixel(doc(&s), ids.background, x, y, WHITE);
@@ -4,8 +4,7 @@
use photocraft_engine::Session;
use serde_json::json;
#[path = "common/csh_fixture.rs"]
mod fixture;
use crate::csh_fixture as fixture;
use fixture::{polygon_csh, triangle_csh};
#[test]
+25
View File
@@ -16,6 +16,7 @@ mod atn_crystallize_cell_size;
mod atn_dialog_filters;
mod atn_direct_adjustments;
mod atn_layer_style;
mod atn_mapped_identifiers;
mod atn_newer_events;
mod atn_perspective_warp;
mod atn_reference_forms;
@@ -39,13 +40,21 @@ mod camera_raw_noise_clamp;
mod canvas_artboard_crop;
mod clipping_semantics;
mod close_document;
mod cmyk_flatten_profile;
mod command_lookup;
mod content_aware_fill_atn;
mod content_aware_fill_options;
mod content_aware_rotation;
mod convert_keeps_references;
mod convert_profile_atn;
mod convert_profile_dither;
mod convert_profile_options;
mod copy_shape_placement;
mod corpus_atn;
mod crop_content_aware;
mod crop_content_aware_layers;
mod crop_delete_off_background;
mod csh_import;
mod current_affinity_artboards;
mod duplicate_layer_comps;
mod duplicate_slices;
@@ -66,6 +75,8 @@ mod guide_layout_limit;
mod guide_layout_preview;
mod hdr_gamma_direction;
mod huge_doc_flatten;
mod image_size_scale_styles;
mod image_size_scale_styles_atn;
mod integration_batch;
mod jpeg_exif_resolution;
mod keyboard_shortcut_bulk;
@@ -75,17 +86,24 @@ mod layer_delete_last;
mod layer_mask_depth;
mod layer_props_several;
mod layer_range_panel_order;
mod live_dab_matches_replay;
mod live_line_transform;
mod magnetic_lasso_composite;
mod mask_lock_all;
mod memory_prefs;
mod merge_transparent_bounds;
mod missing_layer_error;
mod multi_channel_editing;
mod nonfinite_style;
mod open_identity;
mod paste_style_options;
mod path_blur_speed_clamp;
mod path_transform_target;
mod pdn;
mod pen_path_append;
mod photoshop_oracles;
mod pixel_lock_edits;
mod place_steps_measure;
mod precheck;
mod prefs_usage;
mod rasterize_psd_reopen;
@@ -98,8 +116,10 @@ mod shortcuts_headless;
mod smart_clipboard_sources;
mod smart_duplicates;
mod smart_filter_canvas_geometry;
mod smart_filter_stages;
mod smart_object_tones;
mod smart_psd;
mod smart_rerender_fallback;
mod style_and_align;
mod svg_smart_object;
mod tone_target_picker;
@@ -109,6 +129,11 @@ mod type_postscript_font;
mod undo_keeps_active_layer;
mod unicode_colors;
mod unsupported_smart_filters;
mod vector_paste_options;
mod wand_transparent_copy;
mod working_rgb_profile;
mod xmp_charref;
// Shared by atn_shape_blur and csh_import.
#[path = "../common/csh_fixture.rs"]
mod csh_fixture;
File renamed without changes.
+1
View File
@@ -9,5 +9,6 @@ mod float_roundtrip;
mod frame_stroke;
mod layer_labels;
mod roundtrip;
mod scratch_retry;
mod smart_contents;
mod triangle_live;
File renamed without changes.
+9 -9
View File
@@ -115,9 +115,9 @@ impl Compositor {
sink: &mut dyn FnMut(&mut wgpu::CommandEncoder, ChunkOut<'_>),
// The previous intermediate submit, when this refresh may submit in between.
batch: &mut Option<&mut Option<wgpu::SubmissionIndex>>,
) {
) -> Result<(), Unsupported> {
if chunks.is_empty() {
return;
return Ok(());
}
// Chunks may hold different checkpoints: bind from the lowest one any of them resumes at.
let first_pass = checkpoint
@@ -126,7 +126,7 @@ impl Compositor {
let bound = self.bind_cell(device, queue, encoder, doc, plan, paged, cell, fr, first_pass, stats);
// A page couldn't be created: draw nothing with the pages missing (the caller ends the refresh).
if self.layer_alloc.is_some() {
return;
return Ok(());
}
// Chunk pool.
@@ -233,7 +233,7 @@ impl Compositor {
self.recorded = 0;
stats.flushes += 1;
if self.fault().is_some() {
return;
return Ok(());
}
}
// Also after resuming from a lower checkpoint: the chunk moves up to this one.
@@ -294,8 +294,9 @@ impl Compositor {
}
_ => (p.kernel, p.dst),
};
let target = &self.pool[dst as usize].1;
let clear = p.kernel == Kernel::Clear;
let pipeline = if clear { None } else { Some(self.kit.pipelines.get(device, kernel, self.acc_format)?) };
let target = &self.pool[dst as usize].1;
let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("pc_compose_pass"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
@@ -312,10 +313,8 @@ impl Compositor {
occlusion_query_set: None,
multiview_mask: None,
});
if clear {
continue;
}
pass.set_pipeline(&self.kit.pipelines[&(kernel, self.acc_format)]);
let Some(pipeline) = pipeline else { continue };
pass.set_pipeline(pipeline);
pass.set_scissor_rect(scissor.x0 as u32, scissor.y0 as u32, scissor.width(), scissor.height());
pass.set_bind_group(0, &bg0, &[(ci as u64 * STRIDE) as u32, (op_base + i as u64 * STRIDE) as u32]);
pass.set_bind_group(1, bg1[i].as_ref(), &[]);
@@ -330,6 +329,7 @@ impl Compositor {
let (t, v) = &self.pool[plan.root as usize];
sink(encoder, ChunkOut { rect: *c, texture: t, view: v });
}
Ok(())
}
/// Upload changed tiles of `surface` within `region` (its tile area inside one page cell);
+2 -2
View File
@@ -217,7 +217,7 @@ impl Compositor {
stats.chunks += chunks.len();
work += part.width() as u64 * part.height() as u64 * plan.passes.len() as u64;
let mut batch = flush.then_some(&mut last_submit);
self.run_cell(device, queue, encoder, doc.id, &plan, &runs, &paged, cell, &fr, &chunks, checkpoint, &mut stats, sink, &mut batch);
self.run_cell(device, queue, encoder, doc.id, &plan, &runs, &paged, cell, &fr, &chunks, checkpoint, &mut stats, sink, &mut batch)?;
// The device was lost in a submit inside the cell: issue no more work.
if let Some(f) = self.fault() {
return Err(Unsupported(f.to_string()));
@@ -251,7 +251,7 @@ impl Compositor {
return Err(Unsupported(f.to_string()));
}
let mut batch = Some(&mut last_submit);
self.run_cell(device, queue, encoder, doc.id, &plan, &runs, &paged, cell, &fr, &chunks, checkpoint, &mut stats, sink, &mut batch);
self.run_cell(device, queue, encoder, doc.id, &plan, &runs, &paged, cell, &fr, &chunks, checkpoint, &mut stats, sink, &mut batch)?;
if let Some(f) = self.fault() {
return Err(Unsupported(f.to_string()));
}
+1 -2
View File
@@ -258,8 +258,7 @@ impl Compositor {
lut: s.lut.clone(),
});
}
self.kit.run(device, queue, encoder, &draws);
Ok(())
self.kit.run(device, queue, encoder, &draws)
}
}
+11 -49
View File
@@ -1,12 +1,14 @@
use super::consts::{CHUNK_UNIFORM, MAP16, MAP32, OP_UNIFORM, STRIDE};
use super::consts::{CHUNK_UNIFORM, OP_UNIFORM, STRIDE};
use super::convert::{lut_texture, words};
use super::pipelines::Pipelines;
use super::textures::{ResKey, ResidentRef};
use super::{Arc, HashMap, I, Kernel, NonZeroU64, Rect};
use super::{Arc, I, Kernel, NonZeroU64, Rect, Unsupported};
/// Pipelines and layouts, shared by cheap clones (wgpu handles are reference counted).
/// Pipelines and layouts, shared by cheap clones (wgpu handles are reference counted; a sibling
/// compositor uses the pipelines any of them built).
#[derive(Clone)]
pub(crate) struct Kit {
pub(crate) pipelines: HashMap<(Kernel, wgpu::TextureFormat), wgpu::RenderPipeline>,
pub(crate) pipelines: Arc<Pipelines>,
pub(crate) bgl0: wgpu::BindGroupLayout,
pub(crate) bgl1: wgpu::BindGroupLayout,
pub(crate) dummy: wgpu::TextureView,
@@ -28,9 +30,9 @@ pub(crate) struct MapDraw {
impl Kit {
/// Record `draws` (each its own render pass) into `encoder`.
pub(crate) fn run(&self, device: &wgpu::Device, queue: &wgpu::Queue, encoder: &mut wgpu::CommandEncoder, draws: &[MapDraw]) {
pub(crate) fn run(&self, device: &wgpu::Device, queue: &wgpu::Queue, encoder: &mut wgpu::CommandEncoder, draws: &[MapDraw]) -> Result<(), Unsupported> {
if draws.is_empty() {
return;
return Ok(());
}
let mut data = vec![0u8; draws.len() * 2 * STRIDE as usize];
for (i, d) in draws.iter().enumerate() {
@@ -47,6 +49,7 @@ impl Kit {
queue.write_buffer(&ubuf, 0, &data);
let bg0 = uniform_group(device, &self.bgl0, &ubuf);
for (i, d) in draws.iter().enumerate() {
let pipeline = self.pipelines.get(device, d.kernel, d.format)?;
let lut = d.lut.as_ref().map(|l| {
let mut row = [0.0f32; 4096];
row[..l.len().min(4096)].copy_from_slice(&l[..l.len().min(4096)]);
@@ -70,12 +73,13 @@ impl Kit {
occlusion_query_set: None,
multiview_mask: None,
});
pass.set_pipeline(&self.pipelines[&(d.kernel, d.format)]);
pass.set_pipeline(pipeline);
pass.set_scissor_rect(d.scissor[0], d.scissor[1], d.scissor[2], d.scissor[3]);
pass.set_bind_group(0, &bg0, &[(2 * i as u64 * STRIDE) as u32, ((2 * i + 1) as u64 * STRIDE) as u32]);
pass.set_bind_group(1, &bg1, &[]);
pass.draw(0..3, 0..1);
}
Ok(())
}
}
@@ -127,48 +131,6 @@ pub(crate) fn uniform_entry(binding: u32, size: u64) -> wgpu::BindGroupLayoutEnt
/// The compositor's WGSL source (exposed for validation in tests).
pub const SHADER: &str = include_str!("compose.wgsl");
/// One thread's share of the compositor's pipelines: the vertex entry point (in
/// [`vertex_shader`]) and the (kernel, target format) pairs it builds.
pub(crate) struct BuildJob {
pub(crate) vertex: String,
pub(crate) keys: Vec<(Kernel, wgpu::TextureFormat)>,
}
/// The compositor's pipelines, grouped by the thread that builds them: one job per kernel, and
/// an effect-map kernel's R32F and R16F pipelines in the same job. Each job has its own vertex
/// entry point, so no two jobs share a shader (see `Compositor::build`).
pub(crate) fn build_jobs(acc_format: wgpu::TextureFormat) -> Vec<BuildJob> {
let one = |k: Kernel| if k.is_map() { vec![(k, MAP32), (k, MAP16)] } else { vec![(k, acc_format)] };
let (plain, maps): (Vec<Kernel>, Vec<Kernel>) = Kernel::DRAWN.iter().partition(|k| !k.is_map());
plain.into_iter().chain(maps).enumerate().map(|(job, k)| BuildJob { vertex: format!("vs_{job}"), keys: one(k) }).collect()
}
/// The full-chunk triangle's vertex stage, once per build job under that job's name (`vs_0`,
/// `vs_1`, ...): the same code under distinct names, so each job compiles its own vertex shader.
///
/// A workaround, not a design: wgpu-hal's D3D12 shader cache shares a compiled FXC blob between
/// threads, and FXC's blobs don't count references atomically, so a shared one can be freed
/// while still cached (gfx-rs/wgpu#10547, #9173). Each copy costs one compile of a three-line
/// shader. Once a wgpu release fixes the cache, go back to one `vs` in `compose.wgsl` and let
/// `build_jobs` split map kernels by format again.
pub(crate) fn vertex_shader(jobs: &[BuildJob]) -> String {
let mut s = String::from(
"struct VOut { @builtin(position) pos: vec4<f32> };
",
);
for job in jobs {
s.push_str(&format!(
"@vertex fn {}(@builtin(vertex_index) vi: u32) -> VOut {{
let uv = vec2(f32((vi << 1u) & 2u), f32(vi & 2u));
return VOut(vec4(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, 0.0, 1.0));
}}
",
job.vertex
));
}
s
}
/// Pass-level resources resolved for one page cell: resident pages (texture, mask) and effect
/// maps (view and region) per pass.
pub(crate) struct Bound {
+1 -3
View File
@@ -118,9 +118,6 @@ pub struct Compositor {
/// out of memory.
fail_allocs: u32,
acc_format: wgpu::TextureFormat,
/// Whether the effect-map pipelines could be built (else documents with layer effects are
/// [`Unsupported`] and use the CPU compositor).
effect_maps: bool,
/// `CmykSpace::id` of the document being encoded (0: built-in coated CMYK).
cmyk: u64,
/// The device's health (see [`Compositor::set_health`]); `None` = assumed healthy.
@@ -141,6 +138,7 @@ mod encode;
mod fx_passes;
mod kit;
mod paging;
mod pipelines;
#[cfg(not(target_arch = "wasm32"))]
pub mod readback;
mod setup;
+203
View File
@@ -0,0 +1,203 @@
//! The compositor's render pipelines: one table per compositor and its siblings, each pipeline
//! built the first time a draw needs it, or all of them at once where a caller wants every
//! shader compiled up front (the app's background build).
//!
//! On DX12 the shader compiler is FXC, which compiles one shader at a time; the ~30 pipelines
//! took about 8 s on one core (#6419), and 3 to 7.5 s per test process on the Windows CI
//! runners' software adapter (#15439). A compositor that draws one plain layer needs two or three.
use std::sync::OnceLock;
use super::consts::{MAP16, MAP32};
use super::kit::SHADER;
use super::{Kernel, Unsupported, first_error};
/// Why documents with layer effects can't use the GPU compositor on this device.
pub(crate) const NO_EFFECT_MAPS: &str = "layer effects need float effect-map render targets, which this GPU lacks";
/// Every pipeline of one compositor, shared by its siblings.
///
/// No shader is used by two threads at once (#9173): wgpu-hal's D3D12 backend caches each
/// compiled shader and hands every pipeline a reference to it, but FXC's blobs count references
/// without atomics (gfx-rs/wgpu#10547), so threads sharing one could free it while the cache still
/// held it, and dropping the device then aborted the process. So each kernel has its own vertex
/// entry point ([`vertex_shader`]), a kernel's pipelines for its target formats are built
/// together on one thread, and every build in the process holds [`building`]: the tables of
/// several compositors on one device compile the same shaders.
pub(crate) struct Pipelines {
module: wgpu::ShaderModule,
vertex: wgpu::ShaderModule,
layout: wgpu::PipelineLayout,
kernels: Vec<KernelPipelines>,
}
/// One kernel's pipelines, one per target format, built together.
pub(crate) struct KernelPipelines {
pub(crate) kernel: Kernel,
entry: &'static str,
/// Its own vertex entry point in [`Pipelines::vertex`].
pub(crate) vertex: String,
pub(crate) formats: Vec<wgpu::TextureFormat>,
/// Per format, the pipeline or the error building it raised.
built: OnceLock<Vec<Result<wgpu::RenderPipeline, String>>>,
}
/// Held by every pipeline build in the process (see [`Pipelines`]).
fn building() -> std::sync::MutexGuard<'static, ()> {
static BUILDING: std::sync::Mutex<()> = std::sync::Mutex::new(());
BUILDING.lock().unwrap_or_else(std::sync::PoisonError::into_inner)
}
impl Pipelines {
/// The shaders and layout of every pipeline of [`table`]. Builds no pipeline.
pub(crate) fn new(device: &wgpu::Device, acc_format: wgpu::TextureFormat, bgl0: &wgpu::BindGroupLayout, bgl1: &wgpu::BindGroupLayout) -> Self {
let kernels = table(acc_format);
let module = device.create_shader_module(wgpu::ShaderModuleDescriptor { label: Some("pc_compose"), source: wgpu::ShaderSource::Wgsl(SHADER.into()) });
let vertex = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("pc_compose_vertex"),
source: wgpu::ShaderSource::Wgsl(vertex_shader(kernels.iter().map(|k| k.vertex.as_str())).into()),
});
let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pc_compose"),
bind_group_layouts: &[Some(bgl0), Some(bgl1)],
immediate_size: 0,
});
Self { module, vertex, layout, kernels }
}
/// The pipeline drawing `kernel` into `format`, built now if no draw needed it before. A
/// pipeline the device can't build is an [`Unsupported`] for every draw that needs it, so
/// that refresh uses the CPU compositor.
pub(crate) fn get(&self, device: &wgpu::Device, kernel: Kernel, format: wgpu::TextureFormat) -> Result<&wgpu::RenderPipeline, Unsupported> {
let missing = || Unsupported(format!("the compositor has no {kernel:?} pipeline for {format:?}"));
let k = self.kernels.iter().find(|k| k.kernel == kernel).ok_or_else(missing)?;
let i = k.formats.iter().position(|&f| f == format).ok_or_else(missing)?;
let built = match k.built.get() {
Some(built) => built,
None => {
let _building = building();
k.built.get_or_init(|| self.build(device, k))
}
};
built[i].as_ref().map_err(|e| {
Unsupported(if kernel.is_map() {
format!("{NO_EFFECT_MAPS} ({e})")
} else {
format!("couldn't build the compositor's `{}` pipeline: {e}", k.entry)
})
})
}
/// Build every pipeline no draw has built yet, one kernel per thread of the current Rayon
/// pool (or one after another), and return the first error a non-map pipeline raised. Effect
/// maps render to R32Float / R16Float, which some adapters (e.g. GL without float render
/// targets) can't: a failed map pipeline only turns layer effects to the CPU compositor
/// ([`Self::effect_maps`]).
#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn build_all(&self, device: &wgpu::Device, sequential: bool) -> Option<String> {
let _building = building();
let missing: Vec<&KernelPipelines> = self.kernels.iter().filter(|k| k.built.get().is_none()).collect();
let build = |k: &KernelPipelines| {
k.built.get_or_init(|| self.build(device, k));
};
if sequential {
missing.into_iter().for_each(build);
} else {
super::fx::par_map(missing, build);
}
let first_error = |maps: bool| {
self.kernels.iter().filter(|k| k.kernel.is_map() == maps).flat_map(|k| k.built.get().into_iter().flatten()).find_map(|b| b.as_ref().err().cloned())
};
if let Some(e) = first_error(true) {
log::info!("GPU compositor: no effect-map pipelines ({e}); layer effects use the CPU");
}
first_error(false)
}
/// `k`'s pipelines, each inside its own error scope on the calling thread (wgpu's scopes are
/// per thread). The caller holds [`building`].
fn build(&self, device: &wgpu::Device, k: &KernelPipelines) -> Vec<Result<wgpu::RenderPipeline, String>> {
k.formats
.iter()
.map(|&format| {
let (pipeline, error) = first_error(device, || {
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some(k.entry),
layout: Some(&self.layout),
vertex: wgpu::VertexState { module: &self.vertex, entry_point: Some(&k.vertex), buffers: &[], compilation_options: Default::default() },
primitive: wgpu::PrimitiveState::default(),
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
fragment: Some(wgpu::FragmentState {
module: &self.module,
entry_point: Some(k.entry),
targets: &[Some(wgpu::ColorTargetState { format, blend: None, write_mask: wgpu::ColorWrites::ALL })],
compilation_options: Default::default(),
}),
multiview_mask: None,
cache: None,
})
});
match error {
Some(e) => Err(e.to_string()),
None => Ok(pipeline),
}
})
.collect()
}
/// Whether no effect-map pipeline has failed to build (one not built yet is assumed to work).
pub(crate) fn effect_maps(&self) -> bool {
self.kernels.iter().filter(|k| k.kernel.is_map()).all(|k| k.built.get().is_none_or(|b| b.iter().all(Result::is_ok)))
}
/// How many pipelines have been built (or failed to build) so far, and how many there are.
pub(crate) fn counts(&self) -> (usize, usize) {
let built = self.kernels.iter().filter(|k| k.built.get().is_some()).map(|k| k.formats.len()).sum();
(built, self.kernels.iter().map(|k| k.formats.len()).sum())
}
}
/// Every drawn kernel, none built yet: plain kernels draw into `acc_format`, effect-map kernels
/// into R32F and R16F maps.
pub(crate) fn table(acc_format: wgpu::TextureFormat) -> Vec<KernelPipelines> {
let (plain, maps): (Vec<Kernel>, Vec<Kernel>) = Kernel::DRAWN.iter().partition(|k| !k.is_map());
plain
.into_iter()
.chain(maps)
.filter_map(|kernel| Some((kernel, kernel.entry()?)))
.enumerate()
.map(|(i, (kernel, entry))| KernelPipelines {
kernel,
entry,
vertex: format!("vs_{i}"),
formats: if kernel.is_map() { vec![MAP32, MAP16] } else { vec![acc_format] },
built: OnceLock::new(),
})
.collect()
}
/// The full-chunk triangle's vertex stage, once under each of `names` (`vs_0`, `vs_1`, ...): the
/// same code under distinct names, so each kernel compiles its own vertex shader.
///
/// A workaround, not a design: wgpu-hal's D3D12 shader cache shares a compiled FXC blob between
/// threads, and FXC's blobs don't count references atomically, so a shared one can be freed
/// while still cached (gfx-rs/wgpu#10547, #9173). Each copy costs one compile of a three-line
/// shader. Once a wgpu release fixes the cache, go back to one `vs` in `compose.wgsl` and build
/// each pipeline on its own.
pub(crate) fn vertex_shader<'a>(names: impl Iterator<Item = &'a str>) -> String {
let mut s = String::from(
"struct VOut { @builtin(position) pos: vec4<f32> };
",
);
for name in names {
s.push_str(&format!(
"@vertex fn {name}(@builtin(vertex_index) vi: u32) -> VOut {{
let uv = vec2(f32((vi << 1u) & 2u), f32(vi & 2u));
return VOut(vec4(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, 0.0, 1.0));
}}
"
));
}
s
}
+45 -127
View File
@@ -1,11 +1,10 @@
use super::batch::tile_grid;
use super::consts::{ACC_FORMAT, CHUNK, CHUNK_UNIFORM, FX_BUDGET, MAX_PATTERN_TEXTURE_BYTES, OP_UNIFORM, PAGE, PATTERN_BUDGET, RESIDENT_BUDGET};
use super::kit::{Kit, SHADER, build_jobs, tex_entry, uniform_entry, vertex_shader};
use super::kit::{Kit, tex_entry, uniform_entry};
use super::paging::{cell_rect, field_reaches, first_error, grid_rects};
use super::pipelines::{NO_EFFECT_MAPS, Pipelines};
use super::textures::{FxEntry, Resident, Tex, TexKind};
use super::{
Compositor, DeviceHealth, DocId, Document, Fault, HashMap, Kernel, LayerContent, Plan, Rect, Role, TILE_SIZE, Unsupported, fx, plan, prefix, timing,
};
use super::{Compositor, DeviceHealth, DocId, Document, Fault, HashMap, LayerContent, Plan, Rect, Role, TILE_SIZE, Unsupported, fx, plan, prefix, timing};
/// Classification of a synchronous compositor pipeline build failure.
///
@@ -55,84 +54,61 @@ impl Compositor {
if feats.allowed_usages.contains(wgpu::TextureUsages::RENDER_ATTACHMENT) { wgpu::TextureFormat::Rgba32Float } else { wgpu::TextureFormat::Rgba16Float }
}
/// [`Compositor::new_with_format`], but a shader or pipeline the driver can't build (e.g. a
/// D3D12 shader-compiler failure) is an `Err` instead of a panic, so the caller can fall back
/// to the CPU compositor. Where errors only arrive asynchronously (WebGPU), creation is assumed
/// to have worked.
/// [`Compositor::new_with_format`], but a shader the driver can't take is an `Err` instead of
/// a panic. Pipelines are built by the first draw that needs each one; one the driver can't
/// build (e.g. a D3D12 shader-compiler failure) makes that render [`Unsupported`], so the
/// caller falls back to the CPU compositor. Where errors only arrive asynchronously (WebGPU),
/// creation is assumed to have worked.
pub fn try_new_with_format(device: &wgpu::Device, acc_format: wgpu::TextureFormat) -> Result<Self, Unsupported> {
match first_error(device, || Self::build(device, acc_format, false)) {
((comp, None), None) => Ok(comp),
((_, Some(e)), _) | (_, Some(e)) => Err(Unsupported(format!("couldn't build the compositor's pipelines: {e}"))),
match first_error(device, || Self::build(device, acc_format)) {
(comp, None) => Ok(comp),
(_, Some(e)) => Err(Unsupported(format!("couldn't create the compositor: {e}"))),
}
}
/// Build pipelines using a dedicated Rayon pool instead of the process-wide pool.
/// [`Compositor::try_new_with_format`] that also builds every pipeline now, on a dedicated
/// Rayon pool of `threads` instead of the process-wide pool, so a failing one is an `Err`
/// here rather than on a later draw.
///
/// This keeps shader compilation from occupying workers needed by CPU compositing.
/// If the pool cannot be created, pipeline enumeration runs sequentially on the calling
/// thread. The outer and per-pipeline wgpu error scopes are kept on their respective
/// build threads.
/// The dedicated pool keeps shader compilation from occupying workers needed by CPU
/// compositing. If the pool cannot be created, the pipelines are built one after another on
/// the calling thread.
#[cfg(not(target_arch = "wasm32"))]
pub fn try_new_with_format_threads(device: &wgpu::Device, acc_format: wgpu::TextureFormat, threads: usize) -> Result<Self, Unsupported> {
Self::try_new_with_format_threads_classified(device, acc_format, threads).map_err(|e| Unsupported(e.message))
}
/// Build the compositor pipelines with an explicit failure classification for callers
/// that cache deterministic failures across launches. Only recognized shader compiler
/// [`Compositor::try_new_with_format_threads`] with an explicit failure classification for
/// callers that cache deterministic failures across launches. Only recognized shader compiler
/// diagnostics are marked deterministic; all other wgpu errors are transient or unknown.
#[cfg(not(target_arch = "wasm32"))]
pub fn try_new_with_format_threads_classified(device: &wgpu::Device, acc_format: wgpu::TextureFormat, threads: usize) -> Result<Self, BuildFailure> {
let comp = Self::try_new_with_format(device, acc_format).map_err(|e| BuildFailure { kind: BuildFailureKind::TransientOrUnknown, message: e.0 })?;
let pipelines = &comp.kit.pipelines;
let pool = rayon::ThreadPoolBuilder::new().num_threads(threads.max(1)).thread_name(|index| format!("photocraft-gpu-build-{index}")).build();
let built = match pool {
Ok(pool) => pool.install(|| first_error(device, || Self::build(device, acc_format, false))),
let error = match pool {
Ok(pool) => pool.install(|| pipelines.build_all(device, false)),
Err(e) => {
log::warn!("GPU compositor: couldn't create dedicated build pool; building sequentially: {e}");
first_error(device, || Self::build(device, acc_format, true))
pipelines.build_all(device, true)
}
};
match built {
((comp, None), None) => Ok(comp),
((_, Some(e)), None) => {
let kind = classify_build_diagnostic(&e.to_string());
Err(BuildFailure { kind, message: format!("couldn't build the compositor's pipelines: {e}") })
}
(_, Some(e)) => {
Err(BuildFailure { kind: BuildFailureKind::TransientOrUnknown, message: format!("couldn't build the compositor's pipelines: {e}") })
}
match error {
None => Ok(comp),
Some(e) => Err(BuildFailure { kind: classify_build_diagnostic(&e), message: format!("couldn't build the compositor's pipelines: {e}") }),
}
}
/// Create a compositor whose accumulation/render-target format is `acc_format`. Pass
/// `Rgba16Float` on adapters that can't render to `Rgba32Float` (e.g. some Intel Vulkan drivers),
/// which otherwise panics at render-pipeline creation. See `Compositor::preferred_acc_format`.
/// which otherwise fails at render-pipeline creation. See `Compositor::preferred_acc_format`.
/// Pipelines are built on first use (see [`Compositor::try_new_with_format`]).
pub fn new_with_format(device: &wgpu::Device, acc_format: wgpu::TextureFormat) -> Self {
let (comp, error) = Self::build(device, acc_format, false);
if let Some(e) = error {
log::error!("GPU compositor: couldn't build its pipelines: {e}");
}
comp
Self::build(device, acc_format)
}
/// The compositor and the first error raised building its (non-map) pipelines. They are
/// built in parallel, each inside its own error scope on the thread that builds it (wgpu's
/// scopes are per thread): on DX12, FXC compiles one shader at a time and the ~30 pipelines
/// took about 8 s on one core (#6419).
///
/// No shader is used by two threads at once (#9173): wgpu-hal's D3D12 backend caches each
/// compiled shader and hands every pipeline a reference to it, but FXC's blobs count
/// references without atomics (gfx-rs/wgpu#10547), so threads sharing one could free it
/// while the cache still held it, and dropping the device then aborted the process. So each
/// job has its own vertex entry point and fragment shaders ([`build_jobs`]), and builds of
/// several compositors take turns.
fn build(device: &wgpu::Device, acc_format: wgpu::TextureFormat, sequential: bool) -> (Self, Option<wgpu::Error>) {
static BUILDING: std::sync::Mutex<()> = std::sync::Mutex::new(());
let _building = BUILDING.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
let module = device.create_shader_module(wgpu::ShaderModuleDescriptor { label: Some("pc_compose"), source: wgpu::ShaderSource::Wgsl(SHADER.into()) });
let jobs = build_jobs(acc_format);
let vertex = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("pc_compose_vertex"),
source: wgpu::ShaderSource::Wgsl(vertex_shader(&jobs).into()),
});
/// The compositor's shaders, layouts and pipeline table ([`Pipelines`]); no pipeline yet.
fn build(device: &wgpu::Device, acc_format: wgpu::TextureFormat) -> Self {
let bgl0 = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
label: Some("pc_compose_uniforms"),
entries: &[uniform_entry(0, CHUNK_UNIFORM), uniform_entry(1, OP_UNIFORM)],
@@ -141,86 +117,29 @@ impl Compositor {
label: Some("pc_compose_textures"),
entries: &(0..8).map(tex_entry).collect::<Vec<_>>(),
});
let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
label: Some("pc_compose"),
bind_group_layouts: &[Some(&bgl0), Some(&bgl1)],
immediate_size: 0,
});
// `None` only for kernels without a fragment entry point, which are never drawn.
let pipeline = |k: Kernel, format: wgpu::TextureFormat, vs: &str| {
let entry = k.entry()?;
Some(device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some(entry),
layout: Some(&layout),
vertex: wgpu::VertexState { module: &vertex, entry_point: Some(vs), buffers: &[], compilation_options: Default::default() },
primitive: wgpu::PrimitiveState::default(),
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
fragment: Some(wgpu::FragmentState {
module: &module,
entry_point: Some(entry),
targets: &[Some(wgpu::ColorTargetState { format, blend: None, write_mask: wgpu::ColorWrites::ALL })],
compilation_options: Default::default(),
}),
multiview_mask: None,
cache: None,
}))
};
// Effect maps render to R32Float / R16Float, which some adapters (e.g. GL without float
// render targets) can't: then layer effects use the CPU compositor and the rest stays here.
let build_one = |job: super::kit::BuildJob| {
job.keys
.into_iter()
.map(|key| {
let (built, error) = first_error(device, || pipeline(key.0, key.1, &job.vertex));
(key, built, error)
})
.collect::<Vec<_>>()
};
let built: Vec<_> = if sequential { jobs.into_iter().map(build_one).collect() } else { fx::par_map(jobs, build_one) };
let built = built.into_iter().flatten();
let (mut pipelines, mut maps) = (HashMap::new(), Vec::new());
let (mut error, mut map_error) = (None, None);
for (key, built, e) in built {
let map = key.0.is_map();
// A failed map pipeline turns all effect maps off below. A failed non-map pipeline
// keeps its (invalid) handle: draws look pipelines up by key, so dropping it would
// turn a validation error into a missing-key panic on the first draw.
if let Some(e) = e {
if map {
map_error.get_or_insert(e);
continue;
}
error.get_or_insert(e);
}
let Some(p) = built else { continue };
if map {
maps.push((key, p));
} else {
pipelines.insert(key, p);
}
}
if let Some(e) = &map_error {
log::info!("GPU compositor: no effect-map pipelines ({e}); layer effects use the CPU");
} else {
pipelines.extend(maps);
}
let pipelines = std::sync::Arc::new(Pipelines::new(device, acc_format, &bgl0, &bgl1));
let dummy = Tex::new(device, "pc_compose_dummy", 1, 1, wgpu::TextureFormat::Rgba8Unorm, wgpu::TextureUsages::TEXTURE_BINDING).view;
let kit = Kit { pipelines, bgl0, bgl1, dummy };
let comp = Self::from_kit(kit, device.limits().max_texture_dimension_2d, acc_format, map_error.is_none());
(comp, error)
Self::from_kit(kit, device.limits().max_texture_dimension_2d, acc_format)
}
/// Test hook: how many of the compositor's pipelines have been built so far (shared with its
/// siblings), and how many it has.
#[doc(hidden)]
pub fn pipeline_counts(&self) -> (usize, usize) {
self.kit.pipelines.counts()
}
/// Create an independent compositor on the same device, reusing compiled pipelines.
/// Texture caches, budgets, focus and timing start at their defaults; no document state is
/// shared. Render with the same device and queue as this compositor.
pub fn sibling(&self) -> Self {
let mut sibling = Self::from_kit(self.kit.clone(), self.device_max, self.acc_format, self.effect_maps);
let mut sibling = Self::from_kit(self.kit.clone(), self.device_max, self.acc_format);
sibling.health = self.health.clone();
sibling
}
fn from_kit(kit: Kit, device_max: u32, acc_format: wgpu::TextureFormat, effect_maps: bool) -> Self {
fn from_kit(kit: Kit, device_max: u32, acc_format: wgpu::TextureFormat) -> Self {
Self {
kit,
pool: Vec::new(),
@@ -250,7 +169,6 @@ impl Compositor {
admit_freed: 0,
fail_allocs: 0,
acc_format,
effect_maps,
cmyk: 0,
health: None,
timer: None,
@@ -455,8 +373,8 @@ impl Compositor {
/// Effect maps must fit in textures (per page cell when the region exceeds the limit), and
/// patterns in one texture.
pub(crate) fn check_fx(&self, doc: &Document, p: &Plan<'_>) -> Result<(), Unsupported> {
if !self.effect_maps && !p.fx.is_empty() {
return Err(Unsupported("layer effects need float effect-map render targets, which this GPU lacks".into()));
if !p.fx.is_empty() && !self.kit.pipelines.effect_maps() {
return Err(Unsupported(NO_EFFECT_MAPS.into()));
}
for f in &p.fx {
if self.fx_paged(f.region) {
+11 -16
View File
@@ -132,31 +132,26 @@ fn half_roundtrip() {
}
}
/// #9173: no two pipeline build jobs share a shader, so no FXC blob is shared across threads.
/// #9173: no two kernels' pipelines share a shader, so no FXC blob is shared across threads.
#[test]
fn build_jobs_share_no_shader() {
fn kernel_pipelines_share_no_shader() {
use super::consts::{MAP16, MAP32};
use super::kit::{build_jobs, vertex_shader};
let jobs = build_jobs(wgpu::TextureFormat::Rgba32Float);
use super::pipelines::{table, vertex_shader};
let jobs = table(wgpu::TextureFormat::Rgba32Float);
let mut seen = std::collections::HashSet::new();
for job in &jobs {
let fragments: std::collections::HashSet<_> = job.keys.iter().filter_map(|k| k.0.entry()).collect();
for f in fragments {
assert!(seen.insert(f.to_string()), "fragment shader {f} is built by two jobs");
}
let f = job.kernel.entry().expect("a drawn kernel");
assert!(seen.insert(f.to_string()), "fragment shader {f} is built by two kernels");
assert!(seen.insert(job.vertex.clone()), "vertex entry {} is shared", job.vertex);
}
// Every drawn pipeline is still built, in the same formats.
let keys: Vec<_> = jobs.iter().flat_map(|job| job.keys.iter().copied()).collect();
let plain = Kernel::DRAWN.iter().filter(|k| !k.is_map()).count();
assert_eq!(keys.len(), plain + 2 * (Kernel::DRAWN.len() - plain));
// Every drawn kernel has its pipelines, in the same formats.
for k in Kernel::DRAWN {
let formats: Vec<_> = keys.iter().filter(|key| key.0 == k).map(|key| key.1).collect();
let formats: Vec<_> = jobs.iter().filter(|job| job.kernel == k).flat_map(|job| job.formats.iter().copied()).collect();
let want = if k.is_map() { vec![MAP32, MAP16] } else { vec![wgpu::TextureFormat::Rgba32Float] };
assert_eq!(formats, want, "{k:?}");
}
// The vertex module validates and has every job's entry point.
let src = vertex_shader(&jobs);
// The vertex module validates and has every kernel's entry point.
let src = vertex_shader(jobs.iter().map(|job| job.vertex.as_str()));
let module = wgpu::naga::front::wgsl::parse_str(&src).unwrap_or_else(|e| panic!("{}", e.emit_to_string(&src)));
wgpu::naga::valid::Validator::new(wgpu::naga::valid::ValidationFlags::all(), wgpu::naga::valid::Capabilities::empty())
.validate(&module)
@@ -167,7 +162,7 @@ fn build_jobs_share_no_shader() {
// The fragment module has no vertex stage, so the build can't fall back to one shared `vs`.
let compose = wgpu::naga::front::wgsl::parse_str(SHADER).unwrap_or_else(|e| panic!("{}", e.emit_to_string(SHADER)));
let shared: Vec<_> = compose.entry_points.iter().filter(|ep| ep.stage == wgpu::naga::ShaderStage::Vertex).map(|ep| ep.name.as_str()).collect();
assert!(shared.is_empty(), "compose.wgsl has a vertex entry point every job would share: {shared:?}");
assert!(shared.is_empty(), "compose.wgsl has a vertex entry point every kernel would share: {shared:?}");
}
#[test]
+89 -51
View File
@@ -135,7 +135,7 @@ fn gpu() -> Option<Gpu> {
None
}
};
let comp = timed("pipeline creation", compositor)?;
let comp = timed("compositor creation", compositor)?;
let mut paged = comp.sibling();
paged.set_texture_limit(PAGED_LIMIT);
Some(Gpu { device, queue, comp, paged, _lock: lock })
@@ -474,27 +474,31 @@ fn root_checkpoints_keep_clipping_groups_and_adjustments_whole() {
fn disjoint_partial_damages_admit_whole_chunks_not_damage_rects() {
let Some(mut g) = gpu() else { return };
let mut doc = base_doc(600, 300);
doc.layers.push(noise_layer("middle", PixelFormat::RGBA8, doc.bounds(), 2, 0.2));
doc.layers.push(noise_layer("top", PixelFormat::RGBA8, doc.bounds(), 3, 0.2));
// Each layer in a pass of its own (`alone`): batched into one run, the stack has no
// checkpoint below the top layer, so no render would capture and the byte count could not
// grow whatever the admission did.
doc.layers.push(alone(noise_layer("middle", PixelFormat::RGBA8, doc.bounds(), 2, 0.2)));
doc.layers.push(alone(noise_layer("top", PixelFormat::RGBA8, doc.bounds(), 3, 0.2)));
check(&mut g, &doc, "warm");
// Each series paints 8 rectangles. The second series' rectangles are all new (7 px across
// and 65 px down from the first's) but in the same chunk (the 600 x 300 document is one
// chunk at `CHUNK`), so a cache entry per damage rectangle would add 8 entries. (The four
// series of 24 this replaces painted the same 24 rectangles every time.)
let strokes = |g: &mut Gpu, doc: &Document, pass: i32| {
for i in 0..24u32 {
let x = 40 + ((i + pass as u32 * 13) % 8) * 60;
let y = 30 + (i / 8) * 60;
diff_rect(g, doc, Rect::new(x as i32, y as i32, x as i32 + 40, y as i32 + 30), "stroke").unwrap();
for i in 0..8 {
let (x, y) = (40 + i * 60 + pass * 7, 30 + pass * 65);
diff_rect(g, doc, Rect::new(x, y, x + 40, y + 30), "stroke").unwrap();
}
};
for pass in 0..2 {
doc.layers[2].opacity = 0.3 + pass as f32 * 0.1;
strokes(&mut g, &doc, pass);
}
// The same grid chunks hold every stroke: no entry-per-rectangle growth between passes.
doc.layers[2].opacity = 0.3;
strokes(&mut g, &doc, 0);
// The same grid chunks hold every stroke: no entry-per-rectangle growth between series.
let bytes = g.comp.composite_cache_bytes();
assert!(bytes > 0);
for pass in 2..4 {
doc.layers[2].opacity = 0.3 + pass as f32 * 0.1;
strokes(&mut g, &doc, pass);
}
// 0.6, the last opacity the four series this replaces left, so what follows renders the
// same document as before.
doc.layers[2].opacity = 0.6;
strokes(&mut g, &doc, 1);
assert_eq!(g.comp.composite_cache_bytes(), bytes, "partial damages must not add entries");
// A full-canvas render still populates the whole chunks, and the top edit afterwards hits.
check(&mut g, &doc, "full refresh after strokes");
@@ -1425,7 +1429,12 @@ fn small_layers_composite_over_their_bounds() {
check(&mut g, &big, "small layers across chunks");
}
fn many_layers_submit_inside_one_chunk_mode(paged: bool) {
/// One compositor is enough: at 16 x 12 the document is one page and one chunk under the whole
/// texture limit and under [`PAGED_LIMIT`] alike, and both draw it through the same `run_cell`.
/// The paged run this replaces reported the same `Stats`, field for field (1202 passes, 2401
/// tiles uploaded, 1 flush, 1 chunk, 1 cell).
#[test]
fn many_layers_submit_inside_one_chunk_whole() {
// P12: a refresh recorded every pass of a page cell into one command buffer, and with a few
// hundred layers Metal ran out of command buffers (device lost, "pc_compose_uniforms is
// invalid"). 1200 layers need well over 1000 passes in the document's only chunk: each is
@@ -1443,24 +1452,13 @@ fn many_layers_submit_inside_one_chunk_mode(paged: bool) {
d.layers.push(l);
}
let cpu = photocraft_compose::render(&d, d.bounds());
let comp = if paged { &mut g.paged } else { &mut g.comp };
let (out, stats) = photocraft_gpu::render_to_vec_stats(comp, &g.device, &g.queue, &d, d.bounds()).unwrap();
assert!(worst_diff(&cpu.px, &out).0 <= TOL, "1200 layers, paged={paged}");
let (out, stats) = photocraft_gpu::render_to_vec_stats(&mut g.comp, &g.device, &g.queue, &d, d.bounds()).unwrap();
assert!(worst_diff(&cpu.px, &out).0 <= TOL, "1200 layers");
assert_eq!(stats.layers_batched, 0, "{stats:?}");
assert_eq!(stats.chunks, 1);
assert!(stats.flushes > 0, "{stats:?}");
}
#[test]
fn many_layers_submit_inside_one_chunk_whole() {
many_layers_submit_inside_one_chunk_mode(false);
}
#[test]
fn many_layers_submit_inside_one_chunk_paged() {
many_layers_submit_inside_one_chunk_mode(true);
}
#[test]
fn runs_of_plain_layers_blend_in_one_pass() {
// Consecutive plain layers are drawn several to a pass (`fs_layerbatch`). Every layer mode at
@@ -1901,8 +1899,19 @@ fn fx_check(g: &mut Gpu, doc: &Document, what: &str) -> photocraft_gpu::Stats {
fn layer_effects_every_kind() {
let Some(mut g) = gpu() else { return };
let mut failures = Vec::new();
// On the GPU a 16-bit document differs only in the layer upload
// (`convert::rgb_gray16_to_f16`) and in what that input does to Dissolve's threshold and to
// pattern pixels: 16 bits run every Dissolve and pattern case, and the full stack (every kind
// at once) for the rest. Every case runs at 8 bits.
let depth_sensitive = |fx: &[Effect]| {
let text = format!("{fx:?}");
text.contains("Dissolve") || text.contains("Pattern")
};
for depth in [SampleType::U8, SampleType::U16] {
for (name, fx) in effect_cases() {
if depth == SampleType::U16 && name != "full stack" && !depth_sensitive(&fx) {
continue;
}
let mut d = fx_doc(96, 80, depth);
d.patterns.push(checker_pattern());
let mut l = blob("fx", d.pixel_format(), 46.0, 40.0, 22.0, [0.9, 0.4, 0.2]);
@@ -1985,6 +1994,12 @@ fn exterior_effects_merge_from_the_shape_at_any_fill() {
];
for depth in [SampleType::U8, SampleType::U16] {
for (name, fx) in &stacks {
// The merge (`effect_exterior`, `fs_fxmerge`) has no depth branch on the GPU or the
// CPU: depth only changes how the layer is uploaded (`convert::rgb_gray16_to_f16`). The
// stack with both effects covers that at 16 bits; every stack runs at 8 bits.
if depth == SampleType::U16 && *name != "shadow and glow" {
continue;
}
for (opacity, fill, blend) in [
(1.0, 1.0, BlendMode::Normal),
(0.8, 0.6, BlendMode::Normal),
@@ -3067,15 +3082,16 @@ fn rgba16f_fallback_path_renders() {
#[test]
fn unbuildable_pipelines_are_an_error_not_a_panic() {
// The app falls back to the CPU compositor on Err; a panic here would crash it (as FXC once
// did on D3D12). A depth format can't be a colour target, so its pipelines fail to build.
// The app builds every pipeline up front and falls back to the CPU compositor on Err; a panic
// here would crash it (as FXC once did on D3D12). A depth format can't be a colour target, so
// its pipelines fail to build.
let Some((adapter, device, _, _lock)) = any_device() else { return };
let e = Compositor::try_new_with_format(&device, wgpu::TextureFormat::Depth32Float).err().expect("depth target must fail");
let e = Compositor::try_new_with_format_threads(&device, wgpu::TextureFormat::Depth32Float, 4).err().expect("depth target must fail");
assert!(e.0.contains("pipelines"), "{e}");
// The format the app picks builds (effect maps the adapter can't render are left out, not fatal).
let f = Compositor::preferred_acc_format(&adapter);
if adapter.get_texture_format_features(f).allowed_usages.contains(wgpu::TextureUsages::RENDER_ATTACHMENT) {
assert!(Compositor::try_new_with_format(&device, f).is_ok());
assert!(Compositor::try_new_with_format_threads(&device, f, 4).is_ok());
}
}
@@ -3083,30 +3099,50 @@ fn unbuildable_pipelines_are_an_error_not_a_panic() {
/// A document several pages wide under [`PAGED_LIMIT`]: pixel layers crossing page borders (one
/// masked, one off-canvas), a big effect layer whose region exceeds the limit (maps built per
/// page cell), a type layer with a shadow, an adjustment, a clipped group and a gradient fill.
/// page cell), a type layer with a shadow across a border, an adjustment, a clipped group and a
/// gradient fill. 1100 x 900 (5 x 4 pages) for the residency and budget tests, whose views and
/// ratios are measured on it.
fn big_doc() -> Document {
let (w, h) = (1100, 900);
big_doc_sized(false)
}
/// [`big_doc`] at 660 x 580, 3 x 3 pages, with every layer moved and sized to cross the same
/// borders: the middle cell has page borders on all four sides and the four inner page corners,
/// so it holds every border and corner case of the larger document at about 40 % of its pixels.
fn small_big_doc() -> Document {
big_doc_sized(true)
}
fn big_doc_sized(small: bool) -> Document {
// Each geometry as (1100 x 900 value, 660 x 580 value).
let pick = |large: [i32; 4], reduced: [i32; 4]| {
let [x0, y0, x1, y1] = if small { reduced } else { large };
Rect::new(x0, y0, x1, y1)
};
let (w, h) = if small { (660, 580) } else { (1100, 900) };
let mut d = fx_doc(w, h, SampleType::U8);
// Right over the background: adjustment results round to 8 bits, which would turn sub-LSB
// float differences of blends beneath into whole steps.
let mut adj = Layer::new("invert", LayerContent::Adjustment(Adjustment::Invert));
adj.opacity = 0.6;
adj.mask = Some(mask(Rect::new(240, 0, 800, 520), 83, 0.0));
adj.mask = Some(mask(pick([240, 0, 800, 520], [240, 0, 560, 520]), 83, 0.0));
d.layers.push(adj);
let mut top = noise_layer("top", PixelFormat::RGBA8, Rect::new(-30, 200, 700, 820), 81, 0.0);
let mut top = noise_layer("top", PixelFormat::RGBA8, pick([-30, 200, 700, 820], [-30, 200, 620, 600]), 81, 0.0);
top.blend = BlendMode::Multiply;
top.mask = Some(mask(Rect::new(100, 240, 600, 700), 82, 1.0));
top.mask = Some(mask(pick([100, 240, 600, 700], [100, 240, 500, 540]), 82, 1.0));
d.layers.push(top);
let stack = effect_cases().into_iter().find(|(n, _)| *n == "full stack").unwrap().1;
let mut big = blob("big", d.pixel_format(), 520.0, 450.0, 330.0, [0.9, 0.4, 0.2]);
let (bx, by, br) = if small { (330.0, 290.0, 200.0) } else { (520.0, 450.0, 330.0) };
let mut big = blob("big", d.pixel_format(), bx, by, br, [0.9, 0.4, 0.2]);
big.effects.items = stack;
big.effects.items.push(Effect::OuterGlow(glow(FxPaint::Color(Color::rgb(0.2, 1.0, 0.6)), GlowTechnique::Softer, 40.0, 0.2, GlowSource::Edge)));
d.layers.push(big);
let mut text = as_text(blob("type", d.pixel_format(), 900.0, 150.0, 90.0, [0.1, 0.2, 0.9]));
let (tx, ty, tr) = if small { (560.0, 120.0, 60.0) } else { (900.0, 150.0, 90.0) };
let mut text = as_text(blob("type", d.pixel_format(), tx, ty, tr, [0.1, 0.2, 0.9]));
text.effects.items = vec![Effect::DropShadow(shadow(BlendMode::Multiply, 0.8, 135.0, 12.0, 20.0, 0.0))];
d.layers.push(text);
let a = noise_layer("ga", PixelFormat::RGBA8, Rect::new(200, 500, 1000, 880), 84, 0.6);
let mut c = noise_layer("gc", PixelFormat::RGBA8, Rect::new(0, 600, 1100, 700), 85, 0.0);
let a = noise_layer("ga", PixelFormat::RGBA8, pick([200, 500, 1000, 880], [150, 400, 620, 570]), 84, 0.6);
let mut c = noise_layer("gc", PixelFormat::RGBA8, pick([0, 600, 1100, 700], [0, 450, 660, 520]), 85, 0.0);
c.clipped = true;
c.blend = BlendMode::Screen;
let mut grp = Layer::group("g", vec![a, c]);
@@ -3124,20 +3160,20 @@ fn big_doc() -> Document {
fn documents_larger_than_the_texture_limit() {
let _gamma = TEXT_GAMMA.lock().unwrap_or_else(|e| e.into_inner());
let Some(mut g) = gpu() else { return };
let mut d = big_doc();
let mut d = small_big_doc();
assert!(g.paged.supports(&d).is_ok());
// Every pass sees page borders, and effect maps and blurs crossing them.
check(&mut g, &d, "big document");
let s = photocraft_gpu::render_to_vec_stats(&mut g.paged, &g.device, &g.queue, &d, d.bounds()).unwrap().1;
assert!(s.cells >= 20 && s.chunks == s.cells, "{s:?}");
// A viewport off the page grid covers only its cells.
let view = Rect::new(300, 330, 790, 610);
assert!(s.cells >= 9 && s.chunks == s.cells, "{s:?}");
// A viewport off the page grid covers only its cells (3 x 2).
let view = Rect::new(200, 230, 530, 430);
diff_rect(&mut g, &d, view, "viewport").unwrap_or_else(|e| panic!("{e}"));
let s = photocraft_gpu::render_to_vec_stats(&mut g.paged, &g.device, &g.queue, &d, view).unwrap().1;
assert_eq!(s.cells, 6, "{s:?}");
// A dab across a page corner on the effect layer, and an edit elsewhere.
d.layers[3].surface_mut().unwrap().fill_rect(Rect::new(500, 490, 530, 530), &[0.1, 0.1, 0.9, 1.0]);
d.layers[2].surface_mut().unwrap().fill_rect(Rect::new(250, 250, 270, 270), &[0.0, 0.0, 0.0, 0.0]);
d.layers[3].surface_mut().unwrap().fill_rect(Rect::new(240, 240, 270, 270), &[0.1, 0.1, 0.9, 1.0]);
d.layers[2].surface_mut().unwrap().fill_rect(Rect::new(500, 250, 520, 270), &[0.0, 0.0, 0.0, 0.0]);
check(&mut g, &d, "after dabs");
let s = photocraft_gpu::render_to_vec_stats(&mut g.paged, &g.device, &g.queue, &d, d.bounds()).unwrap().1;
assert_eq!((s.tiles_uploaded, s.fx_shapes), (0, 0), "nothing changed since the last render: {s:?}");
@@ -3147,13 +3183,15 @@ fn documents_larger_than_the_texture_limit() {
fn pages_are_evicted_under_the_budget() {
let _gamma = TEXT_GAMMA.lock().unwrap_or_else(|e| e.into_inner());
let Some(mut g) = gpu() else { return };
let mut d = big_doc();
let mut d = small_big_doc();
check(&mut g, &d, "warm");
let all = g.paged.resident_bytes();
// A budget of one page: everything but the cell being drawn is evicted as the render goes.
let page = u64::from(g.paged.page_size()).pow(2) * 4;
g.paged.set_resident_budget(page);
for round in 0..3 {
// Round 0 evicts from a warm, fully resident state; round 1 brings back pages evicted with
// the edits made meanwhile (a third round repeated round 1).
for round in 0..2 {
let cpu = timed("eviction CPU reference", || photocraft_compose::flatten(&d));
let (out, s) =
timed("eviction GPU render/readback", || photocraft_gpu::render_to_vec_stats(&mut g.paged, &g.device, &g.queue, &d, d.bounds())).unwrap();
+12 -12
View File
@@ -1,6 +1,7 @@
//! #6419: the compositor's pipelines are built on several threads. A pipeline the device can't
//! build is still an `Err` from `try_new_with_format`, not a panic from wgpu's default error
//! handler (error scopes are per thread). Skips when no GPU adapter exists.
//! #6419: the compositor's pipelines are built on several threads, or one by one on first use
//! (#15439). A pipeline the device can't build is an `Err` from the build or the draw, not a panic
//! from wgpu's default error handler (error scopes are per thread). Skips when no GPU adapter
//! exists.
use std::sync::Arc;
@@ -26,17 +27,16 @@ fn a_pipeline_built_on_another_thread_fails_as_an_error() {
let _lock = GPU_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
let Some((adapter, device, _queue)) = device() else { return };
// Never a render target, so every accumulation pipeline fails validation.
let Err(e) = Compositor::try_new_with_format(&device, wgpu::TextureFormat::Rgb9e5Ufloat) else {
let Err(e) = Compositor::try_new_with_format_threads(&device, wgpu::TextureFormat::Rgb9e5Ufloat, 4) else {
panic!("a compositor accumulating into Rgb9e5Ufloat");
};
assert!(e.0.contains("couldn't build the compositor's pipelines"), "{e:?}");
// The device is still usable for a compositor it can build.
assert!(Compositor::try_new_with_format(&device, Compositor::preferred_acc_format(&adapter)).is_ok());
assert!(Compositor::try_new_with_format_threads(&device, Compositor::preferred_acc_format(&adapter), 4).is_ok());
}
/// `new_with_format` on a device whose errors go to the caller's handler: a pipeline that failed
/// to build stays in the compositor as an invalid handle, so a draw reports GPU errors instead of
/// panicking on a missing pipeline.
/// A compositor whose pipelines fail to build on first use, on a device whose errors go to the
/// caller's handler: the draw is an `Err`, not a panic.
#[test]
fn a_compositor_with_failed_pipelines_draws_without_panicking() {
let _lock = GPU_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
@@ -46,10 +46,10 @@ fn a_compositor_with_failed_pipelines_draws_without_panicking() {
let mut comp = Compositor::new_with_format(&device, wgpu::TextureFormat::Rgb9e5Ufloat);
let doc = Document::with_background("t", Size::new(8, 8), ColorMode::Rgb, SampleType::U8, Color::rgba(0.5, 0.5, 0.5, 1.0));
// Drawing into an unrenderable format can't succeed, but must not panic.
let _ = render_to_vec(&mut comp, &device, &queue, &doc, doc.bounds());
assert!(render_to_vec(&mut comp, &device, &queue, &doc, doc.bounds()).is_err());
}
/// #9173: the compositor builds its pipelines on several threads (#6419). On Direct3D 12 with FXC,
/// #9173: the threaded build builds the compositor's pipelines on several threads (#6419). On Direct3D 12 with FXC,
/// wgpu-hal caches each compiled shader as an `ID3DBlob` whose reference count isn't atomic
/// (gfx-rs/wgpu#10547), so two threads building pipelines from the same shader could free a blob
/// the cache still holds; dropping the device then aborted the process (`null reference
@@ -83,12 +83,12 @@ fn parallel_compositor_builds_leave_the_shader_cache_intact() {
let format = Compositor::preferred_acc_format(&adapter);
// The first build compiles every shader; the rest are cache hits, so their threads take
// and release references to the cached shaders densely. The builds start together, so
// overlapping `Compositor::build` calls are exercised too (the process-wide lock).
// overlapping builds are exercised too (the process-wide lock).
std::thread::scope(|scope| {
let handles: Vec<_> = (0..builds)
.map(|_| {
scope.spawn(|| {
let built = Compositor::try_new_with_format(&device, format);
let built = Compositor::try_new_with_format_threads(&device, format, 4);
assert!(built.is_ok(), "round {round}: {:?}", built.err());
})
})
+39 -2
View File
@@ -9,6 +9,11 @@
//!
//! The Windows CI runners have no GPU: their adapter is WARP over DX12, so this runs FXC there.
use photocraft_color::{Color, ColorMode, SampleType};
use photocraft_doc::Document;
use photocraft_geom::Size;
use photocraft_gpu::{Compositor, render_to_vec};
use crate::GPU_LOCK;
#[test]
@@ -45,10 +50,42 @@ fn every_compositor_pipeline_builds() {
continue;
};
let info = adapter.get_info();
let format = photocraft_gpu::Compositor::preferred_acc_format(&adapter);
if let Err(e) = photocraft_gpu::Compositor::try_new_with_format(&device, format) {
let format = Compositor::preferred_acc_format(&adapter);
// Draws build only the pipelines they use; this builds every one.
let threads = std::thread::available_parallelism().map_or(1, std::num::NonZero::get);
if let Err(e) = Compositor::try_new_with_format_threads(&device, format, threads) {
panic!("{:?} adapter {} (driver {}): {e}", info.backend, info.name, info.driver_info);
}
}
}
}
/// #15439: a compositor builds a pipeline when a draw first needs it, so a process that draws one
/// layer compiles a few shaders, not all of them (FXC on the Windows runners' WARP adapter took
/// 3 to 7.5 s per process for all of them). Siblings share what any of them built.
#[test]
fn a_draw_builds_only_the_pipelines_it_uses() {
let _lock = GPU_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
let instance = crate::instance();
let Ok(adapter) = pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions::default())) else {
return eprintln!("skipping: no adapter");
};
let Ok((device, queue)) = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor::default())) else {
return eprintln!("skipping: no device");
};
let mut comp = match Compositor::try_new_with_format(&device, Compositor::preferred_acc_format(&adapter)) {
Ok(c) => c,
Err(e) => return eprintln!("skipping: {e}"),
};
let (built, all) = comp.pipeline_counts();
assert_eq!(built, 0, "creating a compositor builds no pipeline");
let doc = Document::with_background("one layer", Size::new(16, 16), ColorMode::Rgb, SampleType::U8, Color::rgba(0.25, 0.5, 0.75, 1.0));
render_to_vec(&mut comp, &device, &queue, &doc, doc.bounds()).expect("one layer renders on the GPU");
let (one_layer, _) = comp.pipeline_counts();
assert!(one_layer > 0 && one_layer * 4 < all, "one layer built {one_layer} of {all} pipelines");
// Drawing it again, or from a sibling, builds nothing new.
render_to_vec(&mut comp, &device, &queue, &doc, doc.bounds()).expect("second render");
let mut sibling = comp.sibling();
render_to_vec(&mut sibling, &device, &queue, &doc, doc.bounds()).expect("sibling render");
assert_eq!(sibling.pipeline_counts(), (one_layer, all));
}
File renamed without changes.
+1
View File
@@ -34,6 +34,7 @@ mod heif_unsupported;
mod krita_corpus;
mod lab16;
mod large_files;
mod large_png_export;
mod large_psb;
mod layer_labels;
mod layer_xmp;
@@ -9,7 +9,7 @@ use photocraft_plugins::{Error, Limits, Plugin};
use photocraft_raster::Surface;
use serde_json::json;
const INVERT: &[u8] = include_bytes!("fixtures/invert.wasm");
const INVERT: &[u8] = include_bytes!("../fixtures/invert.wasm");
/// A module implementing the ABI whose pieces can be swapped: `manifest` JSON, `version`,
/// `filter` body (params `$buf $len $w $h $ch $fmt $pp $pl`, result i32) and extra items.
+3
View File
@@ -0,0 +1,3 @@
//! The crate's integration tests, linked into one test binary.
mod abi;
+18
View File
@@ -0,0 +1,18 @@
//! The crate's integration tests, linked into one test binary.
mod scratch;
mod scratch_capacity;
mod scratch_recovery;
mod scratch_slow_folder;
mod scratch_translate;
mod spill;
use std::sync::{Mutex, MutexGuard, PoisonError};
/// The scratch pool and the spill configuration are process-wide: tests that touch either take turns.
pub(crate) static SCRATCH: Mutex<()> = Mutex::new(());
/// Takes one of the locks above; a failed test that held it does not fail the next.
pub(crate) fn lock(lock: &'static Mutex<()>) -> MutexGuard<'static, ()> {
lock.lock().unwrap_or_else(PoisonError::into_inner)
}
@@ -1,11 +1,6 @@
//! The scratch pool is process-wide, so these tests live in their own binary (nothing else
//! allocates tiles here) and take a lock to run one at a time.
//! The scratch pool is process-wide, so these tests take a lock to run one at a time.
use photocraft_raster::scratch::*;
use std::sync::{Mutex, PoisonError};
static SERIAL: Mutex<()> = Mutex::new(());
/// Lets a miss evict every pooled byte for the test's lifetime, so sizes can be counted.
struct NoFloor;
impl NoFloor {
@@ -22,7 +17,7 @@ impl Drop for NoFloor {
}
/// Locks the process-wide pool tests against concurrent access.
fn lock_serial() -> std::sync::MutexGuard<'static, ()> {
SERIAL.lock().unwrap_or_else(PoisonError::into_inner)
crate::lock(&crate::SCRATCH)
}
/// Runs a test alone with idle release off, so the idle thread can't empty the pool between a
@@ -25,6 +25,7 @@ fn answered_capacity() -> Option<u64> {
#[test]
fn scratch_capacity_follows_spilling_the_size_limit_and_pauses() {
let _scratch = crate::lock(&crate::SCRATCH);
let root = std::env::temp_dir().join(format!("photocraft-scratch-capacity-{}", std::process::id()));
let dir = root.join("scratch");
@@ -44,6 +44,7 @@ fn check(s: &Surface, seed: u32, n: i32) {
#[test]
fn full_or_missing_scratch_disk_pauses_and_recovers() {
let _scratch = crate::lock(&crate::SCRATCH);
let root = std::env::temp_dir().join(format!("photocraft-scratch-recovery-{}", std::process::id()));
let dir = root.join("scratch");
let budget = 8 * TILE_BYTES;
@@ -102,6 +102,7 @@ fn surface(seed: u32, n: i32) -> Surface {
#[test]
fn a_folder_that_stops_answering_never_freezes_the_app() {
let _scratch = crate::lock(&crate::SCRATCH);
let root = std::env::temp_dir().join(format!("photocraft-scratch-slow-{}", std::process::id()));
let good = root.join("good");
let good2 = root.join("good2");
@@ -6,6 +6,7 @@ use photocraft_raster::{Surface, spill};
#[test]
fn translations_and_shared_fills_preserve_spilled_pixels_at_every_depth() {
let _scratch = crate::lock(&crate::SCRATCH);
let dir = std::env::temp_dir().join(format!("photocraft-translate-spill-{}", std::process::id()));
for depth in [SampleType::U8, SampleType::U16, SampleType::F32] {
let format = PixelFormat::RGBA8.with_sample(depth);
@@ -44,6 +44,7 @@ fn check(s: &Surface, seed: u32, n: i32) {
#[test]
fn tiles_spill_and_come_back() {
let _scratch = crate::lock(&crate::SCRATCH);
let dir = std::env::temp_dir().join(format!("photocraft-spill-test-{}", std::process::id()));
let budget = 8 * TILE_BYTES;
spill::configure(Some(&dir), budget).unwrap();
+1
View File
@@ -69,6 +69,7 @@ impl PhotocraftApp {
remove_pending_target: None,
remove_trail: None,
menu_model: None,
toolbar_slots: Default::default(),
move_preview: None,
move_hover: None,
move_distance: None,
+3 -3
View File
@@ -614,11 +614,11 @@ mod zoom_animation_tests {
mod display_memo_tests;
#[cfg(test)]
mod cpu_background_tests;
mod cpu_background_gpu_tests;
#[cfg(test)]
#[path = "canvas/blend_viewport_tests.rs"]
mod blend_viewport_regression;
#[path = "canvas/blend_viewport_gpu_tests.rs"]
mod blend_viewport_gpu_tests;
#[cfg(test)]
#[path = "canvas/pixel_alignment_tests.rs"]
@@ -584,5 +584,7 @@ fn draw(
}
}
#[cfg(test)]
mod gpu_tests;
#[cfg(test)]
mod tests;
@@ -0,0 +1,664 @@
//! Background full CPU redraws (#4024) on a device: the GPU tests skip when there is no adapter.
use super::*;
use serde_json::json;
struct Gpu {
harness: egui_kittest::Harness<'static, Box<PhotocraftApp>>,
observer: GpuCanvas,
}
/// The app on a real device with background jobs, or `None` without a GPU adapter.
fn gpu_app() -> Option<Gpu> {
let observer = Arc::new(std::sync::Mutex::new(None));
let observer_out = observer.clone();
let built = std::panic::catch_unwind(std::panic::AssertUnwindSafe(move || {
egui_kittest::Harness::builder()
.with_size(egui::vec2(1000.0, 700.0))
.with_pixels_per_point(1.0)
.with_max_steps(64)
.wgpu_setup(crate::gpu_canvas::wgpu_setup())
.build_eframe(move |cc| {
PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());
let mut app = PhotocraftApp::with_context(cc.egui_ctx.clone(), photocraft_engine::Session::new(), Default::default());
if let Some(rs) = cc.wgpu_render_state.as_ref() {
*observer_out.lock().expect("observer") = Some(GpuCanvas::new(rs));
app.set_wgpu(rs.clone());
}
app.background_jobs = true;
app
})
}));
let Ok(harness) = built else {
eprintln!("skipping: no GPU adapter");
return None;
};
let observer = observer.lock().expect("observer").take()?;
Some(Gpu { harness, observer })
}
/// A document the wgpu compositor leaves to the CPU (knockout on its top layer, which also has
/// Blend If).
fn cpu_only_document(app: &mut PhotocraftApp, w: u32, h: u32) -> DocId {
app.run("file.new", json!({"width": w, "height": h, "background": "#336699"})).expect("new");
app.run("layer.new.layer", json!({})).expect("layer");
app.run("edit.fill", json!({"color": "#cc8844"})).expect("fill");
app.run("layer.layerStyle.blendingOptions", json!({"opacity": 60, "knockout": "shallow", "blendIf": {"channel": "gray", "underlying": [0, 10, 245, 255]}}))
.expect("blending options");
app.session.active().expect("document").doc.id
}
/// Frames until no redraw is running.
fn settle(g: &mut Gpu) {
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(60);
loop {
g.harness.step();
if g.harness.state().redraws.is_empty() {
return;
}
assert!(std::time::Instant::now() < deadline, "the redraw didn't finish");
std::thread::sleep(std::time::Duration::from_millis(2));
}
}
/// Run the frame that starts `doc`'s redraw with its worker held before the first batch, and wait
/// until that very worker reaches the hold: the redraw runs, every block still to draw, until the
/// returned guard drops. Without it a test that needs the redraw still running at its next frame
/// races the worker: a fast machine draws the document first, and so does a slow frame (a
/// software adapter's uploads) that keeps taking blocks as they land until the last one.
fn start_held_redraw(g: &mut Gpu, doc: DocId) -> HoldRedraws {
let held = hold_redraws();
g.harness.step();
let generation = g.harness.state().redraws.get(&doc).expect("the frame started a redraw").worker_generation;
assert!(wait_for_held_redraw(g.harness.state(), doc, generation, std::time::Duration::from_secs(10)), "the redraw worker never reached the pre-batch hold");
held
}
/// The canvas texture of `doc` against the synchronous CPU refresh of the current document.
fn assert_matches_synchronous(g: &mut Gpu, doc: DocId) {
let app = g.harness.state_mut();
let d = app.session.active().expect("document").doc.clone();
let (display, _) = crate::canvas::canvas_display(app, &d, None);
let reference = doc.0 ^ (1u64 << 60);
g.observer.upload_composite(reference, &d, display.as_deref());
let (_, size, shown) = g.observer.read_texels(doc.0).expect("canvas texture");
let (_, _, want) = g.observer.read_texels(reference).expect("reference texture");
assert_eq!(size, [d.size.width, d.size.height]);
let differ = shown.iter().zip(&want).filter(|(a, b)| a != b).count();
assert_eq!(differ, 0, "{differ} texels differ from the synchronous refresh");
}
#[test]
fn a_full_cpu_refresh_draws_in_the_background_with_the_synchronous_pixels() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 2600, 1700);
// Held, so the frame's later runs can't see the redraw already finished.
let held = hold_redraws();
g.harness.step();
assert!(g.harness.state().redraws.contains_key(&doc), "the frame started a redraw instead of compositing inline");
drop(held);
settle(&mut g);
let app = g.harness.state();
assert_eq!(app.perf.last_refresh, "background");
assert!(app.perf.gpu_fallback.as_deref().is_some_and(|f| f.contains("Advanced Blending")), "{:?}", app.perf.gpu_fallback);
assert_matches_synchronous(&mut g, doc);
}
#[test]
fn an_edit_during_a_redraw_is_not_overwritten_by_blocks_drawn_before_it() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
// Hold the worker before its first batch and wait until this very worker acknowledges that
// hold: when the fill lands, all 12 blocks of this 4×3 document are still to draw by it.
// Without the hold a fast machine finishes them before the next frame, so the edit never
// races the worker and this test only checked a completed redraw; without the per-worker
// acknowledgement an edit could beat the worker to the hold, and its restarted replacement
// would satisfy the checks.
let held = hold_redraws();
let doc = cpu_only_document(g.harness.state_mut(), 4096, 3072);
g.harness.step();
let generation = g.harness.state().redraws.get(&doc).expect("the frame started a redraw").worker_generation;
assert!(
wait_for_held_redraw(g.harness.state(), doc, generation, std::time::Duration::from_secs(10)),
"the redraw worker never reached the pre-batch hold; an edit would race an unstarted redraw"
);
// A corner, drawn last (farthest from the view's centre), changes on a layer of its own while
// the redraw runs: a small edit, drawn at once.
g.harness.state_mut().run("layer.new.layer", json!({})).expect("layer");
g.harness.step();
g.harness.state_mut().run("select.rect", json!({"x": 3900, "y": 2900, "width": 150, "height": 150})).expect("select");
g.harness.step();
g.harness.state_mut().run("edit.fill", json!({"color": "#22ee22"})).expect("fill");
g.harness.step();
assert_eq!(g.harness.state().perf.last_refresh, "rect", "the fill's damage was drawn synchronously");
// Still running with blocks to draw, and drawing the edited document, not the state before it.
let current = g.harness.state().session.active().expect("document").doc.clone();
let r = g.harness.state().redraws.get(&doc).expect("the redraw goes on");
assert!(r.pending.iter().any(|p| *p), "blocks are still to draw");
assert!(Arc::ptr_eq(&r.doc, &current) || *r.doc == *current, "the blocks left draw the edit");
drop(held);
settle(&mut g);
assert_matches_synchronous(&mut g, doc);
}
#[test]
fn an_edit_damaging_most_of_a_large_document_is_drawn_in_the_background_too() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 2600, 1700);
settle(&mut g);
// Filling most of the Blend If layer touches tiles all over it: the whole canvas (a fill of a
// small part damages only its own tiles, #9329).
g.harness.state_mut().run("select.rect", json!({"x": 100, "y": 100, "width": 2500, "height": 1500})).expect("select");
g.harness.step();
g.harness.state_mut().run("edit.fill", json!({"color": "#22ee22"})).expect("fill");
assert_eq!(g.harness.state().session.active().expect("document").last_damage, Some(Rect::new(0, 0, 2600, 1700)));
g.harness.step();
assert!(g.harness.state().redraws.contains_key(&doc), "not composited inline: {}", g.harness.state().perf.last_refresh);
settle(&mut g);
assert_eq!(g.harness.state().perf.last_refresh, "background");
assert_matches_synchronous(&mut g, doc);
}
#[test]
fn showing_a_hidden_layer_again_reuses_the_redraw_from_before_it_was_hidden() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 2600, 1700);
let layer = g.harness.state().session.active().and_then(|st| st.active_layer).expect("layer");
settle(&mut g);
assert_eq!(g.harness.state().perf.last_refresh, "background");
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "visible": false})).expect("hide");
settle(&mut g);
// Back to the state drawn before: its blocks come back, nothing is composited.
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "visible": true})).expect("show");
g.harness.step();
assert!(g.harness.state().redraws.is_empty(), "no redraw: {}", g.harness.state().perf.last_refresh);
assert_eq!(g.harness.state().perf.last_refresh, KEPT);
assert_matches_synchronous(&mut g, doc);
// A real change composites again. `last_refresh` is only set when that redraw finishes, so
// check that one started, then that it was a composite rather than kept blocks.
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "opacity": 0.3})).expect("opacity");
g.harness.step();
assert!(g.harness.state().redraws.contains_key(&doc), "not served from kept blocks: {}", g.harness.state().perf.last_refresh);
settle(&mut g);
assert_eq!(g.harness.state().perf.last_refresh, "background");
assert_matches_synchronous(&mut g, doc);
}
/// Memory Usage lowered while a redraw runs: the finished composite is kept within what it leaves
/// now, not what it left when the redraw began.
#[test]
fn a_redraw_finishing_after_memory_usage_drops_keeps_nothing_over_it() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 4096, 3072);
let held = start_held_redraw(&mut g, doc);
// Less than the document's own pixels: nothing is left for kept composites.
g.harness.state_mut().session.edit_prefs(|p| p.performance.memory_usage_mb = 1);
drop(held);
settle(&mut g);
assert!(g.harness.state().kept.entries.is_empty(), "a composite was kept over the current cap");
}
/// Color Settings › "Blend Text Colors Using Gamma" isn't part of the document, but type layers
/// composite with it: a state drawn before it changed is composited again, not uploaded from
/// blocks drawn with the old gamma. Only the session's setting changes here, not the process-wide
/// gamma compose reads, so tests compositing type layers at the same time aren't affected.
#[test]
fn a_state_drawn_before_the_text_gamma_changed_is_composited_again() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 2600, 1700);
let layer = g.harness.state().session.active().and_then(|st| st.active_layer).expect("layer");
settle(&mut g);
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "visible": false})).expect("hide");
settle(&mut g);
g.harness.state_mut().session.color.settings.blend_text_gamma = 1.0;
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "visible": true})).expect("show");
g.harness.step();
assert!(g.harness.state().redraws.contains_key(&doc), "served from blocks of the old gamma: {}", g.harness.state().perf.last_refresh);
settle(&mut g);
assert_eq!(g.harness.state().perf.last_refresh, "background");
assert_matches_synchronous(&mut g, doc);
}
/// The text gamma changing while a redraw runs: its blocks were drawn with both, so it isn't kept.
#[test]
fn a_redraw_across_a_text_gamma_change_is_not_kept() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 4096, 3072);
let held = start_held_redraw(&mut g, doc);
g.harness.state_mut().session.color.settings.blend_text_gamma = 1.0;
drop(held);
settle(&mut g);
assert!(g.harness.state().kept.entries.is_empty(), "a composite of two gammas was kept");
}
/// Changed and changed back while a redraw runs: blocks drawn in between still mix both.
#[test]
fn a_redraw_across_a_text_gamma_change_and_back_is_not_kept() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 4096, 3072);
let gamma = g.harness.state().session.color.settings.blend_text_gamma;
let held = start_held_redraw(&mut g, doc);
g.harness.state_mut().session.color.settings.blend_text_gamma = 1.0;
g.harness.step();
g.harness.state_mut().session.color.settings.blend_text_gamma = gamma;
assert!(g.harness.state().redraws.contains_key(&doc), "the redraw finished before the change back");
drop(held);
settle(&mut g);
assert!(g.harness.state().kept.entries.is_empty(), "a composite of two gammas was kept");
}
/// The same while another document is shown: its redraw goes on without being polled, so the
/// change is seen every frame, not only when it shows again.
#[test]
fn a_hidden_documents_redraw_across_a_text_gamma_change_and_back_is_not_kept() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 4096, 3072);
let gamma = g.harness.state().session.color.settings.blend_text_gamma;
let held = start_held_redraw(&mut g, doc);
g.harness.state_mut().run("file.new", json!({"width": 64, "height": 64})).expect("another document");
g.harness.step();
g.harness.state_mut().session.color.settings.blend_text_gamma = 1.0;
g.harness.step();
g.harness.state_mut().session.color.settings.blend_text_gamma = gamma;
g.harness.step();
assert!(g.harness.state().redraws.contains_key(&doc), "the hidden document's redraw stopped");
let i = g.harness.state().session.documents().iter().position(|st| st.doc.id == doc).expect("document");
g.harness.state_mut().session.set_active(i);
drop(held);
settle(&mut g);
assert!(g.harness.state().kept.entries.iter().all(|k| k.id != doc), "a composite of two gammas was kept");
}
/// Memory Usage lowered with no redraw running: the kept composites go at the next frame, not
/// only when the next redraw starts.
#[test]
fn kept_composites_go_when_memory_usage_drops_between_redraws() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
cpu_only_document(g.harness.state_mut(), 2600, 1700);
settle(&mut g);
assert!(!g.harness.state().kept.entries.is_empty(), "the finished redraw is kept");
g.harness.state_mut().session.edit_prefs(|p| p.performance.memory_usage_mb = 1);
g.harness.step();
assert!(g.harness.state().redraws.is_empty());
assert!(g.harness.state().kept.entries.is_empty(), "kept over the current cap");
}
/// An edit too small for a background redraw that grows the document past what Memory Usage
/// leaves: the kept composite goes at the next frame. The test holds the kept state itself, so
/// only the cap can drop it, not History letting go of the state.
#[test]
fn kept_composites_go_when_a_small_edit_grows_the_document_past_the_cap() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
cpu_only_document(g.harness.state_mut(), 2600, 1700);
settle(&mut g);
let app = g.harness.state_mut();
let st = app.session.active().expect("document");
let held = st.doc.clone();
let (used, kept) = (st.memory_bytes() as u64, app.kept.bytes());
assert!(kept > 0, "the finished redraw is kept");
// Room for the kept composite and 2-3 MB more.
let mb = (used + kept).div_ceil(1 << 20) + 2;
app.session.edit_prefs(|p| p.performance.memory_usage_mb = mb as _);
g.harness.step();
assert_eq!(g.harness.state().kept.entries.len(), 1, "still within the cap");
// 2 MP of new pixels (8 MB): under the size that redraws in the background.
for (cmd, p) in
[("layer.new.layer", json!({})), ("select.rect", json!({"x": 0, "y": 0, "width": 2000, "height": 1000})), ("edit.fill", json!({"color": "#cc2244"}))]
{
g.harness.state_mut().run(cmd, p).expect(cmd);
g.harness.step();
assert!(g.harness.state().redraws.is_empty(), "{cmd} redrew in the background");
}
assert!(g.harness.state().kept.entries.is_empty(), "kept over the cap after the edit");
drop(held);
}
/// The same for an older kept composite of another document: every kept document's edits count,
/// not only the newest one's.
#[test]
fn an_older_kept_composite_goes_when_its_document_grows_past_the_cap() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let a = cpu_only_document(g.harness.state_mut(), 2600, 1700);
settle(&mut g);
let b = cpu_only_document(g.harness.state_mut(), 2600, 1700);
settle(&mut g);
let app = g.harness.state_mut();
let held: Vec<_> = app.session.documents().iter().map(|st| st.doc.clone()).collect();
assert_eq!(app.kept.entries.iter().map(|k| k.id).collect::<Vec<_>>(), [b, a], "both kept, the second newest");
let used = app.session.documents().iter().map(|st| st.memory_bytes() as u64).max().unwrap_or(0);
let mb = (used + app.kept.bytes()).div_ceil(1 << 20) + 2;
app.session.edit_prefs(|p| p.performance.memory_usage_mb = mb as _);
let i = app.session.documents().iter().position(|st| st.doc.id == a).expect("document");
app.session.set_active(i);
g.harness.step();
assert_eq!(g.harness.state().kept.entries.len(), 2, "still within the cap");
for (cmd, p) in
[("layer.new.layer", json!({})), ("select.rect", json!({"x": 0, "y": 0, "width": 2000, "height": 1000})), ("edit.fill", json!({"color": "#cc2244"}))]
{
g.harness.state_mut().run(cmd, p).expect(cmd);
g.harness.step();
assert!(g.harness.state().redraws.is_empty(), "{cmd} redrew in the background");
}
assert!(g.harness.state().kept.entries.len() < 2, "kept over the cap after the older document grew");
drop(held);
}
/// A kept state History no longer holds goes at the next frame: its texels aren't held until
/// some later redraw.
#[test]
fn a_kept_state_history_purged_goes_at_the_next_frame() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
cpu_only_document(g.harness.state_mut(), 2600, 1700);
let layer = g.harness.state().session.active().and_then(|st| st.active_layer).expect("layer");
settle(&mut g);
// Hidden, the document is drawn on the GPU: the kept state is the one before, in History.
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "visible": false})).expect("hide");
settle(&mut g);
assert_eq!(g.harness.state().kept.entries.len(), 1, "the state before hiding is kept");
g.harness.state_mut().run("edit.purge.histories", json!({})).expect("purge");
g.harness.step();
assert!(g.harness.state().redraws.is_empty());
assert!(g.harness.state().kept.entries.is_empty(), "the purged state's composite is still held");
}
#[test]
fn closing_the_document_stops_its_redraw() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 4096, 3072);
// Held: the close lands while the redraw runs, and a cancelled worker leaves the hold.
let _held = start_held_redraw(&mut g, doc);
g.harness.state_mut().run("file.close", json!({"save": false})).expect("close");
g.harness.step();
assert!(g.harness.state().redraws.is_empty());
}
#[test]
fn hiding_a_large_layer_over_the_gpu_budget_redraws_in_the_background() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
// A layer covering most, but not all, of the document: hiding it damages a large rect that
// isn't the whole canvas.
let app = g.harness.state_mut();
app.run("file.new", json!({"width": 5000, "height": 2000, "background": "#336699"})).expect("new");
app.run("layer.new.layer", json!({})).expect("layer");
app.run("select.rect", json!({"x": 0, "y": 0, "width": 4800, "height": 1800})).expect("select");
app.run("edit.fill", json!({"color": "#cc8844"})).expect("fill");
app.run("select.deselect", json!({})).expect("deselect");
let (doc, layer) = {
let st = app.session.active().expect("document");
(st.doc.id, st.active_layer.expect("layer"))
};
settle(&mut g);
assert!(g.harness.state().perf.last_refresh.starts_with("gpu"), "the document fits the GPU: {}", g.harness.state().perf.last_refresh);
// A budget the pages of one 2048 px page cell fit (about 33 MB here) but not those of the
// whole width (80 MB), as on a multi-gigabyte PSB. Damage refreshes keep it: `gpu_budget`
// recomputes it for full ones only. A small edit still draws on the GPU at once.
g.harness.state_mut().run("layer.new.layer", json!({})).expect("layer");
g.harness.step();
g.harness.state_mut().run("select.rect", json!({"x": 100, "y": 100, "width": 64, "height": 64})).expect("select");
g.harness.step();
g.observer.set_memory_budget(48 << 20);
g.harness.state_mut().run("edit.fill", json!({"color": "#22ee22"})).expect("fill");
g.harness.step();
assert_eq!(g.harness.state().perf.last_refresh, "gpu-rect", "{:?}", g.harness.state().perf.gpu_fallback);
g.harness.state_mut().run("select.deselect", json!({})).expect("deselect");
g.harness.step();
assert!(g.harness.state().redraws.is_empty());
g.observer.set_memory_budget(48 << 20);
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "visible": false})).expect("hide");
let damage = g.harness.state().session.active().expect("document").last_damage.expect("damage");
assert!(damage != Rect::new(0, 0, 5000, 2000) && damage.width() as u64 * damage.height() as u64 >= crate::gpu_canvas::DEFER_PX, "{damage:?}");
g.harness.step();
assert!(g.harness.state().redraws.contains_key(&doc), "not composited inline: {}", g.harness.state().perf.last_refresh);
settle(&mut g);
assert_eq!(g.harness.state().perf.last_refresh, "background");
let app = g.harness.state();
assert!(matches!(app.render_path.current(doc.0), Some(crate::render_path::CpuReason::OverBudget { .. })), "{:?}", app.perf.gpu_fallback);
assert_matches_synchronous(&mut g, doc);
}
/// The active document's render path: its reason's kind.
fn render_path_of(g: &Gpu) -> Option<&'static str> {
let app = g.harness.state();
let doc = app.session.active().expect("document").doc.id.0;
app.render_path.current(doc).map(crate::render_path::CpuReason::kind)
}
/// On the GPU canvas: no reason, or only a software adapter's (CI's runners have one).
fn on_gpu_canvas(g: &Gpu) -> bool {
matches!(render_path_of(g), None | Some("softwareAdapter"))
}
#[test]
fn advanced_blending_fallback_is_shown_in_the_status_bar() {
use egui_kittest::kittest::Queryable;
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
cpu_only_document(g.harness.state_mut(), 800, 600);
g.harness.step();
settle(&mut g);
g.harness.run_steps(2);
assert_eq!(render_path_of(&g), Some("unsupported"));
// PLAN: assumes the status bar's CPU Rendering message exposes its tooltip text to kittest after a hover (panels-w19).
g.harness.get_by_label("CPU Rendering").hover();
g.harness.run_steps(40);
assert!(g.harness.query_by_label_contains("Advanced Blending").is_some(), "the tooltip names the cause");
}
#[test]
fn completed_compositor_build_refreshes_an_unchanged_cached_document() {
let _gpu = photocraft_testkit::gpu_lock();
for success in [true, false] {
let Some(mut g) = gpu_app() else { return };
let gpu = g.harness.state().gpu.as_ref().expect("GPU canvas").clone();
gpu.simulate_compositor_build();
g.harness.state_mut().run("file.new", json!({"width": 400, "height": 300, "background": "#336699"})).expect("new");
g.harness.step();
settle(&mut g);
let doc = g.harness.state().session.active().expect("document").doc.id;
let revision = g.harness.state().session.active().expect("document").revision;
assert_eq!(render_path_of(&g), Some("compositorBuilding"));
assert!(gpu.simulate_compositor_completion(success), "test compositor must build");
g.harness.step();
settle(&mut g);
g.harness.run_steps(2);
assert_eq!(g.harness.state().session.active().expect("document").revision, revision);
if success {
assert!(on_gpu_canvas(&g), "successful build should replace the temporary reason: {:?}", render_path_of(&g));
} else {
assert_eq!(render_path_of(&g), Some("compositorBuild"));
assert!(g.harness.state().perf.gpu_fallback.as_deref().is_some_and(|s| s.contains("simulated build failure")));
assert_matches_synchronous(&mut g, doc);
}
}
}
#[test]
fn a_canvas_over_the_texture_budget_records_its_reason() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
// The app's canvas, not the observer: each `GpuCanvas::new` shares a new budget.
g.harness.state().gpu.as_ref().expect("gpu canvas").set_canvas_budget(1);
g.harness.state_mut().run("file.new", json!({"width": 400, "height": 300, "background": "#336699"})).expect("new");
g.harness.run_steps(3);
assert_eq!(render_path_of(&g), Some("canvasTooLarge"));
let doc = g.harness.state().session.active().expect("document").doc.id.0;
assert_eq!(g.harness.state().render_path.history().filter(|c| c.doc == doc).count(), 1, "once, not every frame");
}
/// Frames until the active document's viewport pages are all rendered and uploaded.
fn settle_pages(g: &mut Gpu) {
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(60);
loop {
g.harness.step();
let app = g.harness.state();
let id = app.session.active().expect("document").doc.id;
if app.streams.get(&id).is_some_and(|s| !s.busy() && s.stats.wanted > 0 && s.stats.ready == s.stats.wanted) {
return;
}
assert!(std::time::Instant::now() < deadline, "the viewport pages didn't finish");
std::thread::sleep(std::time::Duration::from_millis(2));
}
}
/// The screen pixel at the window's centre.
fn centre_pixel(g: &mut Gpu) -> [u8; 4] {
let img = g.harness.render().expect("render");
let p = img.get_pixel(img.width() / 2, img.height() / 2);
p.0
}
/// #5332: a document whose texture set doesn't fit the canvas budget stays on the GPU canvas,
/// drawn from the pages in view instead of the CPU canvas, with the same pixels; an edit
/// re-renders only the pages, and closing it frees them.
#[test]
fn a_canvas_over_the_texture_budget_draws_its_viewport_pages_on_the_gpu() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
g.harness.state_mut().run("file.new", json!({"width": 3000, "height": 2000, "background": "#336699"})).expect("new");
g.harness.run_steps(3);
assert!(on_gpu_canvas(&g));
let whole = centre_pixel(&mut g);
let gpu = g.harness.state().gpu.clone().expect("gpu canvas");
let doc = g.harness.state().session.active().expect("document").doc.clone();
let key = crate::canvas::viewport_pages::stream_key(doc.id.0);
// Room for pages (half the budget), not for the document's texture set.
let (set, _) = gpu.canvas_fit(&doc).expect("fit");
gpu.set_canvas_budget(set - 1);
settle_pages(&mut g);
assert!(on_gpu_canvas(&g), "{:?}", render_path_of(&g));
assert!(gpu.texture_info(doc.id.0).is_none(), "no texture set");
let (pages, bytes) = gpu.pages(key);
let stats = g.harness.state().streams[&doc.id].stats.clone();
assert_eq!(pages.len(), stats.resident);
assert!(stats.wanted > 0 && stats.last_error.is_none(), "{stats:?}");
assert!(bytes <= (set - 1) / 2, "pages stay within half the budget: {bytes}");
let shown = centre_pixel(&mut g);
assert!((0..3).all(|i| shown[i].abs_diff(whole[i]) <= 2), "pages {shown:?}, texture set {whole:?}");
// An edit re-renders the pages it reaches.
let uploads = stats.uploads;
g.harness.state_mut().run("edit.fill", json!({"color": "#cc8844"})).expect("fill");
settle_pages(&mut g);
let stats = g.harness.state().streams[&doc.id].stats.clone();
assert!(stats.dirtied > 0 && stats.uploads > uploads, "{stats:?}");
let filled = centre_pixel(&mut g);
assert!(filled[0] > 0xb0 && filled[2] < 0x60, "the fill is shown: {filled:?}");
// A small edit re-renders only the part of each page it reaches, into the page held.
let (held, partial) = (gpu.pages(key).0.len(), stats.partial);
// (A frame between the steps, as in use: the edit's damage is known one revision at a time.)
g.harness.state_mut().run("select.rect", json!({"x": 1400, "y": 900, "width": 200, "height": 200})).expect("select");
settle_pages(&mut g);
g.harness.state_mut().run("edit.fill", json!({"color": "#22aa22"})).expect("small fill");
settle_pages(&mut g);
let stats = g.harness.state().streams[&doc.id].stats.clone();
assert!(stats.partial > partial, "{stats:?}");
assert_eq!(gpu.pages(key).0.len(), held, "no new page textures");
// Just its square is shown: 200 px at about 20% zoom, some 40 screen pixels a side.
let img = g.harness.render().expect("render");
let green = img.pixels().filter(|p| p.0[1] > 0x90 && p.0[0] < 0x50 && p.0[2] < 0x50).count();
assert!((1000..2500).contains(&green), "the small fill is shown: {green} pixels");
// A budget too small for one page draws it on the CPU canvas, as before.
gpu.set_canvas_budget(1);
g.harness.run_steps(3);
assert_eq!(render_path_of(&g), Some("canvasTooLarge"));
// Its pages and their work are freed meanwhile (#5332 review).
assert!(gpu.pages(key).0.is_empty(), "pages freed");
assert!(!g.harness.state().streams.contains_key(&doc.id), "stream dropped");
gpu.set_canvas_budget(set - 1);
settle_pages(&mut g);
// Closing the document cancels its work and frees its pages.
g.harness.state_mut().run("file.close", json!({"save": false})).expect("close");
g.harness.run_steps(3);
assert!(g.harness.state().streams.is_empty());
assert!(gpu.pages(key).0.is_empty());
}
/// Runs a Window › Arrange command, as its menu item does, and lets the layout settle.
fn arrange(g: &mut Gpu, command: &str) {
let ctx = g.harness.ctx.clone();
crate::menus::invoke(g.harness.state_mut(), &ctx, command, json!({})).expect("arrange");
g.harness.run_steps(3);
}
/// #5332 review: the open documents share one texture budget rather than each having all of
/// it. A document alone on screen keeps the whole budget; one in a background tab gives its
/// textures up when the shown one needs the room; and documents shown side by side split it,
/// a document over its share drawing from viewport pages.
#[test]
fn open_documents_share_one_texture_budget_with_the_shown_ones_first() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let gpu = g.harness.state().gpu.clone().expect("gpu canvas");
let new = |g: &mut Gpu| {
g.harness.state_mut().run("file.new", json!({"width": 3000, "height": 2000, "background": "#336699"})).expect("new");
g.harness.run_steps(3);
assert!(on_gpu_canvas(g), "{:?}", render_path_of(g));
g.harness.state().session.active().expect("document").doc.clone()
};
let a = new(&mut g);
let (set, _) = gpu.canvas_fit(&a).expect("fit");
// Room for one texture set and a half: a document alone on screen has all of it.
let budget = set + set / 2;
gpu.set_canvas_budget(budget);
assert_eq!(gpu.canvas_fit(&a), Some((set, budget)), "alone, the whole budget");
assert!(gpu.texture_info(a.id.0).is_some());
// A second tab: the shown document's texture set takes the room of the background one's.
let b = new(&mut g);
assert_eq!(gpu.canvas_fit(&b), Some((set, budget)));
assert!(gpu.texture_info(b.id.0).is_some());
assert!(gpu.texture_info(a.id.0).is_none(), "the background document's textures are freed");
// Back to the first tab: it gets its texture set back and the other gives its up.
g.harness.state_mut().session.set_active(0);
g.harness.run_steps(3);
assert!(on_gpu_canvas(&g), "{:?}", render_path_of(&g));
assert!(gpu.texture_info(a.id.0).is_some());
assert!(gpu.texture_info(b.id.0).is_none());
// Side by side, they split the budget: neither set fits its half, so both draw from pages.
arrange(&mut g, "window.arrange.twoUpVertical");
assert_eq!(gpu.canvas_fit(&a), Some((set, budget / 2)));
assert_eq!(gpu.canvas_fit(&b), Some((set, budget - budget / 2)));
settle_pages(&mut g);
assert!(on_gpu_canvas(&g), "{:?}", render_path_of(&g));
let streams = &g.harness.state().streams;
assert!(streams.contains_key(&a.id) && streams.contains_key(&b.id), "both on pages");
assert!(gpu.texture_info(a.id.0).is_none() && gpu.texture_info(b.id.0).is_none());
// Switching between them re-splits nothing: no page set is dropped.
let held = gpu.pages(crate::canvas::viewport_pages::stream_key(a.id.0)).0;
g.harness.state_mut().session.set_active(1);
g.harness.run_steps(3);
assert_eq!(gpu.canvas_fit(&a), Some((set, budget / 2)));
assert_eq!(gpu.pages(crate::canvas::viewport_pages::stream_key(a.id.0)).0, held, "no churn on a switch");
// Back to tabs: the shown document has the whole budget, and its texture set, again.
arrange(&mut g, "window.arrange.consolidateAllToTabs");
assert_eq!(gpu.canvas_fit(&b), Some((set, budget)));
assert!(on_gpu_canvas(&g), "{:?}", render_path_of(&g));
assert!(gpu.texture_info(b.id.0).is_some());
}
#[test]
fn a_flipped_view_records_why_it_draws_on_the_cpu() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
g.harness.state_mut().run("file.new", json!({"width": 400, "height": 300, "background": "#336699"})).expect("new");
g.harness.run_steps(3);
assert!(on_gpu_canvas(&g));
g.harness.state_mut().ui.view.flip_horizontal = true;
g.harness.run_steps(3);
assert_eq!(render_path_of(&g), Some("viewTransform"));
g.harness.state_mut().ui.view.flip_horizontal = false;
g.harness.run_steps(3);
assert!(on_gpu_canvas(&g), "back on the GPU");
}
@@ -1,7 +1,6 @@
//! Background full CPU redraws (#4024). The GPU tests skip when there is no adapter.
//! Background full CPU redraws (#4024): block order and the kept composites. The redraws on a device are in `gpu_tests`.
use super::*;
use serde_json::json;
#[test]
fn blocks_cover_the_document_once() {
@@ -119,663 +118,3 @@ fn kept_composites_come_back_only_for_the_exact_state_and_stay_bounded() {
cache.trim(u64::MAX);
assert!(cache.entries.is_empty());
}
struct Gpu {
harness: egui_kittest::Harness<'static, Box<PhotocraftApp>>,
observer: GpuCanvas,
}
/// The app on a real device with background jobs, or `None` without a GPU adapter.
fn gpu_app() -> Option<Gpu> {
let observer = Arc::new(std::sync::Mutex::new(None));
let observer_out = observer.clone();
let built = std::panic::catch_unwind(std::panic::AssertUnwindSafe(move || {
egui_kittest::Harness::builder()
.with_size(egui::vec2(1000.0, 700.0))
.with_pixels_per_point(1.0)
.with_max_steps(64)
.wgpu_setup(crate::gpu_canvas::wgpu_setup())
.build_eframe(move |cc| {
PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());
let mut app = PhotocraftApp::with_context(cc.egui_ctx.clone(), photocraft_engine::Session::new(), Default::default());
if let Some(rs) = cc.wgpu_render_state.as_ref() {
*observer_out.lock().expect("observer") = Some(GpuCanvas::new(rs));
app.set_wgpu(rs.clone());
}
app.background_jobs = true;
app
})
}));
let Ok(harness) = built else {
eprintln!("skipping: no GPU adapter");
return None;
};
let observer = observer.lock().expect("observer").take()?;
Some(Gpu { harness, observer })
}
/// A document the wgpu compositor leaves to the CPU (knockout on its top layer, which also has
/// Blend If).
fn cpu_only_document(app: &mut PhotocraftApp, w: u32, h: u32) -> DocId {
app.run("file.new", json!({"width": w, "height": h, "background": "#336699"})).expect("new");
app.run("layer.new.layer", json!({})).expect("layer");
app.run("edit.fill", json!({"color": "#cc8844"})).expect("fill");
app.run("layer.layerStyle.blendingOptions", json!({"opacity": 60, "knockout": "shallow", "blendIf": {"channel": "gray", "underlying": [0, 10, 245, 255]}}))
.expect("blending options");
app.session.active().expect("document").doc.id
}
/// Frames until no redraw is running.
fn settle(g: &mut Gpu) {
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(60);
loop {
g.harness.step();
if g.harness.state().redraws.is_empty() {
return;
}
assert!(std::time::Instant::now() < deadline, "the redraw didn't finish");
std::thread::sleep(std::time::Duration::from_millis(2));
}
}
/// Run the frame that starts `doc`'s redraw with its worker held before the first batch, and wait
/// until that very worker reaches the hold: the redraw runs, every block still to draw, until the
/// returned guard drops. Without it a test that needs the redraw still running at its next frame
/// races the worker: a fast machine draws the document first, and so does a slow frame (a
/// software adapter's uploads) that keeps taking blocks as they land until the last one.
fn start_held_redraw(g: &mut Gpu, doc: DocId) -> HoldRedraws {
let held = hold_redraws();
g.harness.step();
let generation = g.harness.state().redraws.get(&doc).expect("the frame started a redraw").worker_generation;
assert!(wait_for_held_redraw(g.harness.state(), doc, generation, std::time::Duration::from_secs(10)), "the redraw worker never reached the pre-batch hold");
held
}
/// The canvas texture of `doc` against the synchronous CPU refresh of the current document.
fn assert_matches_synchronous(g: &mut Gpu, doc: DocId) {
let app = g.harness.state_mut();
let d = app.session.active().expect("document").doc.clone();
let (display, _) = crate::canvas::canvas_display(app, &d, None);
let reference = doc.0 ^ (1u64 << 60);
g.observer.upload_composite(reference, &d, display.as_deref());
let (_, size, shown) = g.observer.read_texels(doc.0).expect("canvas texture");
let (_, _, want) = g.observer.read_texels(reference).expect("reference texture");
assert_eq!(size, [d.size.width, d.size.height]);
let differ = shown.iter().zip(&want).filter(|(a, b)| a != b).count();
assert_eq!(differ, 0, "{differ} texels differ from the synchronous refresh");
}
#[test]
fn a_full_cpu_refresh_draws_in_the_background_with_the_synchronous_pixels() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 2600, 1700);
// Held, so the frame's later runs can't see the redraw already finished.
let held = hold_redraws();
g.harness.step();
assert!(g.harness.state().redraws.contains_key(&doc), "the frame started a redraw instead of compositing inline");
drop(held);
settle(&mut g);
let app = g.harness.state();
assert_eq!(app.perf.last_refresh, "background");
assert!(app.perf.gpu_fallback.as_deref().is_some_and(|f| f.contains("Advanced Blending")), "{:?}", app.perf.gpu_fallback);
assert_matches_synchronous(&mut g, doc);
}
#[test]
fn an_edit_during_a_redraw_is_not_overwritten_by_blocks_drawn_before_it() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
// Hold the worker before its first batch and wait until this very worker acknowledges that
// hold: when the fill lands, all 12 blocks of this 4×3 document are still to draw by it.
// Without the hold a fast machine finishes them before the next frame, so the edit never
// races the worker and this test only checked a completed redraw; without the per-worker
// acknowledgement an edit could beat the worker to the hold, and its restarted replacement
// would satisfy the checks.
let held = hold_redraws();
let doc = cpu_only_document(g.harness.state_mut(), 4096, 3072);
g.harness.step();
let generation = g.harness.state().redraws.get(&doc).expect("the frame started a redraw").worker_generation;
assert!(
wait_for_held_redraw(g.harness.state(), doc, generation, std::time::Duration::from_secs(10)),
"the redraw worker never reached the pre-batch hold; an edit would race an unstarted redraw"
);
// A corner, drawn last (farthest from the view's centre), changes on a layer of its own while
// the redraw runs: a small edit, drawn at once.
g.harness.state_mut().run("layer.new.layer", json!({})).expect("layer");
g.harness.step();
g.harness.state_mut().run("select.rect", json!({"x": 3900, "y": 2900, "width": 150, "height": 150})).expect("select");
g.harness.step();
g.harness.state_mut().run("edit.fill", json!({"color": "#22ee22"})).expect("fill");
g.harness.step();
assert_eq!(g.harness.state().perf.last_refresh, "rect", "the fill's damage was drawn synchronously");
// Still running with blocks to draw, and drawing the edited document, not the state before it.
let current = g.harness.state().session.active().expect("document").doc.clone();
let r = g.harness.state().redraws.get(&doc).expect("the redraw goes on");
assert!(r.pending.iter().any(|p| *p), "blocks are still to draw");
assert!(Arc::ptr_eq(&r.doc, &current) || *r.doc == *current, "the blocks left draw the edit");
drop(held);
settle(&mut g);
assert_matches_synchronous(&mut g, doc);
}
#[test]
fn an_edit_damaging_most_of_a_large_document_is_drawn_in_the_background_too() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 2600, 1700);
settle(&mut g);
// Filling most of the Blend If layer touches tiles all over it: the whole canvas (a fill of a
// small part damages only its own tiles, #9329).
g.harness.state_mut().run("select.rect", json!({"x": 100, "y": 100, "width": 2500, "height": 1500})).expect("select");
g.harness.step();
g.harness.state_mut().run("edit.fill", json!({"color": "#22ee22"})).expect("fill");
assert_eq!(g.harness.state().session.active().expect("document").last_damage, Some(Rect::new(0, 0, 2600, 1700)));
g.harness.step();
assert!(g.harness.state().redraws.contains_key(&doc), "not composited inline: {}", g.harness.state().perf.last_refresh);
settle(&mut g);
assert_eq!(g.harness.state().perf.last_refresh, "background");
assert_matches_synchronous(&mut g, doc);
}
#[test]
fn showing_a_hidden_layer_again_reuses_the_redraw_from_before_it_was_hidden() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 2600, 1700);
let layer = g.harness.state().session.active().and_then(|st| st.active_layer).expect("layer");
settle(&mut g);
assert_eq!(g.harness.state().perf.last_refresh, "background");
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "visible": false})).expect("hide");
settle(&mut g);
// Back to the state drawn before: its blocks come back, nothing is composited.
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "visible": true})).expect("show");
g.harness.step();
assert!(g.harness.state().redraws.is_empty(), "no redraw: {}", g.harness.state().perf.last_refresh);
assert_eq!(g.harness.state().perf.last_refresh, KEPT);
assert_matches_synchronous(&mut g, doc);
// A real change composites again. `last_refresh` is only set when that redraw finishes, so
// check that one started, then that it was a composite rather than kept blocks.
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "opacity": 0.3})).expect("opacity");
g.harness.step();
assert!(g.harness.state().redraws.contains_key(&doc), "not served from kept blocks: {}", g.harness.state().perf.last_refresh);
settle(&mut g);
assert_eq!(g.harness.state().perf.last_refresh, "background");
assert_matches_synchronous(&mut g, doc);
}
/// Memory Usage lowered while a redraw runs: the finished composite is kept within what it leaves
/// now, not what it left when the redraw began.
#[test]
fn a_redraw_finishing_after_memory_usage_drops_keeps_nothing_over_it() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 4096, 3072);
let held = start_held_redraw(&mut g, doc);
// Less than the document's own pixels: nothing is left for kept composites.
g.harness.state_mut().session.edit_prefs(|p| p.performance.memory_usage_mb = 1);
drop(held);
settle(&mut g);
assert!(g.harness.state().kept.entries.is_empty(), "a composite was kept over the current cap");
}
/// Color Settings › "Blend Text Colors Using Gamma" isn't part of the document, but type layers
/// composite with it: a state drawn before it changed is composited again, not uploaded from
/// blocks drawn with the old gamma. Only the session's setting changes here, not the process-wide
/// gamma compose reads, so tests compositing type layers at the same time aren't affected.
#[test]
fn a_state_drawn_before_the_text_gamma_changed_is_composited_again() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 2600, 1700);
let layer = g.harness.state().session.active().and_then(|st| st.active_layer).expect("layer");
settle(&mut g);
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "visible": false})).expect("hide");
settle(&mut g);
g.harness.state_mut().session.color.settings.blend_text_gamma = 1.0;
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "visible": true})).expect("show");
g.harness.step();
assert!(g.harness.state().redraws.contains_key(&doc), "served from blocks of the old gamma: {}", g.harness.state().perf.last_refresh);
settle(&mut g);
assert_eq!(g.harness.state().perf.last_refresh, "background");
assert_matches_synchronous(&mut g, doc);
}
/// The text gamma changing while a redraw runs: its blocks were drawn with both, so it isn't kept.
#[test]
fn a_redraw_across_a_text_gamma_change_is_not_kept() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 4096, 3072);
let held = start_held_redraw(&mut g, doc);
g.harness.state_mut().session.color.settings.blend_text_gamma = 1.0;
drop(held);
settle(&mut g);
assert!(g.harness.state().kept.entries.is_empty(), "a composite of two gammas was kept");
}
/// Changed and changed back while a redraw runs: blocks drawn in between still mix both.
#[test]
fn a_redraw_across_a_text_gamma_change_and_back_is_not_kept() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 4096, 3072);
let gamma = g.harness.state().session.color.settings.blend_text_gamma;
let held = start_held_redraw(&mut g, doc);
g.harness.state_mut().session.color.settings.blend_text_gamma = 1.0;
g.harness.step();
g.harness.state_mut().session.color.settings.blend_text_gamma = gamma;
assert!(g.harness.state().redraws.contains_key(&doc), "the redraw finished before the change back");
drop(held);
settle(&mut g);
assert!(g.harness.state().kept.entries.is_empty(), "a composite of two gammas was kept");
}
/// The same while another document is shown: its redraw goes on without being polled, so the
/// change is seen every frame, not only when it shows again.
#[test]
fn a_hidden_documents_redraw_across_a_text_gamma_change_and_back_is_not_kept() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 4096, 3072);
let gamma = g.harness.state().session.color.settings.blend_text_gamma;
let held = start_held_redraw(&mut g, doc);
g.harness.state_mut().run("file.new", json!({"width": 64, "height": 64})).expect("another document");
g.harness.step();
g.harness.state_mut().session.color.settings.blend_text_gamma = 1.0;
g.harness.step();
g.harness.state_mut().session.color.settings.blend_text_gamma = gamma;
g.harness.step();
assert!(g.harness.state().redraws.contains_key(&doc), "the hidden document's redraw stopped");
let i = g.harness.state().session.documents().iter().position(|st| st.doc.id == doc).expect("document");
g.harness.state_mut().session.set_active(i);
drop(held);
settle(&mut g);
assert!(g.harness.state().kept.entries.iter().all(|k| k.id != doc), "a composite of two gammas was kept");
}
/// Memory Usage lowered with no redraw running: the kept composites go at the next frame, not
/// only when the next redraw starts.
#[test]
fn kept_composites_go_when_memory_usage_drops_between_redraws() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
cpu_only_document(g.harness.state_mut(), 2600, 1700);
settle(&mut g);
assert!(!g.harness.state().kept.entries.is_empty(), "the finished redraw is kept");
g.harness.state_mut().session.edit_prefs(|p| p.performance.memory_usage_mb = 1);
g.harness.step();
assert!(g.harness.state().redraws.is_empty());
assert!(g.harness.state().kept.entries.is_empty(), "kept over the current cap");
}
/// An edit too small for a background redraw that grows the document past what Memory Usage
/// leaves: the kept composite goes at the next frame. The test holds the kept state itself, so
/// only the cap can drop it, not History letting go of the state.
#[test]
fn kept_composites_go_when_a_small_edit_grows_the_document_past_the_cap() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
cpu_only_document(g.harness.state_mut(), 2600, 1700);
settle(&mut g);
let app = g.harness.state_mut();
let st = app.session.active().expect("document");
let held = st.doc.clone();
let (used, kept) = (st.memory_bytes() as u64, app.kept.bytes());
assert!(kept > 0, "the finished redraw is kept");
// Room for the kept composite and 2-3 MB more.
let mb = (used + kept).div_ceil(1 << 20) + 2;
app.session.edit_prefs(|p| p.performance.memory_usage_mb = mb as _);
g.harness.step();
assert_eq!(g.harness.state().kept.entries.len(), 1, "still within the cap");
// 2 MP of new pixels (8 MB): under the size that redraws in the background.
for (cmd, p) in
[("layer.new.layer", json!({})), ("select.rect", json!({"x": 0, "y": 0, "width": 2000, "height": 1000})), ("edit.fill", json!({"color": "#cc2244"}))]
{
g.harness.state_mut().run(cmd, p).expect(cmd);
g.harness.step();
assert!(g.harness.state().redraws.is_empty(), "{cmd} redrew in the background");
}
assert!(g.harness.state().kept.entries.is_empty(), "kept over the cap after the edit");
drop(held);
}
/// The same for an older kept composite of another document: every kept document's edits count,
/// not only the newest one's.
#[test]
fn an_older_kept_composite_goes_when_its_document_grows_past_the_cap() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let a = cpu_only_document(g.harness.state_mut(), 2600, 1700);
settle(&mut g);
let b = cpu_only_document(g.harness.state_mut(), 2600, 1700);
settle(&mut g);
let app = g.harness.state_mut();
let held: Vec<_> = app.session.documents().iter().map(|st| st.doc.clone()).collect();
assert_eq!(app.kept.entries.iter().map(|k| k.id).collect::<Vec<_>>(), [b, a], "both kept, the second newest");
let used = app.session.documents().iter().map(|st| st.memory_bytes() as u64).max().unwrap_or(0);
let mb = (used + app.kept.bytes()).div_ceil(1 << 20) + 2;
app.session.edit_prefs(|p| p.performance.memory_usage_mb = mb as _);
let i = app.session.documents().iter().position(|st| st.doc.id == a).expect("document");
app.session.set_active(i);
g.harness.step();
assert_eq!(g.harness.state().kept.entries.len(), 2, "still within the cap");
for (cmd, p) in
[("layer.new.layer", json!({})), ("select.rect", json!({"x": 0, "y": 0, "width": 2000, "height": 1000})), ("edit.fill", json!({"color": "#cc2244"}))]
{
g.harness.state_mut().run(cmd, p).expect(cmd);
g.harness.step();
assert!(g.harness.state().redraws.is_empty(), "{cmd} redrew in the background");
}
assert!(g.harness.state().kept.entries.len() < 2, "kept over the cap after the older document grew");
drop(held);
}
/// A kept state History no longer holds goes at the next frame: its texels aren't held until
/// some later redraw.
#[test]
fn a_kept_state_history_purged_goes_at_the_next_frame() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
cpu_only_document(g.harness.state_mut(), 2600, 1700);
let layer = g.harness.state().session.active().and_then(|st| st.active_layer).expect("layer");
settle(&mut g);
// Hidden, the document is drawn on the GPU: the kept state is the one before, in History.
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "visible": false})).expect("hide");
settle(&mut g);
assert_eq!(g.harness.state().kept.entries.len(), 1, "the state before hiding is kept");
g.harness.state_mut().run("edit.purge.histories", json!({})).expect("purge");
g.harness.step();
assert!(g.harness.state().redraws.is_empty());
assert!(g.harness.state().kept.entries.is_empty(), "the purged state's composite is still held");
}
#[test]
fn closing_the_document_stops_its_redraw() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let doc = cpu_only_document(g.harness.state_mut(), 4096, 3072);
// Held: the close lands while the redraw runs, and a cancelled worker leaves the hold.
let _held = start_held_redraw(&mut g, doc);
g.harness.state_mut().run("file.close", json!({"save": false})).expect("close");
g.harness.step();
assert!(g.harness.state().redraws.is_empty());
}
#[test]
fn hiding_a_large_layer_over_the_gpu_budget_redraws_in_the_background() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
// A layer covering most, but not all, of the document: hiding it damages a large rect that
// isn't the whole canvas.
let app = g.harness.state_mut();
app.run("file.new", json!({"width": 5000, "height": 2000, "background": "#336699"})).expect("new");
app.run("layer.new.layer", json!({})).expect("layer");
app.run("select.rect", json!({"x": 0, "y": 0, "width": 4800, "height": 1800})).expect("select");
app.run("edit.fill", json!({"color": "#cc8844"})).expect("fill");
app.run("select.deselect", json!({})).expect("deselect");
let (doc, layer) = {
let st = app.session.active().expect("document");
(st.doc.id, st.active_layer.expect("layer"))
};
settle(&mut g);
assert!(g.harness.state().perf.last_refresh.starts_with("gpu"), "the document fits the GPU: {}", g.harness.state().perf.last_refresh);
// A budget the pages of one 2048 px page cell fit (about 33 MB here) but not those of the
// whole width (80 MB), as on a multi-gigabyte PSB. Damage refreshes keep it: `gpu_budget`
// recomputes it for full ones only. A small edit still draws on the GPU at once.
g.harness.state_mut().run("layer.new.layer", json!({})).expect("layer");
g.harness.step();
g.harness.state_mut().run("select.rect", json!({"x": 100, "y": 100, "width": 64, "height": 64})).expect("select");
g.harness.step();
g.observer.set_memory_budget(48 << 20);
g.harness.state_mut().run("edit.fill", json!({"color": "#22ee22"})).expect("fill");
g.harness.step();
assert_eq!(g.harness.state().perf.last_refresh, "gpu-rect", "{:?}", g.harness.state().perf.gpu_fallback);
g.harness.state_mut().run("select.deselect", json!({})).expect("deselect");
g.harness.step();
assert!(g.harness.state().redraws.is_empty());
g.observer.set_memory_budget(48 << 20);
g.harness.state_mut().run("layer.setProps", json!({"layer": layer.0, "visible": false})).expect("hide");
let damage = g.harness.state().session.active().expect("document").last_damage.expect("damage");
assert!(damage != Rect::new(0, 0, 5000, 2000) && damage.width() as u64 * damage.height() as u64 >= crate::gpu_canvas::DEFER_PX, "{damage:?}");
g.harness.step();
assert!(g.harness.state().redraws.contains_key(&doc), "not composited inline: {}", g.harness.state().perf.last_refresh);
settle(&mut g);
assert_eq!(g.harness.state().perf.last_refresh, "background");
let app = g.harness.state();
assert!(matches!(app.render_path.current(doc.0), Some(crate::render_path::CpuReason::OverBudget { .. })), "{:?}", app.perf.gpu_fallback);
assert_matches_synchronous(&mut g, doc);
}
/// The active document's render path: its reason's kind.
fn render_path_of(g: &Gpu) -> Option<&'static str> {
let app = g.harness.state();
let doc = app.session.active().expect("document").doc.id.0;
app.render_path.current(doc).map(crate::render_path::CpuReason::kind)
}
/// On the GPU canvas: no reason, or only a software adapter's (CI's runners have one).
fn on_gpu_canvas(g: &Gpu) -> bool {
matches!(render_path_of(g), None | Some("softwareAdapter"))
}
#[test]
fn advanced_blending_fallback_is_shown_in_the_status_bar() {
use egui_kittest::kittest::Queryable;
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
cpu_only_document(g.harness.state_mut(), 800, 600);
g.harness.step();
settle(&mut g);
g.harness.run_steps(2);
assert_eq!(render_path_of(&g), Some("unsupported"));
// PLAN: assumes the status bar's CPU Rendering message exposes its tooltip text to kittest after a hover (panels-w19).
g.harness.get_by_label("CPU Rendering").hover();
g.harness.run_steps(40);
assert!(g.harness.query_by_label_contains("Advanced Blending").is_some(), "the tooltip names the cause");
}
#[test]
fn completed_compositor_build_refreshes_an_unchanged_cached_document() {
let _gpu = photocraft_testkit::gpu_lock();
for success in [true, false] {
let Some(mut g) = gpu_app() else { return };
let gpu = g.harness.state().gpu.as_ref().expect("GPU canvas").clone();
gpu.simulate_compositor_build();
g.harness.state_mut().run("file.new", json!({"width": 400, "height": 300, "background": "#336699"})).expect("new");
g.harness.step();
settle(&mut g);
let doc = g.harness.state().session.active().expect("document").doc.id;
let revision = g.harness.state().session.active().expect("document").revision;
assert_eq!(render_path_of(&g), Some("compositorBuilding"));
assert!(gpu.simulate_compositor_completion(success), "test compositor must build");
g.harness.step();
settle(&mut g);
g.harness.run_steps(2);
assert_eq!(g.harness.state().session.active().expect("document").revision, revision);
if success {
assert!(on_gpu_canvas(&g), "successful build should replace the temporary reason: {:?}", render_path_of(&g));
} else {
assert_eq!(render_path_of(&g), Some("compositorBuild"));
assert!(g.harness.state().perf.gpu_fallback.as_deref().is_some_and(|s| s.contains("simulated build failure")));
assert_matches_synchronous(&mut g, doc);
}
}
}
#[test]
fn a_canvas_over_the_texture_budget_records_its_reason() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
// The app's canvas, not the observer: each `GpuCanvas::new` shares a new budget.
g.harness.state().gpu.as_ref().expect("gpu canvas").set_canvas_budget(1);
g.harness.state_mut().run("file.new", json!({"width": 400, "height": 300, "background": "#336699"})).expect("new");
g.harness.run_steps(3);
assert_eq!(render_path_of(&g), Some("canvasTooLarge"));
let doc = g.harness.state().session.active().expect("document").doc.id.0;
assert_eq!(g.harness.state().render_path.history().filter(|c| c.doc == doc).count(), 1, "once, not every frame");
}
/// Frames until the active document's viewport pages are all rendered and uploaded.
fn settle_pages(g: &mut Gpu) {
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(60);
loop {
g.harness.step();
let app = g.harness.state();
let id = app.session.active().expect("document").doc.id;
if app.streams.get(&id).is_some_and(|s| !s.busy() && s.stats.wanted > 0 && s.stats.ready == s.stats.wanted) {
return;
}
assert!(std::time::Instant::now() < deadline, "the viewport pages didn't finish");
std::thread::sleep(std::time::Duration::from_millis(2));
}
}
/// The screen pixel at the window's centre.
fn centre_pixel(g: &mut Gpu) -> [u8; 4] {
let img = g.harness.render().expect("render");
let p = img.get_pixel(img.width() / 2, img.height() / 2);
p.0
}
/// #5332: a document whose texture set doesn't fit the canvas budget stays on the GPU canvas,
/// drawn from the pages in view instead of the CPU canvas, with the same pixels; an edit
/// re-renders only the pages, and closing it frees them.
#[test]
fn a_canvas_over_the_texture_budget_draws_its_viewport_pages_on_the_gpu() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
g.harness.state_mut().run("file.new", json!({"width": 3000, "height": 2000, "background": "#336699"})).expect("new");
g.harness.run_steps(3);
assert!(on_gpu_canvas(&g));
let whole = centre_pixel(&mut g);
let gpu = g.harness.state().gpu.clone().expect("gpu canvas");
let doc = g.harness.state().session.active().expect("document").doc.clone();
let key = crate::canvas::viewport_pages::stream_key(doc.id.0);
// Room for pages (half the budget), not for the document's texture set.
let (set, _) = gpu.canvas_fit(&doc).expect("fit");
gpu.set_canvas_budget(set - 1);
settle_pages(&mut g);
assert!(on_gpu_canvas(&g), "{:?}", render_path_of(&g));
assert!(gpu.texture_info(doc.id.0).is_none(), "no texture set");
let (pages, bytes) = gpu.pages(key);
let stats = g.harness.state().streams[&doc.id].stats.clone();
assert_eq!(pages.len(), stats.resident);
assert!(stats.wanted > 0 && stats.last_error.is_none(), "{stats:?}");
assert!(bytes <= (set - 1) / 2, "pages stay within half the budget: {bytes}");
let shown = centre_pixel(&mut g);
assert!((0..3).all(|i| shown[i].abs_diff(whole[i]) <= 2), "pages {shown:?}, texture set {whole:?}");
// An edit re-renders the pages it reaches.
let uploads = stats.uploads;
g.harness.state_mut().run("edit.fill", json!({"color": "#cc8844"})).expect("fill");
settle_pages(&mut g);
let stats = g.harness.state().streams[&doc.id].stats.clone();
assert!(stats.dirtied > 0 && stats.uploads > uploads, "{stats:?}");
let filled = centre_pixel(&mut g);
assert!(filled[0] > 0xb0 && filled[2] < 0x60, "the fill is shown: {filled:?}");
// A small edit re-renders only the part of each page it reaches, into the page held.
let (held, partial) = (gpu.pages(key).0.len(), stats.partial);
// (A frame between the steps, as in use: the edit's damage is known one revision at a time.)
g.harness.state_mut().run("select.rect", json!({"x": 1400, "y": 900, "width": 200, "height": 200})).expect("select");
settle_pages(&mut g);
g.harness.state_mut().run("edit.fill", json!({"color": "#22aa22"})).expect("small fill");
settle_pages(&mut g);
let stats = g.harness.state().streams[&doc.id].stats.clone();
assert!(stats.partial > partial, "{stats:?}");
assert_eq!(gpu.pages(key).0.len(), held, "no new page textures");
// Just its square is shown: 200 px at about 20% zoom, some 40 screen pixels a side.
let img = g.harness.render().expect("render");
let green = img.pixels().filter(|p| p.0[1] > 0x90 && p.0[0] < 0x50 && p.0[2] < 0x50).count();
assert!((1000..2500).contains(&green), "the small fill is shown: {green} pixels");
// A budget too small for one page draws it on the CPU canvas, as before.
gpu.set_canvas_budget(1);
g.harness.run_steps(3);
assert_eq!(render_path_of(&g), Some("canvasTooLarge"));
// Its pages and their work are freed meanwhile (#5332 review).
assert!(gpu.pages(key).0.is_empty(), "pages freed");
assert!(!g.harness.state().streams.contains_key(&doc.id), "stream dropped");
gpu.set_canvas_budget(set - 1);
settle_pages(&mut g);
// Closing the document cancels its work and frees its pages.
g.harness.state_mut().run("file.close", json!({"save": false})).expect("close");
g.harness.run_steps(3);
assert!(g.harness.state().streams.is_empty());
assert!(gpu.pages(key).0.is_empty());
}
/// Runs a Window › Arrange command, as its menu item does, and lets the layout settle.
fn arrange(g: &mut Gpu, command: &str) {
let ctx = g.harness.ctx.clone();
crate::menus::invoke(g.harness.state_mut(), &ctx, command, json!({})).expect("arrange");
g.harness.run_steps(3);
}
/// #5332 review: the open documents share one texture budget rather than each having all of
/// it. A document alone on screen keeps the whole budget; one in a background tab gives its
/// textures up when the shown one needs the room; and documents shown side by side split it,
/// a document over its share drawing from viewport pages.
#[test]
fn open_documents_share_one_texture_budget_with_the_shown_ones_first() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
let gpu = g.harness.state().gpu.clone().expect("gpu canvas");
let new = |g: &mut Gpu| {
g.harness.state_mut().run("file.new", json!({"width": 3000, "height": 2000, "background": "#336699"})).expect("new");
g.harness.run_steps(3);
assert!(on_gpu_canvas(g), "{:?}", render_path_of(g));
g.harness.state().session.active().expect("document").doc.clone()
};
let a = new(&mut g);
let (set, _) = gpu.canvas_fit(&a).expect("fit");
// Room for one texture set and a half: a document alone on screen has all of it.
let budget = set + set / 2;
gpu.set_canvas_budget(budget);
assert_eq!(gpu.canvas_fit(&a), Some((set, budget)), "alone, the whole budget");
assert!(gpu.texture_info(a.id.0).is_some());
// A second tab: the shown document's texture set takes the room of the background one's.
let b = new(&mut g);
assert_eq!(gpu.canvas_fit(&b), Some((set, budget)));
assert!(gpu.texture_info(b.id.0).is_some());
assert!(gpu.texture_info(a.id.0).is_none(), "the background document's textures are freed");
// Back to the first tab: it gets its texture set back and the other gives its up.
g.harness.state_mut().session.set_active(0);
g.harness.run_steps(3);
assert!(on_gpu_canvas(&g), "{:?}", render_path_of(&g));
assert!(gpu.texture_info(a.id.0).is_some());
assert!(gpu.texture_info(b.id.0).is_none());
// Side by side, they split the budget: neither set fits its half, so both draw from pages.
arrange(&mut g, "window.arrange.twoUpVertical");
assert_eq!(gpu.canvas_fit(&a), Some((set, budget / 2)));
assert_eq!(gpu.canvas_fit(&b), Some((set, budget - budget / 2)));
settle_pages(&mut g);
assert!(on_gpu_canvas(&g), "{:?}", render_path_of(&g));
let streams = &g.harness.state().streams;
assert!(streams.contains_key(&a.id) && streams.contains_key(&b.id), "both on pages");
assert!(gpu.texture_info(a.id.0).is_none() && gpu.texture_info(b.id.0).is_none());
// Switching between them re-splits nothing: no page set is dropped.
let held = gpu.pages(crate::canvas::viewport_pages::stream_key(a.id.0)).0;
g.harness.state_mut().session.set_active(1);
g.harness.run_steps(3);
assert_eq!(gpu.canvas_fit(&a), Some((set, budget / 2)));
assert_eq!(gpu.pages(crate::canvas::viewport_pages::stream_key(a.id.0)).0, held, "no churn on a switch");
// Back to tabs: the shown document has the whole budget, and its texture set, again.
arrange(&mut g, "window.arrange.consolidateAllToTabs");
assert_eq!(gpu.canvas_fit(&b), Some((set, budget)));
assert!(on_gpu_canvas(&g), "{:?}", render_path_of(&g));
assert!(gpu.texture_info(b.id.0).is_some());
}
#[test]
fn a_flipped_view_records_why_it_draws_on_the_cpu() {
let _gpu = photocraft_testkit::gpu_lock();
let Some(mut g) = gpu_app() else { return };
g.harness.state_mut().run("file.new", json!({"width": 400, "height": 300, "background": "#336699"})).expect("new");
g.harness.run_steps(3);
assert!(on_gpu_canvas(&g));
g.harness.state_mut().ui.view.flip_horizontal = true;
g.harness.run_steps(3);
assert_eq!(render_path_of(&g), Some("viewTransform"));
g.harness.state_mut().ui.view.flip_horizontal = false;
g.harness.run_steps(3);
assert!(on_gpu_canvas(&g), "back on the GPU");
}
@@ -36,12 +36,14 @@ fn blend_hover_pattern_tiles_and_multiple_views_reuse_current_pixels() {
let Some(rs) = render_state() else { return };
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default());
app.set_wgpu(rs);
app.run("file.new", json!({"width":1024,"height":768,"background":"#336699"})).unwrap();
// Half the 1024 × 768 canvas these views were first written for (see `check_blend_viewport`): `a` still runs off
// the right edge and `b` still lies apart from it.
app.run("file.new", json!({"width":512,"height":384,"background":"#336699"})).unwrap();
let layer = app.run("layer.new.layer", json!({})).unwrap()["layer"].as_u64().unwrap();
app.run("edit.fill", json!({"color":"#cc8844"})).unwrap();
let ctx = app.ctx().clone();
let a = DRect::new(724, 200, 1324, 500);
let b = DRect::new(0, 200, 300, 500);
let a = DRect::new(362, 100, 662, 250);
let b = DRect::new(0, 100, 150, 250);
assert!(ensure_gpu(&mut app, &ctx, 0, a, None));
app.ui.view.pattern_preview = true;
crate::blend_preview::hover(&mut app, &[photocraft_doc::LayerId(layer)], Some(BlendMode::Multiply));
@@ -136,7 +138,11 @@ fn check_blend_viewport(cpu_fallback: bool, multiple_layers: bool) {
let Some(rs) = render_state() else { return };
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default());
app.set_wgpu(rs);
app.run("file.new", json!({"width":1024,"height":768,"background":"#336699"})).unwrap();
// Every view and count below is half of the 1024 × 768 fixture first used: the clip to the view
// (`blend_preview::clip_damage`) and the catch-up (`blend_preview::uncovered`) are rectangle arithmetic with no
// size threshold, and the canvas stays far below the background redraw's (that case is
// `blend_hover_during_background_redraw_restores_committed_pixels`). The whole-canvas pixel checks cost a quarter.
app.run("file.new", json!({"width":512,"height":384,"background":"#336699"})).unwrap();
let layer = app.run("layer.new.layer", json!({})).unwrap()["layer"].as_u64().unwrap();
app.run("edit.fill", json!({"color":"#cc8844"})).unwrap();
if cpu_fallback {
@@ -150,7 +156,7 @@ fn check_blend_viewport(cpu_fallback: bool, multiple_layers: bool) {
layers.push(photocraft_doc::LayerId(other));
}
let ctx = app.ctx().clone();
let visible = DRect::new(256, 256, 512, 512);
let visible = DRect::new(128, 128, 256, 256);
assert!(ensure_gpu(&mut app, &ctx, 0, visible, None));
assert!(app.redraws.is_empty(), "small fixture must finish synchronously");
if cpu_fallback {
@@ -161,23 +167,23 @@ fn check_blend_viewport(cpu_fallback: bool, multiple_layers: bool) {
let original = gpu.read_texels(id.0).unwrap();
crate::blend_preview::hover(&mut app, &layers, Some(BlendMode::Multiply));
assert!(ensure_gpu(&mut app, &ctx, 0, visible, None));
println!("BLEND_VIEWPORT kind={} pixels={} expected={} adapter={:?}", app.perf.last_refresh, app.perf.last_refresh_px, 256 * 256, app.perf.gpu_info);
assert_eq!(app.perf.last_refresh_px, 256 * 256, "hover must not recomposite offscreen pixels of a full-canvas layer");
println!("BLEND_VIEWPORT kind={} pixels={} expected={} adapter={:?}", app.perf.last_refresh, app.perf.last_refresh_px, 128 * 128, app.perf.gpu_info);
assert_eq!(app.perf.last_refresh_px, 128 * 128, "hover must not recomposite offscreen pixels of a full-canvas layer");
assert_visible_pixels(&mut app, visible);
app.perf.last_refresh_px = 0;
assert!(ensure_gpu(&mut app, &ctx, 0, visible, None));
assert_eq!(app.perf.last_refresh_px, 0, "unchanged view and mode must reuse the texture");
let zoomed_out = DRect::new(128, 128, 640, 640);
let zoomed_out = DRect::new(64, 64, 320, 320);
assert!(ensure_gpu(&mut app, &ctx, 0, zoomed_out, None));
assert_eq!(app.perf.last_refresh_px, 512 * 512, "zooming out catches up the larger visible area");
let panned = DRect::new(640, 256, 896, 512);
assert_eq!(app.perf.last_refresh_px, 256 * 256, "zooming out catches up the larger visible area");
let panned = DRect::new(320, 128, 448, 256);
assert!(ensure_gpu(&mut app, &ctx, 0, panned, None));
assert_eq!(app.perf.last_refresh_px, 256 * 256, "newly exposed pixels must catch up without a mode change");
assert_eq!(app.perf.last_refresh_px, 128 * 128, "newly exposed pixels must catch up without a mode change");
crate::blend_preview::hover(&mut app, &layers, Some(BlendMode::Screen));
assert!(ensure_gpu(&mut app, &ctx, 0, panned, None));
assert_eq!(app.perf.last_refresh_px, 256 * 256);
assert_eq!(app.perf.last_refresh_px, 128 * 128);
assert!(ensure_gpu(&mut app, &ctx, 0, visible, None));
assert_eq!(app.perf.last_refresh_px, 256 * 256, "returning view must show the current mode");
assert_eq!(app.perf.last_refresh_px, 128 * 128, "returning view must show the current mode");
assert_visible_pixels(&mut app, visible);
assert_visible_pixels(&mut app, panned);
crate::blend_preview::hover(&mut app, &layers, None);
@@ -189,7 +195,7 @@ fn check_blend_viewport(cpu_fallback: bool, multiple_layers: bool) {
assert!(ensure_gpu(&mut app, &ctx, 0, visible, None));
let bounds = app.session.active().unwrap().doc.bounds();
assert_visible_pixels(&mut app, bounds);
app.run("file.new", json!({"width":1024,"height":768,"background":"white"})).unwrap();
app.run("file.new", json!({"width":512,"height":384,"background":"white"})).unwrap();
assert!(ensure_gpu(&mut app, &ctx, 1, visible, None));
app.session.set_active(0);
app.sync_views();
+2 -2
View File
@@ -1107,10 +1107,10 @@ impl GpuCanvas {
}
#[cfg(test)]
mod mip_tests;
mod mip_gpu_tests;
#[cfg(test)]
mod sharp_tests;
mod sharp_gpu_tests;
#[cfg(test)]
mod tests;
@@ -125,7 +125,11 @@ fn canvas_textures_the_gpu_refuses_leave_it_working(gpu: &GpuCanvas) {
fn check_mips(gpu: &GpuCanvas) {
for depth in [SampleType::U8, SampleType::U16, SampleType::F32] {
for (w, h) in [(1791, 1083), (513, 1), (1, 513)] {
// 767 × 431 is a single tile (`DEFAULT_TILE`) with odd sides down the chain (767, 383, 191, 95 and 431,
// 215, 107, 53), and its levels 1 and 2 are over `WHOLE_MIP_SIDE` (128), so the patch below redraws two
// levels by their damage (`mip_damage`) before the chain is redrawn whole: the paths 1791 × 1083 took, at
// a sixth of the pixels. The larger driver case stays in `partial_updates_match_a_full_rebuild_at_every_mip_level`.
for (w, h) in [(767, 431), (513, 1), (1, 513)] {
let mut full = Buffer::filled(Rect::from_xywh(0, 0, w, h), [0.25, 0.5, 0.75, 1.0]);
// Reusing the key also covers replacing textures after a size or depth change.
gpu.upload_buffer_full(1, &full, depth);
Loaded 100 of 154 files, more files were not shown because too many files have changed in this diff. Show more