Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

FC0a: bevy_ui's gradients (BackgroundGradient: LinearGradient, RadialGradient, ConicGradient, ColorStops with hints, UiPosition, Bevy's radial shapes, Oklab by default) as CSS gradients, and a bevy_ui page blending in linear light as Bevy's UI does: vendor/vello_shaders' fine stage decodes every colour, ramp and texel from sRGB, blends, and encodes once (set_blend_linear, marked by data-raea-blend on each root Node); ui/styling/stacked_gradients ported

shinyobjectzd03eb9d7c9e8
diff --git a/Cargo.lock b/Cargo.lock
index 194f78fc..facc8a8a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -20570,8 +20570,6 @@ dependencies = [
[[package]]
name = "vello_shaders"
version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2e653222cee49f2571729c3e4b0fa99bc4f826c6bb9487dbb88b825d552b3a27"
dependencies = [
"bytemuck",
"log",
diff --git a/Cargo.toml b/Cargo.toml
index 7c1296e1..91d09b1c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -298,6 +298,10 @@ anyrender_svg = { path = "vendor/anyrender_svg" }
# BumpAllocationSizes; changes marked "raea:"): raea-page sizes them for its pages, not Vello's 165 MiB of defaults.
# Back to upstream once #1861 lands.
vello_encoding = { path = "vendor/vello_encoding" }
+# vello_shaders 0.11.0 with linear-light blending in the fine stage, switched by vello_encoding's set_blend_linear
+# (changes marked "raea:"): raea-page blends a bevy_ui page as Bevy does (bevy_ui on Blitz). No upstream
+# equivalent yet (linebender/vello blends the encoded values).
+vello_shaders = { path = "vendor/vello_shaders" }
# Firewheel 0.12 on Bevy 0.20: bevy_reflect 0.20 and a glam-33 feature (BillyDM/Firewheel#144; changes marked "raea:")
firewheel = { path = "vendor/firewheel" }
firewheel-core = { path = "vendor/firewheel-core" }
diff --git a/bench/bevy-parity/examples.list b/bench/bevy-parity/examples.list
index b8e81082..aa757965 100644
--- a/bench/bevy-parity/examples.list
+++ b/bench/bevy-parity/examples.list
@@ -68,3 +68,4 @@ ui/styling/borders
ui/window_fallthrough
ui/text/inline_image
ui/layout/z_index
+ui/styling/stacked_gradients
diff --git a/bench/bevy-parity/runs.tsv b/bench/bevy-parity/runs.tsv
index c6fc2eab..92bd8dee 100644
--- a/bench/bevy-parity/runs.tsv
+++ b/bench/bevy-parity/runs.tsv
@@ -67,3 +67,4 @@ ui/styling/borders - 10
ui/window_fallthrough - 10
ui/text/inline_image - 10
ui/layout/z_index - 10
+ui/styling/stacked_gradients - 10
diff --git a/docs/bevy-parity.md b/docs/bevy-parity.md
index d2c87bab..d2660718 100644
--- a/docs/bevy-parity.md
+++ b/docs/bevy-parity.md
@@ -4,7 +4,7 @@ Bevy v0.20.0's examples against their raea TSX ports (docs/control.feature FC0a)
don't edit. An example passes when every probed frame passes pixels (SSIM 0.98 and no 32 px tile off by more than 24 of 255) and cost (batch keys and
frame time at most 1.25x the example's). Wall time is one machine's, measured in the same run.
-Examples: **438**, ported **68**, passing **64**, excluded **16** (docs/bevy-parity/excluded.tsv), left **358**.
+Examples: **438**, ported **69**, passing **65**, excluded **16** (docs/bevy-parity/excluded.tsv), left **357**.
raea's frame ms is its update's plus the time React takes to step a frame for its 3D (step), which the example
doesn't pay.
@@ -13,117 +13,118 @@ doesn't pay.
|---|---:|---:|---:|---:|---:|---:|---:|---:|---|---|
| 3d/rotate_environment_map | 5 | 0.999453 | 1 | 1 / 1 | 442 / 497 | 6 / 8 | 2 / 2 | 84.046 / 6.742 = 5.209 + 1.533 | yes | |
| 3d/rotate_environment_map | 60 | 0.999279 | 1 | 1 / 1 | 442 / 497 | 6 / 8 | 2 / 2 | 3.628 / 3.199 = 2.733 + 0.466 | yes | |
-| stress_tests/many_cubes | 30 | 0.995176 | 1 | 2 / 2 | 10444 / 10495 | 7 / 9 | 3 / 2 | 12.587 / 2.23 = 1.63 + 0.600 | yes | |
-| stress_tests/many_cubes | 60 | 0.995154 | 1 | 2 / 2 | 10444 / 10495 | 7 / 9 | 3 / 2 | 2.36 / 1.954 = 1.503 + 0.451 | yes | |
-| 3d/3d_scene | 10 | 0.999998 | 0 | 2 / 2 | 443 / 498 | 7 / 9 | 3 / 3 | 2.679 / 1.977 = 1.759 + 0.218 | yes | |
-| 3d/3d_scene | 5 | 0.999998 | 0 | 2 / 2 | 443 / 498 | 7 / 9 | 3 / 3 | 52.895 / 2.989 = 2.806 + 0.183 | yes | |
-| stress_tests/many_lights | 30 | 0.999957 | 0 | 1 / 1 | 100443 / 100495 | 7 / 9 | 3 / 3 | 16.798 / 5.847 = 3.705 + 2.142 | yes | |
-| stress_tests/many_lights | 60 | 0.999954 | 0 | 1 / 1 | 100445 / 100495 | 7 / 9 | 3 / 3 | 2.785 / 5.4 = 3.68 + 1.720 | no | frame 5.4 ms (3.68 update + 1.720 React step) vs 2.785 ms |
-| stress_tests/many_foxes | 30 | 0.989592 | 3 | 2 / 2 | 30464 / 31495 | 7 / 9 | 3 / 3 | 15.627 / 17.541 = 8.344 + 9.197 | yes | |
-| stress_tests/many_foxes | 60 | 0.990304 | 3 | 2 / 2 | 30464 / 31495 | 7 / 9 | 3 / 3 | 3.445 / 17.082 = 8.287 + 8.795 | no | frame 17.082 ms (8.287 update + 8.795 React step) vs 3.445 ms |
-| animation/animated_mesh | 30 | 0.996636 | 1 | 2 / 2 | 472 / 526 | 7 / 9 | 3 / 3 | 13.455 / 1.614 = 1.44 + 0.174 | yes | |
-| animation/animated_mesh | 60 | 0.996594 | 1 | 2 / 2 | 472 / 526 | 7 / 9 | 3 / 3 | 2.53 / 1.48 = 1.323 + 0.157 | yes | |
-| shader/extended_material | 30 | 1.000000 | 0 | 0 / 0 | 448 / 495 | 6 / 8 | 1 / 2 | 12.03 / 1.175 = 0.898 + 0.277 | yes | |
-| shader/extended_material | 60 | 1.000000 | 0 | 0 / 0 | 448 / 495 | 6 / 8 | 1 / 2 | 1.867 / 0.95 = 0.776 + 0.174 | yes | |
-| 3d/orthographic | 10 | 0.999503 | 0 | 5 / 2 | 446 / 499 | 10 / 9 | 6 / 3 | 29.78 / 1.247 = 1.056 + 0.191 | yes | |
-| 3d/parenting | 30 | 0.999969 | 0 | 1 / 1 | 443 / 496 | 6 / 8 | 2 / 2 | 11.825 / 1.147 = 0.963 + 0.184 | yes | |
-| 3d/parenting | 60 | 0.999968 | 0 | 1 / 1 | 443 / 496 | 6 / 8 | 2 / 2 | 1.88 / 0.996 = 0.837 + 0.159 | yes | |
-| 2d/mesh2d | 10 | 0.999348 | 0 | 0 / 0 | 441 / 494 | 6 / 8 | 1 / 1 | 28.75 / 1.218 = 1.073 + 0.145 | yes | |
-| 2d/sprite | 10 | 0.998326 | 8 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 28.965 / 1.157 = 1.012 + 0.145 | yes | |
-| transforms/3d_rotation | 30 | 1.000000 | 0 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 11.937 / 1.12 = 0.885 + 0.235 | yes | |
-| transforms/3d_rotation | 60 | 1.000000 | 0 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 1.758 / 0.942 = 0.798 + 0.144 | yes | |
-| 2d/sprite_flipping | 10 | 0.998326 | 8 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 28.942 / 1.334 = 1.17 + 0.164 | yes | |
-| 2d/move_sprite | 120 | 0.998270 | 9 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 1.192 / 0.825 = 0.75 + 0.075 | yes | |
-| 2d/move_sprite | 30 | 0.998261 | 8 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 10.825 / 0.978 = 0.849 + 0.129 | yes | |
-| 2d/transparency_2d | 10 | 0.997674 | 5 | 0 / 0 | 443 / 496 | 5 / 7 | 1 / 1 | 29.048 / 1.313 = 1.186 + 0.127 | yes | |
-| transforms/translation | 180 | 1.000000 | 0 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 1.655 / 0.931 = 0.856 + 0.075 | yes | |
-| transforms/translation | 60 | 1.000000 | 0 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 7.181 / 0.987 = 0.874 + 0.113 | yes | |
-| transforms/scale | 300 | 1.000000 | 0 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 1.537 / 0.83 = 0.765 + 0.065 | yes | |
-| transforms/scale | 60 | 1.000000 | 0 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 6.844 / 0.912 = 0.782 + 0.130 | yes | |
-| 3d/texture | 10 | 0.999547 | 1 | 3 / 3 | 443 / 497 | 6 / 8 | 4 / 4 | 30.728 / 1.337 = 1.128 + 0.209 | yes | |
-| shader/animate_shader | 30 | 1.000000 | 0 | 0 / 0 | 447 / 494 | 6 / 8 | 1 / 2 | 11.804 / 0.917 = 0.804 + 0.113 | yes | |
-| shader/animate_shader | 60 | 1.000000 | 0 | 0 / 0 | 447 / 494 | 6 / 8 | 1 / 2 | 1.9 / 0.856 = 0.769 + 0.087 | yes | |
-| 2d/sprite_sheet | 30 | 0.998820 | 5 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 11.249 / 1.025 = 0.896 + 0.129 | yes | |
-| 2d/sprite_sheet | 60 | 0.999054 | 5 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 1.407 / 0.892 = 0.802 + 0.090 | yes | |
-| 3d/pbr | 30 | 0.997685 | 8 | 56 / 56 | 499 / 550 | 6 / 8 | 57 / 57 | 12.865 / 1.022 = 0.932 + 0.090 | yes | |
-| 3d/pbr | 60 | 0.997685 | 8 | 56 / 56 | 499 / 550 | 6 / 8 | 57 / 57 | 1.908 / 0.959 = 0.887 + 0.072 | yes | |
-| 3d/animated_material | 30 | 0.999892 | 0 | 9 / 9 | 449 / 502 | 6 / 8 | 10 / 19 | 12.662 / 1.314 = 0.969 + 0.345 | yes | |
-| 3d/animated_material | 60 | 0.999940 | 0 | 9 / 9 | 449 / 502 | 6 / 8 | 10 / 19 | 1.902 / 1.155 = 0.891 + 0.264 | yes | |
-| camera/pan_camera_controller | 10 | 0.996838 | 10 | 0 / 0 | 446 / 494 | 5 / 7 | 1 / 1 | 29.052 / 1.132 = 0.977 + 0.155 | yes | |
-| camera/camera_orbit | 10 | 0.999220 | 8 | 2 / 2 | 445 / 496 | 7 / 9 | 3 / 3 | 31.381 / 1.377 = 1.159 + 0.218 | yes | |
-| camera/projection_zoom | 30 | 0.998026 | 8 | 2 / 2 | 473 / 526 | 7 / 9 | 3 / 3 | 12.741 / 1.137 = 0.998 + 0.139 | yes | |
-| 2d/sprite_animation | 12 | 0.997217 | 9 | 0 / 0 | 443 / 495 | 5 / 7 | 1 / 1 | 24.703 / 1.226 = 0.98 + 0.246 | yes | |
-| 2d/sprite_animation | 30 | 0.997017 | 8 | 0 / 0 | 443 / 495 | 5 / 7 | 1 / 1 | 1.358 / 1.044 = 0.889 + 0.155 | yes | |
-| 2d/sprite_animation | 60 | 0.997099 | 8 | 0 / 0 | 443 / 495 | 5 / 7 | 1 / 1 | 1.389 / 0.901 = 0.814 + 0.087 | yes | |
-| 2d/sprite_tile | 30 | 0.998633 | 7 | 0 / 0 | 442 / 494 | 5 / 7 | 1 / 1 | 10.846 / 1.106 = 0.954 + 0.152 | yes | |
-| 2d/sprite_tile | 300 | 0.992213 | 7 | 0 / 0 | 442 / 494 | 5 / 7 | 1 / 1 | 1.184 / 0.867 = 0.809 + 0.058 | yes | |
-| 3d/vertex_colors | 10 | 0.999019 | 0 | 2 / 2 | 443 / 496 | 7 / 9 | 3 / 3 | 34.985 / 2.117 = 1.881 + 0.236 | yes | |
-| 3d/spherical_area_lights | 10 | 0.999738 | 0 | 7 / 2 | 453 / 506 | 7 / 9 | 8 / 3 | 29.222 / 1.503 = 1.312 + 0.191 | yes | |
-| 3d/fog_volumes | 10 | 0.995718 | 14 | 0 / 0 | 442 / 494 | 5 / 7 | 1 / 1 | 30.969 / 1.633 = 1.333 + 0.300 | yes | |
-| 3d/fog_volumes | 60 | 0.995939 | 4 | 0 / 0 | 442 / 494 | 5 / 7 | 1 / 1 | 2.093 / 1.265 = 1.144 + 0.121 | yes | |
-| 3d/bloom_3d | 10 | 0.996668 | 11 | 4 / 4 | 541 / 593 | 6 / 8 | 5 / 5 | 32.558 / 2.872 = 1.745 + 1.127 | yes | |
-| 3d/bloom_3d | 60 | 0.996631 | 12 | 4 / 4 | 541 / 593 | 6 / 8 | 5 / 5 | 2.622 / 2.216 = 1.55 + 0.666 | yes | |
-| transforms/transform | 10 | 0.999999 | 0 | 2 / 2 | 443 / 496 | 7 / 9 | 3 / 3 | 30.631 / 1.389 = 1.062 + 0.327 | yes | |
-| transforms/transform | 120 | 1.000000 | 0 | 2 / 2 | 443 / 496 | 7 / 9 | 3 / 3 | 1.689 / 0.957 = 0.827 + 0.130 | yes | |
-| 3d/transparency_3d | 10 | 0.990065 | 25 | 6 / 6 | 447 / 500 | 11 / 10 | 7 / 11 | 35.823 / 2.702 = 2.075 + 0.627 | no | pixels 0.990065, worst tile 25 |
-| 3d/transparency_3d | 90 | 0.998632 | 0 | 6 / 6 | 447 / 500 | 11 / 10 | 7 / 11 | 3.104 / 1.966 = 1.799 + 0.167 | yes | |
-| animation/eased_motion | 150 | 0.999822 | 0 | 2 / 2 | 443 / 496 | 7 / 9 | 3 / 3 | 2.554 / 1.539 = 1.442 + 0.097 | yes | |
-| animation/eased_motion | 240 | 0.999823 | 0 | 2 / 2 | 443 / 496 | 7 / 9 | 3 / 3 | 2.424 / 1.574 = 1.503 + 0.071 | yes | |
-| animation/eased_motion | 60 | 0.999824 | 0 | 2 / 2 | 443 / 496 | 7 / 9 | 3 / 3 | 8.211 / 1.611 = 1.48 + 0.131 | yes | |
-| animation/color_animation | 120 | 0.998717 | 1 | 0 / 0 | 446 / 499 | 5 / 13 | 1 / 1 | 1.421 / 0.885 = 0.797 + 0.088 | yes | |
-| animation/color_animation | 200 | 0.996870 | 4 | 0 / 0 | 446 / 499 | 5 / 13 | 1 / 1 | 1.132 / 0.861 = 0.784 + 0.077 | yes | |
-| animation/color_animation | 30 | 0.998699 | 2 | 0 / 0 | 446 / 499 | 5 / 13 | 1 / 1 | 10.845 / 1.14 = 0.969 + 0.171 | yes | |
-| 3d/rect_light | 10 | 0.998374 | 8 | 2 / 2 | 446 / 501 | 7 / 9 | 3 / 3 | 32.839 / 1.414 = 1.159 + 0.255 | yes | |
-| 3d/shadow_caster_receiver | 10 | 1.000000 | 0 | 4 / 4 | 446 / 499 | 8 / 9 | 5 / 5 | 32.44 / 2.062 = 1.817 + 0.245 | yes | |
-| 3d/spotlight | 10 | 0.997767 | 10 | 4 / 4 | 530 / 582 | 9 / 11 | 5 / 5 | 34.756 / 6.09 = 4.381 + 1.709 | yes | |
-| 3d/spotlight | 90 | 0.996452 | 10 | 4 / 4 | 530 / 582 | 9 / 11 | 5 / 5 | 5.229 / 4.808 = 4.139 + 0.669 | yes | |
-| transforms/align | 10 | 0.993011 | 11 | 5 / 5 | 453 / 512 | 10 / 12 | 6 / 6 | 33.466 / 2.623 = 2.405 + 0.218 | yes | |
-| transforms/align | 30 | 0.993011 | 11 | 5 / 5 | 453 / 512 | 10 / 12 | 6 / 6 | 3.634 / 2.119 = 1.99 + 0.129 | yes | |
-| 3d/3d_viewport_to_world | 10 | 0.998921 | 1 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 2.524 / 1.287 = 1.051 + 0.236 | yes | |
-| 3d/3d_viewport_to_world | 5 | 0.998921 | 1 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 56.063 / 2.338 = 2.155 + 0.183 | yes | |
-| 3d/atmospheric_fog | 10 | 0.998688 | 9 | 2 / 2 | 449 / 504 | 7 / 9 | 3 / 3 | 3.417 / 1.696 = 1.451 + 0.245 | yes | |
-| 3d/atmospheric_fog | 5 | 0.998688 | 9 | 2 / 2 | 449 / 504 | 7 / 9 | 3 / 3 | 54.999 / 2.902 = 2.569 + 0.333 | yes | |
-| 2d/rotate_to_cursor | 10 | 0.999835 | 3 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 1.676 / 1.199 = 1.063 + 0.136 | yes | |
-| 2d/rotate_to_cursor | 5 | 0.999835 | 3 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 52.232 / 2.617 = 2.45 + 0.167 | yes | |
-| movement/smooth_follow | 120 | 0.998129 | 0 | 3 / 3 | 448 / 497 | 8 / 9 | 4 / 4 | 2.5 / 1.549 = 1.418 + 0.131 | yes | |
-| movement/smooth_follow | 30 | 0.998157 | 0 | 3 / 3 | 448 / 497 | 8 / 9 | 4 / 4 | 13.291 / 1.839 = 1.633 + 0.206 | yes | |
-| 2d/mesh2d_alpha_mode | 10 | 0.989355 | 8 | 0 / 0 | 446 / 499 | 6 / 13 | 1 / 1 | 1.78 / 1.264 = 1.128 + 0.136 | yes | |
-| 2d/mesh2d_alpha_mode | 5 | 0.989355 | 8 | 0 / 0 | 446 / 499 | 6 / 13 | 1 / 1 | 52.85 / 2.395 = 2.228 + 0.167 | yes | |
-| 3d/lightmaps | 10 | 1.000000 | 0 | 6 / 6 | 453 / 506 | 11 / 13 | 6 / 10 | 2.47 / 1.595 = 1.186 + 0.409 | yes | |
-| 3d/lightmaps | 5 | 1.000000 | 0 | 6 / 6 | 453 / 506 | 11 / 13 | 6 / 10 | 63.082 / 2.267 = 2.05 + 0.217 | yes | |
-| ui/styling/transparency_ui | 10 | 0.999700 | 3 | 0 / 0 | 445 / 492 | 5 / 7 | 1 / 1 | 1.694 / 1.103 = 0.967 + 0.136 | yes | |
-| ui/styling/transparency_ui | 5 | 0.999700 | 3 | 0 / 0 | 445 / 492 | 5 / 7 | 1 / 1 | 52.355 / 2.311 = 2.128 + 0.183 | yes | |
-| ui/layout/fixed_node | 10 | 1.000000 | 0 | 0 / 0 | 444 / 492 | 5 / 7 | 1 / 1 | 1.717 / 1.068 = 0.932 + 0.136 | yes | |
-| ui/layout/fixed_node | 5 | 1.000000 | 0 | 0 / 0 | 444 / 492 | 5 / 7 | 1 / 1 | 52.818 / 1.911 = 1.744 + 0.167 | yes | |
-| ui/images/image_node | 10 | 0.999893 | 1 | 0 / 0 | 442 / 492 | 5 / 7 | 1 / 1 | 1.624 / 1.109 = 0.964 + 0.145 | yes | |
-| ui/images/image_node | 5 | 0.999893 | 1 | 0 / 0 | 442 / 492 | 5 / 7 | 1 / 1 | 50.588 / 2.041 = 1.824 + 0.217 | yes | |
-| ui/text/font_weights | 10 | 0.990279 | 17 | 0 / 0 | 454 / 492 | 5 / 7 | 1 / 1 | 1.845 / 1.03 = 0.903 + 0.127 | yes | |
-| ui/text/font_weights | 5 | 0.990279 | 17 | 0 / 0 | 454 / 492 | 5 / 7 | 1 / 1 | 48.833 / 2.079 = 1.912 + 0.167 | yes | |
-| ui/text/font_variations | 10 | 0.992845 | 21 | 0 / 0 | 452 / 492 | 5 / 7 | 1 / 1 | 1.837 / 1.105 = 0.96 + 0.145 | yes | |
-| ui/text/font_variations | 5 | 0.992845 | 21 | 0 / 0 | 452 / 492 | 5 / 7 | 1 / 1 | 55.737 / 2.002 = 1.852 + 0.150 | yes | |
-| ui/text/text_background_colors | 10 | 0.997735 | 8 | 0 / 0 | 505 / 492 | 5 / 7 | 1 / 1 | 1.813 / 0.996 = 0.887 + 0.109 | yes | |
-| ui/text/text_background_colors | 5 | 0.997735 | 8 | 0 / 0 | 505 / 492 | 5 / 7 | 1 / 1 | 50.608 / 1.964 = 1.814 + 0.150 | yes | |
-| ui/text/strikethrough_and_underline | 10 | 0.990152 | 14 | 0 / 0 | 454 / 492 | 5 / 7 | 1 / 1 | 1.961 / 1.071 = 0.944 + 0.127 | yes | |
-| ui/text/strikethrough_and_underline | 5 | 0.990152 | 14 | 0 / 0 | 454 / 492 | 5 / 7 | 1 / 1 | 53.475 / 1.888 = 1.738 + 0.150 | yes | |
-| ui/scroll_and_overflow/overflow | 10 | 0.998143 | 5 | 0 / 0 | 461 / 492 | 5 / 7 | 1 / 1 | 1.631 / 1.044 = 0.88 + 0.164 | yes | |
-| ui/scroll_and_overflow/overflow | 5 | 0.998143 | 5 | 0 / 0 | 461 / 492 | 5 / 7 | 1 / 1 | 52.991 / 2.058 = 1.941 + 0.117 | yes | |
-| ui/images/ui_texture_atlas | 10 | 0.999601 | 7 | 0 / 0 | 445 / 492 | 5 / 7 | 1 / 1 | 1.948 / 1.198 = 1.071 + 0.127 | yes | |
-| ui/images/ui_texture_atlas | 5 | 0.999601 | 7 | 0 / 0 | 445 / 492 | 5 / 7 | 1 / 1 | 52.0 / 1.922 = 1.739 + 0.183 | yes | |
-| 2d/mesh2d_vertex_color_texture | 10 | 0.998651 | 6 | 0 / 0 | 442 / 495 | 6 / 9 | 1 / 1 | 29.837 / 1.185 = 1.04 + 0.145 | yes | |
-| 2d/mesh2d_repeated_texture | 10 | 0.991205 | 17 | 0 / 0 | 437 / 496 | 8 / 10 | 1 / 1 | 22.676 / 1.34 = 1.149 + 0.191 | yes | |
-| ui/layout/flex_layout | 10 | 0.990851 | 8 | 0 / 0 | 602 / 492 | 5 / 7 | 1 / 1 | 29.692 / 1.029 = 0.956 + 0.073 | yes | |
-| ui/scroll_and_overflow/overflow_clip_margin | 10 | 0.996801 | 9 | 0 / 0 | 465 / 492 | 5 / 7 | 1 / 1 | 29.204 / 1.063 = 0.881 + 0.182 | yes | |
-| ui/images/ui_texture_slice | 10 | 0.998957 | 8 | 0 / 0 | 447 / 492 | 5 / 7 | 1 / 1 | 29.886 / 1.111 = 0.984 + 0.127 | yes | |
-| ui/images/ui_texture_slice_flip_and_tile | 10 | 1.000000 | 0 | 0 / 0 | 461 / 492 | 5 / 7 | 1 / 1 | 28.713 / 1.084 = 0.911 + 0.173 | yes | |
-| ui/images/ui_texture_atlas_slice | 10 | 0.990791 | 17 | 0 / 0 | 447 / 492 | 5 / 7 | 1 / 1 | 29.54 / 1.128 = 0.992 + 0.136 | yes | |
-| ui/widgets/button | 10 | 0.999600 | 8 | 0 / 0 | 444 / 492 | 5 / 7 | 1 / 1 | 29.169 / 1.238 = 1.083 + 0.155 | yes | |
-| ui/text/letter_spacing | 10 | 0.995902 | 13 | 0 / 0 | 455 / 492 | 5 / 7 | 1 / 1 | 28.702 / 1.017 = 0.89 + 0.127 | yes | |
-| ui/styling/borders | 10 | 0.991738 | 9 | 0 / 0 | 591 / 492 | 5 / 7 | 1 / 1 | 29.246 / 0.931 = 0.84 + 0.091 | yes | |
-| ui/window_fallthrough | 10 | 0.990127 | 16 | 0 / 0 | 441 / 492 | 5 / 7 | 1 / 1 | 29.513 / 1.036 = 0.881 + 0.155 | yes | |
-| ui/text/inline_image | 10 | 0.996682 | 11 | 0 / 0 | 446 / 492 | 5 / 7 | 1 / 1 | 28.53 / 1.097 = 0.906 + 0.191 | yes | |
-| ui/layout/z_index | 10 | 1.000000 | 0 | 0 / 0 | 447 / 492 | 5 / 7 | 1 / 1 | 28.664 / 1.106 = 0.961 + 0.145 | yes | |
-| 3d/mesh_ray_cast | 300 | 0.999715 | 1 | 1 / 1 | 447 / 4658 | 6 / 8 | 2 / 2 | 3.142 / 4.672 = 1.319 + 3.353 | no | frame 4.672 ms (1.319 update + 3.353 React step) vs 3.142 ms |
-| 3d/mesh_ray_cast | 900 | 0.999608 | 1 | 1 / 1 | 447 / 44258 | 6 / 8 | 2 / 2 | 1.87 / 4.991 = 3.494 + 1.497 | no | frame 4.991 ms (3.494 update + 1.497 React step) vs 1.87 ms |
+| stress_tests/many_cubes | 30 | 0.995176 | 1 | 2 / 2 | 10444 / 10495 | 7 / 9 | 3 / 2 | 12.192 / 2.147 = 1.56 + 0.587 | yes | |
+| stress_tests/many_cubes | 60 | 0.995154 | 1 | 2 / 2 | 10444 / 10495 | 7 / 9 | 3 / 2 | 2.426 / 2.163 = 1.679 + 0.484 | yes | |
+| 3d/3d_scene | 10 | 0.999998 | 0 | 2 / 2 | 443 / 498 | 7 / 9 | 3 / 3 | 3.467 / 1.953 = 1.744 + 0.209 | yes | |
+| 3d/3d_scene | 5 | 0.999998 | 0 | 2 / 2 | 443 / 498 | 7 / 9 | 3 / 3 | 58.043 / 3.327 = 3.127 + 0.200 | yes | |
+| stress_tests/many_lights | 30 | 0.999957 | 0 | 1 / 1 | 100443 / 100495 | 7 / 9 | 3 / 3 | 17.454 / 6.206 = 3.983 + 2.223 | yes | |
+| stress_tests/many_lights | 60 | 0.999954 | 0 | 1 / 1 | 100445 / 100495 | 7 / 9 | 3 / 3 | 2.613 / 5.801 = 3.909 + 1.892 | no | frame 5.801 ms (3.909 update + 1.892 React step) vs 2.613 ms |
+| stress_tests/many_foxes | 30 | 0.989592 | 3 | 2 / 2 | 30464 / 31495 | 7 / 9 | 3 / 3 | 16.651 / 16.796 = 8.557 + 8.239 | yes | |
+| stress_tests/many_foxes | 60 | 0.990304 | 3 | 2 / 2 | 30464 / 31495 | 7 / 9 | 3 / 3 | 3.608 / 17.22 = 8.913 + 8.307 | no | frame 17.22 ms (8.913 update + 8.307 React step) vs 3.608 ms |
+| animation/animated_mesh | 30 | 0.996636 | 1 | 2 / 2 | 472 / 526 | 7 / 9 | 3 / 3 | 13.544 / 1.68 = 1.499 + 0.181 | yes | |
+| animation/animated_mesh | 60 | 0.996594 | 1 | 2 / 2 | 472 / 526 | 7 / 9 | 3 / 3 | 2.564 / 1.437 = 1.312 + 0.125 | yes | |
+| shader/extended_material | 30 | 1.000000 | 0 | 0 / 0 | 448 / 495 | 6 / 8 | 1 / 2 | 12.653 / 1.151 = 0.87 + 0.281 | yes | |
+| shader/extended_material | 60 | 1.000000 | 0 | 0 / 0 | 448 / 495 | 6 / 8 | 1 / 2 | 1.936 / 0.998 = 0.819 + 0.179 | yes | |
+| 3d/orthographic | 10 | 0.999503 | 0 | 5 / 2 | 446 / 499 | 10 / 9 | 6 / 3 | 32.193 / 1.413 = 1.186 + 0.227 | yes | |
+| 3d/parenting | 30 | 0.999969 | 0 | 1 / 1 | 443 / 496 | 6 / 8 | 2 / 2 | 11.992 / 1.22 = 0.972 + 0.248 | yes | |
+| 3d/parenting | 60 | 0.999968 | 0 | 1 / 1 | 443 / 496 | 6 / 8 | 2 / 2 | 1.977 / 1.057 = 0.921 + 0.136 | yes | |
+| 2d/mesh2d | 10 | 0.999348 | 0 | 0 / 0 | 441 / 494 | 6 / 8 | 1 / 1 | 29.819 / 1.168 = 1.004 + 0.164 | yes | |
+| 2d/sprite | 10 | 0.998326 | 8 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 30.978 / 1.239 = 1.094 + 0.145 | yes | |
+| transforms/3d_rotation | 30 | 1.000000 | 0 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 10.882 / 1.089 = 0.918 + 0.171 | yes | |
+| transforms/3d_rotation | 60 | 1.000000 | 0 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 1.571 / 1.004 = 0.848 + 0.156 | yes | |
+| 2d/sprite_flipping | 10 | 0.998326 | 8 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 28.886 / 1.202 = 1.075 + 0.127 | yes | |
+| 2d/move_sprite | 120 | 0.998270 | 9 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 1.384 / 0.85 = 0.782 + 0.068 | yes | |
+| 2d/move_sprite | 30 | 0.998261 | 8 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 11.908 / 0.989 = 0.857 + 0.132 | yes | |
+| 2d/transparency_2d | 10 | 0.997674 | 5 | 0 / 0 | 443 / 496 | 5 / 7 | 1 / 1 | 30.494 / 1.283 = 1.138 + 0.145 | yes | |
+| transforms/translation | 180 | 1.000000 | 0 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 1.451 / 0.825 = 0.754 + 0.071 | yes | |
+| transforms/translation | 60 | 1.000000 | 0 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 7.032 / 0.918 = 0.793 + 0.125 | yes | |
+| transforms/scale | 300 | 1.000000 | 0 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 1.452 / 0.818 = 0.747 + 0.071 | yes | |
+| transforms/scale | 60 | 1.000000 | 0 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 7.498 / 0.935 = 0.819 + 0.116 | yes | |
+| 3d/texture | 10 | 0.999547 | 1 | 3 / 3 | 443 / 497 | 6 / 8 | 4 / 4 | 31.689 / 1.294 = 1.076 + 0.218 | yes | |
+| shader/animate_shader | 30 | 1.000000 | 0 | 0 / 0 | 447 / 494 | 6 / 8 | 1 / 2 | 11.866 / 0.966 = 0.843 + 0.123 | yes | |
+| shader/animate_shader | 60 | 1.000000 | 0 | 0 / 0 | 447 / 494 | 6 / 8 | 1 / 2 | 1.991 / 0.977 = 0.854 + 0.123 | yes | |
+| 2d/sprite_sheet | 30 | 0.998820 | 5 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 11.01 / 1.048 = 0.919 + 0.129 | yes | |
+| 2d/sprite_sheet | 60 | 0.999054 | 5 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 1.313 / 0.897 = 0.795 + 0.102 | yes | |
+| 3d/pbr | 30 | 0.997685 | 8 | 56 / 56 | 499 / 550 | 6 / 8 | 57 / 57 | 13.677 / 1.098 = 1.024 + 0.074 | yes | |
+| 3d/pbr | 60 | 0.997685 | 8 | 56 / 56 | 499 / 550 | 6 / 8 | 57 / 57 | 1.974 / 0.976 = 0.874 + 0.102 | yes | |
+| 3d/animated_material | 30 | 0.999892 | 0 | 9 / 9 | 449 / 502 | 6 / 8 | 10 / 19 | 13.084 / 1.328 = 0.97 + 0.358 | yes | |
+| 3d/animated_material | 60 | 0.999940 | 0 | 9 / 9 | 449 / 502 | 6 / 8 | 10 / 19 | 1.986 / 1.211 = 0.944 + 0.267 | yes | |
+| camera/pan_camera_controller | 10 | 0.996838 | 10 | 0 / 0 | 446 / 494 | 5 / 7 | 1 / 1 | 30.317 / 1.273 = 1.118 + 0.155 | yes | |
+| camera/camera_orbit | 10 | 0.999220 | 8 | 2 / 2 | 445 / 496 | 7 / 9 | 3 / 3 | 31.362 / 1.421 = 1.148 + 0.273 | yes | |
+| camera/projection_zoom | 30 | 0.998026 | 8 | 2 / 2 | 473 / 526 | 7 / 9 | 3 / 3 | 13.211 / 1.189 = 1.037 + 0.152 | yes | |
+| 2d/sprite_animation | 12 | 0.997217 | 9 | 0 / 0 | 443 / 495 | 5 / 7 | 1 / 1 | 25.785 / 1.388 = 0.996 + 0.392 | yes | |
+| 2d/sprite_animation | 30 | 0.997017 | 8 | 0 / 0 | 443 / 495 | 5 / 7 | 1 / 1 | 1.31 / 1.038 = 0.906 + 0.132 | yes | |
+| 2d/sprite_animation | 60 | 0.997099 | 8 | 0 / 0 | 443 / 495 | 5 / 7 | 1 / 1 | 1.456 / 0.906 = 0.806 + 0.100 | yes | |
+| 2d/sprite_tile | 30 | 0.998633 | 7 | 0 / 0 | 442 / 494 | 5 / 7 | 1 / 1 | 11.391 / 1.128 = 0.996 + 0.132 | yes | |
+| 2d/sprite_tile | 300 | 0.992213 | 7 | 0 / 0 | 442 / 494 | 5 / 7 | 1 / 1 | 1.127 / 0.865 = 0.809 + 0.056 | yes | |
+| 3d/vertex_colors | 10 | 0.999019 | 0 | 2 / 2 | 443 / 496 | 7 / 9 | 3 / 3 | 35.055 / 2.476 = 2.24 + 0.236 | yes | |
+| 3d/spherical_area_lights | 10 | 0.999738 | 0 | 7 / 2 | 453 / 506 | 7 / 9 | 8 / 3 | 31.611 / 1.722 = 1.522 + 0.200 | yes | |
+| 3d/fog_volumes | 10 | 0.995718 | 14 | 0 / 0 | 442 / 494 | 5 / 7 | 1 / 1 | 31.512 / 1.605 = 1.287 + 0.318 | yes | |
+| 3d/fog_volumes | 60 | 0.995939 | 4 | 0 / 0 | 442 / 494 | 5 / 7 | 1 / 1 | 2.115 / 1.32 = 1.197 + 0.123 | yes | |
+| 3d/bloom_3d | 10 | 0.996668 | 11 | 4 / 4 | 541 / 593 | 6 / 8 | 5 / 5 | 32.845 / 3.174 = 1.819 + 1.355 | yes | |
+| 3d/bloom_3d | 60 | 0.996631 | 12 | 4 / 4 | 541 / 593 | 6 / 8 | 5 / 5 | 2.805 / 1.979 = 1.39 + 0.589 | yes | |
+| transforms/transform | 10 | 0.999999 | 0 | 2 / 2 | 443 / 496 | 7 / 9 | 3 / 3 | 30.107 / 1.497 = 1.042 + 0.455 | yes | |
+| transforms/transform | 120 | 1.000000 | 0 | 2 / 2 | 443 / 496 | 7 / 9 | 3 / 3 | 1.753 / 1.023 = 0.88 + 0.143 | yes | |
+| 3d/transparency_3d | 10 | 0.990065 | 25 | 6 / 6 | 447 / 500 | 11 / 10 | 7 / 11 | 37.417 / 2.573 = 2.046 + 0.527 | no | pixels 0.990065, worst tile 25 |
+| 3d/transparency_3d | 90 | 0.998632 | 0 | 6 / 6 | 447 / 500 | 11 / 10 | 7 / 11 | 3.16 / 1.961 = 1.779 + 0.182 | yes | |
+| animation/eased_motion | 150 | 0.999822 | 0 | 2 / 2 | 443 / 496 | 7 / 9 | 3 / 3 | 2.243 / 1.61 = 1.521 + 0.089 | yes | |
+| animation/eased_motion | 240 | 0.999823 | 0 | 2 / 2 | 443 / 496 | 7 / 9 | 3 / 3 | 2.162 / 1.647 = 1.572 + 0.075 | yes | |
+| animation/eased_motion | 60 | 0.999824 | 0 | 2 / 2 | 443 / 496 | 7 / 9 | 3 / 3 | 8.174 / 1.695 = 1.551 + 0.144 | yes | |
+| animation/color_animation | 120 | 0.998717 | 1 | 0 / 0 | 446 / 499 | 5 / 13 | 1 / 1 | 1.484 / 0.985 = 0.887 + 0.098 | yes | |
+| animation/color_animation | 200 | 0.996870 | 4 | 0 / 0 | 446 / 499 | 5 / 13 | 1 / 1 | 1.105 / 0.885 = 0.807 + 0.078 | yes | |
+| animation/color_animation | 30 | 0.998699 | 2 | 0 / 0 | 446 / 499 | 5 / 13 | 1 / 1 | 11.713 / 1.174 = 1.009 + 0.165 | yes | |
+| 3d/rect_light | 10 | 0.998374 | 8 | 2 / 2 | 446 / 501 | 7 / 9 | 3 / 3 | 33.243 / 1.542 = 1.333 + 0.209 | yes | |
+| 3d/shadow_caster_receiver | 10 | 1.000000 | 0 | 4 / 4 | 446 / 499 | 8 / 9 | 5 / 5 | 33.524 / 2.036 = 1.672 + 0.364 | yes | |
+| 3d/spotlight | 10 | 0.997767 | 10 | 4 / 4 | 530 / 582 | 9 / 11 | 5 / 5 | 36.727 / 6.009 = 4.691 + 1.318 | yes | |
+| 3d/spotlight | 90 | 0.996452 | 10 | 4 / 4 | 530 / 582 | 9 / 11 | 5 / 5 | 5.318 / 4.868 = 4.254 + 0.614 | yes | |
+| transforms/align | 10 | 0.993011 | 11 | 5 / 5 | 453 / 512 | 10 / 12 | 6 / 6 | 34.423 / 2.539 = 2.321 + 0.218 | yes | |
+| transforms/align | 30 | 0.993011 | 11 | 5 / 5 | 453 / 512 | 10 / 12 | 6 / 6 | 3.547 / 2.019 = 1.887 + 0.132 | yes | |
+| 3d/3d_viewport_to_world | 10 | 0.998921 | 1 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 2.486 / 1.244 = 1.017 + 0.227 | yes | |
+| 3d/3d_viewport_to_world | 5 | 0.998921 | 1 | 1 / 1 | 442 / 495 | 6 / 8 | 2 / 2 | 56.2 / 2.133 = 1.933 + 0.200 | yes | |
+| 3d/atmospheric_fog | 10 | 0.998688 | 9 | 2 / 2 | 449 / 504 | 7 / 9 | 3 / 3 | 3.725 / 1.808 = 1.581 + 0.227 | yes | |
+| 3d/atmospheric_fog | 5 | 0.998688 | 9 | 2 / 2 | 449 / 504 | 7 / 9 | 3 / 3 | 56.032 / 2.907 = 2.707 + 0.200 | yes | |
+| 2d/rotate_to_cursor | 10 | 0.999835 | 3 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 1.6 / 1.141 = 0.996 + 0.145 | yes | |
+| 2d/rotate_to_cursor | 5 | 0.999835 | 3 | 0 / 0 | 441 / 494 | 5 / 7 | 1 / 1 | 55.547 / 2.103 = 1.936 + 0.167 | yes | |
+| movement/smooth_follow | 120 | 0.998129 | 0 | 3 / 3 | 448 / 497 | 8 / 9 | 4 / 4 | 2.541 / 1.587 = 1.465 + 0.122 | yes | |
+| movement/smooth_follow | 30 | 0.998157 | 0 | 3 / 3 | 448 / 497 | 8 / 9 | 4 / 4 | 13.796 / 1.998 = 1.724 + 0.274 | yes | |
+| 3d/mesh_ray_cast | 300 | 0.999715 | 1 | 1 / 1 | 447 / 4658 | 6 / 8 | 2 / 2 | 3.184 / 4.352 = 1.365 + 2.987 | no | frame 4.352 ms (1.365 update + 2.987 React step) vs 3.184 ms |
+| 3d/mesh_ray_cast | 900 | 0.999608 | 1 | 1 / 1 | 447 / 44258 | 6 / 8 | 2 / 2 | 1.986 / 5.092 = 3.694 + 1.398 | no | frame 5.092 ms (3.694 update + 1.398 React step) vs 1.986 ms |
+| 2d/mesh2d_alpha_mode | 10 | 0.989355 | 8 | 0 / 0 | 446 / 499 | 6 / 13 | 1 / 1 | 1.966 / 1.169 = 1.042 + 0.127 | yes | |
+| 2d/mesh2d_alpha_mode | 5 | 0.989355 | 8 | 0 / 0 | 446 / 499 | 6 / 13 | 1 / 1 | 53.6 / 2.176 = 1.959 + 0.217 | yes | |
+| 3d/lightmaps | 10 | 1.000000 | 0 | 6 / 6 | 453 / 506 | 11 / 13 | 6 / 10 | 2.804 / 1.657 = 1.43 + 0.227 | yes | |
+| 3d/lightmaps | 5 | 1.000000 | 0 | 6 / 6 | 453 / 506 | 11 / 13 | 6 / 10 | 67.12 / 2.333 = 2.116 + 0.217 | yes | |
+| ui/styling/transparency_ui | 10 | 0.999721 | 3 | 0 / 0 | 445 / 492 | 5 / 7 | 1 / 1 | 1.711 / 1.467 = 1.34 + 0.127 | yes | |
+| ui/styling/transparency_ui | 5 | 0.999721 | 3 | 0 / 0 | 445 / 492 | 5 / 7 | 1 / 1 | 55.694 / 1.969 = 1.802 + 0.167 | yes | |
+| ui/layout/fixed_node | 10 | 1.000000 | 0 | 0 / 0 | 444 / 492 | 5 / 7 | 1 / 1 | 1.949 / 1.133 = 1.006 + 0.127 | yes | |
+| ui/layout/fixed_node | 5 | 1.000000 | 0 | 0 / 0 | 444 / 492 | 5 / 7 | 1 / 1 | 56.227 / 2.394 = 2.194 + 0.200 | yes | |
+| ui/images/image_node | 10 | 0.999965 | 0 | 0 / 0 | 442 / 492 | 5 / 7 | 1 / 1 | 1.747 / 1.068 = 0.932 + 0.136 | yes | |
+| ui/images/image_node | 5 | 0.999965 | 0 | 0 / 0 | 442 / 492 | 5 / 7 | 1 / 1 | 52.963 / 2.149 = 1.949 + 0.200 | yes | |
+| ui/text/font_weights | 10 | 0.991774 | 17 | 0 / 0 | 454 / 492 | 5 / 7 | 1 / 1 | 1.794 / 0.986 = 0.859 + 0.127 | yes | |
+| ui/text/font_weights | 5 | 0.991774 | 17 | 0 / 0 | 454 / 492 | 5 / 7 | 1 / 1 | 53.23 / 2.183 = 2.033 + 0.150 | yes | |
+| ui/text/font_variations | 10 | 0.993984 | 20 | 0 / 0 | 452 / 492 | 5 / 7 | 1 / 1 | 2.346 / 1.052 = 0.907 + 0.145 | yes | |
+| ui/text/font_variations | 5 | 0.993984 | 20 | 0 / 0 | 452 / 492 | 5 / 7 | 1 / 1 | 55.282 / 2.107 = 1.924 + 0.183 | yes | |
+| ui/text/text_background_colors | 10 | 0.998841 | 7 | 0 / 0 | 505 / 492 | 5 / 7 | 1 / 1 | 1.753 / 1.134 = 1.007 + 0.127 | yes | |
+| ui/text/text_background_colors | 5 | 0.998841 | 7 | 0 / 0 | 505 / 492 | 5 / 7 | 1 / 1 | 54.616 / 2.276 = 2.093 + 0.183 | yes | |
+| ui/text/strikethrough_and_underline | 10 | 0.990823 | 15 | 0 / 0 | 454 / 492 | 5 / 7 | 1 / 1 | 2.046 / 1.148 = 0.912 + 0.236 | yes | |
+| ui/text/strikethrough_and_underline | 5 | 0.990823 | 15 | 0 / 0 | 454 / 492 | 5 / 7 | 1 / 1 | 57.274 / 1.935 = 1.768 + 0.167 | yes | |
+| ui/scroll_and_overflow/overflow | 10 | 0.998763 | 4 | 0 / 0 | 461 / 492 | 5 / 7 | 1 / 1 | 1.907 / 1.143 = 0.952 + 0.191 | yes | |
+| ui/scroll_and_overflow/overflow | 5 | 0.998763 | 4 | 0 / 0 | 461 / 492 | 5 / 7 | 1 / 1 | 55.299 / 2.367 = 2.067 + 0.300 | yes | |
+| ui/images/ui_texture_atlas | 10 | 0.999776 | 6 | 0 / 0 | 445 / 492 | 5 / 7 | 1 / 1 | 1.608 / 1.173 = 0.973 + 0.200 | yes | |
+| ui/images/ui_texture_atlas | 5 | 0.999776 | 6 | 0 / 0 | 445 / 492 | 5 / 7 | 1 / 1 | 55.372 / 2.004 = 1.821 + 0.183 | yes | |
+| 2d/mesh2d_vertex_color_texture | 10 | 0.998651 | 6 | 0 / 0 | 442 / 495 | 6 / 9 | 1 / 1 | 31.381 / 1.123 = 0.978 + 0.145 | yes | |
+| 2d/mesh2d_repeated_texture | 10 | 0.991205 | 17 | 0 / 0 | 437 / 496 | 8 / 10 | 1 / 1 | 22.753 / 1.237 = 1.01 + 0.227 | yes | |
+| ui/layout/flex_layout | 10 | 0.992327 | 8 | 0 / 0 | 602 / 492 | 5 / 7 | 1 / 1 | 30.162 / 1.132 = 1.05 + 0.082 | yes | |
+| ui/scroll_and_overflow/overflow_clip_margin | 10 | 0.997488 | 7 | 0 / 0 | 465 / 492 | 5 / 7 | 1 / 1 | 31.094 / 1.094 = 0.921 + 0.173 | yes | |
+| ui/images/ui_texture_slice | 10 | 0.998941 | 8 | 0 / 0 | 447 / 492 | 5 / 7 | 1 / 1 | 30.286 / 1.001 = 0.865 + 0.136 | yes | |
+| ui/images/ui_texture_slice_flip_and_tile | 10 | 1.000000 | 0 | 0 / 0 | 461 / 492 | 5 / 7 | 1 / 1 | 32.019 / 1.232 = 1.05 + 0.182 | yes | |
+| ui/images/ui_texture_atlas_slice | 10 | 0.990813 | 16 | 0 / 0 | 447 / 492 | 5 / 7 | 1 / 1 | 29.297 / 1.236 = 1.091 + 0.145 | yes | |
+| ui/widgets/button | 10 | 0.999633 | 8 | 0 / 0 | 444 / 492 | 5 / 7 | 1 / 1 | 30.516 / 1.016 = 0.834 + 0.182 | yes | |
+| ui/text/letter_spacing | 10 | 0.996458 | 13 | 0 / 0 | 455 / 492 | 5 / 7 | 1 / 1 | 30.146 / 1.22 = 1.084 + 0.136 | yes | |
+| ui/styling/borders | 10 | 0.992828 | 9 | 0 / 0 | 591 / 492 | 5 / 7 | 1 / 1 | 28.137 / 1.093 = 1.02 + 0.073 | yes | |
+| ui/window_fallthrough | 10 | 0.992068 | 16 | 0 / 0 | 441 / 492 | 5 / 7 | 1 / 1 | 30.023 / 1.097 = 0.942 + 0.155 | yes | |
+| ui/text/inline_image | 10 | 0.998473 | 8 | 0 / 0 | 446 / 492 | 5 / 7 | 1 / 1 | 31.458 / 1.309 = 1.109 + 0.200 | yes | |
+| ui/layout/z_index | 10 | 1.000000 | 0 | 0 / 0 | 447 / 492 | 5 / 7 | 1 / 1 | 30.365 / 1.202 = 1.047 + 0.155 | yes | |
+| ui/styling/stacked_gradients | 10 | 0.994550 | 1 | 0 / 0 | 442 / 492 | 5 / 7 | 1 / 1 | 32.23 / 1.124 = 0.988 + 0.136 | yes | |
## Excluded
diff --git a/docs/bevy-parity/results.jsonl b/docs/bevy-parity/results.jsonl
index 1897ead4..754eff3b 100644
--- a/docs/bevy-parity/results.jsonl
+++ b/docs/bevy-parity/results.jsonl
@@ -1,113 +1,114 @@
{"example":"3d/rotate_environment_map","frame":5,"ssim":0.999453,"tile":1,"bevy":{"batch_keys":1,"entities":442,"extents":["0.9945 1.0000 1.0000"],"frame":5,"frame_ms":84.046,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":12,"entities":497,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.9945 1.0000 1.0000"],"frame_ms":5.209,"step_ms":1.533,"cost_ms":6.742},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"3d/rotate_environment_map","frame":60,"ssim":0.999279,"tile":1,"bevy":{"batch_keys":1,"entities":442,"extents":["0.9945 1.0000 1.0000"],"frame":60,"frame_ms":3.628,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":67,"entities":497,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.9945 1.0000 1.0000"],"frame_ms":2.733,"step_ms":0.466,"cost_ms":3.199},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"stress_tests/many_cubes","frame":30,"ssim":0.995176,"tile":1,"bevy":{"batch_keys":2,"entities":10444,"extents":["0.3620 0.3620 0.3620","550.0000 550.0000 550.0000"],"frame":30,"frame_ms":12.587,"materials":3,"mesh_entities":10001,"meshes":7,"other_material":0,"visible":729},"raea":{"frame":37,"entities":10495,"mesh_entities":10001,"visible":729,"meshes":9,"materials":2,"batch_keys":2,"other_material":0,"extents":["0.3620 0.3620 0.3620","550.0000 550.0000 550.0000"],"frame_ms":1.63,"step_ms":0.600,"cost_ms":2.23},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"stress_tests/many_cubes","frame":60,"ssim":0.995154,"tile":1,"bevy":{"batch_keys":2,"entities":10444,"extents":["0.3620 0.3620 0.3620","550.0000 550.0000 550.0000"],"frame":60,"frame_ms":2.36,"materials":3,"mesh_entities":10001,"meshes":7,"other_material":0,"visible":734},"raea":{"frame":67,"entities":10495,"mesh_entities":10001,"visible":733,"meshes":9,"materials":2,"batch_keys":2,"other_material":0,"extents":["0.3620 0.3620 0.3620","550.0000 550.0000 550.0000"],"frame_ms":1.503,"step_ms":0.451,"cost_ms":1.954},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/3d_scene","frame":10,"ssim":0.999998,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["0.5000 0.5000 0.5000","4.0000 4.0000 0.0000"],"frame":10,"frame_ms":2.679,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":17,"entities":498,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","4.0000 4.0000 0.0000"],"frame_ms":1.759,"step_ms":0.218,"cost_ms":1.977},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/3d_scene","frame":5,"ssim":0.999998,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["0.5000 0.5000 0.5000","4.0000 4.0000 0.0000"],"frame":5,"frame_ms":52.895,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":12,"entities":498,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","4.0000 4.0000 0.0000"],"frame_ms":2.806,"step_ms":0.183,"cost_ms":2.989},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"stress_tests/many_lights","frame":30,"ssim":0.999957,"tile":0,"bevy":{"batch_keys":1,"entities":100443,"extents":["49.9006 50.0000 50.0000"],"frame":30,"frame_ms":16.798,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":1},"raea":{"frame":37,"entities":100495,"mesh_entities":2,"visible":1,"meshes":9,"materials":3,"batch_keys":1,"other_material":0,"extents":["49.9006 50.0000 50.0000"],"frame_ms":3.705,"step_ms":2.142,"cost_ms":5.847},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"stress_tests/many_lights","frame":60,"ssim":0.999954,"tile":0,"bevy":{"batch_keys":1,"entities":100445,"extents":["49.9006 50.0000 50.0000"],"frame":60,"frame_ms":2.785,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":1},"raea":{"frame":67,"entities":100495,"mesh_entities":2,"visible":1,"meshes":9,"materials":3,"batch_keys":1,"other_material":0,"extents":["49.9006 50.0000 50.0000"],"frame_ms":3.68,"step_ms":1.720,"cost_ms":5.4},"pixels":true,"draws":true,"time":false,"pass":false,"why":"frame 5.4 ms (3.68 update + 1.720 React step) vs 2.785 ms"}
-{"example":"stress_tests/many_foxes","frame":30,"ssim":0.989592,"tile":3,"bevy":{"batch_keys":2,"entities":30464,"extents":["17.4810 42.8200 84.6165","2500.0000 0.0000 2500.0000","50.9020 42.8200 89.1329","54.3371 42.8200 89.5665","81.3309 42.8200 92.9734","85.2965 42.8200 93.4739","94.6316 42.8200 94.6520","94.6316 42.8200 94.6521"],"frame":30,"frame_ms":15.627,"materials":3,"mesh_entities":1001,"meshes":7,"other_material":0,"visible":1001},"raea":{"frame":39,"entities":31495,"mesh_entities":1001,"visible":1001,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["17.4809 42.8200 84.6165","2500.0000 0.0000 2500.0000","50.9021 42.8200 89.1329","50.9021 42.8200 89.1330","54.3371 42.8200 89.5665","81.3310 42.8200 92.9734","85.2964 42.8200 93.4738","94.6316 42.8200 94.6520"],"frame_ms":8.344,"step_ms":9.197,"cost_ms":17.541},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"stress_tests/many_foxes","frame":60,"ssim":0.990304,"tile":3,"bevy":{"batch_keys":2,"entities":30464,"extents":["23.6615 34.9370 84.2011","23.6615 34.9370 84.2012","2500.0000 0.0000 2500.0000","78.2183 34.9370 91.5996","80.4108 34.9370 91.8799","84.3248 34.9370 92.3804","86.0376 34.9370 92.5995","86.0377 34.9371 92.5995"],"frame":60,"frame_ms":3.445,"materials":3,"mesh_entities":1001,"meshes":7,"other_material":0,"visible":1001},"raea":{"frame":69,"entities":31495,"mesh_entities":1001,"visible":1001,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["21.9974 34.9370 83.6309","23.6613 34.9370 84.2011","2500.0000 0.0000 2500.0000","78.2186 34.9370 91.5996","80.4110 34.9370 91.8800","84.3247 34.9370 92.3804","86.0374 34.9370 92.5994","86.0374 34.9371 92.5994"],"frame_ms":8.287,"step_ms":8.795,"cost_ms":17.082},"pixels":true,"draws":true,"time":false,"pass":false,"why":"frame 17.082 ms (8.287 update + 8.795 React step) vs 3.445 ms"}
-{"example":"animation/animated_mesh","frame":30,"ssim":0.996636,"tile":1,"bevy":{"batch_keys":2,"entities":472,"extents":["15.4187 42.8200 84.0474","250000.0000 0.0000 250000.0000"],"frame":30,"frame_ms":13.455,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":40,"entities":526,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["15.4187 42.8200 84.0474","250000.0000 0.0000 250000.0000"],"frame_ms":1.44,"step_ms":0.174,"cost_ms":1.614},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"animation/animated_mesh","frame":60,"ssim":0.996594,"tile":1,"bevy":{"batch_keys":2,"entities":472,"extents":["19.9546 34.9370 82.9540","250000.0000 0.0000 250000.0000"],"frame":60,"frame_ms":2.53,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":70,"entities":526,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["19.9546 34.9370 82.9540","250000.0000 0.0000 250000.0000"],"frame_ms":1.323,"step_ms":0.157,"cost_ms":1.48},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/extended_material","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":448,"extents":["0.9945 1.0000 1.0000"],"frame":30,"frame_ms":12.03,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":37,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.9945 1.0000 1.0000"],"frame_ms":0.898,"step_ms":0.277,"cost_ms":1.175},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/extended_material","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":448,"extents":["0.9945 1.0000 1.0000"],"frame":60,"frame_ms":1.867,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":67,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.9945 1.0000 1.0000"],"frame_ms":0.776,"step_ms":0.174,"cost_ms":0.95},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/orthographic","frame":10,"ssim":0.999503,"tile":0,"bevy":{"batch_keys":5,"entities":446,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame":10,"frame_ms":29.78,"materials":6,"mesh_entities":5,"meshes":10,"other_material":0,"visible":5},"raea":{"frame":17,"entities":499,"mesh_entities":5,"visible":5,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame_ms":1.056,"step_ms":0.191,"cost_ms":1.247},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/parenting","frame":30,"ssim":0.999969,"tile":0,"bevy":{"batch_keys":1,"entities":443,"extents":["1.0000 1.0000 1.0000"],"frame":30,"frame_ms":11.825,"materials":2,"mesh_entities":2,"meshes":6,"other_material":0,"visible":2},"raea":{"frame":37,"entities":496,"mesh_entities":2,"visible":2,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["1.0000 1.0000 1.0000"],"frame_ms":0.963,"step_ms":0.184,"cost_ms":1.147},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/parenting","frame":60,"ssim":0.999968,"tile":0,"bevy":{"batch_keys":1,"entities":443,"extents":["1.0000 1.0000 1.0000"],"frame":60,"frame_ms":1.88,"materials":2,"mesh_entities":2,"meshes":6,"other_material":0,"visible":2},"raea":{"frame":67,"entities":496,"mesh_entities":2,"visible":2,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["1.0000 1.0000 1.0000"],"frame_ms":0.837,"step_ms":0.159,"cost_ms":0.996},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/mesh2d","frame":10,"ssim":0.999348,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":28.75,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":494,"mesh_entities":0,"visible":0,"meshes":8,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.073,"step_ms":0.145,"cost_ms":1.218},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/sprite","frame":10,"ssim":0.998326,"tile":8,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":28.965,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.012,"step_ms":0.145,"cost_ms":1.157},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"transforms/3d_rotation","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":30,"frame_ms":11.937,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":37,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.885,"step_ms":0.235,"cost_ms":1.12},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"transforms/3d_rotation","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":1.758,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":67,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.798,"step_ms":0.144,"cost_ms":0.942},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/sprite_flipping","frame":10,"ssim":0.998326,"tile":8,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":28.942,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.17,"step_ms":0.164,"cost_ms":1.334},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/move_sprite","frame":120,"ssim":0.998270,"tile":9,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":120,"frame_ms":1.192,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":127,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.75,"step_ms":0.075,"cost_ms":0.825},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/move_sprite","frame":30,"ssim":0.998261,"tile":8,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":30,"frame_ms":10.825,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.849,"step_ms":0.129,"cost_ms":0.978},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/transparency_2d","frame":10,"ssim":0.997674,"tile":5,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":10,"frame_ms":29.048,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":496,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.186,"step_ms":0.127,"cost_ms":1.313},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"transforms/translation","frame":180,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":180,"frame_ms":1.655,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":187,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.856,"step_ms":0.075,"cost_ms":0.931},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"transforms/translation","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":7.181,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":67,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.874,"step_ms":0.113,"cost_ms":0.987},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"transforms/scale","frame":300,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":300,"frame_ms":1.537,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":307,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.765,"step_ms":0.065,"cost_ms":0.83},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"transforms/scale","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":6.844,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":67,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.782,"step_ms":0.130,"cost_ms":0.912},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/texture","frame":10,"ssim":0.999547,"tile":1,"bevy":{"batch_keys":3,"entities":443,"extents":["4.0000 1.0000 0.0000"],"frame":10,"frame_ms":30.728,"materials":4,"mesh_entities":3,"meshes":6,"other_material":0,"visible":3},"raea":{"frame":17,"entities":497,"mesh_entities":3,"visible":3,"meshes":8,"materials":4,"batch_keys":3,"other_material":0,"extents":["4.0000 0.0000 1.0000"],"frame_ms":1.128,"step_ms":0.209,"cost_ms":1.337},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/animate_shader","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":["0.5000 0.5000 0.5000"],"frame":30,"frame_ms":11.804,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":37,"entities":494,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.804,"step_ms":0.113,"cost_ms":0.917},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/animate_shader","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":1.9,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":67,"entities":494,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.769,"step_ms":0.087,"cost_ms":0.856},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/sprite_sheet","frame":30,"ssim":0.998820,"tile":5,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":30,"frame_ms":11.249,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.896,"step_ms":0.129,"cost_ms":1.025},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/sprite_sheet","frame":60,"ssim":0.999054,"tile":5,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":60,"frame_ms":1.407,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.802,"step_ms":0.090,"cost_ms":0.892},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/pbr","frame":30,"ssim":0.997685,"tile":8,"bevy":{"batch_keys":56,"entities":499,"extents":["0.4475 0.4500 0.4500"],"frame":30,"frame_ms":12.865,"materials":57,"mesh_entities":56,"meshes":6,"other_material":0,"visible":56},"raea":{"frame":37,"entities":550,"mesh_entities":56,"visible":56,"meshes":8,"materials":57,"batch_keys":56,"other_material":0,"extents":["0.4475 0.4500 0.4500"],"frame_ms":0.932,"step_ms":0.090,"cost_ms":1.022},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/pbr","frame":60,"ssim":0.997685,"tile":8,"bevy":{"batch_keys":56,"entities":499,"extents":["0.4475 0.4500 0.4500"],"frame":60,"frame_ms":1.908,"materials":57,"mesh_entities":56,"meshes":6,"other_material":0,"visible":56},"raea":{"frame":67,"entities":550,"mesh_entities":56,"visible":56,"meshes":8,"materials":57,"batch_keys":56,"other_material":0,"extents":["0.4475 0.4500 0.4500"],"frame_ms":0.887,"step_ms":0.072,"cost_ms":0.959},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/animated_material","frame":30,"ssim":0.999892,"tile":0,"bevy":{"batch_keys":9,"entities":449,"extents":["0.2500 0.2500 0.2500"],"frame":30,"frame_ms":12.662,"materials":10,"mesh_entities":9,"meshes":6,"other_material":0,"visible":9},"raea":{"frame":37,"entities":502,"mesh_entities":9,"visible":9,"meshes":8,"materials":19,"batch_keys":9,"other_material":0,"extents":["0.2500 0.2500 0.2500"],"frame_ms":0.969,"step_ms":0.345,"cost_ms":1.314},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/animated_material","frame":60,"ssim":0.999940,"tile":0,"bevy":{"batch_keys":9,"entities":449,"extents":["0.2500 0.2500 0.2500"],"frame":60,"frame_ms":1.902,"materials":10,"mesh_entities":9,"meshes":6,"other_material":0,"visible":9},"raea":{"frame":67,"entities":502,"mesh_entities":9,"visible":9,"meshes":8,"materials":19,"batch_keys":9,"other_material":0,"extents":["0.2500 0.2500 0.2500"],"frame_ms":0.891,"step_ms":0.264,"cost_ms":1.155},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"camera/pan_camera_controller","frame":10,"ssim":0.996838,"tile":10,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":10,"frame_ms":29.052,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.977,"step_ms":0.155,"cost_ms":1.132},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"camera/camera_orbit","frame":10,"ssim":0.999220,"tile":8,"bevy":{"batch_keys":2,"entities":445,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame":10,"frame_ms":31.381,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":17,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame_ms":1.159,"step_ms":0.218,"cost_ms":1.377},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"camera/projection_zoom","frame":30,"ssim":0.998026,"tile":8,"bevy":{"batch_keys":2,"entities":473,"extents":["12.5927 39.5145 77.3599","2.5000 0.0000 2.5000"],"frame":30,"frame_ms":12.741,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":40,"entities":526,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["12.5927 39.5145 77.3599","2.5000 0.0000 2.5000"],"frame_ms":0.998,"step_ms":0.139,"cost_ms":1.137},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/sprite_animation","frame":12,"ssim":0.997217,"tile":9,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":12,"frame_ms":24.703,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":19,"entities":495,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.98,"step_ms":0.246,"cost_ms":1.226},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/sprite_animation","frame":30,"ssim":0.997017,"tile":8,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":30,"frame_ms":1.358,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":495,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.889,"step_ms":0.155,"cost_ms":1.044},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/sprite_animation","frame":60,"ssim":0.997099,"tile":8,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":60,"frame_ms":1.389,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":495,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.814,"step_ms":0.087,"cost_ms":0.901},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/sprite_tile","frame":30,"ssim":0.998633,"tile":7,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":30,"frame_ms":10.846,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.954,"step_ms":0.152,"cost_ms":1.106},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/sprite_tile","frame":300,"ssim":0.992213,"tile":7,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":300,"frame_ms":1.184,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":307,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.809,"step_ms":0.058,"cost_ms":0.867},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/vertex_colors","frame":10,"ssim":0.999019,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame":10,"frame_ms":34.985,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":17,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame_ms":1.881,"step_ms":0.236,"cost_ms":2.117},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/spherical_area_lights","frame":10,"ssim":0.999738,"tile":0,"bevy":{"batch_keys":7,"entities":453,"extents":["1.0000 1.0000 1.0000","50.0000 0.0000 50.0000"],"frame":10,"frame_ms":29.222,"materials":8,"mesh_entities":7,"meshes":7,"other_material":0,"visible":7},"raea":{"frame":17,"entities":506,"mesh_entities":7,"visible":7,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 1.0000 1.0000","50.0000 0.0000 50.0000"],"frame_ms":1.312,"step_ms":0.191,"cost_ms":1.503},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/fog_volumes","frame":10,"ssim":0.995718,"tile":14,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":10,"frame_ms":30.969,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.333,"step_ms":0.300,"cost_ms":1.633},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/fog_volumes","frame":60,"ssim":0.995939,"tile":4,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":60,"frame_ms":2.093,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.144,"step_ms":0.121,"cost_ms":1.265},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/bloom_3d","frame":10,"ssim":0.996668,"tile":11,"bevy":{"batch_keys":4,"entities":541,"extents":["0.3978 0.4000 0.4000"],"frame":10,"frame_ms":32.558,"materials":5,"mesh_entities":100,"meshes":6,"other_material":0,"visible":46},"raea":{"frame":17,"entities":593,"mesh_entities":100,"visible":46,"meshes":8,"materials":5,"batch_keys":4,"other_material":0,"extents":["0.3978 0.4000 0.4000"],"frame_ms":1.745,"step_ms":1.127,"cost_ms":2.872},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/bloom_3d","frame":60,"ssim":0.996631,"tile":12,"bevy":{"batch_keys":4,"entities":541,"extents":["0.3978 0.4000 0.4000"],"frame":60,"frame_ms":2.622,"materials":5,"mesh_entities":100,"meshes":6,"other_material":0,"visible":46},"raea":{"frame":67,"entities":593,"mesh_entities":100,"visible":46,"meshes":8,"materials":5,"batch_keys":4,"other_material":0,"extents":["0.3978 0.4000 0.4000"],"frame_ms":1.55,"step_ms":0.666,"cost_ms":2.216},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"transforms/transform","frame":10,"ssim":0.999999,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["0.5000 0.5000 0.5000","3.0000 3.0000 2.9996"],"frame":10,"frame_ms":30.631,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":17,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","3.0000 3.0000 2.9996"],"frame_ms":1.062,"step_ms":0.327,"cost_ms":1.389},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"transforms/transform","frame":120,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["0.5000 0.5000 0.5000","3.0000 3.0000 2.9996"],"frame":120,"frame_ms":1.689,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":127,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","3.0000 3.0000 2.9996"],"frame_ms":0.827,"step_ms":0.130,"cost_ms":0.957},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/transparency_3d","frame":10,"ssim":0.990065,"tile":25,"bevy":{"batch_keys":6,"entities":447,"extents":["0.5000 0.5000 0.5000","3.0000 0.0000 3.0000"],"frame":10,"frame_ms":35.823,"materials":7,"mesh_entities":6,"meshes":11,"other_material":0,"visible":6},"raea":{"frame":17,"entities":500,"mesh_entities":6,"visible":6,"meshes":10,"materials":11,"batch_keys":6,"other_material":0,"extents":["0.5000 0.5000 0.5000","3.0000 0.0000 3.0000"],"frame_ms":2.075,"step_ms":0.627,"cost_ms":2.702},"pixels":false,"draws":true,"time":true,"pass":false,"why":"pixels 0.990065, worst tile 25"}
-{"example":"3d/transparency_3d","frame":90,"ssim":0.998632,"tile":0,"bevy":{"batch_keys":6,"entities":447,"extents":["0.5000 0.5000 0.5000","3.0000 0.0000 3.0000"],"frame":90,"frame_ms":3.104,"materials":7,"mesh_entities":6,"meshes":11,"other_material":0,"visible":6},"raea":{"frame":97,"entities":500,"mesh_entities":6,"visible":6,"meshes":10,"materials":11,"batch_keys":6,"other_material":0,"extents":["0.5000 0.5000 0.5000","3.0000 0.0000 3.0000"],"frame_ms":1.799,"step_ms":0.167,"cost_ms":1.966},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"animation/eased_motion","frame":150,"ssim":0.999822,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["1.0000 1.0000 1.0000","25.0000 0.0000 25.0000"],"frame":150,"frame_ms":2.554,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":157,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 1.0000 1.0000","25.0000 0.0000 25.0000"],"frame_ms":1.442,"step_ms":0.097,"cost_ms":1.539},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"animation/eased_motion","frame":240,"ssim":0.999823,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["1.0000 1.0000 1.0000","25.0000 0.0000 25.0000"],"frame":240,"frame_ms":2.424,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":247,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 1.0000 1.0000","25.0000 0.0000 25.0000"],"frame_ms":1.503,"step_ms":0.071,"cost_ms":1.574},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"animation/eased_motion","frame":60,"ssim":0.999824,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["1.0000 1.0000 1.0000","25.0000 0.0000 25.0000"],"frame":60,"frame_ms":8.211,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":67,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 1.0000 1.0000","25.0000 0.0000 25.0000"],"frame_ms":1.48,"step_ms":0.131,"cost_ms":1.611},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"animation/color_animation","frame":120,"ssim":0.998717,"tile":1,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":120,"frame_ms":1.421,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":127,"entities":499,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.797,"step_ms":0.088,"cost_ms":0.885},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"animation/color_animation","frame":200,"ssim":0.996870,"tile":4,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":200,"frame_ms":1.132,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":207,"entities":499,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.784,"step_ms":0.077,"cost_ms":0.861},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"animation/color_animation","frame":30,"ssim":0.998699,"tile":2,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":30,"frame_ms":10.845,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":499,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.969,"step_ms":0.171,"cost_ms":1.14},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/rect_light","frame":10,"ssim":0.998374,"tile":8,"bevy":{"batch_keys":2,"entities":446,"extents":["0.9945 1.0000 1.0000","10.0000 0.0000 10.0000"],"frame":10,"frame_ms":32.839,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":17,"entities":501,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.9945 1.0000 1.0000","10.0000 0.0000 10.0000"],"frame_ms":1.159,"step_ms":0.255,"cost_ms":1.414},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/shadow_caster_receiver","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":4,"entities":446,"extents":["0.2486 0.2500 0.2500","10.0000 0.0000 10.0000"],"frame":10,"frame_ms":32.44,"materials":5,"mesh_entities":4,"meshes":8,"other_material":0,"visible":4},"raea":{"frame":17,"entities":499,"mesh_entities":4,"visible":4,"meshes":9,"materials":5,"batch_keys":4,"other_material":0,"extents":["0.2486 0.2500 0.2500","10.0000 0.0000 10.0000"],"frame_ms":1.817,"step_ms":0.245,"cost_ms":2.062},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/spotlight","frame":10,"ssim":0.997767,"tile":10,"bevy":{"batch_keys":4,"entities":530,"extents":["0.0500 0.0500 0.0500","0.1000 0.1000 0.1000","0.2500 0.2500 0.2500","50.0000 0.0000 50.0000"],"frame":10,"frame_ms":34.756,"materials":5,"mesh_entities":73,"meshes":9,"other_material":0,"visible":73},"raea":{"frame":17,"entities":582,"mesh_entities":73,"visible":73,"meshes":11,"materials":5,"batch_keys":4,"other_material":0,"extents":["0.0500 0.0500 0.0500","0.1000 0.1000 0.1000","0.2500 0.2500 0.2500","50.0000 0.0000 50.0000"],"frame_ms":4.381,"step_ms":1.709,"cost_ms":6.09},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/spotlight","frame":90,"ssim":0.996452,"tile":10,"bevy":{"batch_keys":4,"entities":530,"extents":["0.0500 0.0500 0.0500","0.1000 0.1000 0.1000","0.2500 0.2500 0.2500","50.0000 0.0000 50.0000"],"frame":90,"frame_ms":5.229,"materials":5,"mesh_entities":73,"meshes":9,"other_material":0,"visible":73},"raea":{"frame":97,"entities":582,"mesh_entities":73,"visible":73,"meshes":11,"materials":5,"batch_keys":4,"other_material":0,"extents":["0.0500 0.0500 0.0500","0.1000 0.1000 0.1000","0.2500 0.2500 0.2500","50.0000 0.0000 50.0000"],"frame_ms":4.139,"step_ms":0.669,"cost_ms":4.808},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"transforms/align","frame":10,"ssim":0.993011,"tile":11,"bevy":{"batch_keys":5,"entities":453,"extents":["1.4000 0.4500 1.1128","50.0000 0.0000 50.0000"],"frame":10,"frame_ms":33.466,"materials":6,"mesh_entities":5,"meshes":10,"other_material":0,"visible":5},"raea":{"frame":19,"entities":512,"mesh_entities":5,"visible":5,"meshes":12,"materials":6,"batch_keys":5,"other_material":0,"extents":["1.4000 0.4500 1.1128","50.0000 0.0000 50.0000"],"frame_ms":2.405,"step_ms":0.218,"cost_ms":2.623},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"transforms/align","frame":30,"ssim":0.993011,"tile":11,"bevy":{"batch_keys":5,"entities":453,"extents":["1.4000 0.4500 1.1128","50.0000 0.0000 50.0000"],"frame":30,"frame_ms":3.634,"materials":6,"mesh_entities":5,"meshes":10,"other_material":0,"visible":5},"raea":{"frame":39,"entities":512,"mesh_entities":5,"visible":5,"meshes":12,"materials":6,"batch_keys":5,"other_material":0,"extents":["1.4000 0.4500 1.1128","50.0000 0.0000 50.0000"],"frame_ms":1.99,"step_ms":0.129,"cost_ms":2.119},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/3d_viewport_to_world","frame":10,"ssim":0.998921,"tile":1,"bevy":{"batch_keys":1,"entities":442,"extents":["10.0000 0.0000 10.0000"],"frame":10,"frame_ms":2.524,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":17,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["10.0000 0.0000 10.0000"],"frame_ms":1.051,"step_ms":0.236,"cost_ms":1.287},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/3d_viewport_to_world","frame":5,"ssim":0.998921,"tile":1,"bevy":{"batch_keys":1,"entities":442,"extents":["10.0000 0.0000 10.0000"],"frame":5,"frame_ms":56.063,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":12,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["10.0000 0.0000 10.0000"],"frame_ms":2.155,"step_ms":0.183,"cost_ms":2.338},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/atmospheric_fog","frame":10,"ssim":0.998688,"tile":9,"bevy":{"batch_keys":2,"entities":449,"extents":["1.0000 0.1674 1.0026","1.0000 0.5000 0.5000"],"frame":10,"frame_ms":3.417,"materials":3,"mesh_entities":3,"meshes":7,"other_material":0,"visible":3},"raea":{"frame":19,"entities":504,"mesh_entities":3,"visible":3,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 0.1674 1.0026","1.0000 0.5000 0.5000"],"frame_ms":1.451,"step_ms":0.245,"cost_ms":1.696},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/atmospheric_fog","frame":5,"ssim":0.998688,"tile":9,"bevy":{"batch_keys":2,"entities":449,"extents":["1.0000 0.1674 1.0026","1.0000 0.5000 0.5000"],"frame":5,"frame_ms":54.999,"materials":3,"mesh_entities":3,"meshes":7,"other_material":0,"visible":3},"raea":{"frame":14,"entities":504,"mesh_entities":3,"visible":3,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 0.1674 1.0026","1.0000 0.5000 0.5000"],"frame_ms":2.569,"step_ms":0.333,"cost_ms":2.902},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/rotate_to_cursor","frame":10,"ssim":0.999835,"tile":3,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":1.676,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.063,"step_ms":0.136,"cost_ms":1.199},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/rotate_to_cursor","frame":5,"ssim":0.999835,"tile":3,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":5,"frame_ms":52.232,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.45,"step_ms":0.167,"cost_ms":2.617},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"movement/smooth_follow","frame":120,"ssim":0.998129,"tile":0,"bevy":{"batch_keys":3,"entities":448,"extents":["0.2983 0.3000 0.3000","6.0000 0.0000 6.0000"],"frame":120,"frame_ms":2.5,"materials":4,"mesh_entities":3,"meshes":8,"other_material":0,"visible":3},"raea":{"frame":127,"entities":497,"mesh_entities":3,"visible":3,"meshes":9,"materials":4,"batch_keys":3,"other_material":0,"extents":["0.2983 0.3000 0.3000","6.0000 0.0000 6.0000"],"frame_ms":1.418,"step_ms":0.131,"cost_ms":1.549},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"movement/smooth_follow","frame":30,"ssim":0.998157,"tile":0,"bevy":{"batch_keys":3,"entities":448,"extents":["0.2983 0.3000 0.3000","6.0000 0.0000 6.0000"],"frame":30,"frame_ms":13.291,"materials":4,"mesh_entities":3,"meshes":8,"other_material":0,"visible":3},"raea":{"frame":37,"entities":497,"mesh_entities":3,"visible":3,"meshes":9,"materials":4,"batch_keys":3,"other_material":0,"extents":["0.2983 0.3000 0.3000","6.0000 0.0000 6.0000"],"frame_ms":1.633,"step_ms":0.206,"cost_ms":1.839},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/mesh2d_alpha_mode","frame":10,"ssim":0.989355,"tile":8,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":10,"frame_ms":1.78,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":499,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.128,"step_ms":0.136,"cost_ms":1.264},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/mesh2d_alpha_mode","frame":5,"ssim":0.989355,"tile":8,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":5,"frame_ms":52.85,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":12,"entities":499,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.228,"step_ms":0.167,"cost_ms":2.395},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/lightmaps","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":6,"entities":453,"extents":["0.0001 274.4000 279.6000","102.6464 82.5000 102.6464","103.2390 165.0000 103.2390","278.0000 274.4000 279.6001","3.2000 274.4000 279.6000","65.0000 0.0000 52.5000"],"frame":10,"frame_ms":2.47,"materials":6,"mesh_entities":6,"meshes":11,"other_material":0,"visible":6},"raea":{"frame":19,"entities":506,"mesh_entities":6,"visible":6,"meshes":13,"materials":10,"batch_keys":6,"other_material":0,"extents":["0.0001 274.4000 279.6000","102.6464 82.5000 102.6464","103.2390 165.0000 103.2390","278.0000 274.4000 279.6001","3.2000 274.4000 279.6000","65.0000 0.0000 52.5000"],"frame_ms":1.186,"step_ms":0.409,"cost_ms":1.595},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/lightmaps","frame":5,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":6,"entities":453,"extents":["0.0001 274.4000 279.6000","102.6464 82.5000 102.6464","103.2390 165.0000 103.2390","278.0000 274.4000 279.6001","3.2000 274.4000 279.6000","65.0000 0.0000 52.5000"],"frame":5,"frame_ms":63.082,"materials":6,"mesh_entities":6,"meshes":11,"other_material":0,"visible":6},"raea":{"frame":14,"entities":506,"mesh_entities":6,"visible":6,"meshes":13,"materials":10,"batch_keys":6,"other_material":0,"extents":["0.0001 274.4000 279.6000","102.6464 82.5000 102.6464","103.2390 165.0000 103.2390","278.0000 274.4000 279.6001","3.2000 274.4000 279.6000","65.0000 0.0000 52.5000"],"frame_ms":2.05,"step_ms":0.217,"cost_ms":2.267},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/styling/transparency_ui","frame":10,"ssim":0.999700,"tile":3,"bevy":{"batch_keys":0,"entities":445,"extents":[],"frame":10,"frame_ms":1.694,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.967,"step_ms":0.136,"cost_ms":1.103},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/styling/transparency_ui","frame":5,"ssim":0.999700,"tile":3,"bevy":{"batch_keys":0,"entities":445,"extents":[],"frame":5,"frame_ms":52.355,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.128,"step_ms":0.183,"cost_ms":2.311},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/layout/fixed_node","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":444,"extents":[],"frame":10,"frame_ms":1.717,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.932,"step_ms":0.136,"cost_ms":1.068},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/layout/fixed_node","frame":5,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":444,"extents":[],"frame":5,"frame_ms":52.818,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.744,"step_ms":0.167,"cost_ms":1.911},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/images/image_node","frame":10,"ssim":0.999893,"tile":1,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":10,"frame_ms":1.624,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.964,"step_ms":0.145,"cost_ms":1.109},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/images/image_node","frame":5,"ssim":0.999893,"tile":1,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":5,"frame_ms":50.588,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.824,"step_ms":0.217,"cost_ms":2.041},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/text/font_weights","frame":10,"ssim":0.990279,"tile":17,"bevy":{"batch_keys":0,"entities":454,"extents":[],"frame":10,"frame_ms":1.845,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.903,"step_ms":0.127,"cost_ms":1.03},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/text/font_weights","frame":5,"ssim":0.990279,"tile":17,"bevy":{"batch_keys":0,"entities":454,"extents":[],"frame":5,"frame_ms":48.833,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.912,"step_ms":0.167,"cost_ms":2.079},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/text/font_variations","frame":10,"ssim":0.992845,"tile":21,"bevy":{"batch_keys":0,"entities":452,"extents":[],"frame":10,"frame_ms":1.837,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.96,"step_ms":0.145,"cost_ms":1.105},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/text/font_variations","frame":5,"ssim":0.992845,"tile":21,"bevy":{"batch_keys":0,"entities":452,"extents":[],"frame":5,"frame_ms":55.737,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.852,"step_ms":0.150,"cost_ms":2.002},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/text/text_background_colors","frame":10,"ssim":0.997735,"tile":8,"bevy":{"batch_keys":0,"entities":505,"extents":[],"frame":10,"frame_ms":1.813,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.887,"step_ms":0.109,"cost_ms":0.996},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/text/text_background_colors","frame":5,"ssim":0.997735,"tile":8,"bevy":{"batch_keys":0,"entities":505,"extents":[],"frame":5,"frame_ms":50.608,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.814,"step_ms":0.150,"cost_ms":1.964},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/text/strikethrough_and_underline","frame":10,"ssim":0.990152,"tile":14,"bevy":{"batch_keys":0,"entities":454,"extents":[],"frame":10,"frame_ms":1.961,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.944,"step_ms":0.127,"cost_ms":1.071},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/text/strikethrough_and_underline","frame":5,"ssim":0.990152,"tile":14,"bevy":{"batch_keys":0,"entities":454,"extents":[],"frame":5,"frame_ms":53.475,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.738,"step_ms":0.150,"cost_ms":1.888},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/scroll_and_overflow/overflow","frame":10,"ssim":0.998143,"tile":5,"bevy":{"batch_keys":0,"entities":461,"extents":[],"frame":10,"frame_ms":1.631,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.88,"step_ms":0.164,"cost_ms":1.044},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/scroll_and_overflow/overflow","frame":5,"ssim":0.998143,"tile":5,"bevy":{"batch_keys":0,"entities":461,"extents":[],"frame":5,"frame_ms":52.991,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.941,"step_ms":0.117,"cost_ms":2.058},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/images/ui_texture_atlas","frame":10,"ssim":0.999601,"tile":7,"bevy":{"batch_keys":0,"entities":445,"extents":[],"frame":10,"frame_ms":1.948,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.071,"step_ms":0.127,"cost_ms":1.198},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/images/ui_texture_atlas","frame":5,"ssim":0.999601,"tile":7,"bevy":{"batch_keys":0,"entities":445,"extents":[],"frame":5,"frame_ms":52.0,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.739,"step_ms":0.183,"cost_ms":1.922},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/mesh2d_vertex_color_texture","frame":10,"ssim":0.998651,"tile":6,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":10,"frame_ms":29.837,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":495,"mesh_entities":0,"visible":0,"meshes":9,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.04,"step_ms":0.145,"cost_ms":1.185},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"2d/mesh2d_repeated_texture","frame":10,"ssim":0.991205,"tile":17,"bevy":{"batch_keys":0,"entities":437,"extents":[],"frame":10,"frame_ms":22.676,"materials":1,"mesh_entities":0,"meshes":8,"other_material":0,"visible":0},"raea":{"frame":17,"entities":496,"mesh_entities":0,"visible":0,"meshes":10,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.149,"step_ms":0.191,"cost_ms":1.34},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/layout/flex_layout","frame":10,"ssim":0.990851,"tile":8,"bevy":{"batch_keys":0,"entities":602,"extents":[],"frame":10,"frame_ms":29.692,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.956,"step_ms":0.073,"cost_ms":1.029},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/scroll_and_overflow/overflow_clip_margin","frame":10,"ssim":0.996801,"tile":9,"bevy":{"batch_keys":0,"entities":465,"extents":[],"frame":10,"frame_ms":29.204,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.881,"step_ms":0.182,"cost_ms":1.063},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/images/ui_texture_slice","frame":10,"ssim":0.998957,"tile":8,"bevy":{"batch_keys":0,"entities":447,"extents":[],"frame":10,"frame_ms":29.886,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.984,"step_ms":0.127,"cost_ms":1.111},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/images/ui_texture_slice_flip_and_tile","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":461,"extents":[],"frame":10,"frame_ms":28.713,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.911,"step_ms":0.173,"cost_ms":1.084},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/images/ui_texture_atlas_slice","frame":10,"ssim":0.990791,"tile":17,"bevy":{"batch_keys":0,"entities":447,"extents":[],"frame":10,"frame_ms":29.54,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.992,"step_ms":0.136,"cost_ms":1.128},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/widgets/button","frame":10,"ssim":0.999600,"tile":8,"bevy":{"batch_keys":0,"entities":444,"extents":[],"frame":10,"frame_ms":29.169,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.083,"step_ms":0.155,"cost_ms":1.238},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/text/letter_spacing","frame":10,"ssim":0.995902,"tile":13,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":10,"frame_ms":28.702,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.89,"step_ms":0.127,"cost_ms":1.017},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/styling/borders","frame":10,"ssim":0.991738,"tile":9,"bevy":{"batch_keys":0,"entities":591,"extents":[],"frame":10,"frame_ms":29.246,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.84,"step_ms":0.091,"cost_ms":0.931},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/window_fallthrough","frame":10,"ssim":0.990127,"tile":16,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":29.513,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.881,"step_ms":0.155,"cost_ms":1.036},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/text/inline_image","frame":10,"ssim":0.996682,"tile":11,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":10,"frame_ms":28.53,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.906,"step_ms":0.191,"cost_ms":1.097},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/layout/z_index","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":[],"frame":10,"frame_ms":28.664,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.961,"step_ms":0.145,"cost_ms":1.106},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"3d/mesh_ray_cast","frame":300,"ssim":0.999715,"tile":1,"bevy":{"batch_keys":1,"entities":447,"extents":["0.5000 0.0000 0.5000"],"frame":300,"frame_ms":3.142,"materials":2,"mesh_entities":6,"meshes":6,"other_material":0,"visible":6},"raea":{"frame":307,"entities":4658,"mesh_entities":6,"visible":6,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.0000 0.5000"],"frame_ms":1.319,"step_ms":3.353,"cost_ms":4.672},"pixels":true,"draws":true,"time":false,"pass":false,"why":"frame 4.672 ms (1.319 update + 3.353 React step) vs 3.142 ms"}
-{"example":"3d/mesh_ray_cast","frame":900,"ssim":0.999608,"tile":1,"bevy":{"batch_keys":1,"entities":447,"extents":["0.5000 0.0000 0.5000"],"frame":900,"frame_ms":1.87,"materials":2,"mesh_entities":6,"meshes":6,"other_material":0,"visible":6},"raea":{"frame":907,"entities":44258,"mesh_entities":6,"visible":6,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.0000 0.5000"],"frame_ms":3.494,"step_ms":1.497,"cost_ms":4.991},"pixels":true,"draws":true,"time":false,"pass":false,"why":"frame 4.991 ms (3.494 update + 1.497 React step) vs 1.87 ms"}
+{"example":"stress_tests/many_cubes","frame":30,"ssim":0.995176,"tile":1,"bevy":{"batch_keys":2,"entities":10444,"extents":["0.3620 0.3620 0.3620","550.0000 550.0000 550.0000"],"frame":30,"frame_ms":12.192,"materials":3,"mesh_entities":10001,"meshes":7,"other_material":0,"visible":729},"raea":{"frame":37,"entities":10495,"mesh_entities":10001,"visible":729,"meshes":9,"materials":2,"batch_keys":2,"other_material":0,"extents":["0.3620 0.3620 0.3620","550.0000 550.0000 550.0000"],"frame_ms":1.56,"step_ms":0.587,"cost_ms":2.147},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"stress_tests/many_cubes","frame":60,"ssim":0.995154,"tile":1,"bevy":{"batch_keys":2,"entities":10444,"extents":["0.3620 0.3620 0.3620","550.0000 550.0000 550.0000"],"frame":60,"frame_ms":2.426,"materials":3,"mesh_entities":10001,"meshes":7,"other_material":0,"visible":734},"raea":{"frame":67,"entities":10495,"mesh_entities":10001,"visible":733,"meshes":9,"materials":2,"batch_keys":2,"other_material":0,"extents":["0.3620 0.3620 0.3620","550.0000 550.0000 550.0000"],"frame_ms":1.679,"step_ms":0.484,"cost_ms":2.163},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/3d_scene","frame":10,"ssim":0.999998,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["0.5000 0.5000 0.5000","4.0000 4.0000 0.0000"],"frame":10,"frame_ms":3.467,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":17,"entities":498,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","4.0000 4.0000 0.0000"],"frame_ms":1.744,"step_ms":0.209,"cost_ms":1.953},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/3d_scene","frame":5,"ssim":0.999998,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["0.5000 0.5000 0.5000","4.0000 4.0000 0.0000"],"frame":5,"frame_ms":58.043,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":12,"entities":498,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","4.0000 4.0000 0.0000"],"frame_ms":3.127,"step_ms":0.200,"cost_ms":3.327},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"stress_tests/many_lights","frame":30,"ssim":0.999957,"tile":0,"bevy":{"batch_keys":1,"entities":100443,"extents":["49.9006 50.0000 50.0000"],"frame":30,"frame_ms":17.454,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":1},"raea":{"frame":37,"entities":100495,"mesh_entities":2,"visible":1,"meshes":9,"materials":3,"batch_keys":1,"other_material":0,"extents":["49.9006 50.0000 50.0000"],"frame_ms":3.983,"step_ms":2.223,"cost_ms":6.206},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"stress_tests/many_lights","frame":60,"ssim":0.999954,"tile":0,"bevy":{"batch_keys":1,"entities":100445,"extents":["49.9006 50.0000 50.0000"],"frame":60,"frame_ms":2.613,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":1},"raea":{"frame":67,"entities":100495,"mesh_entities":2,"visible":1,"meshes":9,"materials":3,"batch_keys":1,"other_material":0,"extents":["49.9006 50.0000 50.0000"],"frame_ms":3.909,"step_ms":1.892,"cost_ms":5.801},"pixels":true,"draws":true,"time":false,"pass":false,"why":"frame 5.801 ms (3.909 update + 1.892 React step) vs 2.613 ms"}
+{"example":"stress_tests/many_foxes","frame":30,"ssim":0.989592,"tile":3,"bevy":{"batch_keys":2,"entities":30464,"extents":["17.4810 42.8200 84.6165","2500.0000 0.0000 2500.0000","50.9020 42.8200 89.1329","54.3371 42.8200 89.5665","81.3309 42.8200 92.9734","85.2965 42.8200 93.4739","94.6316 42.8200 94.6520","94.6316 42.8200 94.6521"],"frame":30,"frame_ms":16.651,"materials":3,"mesh_entities":1001,"meshes":7,"other_material":0,"visible":1001},"raea":{"frame":39,"entities":31495,"mesh_entities":1001,"visible":1001,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["17.4809 42.8200 84.6165","2500.0000 0.0000 2500.0000","50.9021 42.8200 89.1329","50.9021 42.8200 89.1330","54.3371 42.8200 89.5665","81.3310 42.8200 92.9734","85.2964 42.8200 93.4738","94.6316 42.8200 94.6520"],"frame_ms":8.557,"step_ms":8.239,"cost_ms":16.796},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"stress_tests/many_foxes","frame":60,"ssim":0.990304,"tile":3,"bevy":{"batch_keys":2,"entities":30464,"extents":["23.6615 34.9370 84.2011","23.6615 34.9370 84.2012","2500.0000 0.0000 2500.0000","78.2183 34.9370 91.5996","80.4108 34.9370 91.8799","84.3248 34.9370 92.3804","86.0376 34.9370 92.5995","86.0377 34.9371 92.5995"],"frame":60,"frame_ms":3.608,"materials":3,"mesh_entities":1001,"meshes":7,"other_material":0,"visible":1001},"raea":{"frame":69,"entities":31495,"mesh_entities":1001,"visible":1001,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["21.9974 34.9370 83.6309","23.6613 34.9370 84.2011","2500.0000 0.0000 2500.0000","78.2186 34.9370 91.5996","80.4110 34.9370 91.8800","84.3247 34.9370 92.3804","86.0374 34.9370 92.5994","86.0374 34.9371 92.5994"],"frame_ms":8.913,"step_ms":8.307,"cost_ms":17.22},"pixels":true,"draws":true,"time":false,"pass":false,"why":"frame 17.22 ms (8.913 update + 8.307 React step) vs 3.608 ms"}
+{"example":"animation/animated_mesh","frame":30,"ssim":0.996636,"tile":1,"bevy":{"batch_keys":2,"entities":472,"extents":["15.4187 42.8200 84.0474","250000.0000 0.0000 250000.0000"],"frame":30,"frame_ms":13.544,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":40,"entities":526,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["15.4187 42.8200 84.0474","250000.0000 0.0000 250000.0000"],"frame_ms":1.499,"step_ms":0.181,"cost_ms":1.68},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"animation/animated_mesh","frame":60,"ssim":0.996594,"tile":1,"bevy":{"batch_keys":2,"entities":472,"extents":["19.9546 34.9370 82.9540","250000.0000 0.0000 250000.0000"],"frame":60,"frame_ms":2.564,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":70,"entities":526,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["19.9546 34.9370 82.9540","250000.0000 0.0000 250000.0000"],"frame_ms":1.312,"step_ms":0.125,"cost_ms":1.437},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/extended_material","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":448,"extents":["0.9945 1.0000 1.0000"],"frame":30,"frame_ms":12.653,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":37,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.9945 1.0000 1.0000"],"frame_ms":0.87,"step_ms":0.281,"cost_ms":1.151},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/extended_material","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":448,"extents":["0.9945 1.0000 1.0000"],"frame":60,"frame_ms":1.936,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":67,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.9945 1.0000 1.0000"],"frame_ms":0.819,"step_ms":0.179,"cost_ms":0.998},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/orthographic","frame":10,"ssim":0.999503,"tile":0,"bevy":{"batch_keys":5,"entities":446,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame":10,"frame_ms":32.193,"materials":6,"mesh_entities":5,"meshes":10,"other_material":0,"visible":5},"raea":{"frame":17,"entities":499,"mesh_entities":5,"visible":5,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame_ms":1.186,"step_ms":0.227,"cost_ms":1.413},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/parenting","frame":30,"ssim":0.999969,"tile":0,"bevy":{"batch_keys":1,"entities":443,"extents":["1.0000 1.0000 1.0000"],"frame":30,"frame_ms":11.992,"materials":2,"mesh_entities":2,"meshes":6,"other_material":0,"visible":2},"raea":{"frame":37,"entities":496,"mesh_entities":2,"visible":2,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["1.0000 1.0000 1.0000"],"frame_ms":0.972,"step_ms":0.248,"cost_ms":1.22},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/parenting","frame":60,"ssim":0.999968,"tile":0,"bevy":{"batch_keys":1,"entities":443,"extents":["1.0000 1.0000 1.0000"],"frame":60,"frame_ms":1.977,"materials":2,"mesh_entities":2,"meshes":6,"other_material":0,"visible":2},"raea":{"frame":67,"entities":496,"mesh_entities":2,"visible":2,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["1.0000 1.0000 1.0000"],"frame_ms":0.921,"step_ms":0.136,"cost_ms":1.057},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/mesh2d","frame":10,"ssim":0.999348,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":29.819,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":494,"mesh_entities":0,"visible":0,"meshes":8,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.004,"step_ms":0.164,"cost_ms":1.168},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/sprite","frame":10,"ssim":0.998326,"tile":8,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":30.978,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.094,"step_ms":0.145,"cost_ms":1.239},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"transforms/3d_rotation","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":30,"frame_ms":10.882,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":37,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.918,"step_ms":0.171,"cost_ms":1.089},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"transforms/3d_rotation","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":1.571,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":67,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.848,"step_ms":0.156,"cost_ms":1.004},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/sprite_flipping","frame":10,"ssim":0.998326,"tile":8,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":28.886,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.075,"step_ms":0.127,"cost_ms":1.202},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/move_sprite","frame":120,"ssim":0.998270,"tile":9,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":120,"frame_ms":1.384,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":127,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.782,"step_ms":0.068,"cost_ms":0.85},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/move_sprite","frame":30,"ssim":0.998261,"tile":8,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":30,"frame_ms":11.908,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.857,"step_ms":0.132,"cost_ms":0.989},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/transparency_2d","frame":10,"ssim":0.997674,"tile":5,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":10,"frame_ms":30.494,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":496,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.138,"step_ms":0.145,"cost_ms":1.283},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"transforms/translation","frame":180,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":180,"frame_ms":1.451,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":187,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.754,"step_ms":0.071,"cost_ms":0.825},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"transforms/translation","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":7.032,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":67,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.793,"step_ms":0.125,"cost_ms":0.918},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"transforms/scale","frame":300,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":300,"frame_ms":1.452,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":307,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.747,"step_ms":0.071,"cost_ms":0.818},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"transforms/scale","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":7.498,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":67,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.819,"step_ms":0.116,"cost_ms":0.935},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/texture","frame":10,"ssim":0.999547,"tile":1,"bevy":{"batch_keys":3,"entities":443,"extents":["4.0000 1.0000 0.0000"],"frame":10,"frame_ms":31.689,"materials":4,"mesh_entities":3,"meshes":6,"other_material":0,"visible":3},"raea":{"frame":17,"entities":497,"mesh_entities":3,"visible":3,"meshes":8,"materials":4,"batch_keys":3,"other_material":0,"extents":["4.0000 0.0000 1.0000"],"frame_ms":1.076,"step_ms":0.218,"cost_ms":1.294},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/animate_shader","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":["0.5000 0.5000 0.5000"],"frame":30,"frame_ms":11.866,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":37,"entities":494,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.843,"step_ms":0.123,"cost_ms":0.966},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/animate_shader","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":1.991,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":67,"entities":494,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.854,"step_ms":0.123,"cost_ms":0.977},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/sprite_sheet","frame":30,"ssim":0.998820,"tile":5,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":30,"frame_ms":11.01,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.919,"step_ms":0.129,"cost_ms":1.048},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/sprite_sheet","frame":60,"ssim":0.999054,"tile":5,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":60,"frame_ms":1.313,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.795,"step_ms":0.102,"cost_ms":0.897},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/pbr","frame":30,"ssim":0.997685,"tile":8,"bevy":{"batch_keys":56,"entities":499,"extents":["0.4475 0.4500 0.4500"],"frame":30,"frame_ms":13.677,"materials":57,"mesh_entities":56,"meshes":6,"other_material":0,"visible":56},"raea":{"frame":37,"entities":550,"mesh_entities":56,"visible":56,"meshes":8,"materials":57,"batch_keys":56,"other_material":0,"extents":["0.4475 0.4500 0.4500"],"frame_ms":1.024,"step_ms":0.074,"cost_ms":1.098},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/pbr","frame":60,"ssim":0.997685,"tile":8,"bevy":{"batch_keys":56,"entities":499,"extents":["0.4475 0.4500 0.4500"],"frame":60,"frame_ms":1.974,"materials":57,"mesh_entities":56,"meshes":6,"other_material":0,"visible":56},"raea":{"frame":67,"entities":550,"mesh_entities":56,"visible":56,"meshes":8,"materials":57,"batch_keys":56,"other_material":0,"extents":["0.4475 0.4500 0.4500"],"frame_ms":0.874,"step_ms":0.102,"cost_ms":0.976},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/animated_material","frame":30,"ssim":0.999892,"tile":0,"bevy":{"batch_keys":9,"entities":449,"extents":["0.2500 0.2500 0.2500"],"frame":30,"frame_ms":13.084,"materials":10,"mesh_entities":9,"meshes":6,"other_material":0,"visible":9},"raea":{"frame":37,"entities":502,"mesh_entities":9,"visible":9,"meshes":8,"materials":19,"batch_keys":9,"other_material":0,"extents":["0.2500 0.2500 0.2500"],"frame_ms":0.97,"step_ms":0.358,"cost_ms":1.328},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/animated_material","frame":60,"ssim":0.999940,"tile":0,"bevy":{"batch_keys":9,"entities":449,"extents":["0.2500 0.2500 0.2500"],"frame":60,"frame_ms":1.986,"materials":10,"mesh_entities":9,"meshes":6,"other_material":0,"visible":9},"raea":{"frame":67,"entities":502,"mesh_entities":9,"visible":9,"meshes":8,"materials":19,"batch_keys":9,"other_material":0,"extents":["0.2500 0.2500 0.2500"],"frame_ms":0.944,"step_ms":0.267,"cost_ms":1.211},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"camera/pan_camera_controller","frame":10,"ssim":0.996838,"tile":10,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":10,"frame_ms":30.317,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.118,"step_ms":0.155,"cost_ms":1.273},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"camera/camera_orbit","frame":10,"ssim":0.999220,"tile":8,"bevy":{"batch_keys":2,"entities":445,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame":10,"frame_ms":31.362,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":17,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame_ms":1.148,"step_ms":0.273,"cost_ms":1.421},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"camera/projection_zoom","frame":30,"ssim":0.998026,"tile":8,"bevy":{"batch_keys":2,"entities":473,"extents":["12.5927 39.5145 77.3599","2.5000 0.0000 2.5000"],"frame":30,"frame_ms":13.211,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":40,"entities":526,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["12.5927 39.5145 77.3599","2.5000 0.0000 2.5000"],"frame_ms":1.037,"step_ms":0.152,"cost_ms":1.189},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/sprite_animation","frame":12,"ssim":0.997217,"tile":9,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":12,"frame_ms":25.785,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":19,"entities":495,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.996,"step_ms":0.392,"cost_ms":1.388},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/sprite_animation","frame":30,"ssim":0.997017,"tile":8,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":30,"frame_ms":1.31,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":495,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.906,"step_ms":0.132,"cost_ms":1.038},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/sprite_animation","frame":60,"ssim":0.997099,"tile":8,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":60,"frame_ms":1.456,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":495,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.806,"step_ms":0.100,"cost_ms":0.906},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/sprite_tile","frame":30,"ssim":0.998633,"tile":7,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":30,"frame_ms":11.391,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.996,"step_ms":0.132,"cost_ms":1.128},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/sprite_tile","frame":300,"ssim":0.992213,"tile":7,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":300,"frame_ms":1.127,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":307,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.809,"step_ms":0.056,"cost_ms":0.865},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/vertex_colors","frame":10,"ssim":0.999019,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame":10,"frame_ms":35.055,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":17,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame_ms":2.24,"step_ms":0.236,"cost_ms":2.476},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/spherical_area_lights","frame":10,"ssim":0.999738,"tile":0,"bevy":{"batch_keys":7,"entities":453,"extents":["1.0000 1.0000 1.0000","50.0000 0.0000 50.0000"],"frame":10,"frame_ms":31.611,"materials":8,"mesh_entities":7,"meshes":7,"other_material":0,"visible":7},"raea":{"frame":17,"entities":506,"mesh_entities":7,"visible":7,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 1.0000 1.0000","50.0000 0.0000 50.0000"],"frame_ms":1.522,"step_ms":0.200,"cost_ms":1.722},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/fog_volumes","frame":10,"ssim":0.995718,"tile":14,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":10,"frame_ms":31.512,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.287,"step_ms":0.318,"cost_ms":1.605},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/fog_volumes","frame":60,"ssim":0.995939,"tile":4,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":60,"frame_ms":2.115,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.197,"step_ms":0.123,"cost_ms":1.32},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/bloom_3d","frame":10,"ssim":0.996668,"tile":11,"bevy":{"batch_keys":4,"entities":541,"extents":["0.3978 0.4000 0.4000"],"frame":10,"frame_ms":32.845,"materials":5,"mesh_entities":100,"meshes":6,"other_material":0,"visible":46},"raea":{"frame":17,"entities":593,"mesh_entities":100,"visible":46,"meshes":8,"materials":5,"batch_keys":4,"other_material":0,"extents":["0.3978 0.4000 0.4000"],"frame_ms":1.819,"step_ms":1.355,"cost_ms":3.174},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/bloom_3d","frame":60,"ssim":0.996631,"tile":12,"bevy":{"batch_keys":4,"entities":541,"extents":["0.3978 0.4000 0.4000"],"frame":60,"frame_ms":2.805,"materials":5,"mesh_entities":100,"meshes":6,"other_material":0,"visible":46},"raea":{"frame":67,"entities":593,"mesh_entities":100,"visible":46,"meshes":8,"materials":5,"batch_keys":4,"other_material":0,"extents":["0.3978 0.4000 0.4000"],"frame_ms":1.39,"step_ms":0.589,"cost_ms":1.979},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"transforms/transform","frame":10,"ssim":0.999999,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["0.5000 0.5000 0.5000","3.0000 3.0000 2.9996"],"frame":10,"frame_ms":30.107,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":17,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","3.0000 3.0000 2.9996"],"frame_ms":1.042,"step_ms":0.455,"cost_ms":1.497},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"transforms/transform","frame":120,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["0.5000 0.5000 0.5000","3.0000 3.0000 2.9996"],"frame":120,"frame_ms":1.753,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":127,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","3.0000 3.0000 2.9996"],"frame_ms":0.88,"step_ms":0.143,"cost_ms":1.023},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/transparency_3d","frame":10,"ssim":0.990065,"tile":25,"bevy":{"batch_keys":6,"entities":447,"extents":["0.5000 0.5000 0.5000","3.0000 0.0000 3.0000"],"frame":10,"frame_ms":37.417,"materials":7,"mesh_entities":6,"meshes":11,"other_material":0,"visible":6},"raea":{"frame":17,"entities":500,"mesh_entities":6,"visible":6,"meshes":10,"materials":11,"batch_keys":6,"other_material":0,"extents":["0.5000 0.5000 0.5000","3.0000 0.0000 3.0000"],"frame_ms":2.046,"step_ms":0.527,"cost_ms":2.573},"pixels":false,"draws":true,"time":true,"pass":false,"why":"pixels 0.990065, worst tile 25"}
+{"example":"3d/transparency_3d","frame":90,"ssim":0.998632,"tile":0,"bevy":{"batch_keys":6,"entities":447,"extents":["0.5000 0.5000 0.5000","3.0000 0.0000 3.0000"],"frame":90,"frame_ms":3.16,"materials":7,"mesh_entities":6,"meshes":11,"other_material":0,"visible":6},"raea":{"frame":97,"entities":500,"mesh_entities":6,"visible":6,"meshes":10,"materials":11,"batch_keys":6,"other_material":0,"extents":["0.5000 0.5000 0.5000","3.0000 0.0000 3.0000"],"frame_ms":1.779,"step_ms":0.182,"cost_ms":1.961},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"animation/eased_motion","frame":150,"ssim":0.999822,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["1.0000 1.0000 1.0000","25.0000 0.0000 25.0000"],"frame":150,"frame_ms":2.243,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":157,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 1.0000 1.0000","25.0000 0.0000 25.0000"],"frame_ms":1.521,"step_ms":0.089,"cost_ms":1.61},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"animation/eased_motion","frame":240,"ssim":0.999823,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["1.0000 1.0000 1.0000","25.0000 0.0000 25.0000"],"frame":240,"frame_ms":2.162,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":247,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 1.0000 1.0000","25.0000 0.0000 25.0000"],"frame_ms":1.572,"step_ms":0.075,"cost_ms":1.647},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"animation/eased_motion","frame":60,"ssim":0.999824,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["1.0000 1.0000 1.0000","25.0000 0.0000 25.0000"],"frame":60,"frame_ms":8.174,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":67,"entities":496,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 1.0000 1.0000","25.0000 0.0000 25.0000"],"frame_ms":1.551,"step_ms":0.144,"cost_ms":1.695},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"animation/color_animation","frame":120,"ssim":0.998717,"tile":1,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":120,"frame_ms":1.484,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":127,"entities":499,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.887,"step_ms":0.098,"cost_ms":0.985},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"animation/color_animation","frame":200,"ssim":0.996870,"tile":4,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":200,"frame_ms":1.105,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":207,"entities":499,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.807,"step_ms":0.078,"cost_ms":0.885},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"animation/color_animation","frame":30,"ssim":0.998699,"tile":2,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":30,"frame_ms":11.713,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":499,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.009,"step_ms":0.165,"cost_ms":1.174},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/rect_light","frame":10,"ssim":0.998374,"tile":8,"bevy":{"batch_keys":2,"entities":446,"extents":["0.9945 1.0000 1.0000","10.0000 0.0000 10.0000"],"frame":10,"frame_ms":33.243,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":17,"entities":501,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.9945 1.0000 1.0000","10.0000 0.0000 10.0000"],"frame_ms":1.333,"step_ms":0.209,"cost_ms":1.542},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/shadow_caster_receiver","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":4,"entities":446,"extents":["0.2486 0.2500 0.2500","10.0000 0.0000 10.0000"],"frame":10,"frame_ms":33.524,"materials":5,"mesh_entities":4,"meshes":8,"other_material":0,"visible":4},"raea":{"frame":17,"entities":499,"mesh_entities":4,"visible":4,"meshes":9,"materials":5,"batch_keys":4,"other_material":0,"extents":["0.2486 0.2500 0.2500","10.0000 0.0000 10.0000"],"frame_ms":1.672,"step_ms":0.364,"cost_ms":2.036},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/spotlight","frame":10,"ssim":0.997767,"tile":10,"bevy":{"batch_keys":4,"entities":530,"extents":["0.0500 0.0500 0.0500","0.1000 0.1000 0.1000","0.2500 0.2500 0.2500","50.0000 0.0000 50.0000"],"frame":10,"frame_ms":36.727,"materials":5,"mesh_entities":73,"meshes":9,"other_material":0,"visible":73},"raea":{"frame":17,"entities":582,"mesh_entities":73,"visible":73,"meshes":11,"materials":5,"batch_keys":4,"other_material":0,"extents":["0.0500 0.0500 0.0500","0.1000 0.1000 0.1000","0.2500 0.2500 0.2500","50.0000 0.0000 50.0000"],"frame_ms":4.691,"step_ms":1.318,"cost_ms":6.009},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/spotlight","frame":90,"ssim":0.996452,"tile":10,"bevy":{"batch_keys":4,"entities":530,"extents":["0.0500 0.0500 0.0500","0.1000 0.1000 0.1000","0.2500 0.2500 0.2500","50.0000 0.0000 50.0000"],"frame":90,"frame_ms":5.318,"materials":5,"mesh_entities":73,"meshes":9,"other_material":0,"visible":73},"raea":{"frame":97,"entities":582,"mesh_entities":73,"visible":73,"meshes":11,"materials":5,"batch_keys":4,"other_material":0,"extents":["0.0500 0.0500 0.0500","0.1000 0.1000 0.1000","0.2500 0.2500 0.2500","50.0000 0.0000 50.0000"],"frame_ms":4.254,"step_ms":0.614,"cost_ms":4.868},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"transforms/align","frame":10,"ssim":0.993011,"tile":11,"bevy":{"batch_keys":5,"entities":453,"extents":["1.4000 0.4500 1.1128","50.0000 0.0000 50.0000"],"frame":10,"frame_ms":34.423,"materials":6,"mesh_entities":5,"meshes":10,"other_material":0,"visible":5},"raea":{"frame":19,"entities":512,"mesh_entities":5,"visible":5,"meshes":12,"materials":6,"batch_keys":5,"other_material":0,"extents":["1.4000 0.4500 1.1128","50.0000 0.0000 50.0000"],"frame_ms":2.321,"step_ms":0.218,"cost_ms":2.539},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"transforms/align","frame":30,"ssim":0.993011,"tile":11,"bevy":{"batch_keys":5,"entities":453,"extents":["1.4000 0.4500 1.1128","50.0000 0.0000 50.0000"],"frame":30,"frame_ms":3.547,"materials":6,"mesh_entities":5,"meshes":10,"other_material":0,"visible":5},"raea":{"frame":39,"entities":512,"mesh_entities":5,"visible":5,"meshes":12,"materials":6,"batch_keys":5,"other_material":0,"extents":["1.4000 0.4500 1.1128","50.0000 0.0000 50.0000"],"frame_ms":1.887,"step_ms":0.132,"cost_ms":2.019},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/3d_viewport_to_world","frame":10,"ssim":0.998921,"tile":1,"bevy":{"batch_keys":1,"entities":442,"extents":["10.0000 0.0000 10.0000"],"frame":10,"frame_ms":2.486,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":17,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["10.0000 0.0000 10.0000"],"frame_ms":1.017,"step_ms":0.227,"cost_ms":1.244},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/3d_viewport_to_world","frame":5,"ssim":0.998921,"tile":1,"bevy":{"batch_keys":1,"entities":442,"extents":["10.0000 0.0000 10.0000"],"frame":5,"frame_ms":56.2,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":12,"entities":495,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["10.0000 0.0000 10.0000"],"frame_ms":1.933,"step_ms":0.200,"cost_ms":2.133},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/atmospheric_fog","frame":10,"ssim":0.998688,"tile":9,"bevy":{"batch_keys":2,"entities":449,"extents":["1.0000 0.1674 1.0026","1.0000 0.5000 0.5000"],"frame":10,"frame_ms":3.725,"materials":3,"mesh_entities":3,"meshes":7,"other_material":0,"visible":3},"raea":{"frame":19,"entities":504,"mesh_entities":3,"visible":3,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 0.1674 1.0026","1.0000 0.5000 0.5000"],"frame_ms":1.581,"step_ms":0.227,"cost_ms":1.808},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/atmospheric_fog","frame":5,"ssim":0.998688,"tile":9,"bevy":{"batch_keys":2,"entities":449,"extents":["1.0000 0.1674 1.0026","1.0000 0.5000 0.5000"],"frame":5,"frame_ms":56.032,"materials":3,"mesh_entities":3,"meshes":7,"other_material":0,"visible":3},"raea":{"frame":14,"entities":504,"mesh_entities":3,"visible":3,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 0.1674 1.0026","1.0000 0.5000 0.5000"],"frame_ms":2.707,"step_ms":0.200,"cost_ms":2.907},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/rotate_to_cursor","frame":10,"ssim":0.999835,"tile":3,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":1.6,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.996,"step_ms":0.145,"cost_ms":1.141},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/rotate_to_cursor","frame":5,"ssim":0.999835,"tile":3,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":5,"frame_ms":55.547,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":494,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.936,"step_ms":0.167,"cost_ms":2.103},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"movement/smooth_follow","frame":120,"ssim":0.998129,"tile":0,"bevy":{"batch_keys":3,"entities":448,"extents":["0.2983 0.3000 0.3000","6.0000 0.0000 6.0000"],"frame":120,"frame_ms":2.541,"materials":4,"mesh_entities":3,"meshes":8,"other_material":0,"visible":3},"raea":{"frame":127,"entities":497,"mesh_entities":3,"visible":3,"meshes":9,"materials":4,"batch_keys":3,"other_material":0,"extents":["0.2983 0.3000 0.3000","6.0000 0.0000 6.0000"],"frame_ms":1.465,"step_ms":0.122,"cost_ms":1.587},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"movement/smooth_follow","frame":30,"ssim":0.998157,"tile":0,"bevy":{"batch_keys":3,"entities":448,"extents":["0.2983 0.3000 0.3000","6.0000 0.0000 6.0000"],"frame":30,"frame_ms":13.796,"materials":4,"mesh_entities":3,"meshes":8,"other_material":0,"visible":3},"raea":{"frame":37,"entities":497,"mesh_entities":3,"visible":3,"meshes":9,"materials":4,"batch_keys":3,"other_material":0,"extents":["0.2983 0.3000 0.3000","6.0000 0.0000 6.0000"],"frame_ms":1.724,"step_ms":0.274,"cost_ms":1.998},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/mesh_ray_cast","frame":300,"ssim":0.999715,"tile":1,"bevy":{"batch_keys":1,"entities":447,"extents":["0.5000 0.0000 0.5000"],"frame":300,"frame_ms":3.184,"materials":2,"mesh_entities":6,"meshes":6,"other_material":0,"visible":6},"raea":{"frame":307,"entities":4658,"mesh_entities":6,"visible":6,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.0000 0.5000"],"frame_ms":1.365,"step_ms":2.987,"cost_ms":4.352},"pixels":true,"draws":true,"time":false,"pass":false,"why":"frame 4.352 ms (1.365 update + 2.987 React step) vs 3.184 ms"}
+{"example":"3d/mesh_ray_cast","frame":900,"ssim":0.999608,"tile":1,"bevy":{"batch_keys":1,"entities":447,"extents":["0.5000 0.0000 0.5000"],"frame":900,"frame_ms":1.986,"materials":2,"mesh_entities":6,"meshes":6,"other_material":0,"visible":6},"raea":{"frame":907,"entities":44258,"mesh_entities":6,"visible":6,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.0000 0.5000"],"frame_ms":3.694,"step_ms":1.398,"cost_ms":5.092},"pixels":true,"draws":true,"time":false,"pass":false,"why":"frame 5.092 ms (3.694 update + 1.398 React step) vs 1.986 ms"}
+{"example":"2d/mesh2d_alpha_mode","frame":10,"ssim":0.989355,"tile":8,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":10,"frame_ms":1.966,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":499,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.042,"step_ms":0.127,"cost_ms":1.169},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/mesh2d_alpha_mode","frame":5,"ssim":0.989355,"tile":8,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":5,"frame_ms":53.6,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":12,"entities":499,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.959,"step_ms":0.217,"cost_ms":2.176},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/lightmaps","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":6,"entities":453,"extents":["0.0001 274.4000 279.6000","102.6464 82.5000 102.6464","103.2390 165.0000 103.2390","278.0000 274.4000 279.6001","3.2000 274.4000 279.6000","65.0000 0.0000 52.5000"],"frame":10,"frame_ms":2.804,"materials":6,"mesh_entities":6,"meshes":11,"other_material":0,"visible":6},"raea":{"frame":19,"entities":506,"mesh_entities":6,"visible":6,"meshes":13,"materials":10,"batch_keys":6,"other_material":0,"extents":["0.0001 274.4000 279.6000","102.6464 82.5000 102.6464","103.2390 165.0000 103.2390","278.0000 274.4000 279.6001","3.2000 274.4000 279.6000","65.0000 0.0000 52.5000"],"frame_ms":1.43,"step_ms":0.227,"cost_ms":1.657},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"3d/lightmaps","frame":5,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":6,"entities":453,"extents":["0.0001 274.4000 279.6000","102.6464 82.5000 102.6464","103.2390 165.0000 103.2390","278.0000 274.4000 279.6001","3.2000 274.4000 279.6000","65.0000 0.0000 52.5000"],"frame":5,"frame_ms":67.12,"materials":6,"mesh_entities":6,"meshes":11,"other_material":0,"visible":6},"raea":{"frame":14,"entities":506,"mesh_entities":6,"visible":6,"meshes":13,"materials":10,"batch_keys":6,"other_material":0,"extents":["0.0001 274.4000 279.6000","102.6464 82.5000 102.6464","103.2390 165.0000 103.2390","278.0000 274.4000 279.6001","3.2000 274.4000 279.6000","65.0000 0.0000 52.5000"],"frame_ms":2.116,"step_ms":0.217,"cost_ms":2.333},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/styling/transparency_ui","frame":10,"ssim":0.999721,"tile":3,"bevy":{"batch_keys":0,"entities":445,"extents":[],"frame":10,"frame_ms":1.711,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.34,"step_ms":0.127,"cost_ms":1.467},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/styling/transparency_ui","frame":5,"ssim":0.999721,"tile":3,"bevy":{"batch_keys":0,"entities":445,"extents":[],"frame":5,"frame_ms":55.694,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.802,"step_ms":0.167,"cost_ms":1.969},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/layout/fixed_node","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":444,"extents":[],"frame":10,"frame_ms":1.949,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.006,"step_ms":0.127,"cost_ms":1.133},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/layout/fixed_node","frame":5,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":444,"extents":[],"frame":5,"frame_ms":56.227,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.194,"step_ms":0.200,"cost_ms":2.394},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/images/image_node","frame":10,"ssim":0.999965,"tile":0,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":10,"frame_ms":1.747,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.932,"step_ms":0.136,"cost_ms":1.068},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/images/image_node","frame":5,"ssim":0.999965,"tile":0,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":5,"frame_ms":52.963,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.949,"step_ms":0.200,"cost_ms":2.149},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/text/font_weights","frame":10,"ssim":0.991774,"tile":17,"bevy":{"batch_keys":0,"entities":454,"extents":[],"frame":10,"frame_ms":1.794,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.859,"step_ms":0.127,"cost_ms":0.986},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/text/font_weights","frame":5,"ssim":0.991774,"tile":17,"bevy":{"batch_keys":0,"entities":454,"extents":[],"frame":5,"frame_ms":53.23,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.033,"step_ms":0.150,"cost_ms":2.183},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/text/font_variations","frame":10,"ssim":0.993984,"tile":20,"bevy":{"batch_keys":0,"entities":452,"extents":[],"frame":10,"frame_ms":2.346,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.907,"step_ms":0.145,"cost_ms":1.052},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/text/font_variations","frame":5,"ssim":0.993984,"tile":20,"bevy":{"batch_keys":0,"entities":452,"extents":[],"frame":5,"frame_ms":55.282,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.924,"step_ms":0.183,"cost_ms":2.107},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/text/text_background_colors","frame":10,"ssim":0.998841,"tile":7,"bevy":{"batch_keys":0,"entities":505,"extents":[],"frame":10,"frame_ms":1.753,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.007,"step_ms":0.127,"cost_ms":1.134},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/text/text_background_colors","frame":5,"ssim":0.998841,"tile":7,"bevy":{"batch_keys":0,"entities":505,"extents":[],"frame":5,"frame_ms":54.616,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.093,"step_ms":0.183,"cost_ms":2.276},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/text/strikethrough_and_underline","frame":10,"ssim":0.990823,"tile":15,"bevy":{"batch_keys":0,"entities":454,"extents":[],"frame":10,"frame_ms":2.046,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.912,"step_ms":0.236,"cost_ms":1.148},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/text/strikethrough_and_underline","frame":5,"ssim":0.990823,"tile":15,"bevy":{"batch_keys":0,"entities":454,"extents":[],"frame":5,"frame_ms":57.274,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.768,"step_ms":0.167,"cost_ms":1.935},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/scroll_and_overflow/overflow","frame":10,"ssim":0.998763,"tile":4,"bevy":{"batch_keys":0,"entities":461,"extents":[],"frame":10,"frame_ms":1.907,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.952,"step_ms":0.191,"cost_ms":1.143},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/scroll_and_overflow/overflow","frame":5,"ssim":0.998763,"tile":4,"bevy":{"batch_keys":0,"entities":461,"extents":[],"frame":5,"frame_ms":55.299,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.067,"step_ms":0.300,"cost_ms":2.367},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/images/ui_texture_atlas","frame":10,"ssim":0.999776,"tile":6,"bevy":{"batch_keys":0,"entities":445,"extents":[],"frame":10,"frame_ms":1.608,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.973,"step_ms":0.200,"cost_ms":1.173},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/images/ui_texture_atlas","frame":5,"ssim":0.999776,"tile":6,"bevy":{"batch_keys":0,"entities":445,"extents":[],"frame":5,"frame_ms":55.372,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.821,"step_ms":0.183,"cost_ms":2.004},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/mesh2d_vertex_color_texture","frame":10,"ssim":0.998651,"tile":6,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":10,"frame_ms":31.381,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":495,"mesh_entities":0,"visible":0,"meshes":9,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.978,"step_ms":0.145,"cost_ms":1.123},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"2d/mesh2d_repeated_texture","frame":10,"ssim":0.991205,"tile":17,"bevy":{"batch_keys":0,"entities":437,"extents":[],"frame":10,"frame_ms":22.753,"materials":1,"mesh_entities":0,"meshes":8,"other_material":0,"visible":0},"raea":{"frame":17,"entities":496,"mesh_entities":0,"visible":0,"meshes":10,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.01,"step_ms":0.227,"cost_ms":1.237},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/layout/flex_layout","frame":10,"ssim":0.992327,"tile":8,"bevy":{"batch_keys":0,"entities":602,"extents":[],"frame":10,"frame_ms":30.162,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.05,"step_ms":0.082,"cost_ms":1.132},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/scroll_and_overflow/overflow_clip_margin","frame":10,"ssim":0.997488,"tile":7,"bevy":{"batch_keys":0,"entities":465,"extents":[],"frame":10,"frame_ms":31.094,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.921,"step_ms":0.173,"cost_ms":1.094},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/images/ui_texture_slice","frame":10,"ssim":0.998941,"tile":8,"bevy":{"batch_keys":0,"entities":447,"extents":[],"frame":10,"frame_ms":30.286,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.865,"step_ms":0.136,"cost_ms":1.001},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/images/ui_texture_slice_flip_and_tile","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":461,"extents":[],"frame":10,"frame_ms":32.019,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.05,"step_ms":0.182,"cost_ms":1.232},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/images/ui_texture_atlas_slice","frame":10,"ssim":0.990813,"tile":16,"bevy":{"batch_keys":0,"entities":447,"extents":[],"frame":10,"frame_ms":29.297,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.091,"step_ms":0.145,"cost_ms":1.236},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/widgets/button","frame":10,"ssim":0.999633,"tile":8,"bevy":{"batch_keys":0,"entities":444,"extents":[],"frame":10,"frame_ms":30.516,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.834,"step_ms":0.182,"cost_ms":1.016},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/text/letter_spacing","frame":10,"ssim":0.996458,"tile":13,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":10,"frame_ms":30.146,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.084,"step_ms":0.136,"cost_ms":1.22},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/styling/borders","frame":10,"ssim":0.992828,"tile":9,"bevy":{"batch_keys":0,"entities":591,"extents":[],"frame":10,"frame_ms":28.137,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.02,"step_ms":0.073,"cost_ms":1.093},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/window_fallthrough","frame":10,"ssim":0.992068,"tile":16,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":30.023,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.942,"step_ms":0.155,"cost_ms":1.097},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/text/inline_image","frame":10,"ssim":0.998473,"tile":8,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":10,"frame_ms":31.458,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.109,"step_ms":0.200,"cost_ms":1.309},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/layout/z_index","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":[],"frame":10,"frame_ms":30.365,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.047,"step_ms":0.155,"cost_ms":1.202},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/styling/stacked_gradients","frame":10,"ssim":0.994550,"tile":1,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":10,"frame_ms":32.23,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":492,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.988,"step_ms":0.136,"cost_ms":1.124},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
diff --git a/runtime/page/src/elements.rs b/runtime/page/src/elements.rs
index e617aa65..ea9de09b 100644
--- a/runtime/page/src/elements.rs
+++ b/runtime/page/src/elements.rs
@@ -216,9 +216,10 @@ pub(crate) fn page_props(kind: &str, props: Option<&Map<String, Value>>, dir: &P
// <Text>'s data-raea-bevy-text kept: Blitz measures its block as bevy_text does, vendor/blitz-dom layout/inline.rs;
// a sliced ImageNode's data-raea-bevy-slice kept: Blitz scales and tiles its border-image as bevy_ui does,
// vendor/blitz-paint render/border_image.rs; a GlobalZIndex node's data-raea-bevy-global-z kept: Blitz ranks it in the
- // root's stacking context, vendor/blitz-dom layout/paint_tree.rs;
+ // root's stacking context, vendor/blitz-dom layout/paint_tree.rs; a bevy_ui root's data-raea-blend kept: its page
+ // blends in linear light, systems/page paint;
// the source stamps data-raea-loc and data-raea-use kept for the render manifest, engine/bundle stamp.rs)
- if k == "children" || k == "key" || (k.starts_with("data-raea") && k != "data-raea-start" && k != "data-raea-bevy-text" && k != "data-raea-bevy-slice" && k != "data-raea-bevy-global-z" && k != "data-raea-loc" && k != "data-raea-use") || k == "data-props" || k == "data-shape" || k == "data-anim" || v.is_null() {
+ if k == "children" || k == "key" || (k.starts_with("data-raea") && k != "data-raea-start" && k != "data-raea-bevy-text" && k != "data-raea-bevy-slice" && k != "data-raea-bevy-global-z" && k != "data-raea-blend" && k != "data-raea-loc" && k != "data-raea-use") || k == "data-props" || k == "data-shape" || k == "data-anim" || v.is_null() {
continue;
}
if k.starts_with("on") && k.chars().nth(2).is_some_and(|c| c.is_ascii_uppercase()) {
diff --git a/sdk/raea/bench/bevy-parity/ui/styling/stacked_gradients.tsx b/sdk/raea/bench/bevy-parity/ui/styling/stacked_gradients.tsx
new file mode 100644
index 00000000..894e045f
--- /dev/null
+++ b/sdk/raea/bench/bevy-parity/ui/styling/stacked_gradients.tsx
@@ -0,0 +1,35 @@
+// Bevy v0.20.0 examples/ui/styling/stacked_gradients.rs in raea's TSX (docs/control.feature FC0a): a full-window grid
+// holding a full-size black node with six BackgroundGradients stacked, the first at the bottom: red fading to the top
+// right, blue to the top left, a yellow conic band round the centre, a white-yellow sun (a 30 vh circle 5% right of
+// the top centre) and two black fades at TAU/16 and 15 TAU/16, all interpolated in Oklab. Bevy's Camera2d over the
+// default clear colour is the layered <Canvas3D>. In Bevy's default 1280 x 720 window.
+import { AbsoluteFill, Composition, registerRoot } from "raea";
+import { Canvas3D } from "raea/3d";
+import { AngularColorStop, ColorStop, ConicGradient, LinearGradient, Node, RadialGradient, UiPosition, percent, vh } from "raea/ui";
+import { Srgba } from "raea/color";
+
+const TAU = 2 * Math.PI;
+const RED = new Srgba(1, 0, 0), BLUE = new Srgba(0, 0, 1), YELLOW = new Srgba(1, 1, 0), BLACK = new Srgba(0, 0, 0);
+const fade = (c: Srgba, a = 0) => c.with_alpha(a);
+
+const GRADIENTS = [
+ LinearGradient.to_top_right([ColorStop.auto(RED), ColorStop.auto(fade(RED))]),
+ LinearGradient.to_top_left([ColorStop.auto(BLUE), ColorStop.auto(fade(BLUE))]),
+ ConicGradient.new(UiPosition.CENTER, [fade(YELLOW), fade(YELLOW), YELLOW, fade(YELLOW), fade(YELLOW)].map(AngularColorStop.auto)),
+ RadialGradient.new(UiPosition.TOP.at_x(percent(5)), { Circle: vh(30) }, [ColorStop.auto(new Srgba(1, 1, 1)), ColorStop.auto(YELLOW), ColorStop.auto(fade(YELLOW, 0.1)), ColorStop.auto(fade(YELLOW))]),
+ LinearGradient.new(TAU / 16, [ColorStop.auto(BLACK), ColorStop.auto(fade(BLACK))]),
+ LinearGradient.new((15 * TAU) / 16, [ColorStop.auto(BLACK), ColorStop.auto(fade(BLACK))]),
+];
+
+function Shot() {
+ return (
+ <AbsoluteFill>
+ <Canvas3D layered clearColor="rgb(43, 44, 47)" />
+ <Node display="Grid" width={percent(100)} height={percent(100)}>
+ <Node width={percent(100)} height={percent(100)} background_color={BLACK} background_gradient={GRADIENTS} />
+ </Node>
+ </AbsoluteFill>
+ );
+}
+
+registerRoot(() => <Composition id="main" component={Shot} durationInFrames={11} fps={60} width={1280} height={720} />);
diff --git a/sdk/raea/conformance/ui.test.tsx b/sdk/raea/conformance/ui.test.tsx
index 3eeec099..fd411342 100644
--- a/sdk/raea/conformance/ui.test.tsx
+++ b/sdk/raea/conformance/ui.test.tsx
@@ -1,7 +1,7 @@
// docs/control.feature FC0a: bevy_ui's Node, Text and TextSpan on the page, with Bevy's defaults, values and blend
// (ui/styling/transparency_ui, ui/layout/fixed_node).
import { describe, expect, test } from "bun:test";
-import { BorderRadius, CornerRadius, FontVariationTag, ImageNode, InlineImage, ImagePlugin, Node, TextureAtlasLayout, Overflow, OverflowClipMargin, Text, TextShadow, Text2d, UiScale, TextSpan, UiRect, auto, percent, px, vw } from "raea/ui";
+import { AngularColorStop, ColorStop, ConicGradient, LinearGradient, RadialGradient, UiPosition, BorderRadius, CornerRadius, FontVariationTag, ImageNode, InlineImage, ImagePlugin, Node, TextureAtlasLayout, Overflow, OverflowClipMargin, Text, TextShadow, Text2d, UiScale, TextSpan, UiRect, auto, percent, px, vw } from "raea/ui";
import { LinearRgba, Srgba } from "raea/color";
import { Canvas3D } from "raea/3d";
import { renderFrame } from "../src/test";
@@ -208,6 +208,21 @@ describe("A sliced ImageNode, a sampled picture and UiScale", () => {
expect(html(<Canvas3D layered clearColor="rgb(0, 0, 0)" />)).toContain("z-index:-2147483648");
expect(html(<Canvas3D layered />)).not.toContain("z-index");
});
+ test("BackgroundGradient is CSS gradients in Oklab, the first at the bottom, Bevy's shapes and positions as CSS's", () => {
+ const red = new Srgba(1, 0, 0), clear = new Srgba(1, 0, 0, 0);
+ const out = html(<Node background_color={new Srgba(0, 0, 0)} background_gradient={[
+ LinearGradient.to_right([ColorStop.auto(red), ColorStop.new(clear, percent(80))]),
+ RadialGradient.new(UiPosition.TOP.at_x(percent(5)), "ClosestCorner", [ColorStop.auto(red), ColorStop.auto(clear)]),
+ ConicGradient.new(UiPosition.BOTTOM_RIGHT.at(px(10), px(20)), [AngularColorStop.auto(red), AngularColorStop.new(clear, Math.PI)], 0.5),
+ ]} />);
+ expect(out).toContain("background-image:conic-gradient(from 0.5rad at calc(100% - 10px) calc(100% - 20px) in oklab, rgba(255, 0, 0, 1), rgba(255, 0, 0, 0) 3.141592653589793rad), radial-gradient(ellipse closest-side at calc(50% + 5%) calc(0% + 0px) in oklab, rgba(255, 0, 0, 1), rgba(255, 0, 0, 0)), linear-gradient(1.5707963267948966rad in oklab, rgba(255, 0, 0, 1), rgba(255, 0, 0, 0) 80%)");
+ expect(out).toContain("background-origin:border-box");
+ // a page with bevy_ui in it blends in linear light (raea-page's paint; vendor/vello_shaders fine.wgsl)
+ expect(out).toContain('data-raea-blend="linear"');
+ const hinted = html(<Node background_gradient={[LinearGradient.new(0, [{ color: red, point: px(0), hint: 0.25 }, ColorStop.new(clear, px(100))], "Srgba")]} />);
+ expect(hinted).toContain("linear-gradient(0rad in srgb, rgba(255, 0, 0, 1) 0px, calc(0px + (100px - 0px) * 0.25), rgba(255, 0, 0, 0) 100px)");
+ expect(() => html(<Node background_gradient={[RadialGradient.new(UiPosition.CENTER, { Circle: percent(10) }, [ColorStop.auto(red)])]} />)).toThrow(/Circle's radius in percent/);
+ });
test("BorderColor takes a colour per side", () => {
const out = html(<Node border={UiRect.all(px(2))} border_color={{ top: new Srgba(1, 0, 0), right: new Srgba(0, 0, 1), bottom: new Srgba(1, 1, 0), left: new Srgba(0, 1, 0) }} />);
expect(out).toContain("border-color:rgba(255, 0, 0, 1) rgba(0, 0, 255, 1) rgba(255, 255, 0, 1) rgba(0, 255, 0, 1)");
diff --git a/sdk/raea/src/ui.ts b/sdk/raea/src/ui.ts
index 27a9bcb6..e97f58b2 100644
--- a/sdk/raea/src/ui.ts
+++ b/sdk/raea/src/ui.ts
@@ -7,3 +7,4 @@ export * from "@raea/video/region";
export * from "@raea/video/panel";
// bevy_ui's Node and Text, and bevy_text's TextSpan, with their values (Val, UiRect, BorderRadius, Overflow)
export { Node, Text, TextSpan, TextShadow, Text2d, UiScale, ImageNode, InlineImage, type TextureSlicer, type SliceScaleMode, ImagePlugin, FontVariationTag, TextureAtlasLayout, type ImageNodeProps, px, percent, vw, vh, vmin, vmax, auto, UiRect, BorderRadius, CornerRadius, Overflow, OverflowClipMargin, type NodeProps, type TextProps, type TextStyleProps, type TextRunProps, type Text2dProps, type Val } from "@raea/render/bevy3d";
+export { LinearGradient, RadialGradient, ConicGradient, ColorStop, AngularColorStop, UiPosition, type Gradient, type RadialGradientShape, type InterpolationColorSpace } from "@raea/render/bevy3d";
diff --git a/sdk/render/src/bevy3d.tsx b/sdk/render/src/bevy3d.tsx
index 94093dd6..117920ba 100644
--- a/sdk/render/src/bevy3d.tsx
+++ b/sdk/render/src/bevy3d.tsx
@@ -31,3 +31,4 @@ export { Lightmap, type LightmapProps } from "./bevy3d/lightmap";
export { Node, Text, TextSpan, TextShadow, Text2d, UiScale, FontVariationTag, type NodeProps, type TextProps, type TextStyleProps, type TextRunProps, type Text2dProps } from "./bevy3d/ui";
export { ImageNode, InlineImage, ImagePlugin, TextureAtlasLayout, type TextureSlicer, type SliceScaleMode, type ImageNodeProps } from "./bevy3d/ui-image";
export { px, percent, vw, vh, vmin, vmax, auto, UiRect, BorderRadius, CornerRadius, Overflow, OverflowClipMargin, type Val } from "./bevy3d/ui-val";
+export { LinearGradient, RadialGradient, ConicGradient, ColorStop, AngularColorStop, UiPosition, type Gradient, type RadialGradientShape, type InterpolationColorSpace } from "./bevy3d/ui-gradient";
diff --git a/sdk/render/src/bevy3d/ui-gradient.ts b/sdk/render/src/bevy3d/ui-gradient.ts
new file mode 100644
index 00000000..85a96b9e
--- /dev/null
+++ b/sdk/render/src/bevy3d/ui-gradient.ts
@@ -0,0 +1,144 @@
+// bevy_ui's gradients (BackgroundGradient: LinearGradient, RadialGradient, ConicGradient with their ColorStops) as the
+// page's CSS gradients, which raea's Blitz paints in the colour space each names (blitz-paint gradient.rs).
+import { checkVal, colorCss, type Val } from "./ui-val";
+import type { LinearRgba, Srgba } from "./colors";
+
+type Color = Srgba | LinearRgba | string;
+
+/** bevy_ui's ColorStop: a colour at `point` along the gradient (spaced evenly when left out, as CSS's), and `hint`, where
+ * between it and the next the colour is half way (0.5, linear, by default). @bevy bevy_ui::gradients::ColorStop */
+export interface ColorStop { color: Color; point?: Val; hint?: number }
+export const ColorStop = {
+ new: (color: Color, point: Val): ColorStop => ({ color, point }),
+ auto: (color: Color): ColorStop => ({ color }),
+};
+
+/** bevy_ui's AngularColorStop: a colour at `angle` radians round a conic gradient (spaced evenly when left out).
+ * @bevy bevy_ui::gradients::AngularColorStop */
+export interface AngularColorStop { color: Color; angle?: number; hint?: number }
+export const AngularColorStop = {
+ new: (color: Color, angle: number): AngularColorStop => ({ color, angle }),
+ auto: (color: Color): AngularColorStop => ({ color }),
+};
+
+/** bevy_ui's InterpolationColorSpace: Oklaba by default. @bevy bevy_ui::gradients::InterpolationColorSpace */
+export type InterpolationColorSpace = "Oklaba" | "Oklcha" | "OklchaLong" | "Srgba" | "LinearRgba" | "Hsla" | "HslaLong";
+const SPACE: Record<InterpolationColorSpace, string> = {
+ Oklaba: "in oklab", Oklcha: "in oklch", OklchaLong: "in oklch longer hue", Srgba: "in srgb", LinearRgba: "in srgb-linear", Hsla: "in hsl", HslaLong: "in hsl longer hue",
+};
+
+/** bevy_ui's UiPosition: a point of the node, `anchor` from its centre (each axis -0.5 to 0.5 of its size), moved `x`
+ * and `y` from there: right and down from a left, top or centre anchor, left and up from a right or bottom one.
+ * @bevy bevy_ui::UiPosition */
+export interface UiPosition {
+ anchor: [number, number]; x: Val; y: Val;
+ at(x: Val, y: Val): UiPosition; at_x(x: Val): UiPosition; at_y(y: Val): UiPosition;
+}
+const position = (anchor: [number, number], x: Val = "0px", y: Val = "0px"): UiPosition => ({
+ anchor, x, y,
+ at: (nx, ny) => position(anchor, nx, ny),
+ at_x: (nx) => position(anchor, nx, y),
+ at_y: (ny) => position(anchor, x, ny),
+});
+export const UiPosition = {
+ anchor: (anchor: [number, number]) => position(anchor),
+ CENTER: position([0, 0]), TOP: position([0, -0.5]), BOTTOM: position([0, 0.5]), LEFT: position([-0.5, 0]), RIGHT: position([0.5, 0]),
+ TOP_LEFT: position([-0.5, -0.5]), TOP_RIGHT: position([0.5, -0.5]), BOTTOM_LEFT: position([-0.5, 0.5]), BOTTOM_RIGHT: position([0.5, 0.5]),
+};
+
+/** bevy_ui's RadialGradientShape (ClosestCorner by default): Bevy's ClosestSide and FarthestSide are circles to the
+ * nearest or farthest side, its ClosestCorner and FarthestCorner ellipses through the nearest or farthest sides on each
+ * axis (CSS's closest-side and farthest-side ellipses), Circle a radius, Ellipse two. @bevy bevy_ui::gradients::RadialGradientShape */
+export type RadialGradientShape = "ClosestSide" | "FarthestSide" | "ClosestCorner" | "FarthestCorner" | { Circle: Val } | { Ellipse: [Val, Val] };
+
+/** One of bevy_ui's Gradients. @bevy bevy_ui::gradients::Gradient */
+export type Gradient =
+ | { kind: "Linear"; angle: number; stops: ColorStop[]; color_space?: InterpolationColorSpace }
+ | { kind: "Radial"; position: UiPosition; shape: RadialGradientShape; stops: ColorStop[]; color_space?: InterpolationColorSpace }
+ | { kind: "Conic"; start: number; position: UiPosition; stops: AngularColorStop[]; color_space?: InterpolationColorSpace };
+
+const TAU = 2 * Math.PI;
+const linear = (angle: number) => (stops: ColorStop[]): Gradient => ({ kind: "Linear", angle, stops });
+/** bevy_ui's LinearGradient: `angle` radians, 0 up and clockwise. @bevy bevy_ui::gradients::LinearGradient */
+export const LinearGradient = {
+ new: (angle: number, stops: ColorStop[], color_space?: InterpolationColorSpace): Gradient => ({ kind: "Linear", angle, stops, color_space }),
+ degrees: (degrees: number, stops: ColorStop[]): Gradient => ({ kind: "Linear", angle: (degrees * Math.PI) / 180, stops }),
+ to_top: linear(0), to_top_right: linear(TAU / 8), to_right: linear(TAU / 4), to_bottom_right: linear((3 * TAU) / 8),
+ to_bottom: linear(TAU / 2), to_bottom_left: linear((5 * TAU) / 8), to_left: linear((3 * TAU) / 4), to_top_left: linear((7 * TAU) / 8),
+};
+/** bevy_ui's RadialGradient: centred, ClosestCorner by default. @bevy bevy_ui::gradients::RadialGradient */
+export const RadialGradient = {
+ new: (position: UiPosition, shape: RadialGradientShape, stops: ColorStop[], color_space?: InterpolationColorSpace): Gradient => ({ kind: "Radial", position, shape, stops, color_space }),
+};
+/** bevy_ui's ConicGradient: from `start` radians (0 up, clockwise) round `position`. @bevy bevy_ui::gradients::ConicGradient */
+export const ConicGradient = {
+ new: (position: UiPosition, stops: AngularColorStop[], start = 0, color_space?: InterpolationColorSpace): Gradient => ({ kind: "Conic", start, position, stops, color_space }),
+};
+
+/** A UiPosition as CSS's: each axis from its anchor's edge or the centre, as UiPosition::resolve places it. */
+function positionCss(who: string, p: UiPosition): string {
+ if (!p || !Array.isArray(p.anchor)) throw new TypeError(`${who}: a gradient's position is a UiPosition (UiPosition.CENTER), got ${JSON.stringify(p)}`);
+ const axis = (a: number, v: Val, k: string) => {
+ if (!(Number.isFinite(a) && a >= -0.5 && a <= 0.5)) throw new RangeError(`${who}: a UiPosition's anchor is -0.5 to 0.5 on each axis, got ${a}`);
+ const off = checkVal(who, `position.${k}`, v === "auto" ? "0px" : v);
+ return `calc(${50 + a * 100}% ${a > 0 ? "-" : "+"} ${off})`;
+ };
+ return `${axis(p.anchor[0], p.x, "x")} ${axis(p.anchor[1], p.y, "y")}`;
+}
+
+/** Stops as CSS's: each colour at its point, and a hint other than half way as CSS's midpoint between two points. */
+function stopsCss(who: string, stops: (ColorStop | AngularColorStop)[], at: (s: ColorStop | AngularColorStop) => string | undefined): string {
+ if (!Array.isArray(stops) || stops.length === 0) throw new TypeError(`${who}: a gradient has stops, got ${JSON.stringify(stops)}`);
+ const out: string[] = [];
+ stops.forEach((s, i) => {
+ const p = at(s);
+ out.push(p === undefined ? colorCss(who, "stop", s.color) : `${colorCss(who, "stop", s.color)} ${p}`);
+ const h = s.hint ?? 0.5;
+ if (i + 1 < stops.length && h !== 0.5) {
+ const q = at(stops[i + 1]);
+ if (!(Number.isFinite(h) && h > 0 && h < 1) || p === undefined || q === undefined) throw new TypeError(`${who}: a stop's hint is above 0 and below 1, between two stops with points, got ${h}`);
+ out.push(`calc(${p} + (${q} - ${p}) * ${h})`);
+ }
+ });
+ return out.join(", ");
+}
+
+const space = (who: string, g: { color_space?: InterpolationColorSpace }) => {
+ const s = SPACE[g.color_space ?? "Oklaba"];
+ if (!s) throw new TypeError(`${who}: color_space is one of ${Object.keys(SPACE).join(", ")}, got ${JSON.stringify(g.color_space)}`);
+ return s;
+};
+
+function shapeCss(who: string, s: RadialGradientShape): string {
+ if (s === "ClosestSide") return "circle closest-side";
+ if (s === "FarthestSide") return "circle farthest-side";
+ if (s === "ClosestCorner") return "ellipse closest-side";
+ if (s === "FarthestCorner") return "ellipse farthest-side";
+ if (typeof s === "object" && s && "Circle" in s) {
+ const r = checkVal(who, "shape.Circle", s.Circle);
+ if (r.endsWith("%")) throw new TypeError(`${who}: a Circle's radius in percent (of the node's width) is to do; give px, vw or vh`);
+ return `circle ${r}`;
+ }
+ if (typeof s === "object" && s && "Ellipse" in s) return `ellipse ${checkVal(who, "shape.Ellipse", s.Ellipse[0])} ${checkVal(who, "shape.Ellipse", s.Ellipse[1])}`;
+ throw new TypeError(`${who}: shape is a RadialGradientShape, got ${JSON.stringify(s)}`);
+}
+
+/** One gradient as CSS's. */
+function gradientCss(who: string, g: Gradient): string {
+ if (g?.kind === "Linear") {
+ if (!Number.isFinite(g.angle)) throw new TypeError(`${who}: a LinearGradient's angle is radians, got ${g.angle}`);
+ return `linear-gradient(${g.angle}rad ${space(who, g)}, ${stopsCss(who, g.stops, (s) => (s as ColorStop).point && checkVal(who, "stop.point", (s as ColorStop).point))})`;
+ }
+ if (g?.kind === "Radial") return `radial-gradient(${shapeCss(who, g.shape)} at ${positionCss(who, g.position)} ${space(who, g)}, ${stopsCss(who, g.stops, (s) => (s as ColorStop).point && checkVal(who, "stop.point", (s as ColorStop).point))})`;
+ if (g?.kind === "Conic") {
+ if (!Number.isFinite(g.start)) throw new TypeError(`${who}: a ConicGradient's start is radians, got ${g.start}`);
+ return `conic-gradient(from ${g.start}rad at ${positionCss(who, g.position)} ${space(who, g)}, ${stopsCss(who, g.stops, (s) => ((s as AngularColorStop).angle === undefined ? undefined : `${(s as AngularColorStop).angle}rad`))})`;
+ }
+ throw new TypeError(`${who}: a gradient is a LinearGradient, RadialGradient or ConicGradient, got ${JSON.stringify(g)}`);
+}
+
+/** BackgroundGradient as CSS background images: Bevy draws the list's first at the bottom, CSS its last. */
+export function gradientsCss(who: string, gs: Gradient[]): string {
+ if (!Array.isArray(gs)) throw new TypeError(`${who}: background_gradient is a list of gradients, got ${JSON.stringify(gs)}`);
+ return gs.map((g) => gradientCss(who, g)).reverse().join(", ");
+}
diff --git a/sdk/render/src/bevy3d/ui.tsx b/sdk/render/src/bevy3d/ui.tsx
index 0de72c2d..982e1156 100644
--- a/sdk/render/src/bevy3d/ui.tsx
+++ b/sdk/render/src/bevy3d/ui.tsx
@@ -10,6 +10,7 @@ import {
checkVal, keyword, over, radiusCss, rectCss, type Backdrop, type BorderRadius, type Overflow, type OverflowClipMargin, type UiRect, type Val,
} from "./ui-val";
import { LinearRgba, type Srgba } from "./colors";
+import { gradientsCss, type Gradient } from "./ui-gradient";
import type { TransformValue } from "./core";
import { eulerOf } from "../3d/model";
import { useVideoConfig } from "@raea/app/clock";
@@ -41,6 +42,8 @@ export interface NodeProps {
overflow_clip_margin?: OverflowClipMargin;
row_gap?: Val; column_gap?: Val;
background_color?: Color;
+ /** BackgroundGradient: gradients over the background colour, the first at the bottom, over the whole node */
+ background_gradient?: Gradient[];
/** BorderColor: every side one colour, or each its own ({ top, right, bottom, left }) */
border_color?: Color | { top: Color; right: Color; bottom: Color; left: Color };
/** Outline: a line outside the border box, `offset` from it (0 by default), white by default */
@@ -113,6 +116,11 @@ export function nodeCss(who: string, p: NodeProps, back?: Backdrop): { css: CSSP
if (p.outline.offset !== undefined) s.outlineOffset = checkVal(who, "outline.offset", p.outline.offset);
}
if (p.background_color !== undefined) ({ css: s.backgroundColor, back } = over(who, "background_color", p.background_color, back));
+ if (p.background_gradient !== undefined) {
+ s.backgroundImage = gradientsCss(who, p.background_gradient);
+ s.backgroundOrigin = "border-box";
+ back = undefined;
+ }
// (the border over its own background, as Bevy draws it)
const bc = p.border_color;
if (bc !== undefined && typeof bc === "object" && "top" in bc) {
@@ -143,7 +151,8 @@ export function boxOf(css: CSSProperties, back: Backdrop, children: ReactNode, r
<InUi.Provider value={{ back }}>{children}</InUi.Provider>
</div>
);
- return root ? <div style={root === "fixed" ? { ...VIEWPORT, position: "fixed" } : VIEWPORT}>{font}{inner}</div> : <>{font}{inner}</>;
+ // data-raea-blend: a page with bevy_ui in it blends in linear light, as Bevy's UI does (raea-page's paint)
+ return root ? <div style={root === "fixed" ? { ...VIEWPORT, position: "fixed" } : VIEWPORT} data-raea-blend="linear">{font}{inner}</div> : <>{font}{inner}</>;
}
/** A box of Bevy's UI, laid out as bevy_ui lays it (taffy, with Bevy's defaults). Put it over the 3D in an
diff --git a/systems/page/src/draw.rs b/systems/page/src/draw.rs
index 9f43e2b4..b2b7a61c 100644
--- a/systems/page/src/draw.rs
+++ b/systems/page/src/draw.rs
@@ -253,12 +253,14 @@ pub fn draw(mut scenes: ResMut<Scenes>, mut vello: NonSendMut<Vello>, device: Re
}
let passes = passes.get_or_insert_with(|| raea_sys_filters::Passes::new(device));
let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: Some("raea-page premul") });
- for &(ref handle, px, ref scene, ref layers, print, straight) in &todo {
+ for &(ref handle, px, ref scene, ref layers, print, straight, linear) in &todo {
let Some(gpu) = images.get(handle) else { continue };
if !views && !REDRAW_FULL.load(std::sync::atomic::Ordering::Relaxed) && prints.get(&handle.id()) == Some(&print) {
continue;
}
prints.insert(handle.id(), print);
+ // a bevy_ui page's renders (its layers' and its own) blend in linear light (vendor/vello_shaders fine.wgsl)
+ vello::low_level::vello_encoding::set_blend_linear(linear);
// each filtered layer drawn by Vello, filtered, and handed to Vello as its placeholder's pixels, an inner
// layer before the one that holds it (its own render then copies it in)
for (i, layer) in layers.iter().enumerate() {
@@ -347,6 +349,7 @@ pub fn draw(mut scenes: ResMut<Scenes>, mut vello: NonSendMut<Vello>, device: Re
pass.draw(0..3, 0..1);
}
queue.submit([encoder.finish()]);
+ vello::low_level::vello_encoding::set_blend_linear(false);
passes.recycle();
// the scenes given back for paint to reuse (ZeroHeap)
let mut spare = SPARE.lock().unwrap();
diff --git a/systems/page/src/lib.rs b/systems/page/src/lib.rs
index c22d831e..d1ce5c14 100644
--- a/systems/page/src/lib.rs
+++ b/systems/page/src/lib.rs
@@ -137,8 +137,9 @@ impl Times {
pub struct Painted(pub Arc<Mutex<Vec<Drawn>>>);
/// A page's paint: its image, its size in device px, its scene, its filtered layers (inner ones first), its print
-/// (`raea_sys_filters::Painter::print`: the same as last frame's, the same picture) and whether its image is straight alpha.
-pub type Drawn = (Handle<Image>, UVec2, vello::Scene, Vec<raea_sys_filters::Filtered>, u64, bool);
+/// (`raea_sys_filters::Painter::print`: the same as last frame's, the same picture), whether its image is straight alpha,
+/// and whether it blends in linear light (a bevy_ui page, `data-raea-blend="linear"`: Vello's set_blend_linear).
+pub type Drawn = (Handle<Image>, UVec2, vello::Scene, Vec<raea_sys_filters::Filtered>, u64, bool, bool);
/// Each page restyled and laid out (what changed).
pub fn resolve(mut docs: NonSendMut<Docs>, pages: Query<(Entity, &Page)>, time: Res<Time>, clock: Res<PageClock>, mut scanned: Local<HashMap<Entity, usize>>) {
@@ -188,7 +189,10 @@ pub fn paint(mut docs: NonSendMut<Docs>, pages: Query<(Entity, &Page, &PageImage
blitz_paint::paint_scene(&mut painter, doc, page.scale as f64, px.x, px.y, 0, 0);
let (layers, print) = (std::mem::take(&mut painter.layers), painter.print());
TIMES.add_encode(t1.elapsed());
- out.push((image.0.clone(), px, scene, layers, print, straight));
+ // a page with a bevy_ui node (sdk/render bevy3d/ui.tsx marks each root Node) blends in linear light, as
+ // Bevy's UI does on its sRGB target; the rest blend the encoded values, as Chrome does
+ let linear = doc.query_selector("[data-raea-blend=linear]").ok().flatten().is_some();
+ out.push((image.0.clone(), px, scene, layers, print ^ ((linear as u64) << 63), straight, linear));
}
*painted.0.lock().unwrap() = out;
commands.insert_resource(painted.clone());
diff --git a/vendor/vello_encoding/src/config.rs b/vendor/vello_encoding/src/config.rs
index b7d16b4f..2c3a2cff 100644
--- a/vendor/vello_encoding/src/config.rs
+++ b/vendor/vello_encoding/src/config.rs
@@ -151,6 +151,8 @@ pub struct ConfigUniform {
pub blend_size: u32,
/// Size of per-tile command list buffer allocation (in `u32`s).
pub ptcl_size: u32,
+ /// raea: 1 when the fine stage blends in linear light (set_blend_linear), 0 to blend the sRGB-encoded values
+ pub blend_linear: u32,
}
/// CPU side setup and configuration.
@@ -188,6 +190,7 @@ impl RenderConfig {
segments_size: buffer_sizes.segments.len(),
blend_size: buffer_sizes.blend_spill.len(),
ptcl_size: buffer_sizes.ptcl.len(),
+ blend_linear: BLEND_LINEAR.load(std::sync::atomic::Ordering::Relaxed) as u32,
layout: *layout,
},
workgroup_counts,
@@ -548,3 +551,11 @@ mod tests {
assert_eq!(grown(PAGE, tiles(3840, 2160)).ptcl, 2_073_600 + (2_097_152.0f64 * 32400.0 / 8160.0).ceil() as u32);
}
}
+
+static BLEND_LINEAR: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
+
+/// raea: the renders from now on blend in linear light (true), as bevy_ui does on an sRGB target, or the sRGB-encoded
+/// values (false, Vello's own and Chrome's way); vendor/vello_shaders fine.wgsl reads it as `config.blend_linear`.
+pub fn set_blend_linear(on: bool) {
+ BLEND_LINEAR.store(on, std::sync::atomic::Ordering::Relaxed);
+}
diff --git a/vendor/vello_encoding/src/lib.rs b/vendor/vello_encoding/src/lib.rs
index 66a6fc05..ab18a556 100644
--- a/vendor/vello_encoding/src/lib.rs
+++ b/vendor/vello_encoding/src/lib.rs
@@ -52,7 +52,7 @@ pub use binning::BinHeader;
pub use clip::{Clip, ClipBbox, ClipBic, ClipElement};
pub use config::{
BufferSize, BufferSizes, BumpAllocationSizes, BumpAllocatorMemory, BumpAllocators, ConfigUniform, IndirectCount,
- PTCL_INITIAL_ALLOC, RenderConfig, WorkgroupCounts, WorkgroupSize, bump_sizes_for, set_bump_allocation_sizes, set_bump_full,
+ PTCL_INITIAL_ALLOC, RenderConfig, WorkgroupCounts, WorkgroupSize, bump_sizes_for, set_bump_allocation_sizes, set_bump_full, set_blend_linear,
};
pub use draw::{
DRAW_INFO_FLAGS_FILL_RULE_BIT, DrawBbox, DrawBeginClip, DrawBlurRoundedRect, DrawColor,
diff --git a/vendor/vello_shaders/Cargo.toml b/vendor/vello_shaders/Cargo.toml
new file mode 100644
index 00000000..16b69854
--- /dev/null
+++ b/vendor/vello_shaders/Cargo.toml
@@ -0,0 +1,148 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies.
+#
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
+
+[package]
+edition = "2024"
+rust-version = "1.89"
+name = "vello_shaders"
+version = "0.11.0"
+build = "build.rs"
+autolib = false
+autobins = false
+autoexamples = false
+autotests = false
+autobenches = false
+description = "Vello infrastructure to preprocess and cross-compile shaders at compile time."
+readme = "README.md"
+keywords = [
+ "2d",
+ "vector-graphics",
+]
+categories = [
+ "rendering",
+ "graphics",
+]
+license = "Apache-2.0 OR MIT"
+repository = "https://github.com/linebender/vello"
+resolver = "2"
+
+[package.metadata.docs.rs]
+all-features = true
+default-target = "x86_64-unknown-linux-gnu"
+targets = []
+
+[features]
+compile = [
+ "dep:naga",
+ "dep:thiserror",
+ "dep:log",
+]
+cpu = [
+ "dep:bytemuck",
+ "dep:vello_encoding",
+]
+default = [
+ "wgsl",
+ "cpu",
+]
+msl = ["naga?/msl-out"]
+wgsl = []
+
+[lib]
+name = "vello_shaders"
+path = "src/lib.rs"
+
+[dependencies.bytemuck]
+version = "1.25.0"
+features = ["derive"]
+optional = true
+
+[dependencies.log]
+version = "0.4.29"
+optional = true
+
+[dependencies.naga]
+version = "30.0.0"
+features = ["wgsl-in"]
+optional = true
+default-features = false
+
+[dependencies.thiserror]
+version = "2.0.18"
+optional = true
+default-features = false
+
+[dependencies.vello_encoding]
+version = "0.11.0"
+optional = true
+
+[build-dependencies.log]
+version = "0.4.29"
+
+[build-dependencies.naga]
+version = "30.0.0"
+features = ["wgsl-in"]
+default-features = false
+
+[build-dependencies.thiserror]
+version = "2.0.18"
+default-features = false
+
+[lints.clippy]
+allow_attributes_without_reason = "warn"
+cargo_common_metadata = "warn"
+cast_possible_truncation = "warn"
+collection_is_never_read = "warn"
+dbg_macro = "warn"
+debug_assert_with_mut_call = "warn"
+default_trait_access = "warn"
+doc_markdown = "warn"
+fn_to_numeric_cast_any = "warn"
+infinite_loop = "warn"
+large_stack_arrays = "warn"
+mismatching_type_param_order = "warn"
+missing_assert_message = "warn"
+missing_fields_in_debug = "warn"
+negative_feature_names = "warn"
+redundant_feature_names = "warn"
+same_functions_in_if_condition = "warn"
+semicolon_if_nothing_returned = "warn"
+should_panic_without_expect = "warn"
+todo = "warn"
+too_many_arguments = "allow"
+unseparated_literal_suffix = "warn"
+use_self = "warn"
+wildcard_dependencies = "warn"
+
+[lints.rust]
+elided_lifetimes_in_paths = "warn"
+keyword_idents_2024 = "forbid"
+missing_debug_implementations = "warn"
+missing_docs = "warn"
+non_ascii_idents = "forbid"
+non_local_definitions = "forbid"
+trivial_numeric_casts = "warn"
+unnameable_types = "warn"
+unreachable_pub = "warn"
+unsafe_op_in_unsafe_fn = "forbid"
+unused_import_braces = "warn"
+unused_lifetimes = "warn"
+unused_macro_rules = "warn"
+unused_qualifications = "warn"
+
+[lints.rust.unexpected_cfgs]
+level = "warn"
+priority = 0
+check-cfg = [
+ "cfg(disable_dispatch_sse4_2)",
+ "cfg(disable_dispatch_avx2)",
+ "cfg(disable_dispatch_avx512)",
+]
diff --git a/vendor/vello_shaders/Cargo.toml.orig b/vendor/vello_shaders/Cargo.toml.orig
new file mode 100644
index 00000000..e2cbe23a
--- /dev/null
+++ b/vendor/vello_shaders/Cargo.toml.orig
@@ -0,0 +1,42 @@
+[package]
+name = "vello_shaders"
+version.workspace = true # We mimic Vello's version
+description = "Vello infrastructure to preprocess and cross-compile shaders at compile time."
+categories = ["rendering", "graphics"]
+keywords = ["2d", "vector-graphics"]
+edition.workspace = true
+rust-version.workspace = true
+license.workspace = true
+repository.workspace = true
+
+[package.metadata.docs.rs]
+all-features = true
+# There are no platform specific docs.
+default-target = "x86_64-unknown-linux-gnu"
+targets = []
+
+[features]
+default = ["wgsl", "cpu"]
+compile = ["dep:naga", "dep:thiserror", "dep:log"]
+
+# Target shading language variants of the vello shaders to link into the library.
+wgsl = []
+msl = ["naga?/msl-out"]
+
+# Enable the CPU versions of the shaders
+cpu = ["dep:bytemuck", "dep:vello_encoding"]
+
+[lints]
+workspace = true
+
+[dependencies]
+bytemuck = { workspace = true, optional = true }
+naga = { workspace = true, features = ["wgsl-in"], optional = true }
+thiserror = { workspace = true, optional = true }
+vello_encoding = { workspace = true, optional = true }
+log = { workspace = true, optional = true }
+
+[build-dependencies]
+naga = { workspace = true, features = ["wgsl-in"] }
+thiserror = { workspace = true }
+log = { workspace = true }
diff --git a/vendor/vello_shaders/LICENSE-APACHE b/vendor/vello_shaders/LICENSE-APACHE
new file mode 100644
index 00000000..d9a10c0d
--- /dev/null
+++ b/vendor/vello_shaders/LICENSE-APACHE
@@ -0,0 +1,176 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/vendor/vello_shaders/LICENSE-MIT b/vendor/vello_shaders/LICENSE-MIT
new file mode 100644
index 00000000..48ff8e41
--- /dev/null
+++ b/vendor/vello_shaders/LICENSE-MIT
@@ -0,0 +1,25 @@
+Copyright 2020 the Vello Authors
+
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without
+limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/vendor/vello_shaders/README.md b/vendor/vello_shaders/README.md
new file mode 100644
index 00000000..6d38003d
--- /dev/null
+++ b/vendor/vello_shaders/README.md
@@ -0,0 +1,84 @@
+<div align="center">
+
+# Vello Shaders
+
+**Integrate [Vello] shaders into any renderer project**
+
+[![Latest published version.](https://img.shields.io/crates/v/vello_shaders.svg)](https://crates.io/crates/vello_shaders)
+[![Documentation build status.](https://img.shields.io/docsrs/vello_shaders.svg)](https://docs.rs/vello_shaders)
+[![Apache 2.0 or MIT license.](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue.svg)](#license)
+\
+[![Linebender Zulip chat.](https://img.shields.io/badge/Linebender-%23vello-blue?logo=Zulip)](https://xi.zulipchat.com/#narrow/channel/197075-vello) [![GitHub Actions CI status.](https://img.shields.io/github/actions/workflow/status/linebender/vello/ci.yml?logo=github&label=CI)](https://github.com/linebender/vello/actions)
+[![Dependency staleness status.](https://deps.rs/crate/vello_shaders/latest/status.svg)](https://deps.rs/crate/vello_shaders)
+
+</div>
+
+This is a utility library to help integrate the [Vello] shader modules into any
+renderer project. It provides the necessary metadata to construct the individual
+compute pipelines on any GPU API while leaving the responsibility of all API
+interactions (such as resource management and command encoding) up to the
+client.
+
+The shaders can be pre-compiled to any target shading language at build time
+based on feature flags. Currently only WGSL and Metal Shading Language are
+supported.
+
+Significant changes are documented in [the changelog].
+
+## Minimum supported Rust Version (MSRV)
+
+This version of Vello Shaders has been verified to compile with **Rust 1.89**
+and later.
+
+Future versions of Vello Shaders might increase the Rust version requirement. It
+will not be treated as a breaking change and as such can even happen with small
+patch releases.
+
+<details>
+<summary>Click here if compiling fails.</summary>
+
+As time has passed, some of Vello Shaders' dependencies could have released
+versions with a higher Rust requirement. If you encounter a compilation issue
+due to a dependency and don't want to upgrade your Rust toolchain, then you
+could downgrade the dependency.
+
+```sh
+# Use the problematic dependency's name and version
+cargo update -p package_name --precise 0.1.1
+```
+
+</details>
+
+## Community
+
+Discussion of Vello Shaders development happens in the
+[Linebender Zulip](https://xi.zulipchat.com/), specifically the
+[#vello channel](https://xi.zulipchat.com/#narrow/channel/197075-vello). All
+public content can be read without logging in.
+
+Contributions are welcome by pull request. The [Rust code of conduct] applies.
+
+## License
+
+Licensed under either of
+
+- Apache License, Version 2.0 ([LICENSE-APACHE](../../LICENSE-APACHE) or
+ <http://www.apache.org/licenses/LICENSE-2.0>)
+- MIT license ([LICENSE-MIT](../../LICENSE-MIT) or
+ <http://opensource.org/licenses/MIT>)
+
+at your option.
+
+In addition, all files in the
+[`shader`](https://github.com/linebender/vello/tree/main/research/vello_shaders/shader)
+and
+[`src/cpu`](https://github.com/linebender/vello/tree/main/research/vello_shaders/src/cpu)
+directories and subdirectories thereof are alternatively licensed under the
+Unlicense ([shader/UNLICENSE](shader/UNLICENSE) or <http://unlicense.org/>). For
+clarity, these files are also licensed under either of the above licenses. The
+intent is for this research to be used in as broad a context as possible.
+
+[Rust code of conduct]: https://www.rust-lang.org/policies/code-of-conduct
+[Vello]: ../vello_research
+[the changelog]:
+ https://github.com/linebender/vello/tree/main/research/CHANGELOG.md
diff --git a/vendor/vello_shaders/build.rs b/vendor/vello_shaders/build.rs
new file mode 100644
index 00000000..c029ede1
--- /dev/null
+++ b/vendor/vello_shaders/build.rs
@@ -0,0 +1,206 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+
+//! Build step.
+
+// These modules are also included in the main crate, where the items are reachable
+#[allow(warnings, reason = "Checked elsewhere")]
+#[path = "src/compile/mod.rs"]
+mod compile;
+#[allow(warnings, reason = "Checked elsewhere")]
+#[path = "src/types.rs"]
+mod types;
+
+use std::env;
+use std::fmt::{self, Write as _};
+use std::path::Path;
+
+use compile::ShaderInfo;
+
+fn main() {
+ log::set_logger(&BUILD_SCRIPT_LOGGER).unwrap();
+ log::set_max_level(log::LevelFilter::Info);
+ let out_dir = env::var_os("OUT_DIR").unwrap();
+ let dest_path = Path::new(&out_dir).join("shaders.rs");
+
+ println!("cargo:rerun-if-changed={}", compile::shader_dir().display());
+
+ let mut shaders = match ShaderInfo::from_default() {
+ Ok(s) => s,
+ Err(err) => {
+ let mut target = String::new();
+ // Ideally, we'd write into stdout directly here, but the duck-typing of `write!`
+ // makes that a bit annoying - we'd have to implement `CargoWarningAdapter` for both `io::Write` and `fmt::Write`
+ writeln!(CargoWarningAdapter::new(&mut target), "{err}").unwrap();
+ print!("{target}");
+ return;
+ }
+ };
+
+ // Drop the HashMap and sort by name so that we get deterministic order.
+ let mut shaders = shaders.drain().collect::<Vec<_>>();
+ shaders.sort_by(|x, y| x.0.cmp(&y.0));
+ let mut buf = String::default();
+ write_types(&mut buf, &shaders).unwrap();
+ write_shaders(&mut buf, &shaders).unwrap();
+ std::fs::write(dest_path, &buf).unwrap();
+}
+
+fn write_types(buf: &mut String, shaders: &[(String, ShaderInfo)]) -> Result<(), fmt::Error> {
+ writeln!(buf, "pub struct Shaders<'a> {{")?;
+ for (name, _) in shaders {
+ writeln!(buf, " pub {name}: ComputeShader<'a>,")?;
+ }
+ writeln!(buf, "}}")?;
+ Ok(())
+}
+
+fn write_shaders(buf: &mut String, shaders: &[(String, ShaderInfo)]) -> Result<(), fmt::Error> {
+ writeln!(buf, "mod generated {{")?;
+ writeln!(buf, " use super::*;")?;
+ writeln!(buf, " use BindType::*;")?;
+ writeln!(buf, " pub const SHADERS: Shaders<'static> = Shaders {{")?;
+ for (name, info) in shaders {
+ let bind_tys = info
+ .bindings
+ .iter()
+ .map(|binding| binding.ty)
+ .collect::<Vec<_>>();
+ let wg_bufs = &info.workgroup_buffers;
+ writeln!(buf, " {name}: ComputeShader {{")?;
+ writeln!(buf, " name: Cow::Borrowed({name:?}),")?;
+ writeln!(
+ buf,
+ " workgroup_size: {:?},",
+ info.workgroup_size
+ )?;
+ writeln!(buf, " bindings: Cow::Borrowed(&{bind_tys:?}),")?;
+ writeln!(
+ buf,
+ " workgroup_buffers: Cow::Borrowed(&{wg_bufs:?}),"
+ )?;
+ if cfg!(feature = "wgsl") {
+ let indices = info
+ .bindings
+ .iter()
+ .map(|binding| binding.location.1)
+ .collect::<Vec<_>>();
+ writeln!(buf, " wgsl: WgslSource {{")?;
+ writeln!(
+ buf,
+ " code: Cow::Borrowed({:?}),",
+ info.source
+ )?;
+ writeln!(
+ buf,
+ " binding_indices : Cow::Borrowed(&{indices:?}),"
+ )?;
+ writeln!(buf, " }},")?;
+ }
+ if cfg!(feature = "msl") {
+ write_msl(buf, info)?;
+ }
+ writeln!(buf, " }},")?;
+ }
+ writeln!(buf, " }};")?;
+ writeln!(buf, "}}")?;
+ Ok(())
+}
+
+#[cfg(not(feature = "msl"))]
+fn write_msl(_: &mut String, _: &ShaderInfo) -> Result<(), fmt::Error> {
+ Ok(())
+}
+
+#[cfg(feature = "msl")]
+fn write_msl(buf: &mut String, info: &ShaderInfo) -> Result<(), fmt::Error> {
+ let mut index_iter = compile::msl::BindingIndexIterator::default();
+ let indices = info
+ .bindings
+ .iter()
+ .map(|binding| index_iter.next(binding.ty))
+ .collect::<Vec<_>>();
+ writeln!(buf, " msl: MslSource {{")?;
+ writeln!(
+ buf,
+ " code: Cow::Borrowed({:?}),",
+ compile::msl::translate(info).unwrap()
+ )?;
+ writeln!(
+ buf,
+ " binding_indices : Cow::Borrowed(&{indices:?}),",
+ )?;
+ writeln!(buf, " }},")?;
+ Ok(())
+}
+
+/// A very simple logger for build scripts, which ensures that warnings and above
+/// are visible to the user.
+///
+/// We don't use an external crate here to keep build times down.
+struct BuildScriptLog;
+
+static BUILD_SCRIPT_LOGGER: BuildScriptLog = BuildScriptLog;
+
+impl log::Log for BuildScriptLog {
+ fn enabled(&self, _: &log::Metadata<'_>) -> bool {
+ true
+ }
+
+ fn log(&self, record: &log::Record<'_>) {
+ // "more serious" levels are lower
+ if record.level() <= log::Level::Warn {
+ let mut target = String::new();
+ write!(
+ CargoWarningAdapter::new(&mut target),
+ "{}: {}",
+ record.level(),
+ record.args()
+ )
+ .unwrap();
+ println!("{target}");
+ } else {
+ // If the user wants more verbose output from the build script, they would pass
+ // `-vv` to `cargo build`. In that case, we should provide all of the logs that
+ // people chose to provide.
+ // TODO: Maybe this should fall back to `env_logger`?
+ eprintln!("{}: {}", record.level(), record.args());
+ }
+ }
+
+ fn flush(&self) {
+ // Nothing to do; we use `println` which is "self-flushing"
+ }
+}
+
+/// An adapter for `fmt::Write` which prepends `cargo:warning=` to each line, ensuring that every
+/// output line is shown to build script users.
+struct CargoWarningAdapter<W: fmt::Write> {
+ writer: W,
+ needs_warning: bool,
+}
+
+impl<W: fmt::Write> CargoWarningAdapter<W> {
+ fn new(writer: W) -> Self {
+ Self {
+ writer,
+ needs_warning: true,
+ }
+ }
+}
+
+impl<W: fmt::Write> fmt::Write for CargoWarningAdapter<W> {
+ fn write_str(&mut self, s: &str) -> fmt::Result {
+ for line in s.split_inclusive('\n') {
+ if self.needs_warning {
+ write!(&mut self.writer, "cargo:warning=")?;
+ self.needs_warning = false;
+ }
+ write!(&mut self.writer, "{line}")?;
+ if line.ends_with('\n') {
+ self.needs_warning = true;
+ }
+ }
+ Ok(())
+ }
+}
diff --git a/vendor/vello_shaders/shader/UNLICENSE b/vendor/vello_shaders/shader/UNLICENSE
new file mode 100644
index 00000000..68a49daa
--- /dev/null
+++ b/vendor/vello_shaders/shader/UNLICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
diff --git a/vendor/vello_shaders/shader/backdrop.wgsl b/vendor/vello_shaders/shader/backdrop.wgsl
new file mode 100644
index 00000000..79f4a103
--- /dev/null
+++ b/vendor/vello_shaders/shader/backdrop.wgsl
@@ -0,0 +1,48 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Note: this is the non-atomic version
+struct Tile {
+ backdrop: i32,
+ segments: u32,
+}
+
+#import config
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage, read_write> tiles: array<Tile>;
+
+const WG_SIZE = 64u;
+
+var<workgroup> sh_backdrop: array<i32, WG_SIZE>;
+
+// Each workgroup computes the inclusive prefix sum of the backdrops
+// in one row of tiles.
+@compute @workgroup_size(64)
+fn main(
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+ @builtin(workgroup_id) wg_id: vec3<u32>,
+) {
+ let width_in_tiles = config.width_in_tiles;
+ let ix = wg_id.x * width_in_tiles + local_id.x;
+ var backdrop = 0;
+ if local_id.x < width_in_tiles {
+ backdrop = tiles[ix].backdrop;
+ }
+ sh_backdrop[local_id.x] = backdrop;
+ // iterate log2(WG_SIZE) times
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ workgroupBarrier();
+ if local_id.x >= (1u << i) {
+ backdrop += sh_backdrop[local_id.x - (1u << i)];
+ }
+ workgroupBarrier();
+ sh_backdrop[local_id.x] = backdrop;
+ }
+ if local_id.x < width_in_tiles {
+ tiles[ix].backdrop = backdrop;
+ }
+}
diff --git a/vendor/vello_shaders/shader/backdrop_dyn.wgsl b/vendor/vello_shaders/shader/backdrop_dyn.wgsl
new file mode 100644
index 00000000..69ecaf7f
--- /dev/null
+++ b/vendor/vello_shaders/shader/backdrop_dyn.wgsl
@@ -0,0 +1,86 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Prefix sum for dynamically allocated backdrops
+
+#import bump
+#import config
+#import tile
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage, read_write> bump: BumpAllocators;
+
+@group(0) @binding(2)
+var<storage> paths: array<Path>;
+
+@group(0) @binding(3)
+var<storage, read_write> tiles: array<Tile>;
+
+const WG_SIZE = 256u;
+
+var<workgroup> sh_row_width: array<u32, WG_SIZE>;
+var<workgroup> sh_row_count: array<u32, WG_SIZE>;
+var<workgroup> sh_offset: array<u32, WG_SIZE>;
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+) {
+ // Abort if any of the prior stages failed.
+ if local_id.x == 0u {
+ sh_row_count[0] = atomicLoad(&bump.failed);
+ }
+ let failed = workgroupUniformLoad(&sh_row_count[0]);
+ if failed != 0u {
+ return;
+ }
+ let drawobj_ix = global_id.x;
+ var row_count = 0u;
+ if drawobj_ix < config.n_drawobj {
+ // TODO: when rectangles, path and draw obj are not the same
+ let path = paths[drawobj_ix];
+ sh_row_width[local_id.x] = path.bbox.z - path.bbox.x;
+ row_count = path.bbox.w - path.bbox.y;
+ sh_offset[local_id.x] = path.tiles;
+ } else {
+ // Explicitly zero the row width, just in case.
+ sh_row_width[local_id.x] = 0u;
+ }
+ sh_row_count[local_id.x] = row_count;
+
+ // Prefix sum of row counts
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ workgroupBarrier();
+ if local_id.x >= (1u << i) {
+ row_count += sh_row_count[local_id.x - (1u << i)];
+ }
+ workgroupBarrier();
+ sh_row_count[local_id.x] = row_count;
+ }
+ workgroupBarrier();
+ let total_rows = sh_row_count[WG_SIZE - 1u];
+ for (var row = local_id.x; row < total_rows; row += WG_SIZE) {
+ var el_ix = 0u;
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ let probe = el_ix + ((WG_SIZE / 2u) >> i);
+ if row >= sh_row_count[probe - 1u] {
+ el_ix = probe;
+ }
+ }
+ let width = sh_row_width[el_ix];
+ if width > 0u {
+ var seq_ix = row - select(0u, sh_row_count[el_ix - 1u], el_ix > 0u);
+ var tile_ix = sh_offset[el_ix] + seq_ix * width;
+ var sum = tiles[tile_ix].backdrop;
+ for (var x = 1u; x < width; x += 1u) {
+ tile_ix += 1u;
+ sum += tiles[tile_ix].backdrop;
+ tiles[tile_ix].backdrop = sum;
+ }
+ }
+ }
+}
diff --git a/vendor/vello_shaders/shader/bbox_clear.wgsl b/vendor/vello_shaders/shader/bbox_clear.wgsl
new file mode 100644
index 00000000..067d7c2d
--- /dev/null
+++ b/vendor/vello_shaders/shader/bbox_clear.wgsl
@@ -0,0 +1,24 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+#import config
+#import bbox
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage, read_write> path_bboxes: array<PathBbox>;
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+) {
+ let ix = global_id.x;
+ if ix < config.n_path {
+ path_bboxes[ix].x0 = 0x7fffffff;
+ path_bboxes[ix].y0 = 0x7fffffff;
+ path_bboxes[ix].x1 = -0x80000000;
+ path_bboxes[ix].y1 = -0x80000000;
+ }
+}
diff --git a/vendor/vello_shaders/shader/binning.wgsl b/vendor/vello_shaders/shader/binning.wgsl
new file mode 100644
index 00000000..c5019226
--- /dev/null
+++ b/vendor/vello_shaders/shader/binning.wgsl
@@ -0,0 +1,203 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// The binning stage
+
+#import config
+#import drawtag
+#import bbox
+#import bump
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage> draw_monoids: array<DrawMonoid>;
+
+@group(0) @binding(2)
+var<storage> path_bbox_buf: array<PathBbox>;
+
+@group(0) @binding(3)
+var<storage> clip_bbox_buf: array<vec4<f32>>;
+
+@group(0) @binding(4)
+var<storage, read_write> intersected_bbox: array<vec4<f32>>;
+
+@group(0) @binding(5)
+var<storage, read_write> bump: BumpAllocators;
+
+@group(0) @binding(6)
+var<storage, read_write> bin_data: array<u32>;
+
+// TODO: put in common place
+struct BinHeader {
+ element_count: u32,
+ chunk_offset: u32,
+}
+
+@group(0) @binding(7)
+var<storage, read_write> bin_header: array<BinHeader>;
+
+// conversion factors from coordinates to bin
+const SX = 1.0 / f32(N_TILE_X * TILE_WIDTH);
+const SY = 1.0 / f32(N_TILE_Y * TILE_HEIGHT);
+
+const WG_SIZE = 256u;
+const N_SLICE = WG_SIZE / 32u;
+const N_SUBSLICE = 4u;
+
+var<workgroup> sh_bitmaps: array<array<atomic<u32>, N_TILE>, N_SLICE>;
+// store count values packed two u16's to a u32
+var<workgroup> sh_count: array<array<u32, N_TILE>, N_SUBSLICE>;
+var<workgroup> sh_chunk_offset: array<u32, N_TILE>;
+var<workgroup> sh_previous_failed: u32;
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+ @builtin(workgroup_id) wg_id: vec3<u32>,
+) {
+ for (var i = 0u; i < N_SLICE; i += 1u) {
+ atomicStore(&sh_bitmaps[i][local_id.x], 0u);
+ }
+ if local_id.x == 0u {
+ let failed = atomicLoad(&bump.lines) > config.lines_size;
+ sh_previous_failed = u32(failed);
+ }
+ // also functions as barrier to protect zeroing of bitmaps
+ let failed = workgroupUniformLoad(&sh_previous_failed);
+ if failed != 0u {
+ if global_id.x == 0u {
+ atomicOr(&bump.failed, STAGE_FLATTEN);
+ }
+ return;
+ }
+
+ // Read inputs and determine coverage of bins for the draw object global_id.x
+ let element_ix = global_id.x;
+ var x0 = 0;
+ var y0 = 0;
+ var x1 = 0;
+ var y1 = 0;
+ if element_ix < config.n_drawobj {
+ let draw_monoid = draw_monoids[element_ix];
+ var clip_bbox = vec4(-1e9, -1e9, 1e9, 1e9);
+ if draw_monoid.clip_ix > 0u {
+ // TODO: `clip_ix` should always be valid as long as the monoids are correct. Leaving
+ // the bounds check in here for correctness but we should assert this condition instead
+ // once there is a debug-assertion mechanism.
+ clip_bbox = clip_bbox_buf[min(draw_monoid.clip_ix - 1u, config.n_clip - 1u)];
+ }
+ // For clip elements, clip_box is the bbox of the clip path,
+ // intersected with enclosing clips.
+ // For other elements, it is the bbox of the enclosing clips.
+ // TODO check this is true
+
+ let path_bbox = path_bbox_buf[draw_monoid.path_ix];
+ let pb = vec4<f32>(vec4(path_bbox.x0, path_bbox.y0, path_bbox.x1, path_bbox.y1));
+ let bbox = bbox_intersect(clip_bbox, pb);
+
+ intersected_bbox[element_ix] = bbox;
+
+ // `bbox_intersect` can result in a zero or negative area intersection if the path bbox lies
+ // outside the clip bbox. If that is the case, Don't round up the bottom-right corner of the
+ // and leave the coordinates at 0. This way the path will get clipped out and won't get
+ // assigned to a bin.
+ if bbox.x < bbox.z && bbox.y < bbox.w {
+ x0 = i32(floor(bbox.x * SX));
+ y0 = i32(floor(bbox.y * SY));
+ x1 = i32(ceil(bbox.z * SX));
+ y1 = i32(ceil(bbox.w * SY));
+ }
+ }
+ let width_in_bins = i32((config.width_in_tiles + N_TILE_X - 1u) / N_TILE_X);
+ let height_in_bins = i32((config.height_in_tiles + N_TILE_Y - 1u) / N_TILE_Y);
+ let n_bins = u32(width_in_bins * height_in_bins);
+ let aligned_n_bins = (n_bins + N_TILE - 1u) & ~(N_TILE - 1u);
+
+ x0 = clamp(x0, 0, width_in_bins);
+ y0 = clamp(y0, 0, height_in_bins);
+ x1 = clamp(x1, 0, width_in_bins);
+ y1 = clamp(y1, 0, height_in_bins);
+ if x0 == x1 {
+ y1 = y0;
+ }
+
+ let y0_width = y0 * width_in_bins;
+ let y1_width = y1 * width_in_bins;
+
+ let my_slice = local_id.x / 32u;
+ let my_mask = 1u << (local_id.x & 31u);
+
+ // Loop over the blocks of bins in chunks of N_TILE (256)
+ var next_block = N_TILE;
+ for (var block_start = 0u; block_start < n_bins; ) {
+ // Write coverage for the current block
+ for (var y_offset = y0_width; y_offset < y1_width; y_offset += width_in_bins) {
+ let start_bin = max(u32(y_offset + x0), block_start);
+ let end_bin = min(u32(y_offset + x1), next_block);
+ for (var bin_ix = start_bin; bin_ix < end_bin; bin_ix += 1u) {
+ let sh_bin_ix = bin_ix - block_start;
+ atomicOr(&sh_bitmaps[my_slice][sh_bin_ix], my_mask);
+ }
+ }
+ workgroupBarrier();
+
+ // Accumulate counts and allocate output segment for the bins in this block
+ let cur_bin_ix = block_start + local_id.x;
+ var element_count = 0u;
+ for (var i = 0u; i < N_SUBSLICE; i += 1u) {
+ element_count += countOneBits(atomicLoad(&sh_bitmaps[i * 2u][local_id.x]));
+ let element_count_lo = element_count;
+ element_count += countOneBits(atomicLoad(&sh_bitmaps[i * 2u + 1u][local_id.x]));
+ let element_count_hi = element_count;
+ let element_count_packed = element_count_lo | (element_count_hi << 16u);
+ sh_count[i][local_id.x] = element_count_packed;
+ }
+
+ // element_count is the number of draw objects covering this thread's bin
+ var chunk_offset = atomicAdd(&bump.binning, element_count);
+ if chunk_offset + element_count > config.binning_size {
+ chunk_offset = 0u;
+ atomicOr(&bump.failed, STAGE_BINNING);
+ }
+ sh_chunk_offset[local_id.x] = chunk_offset;
+
+ let header_ix = wg_id.x * aligned_n_bins + cur_bin_ix;
+ bin_header[header_ix].element_count = element_count;
+ bin_header[header_ix].chunk_offset = chunk_offset;
+ workgroupBarrier();
+
+ // Output the element indices to bin_data
+ for (var y_offset = y0_width; y_offset < y1_width; y_offset += width_in_bins) {
+ let start_bin = max(u32(y_offset + x0), block_start);
+ let end_bin = min(u32(y_offset + x1), next_block);
+ for (var bin_ix = start_bin; bin_ix < end_bin; bin_ix += 1u) {
+ let sh_bin_ix = bin_ix - block_start;
+ let out_mask = atomicLoad(&sh_bitmaps[my_slice][sh_bin_ix]);
+ // I think this predicate will always be true...
+ if (out_mask & my_mask) != 0u {
+ var idx = countOneBits(out_mask & (my_mask - 1u));
+ if my_slice > 0u {
+ let count_ix = my_slice - 1u;
+ let count_packed = sh_count[count_ix / 2u][sh_bin_ix];
+ idx += (count_packed >> (16u * (count_ix & 1u))) & 0xffffu;
+ }
+ let offset = config.bin_data_start + sh_chunk_offset[sh_bin_ix];
+ bin_data[offset + idx] = element_ix;
+ }
+ }
+ }
+
+ block_start = next_block;
+ if next_block < aligned_n_bins {
+ workgroupBarrier();
+ for (var i = 0u; i < N_SLICE; i += 1u) {
+ atomicStore(&sh_bitmaps[i][local_id.x], 0u);
+ }
+ workgroupBarrier();
+ next_block += N_TILE;
+ }
+ }
+}
diff --git a/vendor/vello_shaders/shader/clip_leaf.wgsl b/vendor/vello_shaders/shader/clip_leaf.wgsl
new file mode 100644
index 00000000..7a793704
--- /dev/null
+++ b/vendor/vello_shaders/shader/clip_leaf.wgsl
@@ -0,0 +1,217 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+#import config
+#import bbox
+#import clip
+#import drawtag
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage> clip_inp: array<ClipInp>;
+
+@group(0) @binding(2)
+var<storage> path_bboxes: array<PathBbox>;
+
+@group(0) @binding(3)
+var<storage> reduced: array<Bic>;
+
+@group(0) @binding(4)
+var<storage> clip_els: array<ClipEl>;
+
+@group(0) @binding(5)
+var<storage, read_write> draw_monoids: array<DrawMonoid>;
+
+@group(0) @binding(6)
+var<storage, read_write> clip_bboxes: array<vec4<f32>>;
+
+const WG_SIZE = 256u;
+var<workgroup> sh_bic: array<Bic, 510 >;
+var<workgroup> sh_stack: array<u32, WG_SIZE>;
+var<workgroup> sh_stack_bbox: array<vec4<f32>, WG_SIZE>;
+var<workgroup> sh_bbox: array<vec4<f32>, WG_SIZE>;
+var<workgroup> sh_link: array<i32, WG_SIZE>;
+
+fn search_link(bic: ptr<function, Bic>, ix_in: u32) -> i32 {
+ var ix = ix_in;
+ var j = 0u;
+ while j < firstTrailingBit(WG_SIZE) {
+ let base = 2u * WG_SIZE - (2u << (firstTrailingBit(WG_SIZE) - j));
+ if ((ix >> j) & 1u) != 0u {
+ let test = bic_combine(sh_bic[base + (ix >> j) - 1u], *bic);
+ if test.b > 0u {
+ break;
+ }
+ *bic = test;
+ ix -= 1u << j;
+ }
+ j += 1u;
+ }
+ if ix > 0u {
+ while j > 0u {
+ j -= 1u;
+ let base = 2u * WG_SIZE - (2u << (firstTrailingBit(WG_SIZE) - j));
+ let test = bic_combine(sh_bic[base + (ix >> j) - 1u], *bic);
+ if test.b == 0u {
+ *bic = test;
+ ix -= 1u << j;
+ }
+ }
+ }
+ if ix > 0u {
+ return i32(ix) - 1;
+ } else {
+ return i32(~0u - (*bic).a);
+ }
+}
+
+fn load_clip_path(ix: u32) -> i32 {
+ if ix < config.n_clip {
+ return clip_inp[ix].path_ix;
+ } else {
+ return -2147483648;
+ // literal too large?
+ // return 0x80000000;
+ }
+}
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+ @builtin(workgroup_id) wg_id: vec3<u32>,
+) {
+ var bic: Bic;
+ if local_id.x < wg_id.x {
+ bic = reduced[local_id.x];
+ }
+ sh_bic[local_id.x] = bic;
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ workgroupBarrier();
+ if local_id.x + (1u << i) < WG_SIZE {
+ let other = sh_bic[local_id.x + (1u << i)];
+ bic = bic_combine(bic, other);
+ }
+ workgroupBarrier();
+ sh_bic[local_id.x] = bic;
+ }
+ workgroupBarrier();
+ let stack_size = sh_bic[0].b;
+ // TODO: if stack depth > WG_SIZE desired, scan here
+
+ // binary search in stack
+ let sp = WG_SIZE - 1u - local_id.x;
+ var ix = 0u;
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ let probe = ix + ((WG_SIZE / 2u) >> i);
+ if sp < sh_bic[probe].b {
+ ix = probe;
+ }
+ }
+ let b = sh_bic[ix].b;
+ var bbox = vec4(-1e9, -1e9, 1e9, 1e9);
+ if sp < b {
+ let el = clip_els[ix * WG_SIZE + b - sp - 1u];
+ sh_stack[local_id.x] = el.parent_ix;
+ bbox = el.bbox;
+ }
+ // forward scan of bbox values of prefix stack
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ sh_stack_bbox[local_id.x] = bbox;
+ workgroupBarrier();
+ if local_id.x >= (1u << i) {
+ bbox = bbox_intersect(sh_stack_bbox[local_id.x - (1u << i)], bbox);
+ }
+ workgroupBarrier();
+ }
+ sh_stack_bbox[local_id.x] = bbox;
+
+ // Read input and compute Bic binary tree
+ let inp = load_clip_path(global_id.x);
+ let is_push = inp >= 0;
+ bic = Bic(1u - u32(is_push), u32(is_push));
+ sh_bic[local_id.x] = bic;
+ if is_push {
+ let path_bbox = path_bboxes[inp];
+ bbox = vec4(f32(path_bbox.x0), f32(path_bbox.y0), f32(path_bbox.x1), f32(path_bbox.y1));
+ } else {
+ bbox = vec4(-1e9, -1e9, 1e9, 1e9);
+ }
+ var inbase = 0u;
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE) - 1u; i += 1u) {
+ let outbase = 2u * WG_SIZE - (1u << (firstTrailingBit(WG_SIZE) - i));
+ workgroupBarrier();
+ if local_id.x < 1u << (firstTrailingBit(WG_SIZE) - 1u - i) {
+ let in_off = inbase + local_id.x * 2u;
+ sh_bic[outbase + local_id.x] = bic_combine(sh_bic[in_off], sh_bic[in_off + 1u]);
+ }
+ inbase = outbase;
+ }
+ workgroupBarrier();
+ // search for predecessor node
+ bic = Bic();
+ var link = -1;
+ if global_id.x < config.n_clip {
+ link = search_link(&bic, local_id.x);
+ }
+ sh_link[local_id.x] = link;
+ workgroupBarrier();
+ // Use explicit control flow rather than select here, as some backends may
+ // still materialize the indexed operand and expose invalid inactive lanes.
+ var grandparent = link - 1;
+ if link >= 0 {
+ grandparent = sh_link[link];
+ }
+ var parent: i32;
+ if link >= 0 {
+ parent = i32(wg_id.x * WG_SIZE) + link;
+ } else if link + i32(stack_size) >= 0 {
+ parent = i32(sh_stack[i32(WG_SIZE) + link]);
+ } else {
+ parent = -1;
+ }
+ // bbox scan (intersect) across parent links
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ if i != 0u {
+ sh_link[local_id.x] = link;
+ }
+ sh_bbox[local_id.x] = bbox;
+ workgroupBarrier();
+ if link >= 0 {
+ bbox = bbox_intersect(sh_bbox[link], bbox);
+ link = sh_link[link];
+ }
+ workgroupBarrier();
+ }
+ if link + i32(stack_size) >= 0 {
+ bbox = bbox_intersect(sh_stack_bbox[i32(WG_SIZE) + link], bbox);
+ }
+ // At this point, bbox is the intersection of bboxes on the path to the root
+ sh_bbox[local_id.x] = bbox;
+ workgroupBarrier();
+
+ if !is_push && global_id.x < config.n_clip {
+ // Fix up drawmonoid so path_ix of EndClip matches BeginClip
+ let parent_clip = clip_inp[parent];
+ let path_ix = parent_clip.path_ix;
+ let parent_ix = parent_clip.ix;
+ let ix = ~inp;
+ draw_monoids[ix].path_ix = u32(path_ix);
+ // Make EndClip point to the same draw data as BeginClip
+ draw_monoids[ix].scene_offset = draw_monoids[parent_ix].scene_offset;
+ // Make EndClip point to the same info (draw flags) as BeginClip
+ draw_monoids[ix].info_offset = draw_monoids[parent_ix].info_offset;
+ if grandparent >= 0 {
+ bbox = sh_bbox[grandparent];
+ } else if grandparent + i32(stack_size) >= 0 {
+ bbox = sh_stack_bbox[i32(WG_SIZE) + grandparent];
+ } else {
+ bbox = vec4(-1e9, -1e9, 1e9, 1e9);
+ }
+ }
+ if global_id.x < config.n_clip {
+ clip_bboxes[global_id.x] = bbox;
+ }
+}
diff --git a/vendor/vello_shaders/shader/clip_reduce.wgsl b/vendor/vello_shaders/shader/clip_reduce.wgsl
new file mode 100644
index 00000000..6b8979a5
--- /dev/null
+++ b/vendor/vello_shaders/shader/clip_reduce.wgsl
@@ -0,0 +1,67 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+#import bbox
+#import clip
+
+@group(0) @binding(0)
+var<storage> clip_inp: array<ClipInp>;
+
+@group(0) @binding(1)
+var<storage> path_bboxes: array<PathBbox>;
+
+@group(0) @binding(2)
+var<storage, read_write> reduced: array<Bic>;
+
+@group(0) @binding(3)
+var<storage, read_write> clip_out: array<ClipEl>;
+
+const WG_SIZE = 256u;
+var<workgroup> sh_bic: array<Bic, WG_SIZE>;
+var<workgroup> sh_parent: array<u32, WG_SIZE>;
+var<workgroup> sh_path_ix: array<u32, WG_SIZE>;
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+ @builtin(workgroup_id) wg_id: vec3<u32>,
+) {
+ let inp = clip_inp[global_id.x].path_ix;
+ let is_push = inp >= 0;
+ var bic = Bic(1u - u32(is_push), u32(is_push));
+ // reverse scan of bicyclic semigroup
+ sh_bic[local_id.x] = bic;
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ workgroupBarrier();
+ if local_id.x + (1u << i) < WG_SIZE {
+ let other = sh_bic[local_id.x + (1u << i)];
+ bic = bic_combine(bic, other);
+ }
+ workgroupBarrier();
+ sh_bic[local_id.x] = bic;
+ }
+ if local_id.x == 0u {
+ reduced[wg_id.x] = bic;
+ }
+ workgroupBarrier();
+ let size = sh_bic[0].b;
+ bic = Bic();
+ if local_id.x + 1u < WG_SIZE {
+ bic = sh_bic[local_id.x + 1u];
+ }
+ if is_push && bic.a == 0u {
+ let local_ix = size - bic.b - 1u;
+ sh_parent[local_ix] = local_id.x;
+ sh_path_ix[local_ix] = u32(inp);
+ }
+ workgroupBarrier();
+ // TODO: possibly do forward scan here if depth can exceed wg size
+ if local_id.x < size {
+ let path_ix = sh_path_ix[local_id.x];
+ let path_bbox = path_bboxes[path_ix];
+ let parent_ix = sh_parent[local_id.x] + wg_id.x * WG_SIZE;
+ let bbox = vec4(f32(path_bbox.x0), f32(path_bbox.y0), f32(path_bbox.x1), f32(path_bbox.y1));
+ clip_out[global_id.x] = ClipEl(parent_ix, bbox);
+ }
+}
diff --git a/vendor/vello_shaders/shader/coarse.wgsl b/vendor/vello_shaders/shader/coarse.wgsl
new file mode 100644
index 00000000..4e045c11
--- /dev/null
+++ b/vendor/vello_shaders/shader/coarse.wgsl
@@ -0,0 +1,471 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// The coarse rasterization stage.
+
+#import config
+#import bump
+#import drawtag
+#import ptcl
+#import tile
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage> scene: array<u32>;
+
+@group(0) @binding(2)
+var<storage> draw_monoids: array<DrawMonoid>;
+
+// TODO: dedup
+struct BinHeader {
+ element_count: u32,
+ chunk_offset: u32,
+}
+
+@group(0) @binding(3)
+var<storage> bin_headers: array<BinHeader>;
+
+@group(0) @binding(4)
+var<storage> info_bin_data: array<u32>;
+
+@group(0) @binding(5)
+var<storage> paths: array<Path>;
+
+@group(0) @binding(6)
+var<storage, read_write> tiles: array<Tile>;
+
+@group(0) @binding(7)
+var<storage, read_write> bump: BumpAllocators;
+
+@group(0) @binding(8)
+var<storage, read_write> ptcl: array<u32>;
+
+
+
+// Much of this code assumes WG_SIZE == N_TILE. If these diverge, then
+// a fair amount of fixup is needed.
+const WG_SIZE = 256u;
+const N_SLICE = WG_SIZE / 32u;
+
+var<workgroup> sh_bitmaps: array<array<atomic<u32>, N_TILE>, N_SLICE>;
+var<workgroup> sh_part_count: array<u32, WG_SIZE>;
+var<workgroup> sh_part_offsets: array<u32, WG_SIZE>;
+var<workgroup> sh_drawobj_ix: array<u32, WG_SIZE>;
+var<workgroup> sh_tile_stride: array<u32, WG_SIZE>;
+var<workgroup> sh_tile_width: array<u32, WG_SIZE>;
+var<workgroup> sh_tile_x0y0: array<u32, WG_SIZE>;
+var<workgroup> sh_tile_count: array<u32, WG_SIZE>;
+var<workgroup> sh_tile_base: array<u32, WG_SIZE>;
+
+// helper functions for writing ptcl
+
+var<private> cmd_offset: u32;
+var<private> cmd_limit: u32;
+
+// Make sure there is space for a command of given size, plus a jump if needed
+fn alloc_cmd(size: u32) {
+ if cmd_offset + size >= cmd_limit {
+ // We might be able to save a little bit of computation here
+ // by setting the initial value of the bump allocator.
+ let ptcl_dyn_start = config.width_in_tiles * config.height_in_tiles * PTCL_INITIAL_ALLOC;
+ var new_cmd = ptcl_dyn_start + atomicAdd(&bump.ptcl, PTCL_INCREMENT);
+ if new_cmd + PTCL_INCREMENT > config.ptcl_size {
+ // This sets us up for technical UB, as lots of threads will be writing
+ // to the same locations. But I think it's fine, and predicating the
+ // writes would probably slow things down.
+ new_cmd = 0u;
+ atomicOr(&bump.failed, STAGE_COARSE);
+ }
+ ptcl[cmd_offset] = CMD_JUMP;
+ ptcl[cmd_offset + 1u] = new_cmd;
+ cmd_offset = new_cmd;
+ cmd_limit = cmd_offset + (PTCL_INCREMENT - PTCL_HEADROOM);
+ }
+}
+
+fn write_path(tile: Tile, tile_ix: u32, draw_flags: u32) {
+ // We overload the "segments" field to store both count (written by
+ // path_count stage) and segment allocation (used by path_tiling and
+ // fine).
+ let n_segs = tile.segment_count_or_ix;
+ if n_segs != 0u {
+ var seg_ix = atomicAdd(&bump.segments, n_segs);
+ tiles[tile_ix].segment_count_or_ix = ~seg_ix;
+ alloc_cmd(4u);
+ ptcl[cmd_offset] = CMD_FILL;
+ let even_odd = (draw_flags & DRAW_INFO_FLAGS_FILL_RULE_BIT) != 0u;
+ let size_and_rule = (n_segs << 1u) | u32(even_odd);
+ let fill = CmdFill(size_and_rule, seg_ix, tile.backdrop);
+ ptcl[cmd_offset + 1u] = fill.size_and_rule;
+ ptcl[cmd_offset + 2u] = fill.seg_data;
+ ptcl[cmd_offset + 3u] = u32(fill.backdrop);
+ cmd_offset += 4u;
+ } else {
+ alloc_cmd(1u);
+ ptcl[cmd_offset] = CMD_SOLID;
+ cmd_offset += 1u;
+ }
+}
+
+fn write_color(color: CmdColor) {
+ alloc_cmd(2u);
+ ptcl[cmd_offset] = CMD_COLOR;
+ ptcl[cmd_offset + 1u] = color.rgba_color;
+ cmd_offset += 2u;
+}
+
+fn write_grad(ty: u32, index: u32, info_offset: u32) {
+ alloc_cmd(3u);
+ ptcl[cmd_offset] = ty;
+ ptcl[cmd_offset + 1u] = index;
+ ptcl[cmd_offset + 2u] = info_offset;
+ cmd_offset += 3u;
+}
+
+fn write_image(info_offset: u32) {
+ alloc_cmd(2u);
+ ptcl[cmd_offset] = CMD_IMAGE;
+ ptcl[cmd_offset + 1u] = info_offset;
+ cmd_offset += 2u;
+}
+
+fn write_begin_clip() {
+ alloc_cmd(1u);
+ ptcl[cmd_offset] = CMD_BEGIN_CLIP;
+ cmd_offset += 1u;
+}
+
+fn write_end_clip(end_clip: CmdEndClip) {
+ alloc_cmd(3u);
+ ptcl[cmd_offset] = CMD_END_CLIP;
+ ptcl[cmd_offset + 1u] = end_clip.blend;
+ ptcl[cmd_offset + 2u] = bitcast<u32>(end_clip.alpha);
+ cmd_offset += 3u;
+}
+
+fn write_blurred_rounded_rect(color: CmdColor, info_offset: u32) {
+ alloc_cmd(3u);
+ ptcl[cmd_offset] = CMD_BLUR_RECT;
+ ptcl[cmd_offset + 1u] = info_offset;
+ ptcl[cmd_offset + 2u] = color.rgba_color;
+ cmd_offset += 3u;
+}
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+ @builtin(workgroup_id) wg_id: vec3<u32>,
+) {
+ // Exit early if prior stages failed, as we can't run this stage.
+ // We need to check only prior stages, as if this stage has failed in another workgroup,
+ // we still want to know this workgroup's memory requirement.
+ if local_id.x == 0u {
+ var failed = atomicLoad(&bump.failed) & (STAGE_BINNING | STAGE_TILE_ALLOC | STAGE_FLATTEN);
+ if atomicLoad(&bump.seg_counts) > config.seg_counts_size {
+ failed |= STAGE_PATH_COUNT;
+ }
+ // Reuse sh_part_count to hold failed flag, shmem is tight
+ sh_part_count[0] = u32(failed);
+ }
+ let failed = workgroupUniformLoad(&sh_part_count[0]);
+ if failed != 0u {
+ if wg_id.x == 0u && local_id.x == 0u {
+ // propagate PATH_COUNT failure to path_tiling_setup so it doesn't need to bind config
+ atomicOr(&bump.failed, failed);
+ }
+ return;
+ }
+ let width_in_bins = (config.width_in_tiles + N_TILE_X - 1u) / N_TILE_X;
+ let bin_ix = width_in_bins * wg_id.y + wg_id.x;
+ let height_in_bins = (config.height_in_tiles + N_TILE_Y - 1u) / N_TILE_Y;
+ let aligned_n_bins = (width_in_bins * height_in_bins + N_TILE - 1u) & ~(N_TILE - 1u);
+ let n_partitions = (config.n_drawobj + N_TILE - 1u) / N_TILE;
+
+ // Coordinates of the top left of this bin, in tiles.
+ let bin_tile_x = N_TILE_X * wg_id.x;
+ let bin_tile_y = N_TILE_Y * wg_id.y;
+
+ let tile_x = local_id.x % N_TILE_X;
+ let tile_y = local_id.x / N_TILE_X;
+ let this_tile_ix = (bin_tile_y + tile_y) * config.width_in_tiles + bin_tile_x + tile_x;
+ cmd_offset = this_tile_ix * PTCL_INITIAL_ALLOC;
+ cmd_limit = cmd_offset + (PTCL_INITIAL_ALLOC - PTCL_HEADROOM);
+
+ // clip state
+ var clip_zero_depth = 0u;
+ var clip_depth = 0u;
+
+ var partition_ix = 0u;
+ var rd_ix = 0u;
+ var wr_ix = 0u;
+ var part_start_ix = 0u;
+ var ready_ix = 0u;
+
+ // blend state
+ var render_blend_depth = 0u;
+ var max_blend_depth = 0u;
+
+ let blend_offset = cmd_offset;
+ cmd_offset += 1u;
+
+ while true {
+ for (var i = 0u; i < N_SLICE; i += 1u) {
+ atomicStore(&sh_bitmaps[i][local_id.x], 0u);
+ }
+
+ while true {
+ if ready_ix == wr_ix && partition_ix < n_partitions {
+ part_start_ix = ready_ix;
+ var count = 0u;
+ if partition_ix + local_id.x < n_partitions {
+ let in_ix = (partition_ix + local_id.x) * aligned_n_bins + bin_ix;
+ let bin_header = bin_headers[in_ix];
+ count = bin_header.element_count;
+ sh_part_offsets[local_id.x] = bin_header.chunk_offset;
+ }
+ // prefix sum the element counts
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ sh_part_count[local_id.x] = count;
+ workgroupBarrier();
+ if local_id.x >= (1u << i) {
+ count += sh_part_count[local_id.x - (1u << i)];
+ }
+ workgroupBarrier();
+ }
+ sh_part_count[local_id.x] = part_start_ix + count;
+ ready_ix = workgroupUniformLoad(&sh_part_count[WG_SIZE - 1u]);
+ partition_ix += WG_SIZE;
+ }
+ // use binary search to find draw object to read
+ var ix = rd_ix + local_id.x;
+ if ix >= wr_ix && ix < ready_ix {
+ var part_ix = 0u;
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ let probe = part_ix + ((N_TILE / 2u) >> i);
+ if ix >= sh_part_count[probe - 1u] {
+ part_ix = probe;
+ }
+ }
+ ix -= select(part_start_ix, sh_part_count[part_ix - 1u], part_ix > 0u);
+ let offset = config.bin_data_start + sh_part_offsets[part_ix];
+ sh_drawobj_ix[local_id.x] = info_bin_data[offset + ix];
+ }
+ wr_ix = min(rd_ix + N_TILE, ready_ix);
+ if wr_ix - rd_ix >= N_TILE || (wr_ix >= ready_ix && partition_ix >= n_partitions) {
+ break;
+ }
+ workgroupBarrier();
+ }
+ // At this point, sh_drawobj_ix[0.. wr_ix - rd_ix] contains merged binning results.
+ var tag = DRAWTAG_NOP;
+ var drawobj_ix: u32;
+ if local_id.x + rd_ix < wr_ix {
+ drawobj_ix = sh_drawobj_ix[local_id.x];
+ tag = scene[config.drawtag_base + drawobj_ix];
+ }
+
+ var tile_count = 0u;
+ // I think this predicate is the same as the last, maybe they can be combined
+ if tag != DRAWTAG_NOP {
+ let path_ix = draw_monoids[drawobj_ix].path_ix;
+ let path = paths[path_ix];
+ let stride = path.bbox.z - path.bbox.x;
+ sh_tile_stride[local_id.x] = stride;
+ let dx = i32(path.bbox.x) - i32(bin_tile_x);
+ let dy = i32(path.bbox.y) - i32(bin_tile_y);
+ let x0 = clamp(dx, 0, i32(N_TILE_X));
+ let y0 = clamp(dy, 0, i32(N_TILE_Y));
+ let x1 = clamp(i32(path.bbox.z) - i32(bin_tile_x), 0, i32(N_TILE_X));
+ let y1 = clamp(i32(path.bbox.w) - i32(bin_tile_y), 0, i32(N_TILE_Y));
+ sh_tile_width[local_id.x] = u32(x1 - x0);
+ sh_tile_x0y0[local_id.x] = u32(x0) | u32(y0 << 16u);
+ tile_count = u32(x1 - x0) * u32(y1 - y0);
+ // base relative to bin
+ let base = path.tiles - u32(dy * i32(stride) + dx);
+ sh_tile_base[local_id.x] = base;
+ // TODO: there's a write_tile_alloc here in the source, not sure what it's supposed to do
+ }
+
+ // Prefix sum of tile counts
+ sh_tile_count[local_id.x] = tile_count;
+ for (var i = 0u; i < firstTrailingBit(N_TILE); i += 1u) {
+ workgroupBarrier();
+ if local_id.x >= (1u << i) {
+ tile_count += sh_tile_count[local_id.x - (1u << i)];
+ }
+ workgroupBarrier();
+ sh_tile_count[local_id.x] = tile_count;
+ }
+ workgroupBarrier();
+ let total_tile_count = sh_tile_count[N_TILE - 1u];
+ // Parallel iteration over all tiles
+ for (var ix = local_id.x; ix < total_tile_count; ix += N_TILE) {
+ // Binary search to find draw object which contains this tile
+ var el_ix = 0u;
+ for (var i = 0u; i < firstTrailingBit(N_TILE); i += 1u) {
+ let probe = el_ix + ((N_TILE / 2u) >> i);
+ if ix >= sh_tile_count[probe - 1u] {
+ el_ix = probe;
+ }
+ }
+ drawobj_ix = sh_drawobj_ix[el_ix];
+ tag = scene[config.drawtag_base + drawobj_ix];
+ let seq_ix = ix - select(0u, sh_tile_count[el_ix - 1u], el_ix > 0u);
+ let width = sh_tile_width[el_ix];
+ let x0y0 = sh_tile_x0y0[el_ix];
+ let x = (x0y0 & 0xffffu) + seq_ix % width;
+ let y = (x0y0 >> 16u) + seq_ix / width;
+ let tile_ix = sh_tile_base[el_ix] + sh_tile_stride[el_ix] * y + x;
+ let tile = tiles[tile_ix];
+ let is_clip = (tag & 1u) != 0u;
+ var is_blend = false;
+ if is_clip {
+ let BLEND_CLIP = (128u << 8u) | 3u;
+ let scene_offset = draw_monoids[drawobj_ix].scene_offset;
+ let dd = config.drawdata_base + scene_offset;
+ let blend = scene[dd];
+ is_blend = blend != BLEND_CLIP;
+ }
+
+ let di = draw_monoids[drawobj_ix].info_offset;
+ let draw_flags = info_bin_data[di];
+ let even_odd = (draw_flags & DRAW_INFO_FLAGS_FILL_RULE_BIT) != 0u;
+ let n_segs = tile.segment_count_or_ix;
+
+ // If this draw object represents an even-odd fill and we know that no line segment
+ // crosses this tile and then this draw object should not contribute to the tile if its
+ // backdrop (i.e. the winding number of its top-left corner) is even.
+ let backdrop_clear = select(tile.backdrop, abs(tile.backdrop) & 1, even_odd) == 0;
+ let include_tile = n_segs != 0u || (backdrop_clear == is_clip) || is_blend;
+ if include_tile {
+ let el_slice = el_ix / 32u;
+ let el_mask = 1u << (el_ix & 31u);
+ atomicOr(&sh_bitmaps[el_slice][y * N_TILE_X + x], el_mask);
+ }
+ }
+ workgroupBarrier();
+ // At this point bit drawobj % 32 is set in sh_bitmaps[drawobj / 32][y * N_TILE_X + x]
+ // if drawobj touches tile (x, y).
+
+ // Write per-tile command list for this tile
+ var slice_ix = 0u;
+ var bitmap = atomicLoad(&sh_bitmaps[0u][local_id.x]);
+ while true {
+ if bitmap == 0u {
+ slice_ix += 1u;
+ // potential optimization: make iteration limit dynamic
+ if slice_ix == N_SLICE {
+ break;
+ }
+ bitmap = atomicLoad(&sh_bitmaps[slice_ix][local_id.x]);
+ if bitmap == 0u {
+ continue;
+ }
+ }
+
+ let el_ix = slice_ix * 32u + firstTrailingBit(bitmap);
+ drawobj_ix = sh_drawobj_ix[el_ix];
+ // clear LSB of bitmap, using bit magic
+ bitmap &= bitmap - 1u;
+ let drawtag = scene[config.drawtag_base + drawobj_ix];
+ let dm = draw_monoids[drawobj_ix];
+ let dd = config.drawdata_base + dm.scene_offset;
+ let di = dm.info_offset;
+ let draw_flags = info_bin_data[di];
+ if clip_zero_depth == 0u {
+ let tile_ix = sh_tile_base[el_ix] + sh_tile_stride[el_ix] * tile_y + tile_x;
+ let tile = tiles[tile_ix];
+ switch drawtag {
+ case DRAWTAG_FILL_COLOR: {
+ write_path(tile, tile_ix, draw_flags);
+ let rgba_color = scene[dd];
+ write_color(CmdColor(rgba_color));
+ }
+ case DRAWTAG_BLURRED_ROUNDED_RECT: {
+ write_path(tile, tile_ix, draw_flags);
+ let rgba_color = scene[dd];
+ let info_offset = di + 1u;
+ write_blurred_rounded_rect(CmdColor(rgba_color), info_offset);
+ }
+ case DRAWTAG_FILL_LIN_GRADIENT: {
+ write_path(tile, tile_ix, draw_flags);
+ let index = scene[dd];
+ let info_offset = di + 1u;
+ write_grad(CMD_LIN_GRAD, index, info_offset);
+ }
+ case DRAWTAG_FILL_RAD_GRADIENT: {
+ write_path(tile, tile_ix, draw_flags);
+ let index = scene[dd];
+ let info_offset = di + 1u;
+ write_grad(CMD_RAD_GRAD, index, info_offset);
+ }
+ case DRAWTAG_FILL_SWEEP_GRADIENT: {
+ write_path(tile, tile_ix, draw_flags);
+ let index = scene[dd];
+ let info_offset = di + 1u;
+ write_grad(CMD_SWEEP_GRAD, index, info_offset);
+ }
+ case DRAWTAG_FILL_IMAGE: {
+ write_path(tile, tile_ix, draw_flags);
+ write_image(di + 1u);
+ }
+ case DRAWTAG_BEGIN_CLIP: {
+ let even_odd = (draw_flags & DRAW_INFO_FLAGS_FILL_RULE_BIT) != 0u;
+ let backdrop_clear = select(tile.backdrop, abs(tile.backdrop) & 1, even_odd) == 0;
+ if tile.segment_count_or_ix == 0u && backdrop_clear {
+ clip_zero_depth = clip_depth + 1u;
+ } else {
+ write_begin_clip();
+ render_blend_depth += 1u;
+ max_blend_depth = max(max_blend_depth, render_blend_depth);
+ }
+ clip_depth += 1u;
+ }
+ case DRAWTAG_END_CLIP: {
+ clip_depth -= 1u;
+ write_path(tile, tile_ix, draw_flags);
+ let blend = scene[dd];
+ let alpha = bitcast<f32>(scene[dd + 1u]);
+ write_end_clip(CmdEndClip(blend, alpha));
+ render_blend_depth -= 1u;
+ }
+ default: {}
+ }
+ } else {
+ // In "clip zero" state, suppress all drawing
+ switch drawtag {
+ case DRAWTAG_BEGIN_CLIP: {
+ clip_depth += 1u;
+ }
+ case DRAWTAG_END_CLIP: {
+ if clip_depth == clip_zero_depth {
+ clip_zero_depth = 0u;
+ }
+ clip_depth -= 1u;
+ }
+ default: {}
+ }
+ }
+ }
+
+ rd_ix += N_TILE;
+ if rd_ix >= ready_ix && partition_ix >= n_partitions {
+ break;
+ }
+ workgroupBarrier();
+ }
+ if bin_tile_x + tile_x < config.width_in_tiles && bin_tile_y + tile_y < config.height_in_tiles {
+ ptcl[cmd_offset] = CMD_END;
+ var blend_ix = 0u;
+ if max_blend_depth > BLEND_STACK_SPLIT {
+ let scratch_size = (max_blend_depth - BLEND_STACK_SPLIT) * TILE_WIDTH * TILE_HEIGHT;
+ blend_ix = atomicAdd(&bump.blend, scratch_size);
+ if blend_ix + scratch_size > config.blend_size {
+ atomicOr(&bump.failed, STAGE_COARSE);
+ }
+ }
+ ptcl[blend_offset] = blend_ix;
+ }
+}
diff --git a/vendor/vello_shaders/shader/draw_leaf.wgsl b/vendor/vello_shaders/shader/draw_leaf.wgsl
new file mode 100644
index 00000000..b5514b5a
--- /dev/null
+++ b/vendor/vello_shaders/shader/draw_leaf.wgsl
@@ -0,0 +1,303 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Finish prefix sum of drawtags, decode draw objects.
+
+#import config
+#import clip
+#import drawtag
+#import bbox
+#import transform
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage> scene: array<u32>;
+
+@group(0) @binding(2)
+var<storage> reduced: array<DrawMonoid>;
+
+@group(0) @binding(3)
+var<storage> path_bbox: array<PathBbox>;
+
+@group(0) @binding(4)
+var<storage, read_write> draw_monoid: array<DrawMonoid>;
+
+@group(0) @binding(5)
+var<storage, read_write> info: array<u32>;
+
+@group(0) @binding(6)
+var<storage, read_write> clip_inp: array<ClipInp>;
+
+#import util
+
+const WG_SIZE = 256u;
+
+fn read_transform(transform_base: u32, ix: u32) -> Transform {
+ let base = transform_base + ix * 6u;
+ let c0 = bitcast<f32>(scene[base]);
+ let c1 = bitcast<f32>(scene[base + 1u]);
+ let c2 = bitcast<f32>(scene[base + 2u]);
+ let c3 = bitcast<f32>(scene[base + 3u]);
+ let c4 = bitcast<f32>(scene[base + 4u]);
+ let c5 = bitcast<f32>(scene[base + 5u]);
+ let matrx = vec4(c0, c1, c2, c3);
+ let translate = vec2(c4, c5);
+ return Transform(matrx, translate);
+}
+
+var<workgroup> sh_scratch: array<DrawMonoid, WG_SIZE>;
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+ @builtin(workgroup_id) wg_id: vec3<u32>,
+) {
+ // Reduce prefix of workgroups up to this one
+ var agg = draw_monoid_identity();
+ if local_id.x < wg_id.x {
+ agg = reduced[local_id.x];
+ }
+ sh_scratch[local_id.x] = agg;
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ workgroupBarrier();
+ if local_id.x + (1u << i) < WG_SIZE {
+ let other = sh_scratch[local_id.x + (1u << i)];
+ agg = combine_draw_monoid(agg, other);
+ }
+ workgroupBarrier();
+ sh_scratch[local_id.x] = agg;
+ }
+ // Two barriers can be eliminated if we use separate shared arrays
+ // for prefix and intra-workgroup prefix sum.
+ workgroupBarrier();
+ var prefix = sh_scratch[0];
+
+ // This is the same division of work as draw_reduce.
+ let num_blocks_total = (config.n_drawobj + WG_SIZE - 1u) / WG_SIZE;
+ let n_blocks_base = num_blocks_total / WG_SIZE;
+ let remainder = num_blocks_total % WG_SIZE;
+ let first_block = n_blocks_base * wg_id.x + min(wg_id.x, remainder);
+ let n_blocks = n_blocks_base + u32(wg_id.x < remainder);
+ var block_start = first_block * WG_SIZE;
+ let blocks_end = block_start + n_blocks * WG_SIZE;
+ while block_start != blocks_end {
+ let ix = block_start + local_id.x;
+ let tag_word = read_draw_tag_from_scene(ix);
+ agg = map_draw_tag(tag_word);
+ workgroupBarrier();
+ sh_scratch[local_id.x] = agg;
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ workgroupBarrier();
+ if local_id.x >= 1u << i {
+ let other = sh_scratch[local_id.x - (1u << i)];
+ agg = combine_draw_monoid(agg, other);
+ }
+ workgroupBarrier();
+ sh_scratch[local_id.x] = agg;
+ }
+ var m = prefix;
+ workgroupBarrier();
+ if local_id.x > 0u {
+ m = combine_draw_monoid(m, sh_scratch[local_id.x - 1u]);
+ }
+ // m now contains exclusive prefix sum of draw monoid
+ if ix < config.n_drawobj {
+ draw_monoid[ix] = m;
+ }
+ let dd = config.drawdata_base + m.scene_offset;
+ let di = m.info_offset;
+ if tag_word == DRAWTAG_FILL_COLOR || tag_word == DRAWTAG_FILL_LIN_GRADIENT ||
+ tag_word == DRAWTAG_FILL_RAD_GRADIENT || tag_word == DRAWTAG_FILL_SWEEP_GRADIENT ||
+ tag_word == DRAWTAG_FILL_IMAGE || tag_word == DRAWTAG_BEGIN_CLIP || tag_word == DRAWTAG_BLURRED_ROUNDED_RECT
+ {
+ let bbox = path_bbox[m.path_ix];
+ // TODO: bbox is mostly yagni here, sort that out. Maybe clips?
+ // let x0 = f32(bbox.x0);
+ // let y0 = f32(bbox.y0);
+ // let x1 = f32(bbox.x1);
+ // let y1 = f32(bbox.y1);
+ // let bbox_f = vec4(x0, y0, x1, y1);
+ var transform = Transform();
+ let draw_flags = bbox.draw_flags;
+ if tag_word == DRAWTAG_FILL_LIN_GRADIENT || tag_word == DRAWTAG_FILL_RAD_GRADIENT ||
+ tag_word == DRAWTAG_FILL_SWEEP_GRADIENT || tag_word == DRAWTAG_FILL_IMAGE ||
+ tag_word == DRAWTAG_BLURRED_ROUNDED_RECT
+ {
+ transform = read_transform(config.transform_base, bbox.trans_ix);
+ }
+ switch tag_word {
+ case DRAWTAG_FILL_COLOR: {
+ info[di] = draw_flags;
+ }
+ case DRAWTAG_BEGIN_CLIP: {
+ info[di] = draw_flags;
+ }
+ case DRAWTAG_FILL_LIN_GRADIENT: {
+ info[di] = draw_flags;
+ var p0 = bitcast<vec2<f32>>(vec2(scene[dd + 1u], scene[dd + 2u]));
+ var p1 = bitcast<vec2<f32>>(vec2(scene[dd + 3u], scene[dd + 4u]));
+ p0 = transform_apply(transform, p0);
+ p1 = transform_apply(transform, p1);
+ let dxy = p1 - p0;
+ let scale = 1.0 / dot(dxy, dxy);
+ let line_xy = dxy * scale;
+ let line_c = -dot(p0, line_xy);
+ info[di + 1u] = bitcast<u32>(line_xy.x);
+ info[di + 2u] = bitcast<u32>(line_xy.y);
+ info[di + 3u] = bitcast<u32>(line_c);
+ }
+ case DRAWTAG_FILL_RAD_GRADIENT: {
+ // Two-point conical gradient implementation based
+ // on the algorithm at <https://skia.org/docs/dev/design/conical/>
+ // This epsilon matches what Skia uses
+ let GRADIENT_EPSILON = 1.0 / f32(1u << 12u);
+ info[di] = draw_flags;
+ var p0 = bitcast<vec2<f32>>(vec2(scene[dd + 1u], scene[dd + 2u]));
+ var p1 = bitcast<vec2<f32>>(vec2(scene[dd + 3u], scene[dd + 4u]));
+ var r0 = bitcast<f32>(scene[dd + 5u]);
+ var r1 = bitcast<f32>(scene[dd + 6u]);
+ let user_to_gradient = transform_inverse(transform);
+ // Output variables
+ var xform = Transform();
+ var focal_x = 0.0;
+ var radius = 0.0;
+ var kind = 0u;
+ var flags = 0u;
+ if abs(r0 - r1) <= GRADIENT_EPSILON {
+ // When the radii are the same, emit a strip gradient
+ kind = RAD_GRAD_KIND_STRIP;
+ let scaled = r0 / distance(p0, p1);
+ xform = transform_mul(
+ two_point_to_unit_line(p0, p1),
+ user_to_gradient
+ );
+ radius = scaled * scaled;
+ } else {
+ // Assume a two point conical gradient unless the centers
+ // are equal.
+ kind = RAD_GRAD_KIND_CONE;
+ if all(p0 == p1) {
+ kind = RAD_GRAD_KIND_CIRCULAR;
+ // Nudge p0 a bit to avoid denormals.
+ p0 += GRADIENT_EPSILON;
+ }
+ if r1 == 0.0 {
+ // If r1 == 0.0, swap the points and radii
+ flags |= RAD_GRAD_SWAPPED;
+ let tmp_p = p0;
+ p0 = p1;
+ p1 = tmp_p;
+ let tmp_r = r0;
+ r0 = r1;
+ r1 = tmp_r;
+ }
+ focal_x = r0 / (r0 - r1);
+ let cf = (1.0 - focal_x) * p0 + focal_x * p1;
+ radius = r1 / (distance(cf, p1));
+ let user_to_unit_line = transform_mul(
+ two_point_to_unit_line(cf, p1),
+ user_to_gradient
+ );
+ var user_to_scaled = user_to_unit_line;
+ // When r == 1.0, focal point is on circle
+ if abs(radius - 1.0) <= GRADIENT_EPSILON {
+ kind = RAD_GRAD_KIND_FOCAL_ON_CIRCLE;
+ let scale = 0.5 * abs(1.0 - focal_x);
+ user_to_scaled = transform_mul(
+ Transform(vec4(scale, 0.0, 0.0, scale), vec2(0.0)),
+ user_to_unit_line
+ );
+ } else {
+ let a = radius * radius - 1.0;
+ let scale_ratio = abs(1.0 - focal_x) / a;
+ let scale_x = radius * scale_ratio;
+ let scale_y = sqrt(abs(a)) * scale_ratio;
+ user_to_scaled = transform_mul(
+ Transform(vec4(scale_x, 0.0, 0.0, scale_y), vec2(0.0)),
+ user_to_unit_line
+ );
+ }
+ xform = user_to_scaled;
+ }
+ info[di + 1u] = bitcast<u32>(xform.matrx.x);
+ info[di + 2u] = bitcast<u32>(xform.matrx.y);
+ info[di + 3u] = bitcast<u32>(xform.matrx.z);
+ info[di + 4u] = bitcast<u32>(xform.matrx.w);
+ info[di + 5u] = bitcast<u32>(xform.translate.x);
+ info[di + 6u] = bitcast<u32>(xform.translate.y);
+ info[di + 7u] = bitcast<u32>(focal_x);
+ info[di + 8u] = bitcast<u32>(radius);
+ info[di + 9u] = bitcast<u32>((flags << 3u) | kind);
+ }
+ case DRAWTAG_FILL_SWEEP_GRADIENT: {
+ info[di] = draw_flags;
+ let p0 = bitcast<vec2<f32>>(vec2(scene[dd + 1u], scene[dd + 2u]));
+ let xform = transform_mul(transform, Transform(vec4(1.0, 0.0, 0.0, 1.0), p0));
+ let inv = transform_inverse(xform);
+ info[di + 1u] = bitcast<u32>(inv.matrx.x);
+ info[di + 2u] = bitcast<u32>(inv.matrx.y);
+ info[di + 3u] = bitcast<u32>(inv.matrx.z);
+ info[di + 4u] = bitcast<u32>(inv.matrx.w);
+ info[di + 5u] = bitcast<u32>(inv.translate.x);
+ info[di + 6u] = bitcast<u32>(inv.translate.y);
+ info[di + 7u] = scene[dd + 3u];
+ info[di + 8u] = scene[dd + 4u];
+ }
+ case DRAWTAG_FILL_IMAGE: {
+ info[di] = draw_flags;
+ let inv = transform_inverse(transform);
+ info[di + 1u] = bitcast<u32>(inv.matrx.x);
+ info[di + 2u] = bitcast<u32>(inv.matrx.y);
+ info[di + 3u] = bitcast<u32>(inv.matrx.z);
+ info[di + 4u] = bitcast<u32>(inv.matrx.w);
+ info[di + 5u] = bitcast<u32>(inv.translate.x);
+ info[di + 6u] = bitcast<u32>(inv.translate.y);
+ info[di + 7u] = scene[dd];
+ info[di + 8u] = scene[dd + 1u];
+ info[di + 9u] = scene[dd + 2u];
+ }
+ case DRAWTAG_BLURRED_ROUNDED_RECT: {
+ info[di] = draw_flags;
+ let inv = transform_inverse(transform);
+ info[di + 1u] = bitcast<u32>(inv.matrx.x);
+ info[di + 2u] = bitcast<u32>(inv.matrx.y);
+ info[di + 3u] = bitcast<u32>(inv.matrx.z);
+ info[di + 4u] = bitcast<u32>(inv.matrx.w);
+ info[di + 5u] = bitcast<u32>(inv.translate.x);
+ info[di + 6u] = bitcast<u32>(inv.translate.y);
+ info[di + 7u] = scene[dd + 1u];
+ info[di + 8u] = scene[dd + 2u];
+ info[di + 9u] = scene[dd + 3u];
+ info[di + 10u] = scene[dd + 4u];
+ }
+ default: {}
+ }
+ }
+ if tag_word == DRAWTAG_BEGIN_CLIP || tag_word == DRAWTAG_END_CLIP {
+ var path_ix = ~ix;
+ if tag_word == DRAWTAG_BEGIN_CLIP {
+ path_ix = m.path_ix;
+ }
+ clip_inp[m.clip_ix] = ClipInp(ix, i32(path_ix));
+ }
+ block_start += WG_SIZE;
+ // break here on end to save monoid aggregation?
+ prefix = combine_draw_monoid(prefix, sh_scratch[WG_SIZE - 1u]);
+ }
+}
+
+fn two_point_to_unit_line(p0: vec2<f32>, p1: vec2<f32>) -> Transform {
+ let tmp1 = from_poly2(p0, p1);
+ let inv = transform_inverse(tmp1);
+ let tmp2 = from_poly2(vec2(0.0), vec2(1.0, 0.0));
+ return transform_mul(tmp2, inv);
+}
+
+fn from_poly2(p0: vec2<f32>, p1: vec2<f32>) -> Transform {
+ return Transform(
+ vec4(p1.y - p0.y, p0.x - p1.x, p1.x - p0.x, p1.y - p0.y),
+ vec2(p0.x, p0.y)
+ );
+}
diff --git a/vendor/vello_shaders/shader/draw_reduce.wgsl b/vendor/vello_shaders/shader/draw_reduce.wgsl
new file mode 100644
index 00000000..7a12b818
--- /dev/null
+++ b/vendor/vello_shaders/shader/draw_reduce.wgsl
@@ -0,0 +1,55 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+#import config
+#import drawtag
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage> scene: array<u32>;
+
+@group(0) @binding(2)
+var<storage, read_write> reduced: array<DrawMonoid>;
+
+const WG_SIZE = 256u;
+
+var<workgroup> sh_scratch: array<DrawMonoid, WG_SIZE>;
+
+#import util
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+ @builtin(workgroup_id) wg_id: vec3<u32>,
+) {
+ let num_blocks_total = (config.n_drawobj + (WG_SIZE - 1u)) / WG_SIZE;
+ // When the number of blocks exceeds the workgroup size, divide
+ // the work evenly so each workgroup handles n_blocks / wg, with
+ // the low workgroups doing one more each to handle the remainder.
+ let n_blocks_base = num_blocks_total / WG_SIZE;
+ let remainder = num_blocks_total % WG_SIZE;
+ let first_block = n_blocks_base * wg_id.x + min(wg_id.x, remainder);
+ let n_blocks = n_blocks_base + u32(wg_id.x < remainder);
+ var block_index = first_block * WG_SIZE + local_id.x;
+ var agg = draw_monoid_identity();
+ for (var i = 0u; i < n_blocks; i++) {
+ let tag_word = read_draw_tag_from_scene(block_index);
+ agg = combine_draw_monoid(agg, map_draw_tag(tag_word));
+ block_index += WG_SIZE;
+ }
+ sh_scratch[local_id.x] = agg;
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ workgroupBarrier();
+ if local_id.x + (1u << i) < WG_SIZE {
+ let other = sh_scratch[local_id.x + (1u << i)];
+ agg = combine_draw_monoid(agg, other);
+ }
+ workgroupBarrier();
+ sh_scratch[local_id.x] = agg;
+ }
+ if local_id.x == 0u {
+ reduced[wg_id.x] = agg;
+ }
+}
diff --git a/vendor/vello_shaders/shader/fine.wgsl b/vendor/vello_shaders/shader/fine.wgsl
new file mode 100644
index 00000000..4e2fde00
--- /dev/null
+++ b/vendor/vello_shaders/shader/fine.wgsl
@@ -0,0 +1,1432 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Fine rasterizer.
+//
+// To enable multisampled rendering, turn on both the msaa ifdef and one of msaa8
+// or msaa16.
+
+struct Tile {
+ backdrop: i32,
+ segments: u32,
+}
+
+#import segment
+#import config
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage> segments: array<Segment>;
+
+#import blend
+#import ptcl
+
+const GRADIENT_WIDTH = 512;
+
+const IMAGE_QUALITY_LOW = 0u;
+const IMAGE_QUALITY_MEDIUM = 1u;
+const IMAGE_QUALITY_HIGH = 2u;
+
+const LUMINANCE_MASK_LAYER = 0x10000u;
+
+@group(0) @binding(2)
+var<storage> ptcl: array<u32>;
+
+@group(0) @binding(3)
+var<storage> info: array<u32>;
+
+@group(0) @binding(4)
+var<storage, read_write> blend_spill: array<u32>;
+
+@group(0) @binding(5)
+var output: texture_storage_2d<rgba8unorm, write>;
+
+@group(0) @binding(6)
+var gradients: texture_2d<f32>;
+
+@group(0) @binding(7)
+var image_atlas: texture_2d<f32>;
+
+// MSAA-only bindings and utilities
+#ifdef msaa
+
+const MASK_LUT_INDEX: u32 = 8;
+
+#ifdef msaa8
+const MASK_WIDTH = 32u;
+const MASK_HEIGHT = 32u;
+const SH_SAMPLES_SIZE = 512u;
+const SAMPLE_WORDS_PER_PIXEL = 2u;
+// This might be better in uniform, but that has 16 byte alignment
+@group(0) @binding(MASK_LUT_INDEX)
+var<storage> mask_lut: array<u32, 256u>;
+#endif
+
+#ifdef msaa16
+const MASK_WIDTH = 64u;
+const MASK_HEIGHT = 64u;
+const SH_SAMPLES_SIZE = 1024u;
+const SAMPLE_WORDS_PER_PIXEL = 4u;
+@group(0) @binding(MASK_LUT_INDEX)
+var<storage> mask_lut: array<u32, 2048u>;
+#endif
+
+const WG_SIZE = 64u;
+var<workgroup> sh_count: array<u32, WG_SIZE>;
+
+// This array contains the winding number of the top left corner of each
+// 16 pixel wide row of pixels, relative to the top left corner of the row
+// immediately above.
+//
+// The values are stored packed, as 4 8-bit subwords in a 32 bit word.
+// The values are biased signed integers, with 0x80 representing a winding
+// number of 0, so that the range of -128 to 127 (inclusive) can be stored
+// without carry.
+//
+// For the even-odd case, the same storage is repurposed, so that a single
+// word contains 16 one-bit winding parity values packed to the word.
+var<workgroup> sh_winding_y: array<atomic<u32>, 4u>;
+// This array contains the winding number of the top left corner of each
+// 16 pixel wide row of pixels, relative to the top left corner of the tile.
+// It is expanded from sh_winding_y by inclusive prefix sum.
+var<workgroup> sh_winding_y_prefix: array<atomic<u32>, 4u>;
+// This array contains winding numbers of the top left corner of each
+// pixel, relative to the top left corner of the enclosing 16 pixel
+// wide row.
+//
+// During winding number accumulation, it stores a delta (winding number
+// relative to the pixel immediately to the left), then expanded using
+// prefix sum and reusing the same storage.
+//
+// The encoding and packing is the same as `sh_winding_y`. For the even-odd
+// case, only the first 16 values are used, and each word stores packed
+// parity values for one row of pixels.
+var<workgroup> sh_winding: array<atomic<u32>, 64u>;
+// This array contains winding numbers of multiple sample points within
+// a pixel, relative to the winding number of the top left corner of the
+// pixel. The encoding and packing is the same as `sh_winding_y`.
+var<workgroup> sh_samples: array<atomic<u32>, SH_SAMPLES_SIZE>;
+
+// number of integer cells spanned by interval defined by a, b
+fn span(a: f32, b: f32) -> u32 {
+ return u32(max(ceil(max(a, b)) - floor(min(a, b)), 1.0));
+}
+
+const SEG_SIZE = 5u;
+
+// See cpu_shaders/util.rs for explanation of these.
+const ONE_MINUS_ULP: f32 = 0.99999994;
+const ROBUST_EPSILON: f32 = 2e-7;
+
+// Multisampled path rendering algorithm.
+//
+// FIXME: This could return an array when https://github.com/gfx-rs/naga/issues/1930 is fixed.
+//
+// Generally, this algorithm works in an accumulation phase followed by a
+// resolving phase, with arrays in workgroup shared memory accumulating
+// winding number deltas as the results of edge crossings detected in the
+// path segments. Accumulation is in two stages: first a counting stage
+// which computes the number of pixels touched by each line segment (with
+// each thread processing one line segment), then a stage in which the
+// deltas are bumped. Separating these two is a partition-wide prefix sum
+// and a binary search to assign the work to threads in a load-balanced
+// manner.
+//
+// The resolving phase is also two stages: prefix sums in both x and y
+// directions, then counting nonzero winding numbers for all samples within
+// all pixels in the tile.
+//
+// A great deal of SIMD within a register (SWAR) logic is used, as there
+// are a great many winding numbers to be computed. The interested reader
+// is invited to study the even-odd case first, as there only one bit is
+// needed to represent a winding number parity, thus there is a lot less
+// bit shifting, and less shuffling altogether.
+fn fill_path_ms(fill: CmdFill, local_id: vec2<u32>, result: ptr<function, array<f32, PIXELS_PER_THREAD>>) {
+ let even_odd = (fill.size_and_rule & 1u) != 0u;
+ // This isn't a divergent branch because the fill parameters are workgroup uniform,
+ // provably so because the ptcl buffer is bound read-only.
+ if even_odd {
+ fill_path_ms_evenodd(fill, local_id, result);
+ return;
+ }
+ let n_segs = fill.size_and_rule >> 1u;
+ let th_ix = local_id.y * (TILE_WIDTH / PIXELS_PER_THREAD) + local_id.x;
+ // Initialize winding number arrays to a winding number of 0, which is 0x80 in an
+ // 8 bit biased signed integer encoding.
+ if th_ix < 64u {
+ if th_ix < 4u {
+ atomicStore(&sh_winding_y[th_ix], 0x80808080u);
+ }
+ atomicStore(&sh_winding[th_ix], 0x80808080u);
+ }
+ let sample_count = PIXELS_PER_THREAD * SAMPLE_WORDS_PER_PIXEL;
+ for (var i = 0u; i < sample_count; i++) {
+ atomicStore(&sh_samples[th_ix * sample_count + i], 0x80808080u);
+ }
+ workgroupBarrier();
+ let n_batch = (n_segs + (WG_SIZE - 1u)) / WG_SIZE;
+ for (var batch = 0u; batch < n_batch; batch++) {
+ let seg_ix = batch * WG_SIZE + th_ix;
+ let seg_off = fill.seg_data + seg_ix;
+ var count = 0u;
+ let slice_size = min(n_segs - batch * WG_SIZE, WG_SIZE);
+ // TODO: might save a register rewriting this in terms of limit
+ if th_ix < slice_size {
+ let segment = segments[seg_off];
+ let xy0 = segment.point0;
+ let xy1 = segment.point1;
+ var y_edge_f = f32(TILE_HEIGHT);
+ var delta = select(-1, 1, xy1.x <= xy0.x);
+ if xy0.x == 0.0 {
+ y_edge_f = xy0.y;
+ } else if xy1.x == 0.0 {
+ y_edge_f = xy1.y;
+ }
+ // discard horizontal lines aligned to pixel grid
+ if !(xy0.y == xy1.y && xy0.y == floor(xy0.y)) {
+ count = span(xy0.x, xy1.x) + span(xy0.y, xy1.y) - 1u;
+ }
+ let y_edge = u32(ceil(y_edge_f));
+ if y_edge < TILE_HEIGHT {
+ atomicAdd(&sh_winding_y[y_edge >> 2u], u32(delta) << ((y_edge & 3u) << 3u));
+ }
+ }
+ // workgroup prefix sum of counts
+ sh_count[th_ix] = count;
+ let lg_n = firstLeadingBit(slice_size * 2u - 1u);
+ for (var i = 0u; i < lg_n; i++) {
+ workgroupBarrier();
+ if th_ix >= 1u << i {
+ count += sh_count[th_ix - (1u << i)];
+ }
+ workgroupBarrier();
+ sh_count[th_ix] = count;
+ }
+ let total = workgroupUniformLoad(&sh_count[slice_size - 1u]);
+ for (var i = th_ix; i < total; i += WG_SIZE) {
+ // binary search to find pixel
+ var lo = 0u;
+ var hi = slice_size;
+ let goal = i;
+ while hi > lo + 1u {
+ let mid = (lo + hi) >> 1u;
+ if goal >= sh_count[mid - 1u] {
+ lo = mid;
+ } else {
+ hi = mid;
+ }
+ }
+ let el_ix = lo;
+ let last_pixel = i + 1u == sh_count[el_ix];
+ let sub_ix = i - select(0u, sh_count[el_ix - 1u], el_ix > 0u);
+ let seg_off = fill.seg_data + batch * WG_SIZE + el_ix;
+ let segment = segments[seg_off];
+ // Coordinates are relative to tile origin
+ let xy0_in = segment.point0;
+ let xy1_in = segment.point1;
+ let is_down = xy1_in.y >= xy0_in.y;
+ let xy0 = select(xy1_in, xy0_in, is_down);
+ let xy1 = select(xy0_in, xy1_in, is_down);
+
+ // Set up data for line rasterization
+ // Note: this is duplicated work if total count exceeds a workgroup.
+ // One alternative is to compute it in a separate dispatch.
+ let dx = abs(xy1.x - xy0.x);
+ let dy = xy1.y - xy0.y;
+ let idxdy = 1.0 / (dx + dy);
+ var a = dx * idxdy;
+ // is_positive_slope is true for \ and | slopes, false for /. For
+ // horizontal lines, it follows the original data.
+ let is_positive_slope = xy1.x >= xy0.x;
+ let x_sign = select(-1.0, 1.0, is_positive_slope);
+ let xt0 = floor(xy0.x * x_sign);
+ let c = xy0.x * x_sign - xt0;
+ let y0i = floor(xy0.y);
+ let ytop = y0i + 1.0;
+ let b = min((dy * c + dx * (ytop - xy0.y)) * idxdy, ONE_MINUS_ULP);
+ let count_x = span(xy0.x, xy1.x) - 1u;
+ let count = count_x + span(xy0.y, xy1.y);
+ let robust_err = floor(a * (f32(count) - 1.0) + b) - f32(count_x);
+ if robust_err != 0.0 {
+ a -= ROBUST_EPSILON * sign(robust_err);
+ }
+ let x0i = i32(xt0 * x_sign + 0.5 * (x_sign - 1.0));
+ // Use line equation to plot pixel coordinates
+
+ let zf = a * f32(sub_ix) + b;
+ let z = floor(zf);
+ let x = x0i + i32(x_sign * z);
+ let y = i32(y0i) + i32(sub_ix) - i32(z);
+ // is_delta captures whether the line crosses the top edge of this
+ // pixel. If so, then a delta is added to `sh_winding`, followed by
+ // a prefix sum, so that a winding number delta is applied to all
+ // pixels to the right of this one.
+ var is_delta: bool;
+ // is_bump captures whether x0 crosses the left edge of this pixel.
+ var is_bump = false;
+ let zp = floor(a * f32(sub_ix - 1u) + b);
+ if sub_ix == 0u {
+ // The first (top-most) pixel in the line. It is considered to be
+ // a line crossing when it touches the top of the pixel.
+ //
+ // Note: horizontal lines aligned to the pixel grid have already
+ // been discarded.
+ is_delta = y0i == xy0.y;
+ // The pixel is counted as a left edge crossing only at the left
+ // edge of the tile (and when it is not the top left corner,
+ // using logic analogous to tiling).
+ is_bump = xy0.x == 0.0 && y0i != xy0.y;
+ } else {
+ // Pixels other than the first are a crossing at the top or on
+ // the side, based on the conservative line rasterization. When
+ // positive slope, the crossing is on the left.
+ is_delta = z == zp;
+ is_bump = is_positive_slope && !is_delta;
+ }
+ let pix_ix = u32(y) * TILE_WIDTH + u32(x);
+ if u32(x) < TILE_WIDTH - 1u && u32(y) < TILE_HEIGHT {
+ let delta_pix = pix_ix + 1u;
+ if is_delta {
+ let delta = select(u32(-1i), 1u, is_down) << ((delta_pix & 3u) << 3u);
+ atomicAdd(&sh_winding[delta_pix >> 2u], delta);
+ }
+ }
+ // Apply sample mask
+ let mask_block = u32(is_positive_slope) * (MASK_WIDTH * MASK_HEIGHT / 2u);
+ let half_height = f32(MASK_HEIGHT / 2u);
+ let mask_row = floor(min(a * half_height, half_height - 1.0)) * f32(MASK_WIDTH);
+ let mask_col = floor((zf - z) * f32(MASK_WIDTH));
+ let mask_ix = mask_block + u32(mask_row + mask_col);
+#ifdef msaa8
+ var mask = mask_lut[mask_ix / 4u] >> ((mask_ix % 4u) * 8u);
+ mask &= 0xffu;
+ // Intersect with y half-plane masks
+ if sub_ix == 0u && !is_bump {
+ let mask_shift = u32(round(8.0 * (xy0.y - f32(y))));
+ mask &= 0xffu << mask_shift;
+ }
+ if last_pixel && xy1.x != 0.0 {
+ let mask_shift = u32(round(8.0 * (xy1.y - f32(y))));
+ mask &= ~(0xffu << mask_shift);
+ }
+ // Expand an 8 bit mask value to 8 1-bit values, packed 4 to a subword,
+ // so that two words are used to represent the result. An efficient
+ // technique is carry-less multiplication by 0b10_0000_0100_0000_1000_0001
+ // followed by and-masking to extract bit in position 4 * k.
+ //
+ // See https://en.wikipedia.org/wiki/Carry-less_product
+ let mask_a = mask ^ (mask << 7u);
+ let mask_b = mask_a ^ (mask_a << 14u);
+ let mask0_exp = mask_b & 0x1010101u;
+ var mask0_signed = select(mask0_exp, u32(-i32(mask0_exp)), is_down);
+ let mask1_exp = (mask_b >> 4u) & 0x1010101u;
+ var mask1_signed = select(mask1_exp, u32(-i32(mask1_exp)), is_down);
+ if is_bump {
+ let bump_delta = select(u32(-0x1010101i), 0x1010101u, is_down);
+ mask0_signed += bump_delta;
+ mask1_signed += bump_delta;
+ }
+ atomicAdd(&sh_samples[pix_ix * 2u], mask0_signed);
+ atomicAdd(&sh_samples[pix_ix * 2u + 1u], mask1_signed);
+#endif
+#ifdef msaa16
+ var mask = mask_lut[mask_ix / 2u] >> ((mask_ix % 2u) * 16u);
+ mask &= 0xffffu;
+ // Intersect with y half-plane masks
+ if sub_ix == 0u && !is_bump {
+ let mask_shift = u32(round(16.0 * (xy0.y - f32(y))));
+ mask &= 0xffffu << mask_shift;
+ }
+ if last_pixel && xy1.x != 0.0 {
+ let mask_shift = u32(round(16.0 * (xy1.y - f32(y))));
+ mask &= ~(0xffffu << mask_shift);
+ }
+ // Similar logic as above, only a 16 bit mask is divided into
+ // two 8 bit halves first, then each is expanded as above.
+ // Mask is 0bABCD_EFGH_IJKL_MNOP. Expand to 4 32 bit words
+ // mask0_exp will be 0b0000_000M_0000_000N_0000_000O_0000_000P
+ // mask3_exp will be 0b0000_000A_0000_000B_0000_000C_0000_000D
+ let mask0 = mask & 0xffu;
+ // mask0_a = 0b0IJK_LMNO_*JKL_MNOP
+ let mask0_a = mask0 ^ (mask0 << 7u);
+ // mask0_b = 0b000I_JKLM_NO*J_KLMN_O*K_LMNO_*JKL_MNOP
+ // ^ ^ ^ ^ ^ ^ ^ ^
+ let mask0_b = mask0_a ^ (mask0_a << 14u);
+ let mask0_exp = mask0_b & 0x1010101u;
+ var mask0_signed = select(mask0_exp, u32(-i32(mask0_exp)), is_down);
+ let mask1_exp = (mask0_b >> 4u) & 0x1010101u;
+ var mask1_signed = select(mask1_exp, u32(-i32(mask1_exp)), is_down);
+ let mask1 = (mask >> 8u) & 0xffu;
+ let mask1_a = mask1 ^ (mask1 << 7u);
+ // mask1_a = 0b0ABC_DEFG_*BCD_EFGH
+ let mask1_b = mask1_a ^ (mask1_a << 14u);
+ // mask1_b = 0b000A_BCDE_FG*B_CDEF_G*C_DEFG_*BCD_EFGH
+ let mask2_exp = mask1_b & 0x1010101u;
+ var mask2_signed = select(mask2_exp, u32(-i32(mask2_exp)), is_down);
+ let mask3_exp = (mask1_b >> 4u) & 0x1010101u;
+ var mask3_signed = select(mask3_exp, u32(-i32(mask3_exp)), is_down);
+ if is_bump {
+ let bump_delta = select(u32(-0x1010101i), 0x1010101u, is_down);
+ mask0_signed += bump_delta;
+ mask1_signed += bump_delta;
+ mask2_signed += bump_delta;
+ mask3_signed += bump_delta;
+ }
+ atomicAdd(&sh_samples[pix_ix * 4u], mask0_signed);
+ atomicAdd(&sh_samples[pix_ix * 4u + 1u], mask1_signed);
+ atomicAdd(&sh_samples[pix_ix * 4u + 2u], mask2_signed);
+ atomicAdd(&sh_samples[pix_ix * 4u + 3u], mask3_signed);
+#endif
+ }
+ workgroupBarrier();
+ }
+ var area: array<f32, PIXELS_PER_THREAD>;
+ let major = (th_ix * PIXELS_PER_THREAD) >> 2u;
+ var packed_w = atomicLoad(&sh_winding[major]);
+ // Compute prefix sums of both `sh_winding` and `sh_winding_y`. Both
+ // use the same technique. First, a per-word prefix sum is computed
+ // of the 4 subwords within each word. The last subword is the sum
+ // (reduction) of that group of 4 values, and is stored to shared
+ // memory for broadcast to other threads. Then each thread computes
+ // the prefix by adding the preceding reduced values.
+ //
+ // Addition of 2 biased signed values is accomplished by adding the
+ // values, then subtracting the bias.
+ packed_w += (packed_w - 0x808080u) << 8u;
+ packed_w += (packed_w - 0x8080u) << 16u;
+ var packed_y = atomicLoad(&sh_winding_y[local_id.y >> 2u]);
+ packed_y += (packed_y - 0x808080u) << 8u;
+ packed_y += (packed_y - 0x8080u) << 16u;
+ var wind_y = (packed_y >> ((local_id.y & 3u) << 3u)) - 0x80u;
+ if (local_id.y & 3u) == 3u && local_id.x == 0u {
+ let prefix_y = wind_y;
+ atomicStore(&sh_winding_y_prefix[local_id.y >> 2u], prefix_y);
+ }
+ let prefix_x = ((packed_w >> 24u) - 0x80u) * 0x1010101u;
+ // reuse sh_winding to store prefix as well
+ atomicStore(&sh_winding[major], prefix_x);
+ workgroupBarrier();
+ for (var i = (major & ~3u); i < major; i++) {
+ packed_w += atomicLoad(&sh_winding[i]);
+ }
+ // packed_w now contains the winding numbers for a slice of 4 pixels,
+ // each relative to the top left of the row.
+ for (var i = 0u; i < (local_id.y >> 2u); i++) {
+ wind_y += atomicLoad(&sh_winding_y_prefix[i]);
+ }
+ // wind_y now contains the winding number of the top left of the row of
+ // pixels relative to the top left of the tile. Note that this is actually
+ // a signed quantity stored without bias.
+
+ // The winding number of a sample point is the sum of four levels of
+ // hierarchy:
+ // * The winding number of the top left of the tile (backdrop)
+ // * The winding number of the pixel row relative to tile (wind_y)
+ // * The winding number of the pixel relative to row (packed_w)
+ // * The winding number of the sample relative to pixel (sh_samples)
+ //
+ // Conceptually, we want to compute each of these total winding numbers
+ // for each sample within a pixel, then count the number that are non-zero.
+ // However, we apply a shortcut, partly to make the computation more
+ // efficient, and partly to avoid overflow of intermediate results.
+ //
+ // Here's the technique that's used. The `expected_zero` value contains
+ // the *negation* of the sum of the first three levels of the hierarchy.
+ // Thus, `sample - expected` is zero when the sum of all levels in the
+ // hierarchy is zero, and this is true when `sample = expected`. We
+ // compute this using SWAR techniques as follows: we compute the xor of
+ // all bits of `expected` (repeated to all subwords) against the packed
+ // samples, then the or-reduction of the bits within each subword. This
+ // value is 1 when the values are unequal, thus the sum is nonzero, and
+ // 0 when the sum is zero. These bits are then masked and counted.
+
+ for (var i = 0u; i < PIXELS_PER_THREAD; i++) {
+ let pix_ix = th_ix * PIXELS_PER_THREAD + i;
+ let minor = i; // assumes PIXELS_PER_THREAD == 4
+ let expected_zero = (((packed_w >> (minor * 8u)) + wind_y) & 0xffu) - u32(fill.backdrop);
+ // When the expected_zero value exceeds the range of what can be stored
+ // in a (biased) signed integer, then there is no sample value that can
+ // be equal to the expected value, thus all resulting bits are 1.
+ if expected_zero >= 256u {
+ area[i] = 1.0;
+ } else {
+#ifdef msaa8
+ let samples0 = atomicLoad(&sh_samples[pix_ix * 2u]);
+ let samples1 = atomicLoad(&sh_samples[pix_ix * 2u + 1u]);
+ let xored0 = (expected_zero * 0x1010101u) ^ samples0;
+ let xored0_2 = xored0 | (xored0 * 2u);
+ let xored1 = (expected_zero * 0x1010101u) ^ samples1;
+ let xored1_2 = xored1 | (xored1 >> 1u);
+ // xored2 contains 2-reductions from each word, interleaved
+ let xored2 = (xored0_2 & 0xAAAAAAAAu) | (xored1_2 & 0x55555555u);
+ // bits 4 * k + 2 and 4 * k + 3 contain 4-reductions
+ let xored4 = xored2 | (xored2 * 4u);
+ // bits 8 * k + 6 and 8 * k + 7 contain 8-reductions
+ let xored8 = xored4 | (xored4 * 16u);
+ area[i] = f32(countOneBits(xored8 & 0xC0C0C0C0u)) * 0.125;
+#endif
+#ifdef msaa16
+ let samples0 = atomicLoad(&sh_samples[pix_ix * 4u]);
+ let samples1 = atomicLoad(&sh_samples[pix_ix * 4u + 1u]);
+ let samples2 = atomicLoad(&sh_samples[pix_ix * 4u + 2u]);
+ let samples3 = atomicLoad(&sh_samples[pix_ix * 4u + 3u]);
+ let xored0 = (expected_zero * 0x1010101u) ^ samples0;
+ let xored0_2 = xored0 | (xored0 * 2u);
+ let xored1 = (expected_zero * 0x1010101u) ^ samples1;
+ let xored1_2 = xored1 | (xored1 >> 1u);
+ // xored01 contains 2-reductions from words 0 and 1, interleaved
+ let xored01 = (xored0_2 & 0xAAAAAAAAu) | (xored1_2 & 0x55555555u);
+ // bits 4 * k + 2 and 4 * k + 3 contain 4-reductions
+ let xored01_4 = xored01 | (xored01 * 4u);
+ let xored2 = (expected_zero * 0x1010101u) ^ samples2;
+ let xored2_2 = xored2 | (xored2 * 2u);
+ let xored3 = (expected_zero * 0x1010101u) ^ samples3;
+ let xored3_2 = xored3 | (xored3 >> 1u);
+ // xored23 contains 2-reductions from words 2 and 3, interleaved
+ let xored23 = (xored2_2 & 0xAAAAAAAAu) | (xored3_2 & 0x55555555u);
+ // bits 4 * k and 4 * k + 1 contain 4-reductions
+ let xored23_4 = xored23 | (xored23 >> 2u);
+ // each bit is a 4-reduction, with values from all 4 words
+ let xored4 = (xored01_4 & 0xCCCCCCCCu) | (xored23_4 & 0x33333333u);
+ // bits 8 * k + {4, 5, 6, 7} contain 8-reductions
+ let xored8 = xored4 | (xored4 * 16u);
+ area[i] = f32(countOneBits(xored8 & 0xF0F0F0F0u)) * 0.0625;
+#endif
+ }
+ }
+ *result = area;
+}
+
+// Path rendering specialized to the even-odd rule.
+//
+// This proceeds very much the same as `fill_path_ms`, but is simpler because
+// all winding numbers can be represented in one bit. Formally, addition is
+// modulo 2, or, equivalently, winding numbers are elements of GF(2). One
+// simplification is that we don't need to track the direction of crossings,
+// as both have the same effect on winding number.
+//
+// TODO: factor some logic out to reduce code duplication.
+fn fill_path_ms_evenodd(fill: CmdFill, local_id: vec2<u32>, result: ptr<function, array<f32, PIXELS_PER_THREAD>>) {
+ let n_segs = fill.size_and_rule >> 1u;
+ let th_ix = local_id.y * (TILE_WIDTH / PIXELS_PER_THREAD) + local_id.x;
+ if th_ix < TILE_HEIGHT {
+ if th_ix == 0u {
+ atomicStore(&sh_winding_y[th_ix], 0u);
+ }
+ atomicStore(&sh_winding[th_ix], 0u);
+ }
+ let sample_count = PIXELS_PER_THREAD;
+ for (var i = 0u; i < sample_count; i++) {
+ atomicStore(&sh_samples[th_ix * sample_count + i], 0u);
+ }
+ workgroupBarrier();
+ let n_batch = (n_segs + (WG_SIZE - 1u)) / WG_SIZE;
+ for (var batch = 0u; batch < n_batch; batch++) {
+ let seg_ix = batch * WG_SIZE + th_ix;
+ let seg_off = fill.seg_data + seg_ix;
+ var count = 0u;
+ let slice_size = min(n_segs - batch * WG_SIZE, WG_SIZE);
+ // TODO: might save a register rewriting this in terms of limit
+ if th_ix < slice_size {
+ let segment = segments[seg_off];
+ // Coordinates are relative to tile origin
+ let xy0 = segment.point0;
+ let xy1 = segment.point1;
+ var y_edge_f = f32(TILE_HEIGHT);
+ if xy0.x == 0.0 {
+ y_edge_f = xy0.y;
+ } else if xy1.x == 0.0 {
+ y_edge_f = xy1.y;
+ }
+ // discard horizontal lines aligned to pixel grid
+ if !(xy0.y == xy1.y && xy0.y == floor(xy0.y)) {
+ count = span(xy0.x, xy1.x) + span(xy0.y, xy1.y) - 1u;
+ }
+ let y_edge = u32(ceil(y_edge_f));
+ if y_edge < TILE_HEIGHT {
+ atomicXor(&sh_winding_y[0], 1u << y_edge);
+ }
+ }
+ // workgroup prefix sum of counts
+ sh_count[th_ix] = count;
+ let lg_n = firstLeadingBit(slice_size * 2u - 1u);
+ for (var i = 0u; i < lg_n; i++) {
+ workgroupBarrier();
+ if th_ix >= 1u << i {
+ count += sh_count[th_ix - (1u << i)];
+ }
+ workgroupBarrier();
+ sh_count[th_ix] = count;
+ }
+ let total = workgroupUniformLoad(&sh_count[slice_size - 1u]);
+ for (var i = th_ix; i < total; i += WG_SIZE) {
+ // binary search to find pixel
+ var lo = 0u;
+ var hi = slice_size;
+ let goal = i;
+ while hi > lo + 1u {
+ let mid = (lo + hi) >> 1u;
+ if goal >= sh_count[mid - 1u] {
+ lo = mid;
+ } else {
+ hi = mid;
+ }
+ }
+ let el_ix = lo;
+ let last_pixel = i + 1u == sh_count[el_ix];
+ let sub_ix = i - select(0u, sh_count[el_ix - 1u], el_ix > 0u);
+ let seg_off = fill.seg_data + batch * WG_SIZE + el_ix;
+ let segment = segments[seg_off];
+ let xy0_in = segment.point0;
+ let xy1_in = segment.point1;
+ let is_down = xy1_in.y >= xy0_in.y;
+ let xy0 = select(xy1_in, xy0_in, is_down);
+ let xy1 = select(xy0_in, xy1_in, is_down);
+
+ // Set up data for line rasterization
+ // Note: this is duplicated work if total count exceeds a workgroup.
+ // One alternative is to compute it in a separate dispatch.
+ let dx = abs(xy1.x - xy0.x);
+ let dy = xy1.y - xy0.y;
+ let idxdy = 1.0 / (dx + dy);
+ var a = dx * idxdy;
+ let is_positive_slope = xy1.x >= xy0.x;
+ let x_sign = select(-1.0, 1.0, is_positive_slope);
+ let xt0 = floor(xy0.x * x_sign);
+ let c = xy0.x * x_sign - xt0;
+ let y0i = floor(xy0.y);
+ let ytop = y0i + 1.0;
+ let b = min((dy * c + dx * (ytop - xy0.y)) * idxdy, ONE_MINUS_ULP);
+ let count_x = span(xy0.x, xy1.x) - 1u;
+ let count = count_x + span(xy0.y, xy1.y);
+ let robust_err = floor(a * (f32(count) - 1.0) + b) - f32(count_x);
+ if robust_err != 0.0 {
+ a -= ROBUST_EPSILON * sign(robust_err);
+ }
+ let x0i = i32(xt0 * x_sign + 0.5 * (x_sign - 1.0));
+ // Use line equation to plot pixel coordinates
+
+ let zf = a * f32(sub_ix) + b;
+ let z = floor(zf);
+ let x = x0i + i32(x_sign * z);
+ let y = i32(y0i) + i32(sub_ix) - i32(z);
+ var is_delta: bool;
+ // See comments in nonzero case.
+ var is_bump = false;
+ let zp = floor(a * f32(sub_ix - 1u) + b);
+ if sub_ix == 0u {
+ is_delta = y0i == xy0.y;
+ is_bump = xy0.x == 0.0;
+ } else {
+ is_delta = z == zp;
+ is_bump = is_positive_slope && !is_delta;
+ }
+ if u32(x) < TILE_WIDTH - 1u && u32(y) < TILE_HEIGHT {
+ if is_delta {
+ atomicXor(&sh_winding[y], 2u << u32(x));
+ }
+ }
+ // Apply sample mask
+ let mask_block = u32(is_positive_slope) * (MASK_WIDTH * MASK_HEIGHT / 2u);
+ let half_height = f32(MASK_HEIGHT / 2u);
+ let mask_row = floor(min(a * half_height, half_height - 1.0)) * f32(MASK_WIDTH);
+ let mask_col = floor((zf - z) * f32(MASK_WIDTH));
+ let mask_ix = mask_block + u32(mask_row + mask_col);
+ let pix_ix = u32(y) * TILE_WIDTH + u32(x);
+#ifdef msaa8
+ var mask = mask_lut[mask_ix / 4u] >> ((mask_ix % 4u) * 8u);
+ mask &= 0xffu;
+ // Intersect with y half-plane masks
+ if sub_ix == 0u && !is_bump {
+ let mask_shift = u32(round(8.0 * (xy0.y - f32(y))));
+ mask &= 0xffu << mask_shift;
+ }
+ if last_pixel && xy1.x != 0.0 {
+ let mask_shift = u32(round(8.0 * (xy1.y - f32(y))));
+ mask &= ~(0xffu << mask_shift);
+ }
+ if is_bump {
+ mask ^= 0xffu;
+ }
+ atomicXor(&sh_samples[pix_ix], mask);
+#endif
+#ifdef msaa16
+ var mask = mask_lut[mask_ix / 2u] >> ((mask_ix % 2u) * 16u);
+ mask &= 0xffffu;
+ // Intersect with y half-plane masks
+ if sub_ix == 0u && !is_bump {
+ let mask_shift = u32(round(16.0 * (xy0.y - f32(y))));
+ mask &= 0xffffu << mask_shift;
+ }
+ if last_pixel && xy1.x != 0.0 {
+ let mask_shift = u32(round(16.0 * (xy1.y - f32(y))));
+ mask &= ~(0xffffu << mask_shift);
+ }
+ if is_bump {
+ mask ^= 0xffffu;
+ }
+ atomicXor(&sh_samples[pix_ix], mask);
+#endif
+ }
+ workgroupBarrier();
+ }
+ var area: array<f32, PIXELS_PER_THREAD>;
+ var scan_x = atomicLoad(&sh_winding[local_id.y]);
+ // prefix sum over GF(2) is equivalent to carry-less multiplication
+ // by 0xFFFF
+ scan_x ^= scan_x << 1u;
+ scan_x ^= scan_x << 2u;
+ scan_x ^= scan_x << 4u;
+ scan_x ^= scan_x << 8u;
+ // scan_x contains the winding number parity for all pixels in the row
+ var scan_y = atomicLoad(&sh_winding_y[0]);
+ scan_y ^= scan_y << 1u;
+ scan_y ^= scan_y << 2u;
+ scan_y ^= scan_y << 4u;
+ scan_y ^= scan_y << 8u;
+ // winding number parity for the row of pixels is in the LSB of row_parity
+ let row_parity = (scan_y >> local_id.y) ^ u32(fill.backdrop);
+
+ for (var i = 0u; i < PIXELS_PER_THREAD; i++) {
+ let pix_ix = th_ix * PIXELS_PER_THREAD + i;
+ let samples = atomicLoad(&sh_samples[pix_ix]);
+ let pix_parity = row_parity ^ (scan_x >> (pix_ix % TILE_WIDTH));
+ // The LSB of pix_parity contains the sum of the first three levels
+ // of the hierarchy, thus the absolute winding number of the top left
+ // of the pixel.
+ let pix_mask = u32(-i32(pix_parity & 1u));
+ // pix_mask is pix_party broadcast to all bits in the word.
+#ifdef msaa8
+ area[i] = f32(countOneBits((samples ^ pix_mask) & 0xffu)) * 0.125;
+#endif
+#ifdef msaa16
+ area[i] = f32(countOneBits((samples ^ pix_mask) & 0xffffu)) * 0.0625;
+#endif
+ }
+ *result = area;
+}
+#endif // msaa
+
+// Error function approximation.
+//
+// https://raphlinus.github.io/graphics/2020/04/21/blurred-rounded-rects.html
+fn erf7(x: f32) -> f32 {
+ // Clamp to prevent overflow.
+ // Intermediate steps calculate pow(x, 14).
+ let y = clamp(x * 1.1283791671, -100.0, 100.0);
+ let yy = y * y;
+ let z = y + (0.24295 + (0.03395 + 0.0104 * yy) * yy) * (y * yy);
+ return z / sqrt(1.0 + z * z);
+}
+
+fn hypot(a: f32, b: f32) -> f32 {
+ return sqrt(a * a + b * b);
+}
+
+fn read_fill(cmd_ix: u32) -> CmdFill {
+ let size_and_rule = ptcl[cmd_ix + 1u];
+ let seg_data = ptcl[cmd_ix + 2u];
+ let backdrop = i32(ptcl[cmd_ix + 3u]);
+ return CmdFill(size_and_rule, seg_data, backdrop);
+}
+
+fn read_color(cmd_ix: u32) -> CmdColor {
+ let rgba_color = ptcl[cmd_ix + 1u];
+ return CmdColor(rgba_color);
+}
+
+fn read_blur_rect(cmd_ix: u32) -> CmdBlurRect {
+ let info_offset = ptcl[cmd_ix + 1u];
+ let rgba_color = ptcl[cmd_ix + 2u];
+
+ let m0 = bitcast<f32>(info[info_offset]);
+ let m1 = bitcast<f32>(info[info_offset + 1u]);
+ let m2 = bitcast<f32>(info[info_offset + 2u]);
+ let m3 = bitcast<f32>(info[info_offset + 3u]);
+ let matrx = vec4(m0, m1, m2, m3);
+ let xlat = vec2(bitcast<f32>(info[info_offset + 4u]), bitcast<f32>(info[info_offset + 5u]));
+ let width = bitcast<f32>(info[info_offset + 6u]);
+ let height = bitcast<f32>(info[info_offset + 7u]);
+ let radius = bitcast<f32>(info[info_offset + 8u]);
+ let std_dev = bitcast<f32>(info[info_offset + 9u]);
+
+ return CmdBlurRect(rgba_color, matrx, xlat, width, height, radius, std_dev);
+}
+
+fn read_lin_grad(cmd_ix: u32) -> CmdLinGrad {
+ let index_mode = ptcl[cmd_ix + 1u];
+ let index = index_mode >> 2u;
+ let extend_mode = index_mode & 0x3u;
+ let info_offset = ptcl[cmd_ix + 2u];
+ let line_x = bitcast<f32>(info[info_offset]);
+ let line_y = bitcast<f32>(info[info_offset + 1u]);
+ let line_c = bitcast<f32>(info[info_offset + 2u]);
+ return CmdLinGrad(index, extend_mode, line_x, line_y, line_c);
+}
+
+fn read_rad_grad(cmd_ix: u32) -> CmdRadGrad {
+ let index_mode = ptcl[cmd_ix + 1u];
+ let index = index_mode >> 2u;
+ let extend_mode = index_mode & 0x3u;
+ let info_offset = ptcl[cmd_ix + 2u];
+ let m0 = bitcast<f32>(info[info_offset]);
+ let m1 = bitcast<f32>(info[info_offset + 1u]);
+ let m2 = bitcast<f32>(info[info_offset + 2u]);
+ let m3 = bitcast<f32>(info[info_offset + 3u]);
+ let matrx = vec4(m0, m1, m2, m3);
+ let xlat = vec2(bitcast<f32>(info[info_offset + 4u]), bitcast<f32>(info[info_offset + 5u]));
+ let focal_x = bitcast<f32>(info[info_offset + 6u]);
+ let radius = bitcast<f32>(info[info_offset + 7u]);
+ let flags_kind = info[info_offset + 8u];
+ let flags = flags_kind >> 3u;
+ let kind = flags_kind & 0x7u;
+ return CmdRadGrad(index, extend_mode, matrx, xlat, focal_x, radius, kind, flags);
+}
+
+fn read_sweep_grad(cmd_ix: u32) -> CmdSweepGrad {
+ let index_mode = ptcl[cmd_ix + 1u];
+ let index = index_mode >> 2u;
+ let extend_mode = index_mode & 0x3u;
+ let info_offset = ptcl[cmd_ix + 2u];
+ let m0 = bitcast<f32>(info[info_offset]);
+ let m1 = bitcast<f32>(info[info_offset + 1u]);
+ let m2 = bitcast<f32>(info[info_offset + 2u]);
+ let m3 = bitcast<f32>(info[info_offset + 3u]);
+ let matrx = vec4(m0, m1, m2, m3);
+ let xlat = vec2(bitcast<f32>(info[info_offset + 4u]), bitcast<f32>(info[info_offset + 5u]));
+ let t0 = bitcast<f32>(info[info_offset + 6u]);
+ let t1 = bitcast<f32>(info[info_offset + 7u]);
+ return CmdSweepGrad(index, extend_mode, matrx, xlat, t0, t1);
+}
+
+fn read_image(cmd_ix: u32) -> CmdImage {
+ let info_offset = ptcl[cmd_ix + 1u];
+ let m0 = bitcast<f32>(info[info_offset]);
+ let m1 = bitcast<f32>(info[info_offset + 1u]);
+ let m2 = bitcast<f32>(info[info_offset + 2u]);
+ let m3 = bitcast<f32>(info[info_offset + 3u]);
+ let matrx = vec4(m0, m1, m2, m3);
+ let xlat = vec2(bitcast<f32>(info[info_offset + 4u]), bitcast<f32>(info[info_offset + 5u]));
+ let xy = info[info_offset + 6u];
+ let width_height = info[info_offset + 7u];
+ let sample_alpha = info[info_offset + 8u];
+ let alpha = f32(sample_alpha & 0xFFu) / 255.0;
+ let format = sample_alpha >> 15u;
+ let alpha_type = (sample_alpha >> 14u) & 0x1u;
+ let quality = (sample_alpha >> 12u) & 0x3u;
+ let x_extend = (sample_alpha >> 10u) & 0x3u;
+ let y_extend = (sample_alpha >> 8u) & 0x3u;
+ // The following are not intended to be bitcasts
+ let x = f32(xy >> 16u);
+ let y = f32(xy & 0xffffu);
+ let width = f32(width_height >> 16u);
+ let height = f32(width_height & 0xffffu);
+ return CmdImage(matrx, xlat, vec2(x, y), vec2(width, height), format, x_extend, y_extend, quality, alpha, alpha_type);
+}
+
+fn read_end_clip(cmd_ix: u32) -> CmdEndClip {
+ let blend = ptcl[cmd_ix + 1u];
+ let alpha = bitcast<f32>(ptcl[cmd_ix + 2u]);
+ return CmdEndClip(blend, alpha);
+}
+
+const PIXEL_FORMAT_RGBA: u32 = 0u;
+const PIXEL_FORMAT_BGRA: u32 = 1u;
+// Normalises subpixel order loaded from an image, based on the image's format.
+fn pixel_format(pixel: vec4f, format: u32) -> vec4f {
+ switch format {
+ case PIXEL_FORMAT_BGRA: {
+ // The conversion from RGBA to BGRA is its own inverse.
+ return pixel.bgra;
+ }
+ case PIXEL_FORMAT_RGBA, default: {
+ return pixel;
+ }
+ }
+}
+
+const ALPHA: u32 = 0u;
+const PREMULTIPLIED_ALPHA: u32 = 1u;
+// Premultiplies alpha if not already
+fn maybe_premul_alpha(pixel: vec4f, alpha_type: u32) -> vec4f {
+ switch alpha_type {
+ case PREMULTIPLIED_ALPHA: {
+ return blend_in(pixel);
+ }
+ case ALPHA, default: {
+ return blend_in(premul_alpha(pixel));
+ }
+ }
+}
+
+const EXTEND_PAD: u32 = 0u;
+const EXTEND_REPEAT: u32 = 1u;
+const EXTEND_REFLECT: u32 = 2u;
+fn extend_mode_normalized(t: f32, mode: u32) -> f32 {
+ switch mode {
+ case EXTEND_PAD: {
+ return clamp(t, 0.0, 1.0);
+ }
+ case EXTEND_REPEAT: {
+ return fract(t);
+ }
+ case EXTEND_REFLECT, default: {
+ return abs(t - 2.0 * round(0.5 * t));
+ }
+ }
+}
+
+fn extend_mode(t: f32, mode: u32, max: f32) -> f32 {
+ switch mode {
+ case EXTEND_PAD: {
+ return clamp(t, 0.0, max);
+ }
+ case EXTEND_REPEAT: {
+ return extend_mode_normalized(t / max, mode) * max;
+ }
+ case EXTEND_REFLECT, default: {
+ return extend_mode_normalized(t / max, mode) * max;
+ }
+ }
+}
+
+// Cubic resampler logic borrowed from Skia (same as CPU cubic_resampler function)
+// Mitchell-Netravali cubic filter coefficients with parameters B=1/3 and C=1/3
+const MF: array<vec4<f32>, 4> = array<vec4<f32>, 4>(
+ vec4<f32>(
+ (1.0 / 6.0) / 3.0,
+ -(3.0 / 6.0) / 3.0 - 1.0 / 3.0,
+ (3.0 / 6.0) / 3.0 + 2.0 * 1.0 / 3.0,
+ -(1.0 / 6.0) / 3.0 - 1.0 / 3.0
+ ),
+ vec4<f32>(
+ 1.0 - (2.0 / 6.0) / 3.0,
+ 0.0,
+ -3.0 + (12.0 / 6.0) / 3.0 + 1.0 / 3.0,
+ 2.0 - (9.0 / 6.0) / 3.0 - 1.0 / 3.0
+ ),
+ vec4<f32>(
+ (1.0 / 6.0) / 3.0,
+ (3.0 / 6.0) / 3.0 + 1.0 / 3.0,
+ 3.0 - (15.0 / 6.0) / 3.0 - 2.0 * 1.0 / 3.0,
+ -2.0 + (9.0 / 6.0) / 3.0 + 1.0 / 3.0
+ ),
+ vec4<f32>(
+ 0.0,
+ 0.0,
+ -1.0 / 3.0,
+ (1.0 / 6.0) / 3.0 + 1.0 / 3.0
+ )
+);
+
+// Calculate the weights for a single fractional value (same as CPU weights function)
+fn cubic_weights(fract: f32) -> vec4<f32> {
+ return vec4<f32>(
+ single_weight(fract, MF[0][0], MF[0][1], MF[0][2], MF[0][3]),
+ single_weight(fract, MF[1][0], MF[1][1], MF[1][2], MF[1][3]),
+ single_weight(fract, MF[2][0], MF[2][1], MF[2][2], MF[2][3]),
+ single_weight(fract, MF[3][0], MF[3][1], MF[3][2], MF[3][3])
+ );
+}
+
+// Calculate a weight based on the fractional value t and the cubic coefficients
+// This matches the CPU implementation exactly
+fn single_weight(t: f32, a: f32, b: f32, c: f32, d: f32) -> f32 {
+ return t * (t * (t * d + c) + b) + a;
+}
+
+// Bicubic filtering using Mitchell filter with B=1/3, C=1/3
+//
+// Cubic resampling consists of sampling the 16 surrounding pixels of the target point and
+// interpolating them with a cubic filter. The generated matrix is 4x4 and represent the coefficients
+// of the cubic function used to calculate weights based on the `x_fract` and `y_fract` of the
+// location we are looking at.
+//
+// This is adapted from the sparse-strips shader for the main Vello image path:
+// - the atlas is a single `texture_2d`, not a texture array
+// - each tap is premultiplied before filtering, matching the existing bilinear path
+fn bicubic_sample(
+ coords: vec2<f32>,
+ atlas_offset: vec2<f32>,
+ atlas_max: vec2<f32>,
+ alpha_type: u32,
+) -> vec4<f32> {
+ let frac_coords = fract(coords + vec2(0.5));
+ // Get cubic weights for x and y directions
+ let cx = cubic_weights(frac_coords.x);
+ let cy = cubic_weights(frac_coords.y);
+
+ // Sample 4x4 grid around coords
+ let s00 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(-1.5, -1.5), atlas_offset, atlas_max)), 0), alpha_type);
+ let s10 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(-0.5, -1.5), atlas_offset, atlas_max)), 0), alpha_type);
+ let s20 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(0.5, -1.5), atlas_offset, atlas_max)), 0), alpha_type);
+ let s30 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(1.5, -1.5), atlas_offset, atlas_max)), 0), alpha_type);
+
+ let s01 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(-1.5, -0.5), atlas_offset, atlas_max)), 0), alpha_type);
+ let s11 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(-0.5, -0.5), atlas_offset, atlas_max)), 0), alpha_type);
+ let s21 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(0.5, -0.5), atlas_offset, atlas_max)), 0), alpha_type);
+ let s31 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(1.5, -0.5), atlas_offset, atlas_max)), 0), alpha_type);
+
+ let s02 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(-1.5, 0.5), atlas_offset, atlas_max)), 0), alpha_type);
+ let s12 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(-0.5, 0.5), atlas_offset, atlas_max)), 0), alpha_type);
+ let s22 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(0.5, 0.5), atlas_offset, atlas_max)), 0), alpha_type);
+ let s32 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(1.5, 0.5), atlas_offset, atlas_max)), 0), alpha_type);
+
+ let s03 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(-1.5, 1.5), atlas_offset, atlas_max)), 0), alpha_type);
+ let s13 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(-0.5, 1.5), atlas_offset, atlas_max)), 0), alpha_type);
+ let s23 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(0.5, 1.5), atlas_offset, atlas_max)), 0), alpha_type);
+ let s33 = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(clamp(coords + vec2(1.5, 1.5), atlas_offset, atlas_max)), 0), alpha_type);
+
+ // Interpolate in x direction for each row
+ let row0 = cx.x * s00 + cx.y * s10 + cx.z * s20 + cx.w * s30;
+ let row1 = cx.x * s01 + cx.y * s11 + cx.z * s21 + cx.w * s31;
+ let row2 = cx.x * s02 + cx.y * s12 + cx.z * s22 + cx.w * s32;
+ let row3 = cx.x * s03 + cx.y * s13 + cx.z * s23 + cx.w * s33;
+ // Interpolate in y direction
+ let result = cy.x * row0 + cy.y * row1 + cy.z * row2 + cy.w * row3;
+
+ // Clamp alpha first, then clamp premultiplied color channels against it.
+ let a = clamp(result.a, 0.0, 1.0);
+ return vec4<f32>(clamp(result.rgb, vec3(0.0), vec3(a)), a);
+}
+
+const PIXELS_PER_THREAD = 4u;
+
+#ifndef msaa
+
+// Analytic area anti-aliasing.
+//
+// This is currently dead code if msaa is enabled, but it would be fairly straightforward
+// to wire this so it's a dynamic choice (even per-path).
+//
+// FIXME: This should return an array when https://github.com/gfx-rs/naga/issues/1930 is fixed.
+fn fill_path(fill: CmdFill, xy: vec2<f32>, result: ptr<function, array<f32, PIXELS_PER_THREAD>>) {
+ let n_segs = fill.size_and_rule >> 1u;
+ let even_odd = (fill.size_and_rule & 1u) != 0u;
+ var area: array<f32, PIXELS_PER_THREAD>;
+ let backdrop_f = f32(fill.backdrop);
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ area[i] = backdrop_f;
+ }
+ for (var i = 0u; i < n_segs; i++) {
+ let seg_off = fill.seg_data + i;
+ let segment = segments[seg_off];
+ let y = segment.point0.y - xy.y;
+ let delta = segment.point1 - segment.point0;
+ let y0 = clamp(y, 0.0, 1.0);
+ let y1 = clamp(y + delta.y, 0.0, 1.0);
+ let dy = y0 - y1;
+ if dy != 0.0 {
+ let vec_y_recip = 1.0 / delta.y;
+ let t0 = (y0 - y) * vec_y_recip;
+ let t1 = (y1 - y) * vec_y_recip;
+ let startx = segment.point0.x - xy.x;
+ let x0 = startx + t0 * delta.x;
+ let x1 = startx + t1 * delta.x;
+ let xmin0 = min(x0, x1);
+ let xmax0 = max(x0, x1);
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ let i_f = f32(i);
+ let xmin = min(xmin0 - i_f, 1.0) - 1.0e-6;
+ let xmax = xmax0 - i_f;
+ let b = min(xmax, 1.0);
+ let c = max(b, 0.0);
+ let d = max(xmin, 0.0);
+ let a = (b + 0.5 * (d * d - c * c) - xmin) / (xmax - xmin);
+ area[i] += a * dy;
+ }
+ }
+ let y_edge = sign(delta.x) * clamp(xy.y - segment.y_edge + 1.0, 0.0, 1.0);
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ area[i] += y_edge;
+ }
+ }
+ if even_odd {
+ // even-odd winding rule
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ let a = area[i];
+ area[i] = abs(a - 2.0 * round(0.5 * a));
+ }
+ } else {
+ // non-zero winding rule
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ area[i] = min(abs(area[i]), 1.0);
+ }
+ }
+ *result = area;
+}
+
+#endif
+
+// The X size should be 16 / PIXELS_PER_THREAD
+@compute @workgroup_size(4, 16)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+ @builtin(workgroup_id) wg_id: vec3<u32>,
+) {
+ if ptcl[0] == ~0u {
+ // An earlier stage has failed, don't try to render.
+ // We use ptcl[0] for this so we don't use up a binding for bump.
+ return;
+ }
+ let tile_ix = wg_id.y * config.width_in_tiles + wg_id.x;
+ let xy = vec2(f32(global_id.x * PIXELS_PER_THREAD), f32(global_id.y));
+ let local_xy = vec2(f32(local_id.x * PIXELS_PER_THREAD), f32(local_id.y));
+ var rgba: array<vec4<f32>, PIXELS_PER_THREAD>;
+ // raea: each colour read through blend_in and the blend stack through blend_out (linear-light blending, below)
+ let base_color = blend_in(unpack4x8unorm(config.base_color));
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ rgba[i] = base_color;
+ }
+ var blend_stack: array<array<u32, PIXELS_PER_THREAD>, BLEND_STACK_SPLIT>;
+ var clip_depth = 0u;
+ var area: array<f32, PIXELS_PER_THREAD>;
+ var cmd_ix = tile_ix * PTCL_INITIAL_ALLOC;
+ let blend_offset = ptcl[cmd_ix];
+ cmd_ix += 1u;
+ // main interpretation loop
+ while true {
+ let tag = ptcl[cmd_ix];
+ if tag == CMD_END {
+ break;
+ }
+ switch tag {
+ case CMD_FILL: {
+ let fill = read_fill(cmd_ix);
+#ifdef msaa
+ fill_path_ms(fill, local_id.xy, &area);
+#else
+ fill_path(fill, local_xy, &area);
+#endif
+ cmd_ix += 4u;
+ }
+ case CMD_SOLID: {
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ area[i] = 1.0;
+ }
+ cmd_ix += 1u;
+ }
+ case CMD_COLOR: {
+ let color = read_color(cmd_ix);
+ let fg = blend_in(unpack4x8unorm(color.rgba_color));
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ let fg_i = fg * area[i];
+ rgba[i] = rgba[i] * (1.0 - fg_i.a) + fg_i;
+ }
+ cmd_ix += 2u;
+ }
+ case CMD_BEGIN_CLIP: {
+ if clip_depth < BLEND_STACK_SPLIT {
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ blend_stack[clip_depth][i] = pack4x8unorm(blend_out(rgba[i]));
+ rgba[i] = vec4(0.0);
+ }
+ } else {
+ let blend_in_scratch = clip_depth - BLEND_STACK_SPLIT;
+ let local_tile_ix = local_id.x * PIXELS_PER_THREAD + local_id.y * TILE_WIDTH;
+ let local_blend_start = blend_offset + blend_in_scratch * TILE_WIDTH * TILE_HEIGHT + local_tile_ix;
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ blend_spill[local_blend_start + i] = pack4x8unorm(blend_out(rgba[i]));
+ rgba[i] = vec4(0.0);
+ }
+ }
+ clip_depth += 1u;
+ cmd_ix += 1u;
+ }
+ case CMD_END_CLIP: {
+ let end_clip = read_end_clip(cmd_ix);
+ clip_depth -= 1u;
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ var bg_rgba: u32;
+ if clip_depth < BLEND_STACK_SPLIT {
+ bg_rgba = blend_stack[clip_depth][i];
+ } else {
+ let blend_in_scratch = clip_depth - BLEND_STACK_SPLIT;
+ let local_tile_ix = local_id.x * PIXELS_PER_THREAD + local_id.y * TILE_WIDTH;
+ let local_blend_start = blend_offset + blend_in_scratch * TILE_WIDTH * TILE_HEIGHT + local_tile_ix;
+ bg_rgba = blend_spill[local_blend_start + i];
+ }
+ let bg = blend_in(unpack4x8unorm(bg_rgba));
+ let fg = rgba[i] * area[i] * end_clip.alpha;
+ if end_clip.blend == LUMINANCE_MASK_LAYER {
+ // TODO: Does this case apply more generally?
+ // See https://github.com/linebender/vello/issues/1061
+ // TODO: How do we handle anti-aliased edges here?
+ // This is really an imaging model question
+ if area[i] == 0f {
+ rgba[i] = bg;
+ continue;
+ }
+ let luminance = clamp(svg_lum(unpremultiply(fg)) * fg.a, 0.0, 1.0);
+ rgba[i] = bg * luminance;
+ } else {
+ rgba[i] = blend_mix_compose(bg, fg, end_clip.blend);
+ }
+ }
+ cmd_ix += 3u;
+ }
+ case CMD_JUMP: {
+ cmd_ix = ptcl[cmd_ix + 1u];
+ }
+ case CMD_BLUR_RECT: {
+ /// Approximation for the convolution of a gaussian filter with a rounded rectangle.
+ ///
+ /// See https://raphlinus.github.io/graphics/2020/04/21/blurred-rounded-rects.html
+
+ let blur = read_blur_rect(cmd_ix);
+
+ // Avoid division by 0
+ let std_dev = max(blur.std_dev, 1e-5);
+ let inv_std_dev = 1.0 / std_dev;
+
+ let min_edge = min(blur.width, blur.height);
+ let radius_max = 0.5 * min_edge;
+ let r0 = min(hypot(blur.radius, std_dev * 1.15), radius_max);
+ let r1 = min(hypot(blur.radius, std_dev * 2.0), radius_max);
+
+ let exponent = 2.0 * r1 / r0;
+ let inv_exponent = 1.0 / exponent;
+
+ // Pull in long end (make less eccentric).
+ let delta = 1.25 * std_dev * (exp(-pow(0.5 * inv_std_dev * blur.width, 2.0)) - exp(-pow(0.5 * inv_std_dev * blur.height, 2.0)));
+ let width = blur.width + min(delta, 0.0);
+ let height = blur.height - max(delta, 0.0);
+
+ let scale = 0.5 * erf7(inv_std_dev * 0.5 * (max(width, height) - 0.5 * blur.radius));
+
+ let blur_rgba = blend_in(unpack4x8unorm(blur.rgba_color));
+
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ // Transform fragment location to local 'uv' space of the rounded rectangle.
+ let my_xy = vec2(xy.x + f32(i), xy.y);
+ let local_xy = blur.matrx.xy * my_xy.x + blur.matrx.zw * my_xy.y + blur.xlat;
+ let x = local_xy.x;
+ let y = local_xy.y;
+
+ let y0 = abs(y) - (height * 0.5 - r1);
+ let y1 = max(y0, 0.0);
+
+ let x0 = abs(x) - (width * 0.5 - r1);
+ let x1 = max(x0, 0.0);
+
+ let d_pos = pow(pow(x1, exponent) + pow(y1, exponent), inv_exponent);
+ let d_neg = min(max(x0, y0), 0.0);
+ let d = d_pos + d_neg - r1;
+ let alpha = scale * (erf7(inv_std_dev * (min_edge + d)) - erf7(inv_std_dev * d));
+
+ let fg_rgba = blur_rgba * alpha;
+ let fg_i = fg_rgba * area[i];
+ rgba[i] = rgba[i] * (1.0 - fg_i.a) + fg_i;
+ }
+ cmd_ix += 3u;
+ }
+ case CMD_LIN_GRAD: {
+ let lin = read_lin_grad(cmd_ix);
+ let d = lin.line_x * xy.x + lin.line_y * xy.y + lin.line_c;
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ let my_d = d + lin.line_x * f32(i);
+ let x = i32(round(extend_mode_normalized(my_d, lin.extend_mode) * f32(GRADIENT_WIDTH - 1)));
+ let fg_rgba = blend_in(textureLoad(gradients, vec2(x, i32(lin.index)), 0));
+ let fg_i = fg_rgba * area[i];
+ rgba[i] = rgba[i] * (1.0 - fg_i.a) + fg_i;
+ }
+ cmd_ix += 3u;
+ }
+ case CMD_RAD_GRAD: {
+ let rad = read_rad_grad(cmd_ix);
+ let focal_x = rad.focal_x;
+ let radius = rad.radius;
+ let is_strip = rad.kind == RAD_GRAD_KIND_STRIP;
+ let is_circular = rad.kind == RAD_GRAD_KIND_CIRCULAR;
+ let is_focal_on_circle = rad.kind == RAD_GRAD_KIND_FOCAL_ON_CIRCLE;
+ let is_swapped = (rad.flags & RAD_GRAD_SWAPPED) != 0u;
+ let r1_recip = select(1.0 / radius, 0.0, is_circular);
+ let less_scale = select(1.0, -1.0, is_swapped || (1.0 - focal_x) < 0.0);
+ let t_sign = sign(1.0 - focal_x);
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ let my_xy = vec2(xy.x + f32(i), xy.y);
+ let local_xy = rad.matrx.xy * my_xy.x + rad.matrx.zw * my_xy.y + rad.xlat;
+ let x = local_xy.x;
+ let y = local_xy.y;
+ let xx = x * x;
+ let yy = y * y;
+ var t = 0.0;
+ var is_valid = true;
+ if is_strip {
+ let a = radius - yy;
+ t = sqrt(a) + x;
+ is_valid = a >= 0.0;
+ } else if is_focal_on_circle {
+ t = (xx + yy) / x;
+ is_valid = t >= 0.0 && x != 0.0;
+ } else if radius > 1.0 {
+ t = sqrt(xx + yy) - x * r1_recip;
+ } else { // radius < 1.0
+ let a = xx - yy;
+ t = less_scale * sqrt(a) - x * r1_recip;
+ is_valid = a >= 0.0 && t >= 0.0;
+ }
+ if is_valid {
+ t = extend_mode_normalized(focal_x + t_sign * t, rad.extend_mode);
+ t = select(t, 1.0 - t, is_swapped);
+ let x = i32(round(t * f32(GRADIENT_WIDTH - 1)));
+ let fg_rgba = blend_in(textureLoad(gradients, vec2(x, i32(rad.index)), 0));
+ let fg_i = fg_rgba * area[i];
+ rgba[i] = rgba[i] * (1.0 - fg_i.a) + fg_i;
+ }
+ }
+ cmd_ix += 3u;
+ }
+ case CMD_SWEEP_GRAD: {
+ let sweep = read_sweep_grad(cmd_ix);
+ let scale = 1.0 / (sweep.t1 - sweep.t0);
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ let my_xy = vec2(xy.x + f32(i), xy.y);
+ let local_xy = sweep.matrx.xy * my_xy.x + sweep.matrx.zw * my_xy.y + sweep.xlat;
+ let x = local_xy.x;
+ let y = local_xy.y;
+ // xy_to_unit_angle from Skia:
+ // See <https://github.com/google/skia/blob/30bba741989865c157c7a997a0caebe94921276b/src/opts/SkRasterPipeline_opts.h#L5859>
+ let xabs = abs(x);
+ let yabs = abs(y);
+ let slope = min(xabs, yabs) / max(xabs, yabs);
+ let s = slope * slope;
+ // again, from Skia:
+ // Use a 7th degree polynomial to approximate atan.
+ // This was generated using sollya.gforge.inria.fr.
+ // A float optimized polynomial was generated using the following command.
+ // P1 = fpminimax((1/(2*Pi))*atan(x),[|1,3,5,7|],[|24...|],[2^(-40),1],relative);
+ var phi = slope * (0.15912117063999176025390625f + s * (-5.185396969318389892578125e-2f + s * (2.476101927459239959716796875e-2f + s * (-7.0547382347285747528076171875e-3f))));
+ phi = select(phi, 1.0 / 4.0 - phi, xabs < yabs);
+ phi = select(phi, 1.0 / 2.0 - phi, x < 0.0);
+ phi = select(phi, 1.0 - phi, y < 0.0);
+ phi = select(phi, 0.0, phi != phi); // check for NaN
+ phi = (phi - sweep.t0) * scale;
+ let t = extend_mode_normalized(phi, sweep.extend_mode);
+ let ramp_x = i32(round(t * f32(GRADIENT_WIDTH - 1)));
+ let fg_rgba = blend_in(textureLoad(gradients, vec2(ramp_x, i32(sweep.index)), 0));
+ let fg_i = fg_rgba * area[i];
+ rgba[i] = rgba[i] * (1.0 - fg_i.a) + fg_i;
+ }
+ cmd_ix += 3u;
+ }
+ case CMD_IMAGE: {
+ let image = read_image(cmd_ix);
+ let atlas_max = image.atlas_offset + image.extents - vec2(1.0);
+ switch image.quality {
+ case IMAGE_QUALITY_LOW: {
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ // We only need to load from the textures if the value will be used.
+ if area[i] != 0.0 {
+ // Use pixel centers (+0.5) rather than pixel corners for correct sampling
+ let my_xy = vec2(xy.x + f32(i) + 0.5, xy.y + 0.5);
+ var atlas_uv = image.matrx.xy * my_xy.x + image.matrx.zw * my_xy.y + image.xlat;
+ atlas_uv.x = extend_mode(atlas_uv.x, image.x_extend_mode, image.extents.x);
+ atlas_uv.y = extend_mode(atlas_uv.y, image.y_extend_mode, image.extents.y);
+ atlas_uv = atlas_uv + image.atlas_offset;
+ // TODO: If the image couldn't be added to the atlas (i.e. was too big), this isn't robust
+ let atlas_uv_clamped = clamp(atlas_uv, image.atlas_offset, atlas_max);
+ // Nearest neighbor sampling
+ let fg_rgba = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(atlas_uv_clamped), 0), image.alpha_type);
+ let fg_i = pixel_format(fg_rgba * area[i] * image.alpha, image.format);
+ rgba[i] = rgba[i] * (1.0 - fg_i.a) + fg_i;
+ }
+ }
+ }
+ case IMAGE_QUALITY_MEDIUM, default: {
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ // We only need to load from the textures if the value will be used.
+ if area[i] != 0.0 {
+ // Use pixel centers (+0.5) rather than pixel corners for correct sampling
+ let my_xy = vec2(xy.x + f32(i) + 0.5, xy.y + 0.5);
+ var atlas_uv = image.matrx.xy * my_xy.x + image.matrx.zw * my_xy.y + image.xlat;
+ atlas_uv.x = extend_mode(atlas_uv.x, image.x_extend_mode, image.extents.x);
+ atlas_uv.y = extend_mode(atlas_uv.y, image.y_extend_mode, image.extents.y);
+ atlas_uv = atlas_uv + image.atlas_offset - vec2(0.5);
+ // TODO: If the image couldn't be added to the atlas (i.e. was too big), this isn't robust
+ let atlas_uv_clamped = clamp(atlas_uv, image.atlas_offset, atlas_max);
+ // We know that the floor and ceil are within the atlas area because atlas_max and
+ // atlas_offset are integers
+ let uv_quad = vec4(floor(atlas_uv_clamped), ceil(atlas_uv_clamped));
+ let uv_frac = fract(atlas_uv);
+ let a = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(uv_quad.xy), 0), image.alpha_type);
+ let b = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(uv_quad.xw), 0), image.alpha_type);
+ let c = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(uv_quad.zy), 0), image.alpha_type);
+ let d = maybe_premul_alpha(textureLoad(image_atlas, vec2<i32>(uv_quad.zw), 0), image.alpha_type);
+ // Bilinear sampling
+ let fg_rgba = mix(mix(a, b, uv_frac.y), mix(c, d, uv_frac.y), uv_frac.x);
+ let fg_i = pixel_format(fg_rgba * area[i] * image.alpha, image.format);
+ rgba[i] = rgba[i] * (1.0 - fg_i.a) + fg_i;
+ }
+ }
+ }
+ case IMAGE_QUALITY_HIGH: {
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ if area[i] != 0.0 {
+ // Use pixel centers (+0.5) rather than pixel corners for correct sampling
+ let my_xy = vec2(xy.x + f32(i) + 0.5, xy.y + 0.5);
+ var atlas_uv = image.matrx.xy * my_xy.x + image.matrx.zw * my_xy.y + image.xlat;
+ atlas_uv.x = extend_mode(atlas_uv.x, image.x_extend_mode, image.extents.x);
+ atlas_uv.y = extend_mode(atlas_uv.y, image.y_extend_mode, image.extents.y);
+ atlas_uv = atlas_uv + image.atlas_offset;
+ let fg_rgba = bicubic_sample(atlas_uv, image.atlas_offset, atlas_max, image.alpha_type);
+ let fg_i = pixel_format(fg_rgba * area[i] * image.alpha, image.format);
+ rgba[i] = rgba[i] * (1.0 - fg_i.a) + fg_i;
+ }
+ }
+ }
+ }
+ cmd_ix += 2u;
+ }
+ default: {}
+ }
+ }
+ let xy_uint = vec2<u32>(xy);
+ for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
+ let coords = xy_uint + vec2(i, 0u);
+ if coords.x < config.target_width && coords.y < config.target_height {
+ let fg = rgba[i];
+ // let fg = base_color * (1.0 - foreground.a) + foreground;
+ // Max with a small epsilon to avoid NaNs
+ let a_inv = 1.0 / max(fg.a, 1e-6);
+ let rgba_sep = straight_out(vec4(fg.rgb * a_inv, fg.a));
+ textureStore(output, vec2<i32>(coords), rgba_sep);
+ }
+ }
+}
+
+fn premul_alpha(rgba: vec4<f32>) -> vec4<f32> {
+ return vec4(rgba.rgb * rgba.a, rgba.a);
+}
+
+// raea: linear-light blending (config.blend_linear, vello_encoding's set_blend_linear), as bevy_ui's blending on an sRGB
+// target: every colour read (a premultiplied, sRGB-encoded colour, ramp or texel) made linear-light, the blend done
+// there, the blend stack kept sRGB-encoded so its 8 bits keep the darks, and the result encoded to sRGB once. Off,
+// each is as it was: Vello blends the encoded values, as Chrome does.
+fn srgb_decode(c: vec3<f32>) -> vec3<f32> {
+ return select(pow((c + 0.055) / 1.055, vec3(2.4)), c / 12.92, c <= vec3(0.04045));
+}
+fn srgb_encode(c: vec3<f32>) -> vec3<f32> {
+ return select(1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055, c * 12.92, c <= vec3(0.0031308));
+}
+fn blend_in(premul: vec4<f32>) -> vec4<f32> {
+ if config.blend_linear == 0u || premul.a <= 0.0 {
+ return premul;
+ }
+ return vec4(srgb_decode(clamp(premul.rgb / premul.a, vec3(0.0), vec3(1.0))) * premul.a, premul.a);
+}
+fn blend_out(premul: vec4<f32>) -> vec4<f32> {
+ if config.blend_linear == 0u || premul.a <= 0.0 {
+ return premul;
+ }
+ return vec4(srgb_encode(clamp(premul.rgb / premul.a, vec3(0.0), vec3(1.0))) * premul.a, premul.a);
+}
+fn straight_out(straight: vec4<f32>) -> vec4<f32> {
+ if config.blend_linear == 0u {
+ return straight;
+ }
+ return vec4(srgb_encode(clamp(straight.rgb, vec3(0.0), vec3(1.0))), straight.a);
+}
diff --git a/vendor/vello_shaders/shader/flatten.wgsl b/vendor/vello_shaders/shader/flatten.wgsl
new file mode 100644
index 00000000..aa0389d0
--- /dev/null
+++ b/vendor/vello_shaders/shader/flatten.wgsl
@@ -0,0 +1,923 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Flatten curves to lines
+
+#import config
+#import drawtag
+#import pathtag
+#import segment
+#import cubic
+#import bump
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage> scene: array<u32>;
+
+@group(0) @binding(2)
+var<storage> tag_monoids: array<TagMonoid>;
+
+struct AtomicPathBbox {
+ x0: atomic<i32>,
+ y0: atomic<i32>,
+ x1: atomic<i32>,
+ y1: atomic<i32>,
+ draw_flags: u32,
+ trans_ix: u32,
+}
+
+@group(0) @binding(3)
+var<storage, read_write> path_bboxes: array<AtomicPathBbox>;
+
+@group(0) @binding(4)
+var<storage, read_write> bump: BumpAllocators;
+
+@group(0) @binding(5)
+var<storage, read_write> lines: array<LineSoup>;
+
+struct SubdivResult {
+ val: f32,
+ a0: f32,
+ a2: f32,
+}
+
+const D = 0.67;
+fn approx_parabola_integral(x: f32) -> f32 {
+ return x * inverseSqrt(sqrt(1.0 - D + (D * D * D * D + 0.25 * x * x)));
+}
+
+const B = 0.39;
+fn approx_parabola_inv_integral(x: f32) -> f32 {
+ return x * sqrt(1.0 - B + (B * B + 0.5 * x * x));
+}
+
+// Functions for Euler spirals
+
+struct CubicParams {
+ th0: f32,
+ th1: f32,
+ chord_len: f32,
+ err: f32,
+}
+
+struct EulerParams {
+ th0: f32,
+ // th1 need not be explicitly stored, as it can be derived from k0 - th0
+ k0: f32,
+ k1: f32,
+ ch: f32,
+}
+
+struct EulerSeg {
+ p0: vec2f,
+ p1: vec2f,
+ params: EulerParams,
+}
+
+// Threshold below which a derivative is considered too small.
+const DERIV_THRESH: f32 = 1e-6;
+const DERIV_THRESH_SQUARED: f32 = DERIV_THRESH * DERIV_THRESH;
+// Amount to nudge t when derivative is near-zero.
+const DERIV_EPS: f32 = 1e-6;
+// Limit for subdivision of cubic Béziers.
+const SUBDIV_LIMIT: f32 = 1.0 / 65536.0;
+// Robust ESPC computation: below this value, treat curve as circular arc
+const K1_THRESH: f32 = 1e-3;
+// Robust ESPC: below this value, evaluate ES rather than parallel curve
+const DIST_THRESH: f32 = 1e-3;
+// Threshold for tangents to be considered near zero length
+const TANGENT_THRESH: f32 = 1e-6;
+
+/// Compute cubic parameters from endpoints and derivatives.
+fn cubic_from_points_derivs(p0: vec2f, p1: vec2f, q0: vec2f, q1: vec2f, dt: f32) -> CubicParams {
+ let chord = p1 - p0;
+ let chord_squared = dot(chord, chord);
+ let chord_len = sqrt(chord_squared);
+ if chord_squared < DERIV_THRESH_SQUARED {
+ let chord_err = sqrt((9. / 32.0) * (dot(q0, q0) + dot(q1, q1))) * dt;
+ return CubicParams(0.0, 0.0, DERIV_THRESH, chord_err);
+ }
+ let scale = dt / chord_squared;
+ let h0 = vec2(q0.x * chord.x + q0.y * chord.y, q0.y * chord.x - q0.x * chord.y);
+ let th0 = atan2(h0.y, h0.x);
+ let d0 = length(h0) * scale;
+ let h1 = vec2(q1.x * chord.x + q1.y * chord.y, q1.x * chord.y - q1.y * chord.x);
+ let th1 = atan2(h1.y, h1.x);
+ let d1 = length(h1) * scale;
+
+ // Estimate error of geometric Hermite interpolation to Euler spiral.
+ let cth0 = cos(th0);
+ let cth1 = cos(th1);
+ var err = 2.0;
+ if cth0 * cth1 >= 0.0 {
+ let e0 = (2. / 3.) / max(1.0 + cth0, 1e-9);
+ let e1 = (2. / 3.) / max(1.0 + cth1, 1e-9);
+ let s0 = sin(th0);
+ let s1 = sin(th1);
+ let s01 = cth0 * s1 + cth1 * s0;
+ let amin = 0.15 * (2. * e0 * s0 + 2. * e1 * s1 - e0 * e1 * s01);
+ let a = 0.15 * (2. * d0 * s0 + 2. * d1 * s1 - d0 * d1 * s01);
+ let aerr = abs(a - amin);
+ let symm = abs(th0 + th1);
+ let asymm = abs(th0 - th1);
+ let dist = length(vec2(d0 - e0, d1 - e1));
+ let symm2 = symm * symm;
+ let ctr = (4.625e-6 * symm * symm2 + 7.5e-3 * asymm) * symm2;
+ let halo = (5e-3 * symm + 7e-2 * asymm) * dist;
+ err = ctr + 1.55 * aerr + halo;
+ }
+ err *= chord_len;
+ return CubicParams(th0, th1, chord_len, err);
+}
+
+fn es_params_from_angles(th0: f32, th1: f32) -> EulerParams {
+ let k0 = th0 + th1;
+ let dth = th1 - th0;
+ let d2 = dth * dth;
+ let k2 = k0 * k0;
+ var a = 6.0;
+ a -= d2 * (1. / 70.);
+ a -= (d2 * d2) * (1. / 10780.);
+ a += (d2 * d2 * d2) * 2.769178184818219e-07;
+ let b = -0.1 + d2 * (1. / 4200.) + d2 * d2 * 1.6959677820260655e-05;
+ let c = -1. / 1400. + d2 * 6.84915970574303e-05 - k2 * 7.936475029053326e-06;
+ a += (b + c * k2) * k2;
+ let k1 = dth * a;
+
+ // calculation of chord
+ var ch = 1.0;
+ ch -= d2 * (1. / 40.);
+ ch += (d2 * d2) * 0.00034226190482569864;
+ ch -= (d2 * d2 * d2) * 1.9349474568904524e-06;
+ let b_ = -1. / 24. + d2 * 0.0024702380951963226 - d2 * d2 * 3.7297408997537985e-05;
+ let c_ = 1. / 1920. - d2 * 4.87350869747975e-05 - k2 * 3.1001936068463107e-06;
+ ch += (b_ + c_ * k2) * k2;
+ return EulerParams(th0, k0, k1, ch);
+}
+
+fn es_params_eval_th(params: EulerParams, t: f32) -> f32 {
+ return (params.k0 + 0.5 * params.k1 * (t - 1.0)) * t - params.th0;
+}
+
+// Integrate Euler spiral.
+fn integ_euler_10(k0: f32, k1: f32) -> vec2f {
+ let t1_1 = k0;
+ let t1_2 = 0.5 * k1;
+ let t2_2 = t1_1 * t1_1;
+ let t2_3 = 2. * (t1_1 * t1_2);
+ let t2_4 = t1_2 * t1_2;
+ let t3_4 = t2_2 * t1_2 + t2_3 * t1_1;
+ let t3_6 = t2_4 * t1_2;
+ let t4_4 = t2_2 * t2_2;
+ let t4_5 = 2. * (t2_2 * t2_3);
+ let t4_6 = 2. * (t2_2 * t2_4) + t2_3 * t2_3;
+ let t4_7 = 2. * (t2_3 * t2_4);
+ let t4_8 = t2_4 * t2_4;
+ let t5_6 = t4_4 * t1_2 + t4_5 * t1_1;
+ let t5_8 = t4_6 * t1_2 + t4_7 * t1_1;
+ let t6_6 = t4_4 * t2_2;
+ let t6_7 = t4_4 * t2_3 + t4_5 * t2_2;
+ let t6_8 = t4_4 * t2_4 + t4_5 * t2_3 + t4_6 * t2_2;
+ let t7_8 = t6_6 * t1_2 + t6_7 * t1_1;
+ let t8_8 = t6_6 * t2_2;
+ var u = 1.;
+ u -= (1. / 24.) * t2_2 + (1. / 160.) * t2_4;
+ u += (1. / 1920.) * t4_4 + (1. / 10752.) * t4_6 + (1. / 55296.) * t4_8;
+ u -= (1. / 322560.) * t6_6 + (1. / 1658880.) * t6_8;
+ u += (1. / 92897280.) * t8_8;
+ var v = (1. / 12.) * t1_2;
+ v -= (1. / 480.) * t3_4 + (1. / 2688.) * t3_6;
+ v += (1. / 53760.) * t5_6 + (1. / 276480.) * t5_8;
+ v -= (1. / 11612160.) * t7_8;
+ return vec2(u, v);
+}
+
+fn es_params_eval(params: EulerParams, t: f32) -> vec2f {
+ let thm = es_params_eval_th(params, t * 0.5);
+ let k0 = params.k0;
+ let k1 = params.k1;
+ let uv = integ_euler_10((k0 + k1 * (0.5 * t - 0.5)) * t, k1 * t * t);
+ let scale = t / params.ch;
+ let s = scale * sin(thm);
+ let c = scale * cos(thm);
+ let x = uv.x * c - uv.y * s;
+ let y = -uv.y * c - uv.x * s;
+ return vec2(x, y);
+}
+
+fn es_params_eval_with_offset(params: EulerParams, t: f32, offset: f32) -> vec2f {
+ let th = es_params_eval_th(params, t);
+ let v = offset * vec2f(sin(th), cos(th));
+ return es_params_eval(params, t) + v;
+}
+
+fn es_seg_from_params(p0: vec2f, p1: vec2f, params: EulerParams) -> EulerSeg {
+ return EulerSeg(p0, p1, params);
+}
+
+// Note: offset provided is scaled so that 1 = chord length
+fn es_seg_eval_with_offset(es: EulerSeg, t: f32, normalized_offset: f32) -> vec2f {
+ let chord = es.p1 - es.p0;
+ let xy = es_params_eval_with_offset(es.params, t, normalized_offset);
+ return es.p0 + vec2f(chord.x * xy.x - chord.y * xy.y, chord.x * xy.y + chord.y * xy.x);
+}
+
+fn pow_1_5_signed(x: f32) -> f32 {
+ return x * sqrt(abs(x));
+}
+
+const BREAK1: f32 = 0.8;
+const BREAK2: f32 = 1.25;
+const BREAK3: f32 = 2.1;
+const SIN_SCALE: f32 = 1.0976991822760038;
+const QUAD_A1: f32 = 0.6406;
+const QUAD_B1: f32 = -0.81;
+const QUAD_C1: f32 = 0.9148117935952064;
+const QUAD_A2: f32 = 0.5;
+const QUAD_B2: f32 = -0.156;
+const QUAD_C2: f32 = 0.16145779359520596;
+const QUAD_W1: f32 = 0.5 * QUAD_B1 / QUAD_A1;
+const QUAD_V1: f32 = 1.0 / QUAD_A1;
+const QUAD_U1: f32 = QUAD_W1 * QUAD_W1 - QUAD_C1 / QUAD_A1;
+const QUAD_W2: f32 = 0.5 * QUAD_B2 / QUAD_A2;
+const QUAD_V2: f32 = 1.0 / QUAD_A2;
+const QUAD_U2: f32 = QUAD_W2 * QUAD_W2 - QUAD_C2 / QUAD_A2;
+const FRAC_PI_4: f32 = 0.7853981633974483;
+const CBRT_9_8: f32 = 1.040041911525952;
+
+fn espc_int_approx(x: f32) -> f32 {
+ let y = abs(x);
+ var a: f32;
+ if y < BREAK1 {
+ a = sin(SIN_SCALE * y) * (1.0 / SIN_SCALE);
+ } else if y < BREAK2 {
+ a = (sqrt(8.0) / 3.0) * pow_1_5_signed(y - 1.0) + FRAC_PI_4;
+ } else {
+ let abc = select(vec3(QUAD_A2, QUAD_B2, QUAD_C2), vec3(QUAD_A1, QUAD_B1, QUAD_C1), y < BREAK3);
+ a = (abc.x * y + abc.y) * y + abc.z;
+ };
+ return a * sign(x);
+}
+
+fn espc_int_inv_approx(x: f32) -> f32 {
+ let y = abs(x);
+ var a: f32;
+ if y < 0.7010707591262915 {
+ a = asin(y * SIN_SCALE) * (1.0 / SIN_SCALE);
+ } else if y < 0.903249293595206 {
+ let b = y - FRAC_PI_4;
+ let u = pow(abs(b), 2. / 3.) * sign(b);
+ a = u * CBRT_9_8 + 1.0;
+ } else {
+ let uvw = select(vec3(QUAD_U2, QUAD_V2, QUAD_W2), vec3(QUAD_U1, QUAD_V1, QUAD_W1), y < 2.038857793595206);
+ a = sqrt(uvw.x + uvw.y * y) - uvw.z;
+ }
+ return a * sign(x);
+}
+
+struct PointDeriv {
+ point: vec2f,
+ deriv: vec2f,
+}
+
+fn eval_cubic_and_deriv(p0: vec2f, p1: vec2f, p2: vec2f, p3: vec2f, t: f32) -> PointDeriv {
+ let m = 1.0 - t;
+ let mm = m * m;
+ let mt = m * t;
+ let tt = t * t;
+ let p = p0 * (mm * m) + (p1 * (3.0 * mm) + p2 * (3.0 * mt) + p3 * tt) * t;
+ let q = (p1 - p0) * mm + (p2 - p1) * (2.0 * mt) + (p3 - p2) * tt;
+ return PointDeriv(p, q);
+}
+
+fn cubic_start_tangent(p0: vec2f, p1: vec2f, p2: vec2f, p3: vec2f) -> vec2f {
+ let EPS = 1e-12;
+ let d01 = p1 - p0;
+ let d02 = p2 - p0;
+ let d03 = p3 - p0;
+ return select(select(d03, d02, dot(d02, d02) > EPS), d01, dot(d01, d01) > EPS);
+}
+
+fn cubic_end_tangent(p0: vec2f, p1: vec2f, p2: vec2f, p3: vec2f) -> vec2f {
+ let EPS = 1e-12;
+ let d23 = p3 - p2;
+ let d13 = p3 - p1;
+ let d03 = p3 - p0;
+ return select(select(d03, d13, dot(d13, d13) > EPS), d23, dot(d23, d23) > EPS);
+}
+
+fn cubic_start_normal(p0: vec2f, p1: vec2f, p2: vec2f, p3: vec2f) -> vec2f {
+ let tangent = normalize(cubic_start_tangent(p0, p1, p2, p3));
+ return vec2(-tangent.y, tangent.x);
+}
+
+fn cubic_end_normal(p0: vec2f, p1: vec2f, p2: vec2f, p3: vec2f) -> vec2f {
+ let tangent = normalize(cubic_end_tangent(p0, p1, p2, p3));
+ return vec2(-tangent.y, tangent.x);
+}
+
+const ESPC_ROBUST_NORMAL = 0;
+const ESPC_ROBUST_LOW_K1 = 1;
+const ESPC_ROBUST_LOW_DIST = 2;
+
+// This function flattens a cubic Bézier by first converting it into Euler spiral
+// segments, and then computes a near-optimal flattening of the parallel curves of
+// the Euler spiral segments.
+fn flatten_euler(
+ cubic: CubicPoints,
+ path_ix: u32,
+ local_to_device: Transform,
+ offset: f32,
+ start_p: vec2f,
+ end_p: vec2f,
+) {
+ var p0: vec2f;
+ var p1: vec2f;
+ var p2: vec2f;
+ var p3: vec2f;
+ var scale: f32;
+ var transform: Transform;
+ var t_start = start_p;
+ var t_end = end_p;
+ if offset == 0. {
+ let t = local_to_device;
+ p0 = transform_apply(t, cubic.p0);
+ p1 = transform_apply(t, cubic.p1);
+ p2 = transform_apply(t, cubic.p2);
+ p3 = transform_apply(t, cubic.p3);
+ scale = 1.;
+ transform = transform_identity();
+ t_start = p0;
+ t_end = p3;
+ } else {
+ p0 = cubic.p0;
+ p1 = cubic.p1;
+ p2 = cubic.p2;
+ p3 = cubic.p3;
+
+ transform = local_to_device;
+ let mat = transform.mat;
+ // The scale is the semi-major axis of the ellipse given by the unit
+ // circle transformed by `transform`. This is the greater of the two
+ // singular values of the 2x2 `transform` matrix (ignoring
+ // translation).
+ scale = 0.5 * (length(vec2(mat.x + mat.w, mat.y - mat.z)) +
+ length(vec2(mat.x - mat.w, mat.y + mat.z)));
+ }
+
+ // Drop zero length lines. This is an exact equality test because dropping very short
+ // line segments may result in loss of watertightness.
+ if all(p0 == p1) && all(p0 == p2) && all(p0 == p3) {
+ return;
+ }
+
+ let tol = 0.25;
+ var t0_u = 0u;
+ var dt = 1.0;
+ var last_p = p0;
+ var last_q = p1 - p0;
+ if dot(last_q, last_q) < DERIV_THRESH_SQUARED {
+ last_q = eval_cubic_and_deriv(p0, p1, p2, p3, DERIV_EPS).deriv;
+ }
+ var last_t = 0.0;
+ var lp0 = t_start;
+ loop {
+ let t0 = f32(t0_u) * dt;
+ if t0 == 1.0 {
+ break;
+ }
+ var t1 = t0 + dt;
+ let this_p0 = last_p;
+ let this_q0 = last_q;
+ var this_pq1 = eval_cubic_and_deriv(p0, p1, p2, p3, t1);
+ if dot(this_pq1.deriv, this_pq1.deriv) < DERIV_THRESH_SQUARED {
+ let new_pq1 = eval_cubic_and_deriv(p0, p1, p2, p3, t1 - DERIV_EPS);
+ this_pq1.deriv = new_pq1.deriv;
+ if t1 < 1.0 {
+ this_pq1.point = new_pq1.point;
+ t1 = t1 - DERIV_EPS;
+ }
+ }
+ let actual_dt = t1 - last_t;
+ let cubic_params = cubic_from_points_derivs(this_p0, this_pq1.point, this_q0, this_pq1.deriv, actual_dt);
+ if cubic_params.err * scale <= tol || dt <= SUBDIV_LIMIT {
+ let euler_params = es_params_from_angles(cubic_params.th0, cubic_params.th1);
+ let es = es_seg_from_params(this_p0, this_pq1.point, euler_params);
+ let k0 = es.params.k0 - 0.5 * es.params.k1;
+ let k1 = es.params.k1;
+ let normalized_offset = offset / cubic_params.chord_len;
+ let dist_scaled = normalized_offset * es.params.ch;
+ let scale_multiplier = sqrt(0.125 * scale * cubic_params.chord_len / (es.params.ch * tol));
+ var a = 0.0;
+ var b = 0.0;
+ var integral = 0.0;
+ var int0 = 0.0;
+ var n_frac: f32;
+ var robust = ESPC_ROBUST_NORMAL;
+ if abs(k1) < K1_THRESH {
+ let k = es.params.k0;
+ n_frac = sqrt(abs(k * (k * dist_scaled + 1.0)));
+ robust = ESPC_ROBUST_LOW_K1;
+ } else if abs(dist_scaled) < DIST_THRESH {
+ a = k1;
+ b = k0;
+ int0 = pow_1_5_signed(b);
+ let int1 = pow_1_5_signed(a + b);
+ integral = int1 - int0;
+ n_frac = (2. / 3.) * integral / a;
+ robust = ESPC_ROBUST_LOW_DIST;
+ } else {
+ a = -2.0 * dist_scaled * k1;
+ b = -1.0 - 2.0 * dist_scaled * k0;
+ int0 = espc_int_approx(b);
+ let int1 = espc_int_approx(a + b);
+ integral = int1 - int0;
+ let k_peak = k0 - k1 * b / a;
+ let integrand_peak = sqrt(abs(k_peak * (k_peak * dist_scaled + 1.0)));
+ n_frac = integral * integrand_peak / a;
+ }
+ // Bound number of subdivisions to a reasonable number when the scale is huge.
+ // This may give slightly incorrect rendering but avoids hangs.
+ // TODO: aggressively cull to viewport
+ let n = clamp(ceil(n_frac * scale_multiplier), 1.0, 100.0);
+ for (var i = 0u; i < u32(n); i++) {
+ var lp1: vec2f;
+ if i + 1u == u32(n) && t1 == 1.0 {
+ lp1 = t_end;
+ } else {
+ let t = f32(i + 1u) / n;
+ var s = t;
+ if robust != ESPC_ROBUST_LOW_K1 {
+ let u = integral * t + int0;
+ var inv: f32;
+ if robust == ESPC_ROBUST_LOW_DIST {
+ inv = pow(abs(u), 2. / 3.) * sign(u);
+ } else {
+ inv = espc_int_inv_approx(u);
+ }
+ s = (inv - b) / a;
+ }
+ lp1 = es_seg_eval_with_offset(es, s, normalized_offset);
+ }
+ let l0 = select(lp1, lp0, offset >= 0.);
+ let l1 = select(lp0, lp1, offset >= 0.);
+ output_line_with_transform(path_ix, l0, l1, transform);
+ lp0 = lp1;
+ }
+ last_p = this_pq1.point;
+ last_q = this_pq1.deriv;
+ last_t = t1;
+ t0_u += 1u;
+ let shift = countTrailingZeros(t0_u);
+ t0_u >>= shift;
+ dt *= f32(1u << shift);
+ } else {
+ t0_u = t0_u * 2u;
+ dt *= 0.5;
+ }
+ }
+}
+
+// Flattens the circular arc that subtends the angle begin-center-end. It is assumed that
+// ||begin - center|| == ||end - center||. `begin`, `end`, and `center` are defined in the path's
+// local coordinate space.
+//
+// The direction of the arc is always a counter-clockwise (Y-down) rotation starting from `begin`,
+// towards `end`, centered at `center`, and will be subtended by `angle` (which is assumed to be
+// positive). A line segment will always be drawn from the arc's terminus to `end`, regardless of
+// `angle`.
+//
+// `begin`, `end`, center`, and `angle` should be chosen carefully to ensure a smooth arc with the
+// correct winding.
+fn flatten_arc(
+ path_ix: u32, begin: vec2f, end: vec2f, center: vec2f, angle: f32, transform: Transform
+) {
+ var p0 = transform_apply(transform, begin);
+ var r = begin - center;
+
+ let MIN_THETA = 0.0001;
+ let tol = 0.25;
+ let radius = max(tol, length(p0 - transform_apply(transform, center)));
+ let theta = max(MIN_THETA, 2. * acos(1. - tol / radius));
+
+ // Always output at least one line so that we always draw the chord.
+ let n_lines = max(1u, u32(ceil(angle / theta)));
+
+ let c = cos(theta);
+ let s = sin(theta);
+ let rot = mat2x2(c, -s, s, c);
+
+ let line_ix = atomicAdd(&bump.lines, n_lines);
+ for (var i = 0u; i < n_lines - 1u; i += 1u) {
+ r = rot * r;
+ let p1 = transform_apply(transform, center + r);
+ write_line(line_ix + i, path_ix, p0, p1);
+ p0 = p1;
+ }
+ let p1 = transform_apply(transform, end);
+ write_line(line_ix + n_lines - 1u, path_ix, p0, p1);
+}
+
+fn draw_cap(
+ path_ix: u32, cap_style: u32, point: vec2f,
+ cap0: vec2f, cap1: vec2f, offset_tangent: vec2f,
+ transform: Transform,
+) {
+ if cap_style == STYLE_FLAGS_CAP_ROUND {
+ flatten_arc(path_ix, cap0, cap1, point, 3.1415927, transform);
+ return;
+ }
+
+ var start = cap0;
+ var end = cap1;
+ let is_square = (cap_style == STYLE_FLAGS_CAP_SQUARE);
+ let line_ix = atomicAdd(&bump.lines, select(1u, 3u, is_square));
+ if is_square {
+ let v = offset_tangent;
+ let p0 = start + v;
+ let p1 = end + v;
+ write_line_with_transform(line_ix + 1u, path_ix, start, p0, transform);
+ write_line_with_transform(line_ix + 2u, path_ix, p1, end, transform);
+ start = p0;
+ end = p1;
+ }
+ write_line_with_transform(line_ix, path_ix, start, end, transform);
+}
+
+fn draw_join(
+ path_ix: u32, style_flags: u32, p0: vec2f,
+ tan_prev: vec2f, tan_next: vec2f,
+ n_prev: vec2f, n_next: vec2f,
+ transform: Transform,
+) {
+ var front0 = p0 + n_prev;
+ let front1 = p0 + n_next;
+ var back0 = p0 - n_next;
+ let back1 = p0 - n_prev;
+
+ let cr = tan_prev.x * tan_next.y - tan_prev.y * tan_next.x;
+ let d = dot(tan_prev, tan_next);
+
+ switch style_flags & STYLE_FLAGS_JOIN_MASK {
+ case STYLE_FLAGS_JOIN_BEVEL: {
+ output_two_lines_with_transform(path_ix, front0, front1, back0, back1, transform);
+ }
+ case STYLE_FLAGS_JOIN_MITER: {
+ let hypot = length(vec2f(cr, d));
+ let miter_limit = unpack2x16float(style_flags & STYLE_MITER_LIMIT_MASK)[0];
+
+ var line_ix: u32;
+ // Given the two tangents `tan_prev` and `tan_next` arranged tail-to-tail, the
+ // miter length ratio is `1 / |cos(theta/2)|`, where `theta` is the angle
+ // between the tangents.
+ //
+ // `hypot` is `|tan_prev| * |tan_next|` (since cr^2 + d^2 = |a|^2 |b|^2) and
+ // `hypot + d` is `2 * |tan_prev| * |tan_next| * cos^2(theta/2)`. After
+ // rearranging, the following tests whether `1/|cos(theta/2)| < miter_limit`.
+ //
+ // Also avoid the miter computation when `cr` is very small; the intersection
+ // math divides by `cr` and becomes numerically unstable for near-collinear
+ // tangents.
+ if 2. * hypot < (hypot + d) * miter_limit * miter_limit
+ && abs(cr) > TANGENT_THRESH * TANGENT_THRESH
+ {
+ let is_backside = cr > 0.;
+ let fp_last = select(front0, back1, is_backside);
+ let fp_this = select(front1, back0, is_backside);
+ let p = select(front0, back0, is_backside);
+
+ let v = fp_this - fp_last;
+ let h = (tan_prev.x * v.y - tan_prev.y * v.x) / cr;
+ let miter_pt = fp_this - tan_next * h;
+
+ line_ix = atomicAdd(&bump.lines, 3u);
+ write_line_with_transform(line_ix, path_ix, p, miter_pt, transform);
+ line_ix += 1u;
+
+ if is_backside {
+ back0 = miter_pt;
+ } else {
+ front0 = miter_pt;
+ }
+ } else {
+ line_ix = atomicAdd(&bump.lines, 2u);
+ }
+ write_line_with_transform(line_ix, path_ix, front0, front1, transform);
+ write_line_with_transform(line_ix + 1u, path_ix, back0, back1, transform);
+ }
+ case STYLE_FLAGS_JOIN_ROUND: {
+ var arc0: vec2f;
+ var arc1: vec2f;
+ var other0: vec2f;
+ var other1: vec2f;
+ if cr > 0. {
+ arc0 = back0;
+ arc1 = back1;
+ other0 = front0;
+ other1 = front1;
+ } else {
+ arc0 = front0;
+ arc1 = front1;
+ other0 = back0;
+ other1 = back1;
+ }
+ flatten_arc(path_ix, arc0, arc1, p0, abs(atan2(cr, d)), transform);
+ output_line_with_transform(path_ix, other0, other1, transform);
+ }
+ default: {}
+ }
+}
+
+fn read_f32_point(ix: u32) -> vec2f {
+ let x = bitcast<f32>(scene[pathdata_base + ix]);
+ let y = bitcast<f32>(scene[pathdata_base + ix + 1u]);
+ return vec2(x, y);
+}
+
+fn read_i16_point(ix: u32) -> vec2f {
+ let raw = scene[pathdata_base + ix];
+ let x = f32(i32(raw << 16u) >> 16u);
+ let y = f32(i32(raw) >> 16u);
+ return vec2(x, y);
+}
+
+struct Transform {
+ mat: vec4f,
+ translate: vec2f,
+}
+
+fn transform_identity() -> Transform {
+ return Transform(vec4(1., 0., 0., 1.), vec2(0.));
+}
+
+fn read_transform(transform_base: u32, ix: u32) -> Transform {
+ let base = transform_base + ix * 6u;
+ let c0 = bitcast<f32>(scene[base]);
+ let c1 = bitcast<f32>(scene[base + 1u]);
+ let c2 = bitcast<f32>(scene[base + 2u]);
+ let c3 = bitcast<f32>(scene[base + 3u]);
+ let c4 = bitcast<f32>(scene[base + 4u]);
+ let c5 = bitcast<f32>(scene[base + 5u]);
+ let mat = vec4(c0, c1, c2, c3);
+ let translate = vec2(c4, c5);
+ return Transform(mat, translate);
+}
+
+fn transform_apply(transform: Transform, p: vec2f) -> vec2f {
+ let px = fma(transform.mat.x, p.x, fma(transform.mat.z, p.y, transform.translate.x));
+ let py = fma(transform.mat.y, p.x, fma(transform.mat.w, p.y, transform.translate.y));
+ return vec2(px, py);
+}
+
+fn round_down(x: f32) -> i32 {
+ return i32(floor(x));
+}
+
+fn round_up(x: f32) -> i32 {
+ return i32(ceil(x));
+}
+
+struct PathTagData {
+ tag_byte: u32,
+ monoid: TagMonoid,
+}
+
+fn compute_tag_monoid(ix: u32) -> PathTagData {
+ let tag_word = scene[config.pathtag_base + (ix >> 2u)];
+ let shift = (ix & 3u) * 8u;
+ var tm = reduce_tag(tag_word & ((1u << shift) - 1u));
+ // TODO: this can be a read buf overflow. Conditionalize by tag byte?
+ tm = combine_tag_monoid(tag_monoids[ix >> 2u], tm);
+ var tag_byte = (tag_word >> shift) & 0xffu;
+ // We no longer encode an initial transform and style so these
+ // are off by one.
+ // Note: an alternative would be to adjust config.transform_base and
+ // config.style_base.
+ tm.trans_ix -= 1u;
+ tm.style_ix -= STYLE_SIZE_IN_WORDS;
+ return PathTagData(tag_byte, tm);
+}
+
+struct CubicPoints {
+ p0: vec2f,
+ p1: vec2f,
+ p2: vec2f,
+ p3: vec2f,
+}
+
+fn read_path_segment(tag: PathTagData, is_stroke: bool) -> CubicPoints {
+ var p0: vec2f;
+ var p1: vec2f;
+ var p2: vec2f;
+ var p3: vec2f;
+
+ var seg_type = tag.tag_byte & PATH_TAG_SEG_TYPE;
+ let pathseg_offset = tag.monoid.pathseg_offset;
+ let is_stroke_cap_marker = is_stroke && (tag.tag_byte & PATH_TAG_SUBPATH_END) != 0u;
+ let is_open = seg_type == PATH_TAG_QUADTO;
+
+ if (tag.tag_byte & PATH_TAG_F32) != 0u {
+ p0 = read_f32_point(pathseg_offset);
+ p1 = read_f32_point(pathseg_offset + 2u);
+ if seg_type >= PATH_TAG_QUADTO {
+ p2 = read_f32_point(pathseg_offset + 4u);
+ if seg_type == PATH_TAG_CUBICTO {
+ p3 = read_f32_point(pathseg_offset + 6u);
+ }
+ }
+ } else {
+ p0 = read_i16_point(pathseg_offset);
+ p1 = read_i16_point(pathseg_offset + 1u);
+ if seg_type >= PATH_TAG_QUADTO {
+ p2 = read_i16_point(pathseg_offset + 2u);
+ if seg_type == PATH_TAG_CUBICTO {
+ p3 = read_i16_point(pathseg_offset + 3u);
+ }
+ }
+ }
+
+ if is_stroke_cap_marker && is_open {
+ // The stroke cap marker for an open path is encoded as a quadto where the p1 and p2 store
+ // the start control point of the subpath and together with p2 forms the start tangent. p0
+ // is ignored.
+ //
+ // This is encoded this way because encoding this as a lineto would require adding a moveto,
+ // which would terminate the subpath too early (by setting the SUBPATH_END on the
+ // segment preceding the cap marker). This scheme is only used for strokes.
+ p0 = p1;
+ p1 = p2;
+ seg_type = PATH_TAG_LINETO;
+ }
+
+ // Degree-raise
+ if seg_type == PATH_TAG_LINETO {
+ p3 = p1;
+ p2 = p3 + (1.0 / 3.0) * (p0 - p3);
+ p1 = p0 + (1.0 / 3.0) * (p3 - p0);
+ } else if seg_type == PATH_TAG_QUADTO {
+ p3 = p2;
+ p2 = p1 + (1.0 / 3.0) * (p2 - p1);
+ p1 = p1 + (1.0 / 3.0) * (p0 - p1);
+ }
+
+ return CubicPoints(p0, p1, p2, p3);
+}
+
+// Writes a line into a the `lines` buffer at a pre-allocated location designated by `line_ix`.
+fn write_line(line_ix: u32, path_ix: u32, p0: vec2f, p1: vec2f) {
+ bbox = vec4(min(bbox.xy, min(p0, p1)), max(bbox.zw, max(p0, p1)));
+ if line_ix < config.lines_size {
+ lines[line_ix] = LineSoup(path_ix, p0, p1);
+ }
+}
+
+fn write_line_with_transform(line_ix: u32, path_ix: u32, p0: vec2f, p1: vec2f, t: Transform) {
+ let tp0 = transform_apply(t, p0);
+ let tp1 = transform_apply(t, p1);
+ write_line(line_ix, path_ix, tp0, tp1);
+}
+
+fn output_line(path_ix: u32, p0: vec2f, p1: vec2f) {
+ let line_ix = atomicAdd(&bump.lines, 1u);
+ write_line(line_ix, path_ix, p0, p1);
+}
+
+fn output_line_with_transform(path_ix: u32, p0: vec2f, p1: vec2f, transform: Transform) {
+ let line_ix = atomicAdd(&bump.lines, 1u);
+ write_line_with_transform(line_ix, path_ix, p0, p1, transform);
+}
+
+fn output_two_lines_with_transform(
+ path_ix: u32,
+ p00: vec2f, p01: vec2f,
+ p10: vec2f, p11: vec2f,
+ transform: Transform
+) {
+ let line_ix = atomicAdd(&bump.lines, 2u);
+ write_line_with_transform(line_ix, path_ix, p00, p01, transform);
+ write_line_with_transform(line_ix + 1u, path_ix, p10, p11, transform);
+}
+
+struct NeighboringSegment {
+ do_join: bool,
+
+ // Device-space start tangent vector
+ tangent: vec2f,
+}
+
+fn read_neighboring_segment(ix: u32) -> NeighboringSegment {
+ let tag = compute_tag_monoid(ix);
+ let pts = read_path_segment(tag, true);
+
+ let is_closed = (tag.tag_byte & PATH_TAG_SEG_TYPE) == PATH_TAG_LINETO;
+ let is_stroke_cap_marker = (tag.tag_byte & PATH_TAG_SUBPATH_END) != 0u;
+ let do_join = !is_stroke_cap_marker || is_closed;
+ var tangent = pts.p3 - pts.p0;
+ if !is_stroke_cap_marker {
+ tangent = cubic_start_tangent(pts.p0, pts.p1, pts.p2, pts.p3);
+ }
+ return NeighboringSegment(do_join, tangent);
+}
+
+// `pathdata_base` is decoded once and reused by helpers above.
+var<private> pathdata_base: u32;
+
+// This is the bounding box of the shape flattened by a single shader invocation. It gets modified
+// during LineSoup generation.
+var<private> bbox: vec4f;
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+) {
+ let ix = global_id.x;
+ pathdata_base = config.pathdata_base;
+ bbox = vec4(1e31, 1e31, -1e31, -1e31);
+
+ let tag = compute_tag_monoid(ix);
+ let path_ix = tag.monoid.path_ix;
+ let style_ix = tag.monoid.style_ix;
+ let trans_ix = tag.monoid.trans_ix;
+
+ let out = &path_bboxes[path_ix];
+ let style_flags = scene[config.style_base + style_ix];
+ // The fill bit is always set to 0 for strokes which represents a non-zero fill.
+ let draw_flags = select(DRAW_INFO_FLAGS_FILL_RULE_BIT, 0u, (style_flags & STYLE_FLAGS_FILL) == 0u);
+ if (tag.tag_byte & PATH_TAG_PATH) != 0u {
+ (*out).draw_flags = draw_flags;
+ (*out).trans_ix = trans_ix;
+ }
+ // Decode path data
+ let seg_type = tag.tag_byte & PATH_TAG_SEG_TYPE;
+ if seg_type != 0u {
+ let is_stroke = (style_flags & STYLE_FLAGS_STYLE) != 0u;
+ let transform = read_transform(config.transform_base, trans_ix);
+ let pts = read_path_segment(tag, is_stroke);
+
+ if is_stroke {
+ let linewidth = bitcast<f32>(scene[config.style_base + style_ix + 1u]);
+ let offset = 0.5 * linewidth;
+
+ let is_open = (tag.tag_byte & PATH_TAG_SEG_TYPE) != PATH_TAG_LINETO;
+ let is_stroke_cap_marker = (tag.tag_byte & PATH_TAG_SUBPATH_END) != 0u;
+ if is_stroke_cap_marker {
+ if is_open {
+ // Draw start cap
+ let tangent = pts.p3 - pts.p0;
+ let offset_tangent = offset * normalize(tangent);
+ let n = offset_tangent.yx * vec2f(-1., 1.);
+ draw_cap(path_ix, (style_flags & STYLE_FLAGS_START_CAP_MASK) >> 2u,
+ pts.p0, pts.p0 - n, pts.p0 + n, -offset_tangent, transform);
+ } else {
+ // Don't draw anything if the path is closed.
+ }
+ } else {
+ // Read the neighboring segment.
+ let neighbor = read_neighboring_segment(ix + 1u);
+ var tan_start = cubic_start_tangent(pts.p0, pts.p1, pts.p2, pts.p3);
+ if dot(tan_start, tan_start) < TANGENT_THRESH * TANGENT_THRESH {
+ tan_start = vec2(TANGENT_THRESH, 0.);
+ }
+ var tan_prev = cubic_end_tangent(pts.p0, pts.p1, pts.p2, pts.p3);
+ if dot(tan_prev, tan_prev) < TANGENT_THRESH * TANGENT_THRESH {
+ tan_prev = vec2(TANGENT_THRESH, 0.);
+ }
+ var tan_next = neighbor.tangent;
+ if dot(tan_next, tan_next) < TANGENT_THRESH * TANGENT_THRESH {
+ tan_next = vec2(TANGENT_THRESH, 0.);
+ }
+ let n_start = offset * normalize(vec2(-tan_start.y, tan_start.x));
+ let offset_tangent = offset * normalize(tan_prev);
+ let n_prev = offset_tangent.yx * vec2f(-1., 1.);
+ let n_next = offset * normalize(tan_next).yx * vec2f(-1., 1.);
+
+ // Render offset curves
+ flatten_euler(pts, path_ix, transform, offset, pts.p0 + n_start, pts.p3 + n_prev);
+ flatten_euler(pts, path_ix, transform, -offset, pts.p0 - n_start, pts.p3 - n_prev);
+
+ if neighbor.do_join {
+ draw_join(path_ix, style_flags, pts.p3, tan_prev, tan_next,
+ n_prev, n_next, transform);
+ } else {
+ // Draw end cap.
+ draw_cap(path_ix, (style_flags & STYLE_FLAGS_END_CAP_MASK),
+ pts.p3, pts.p3 + n_prev, pts.p3 - n_prev, offset_tangent, transform);
+ }
+ }
+ } else {
+ let offset = 0.;
+ flatten_euler(pts, path_ix, transform, offset, pts.p0, pts.p3);
+ }
+ // Update bounding box using atomics only. Computing a monoid is a
+ // potential future optimization.
+ if bbox.z > bbox.x || bbox.w > bbox.y {
+ atomicMin(&(*out).x0, round_down(bbox.x));
+ atomicMin(&(*out).y0, round_down(bbox.y));
+ atomicMax(&(*out).x1, round_up(bbox.z));
+ atomicMax(&(*out).y1, round_up(bbox.w));
+ }
+ }
+}
diff --git a/vendor/vello_shaders/shader/path_count.wgsl b/vendor/vello_shaders/shader/path_count.wgsl
new file mode 100644
index 00000000..9a489c20
--- /dev/null
+++ b/vendor/vello_shaders/shader/path_count.wgsl
@@ -0,0 +1,202 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Stage to compute counts of number of segments in each tile
+
+#import bump
+#import config
+#import segment
+#import tile
+
+// TODO: this is cut'n'pasted from path_coarse.
+struct AtomicTile {
+ backdrop: atomic<i32>,
+ segment_count_or_ix: atomic<u32>,
+}
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage, read_write> bump: BumpAllocators;
+
+@group(0) @binding(2)
+var<storage> lines: array<LineSoup>;
+
+@group(0) @binding(3)
+var<storage> paths: array<Path>;
+
+@group(0) @binding(4)
+var<storage, read_write> tile: array<AtomicTile>;
+
+@group(0) @binding(5)
+var<storage, read_write> seg_counts: array<SegmentCount>;
+
+// number of integer cells spanned by interval defined by a, b
+fn span(a: f32, b: f32) -> u32 {
+ return u32(max(ceil(max(a, b)) - floor(min(a, b)), 1.0));
+}
+
+// See cpu_shaders/util.rs for explanation of these.
+const ONE_MINUS_ULP: f32 = 0.99999994;
+const ROBUST_EPSILON: f32 = 2e-7;
+
+// Note regarding clipping to bounding box:
+//
+// We have to do the backdrop bumps for all tiles to the left of the bbox.
+// This should probably be a separate loop. This also causes a numerical
+// robustness issue.
+
+// This shader is dispatched with one thread for each line.
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+) {
+ let n_lines = atomicLoad(&bump.lines);
+ var count = 0u;
+ if global_id.x < n_lines {
+ let line = lines[global_id.x];
+ // coarse rasterization logic to count number of tiles touched by line
+ let is_down = line.p1.y >= line.p0.y;
+ let xy0 = select(line.p1, line.p0, is_down);
+ let xy1 = select(line.p0, line.p1, is_down);
+ let s0 = xy0 * TILE_SCALE;
+ let s1 = xy1 * TILE_SCALE;
+ let count_x = span(s0.x, s1.x) - 1u;
+ count = count_x + span(s0.y, s1.y);
+ let line_ix = global_id.x;
+
+ let dx = abs(s1.x - s0.x);
+ let dy = s1.y - s0.y;
+ if dx + dy == 0.0 {
+ // Zero-length segment, drop it. Note, this could be culled in the
+ // flattening stage, but eliding the test here would be fragile, as
+ // it would be pretty bad to let it slip through.
+ return;
+ }
+ if dy == 0.0 && floor(s0.y) == s0.y {
+ return;
+ }
+ let idxdy = 1.0 / (dx + dy);
+ var a = dx * idxdy;
+ let is_positive_slope = s1.x >= s0.x;
+ let x_sign = select(-1.0, 1.0, is_positive_slope);
+ let xt0 = floor(s0.x * x_sign);
+ let c = s0.x * x_sign - xt0;
+ let y0 = floor(s0.y);
+ let ytop = select(y0 + 1.0, ceil(s0.y), s0.y == s1.y);
+ let b = min((dy * c + dx * (ytop - s0.y)) * idxdy, ONE_MINUS_ULP);
+ let robust_err = floor(a * (f32(count) - 1.0) + b) - f32(count_x);
+ if robust_err != 0.0 {
+ a -= ROBUST_EPSILON * sign(robust_err);
+ }
+ let x0 = xt0 * x_sign + select(-1.0, 0.0, is_positive_slope);
+
+ let path = paths[line.path_ix];
+ let bbox = vec4<i32>(path.bbox);
+ let xmin = min(s0.x, s1.x);
+ // If line is to left of bbox, we may still need to do backdrop
+ let stride = bbox.z - bbox.x;
+ if s0.y >= f32(bbox.w) || s1.y <= f32(bbox.y) || xmin >= f32(bbox.z) || stride == 0 {
+ return;
+ }
+ // Clip line to bounding box. Clipping is done in "i" space.
+ var imin = 0u;
+ if s0.y < f32(bbox.y) {
+ var iminf = round((f32(bbox.y) - y0 + b - a) / (1.0 - a)) - 1.0;
+ // Numerical robustness: goal is to find the first i value for which
+ // the following predicate is false. Above formula is designed to
+ // undershoot by 0.5.
+ if y0 + iminf - floor(a * iminf + b) < f32(bbox.y) {
+ iminf += 1.0;
+ }
+ imin = u32(iminf);
+ }
+ var imax = count;
+ if s1.y > f32(bbox.w) {
+ var imaxf = round((f32(bbox.w) - y0 + b - a) / (1.0 - a)) - 1.0;
+ if y0 + imaxf - floor(a * imaxf + b) < f32(bbox.w) {
+ imaxf += 1.0;
+ }
+ imax = u32(imaxf);
+ }
+ let delta = select(1, -1, is_down);
+ var ymin = 0;
+ var ymax = 0;
+ if max(s0.x, s1.x) <= f32(bbox.x) {
+ ymin = i32(ceil(s0.y));
+ ymax = i32(ceil(s1.y));
+ imax = imin;
+ } else {
+ let fudge = select(1.0, 0.0, is_positive_slope);
+ if xmin < f32(bbox.x) {
+ var f = round((x_sign * (f32(bbox.x) - x0) - b + fudge) / a);
+ if (x0 + x_sign * floor(a * f + b) < f32(bbox.x)) == is_positive_slope {
+ f += 1.0;
+ }
+ let ynext = i32(y0 + f - floor(a * f + b) + 1.0);
+ if is_positive_slope {
+ if u32(f) > imin {
+ ymin = i32(y0 + select(1.0, 0.0, y0 == s0.y));
+ ymax = ynext;
+ imin = u32(f);
+ }
+ } else {
+ if u32(f) < imax {
+ ymin = ynext;
+ ymax = i32(ceil(s1.y));
+ imax = u32(f);
+ }
+ }
+ }
+ if max(s0.x, s1.x) > f32(bbox.z) {
+ var f = round((x_sign * (f32(bbox.z) - x0) - b + fudge) / a);
+ if (x0 + x_sign * floor(a * f + b) < f32(bbox.z)) == is_positive_slope {
+ f += 1.0;
+ }
+ if is_positive_slope {
+ imax = min(imax, u32(f));
+ } else {
+ imin = max(imin, u32(f));
+ }
+ }
+ }
+ imax = max(imin, imax);
+ // Apply backdrop for part of line left of bbox
+ ymin = max(ymin, bbox.y);
+ ymax = min(ymax, bbox.w);
+ for (var y = ymin; y < ymax; y++) {
+ let base = i32(path.tiles) + (y - bbox.y) * stride;
+ atomicAdd(&tile[base].backdrop, delta);
+ }
+ var last_z = floor(a * (f32(imin) - 1.0) + b);
+ let seg_base = atomicAdd(&bump.seg_counts, imax - imin);
+ for (var i = imin; i < imax; i++) {
+ let subix = i;
+ // coarse rasterization logic
+ // Note: we hope fast-math doesn't strength reduce this.
+ let zf = a * f32(subix) + b;
+ let z = floor(zf);
+ // x, y are tile coordinates relative to render target
+ let y = i32(y0 + f32(subix) - z);
+ let x = i32(x0 + x_sign * z);
+ let base = i32(path.tiles) + (y - bbox.y) * stride - bbox.x;
+ let top_edge = select(last_z == z, y0 == s0.y, subix == 0u);
+ if top_edge && x + 1 < bbox.z {
+ let x_bump = max(x + 1, bbox.x);
+ atomicAdd(&tile[base + x_bump].backdrop, delta);
+ }
+ let seg_within_slice = atomicAdd(&tile[base + x].segment_count_or_ix, 1u);
+ // Pack two count values into a single u32
+ let counts = (seg_within_slice << 16u) | subix;
+ let seg_count = SegmentCount(line_ix, counts);
+ let seg_ix = seg_base + i - imin;
+ if seg_ix < config.seg_counts_size {
+ seg_counts[seg_ix] = seg_count;
+ }
+ // Note: since we're iterating, we have a reliable value for
+ // last_z.
+ last_z = z;
+ }
+ }
+}
diff --git a/vendor/vello_shaders/shader/path_count_setup.wgsl b/vendor/vello_shaders/shader/path_count_setup.wgsl
new file mode 100644
index 00000000..2daa7fd1
--- /dev/null
+++ b/vendor/vello_shaders/shader/path_count_setup.wgsl
@@ -0,0 +1,27 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Set up dispatch size for path count stage.
+
+#import bump
+
+@group(0) @binding(0)
+var<storage, read_write> bump: BumpAllocators;
+
+@group(0) @binding(1)
+var<storage, read_write> indirect: IndirectCount;
+
+// Partition size for path count stage
+const WG_SIZE = 256u;
+
+@compute @workgroup_size(1)
+fn main() {
+ if atomicLoad(&bump.failed) != 0u {
+ indirect.count_x = 0u;
+ } else {
+ let lines = atomicLoad(&bump.lines);
+ indirect.count_x = (lines + (WG_SIZE - 1u)) / WG_SIZE;
+ }
+ indirect.count_y = 1u;
+ indirect.count_z = 1u;
+}
diff --git a/vendor/vello_shaders/shader/path_tiling.wgsl b/vendor/vello_shaders/shader/path_tiling.wgsl
new file mode 100644
index 00000000..e15dc75b
--- /dev/null
+++ b/vendor/vello_shaders/shader/path_tiling.wgsl
@@ -0,0 +1,173 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Write path segments
+
+#import bump
+#import config
+#import segment
+#import tile
+
+@group(0) @binding(0)
+var<storage, read_write> bump: BumpAllocators;
+
+@group(0) @binding(1)
+var<storage> seg_counts: array<SegmentCount>;
+
+@group(0) @binding(2)
+var<storage> lines: array<LineSoup>;
+
+@group(0) @binding(3)
+var<storage> paths: array<Path>;
+
+@group(0) @binding(4)
+var<storage> tiles: array<Tile>;
+
+@group(0) @binding(5)
+var<storage, read_write> segments: array<Segment>;
+
+fn span(a: f32, b: f32) -> u32 {
+ return u32(max(ceil(max(a, b)) - floor(min(a, b)), 1.0));
+}
+
+// See cpu_shaders/util.rs for explanation of these.
+const ONE_MINUS_ULP: f32 = 0.99999994;
+const ROBUST_EPSILON: f32 = 2e-7;
+
+// One invocation for each tile that is to be written.
+// Total number of invocations = bump.seg_counts
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+) {
+ let n_segments = atomicLoad(&bump.seg_counts);
+ if global_id.x < n_segments {
+ let seg_count = seg_counts[global_id.x];
+ let line = lines[seg_count.line_ix];
+ let counts = seg_count.counts;
+ let seg_within_slice = counts >> 16u;
+ let seg_within_line = counts & 0xffffu;
+
+ // coarse rasterization logic
+ let is_down = line.p1.y >= line.p0.y;
+ var xy0 = select(line.p1, line.p0, is_down);
+ var xy1 = select(line.p0, line.p1, is_down);
+ let s0 = xy0 * TILE_SCALE;
+ let s1 = xy1 * TILE_SCALE;
+ let count_x = span(s0.x, s1.x) - 1u;
+ let count = count_x + span(s0.y, s1.y);
+ let dx = abs(s1.x - s0.x);
+ let dy = s1.y - s0.y;
+ // Division by zero can't happen because zero-length lines
+ // have already been discarded in the path_count stage.
+ let idxdy = 1.0 / (dx + dy);
+ var a = dx * idxdy;
+ let is_positive_slope = s1.x >= s0.x;
+ let x_sign = select(-1.0, 1.0, is_positive_slope);
+ let xt0 = floor(s0.x * x_sign);
+ let c = s0.x * x_sign - xt0;
+ let y0i = floor(s0.y);
+ let ytop = select(y0i + 1.0, ceil(s0.y), s0.y == s1.y);
+ let b = min((dy * c + dx * (ytop - s0.y)) * idxdy, ONE_MINUS_ULP);
+ let robust_err = floor(a * (f32(count) - 1.0) + b) - f32(count_x);
+ if robust_err != 0.0 {
+ a -= ROBUST_EPSILON * sign(robust_err);
+ }
+ let x0i = i32(xt0 * x_sign + 0.5 * (x_sign - 1.0));
+ let z = floor(a * f32(seg_within_line) + b);
+ let x = x0i + i32(x_sign * z);
+ let y = i32(y0i + f32(seg_within_line) - z);
+
+ let path = paths[line.path_ix];
+ let bbox = vec4<i32>(path.bbox);
+ let stride = bbox.z - bbox.x;
+ let tile_ix = i32(path.tiles) + (y - bbox.y) * stride + x - bbox.x;
+ let tile = tiles[tile_ix];
+ let seg_start = ~tile.segment_count_or_ix;
+ if i32(seg_start) < 0 {
+ return;
+ }
+ let tile_xy = vec2(f32(x) * f32(TILE_WIDTH), f32(y) * f32(TILE_HEIGHT));
+ let tile_xy1 = tile_xy + vec2(f32(TILE_WIDTH), f32(TILE_HEIGHT));
+
+ if seg_within_line > 0u {
+ let z_prev = floor(a * (f32(seg_within_line) - 1.0) + b);
+ if z == z_prev {
+ // Top edge is clipped
+ var xt = xy0.x + (xy1.x - xy0.x) * (tile_xy.y - xy0.y) / (xy1.y - xy0.y);
+ // TODO: we want to switch to tile-relative coordinates
+ xt = clamp(xt, tile_xy.x + 1e-3, tile_xy1.x);
+ xy0 = vec2(xt, tile_xy.y);
+ } else {
+ // If is_positive_slope, left edge is clipped, otherwise right
+ let x_clip = select(tile_xy1.x, tile_xy.x, is_positive_slope);
+ var yt = xy0.y + (xy1.y - xy0.y) * (x_clip - xy0.x) / (xy1.x - xy0.x);
+ yt = clamp(yt, tile_xy.y + 1e-3, tile_xy1.y);
+ xy0 = vec2(x_clip, yt);
+ }
+ }
+ if seg_within_line < count - 1u {
+ let z_next = floor(a * (f32(seg_within_line) + 1.0) + b);
+ if z == z_next {
+ // Bottom edge is clipped
+ var xt = xy0.x + (xy1.x - xy0.x) * (tile_xy1.y - xy0.y) / (xy1.y - xy0.y);
+ xt = clamp(xt, tile_xy.x + 1e-3, tile_xy1.x);
+ xy1 = vec2(xt, tile_xy1.y);
+ } else {
+ // If is_positive_slope, right edge is clipped, otherwise left
+ let x_clip = select(tile_xy.x, tile_xy1.x, is_positive_slope);
+ var yt = xy0.y + (xy1.y - xy0.y) * (x_clip - xy0.x) / (xy1.x - xy0.x);
+ yt = clamp(yt, tile_xy.y + 1e-3, tile_xy1.y);
+ xy1 = vec2(x_clip, yt);
+ }
+ }
+ var y_edge = 1e9;
+ // Apply numerical robustness logic
+ var p0 = xy0 - tile_xy;
+ var p1 = xy1 - tile_xy;
+ // When we move to f16, this will be f16::MIN_POSITIVE
+ let EPSILON = 1e-6;
+ if p0.x == 0.0 {
+ if p1.x == 0.0 {
+ p0.x = EPSILON;
+ if p0.y == 0.0 {
+ // Entire tile
+ p1.x = EPSILON;
+ p1.y = f32(TILE_HEIGHT);
+ } else {
+ // Make segment disappear
+ p1.x = 2.0 * EPSILON;
+ p1.y = p0.y;
+ }
+ } else if p0.y == 0.0 {
+ p0.x = EPSILON;
+ } else {
+ y_edge = p0.y;
+ }
+ } else if p1.x == 0.0 {
+ if p1.y == 0.0 {
+ p1.x = EPSILON;
+ } else {
+ y_edge = p1.y;
+ }
+ }
+ // Hacky approach to numerical robustness in fine.
+ // This just makes sure there are no vertical lines aligned to
+ // the pixel grid internal to the tile. It's faster to do this
+ // logic here rather than in fine, but at some point we might
+ // rework it.
+ if p0.x == floor(p0.x) && p0.x != 0.0 {
+ p0.x -= EPSILON;
+ }
+ if p1.x == floor(p1.x) && p1.x != 0.0 {
+ p1.x -= EPSILON;
+ }
+ if !is_down {
+ let tmp = p0;
+ p0 = p1;
+ p1 = tmp;
+ }
+ let segment = Segment(p0, p1, y_edge);
+ segments[seg_start + seg_within_slice] = segment;
+ }
+}
diff --git a/vendor/vello_shaders/shader/path_tiling_setup.wgsl b/vendor/vello_shaders/shader/path_tiling_setup.wgsl
new file mode 100644
index 00000000..8698a6c2
--- /dev/null
+++ b/vendor/vello_shaders/shader/path_tiling_setup.wgsl
@@ -0,0 +1,32 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Set up dispatch size for path tiling stage.
+
+#import bump
+
+@group(0) @binding(0)
+var<storage, read_write> bump: BumpAllocators;
+
+@group(0) @binding(1)
+var<storage, read_write> indirect: IndirectCount;
+
+@group(0) @binding(2)
+var<storage, read_write> ptcl: array<u32>;
+
+// Partition size for path tiling stage
+const WG_SIZE = 256u;
+
+@compute @workgroup_size(1)
+fn main() {
+ if atomicLoad(&bump.failed) != 0u {
+ indirect.count_x = 0u;
+ // signal fine rasterizer that failure happened (it doesn't bind bump)
+ ptcl[0] = ~0u;
+ } else {
+ let segments = atomicLoad(&bump.seg_counts);
+ indirect.count_x = (segments + (WG_SIZE - 1u)) / WG_SIZE;
+ }
+ indirect.count_y = 1u;
+ indirect.count_z = 1u;
+}
diff --git a/vendor/vello_shaders/shader/pathtag_reduce.wgsl b/vendor/vello_shaders/shader/pathtag_reduce.wgsl
new file mode 100644
index 00000000..beefd56e
--- /dev/null
+++ b/vendor/vello_shaders/shader/pathtag_reduce.wgsl
@@ -0,0 +1,42 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+#import config
+#import pathtag
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage> scene: array<u32>;
+
+@group(0) @binding(2)
+var<storage, read_write> reduced: array<TagMonoid>;
+
+const LG_WG_SIZE = 8u;
+const WG_SIZE = 256u;
+
+var<workgroup> sh_scratch: array<TagMonoid, WG_SIZE>;
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+) {
+ let ix = global_id.x;
+ let tag_word = scene[config.pathtag_base + ix];
+ var agg = reduce_tag(tag_word);
+ sh_scratch[local_id.x] = agg;
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ workgroupBarrier();
+ if local_id.x + (1u << i) < WG_SIZE {
+ let other = sh_scratch[local_id.x + (1u << i)];
+ agg = combine_tag_monoid(agg, other);
+ }
+ workgroupBarrier();
+ sh_scratch[local_id.x] = agg;
+ }
+ if local_id.x == 0u {
+ reduced[ix >> LG_WG_SIZE] = agg;
+ }
+}
diff --git a/vendor/vello_shaders/shader/pathtag_reduce2.wgsl b/vendor/vello_shaders/shader/pathtag_reduce2.wgsl
new file mode 100644
index 00000000..fe47a62a
--- /dev/null
+++ b/vendor/vello_shaders/shader/pathtag_reduce2.wgsl
@@ -0,0 +1,41 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// This shader is the second stage of reduction for the pathtag
+// monoid scan, needed when the number of tags is large.
+
+#import config
+#import pathtag
+
+@group(0) @binding(0)
+var<storage> reduced_in: array<TagMonoid>;
+
+@group(0) @binding(1)
+var<storage, read_write> reduced: array<TagMonoid>;
+
+const LG_WG_SIZE = 8u;
+const WG_SIZE = 256u;
+
+var<workgroup> sh_scratch: array<TagMonoid, WG_SIZE>;
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+) {
+ let ix = global_id.x;
+ var agg = reduced_in[ix];
+ sh_scratch[local_id.x] = agg;
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ workgroupBarrier();
+ if local_id.x + (1u << i) < WG_SIZE {
+ let other = sh_scratch[local_id.x + (1u << i)];
+ agg = combine_tag_monoid(agg, other);
+ }
+ workgroupBarrier();
+ sh_scratch[local_id.x] = agg;
+ }
+ if local_id.x == 0u {
+ reduced[ix >> LG_WG_SIZE] = agg;
+ }
+}
diff --git a/vendor/vello_shaders/shader/pathtag_scan.wgsl b/vendor/vello_shaders/shader/pathtag_scan.wgsl
new file mode 100644
index 00000000..686fae81
--- /dev/null
+++ b/vendor/vello_shaders/shader/pathtag_scan.wgsl
@@ -0,0 +1,76 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+#import config
+#import pathtag
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage> scene: array<u32>;
+
+@group(0) @binding(2)
+var<storage> reduced: array<TagMonoid>;
+
+@group(0) @binding(3)
+var<storage, read_write> tag_monoids: array<TagMonoid>;
+
+const LG_WG_SIZE = 8u;
+const WG_SIZE = 256u;
+
+#ifdef small
+var<workgroup> sh_parent: array<TagMonoid, WG_SIZE>;
+#endif
+// These could be combined?
+var<workgroup> sh_monoid: array<TagMonoid, WG_SIZE>;
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+ @builtin(workgroup_id) wg_id: vec3<u32>,
+) {
+#ifdef small
+ var agg = tag_monoid_identity();
+ if local_id.x < wg_id.x {
+ agg = reduced[local_id.x];
+ }
+ sh_parent[local_id.x] = agg;
+ for (var i = 0u; i < LG_WG_SIZE; i += 1u) {
+ workgroupBarrier();
+ if local_id.x + (1u << i) < WG_SIZE {
+ let other = sh_parent[local_id.x + (1u << i)];
+ agg = combine_tag_monoid(agg, other);
+ }
+ workgroupBarrier();
+ sh_parent[local_id.x] = agg;
+ }
+#endif
+
+ let ix = global_id.x;
+ let tag_word = scene[config.pathtag_base + ix];
+ var agg_part = reduce_tag(tag_word);
+ sh_monoid[local_id.x] = agg_part;
+ for (var i = 0u; i < LG_WG_SIZE; i += 1u) {
+ workgroupBarrier();
+ if local_id.x >= 1u << i {
+ let other = sh_monoid[local_id.x - (1u << i)];
+ agg_part = combine_tag_monoid(other, agg_part);
+ }
+ workgroupBarrier();
+ sh_monoid[local_id.x] = agg_part;
+ }
+ workgroupBarrier();
+ // prefix up to this workgroup
+#ifdef small
+ var tm = sh_parent[0];
+#else
+ var tm = reduced[wg_id.x];
+#endif
+ if local_id.x > 0u {
+ tm = combine_tag_monoid(tm, sh_monoid[local_id.x - 1u]);
+ }
+ // exclusive prefix sum, granularity of 4 tag bytes
+ tag_monoids[ix] = tm;
+}
diff --git a/vendor/vello_shaders/shader/pathtag_scan1.wgsl b/vendor/vello_shaders/shader/pathtag_scan1.wgsl
new file mode 100644
index 00000000..fc5236b0
--- /dev/null
+++ b/vendor/vello_shaders/shader/pathtag_scan1.wgsl
@@ -0,0 +1,67 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// This shader computes the scan of reduced tag monoids given
+// two levels of reduction.
+
+#import config
+#import pathtag
+
+@group(0) @binding(0)
+var<storage> reduced: array<TagMonoid>;
+
+@group(0) @binding(1)
+var<storage> reduced2: array<TagMonoid>;
+
+@group(0) @binding(2)
+var<storage, read_write> tag_monoids: array<TagMonoid>;
+
+const LG_WG_SIZE = 8u;
+const WG_SIZE = 256u;
+
+var<workgroup> sh_parent: array<TagMonoid, WG_SIZE>;
+// These could be combined?
+var<workgroup> sh_monoid: array<TagMonoid, WG_SIZE>;
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+ @builtin(workgroup_id) wg_id: vec3<u32>,
+) {
+ var agg = tag_monoid_identity();
+ if local_id.x < wg_id.x {
+ agg = reduced2[local_id.x];
+ }
+ sh_parent[local_id.x] = agg;
+ for (var i = 0u; i < LG_WG_SIZE; i += 1u) {
+ workgroupBarrier();
+ if local_id.x + (1u << i) < WG_SIZE {
+ let other = sh_parent[local_id.x + (1u << i)];
+ agg = combine_tag_monoid(agg, other);
+ }
+ workgroupBarrier();
+ sh_parent[local_id.x] = agg;
+ }
+
+ let ix = global_id.x;
+ agg = reduced[ix];
+ sh_monoid[local_id.x] = agg;
+ for (var i = 0u; i < LG_WG_SIZE; i += 1u) {
+ workgroupBarrier();
+ if local_id.x >= 1u << i {
+ let other = sh_monoid[local_id.x - (1u << i)];
+ agg = combine_tag_monoid(other, agg);
+ }
+ workgroupBarrier();
+ sh_monoid[local_id.x] = agg;
+ }
+ workgroupBarrier();
+ // prefix up to this workgroup
+ var tm = sh_parent[0];
+ if local_id.x > 0u {
+ tm = combine_tag_monoid(tm, sh_monoid[local_id.x - 1u]);
+ }
+ // exclusive prefix sum, granularity of 4 tag bytes * workgroup size
+ tag_monoids[ix] = tm;
+}
diff --git a/vendor/vello_shaders/shader/permutations b/vendor/vello_shaders/shader/permutations
new file mode 100644
index 00000000..b235168b
--- /dev/null
+++ b/vendor/vello_shaders/shader/permutations
@@ -0,0 +1,7 @@
+pathtag_scan
++ pathtag_scan_large
++ pathtag_scan_small: small
+fine
++ fine_area
++ fine_msaa8: msaa msaa8
++ fine_msaa16: msaa msaa16
diff --git a/vendor/vello_shaders/shader/shared/bbox.wgsl b/vendor/vello_shaders/shader/shared/bbox.wgsl
new file mode 100644
index 00000000..c4b026f4
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/bbox.wgsl
@@ -0,0 +1,23 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// The annotated bounding box for a path. It has been transformed,
+// but contains a link to the active transform, mostly for gradients.
+// Coordinates are integer pixels (for the convenience of atomic update)
+// but will probably become fixed-point fractions for rectangles.
+//
+// TODO: This also carries a `draw_flags` field that contains information that gets propagated to
+// the draw info stream. This is currently only used for the fill rule. If the other bits remain
+// unused we could possibly pack this into some other field, such as the MSB of `trans_ix`.
+struct PathBbox {
+ x0: i32,
+ y0: i32,
+ x1: i32,
+ y1: i32,
+ draw_flags: u32,
+ trans_ix: u32,
+}
+
+fn bbox_intersect(a: vec4<f32>, b: vec4<f32>) -> vec4<f32> {
+ return vec4(max(a.xy, b.xy), min(a.zw, b.zw));
+}
diff --git a/vendor/vello_shaders/shader/shared/blend.wgsl b/vendor/vello_shaders/shader/shared/blend.wgsl
new file mode 100644
index 00000000..cb71dfa6
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/blend.wgsl
@@ -0,0 +1,319 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Color mixing modes
+
+const MIX_NORMAL = 0u;
+const MIX_MULTIPLY = 1u;
+const MIX_SCREEN = 2u;
+const MIX_OVERLAY = 3u;
+const MIX_DARKEN = 4u;
+const MIX_LIGHTEN = 5u;
+const MIX_COLOR_DODGE = 6u;
+const MIX_COLOR_BURN = 7u;
+const MIX_HARD_LIGHT = 8u;
+const MIX_SOFT_LIGHT = 9u;
+const MIX_DIFFERENCE = 10u;
+const MIX_EXCLUSION = 11u;
+const MIX_HUE = 12u;
+const MIX_SATURATION = 13u;
+const MIX_COLOR = 14u;
+const MIX_LUMINOSITY = 15u;
+const MIX_CLIP = 128u;
+
+fn screen(cb: vec3<f32>, cs: vec3<f32>) -> vec3<f32> {
+ return cb + cs - (cb * cs);
+}
+
+fn color_dodge(cb: f32, cs: f32) -> f32 {
+ if cb == 0.0 {
+ return 0.0;
+ } else if cs == 1.0 {
+ return 1.0;
+ } else {
+ return min(1.0, cb / (1.0 - cs));
+ }
+}
+
+fn color_burn(cb: f32, cs: f32) -> f32 {
+ if cb == 1.0 {
+ return 1.0;
+ } else if cs == 0.0 {
+ return 0.0;
+ } else {
+ return 1.0 - min(1.0, (1.0 - cb) / cs);
+ }
+}
+
+fn hard_light(cb: vec3<f32>, cs: vec3<f32>) -> vec3<f32> {
+ return select(
+ screen(cb, 2.0 * cs - 1.0),
+ cb * 2.0 * cs,
+ cs <= vec3(0.5)
+ );
+}
+
+fn soft_light(cb: vec3<f32>, cs: vec3<f32>) -> vec3<f32> {
+ let d = select(
+ sqrt(cb),
+ ((16.0 * cb - 12.0) * cb + 4.0) * cb,
+ cb <= vec3(0.25)
+ );
+ return select(
+ cb + (2.0 * cs - 1.0) * (d - cb),
+ cb - (1.0 - 2.0 * cs) * cb * (1.0 - cb),
+ cs <= vec3(0.5)
+ );
+}
+
+fn sat(c: vec3<f32>) -> f32 {
+ return max(c.x, max(c.y, c.z)) - min(c.x, min(c.y, c.z));
+}
+
+fn lum(c: vec3<f32>) -> f32 {
+ let f = vec3(0.3, 0.59, 0.11);
+ return dot(c, f);
+}
+
+fn svg_lum(c: vec3<f32>) -> f32 {
+ let f = vec3(0.2125, 0.7154, 0.0721);
+ return dot(c, f);
+}
+
+fn clip_color(c_in: vec3<f32>) -> vec3<f32> {
+ var c = c_in;
+ let l = lum(c);
+ let n = min(c.x, min(c.y, c.z));
+ let x = max(c.x, max(c.y, c.z));
+ if n < 0.0 {
+ c = l + (((c - l) * l) / (l - n));
+ }
+ if x > 1.0 {
+ c = l + (((c - l) * (1.0 - l)) / (x - l));
+ }
+ return c;
+}
+
+fn set_lum(c: vec3<f32>, l: f32) -> vec3<f32> {
+ return clip_color(c + (l - lum(c)));
+}
+
+fn set_sat_inner(
+ cmin: ptr<function, f32>,
+ cmid: ptr<function, f32>,
+ cmax: ptr<function, f32>,
+ s: f32
+) {
+ if *cmax > *cmin {
+ *cmid = ((*cmid - *cmin) * s) / (*cmax - *cmin);
+ *cmax = s;
+ } else {
+ *cmid = 0.0;
+ *cmax = 0.0;
+ }
+ *cmin = 0.0;
+}
+
+fn set_sat(c: vec3<f32>, s: f32) -> vec3<f32> {
+ var r = c.r;
+ var g = c.g;
+ var b = c.b;
+ if r <= g {
+ if g <= b {
+ set_sat_inner(&r, &g, &b, s);
+ } else {
+ if r <= b {
+ set_sat_inner(&r, &b, &g, s);
+ } else {
+ set_sat_inner(&b, &r, &g, s);
+ }
+ }
+ } else {
+ if r <= b {
+ set_sat_inner(&g, &r, &b, s);
+ } else {
+ if g <= b {
+ set_sat_inner(&g, &b, &r, s);
+ } else {
+ set_sat_inner(&b, &g, &r, s);
+ }
+ }
+ }
+ return vec3(r, g, b);
+}
+
+// Blends two RGB colors together. The colors are assumed to be in sRGB
+// color space, and this function does not take alpha into account.
+fn blend_mix(cb: vec3<f32>, cs: vec3<f32>, mode: u32) -> vec3<f32> {
+ var b = vec3(0.0);
+ switch mode {
+ case MIX_MULTIPLY: {
+ b = cb * cs;
+ }
+ case MIX_SCREEN: {
+ b = screen(cb, cs);
+ }
+ case MIX_OVERLAY: {
+ b = hard_light(cs, cb);
+ }
+ case MIX_DARKEN: {
+ b = min(cb, cs);
+ }
+ case MIX_LIGHTEN: {
+ b = max(cb, cs);
+ }
+ case MIX_COLOR_DODGE: {
+ b = vec3(color_dodge(cb.x, cs.x), color_dodge(cb.y, cs.y), color_dodge(cb.z, cs.z));
+ }
+ case MIX_COLOR_BURN: {
+ b = vec3(color_burn(cb.x, cs.x), color_burn(cb.y, cs.y), color_burn(cb.z, cs.z));
+ }
+ case MIX_HARD_LIGHT: {
+ b = hard_light(cb, cs);
+ }
+ case MIX_SOFT_LIGHT: {
+ b = soft_light(cb, cs);
+ }
+ case MIX_DIFFERENCE: {
+ b = abs(cb - cs);
+ }
+ case MIX_EXCLUSION: {
+ b = cb + cs - 2.0 * cb * cs;
+ }
+ case MIX_HUE: {
+ b = set_lum(set_sat(cs, sat(cb)), lum(cb));
+ }
+ case MIX_SATURATION: {
+ b = set_lum(set_sat(cb, sat(cs)), lum(cb));
+ }
+ case MIX_COLOR: {
+ b = set_lum(cs, lum(cb));
+ }
+ case MIX_LUMINOSITY: {
+ b = set_lum(cb, lum(cs));
+ }
+ default: {
+ b = cs;
+ }
+ }
+ return b;
+}
+
+// Composition modes
+
+const COMPOSE_CLEAR = 0u;
+const COMPOSE_COPY = 1u;
+const COMPOSE_DEST = 2u;
+const COMPOSE_SRC_OVER = 3u;
+const COMPOSE_DEST_OVER = 4u;
+const COMPOSE_SRC_IN = 5u;
+const COMPOSE_DEST_IN = 6u;
+const COMPOSE_SRC_OUT = 7u;
+const COMPOSE_DEST_OUT = 8u;
+const COMPOSE_SRC_ATOP = 9u;
+const COMPOSE_DEST_ATOP = 10u;
+const COMPOSE_XOR = 11u;
+const COMPOSE_PLUS = 12u;
+const COMPOSE_PLUS_LIGHTER = 13u;
+
+// Apply general compositing operation.
+// Inputs are separated colors and alpha, output is premultiplied.
+fn blend_compose(
+ cb: vec3<f32>,
+ cs: vec3<f32>,
+ ab: f32,
+ as_: f32,
+ compose_mode: u32,
+) -> vec4<f32> {
+ var fa = 0.0;
+ var fb = 0.0;
+ switch compose_mode {
+ case COMPOSE_COPY: {
+ fa = 1.0;
+ fb = 0.0;
+ }
+ case COMPOSE_DEST: {
+ fa = 0.0;
+ fb = 1.0;
+ }
+ case COMPOSE_SRC_OVER: {
+ fa = 1.0;
+ fb = 1.0 - as_;
+ }
+ case COMPOSE_DEST_OVER: {
+ fa = 1.0 - ab;
+ fb = 1.0;
+ }
+ case COMPOSE_SRC_IN: {
+ fa = ab;
+ fb = 0.0;
+ }
+ case COMPOSE_DEST_IN: {
+ fa = 0.0;
+ fb = as_;
+ }
+ case COMPOSE_SRC_OUT: {
+ fa = 1.0 - ab;
+ fb = 0.0;
+ }
+ case COMPOSE_DEST_OUT: {
+ fa = 0.0;
+ fb = 1.0 - as_;
+ }
+ case COMPOSE_SRC_ATOP: {
+ fa = ab;
+ fb = 1.0 - as_;
+ }
+ case COMPOSE_DEST_ATOP: {
+ fa = 1.0 - ab;
+ fb = as_;
+ }
+ case COMPOSE_XOR: {
+ fa = 1.0 - ab;
+ fb = 1.0 - as_;
+ }
+ case COMPOSE_PLUS: {
+ fa = 1.0;
+ fb = 1.0;
+ }
+ case COMPOSE_PLUS_LIGHTER: {
+ return min(vec4(1.0), vec4(as_ * cs + ab * cb, as_ + ab));
+ }
+ default: {}
+ }
+ let as_fa = as_ * fa;
+ let ab_fb = ab * fb;
+ let co = as_fa * cs + ab_fb * cb;
+ // Modes like COMPOSE_PLUS can generate alpha > 1.0, so clamp.
+ return vec4(co, min(as_fa + ab_fb, 1.0));
+}
+
+fn unpremultiply(color: vec4<f32>) -> vec3<f32> {
+ let EPSILON = 1e-15;
+ // Max with a small epsilon to avoid NaNs.
+ let inv_alpha = 1.0 / max(color.a, EPSILON);
+ return color.rgb * inv_alpha;
+}
+
+// Apply color mixing and composition. Both input and output colors are
+// premultiplied RGB.
+fn blend_mix_compose(backdrop: vec4<f32>, src: vec4<f32>, mode: u32) -> vec4<f32> {
+ let BLEND_DEFAULT = ((MIX_NORMAL << 8u) | COMPOSE_SRC_OVER);
+ if (mode & 0x7fffu) == BLEND_DEFAULT {
+ // Both normal+src_over blend and clip case
+ return backdrop * (1.0 - src.a) + src;
+ }
+ // Un-premultiply colors for blending.
+ var cs = unpremultiply(src);
+ let cb = unpremultiply(backdrop);
+ let mix_mode = mode >> 8u;
+ let mixed = blend_mix(cb, cs, mix_mode);
+ cs = mix(cs, mixed, backdrop.a);
+ let compose_mode = mode & 0xffu;
+ if compose_mode == COMPOSE_SRC_OVER {
+ let co = mix(backdrop.rgb, cs, src.a);
+ return vec4(co, src.a + backdrop.a * (1.0 - src.a));
+ } else {
+ return blend_compose(cb, cs, backdrop.a, src.a, compose_mode);
+ }
+}
diff --git a/vendor/vello_shaders/shader/shared/bump.wgsl b/vendor/vello_shaders/shader/shared/bump.wgsl
new file mode 100644
index 00000000..c1cdaa48
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/bump.wgsl
@@ -0,0 +1,28 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Bitflags for each stage that can fail allocation.
+const STAGE_BINNING: u32 = 0x1u;
+const STAGE_TILE_ALLOC: u32 = 0x2u;
+const STAGE_FLATTEN: u32 = 0x4u;
+const STAGE_PATH_COUNT: u32 = 0x8u;
+const STAGE_COARSE: u32 = 0x10u;
+
+// This must be kept in sync with the struct in config.rs in the encoding crate.
+struct BumpAllocators {
+ // Bitmask of stages that have failed allocation.
+ failed: atomic<u32>,
+ binning: atomic<u32>,
+ ptcl: atomic<u32>,
+ tile: atomic<u32>,
+ seg_counts: atomic<u32>,
+ segments: atomic<u32>,
+ blend: atomic<u32>,
+ lines: atomic<u32>,
+}
+
+struct IndirectCount {
+ count_x: u32,
+ count_y: u32,
+ count_z: u32,
+}
diff --git a/vendor/vello_shaders/shader/shared/clip.wgsl b/vendor/vello_shaders/shader/shared/clip.wgsl
new file mode 100644
index 00000000..9c768ae8
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/clip.wgsl
@@ -0,0 +1,26 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+struct Bic {
+ a: u32,
+ b: u32,
+}
+
+fn bic_combine(x: Bic, y: Bic) -> Bic {
+ let m = min(x.b, y.a);
+ return Bic(x.a + y.a - m, x.b + y.b - m);
+}
+
+struct ClipInp {
+ // Index of the draw object.
+ ix: u32,
+ // This is a packed encoding of an enum with the sign bit as the tag. If positive,
+ // this entry is a BeginClip and contains the associated path index. If negative,
+ // it is an EndClip and contains the bitwise-not of the EndClip draw object index.
+ path_ix: i32,
+}
+
+struct ClipEl {
+ parent_ix: u32,
+ bbox: vec4<f32>,
+}
diff --git a/vendor/vello_shaders/shader/shared/config.wgsl b/vendor/vello_shaders/shader/shared/config.wgsl
new file mode 100644
index 00000000..8459649e
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/config.wgsl
@@ -0,0 +1,74 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// This must be kept in sync with `ConfigUniform` in `research/vello_encoding/src/config.rs`
+struct Config {
+ width_in_tiles: u32,
+ height_in_tiles: u32,
+
+ target_width: u32,
+ target_height: u32,
+
+ // The initial color applied to the pixels in a tile during the fine stage.
+ // The format is packed RGBA8 in MSB order.
+ base_color: u32,
+
+ n_drawobj: u32,
+ n_path: u32,
+ n_clip: u32,
+
+ // To reduce the number of bindings, info and bin data are combined
+ // into one buffer.
+ bin_data_start: u32,
+
+ // offsets within scene buffer (in u32 units)
+ pathtag_base: u32,
+ pathdata_base: u32,
+
+ drawtag_base: u32,
+ drawdata_base: u32,
+
+ transform_base: u32,
+ style_base: u32,
+
+ // Sizes of bump allocated buffers (in element size units)
+ lines_size: u32,
+ binning_size: u32,
+ tiles_size: u32,
+ seg_counts_size: u32,
+ segments_size: u32,
+ blend_size: u32,
+ ptcl_size: u32,
+ // raea: 1 blends in linear light (fine.wgsl blend_in), as bevy_ui does; 0 blends the sRGB-encoded values
+ blend_linear: u32,
+}
+
+// Geometry of tiles and bins
+
+const TILE_WIDTH = 16u;
+const TILE_HEIGHT = 16u;
+// Number of tiles per bin
+const N_TILE_X = 16u;
+const N_TILE_Y = 16u;
+const N_TILE = N_TILE_X * N_TILE_Y;
+
+// Not currently supporting non-square tiles
+const TILE_SCALE = 0.0625;
+
+// The "split" point between using local memory in fine for the blend stack and spilling to the blend_spill buffer.
+// A higher value will increase vgpr ("register") pressure in fine, but decrease required dynamic memory allocation.
+// If changing, also change in research/vello_shaders/src/cpu/coarse.rs.
+const BLEND_STACK_SPLIT = 4u;
+
+// The following are computed in draw_leaf from the generic gradient parameters
+// encoded in the scene, and stored in the gradient's info struct, for
+// consumption during fine rasterization.
+
+// Radial gradient kinds
+const RAD_GRAD_KIND_CIRCULAR = 1u;
+const RAD_GRAD_KIND_STRIP = 2u;
+const RAD_GRAD_KIND_FOCAL_ON_CIRCLE = 3u;
+const RAD_GRAD_KIND_CONE = 4u;
+
+// Radial gradient flags
+const RAD_GRAD_SWAPPED = 1u;
diff --git a/vendor/vello_shaders/shader/shared/cubic.wgsl b/vendor/vello_shaders/shader/shared/cubic.wgsl
new file mode 100644
index 00000000..10a306a7
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/cubic.wgsl
@@ -0,0 +1,14 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+struct Cubic {
+ p0: vec2<f32>,
+ p1: vec2<f32>,
+ p2: vec2<f32>,
+ p3: vec2<f32>,
+ stroke: vec2<f32>,
+ path_ix: u32,
+ flags: u32,
+}
+
+const CUBIC_IS_STROKE = 1u;
diff --git a/vendor/vello_shaders/shader/shared/drawtag.wgsl b/vendor/vello_shaders/shader/shared/drawtag.wgsl
new file mode 100644
index 00000000..6020e9f7
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/drawtag.wgsl
@@ -0,0 +1,54 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// The DrawMonoid is computed as a prefix sum to aid in decoding
+// the variable-length encoding of draw objects.
+struct DrawMonoid {
+ // The number of paths preceding this draw object.
+ path_ix: u32,
+ // The number of clip operations preceding this draw object.
+ clip_ix: u32,
+ // The offset of the encoded draw object in the scene (u32s).
+ scene_offset: u32,
+ // The offset of the associated info.
+ info_offset: u32,
+}
+
+// Each draw object has a 32-bit draw tag, which is a bit-packed
+// version of the draw monoid.
+const DRAWTAG_NOP = 0u;
+const DRAWTAG_FILL_COLOR = 0x44u;
+const DRAWTAG_FILL_LIN_GRADIENT = 0x114u;
+const DRAWTAG_FILL_RAD_GRADIENT = 0x29cu;
+const DRAWTAG_FILL_SWEEP_GRADIENT = 0x254u;
+const DRAWTAG_FILL_IMAGE = 0x28Cu;
+const DRAWTAG_BLURRED_ROUNDED_RECT = 0x2d4u;
+const DRAWTAG_BEGIN_CLIP = 0x49u;
+const DRAWTAG_END_CLIP = 0x21u;
+
+/// The first word of each draw info stream entry contains the flags. This is not a part of the
+/// draw object stream but get used after the draw objects have been reduced on the GPU.
+/// 0 represents a non-zero fill. 1 represents an even-odd fill.
+const DRAW_INFO_FLAGS_FILL_RULE_BIT = 1u;
+
+fn draw_monoid_identity() -> DrawMonoid {
+ return DrawMonoid();
+}
+
+fn combine_draw_monoid(a: DrawMonoid, b: DrawMonoid) -> DrawMonoid {
+ var c: DrawMonoid;
+ c.path_ix = a.path_ix + b.path_ix;
+ c.clip_ix = a.clip_ix + b.clip_ix;
+ c.scene_offset = a.scene_offset + b.scene_offset;
+ c.info_offset = a.info_offset + b.info_offset;
+ return c;
+}
+
+fn map_draw_tag(tag_word: u32) -> DrawMonoid {
+ var c: DrawMonoid;
+ c.path_ix = u32(tag_word != DRAWTAG_NOP);
+ c.clip_ix = tag_word & 1u;
+ c.scene_offset = (tag_word >> 2u) & 0x07u;
+ c.info_offset = (tag_word >> 6u) & 0x0fu;
+ return c;
+}
diff --git a/vendor/vello_shaders/shader/shared/pathtag.wgsl b/vendor/vello_shaders/shader/shared/pathtag.wgsl
new file mode 100644
index 00000000..cebf0a04
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/pathtag.wgsl
@@ -0,0 +1,71 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+struct TagMonoid {
+ trans_ix: u32,
+ // TODO: I don't think pathseg_ix is used.
+ pathseg_ix: u32,
+ pathseg_offset: u32,
+ style_ix: u32,
+ path_ix: u32,
+}
+
+const PATH_TAG_SEG_TYPE = 3u;
+const PATH_TAG_LINETO = 1u;
+const PATH_TAG_QUADTO = 2u;
+const PATH_TAG_CUBICTO = 3u;
+const PATH_TAG_F32 = 8u;
+const PATH_TAG_TRANSFORM = 0x20u;
+const PATH_TAG_PATH = 0x10u;
+const PATH_TAG_STYLE = 0x40u;
+const PATH_TAG_SUBPATH_END = 4u;
+
+// Size of the `Style` data structure in words
+const STYLE_SIZE_IN_WORDS: u32 = 2u;
+
+const STYLE_FLAGS_STYLE: u32 = 0x80000000u;
+const STYLE_FLAGS_FILL: u32 = 0x40000000u;
+const STYLE_MITER_LIMIT_MASK: u32 = 0xFFFFu;
+
+const STYLE_FLAGS_START_CAP_MASK: u32 = 0x0C000000u;
+const STYLE_FLAGS_END_CAP_MASK: u32 = 0x03000000u;
+
+const STYLE_FLAGS_CAP_BUTT: u32 = 0u;
+const STYLE_FLAGS_CAP_SQUARE: u32 = 0x01000000u;
+const STYLE_FLAGS_CAP_ROUND: u32 = 0x02000000u;
+
+const STYLE_FLAGS_JOIN_MASK: u32 = 0x30000000u;
+const STYLE_FLAGS_JOIN_BEVEL: u32 = 0u;
+const STYLE_FLAGS_JOIN_MITER: u32 = 0x10000000u;
+const STYLE_FLAGS_JOIN_ROUND: u32 = 0x20000000u;
+
+// TODO: Declare the remaining STYLE flags here.
+
+fn tag_monoid_identity() -> TagMonoid {
+ return TagMonoid();
+}
+
+fn combine_tag_monoid(a: TagMonoid, b: TagMonoid) -> TagMonoid {
+ var c: TagMonoid;
+ c.trans_ix = a.trans_ix + b.trans_ix;
+ c.pathseg_ix = a.pathseg_ix + b.pathseg_ix;
+ c.pathseg_offset = a.pathseg_offset + b.pathseg_offset;
+ c.style_ix = a.style_ix + b.style_ix;
+ c.path_ix = a.path_ix + b.path_ix;
+ return c;
+}
+
+fn reduce_tag(tag_word: u32) -> TagMonoid {
+ var c: TagMonoid;
+ let point_count = tag_word & 0x3030303u;
+ c.pathseg_ix = countOneBits((point_count * 7u) & 0x4040404u);
+ c.trans_ix = countOneBits(tag_word & (PATH_TAG_TRANSFORM * 0x1010101u));
+ let n_points = point_count + ((tag_word >> 2u) & 0x1010101u);
+ var a = n_points + (n_points & (((tag_word >> 3u) & 0x1010101u) * 15u));
+ a += a >> 8u;
+ a += a >> 16u;
+ c.pathseg_offset = a & 0xffu;
+ c.path_ix = countOneBits(tag_word & (PATH_TAG_PATH * 0x1010101u));
+ c.style_ix = countOneBits(tag_word & (PATH_TAG_STYLE * 0x1010101u)) * STYLE_SIZE_IN_WORDS;
+ return c;
+}
diff --git a/vendor/vello_shaders/shader/shared/ptcl.wgsl b/vendor/vello_shaders/shader/shared/ptcl.wgsl
new file mode 100644
index 00000000..487c3496
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/ptcl.wgsl
@@ -0,0 +1,111 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Layout of per-tile command list
+// Initial allocation, in u32's.
+const PTCL_INITIAL_ALLOC = 64u;
+const PTCL_INCREMENT = 256u;
+
+// Amount of space taken by jump
+const PTCL_HEADROOM = 2u;
+
+// Tags for PTCL commands
+const CMD_END = 0u;
+const CMD_FILL = 1u;
+const CMD_STROKE = 2u;
+const CMD_SOLID = 3u;
+const CMD_COLOR = 5u;
+const CMD_LIN_GRAD = 6u;
+const CMD_RAD_GRAD = 7u;
+const CMD_SWEEP_GRAD = 8u;
+const CMD_IMAGE = 9u;
+const CMD_BEGIN_CLIP = 10u;
+const CMD_END_CLIP = 11u;
+const CMD_JUMP = 12u;
+const CMD_BLUR_RECT = 13u;
+
+// The individual PTCL structs are written here, but read/write is by
+// hand in the relevant shaders
+
+struct CmdFill {
+ size_and_rule: u32,
+ seg_data: u32,
+ backdrop: i32,
+}
+
+struct CmdStroke {
+ tile: u32,
+ half_width: f32,
+}
+
+struct CmdJump {
+ new_ix: u32,
+}
+
+struct CmdColor {
+ rgba_color: u32,
+}
+
+struct CmdBlurRect {
+ // Solid fill color.
+ rgba_color: u32,
+
+ // 2x2 transformation matrix (inverse).
+ matrx: vec4<f32>,
+ // 2D translation (inverse)
+ xlat: vec2<f32>,
+
+ // Rounded rectangle properties.
+ width: f32,
+ height: f32,
+ radius: f32,
+
+ // Gaussian filter standard deviation
+ std_dev: f32,
+}
+
+struct CmdLinGrad {
+ index: u32,
+ extend_mode: u32,
+ line_x: f32,
+ line_y: f32,
+ line_c: f32,
+}
+
+struct CmdRadGrad {
+ index: u32,
+ extend_mode: u32,
+ matrx: vec4<f32>,
+ xlat: vec2<f32>,
+ focal_x: f32,
+ radius: f32,
+ kind: u32,
+ flags: u32,
+}
+
+struct CmdSweepGrad {
+ index: u32,
+ extend_mode: u32,
+ matrx: vec4<f32>,
+ xlat: vec2<f32>,
+ t0: f32,
+ t1: f32,
+}
+
+struct CmdImage {
+ matrx: vec4<f32>,
+ xlat: vec2<f32>,
+ atlas_offset: vec2<f32>,
+ extents: vec2<f32>,
+ format: u32,
+ x_extend_mode: u32,
+ y_extend_mode: u32,
+ quality: u32,
+ alpha: f32,
+ alpha_type: u32,
+}
+
+struct CmdEndClip {
+ blend: u32,
+ alpha: f32,
+}
diff --git a/vendor/vello_shaders/shader/shared/segment.wgsl b/vendor/vello_shaders/shader/shared/segment.wgsl
new file mode 100644
index 00000000..560f18c9
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/segment.wgsl
@@ -0,0 +1,35 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Segments laid out for contiguous storage
+struct Segment {
+ // Points are relative to tile origin
+ point0: vec2<f32>,
+ point1: vec2<f32>,
+ y_edge: f32,
+}
+
+// A line segment produced by flattening and ready for rasterization.
+//
+// The name is perhaps too playful, but reflects the fact that these
+// lines are completely unordered. They will flow through coarse path
+// rasterization, then the per-tile segments will be scatter-written into
+// segment storage so that each (tile, path) tuple gets a contiguous
+// slice of segments.
+struct LineSoup {
+ path_ix: u32,
+ // Note: this creates an alignment gap. Don't worry about
+ // this now, but maybe move to scalars.
+ p0: vec2<f32>,
+ p1: vec2<f32>,
+}
+
+// An intermediate data structure for sorting tile segments.
+struct SegmentCount {
+ // Reference to element of LineSoup array
+ line_ix: u32,
+ // Two count values packed into a single u32
+ // Lower 16 bits: index of segment within line
+ // Upper 16 bits: index of segment within segment slice
+ counts: u32,
+}
diff --git a/vendor/vello_shaders/shader/shared/tile.wgsl b/vendor/vello_shaders/shader/shared/tile.wgsl
new file mode 100644
index 00000000..f57c6743
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/tile.wgsl
@@ -0,0 +1,21 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Common datatypes for path and tile intermediate info.
+
+struct Path {
+ // bounding box in tiles
+ bbox: vec4<u32>,
+ // offset (in u32's) to tile rectangle
+ tiles: u32,
+}
+
+struct Tile {
+ backdrop: i32,
+ // This is used for the count of the number of segments in the
+ // tile up to coarse rasterization, and the index afterwards.
+ // In the latter variant, the bits are inverted so that tiling
+ // can detect whether the tile was allocated; it's best to
+ // consider this an enum packed into a u32.
+ segment_count_or_ix: u32,
+}
diff --git a/vendor/vello_shaders/shader/shared/transform.wgsl b/vendor/vello_shaders/shader/shared/transform.wgsl
new file mode 100644
index 00000000..c59bf563
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/transform.wgsl
@@ -0,0 +1,27 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Helpers for working with transforms.
+
+struct Transform {
+ matrx: vec4<f32>,
+ translate: vec2<f32>,
+}
+
+fn transform_apply(transform: Transform, p: vec2<f32>) -> vec2<f32> {
+ return transform.matrx.xy * p.x + transform.matrx.zw * p.y + transform.translate;
+}
+
+fn transform_inverse(transform: Transform) -> Transform {
+ let inv_det = 1.0 / (transform.matrx.x * transform.matrx.w - transform.matrx.y * transform.matrx.z);
+ let inv_mat = inv_det * vec4(transform.matrx.w, -transform.matrx.y, -transform.matrx.z, transform.matrx.x);
+ let inv_tr = mat2x2(inv_mat.xy, inv_mat.zw) * -transform.translate;
+ return Transform(inv_mat, inv_tr);
+}
+
+fn transform_mul(a: Transform, b: Transform) -> Transform {
+ return Transform(
+ a.matrx.xyxy * b.matrx.xxzz + a.matrx.zwzw * b.matrx.yyww,
+ a.matrx.xy * b.translate.x + a.matrx.zw * b.translate.y + a.translate
+ );
+}
diff --git a/vendor/vello_shaders/shader/shared/util.wgsl b/vendor/vello_shaders/shader/shared/util.wgsl
new file mode 100644
index 00000000..d1ce6315
--- /dev/null
+++ b/vendor/vello_shaders/shader/shared/util.wgsl
@@ -0,0 +1,24 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// This file defines utility functions that interact with host-shareable buffer objects. It should
+// be imported once following the resource binding declarations in the shader module that access
+// them.
+
+// Reads a draw tag from the scene buffer, defaulting to DRAWTAG_NOP if the given `ix` is beyond the
+// range of valid draw objects (e.g this can happen if `ix` is derived from an invocation ID in a
+// workgroup that partially spans valid range).
+//
+// This function depends on the following global declarations:
+// * `scene`: array<u32>
+// * `config`: Config (see config.wgsl)
+fn read_draw_tag_from_scene(ix: u32) -> u32 {
+ var tag_word: u32;
+ if ix < config.n_drawobj {
+ let tag_ix = config.drawtag_base + ix;
+ tag_word = scene[tag_ix];
+ } else {
+ tag_word = DRAWTAG_NOP;
+ }
+ return tag_word;
+}
diff --git a/vendor/vello_shaders/shader/tile_alloc.wgsl b/vendor/vello_shaders/shader/tile_alloc.wgsl
new file mode 100644
index 00000000..00915fef
--- /dev/null
+++ b/vendor/vello_shaders/shader/tile_alloc.wgsl
@@ -0,0 +1,123 @@
+// Copyright 2022 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+// Tile allocation (and zeroing of tiles)
+
+#import config
+#import bump
+#import drawtag
+#import tile
+
+@group(0) @binding(0)
+var<uniform> config: Config;
+
+@group(0) @binding(1)
+var<storage> scene: array<u32>;
+
+@group(0) @binding(2)
+var<storage> draw_bboxes: array<vec4<f32>>;
+
+@group(0) @binding(3)
+var<storage, read_write> bump: BumpAllocators;
+
+@group(0) @binding(4)
+var<storage, read_write> paths: array<Path>;
+
+@group(0) @binding(5)
+var<storage, read_write> tiles: array<Tile>;
+
+const WG_SIZE = 256u;
+
+var<workgroup> sh_tile_count: array<u32, WG_SIZE>;
+var<workgroup> sh_tile_offset: u32;
+var<workgroup> sh_previous_failed: u32;
+
+@compute @workgroup_size(256)
+fn main(
+ @builtin(global_invocation_id) global_id: vec3<u32>,
+ @builtin(local_invocation_id) local_id: vec3<u32>,
+) {
+ // Exit early if prior stages failed, as we can't run this stage.
+ // We need to check only prior stages, as if this stage has failed in another workgroup,
+ // we still want to know this workgroup's memory requirement.
+ if local_id.x == 0u {
+ let failed = (atomicLoad(&bump.failed) & (STAGE_BINNING | STAGE_FLATTEN)) != 0u;
+ sh_previous_failed = u32(failed);
+ }
+ let failed = workgroupUniformLoad(&sh_previous_failed);
+ if failed != 0u {
+ return;
+ }
+ // scale factors useful for converting coordinates to tiles
+ // TODO: make into constants
+ let SX = 1.0 / f32(TILE_WIDTH);
+ let SY = 1.0 / f32(TILE_HEIGHT);
+
+ let drawobj_ix = global_id.x;
+ var drawtag = DRAWTAG_NOP;
+ if drawobj_ix < config.n_drawobj {
+ drawtag = scene[config.drawtag_base + drawobj_ix];
+ }
+ var x0 = 0;
+ var y0 = 0;
+ var x1 = 0;
+ var y1 = 0;
+ if drawtag != DRAWTAG_NOP && drawtag != DRAWTAG_END_CLIP {
+ let bbox = draw_bboxes[drawobj_ix];
+
+ // Don't round up the bottom-right corner of the bbox if the area is zero and leave the
+ // coordinates at 0. This will make `tile_count` zero as the shape is clipped out.
+ if bbox.x < bbox.z && bbox.y < bbox.w {
+ x0 = i32(floor(bbox.x * SX));
+ y0 = i32(floor(bbox.y * SY));
+ x1 = i32(ceil(bbox.z * SX));
+ y1 = i32(ceil(bbox.w * SY));
+ }
+ }
+ let ux0 = u32(clamp(x0, 0, i32(config.width_in_tiles)));
+ let uy0 = u32(clamp(y0, 0, i32(config.height_in_tiles)));
+ let ux1 = u32(clamp(x1, 0, i32(config.width_in_tiles)));
+ let uy1 = u32(clamp(y1, 0, i32(config.height_in_tiles)));
+ let tile_count = (ux1 - ux0) * (uy1 - uy0);
+ var total_tile_count = tile_count;
+ sh_tile_count[local_id.x] = tile_count;
+ for (var i = 0u; i < firstTrailingBit(WG_SIZE); i += 1u) {
+ workgroupBarrier();
+ if local_id.x >= (1u << i) {
+ total_tile_count += sh_tile_count[local_id.x - (1u << i)];
+ }
+ workgroupBarrier();
+ sh_tile_count[local_id.x] = total_tile_count;
+ }
+ if local_id.x == WG_SIZE - 1u {
+ let count = sh_tile_count[WG_SIZE - 1u];
+ var offset = atomicAdd(&bump.tile, count);
+ if offset + count > config.tiles_size {
+ offset = 0u;
+ atomicOr(&bump.failed, STAGE_TILE_ALLOC);
+ }
+ paths[drawobj_ix].tiles = offset;
+ }
+ // Using storage barriers is a workaround for what appears to be a miscompilation
+ // when a normal workgroup-shared variable is used to broadcast the value.
+ storageBarrier();
+ let tile_offset = paths[drawobj_ix | (WG_SIZE - 1u)].tiles;
+ storageBarrier();
+ if drawobj_ix < config.n_drawobj {
+ let tile_subix = select(0u, sh_tile_count[local_id.x - 1u], local_id.x > 0u);
+ let bbox = vec4(ux0, uy0, ux1, uy1);
+ let path = Path(bbox, tile_offset + tile_subix);
+ paths[drawobj_ix] = path;
+ }
+
+ // zero allocated memory
+ // Note: if the number of draw objects is small, utilization will be poor.
+ // There are two things that can be done to improve that. One would be a
+ // separate (indirect) dispatch. Another would be to have each workgroup
+ // process fewer draw objects than the number of threads in the wg.
+ let total_count = sh_tile_count[WG_SIZE - 1u];
+ for (var i = local_id.x; i < total_count; i += WG_SIZE) {
+ // Note: could format output buffer as u32 for even better load balancing.
+ tiles[tile_offset + i] = Tile(0, 0u);
+ }
+}
diff --git a/vendor/vello_shaders/src/compile/mod.rs b/vendor/vello_shaders/src/compile/mod.rs
new file mode 100644
index 00000000..1974c2c9
--- /dev/null
+++ b/vendor/vello_shaders/src/compile/mod.rs
@@ -0,0 +1,295 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+
+use naga::front::wgsl;
+use naga::valid::{Capabilities, ModuleInfo, ValidationError, ValidationFlags};
+use naga::{AddressSpace, ArraySize, ImageClass, Module, StorageAccess, WithSpan};
+use std::collections::{HashMap, HashSet};
+use std::fmt;
+use std::path::{Path, PathBuf};
+use std::sync::OnceLock;
+use thiserror::Error;
+
+pub mod permutations;
+pub mod preprocess;
+
+#[cfg(feature = "msl")]
+pub mod msl;
+
+use crate::types::{BindType, BindingInfo, WorkgroupBufferInfo};
+
+pub type Result<T> = std::result::Result<T, Error>;
+pub type CoalescedResult<T> = std::result::Result<T, ErrorVec>;
+
+#[derive(Error, Debug)]
+pub struct ErrorVec(Vec<Error>);
+
+#[derive(Error, Debug)]
+#[error("{source} ({name}) {msg}")]
+pub struct Error {
+ name: String,
+ msg: String,
+ source: InnerError,
+}
+
+#[derive(Error, Debug)]
+enum InnerError {
+ #[error("failed to parse shader")]
+ Parse(#[from] wgsl::ParseError),
+
+ #[error("failed to validate shader")]
+ Validate(#[from] WithSpan<ValidationError>),
+
+ #[error("missing entry point function")]
+ EntryPointNotFound,
+}
+
+impl fmt::Display for ErrorVec {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ for e in self.0.iter() {
+ write!(f, "{e}")?;
+ }
+ Ok(())
+ }
+}
+
+impl Error {
+ fn new(wgsl: &str, name: &str, error: impl Into<InnerError>) -> Self {
+ let source = error.into();
+ Self {
+ name: name.to_owned(),
+ msg: source.emit_msg(wgsl, &format!("({name} preprocessed)")),
+ source,
+ }
+ }
+}
+
+impl InnerError {
+ fn emit_msg(&self, wgsl: &str, name: &str) -> String {
+ match self {
+ Self::Parse(e) => e.emit_to_string_with_path(wgsl, name),
+ Self::Validate(e) => e.emit_to_string_with_path(wgsl, name),
+ _ => String::default(),
+ }
+ }
+}
+
+#[derive(Debug)]
+pub struct ShaderInfo {
+ pub source: String,
+ pub module: Module,
+ pub module_info: ModuleInfo,
+ pub workgroup_size: [u32; 3],
+ pub bindings: Vec<BindingInfo>,
+ pub workgroup_buffers: Vec<WorkgroupBufferInfo>,
+}
+
+impl ShaderInfo {
+ #[allow(
+ clippy::result_large_err,
+ reason = "Deferred: This is a cold code path."
+ )]
+ pub fn new(name: &str, source: String, entry_point: &str) -> Result<Self> {
+ let module = wgsl::parse_str(&source).map_err(|error| Error::new(&source, name, error))?;
+ let module_info = naga::valid::Validator::new(ValidationFlags::all(), Capabilities::all())
+ .validate(&module)
+ .map_err(|error| Error::new(&source, name, error))?;
+ let (entry_index, entry) = module
+ .entry_points
+ .iter()
+ .enumerate()
+ .find(|(_, entry)| entry.name.as_str() == entry_point)
+ .ok_or(Error::new(&source, name, InnerError::EntryPointNotFound))?;
+ let mut bindings = vec![];
+ let mut workgroup_buffers = vec![];
+ let mut wg_buffer_idx = 0;
+ let entry_info = module_info.get_entry_point(entry_index);
+ for (var_handle, var) in module.global_variables.iter() {
+ if entry_info[var_handle].is_empty() {
+ continue;
+ }
+ let binding_ty = match module.types[var.ty].inner {
+ naga::TypeInner::BindingArray { base, .. } => &module.types[base].inner,
+ ref ty => ty,
+ };
+ let Some(binding) = &var.binding else {
+ if var.space == AddressSpace::WorkGroup {
+ let index = wg_buffer_idx;
+ wg_buffer_idx += 1;
+ let size_in_bytes = match binding_ty {
+ naga::TypeInner::Array {
+ size: ArraySize::Constant(size),
+ stride,
+ ..
+ } => u32::from(*size) * stride,
+ naga::TypeInner::Struct { span, .. } => *span,
+ naga::TypeInner::Scalar(scalar)
+ | naga::TypeInner::Vector { scalar, .. }
+ | naga::TypeInner::Matrix { scalar, .. }
+ | naga::TypeInner::Atomic(scalar) => scalar.width as u32,
+ _ => {
+ // Not a valid workgroup variable type. At least not one that is used
+ // in our shaders.
+ continue;
+ }
+ };
+ workgroup_buffers.push(WorkgroupBufferInfo {
+ size_in_bytes,
+ index,
+ });
+ }
+ continue;
+ };
+ let mut resource = BindingInfo {
+ name: var.name.clone(),
+ location: (binding.group, binding.binding),
+ ty: BindType::Buffer,
+ };
+ if let naga::TypeInner::Image { class, .. } = &binding_ty {
+ resource.ty = BindType::ImageRead;
+ if let ImageClass::Storage { access, .. } = class
+ && access.contains(StorageAccess::STORE)
+ {
+ resource.ty = BindType::Image;
+ }
+ } else {
+ resource.ty = BindType::BufReadOnly;
+ match var.space {
+ AddressSpace::Storage { access } if access.contains(StorageAccess::STORE) => {
+ resource.ty = BindType::Buffer;
+ }
+ AddressSpace::Uniform => {
+ resource.ty = BindType::Uniform;
+ }
+ _ => {}
+ }
+ }
+ bindings.push(resource);
+ }
+ bindings.sort_by_key(|res| res.location);
+ let workgroup_size = entry.workgroup_size;
+ Ok(Self {
+ source: postprocess(&source),
+ module,
+ module_info,
+ workgroup_size,
+ bindings,
+ workgroup_buffers,
+ })
+ }
+
+ /// Same as [`ShaderInfo::from_dir`] but uses the default shader directory provided by [`shader_dir`].
+ pub fn from_default() -> CoalescedResult<HashMap<String, Self>> {
+ Self::from_dir(shader_dir())
+ }
+
+ pub fn from_dir(shader_dir: impl AsRef<Path>) -> CoalescedResult<HashMap<String, Self>> {
+ use std::fs;
+ let shader_dir = shader_dir.as_ref();
+ let permutation_map =
+ if let Ok(permutations_source) = fs::read_to_string(shader_dir.join("permutations")) {
+ permutations::parse(&permutations_source)
+ } else {
+ HashMap::default()
+ };
+ //println!("{permutation_map:?}");
+ let imports = preprocess::get_imports(shader_dir);
+ let mut errors = vec![];
+ let mut info = HashMap::default();
+ let defines: HashSet<_> = HashSet::default();
+ for entry in shader_dir
+ .read_dir()
+ .expect("Can read shader import directory")
+ .filter_map(move |e| {
+ e.ok()
+ .filter(|e| e.path().extension().map(|e| e == "wgsl").unwrap_or(false))
+ })
+ {
+ let file_name = entry.file_name();
+ if let Some(name) = file_name.to_str() {
+ let suffix = ".wgsl";
+ if let Some(shader_name) = name.strip_suffix(suffix) {
+ let contents = fs::read_to_string(shader_dir.join(&file_name))
+ .unwrap_or_else(|_| panic!("Couldn't read shader {shader_name} contents"));
+ if let Some(permutations) = permutation_map.get(shader_name) {
+ for permutation in permutations {
+ let mut defines = defines.clone();
+ defines.extend(permutation.defines.iter().cloned());
+ let source =
+ preprocess::preprocess(&contents, shader_name, &defines, &imports);
+ match Self::new(&permutation.name, source, "main") {
+ Ok(shader_info) => {
+ info.insert(permutation.name.clone(), shader_info);
+ }
+ Err(e) => {
+ errors.push(e);
+ }
+ }
+ }
+ } else {
+ let source =
+ preprocess::preprocess(&contents, shader_name, &defines, &imports);
+ match Self::new(shader_name, source, "main") {
+ Ok(shader_info) => {
+ info.insert(shader_name.to_string(), shader_info);
+ }
+ Err(e) => {
+ errors.push(e);
+ }
+ }
+ }
+ }
+ }
+ }
+ if !errors.is_empty() {
+ Err(ErrorVec(errors))
+ } else {
+ Ok(info)
+ }
+ }
+}
+
+// TODO: This is a workaround for gfx-rs/wgpu#5476. Since naga can't handle the `enable` directive,
+// we allow its use in other WGSL compilers using our own "#enable" post-process directive. Remove
+// this mechanism once naga supports the directive.
+fn postprocess(wgsl: &str) -> String {
+ let mut output = String::with_capacity(wgsl.len());
+ for line in wgsl.lines() {
+ if line.starts_with("//__#enable") {
+ output.push_str(&line["//__#".len()..]);
+ } else {
+ output.push_str(line);
+ }
+ output.push('\n');
+ }
+ output
+}
+
+/// Returns the absolute path to the directory containing the WGSL shaders.
+///
+/// The path is determined at compile time and is likely only valid on the compiling machine.
+// NOTE: Embedding build environment info into the code makes reproducible builds trickier.
+pub fn shader_dir() -> &'static PathBuf {
+ static SHADER_DIR: OnceLock<PathBuf> = OnceLock::new();
+ SHADER_DIR.get_or_init(|| manifest_dir().join("shader"))
+}
+
+// In a regular cargo build the manifest directory is simply given by CARGO_MANIFEST_DIR.
+//
+// Skia, an external consumer of this crate, uses Bazel rules to compile Rust code. Due to
+// limitations in Bazel's rust support, Skia maintains its own build definitions
+// (https://source.chromium.org/chromium/chromium/src/+/main:third_party/skia/bazel/external/vello/BUILD.bazel).
+//
+// Because of the current setup, Bazel sets CARGO_MANIFEST_DIR to the workspace root instead of the
+// actual crate being built. This could be improved but until then, we work around this by allowing
+// the absolute path to the vello_shader crate's manifest to be specified using the
+// `UNSTABLE_BAZEL_VELLO_SHADERS_CRATE_MANIFEST_PATH` build script environment variable.
+//
+// This should never be set when using cargo.
+fn manifest_dir() -> PathBuf {
+ use std::env;
+ env::var_os("UNSTABLE_BAZEL_VELLO_SHADERS_CRATE_MANIFEST_PATH")
+ .and_then(|p| Path::new(&p).parent().map(|p| p.to_owned()))
+ .unwrap_or_else(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")))
+ .to_path_buf()
+}
diff --git a/vendor/vello_shaders/src/compile/msl.rs b/vendor/vello_shaders/src/compile/msl.rs
new file mode 100644
index 00000000..0626a8b5
--- /dev/null
+++ b/vendor/vello_shaders/src/compile/msl.rs
@@ -0,0 +1,80 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+
+use super::{BindType, ShaderInfo};
+use crate::types::msl::BindingIndex;
+use naga::back::msl as naga_msl;
+
+pub fn translate(shader: &ShaderInfo) -> Result<String, naga_msl::Error> {
+ let mut map = naga_msl::EntryPointResourceMap::default();
+ let mut idx_iter = BindingIndexIterator::default();
+ let mut binding_map = naga_msl::BindingMap::default();
+ for resource in &shader.bindings {
+ let binding = naga::ResourceBinding {
+ group: resource.location.0,
+ binding: resource.location.1,
+ };
+ let mut target = naga_msl::BindTarget::default();
+ match idx_iter.next(resource.ty) {
+ BindingIndex::Buffer(idx) => {
+ target.buffer = Some(idx);
+ }
+ BindingIndex::Texture(idx) => {
+ target.texture = Some(idx);
+ }
+ }
+ target.mutable = resource.ty.is_mutable();
+ binding_map.insert(binding, target);
+ }
+ map.insert(
+ "main".to_string(),
+ naga_msl::EntryPointResources {
+ resources: binding_map,
+ immediates_buffer: None,
+ sizes_buffer: Some(30),
+ },
+ );
+ let options = naga_msl::Options {
+ lang_version: (2, 0),
+ per_entry_point_map: map,
+ inline_samplers: vec![],
+ spirv_cross_compatibility: false,
+ fake_missing_bindings: false,
+ bounds_check_policies: naga::proc::BoundsCheckPolicies::default(),
+ zero_initialize_workgroup_memory: true,
+ force_loop_bounding: true,
+ ..Default::default()
+ };
+ let (source, _) = naga_msl::write_string(
+ &shader.module,
+ &shader.module_info,
+ &options,
+ &naga_msl::PipelineOptions::default(),
+ )?;
+ Ok(source)
+}
+
+#[derive(Default)]
+pub struct BindingIndexIterator {
+ buffer_idx: u8,
+ tex_idx: u8,
+}
+
+impl BindingIndexIterator {
+ pub fn next(&mut self, ty: BindType) -> BindingIndex {
+ match ty {
+ BindType::Buffer | BindType::BufReadOnly | BindType::Uniform => {
+ let idx = self.buffer_idx;
+ self.buffer_idx += 1;
+ assert!(self.buffer_idx > 0);
+ BindingIndex::Buffer(idx)
+ }
+ BindType::Image | BindType::ImageRead => {
+ let idx = self.tex_idx;
+ self.tex_idx += 1;
+ assert!(self.tex_idx > 0);
+ BindingIndex::Texture(idx)
+ }
+ }
+ }
+}
diff --git a/vendor/vello_shaders/src/compile/permutations.rs b/vendor/vello_shaders/src/compile/permutations.rs
new file mode 100644
index 00000000..5cc5bdd8
--- /dev/null
+++ b/vendor/vello_shaders/src/compile/permutations.rs
@@ -0,0 +1,44 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+
+use std::collections::HashMap;
+
+#[derive(Debug)]
+pub struct Permutation {
+ /// The new name for the permutation
+ pub name: String,
+ /// Set of defines to apply for the permutation
+ pub defines: Vec<String>,
+}
+
+pub fn parse(source: &str) -> HashMap<String, Vec<Permutation>> {
+ let mut map: HashMap<String, Vec<Permutation>> = HashMap::default();
+ let mut current_source: Option<String> = None;
+ for line in source.lines() {
+ let line = line.trim();
+ if line.is_empty() || line.starts_with('#') {
+ continue;
+ }
+ if let Some(line) = line.strip_prefix('+') {
+ if let Some(current_source) = &current_source {
+ let mut parts = line.split(':').map(|s| s.trim());
+ let Some(name) = parts.next() else {
+ continue;
+ };
+ let mut defines = vec![];
+ if let Some(define_list) = parts.next() {
+ defines.extend(define_list.split(' ').map(|s| s.trim().to_string()));
+ }
+ map.entry(current_source.to_string())
+ .or_default()
+ .push(Permutation {
+ name: name.to_string(),
+ defines,
+ });
+ }
+ } else {
+ current_source = Some(line.to_string());
+ }
+ }
+ map
+}
diff --git a/vendor/vello_shaders/src/compile/preprocess.rs b/vendor/vello_shaders/src/compile/preprocess.rs
new file mode 100644
index 00000000..71280d3b
--- /dev/null
+++ b/vendor/vello_shaders/src/compile/preprocess.rs
@@ -0,0 +1,184 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+
+use std::collections::{HashMap, HashSet};
+use std::path::Path;
+use std::{fs, vec};
+
+pub fn get_imports(shader_dir: &Path) -> HashMap<String, String> {
+ let mut imports = HashMap::new();
+ let imports_dir = shader_dir.join("shared");
+ for entry in imports_dir
+ .read_dir()
+ .expect("Can read shader import directory")
+ .filter_map(move |e| {
+ e.ok()
+ .filter(|e| e.path().extension().map(|e| e == "wgsl").unwrap_or(false))
+ })
+ {
+ let file_name = entry.file_name();
+ if let Some(name) = file_name.to_str() {
+ let suffix = ".wgsl";
+ if let Some(import_name) = name.strip_suffix(suffix) {
+ let contents = fs::read_to_string(imports_dir.join(&file_name))
+ .unwrap_or_else(|_| panic!("Couldn't read shader {import_name} contents"));
+ imports.insert(import_name.to_owned(), contents);
+ }
+ }
+ }
+ imports
+}
+
+pub struct StackItem {
+ active: bool,
+ else_passed: bool,
+}
+
+pub fn preprocess(
+ input: &str,
+ shader_name: &str,
+ defines: &HashSet<String>,
+ imports: &HashMap<String, String>,
+) -> String {
+ let mut output = String::with_capacity(input.len());
+ let mut stack = vec![];
+ 'all_lines: for (line_number, mut line) in input.lines().enumerate() {
+ loop {
+ if line.is_empty() {
+ break;
+ }
+ let hash_index = line.find('#');
+ let comment_index = line.find("//");
+ let hash_index = match (hash_index, comment_index) {
+ (Some(hash_index), None) => hash_index,
+ (Some(hash_index), Some(comment_index)) if hash_index < comment_index => hash_index,
+ // Add this line to the output - all directives are commented out or there are no directives
+ _ => break,
+ };
+ let directive_start = &line[hash_index + '#'.len_utf8()..];
+ let directive_len = directive_start
+ // The first character which can't be part of the directive name marks the end of the directive
+ // In practise this should always be whitespace, but in theory a 'unit' directive
+ // could be added
+ .find(|c: char| !c.is_alphanumeric())
+ .unwrap_or(directive_start.len());
+ let directive = &directive_start[..directive_len];
+ let directive_is_at_start = line.trim_start().starts_with('#');
+
+ match directive {
+ item @ ("ifdef" | "ifndef" | "else" | "endif" | "enable")
+ if !directive_is_at_start =>
+ {
+ log::warn!(
+ "#{item} directives must be the first non_whitespace items on \
+ their line, ignoring (line {line_number} of {shader_name}.wgsl)"
+ );
+ break;
+ }
+ def_test @ ("ifdef" | "ifndef") => {
+ let def = directive_start[directive_len..].trim();
+ let exists = defines.contains(def);
+ let mode = def_test == "ifdef";
+ stack.push(StackItem {
+ active: mode == exists,
+ else_passed: false,
+ });
+ // Don't add this line to the output; instead process the next line
+ continue 'all_lines;
+ }
+ "else" => {
+ let item = stack.last_mut();
+ if let Some(item) = item {
+ if item.else_passed {
+ log::warn!(
+ "Second else for same ifdef/ifndef (line {line_number} of {shader_name}.wgsl); \
+ ignoring second else"
+ );
+ } else {
+ item.else_passed = true;
+ item.active = !item.active;
+ }
+ }
+ let remainder = directive_start[directive_len..].trim();
+ if !remainder.is_empty() {
+ log::warn!(
+ "#else directives don't take an argument. `{remainder}` will not \
+ be in output (line {line_number} of {shader_name}.wgsl)"
+ );
+ }
+ // Don't add this line to the output; it should be empty (see warning above)
+ continue 'all_lines;
+ }
+ "endif" => {
+ if stack.pop().is_none() {
+ log::warn!("Mismatched endif (line {line_number} of {shader_name}.wgsl)");
+ }
+ let remainder = directive_start[directive_len..].trim();
+ if !remainder.is_empty() && !remainder.starts_with("//") {
+ log::warn!(
+ "#endif directives don't take an argument. `{remainder}` will \
+ not be in output (line {line_number} of {shader_name}.wgsl)"
+ );
+ }
+ // Don't add this line to the output; it should be empty (see warning above)
+ continue 'all_lines;
+ }
+ "import" => {
+ output.push_str(&line[..hash_index]);
+ let directive_end = &directive_start[directive_len..];
+ let import_name_start = if let Some(import_name_start) =
+ directive_end.find(|c: char| !c.is_whitespace())
+ {
+ import_name_start
+ } else {
+ log::warn!(
+ "#import needs a non_whitespace argument (line {line_number} of {shader_name}.wgsl)"
+ );
+ continue 'all_lines;
+ };
+ let import_name_start = &directive_end[import_name_start..];
+ let import_name_end_index = import_name_start
+ // The first character which can't be part of the import name marks the end of the import
+ .find(|c: char| !(c == '_' || c.is_alphanumeric()))
+ .unwrap_or(import_name_start.len());
+ let import_name = &import_name_start[..import_name_end_index];
+ line = &import_name_start[import_name_end_index..];
+ let import = imports.get(import_name);
+ if let Some(import) = import {
+ // In theory, we can cache this until the top item of the stack changes
+ // However, in practise there will only ever be at most 2 stack items, so
+ // it's reasonable to just recompute it every time
+ if stack.iter().all(|item| item.active) {
+ output.push_str(&preprocess(import, shader_name, defines, imports));
+ }
+ } else {
+ log::warn!(
+ "Unknown import `{import_name}` (line {line_number} of {shader_name}.wgsl)"
+ );
+ }
+ continue;
+ }
+ "enable" => {
+ // Turn this directive into a comment. It will be handled as part in
+ // postprocess.
+ if stack.iter().all(|item| item.active) {
+ output.push_str("//__");
+ output.push_str(line);
+ output.push('\n');
+ }
+ continue 'all_lines;
+ }
+ val => {
+ log::warn!(
+ "Unknown preprocessor directive `{val}` (line {line_number} of {shader_name}.wgsl)"
+ );
+ }
+ }
+ }
+ if stack.iter().all(|item| item.active) {
+ output.push_str(line);
+ output.push('\n');
+ }
+ }
+ output
+}
diff --git a/vendor/vello_shaders/src/cpu.rs b/vendor/vello_shaders/src/cpu.rs
new file mode 100644
index 00000000..0804283f
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu.rs
@@ -0,0 +1,197 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+
+//! Support for CPU implementations of compute shaders.
+//!
+//! Note that while this CPU implementation is useful for testing and debugging,
+//! a full CPU fallback as an alternative to GPU shaders is not provided.
+
+// Allow un-idiomatic Rust to more closely match shaders
+#![expect(
+ clippy::needless_range_loop,
+ reason = "Keeps code easily comparable to GPU shaders"
+)]
+
+mod backdrop;
+mod bbox_clear;
+mod binning;
+mod clip_leaf;
+mod clip_reduce;
+mod coarse;
+mod draw_leaf;
+mod draw_reduce;
+mod euler;
+mod fine;
+mod flatten;
+mod path_count;
+mod path_count_setup;
+mod path_tiling;
+mod path_tiling_setup;
+mod pathtag_reduce;
+mod pathtag_scan;
+mod tile_alloc;
+mod util;
+
+pub use backdrop::backdrop;
+pub use bbox_clear::bbox_clear;
+pub use binning::binning;
+pub use clip_leaf::clip_leaf;
+pub use clip_reduce::clip_reduce;
+pub use coarse::coarse;
+pub use draw_leaf::draw_leaf;
+pub use draw_reduce::draw_reduce;
+pub use flatten::flatten;
+pub use path_count::path_count;
+pub use path_count_setup::path_count_setup;
+pub use path_tiling::path_tiling;
+pub use path_tiling_setup::path_tiling_setup;
+pub use pathtag_reduce::pathtag_reduce;
+pub use pathtag_scan::pathtag_scan;
+pub use tile_alloc::tile_alloc;
+
+use std::cell::{Ref, RefCell, RefMut};
+use std::ops::{Deref, DerefMut};
+
+use bytemuck::Pod;
+
+#[derive(Clone, Copy)]
+pub enum CpuBinding<'a> {
+ Buffer(&'a [u8]),
+ BufferRW(&'a RefCell<Vec<u8>>),
+ Texture(&'a CpuTexture),
+}
+
+pub enum TypedBufGuard<'a, T: ?Sized> {
+ Slice(&'a T),
+ Interior(Ref<'a, T>),
+}
+
+pub enum TypedBufGuardMut<'a, T: ?Sized> {
+ Slice(&'a mut T),
+ Interior(RefMut<'a, T>),
+}
+
+impl<T: ?Sized> Deref for TypedBufGuard<'_, T> {
+ type Target = T;
+
+ fn deref(&self) -> &Self::Target {
+ match self {
+ TypedBufGuard::Slice(s) => s,
+ TypedBufGuard::Interior(r) => r,
+ }
+ }
+}
+
+impl<T: ?Sized> Deref for TypedBufGuardMut<'_, T> {
+ type Target = T;
+
+ fn deref(&self) -> &Self::Target {
+ match self {
+ TypedBufGuardMut::Slice(s) => s,
+ TypedBufGuardMut::Interior(r) => r,
+ }
+ }
+}
+
+impl<T: ?Sized> DerefMut for TypedBufGuardMut<'_, T> {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ match self {
+ TypedBufGuardMut::Slice(s) => s,
+ TypedBufGuardMut::Interior(r) => r,
+ }
+ }
+}
+
+impl CpuBinding<'_> {
+ pub fn as_typed<T: Pod>(&self) -> TypedBufGuard<'_, T> {
+ match self {
+ CpuBinding::Buffer(b) => TypedBufGuard::Slice(bytemuck::from_bytes(b)),
+ CpuBinding::BufferRW(b) => {
+ TypedBufGuard::Interior(Ref::map(b.borrow(), |buf| bytemuck::from_bytes(buf)))
+ }
+ _ => panic!("resource type mismatch"),
+ }
+ }
+
+ pub fn as_typed_mut<T: Pod>(&self) -> TypedBufGuardMut<'_, T> {
+ match self {
+ CpuBinding::Buffer(_) => panic!("can't borrow external buffer mutably"),
+ CpuBinding::BufferRW(b) => {
+ TypedBufGuardMut::Interior(RefMut::map(b.borrow_mut(), |buf| {
+ bytemuck::from_bytes_mut(buf)
+ }))
+ }
+ _ => panic!("resource type mismatch"),
+ }
+ }
+
+ pub fn as_slice<T: Pod>(&self) -> TypedBufGuard<'_, [T]> {
+ match self {
+ CpuBinding::Buffer(b) => TypedBufGuard::Slice(bytemuck::cast_slice(b)),
+ CpuBinding::BufferRW(b) => {
+ TypedBufGuard::Interior(Ref::map(b.borrow(), |buf| bytemuck::cast_slice(buf)))
+ }
+ _ => panic!("resource type mismatch"),
+ }
+ }
+
+ pub fn as_slice_mut<T: Pod>(&self) -> TypedBufGuardMut<'_, [T]> {
+ match self {
+ CpuBinding::Buffer(_) => panic!("can't borrow external buffer mutably"),
+ CpuBinding::BufferRW(b) => {
+ TypedBufGuardMut::Interior(RefMut::map(b.borrow_mut(), |buf| {
+ bytemuck::cast_slice_mut(buf)
+ }))
+ }
+ _ => panic!("resource type mismatch"),
+ }
+ }
+
+ // TODO: same guard as buf to make mutable
+ pub fn as_tex(&self) -> &CpuTexture {
+ match self {
+ CpuBinding::Texture(t) => t,
+ _ => panic!("resource type mismatch"),
+ }
+ }
+}
+
+/// Structure used for binding textures to CPU shaders.
+pub struct CpuTexture {
+ pub width: usize,
+ pub height: usize,
+ // In RGBA format. May expand in the future.
+ pub pixels: Vec<u32>,
+}
+
+// Common internal definitions
+
+const PTCL_INITIAL_ALLOC: u32 = 64;
+
+// Tags for PTCL commands
+const CMD_END: u32 = 0;
+const CMD_FILL: u32 = 1;
+//const CMD_STROKE: u32 = 2;
+const CMD_SOLID: u32 = 3;
+const CMD_COLOR: u32 = 5;
+const CMD_LIN_GRAD: u32 = 6;
+const CMD_RAD_GRAD: u32 = 7;
+const CMD_SWEEP_GRAD: u32 = 8;
+const CMD_IMAGE: u32 = 9;
+const CMD_BEGIN_CLIP: u32 = 10;
+const CMD_END_CLIP: u32 = 11;
+const CMD_JUMP: u32 = 12;
+const CMD_BLUR_RECT: u32 = 13;
+
+// The following are computed in draw_leaf from the generic gradient parameters
+// encoded in the scene, and stored in the gradient's info struct, for
+// consumption during fine rasterization.
+
+// Radial gradient kinds
+const RAD_GRAD_KIND_CIRCULAR: u32 = 1;
+const RAD_GRAD_KIND_STRIP: u32 = 2;
+const RAD_GRAD_KIND_FOCAL_ON_CIRCLE: u32 = 3;
+const RAD_GRAD_KIND_CONE: u32 = 4;
+
+// Radial gradient flags
+const RAD_GRAD_SWAPPED: u32 = 1;
diff --git a/vendor/vello_shaders/src/cpu/backdrop.rs b/vendor/vello_shaders/src/cpu/backdrop.rs
new file mode 100644
index 00000000..7539a980
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/backdrop.rs
@@ -0,0 +1,31 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{BumpAllocators, ConfigUniform, Path, Tile};
+
+use super::CpuBinding;
+
+fn backdrop_main(config: &ConfigUniform, _: &BumpAllocators, paths: &[Path], tiles: &mut [Tile]) {
+ for drawobj_ix in 0..config.layout.n_draw_objects {
+ let path = paths[drawobj_ix as usize];
+ let width = path.bbox[2] - path.bbox[0];
+ let height = path.bbox[3] - path.bbox[1];
+ let base = path.tiles;
+ for y in 0..height {
+ let mut sum = 0;
+ for x in 0..width {
+ let tile = &mut tiles[(base + y * width + x) as usize];
+ sum += tile.backdrop;
+ tile.backdrop = sum;
+ }
+ }
+ }
+}
+
+pub fn backdrop(_n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let config = resources[0].as_typed();
+ let bump = resources[1].as_typed();
+ let paths = resources[2].as_slice();
+ let mut tiles = resources[3].as_slice_mut();
+ backdrop_main(&config, &bump, &paths, &mut tiles);
+}
diff --git a/vendor/vello_shaders/src/cpu/bbox_clear.rs b/vendor/vello_shaders/src/cpu/bbox_clear.rs
new file mode 100644
index 00000000..5932f286
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/bbox_clear.rs
@@ -0,0 +1,21 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{ConfigUniform, PathBbox};
+
+use super::CpuBinding;
+
+fn bbox_clear_main(config: &ConfigUniform, path_bboxes: &mut [PathBbox]) {
+ for i in 0..(config.layout.n_paths as usize) {
+ path_bboxes[i].x0 = 0x7fff_ffff;
+ path_bboxes[i].y0 = 0x7fff_ffff;
+ path_bboxes[i].x1 = -0x8000_0000;
+ path_bboxes[i].y1 = -0x8000_0000;
+ }
+}
+
+pub fn bbox_clear(_n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let config = resources[0].as_typed();
+ let mut path_bboxes = resources[1].as_slice_mut();
+ bbox_clear_main(&config, &mut path_bboxes);
+}
diff --git a/vendor/vello_shaders/src/cpu/binning.rs b/vendor/vello_shaders/src/cpu/binning.rs
new file mode 100644
index 00000000..fb864420
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/binning.rs
@@ -0,0 +1,130 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{BinHeader, BumpAllocators, ConfigUniform, DrawMonoid, PathBbox};
+
+use super::CpuBinding;
+
+const WG_SIZE: usize = 256;
+const TILE_WIDTH: usize = 16;
+const TILE_HEIGHT: usize = 16;
+const N_TILE_X: usize = 16;
+const N_TILE_Y: usize = 16;
+const SX: f32 = 1.0 / ((N_TILE_X * TILE_WIDTH) as f32);
+const SY: f32 = 1.0 / ((N_TILE_Y * TILE_HEIGHT) as f32);
+
+fn bbox_intersect(a: [f32; 4], b: [f32; 4]) -> [f32; 4] {
+ [
+ a[0].max(b[0]),
+ a[1].max(b[1]),
+ a[2].min(b[2]),
+ a[3].min(b[3]),
+ ]
+}
+
+fn binning_main(
+ n_wg: u32,
+ config: &ConfigUniform,
+ draw_monoids: &[DrawMonoid],
+ path_bbox_buf: &[PathBbox],
+ clip_bbox_buf: &[[f32; 4]],
+ intersected_bbox: &mut [[f32; 4]],
+ bump: &mut BumpAllocators,
+ bin_data: &mut [u32],
+ bin_header: &mut [BinHeader],
+) {
+ let width_in_bins = config.width_in_tiles.div_ceil(N_TILE_X as u32) as i32;
+ let height_in_bins = config.height_in_tiles.div_ceil(N_TILE_Y as u32) as i32;
+ let n_bins = (width_in_bins * height_in_bins) as usize;
+ for wg in 0..n_wg as usize {
+ let mut counts = vec![0; n_bins];
+ let mut bboxes = [[0, 0, 0, 0]; WG_SIZE];
+ for local_ix in 0..WG_SIZE {
+ let element_ix = wg * WG_SIZE + local_ix;
+ let mut x0 = 0;
+ let mut y0 = 0;
+ let mut x1 = 0;
+ let mut y1 = 0;
+ if element_ix < config.layout.n_draw_objects as usize {
+ let draw_monoid = draw_monoids[element_ix];
+ let mut clip_bbox = [-1e9, -1e9, 1e9, 1e9];
+ if draw_monoid.clip_ix > 0 {
+ assert!(draw_monoid.clip_ix - 1 < config.layout.n_clips);
+ clip_bbox = clip_bbox_buf[draw_monoid.clip_ix as usize - 1];
+ }
+ let path_bbox = path_bbox_buf[draw_monoid.path_ix as usize];
+ let pb = [
+ path_bbox.x0 as f32,
+ path_bbox.y0 as f32,
+ path_bbox.x1 as f32,
+ path_bbox.y1 as f32,
+ ];
+ let bbox = bbox_intersect(clip_bbox, pb);
+ intersected_bbox[element_ix] = bbox;
+ if bbox[0] < bbox[2] && bbox[1] < bbox[3] {
+ x0 = (bbox[0] * SX).floor() as i32;
+ y0 = (bbox[1] * SY).floor() as i32;
+ x1 = (bbox[2] * SX).ceil() as i32;
+ y1 = (bbox[3] * SY).ceil() as i32;
+ }
+ }
+ x0 = x0.clamp(0, width_in_bins);
+ y0 = y0.clamp(0, height_in_bins);
+ x1 = x1.clamp(0, width_in_bins);
+ y1 = y1.clamp(0, height_in_bins);
+ for y in y0..y1 {
+ for x in x0..x1 {
+ counts[(y * width_in_bins + x) as usize] += 1;
+ }
+ }
+ bboxes[local_ix] = [x0, y0, x1, y1];
+ }
+ let mut chunk_offset = vec![0; n_bins];
+ let aligned_n_bins = (n_bins + 255) & !255;
+ // Looping on the number of bins instead of workgroup sized chunks, not idiomatic of gpus
+ // Oh well!
+ for local_ix in 0..n_bins {
+ let global_ix = wg * aligned_n_bins + local_ix;
+ chunk_offset[local_ix] = bump.binning;
+ bump.binning += counts[local_ix];
+ bin_header[global_ix] = BinHeader {
+ element_count: counts[local_ix],
+ chunk_offset: chunk_offset[local_ix],
+ };
+ }
+ for local_ix in 0..WG_SIZE {
+ let element_ix = wg * WG_SIZE + local_ix;
+ let bbox = bboxes[local_ix];
+ for y in bbox[1]..bbox[3] {
+ for x in bbox[0]..bbox[2] {
+ let bin_ix = (y * width_in_bins + x) as usize;
+ let ix = config.layout.bin_data_start + chunk_offset[bin_ix];
+ bin_data[ix as usize] = element_ix as u32;
+ chunk_offset[bin_ix] += 1;
+ }
+ }
+ }
+ }
+}
+
+pub fn binning(n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let config = resources[0].as_typed();
+ let draw_monoids = resources[1].as_slice();
+ let path_bbox_buf = resources[2].as_slice();
+ let clip_bbox_buf = resources[3].as_slice();
+ let mut intersected_bbox = resources[4].as_slice_mut();
+ let mut bump = resources[5].as_typed_mut();
+ let mut bin_data = resources[6].as_slice_mut();
+ let mut bin_header = resources[7].as_slice_mut();
+ binning_main(
+ n_wg,
+ &config,
+ &draw_monoids,
+ &path_bbox_buf,
+ &clip_bbox_buf,
+ &mut intersected_bbox,
+ &mut bump,
+ &mut bin_data,
+ &mut bin_header,
+ );
+}
diff --git a/vendor/vello_shaders/src/cpu/clip_leaf.rs b/vendor/vello_shaders/src/cpu/clip_leaf.rs
new file mode 100644
index 00000000..80633100
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/clip_leaf.rs
@@ -0,0 +1,88 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{Clip, ConfigUniform, DrawMonoid, PathBbox};
+
+use super::CpuBinding;
+
+struct ClipStackElement {
+ // index of draw object
+ parent_ix: u32,
+ path_ix: u32,
+ bbox: [f32; 4],
+}
+
+const BIG_BBOX: [f32; 4] = [-1e9, -1e9, 1e9, 1e9];
+
+// Note: this implementation doesn't rigorously follow the
+// WGSL original. In particular, it just computes the clips
+// sequentially rather than using the partition reductions.
+fn clip_leaf_main(
+ config: &ConfigUniform,
+ clip_inp: &[Clip],
+ path_bboxes: &[PathBbox],
+ draw_monoids: &mut [DrawMonoid],
+ clip_bboxes: &mut [[f32; 4]],
+) {
+ let mut stack: Vec<ClipStackElement> = Vec::new();
+ for global_ix in 0..config.layout.n_clips {
+ let clip_el = clip_inp[global_ix as usize];
+ if clip_el.path_ix >= 0 {
+ // begin clip
+ let path_ix = clip_el.path_ix as u32;
+ let path_bbox = path_bboxes[path_ix as usize];
+ let p_bbox = [
+ path_bbox.x0 as f32,
+ path_bbox.y0 as f32,
+ path_bbox.x1 as f32,
+ path_bbox.y1 as f32,
+ ];
+ let bbox = if let Some(last) = stack.last() {
+ [
+ p_bbox[0].max(last.bbox[0]),
+ p_bbox[1].max(last.bbox[1]),
+ p_bbox[2].min(last.bbox[2]),
+ p_bbox[3].min(last.bbox[3]),
+ ]
+ } else {
+ p_bbox
+ };
+ clip_bboxes[global_ix as usize] = bbox;
+ let parent_ix = clip_el.ix;
+ stack.push(ClipStackElement {
+ parent_ix,
+ path_ix,
+ bbox,
+ });
+ } else {
+ // end clip
+ let tos = stack.pop().unwrap();
+ let bbox = if let Some(nos) = stack.last() {
+ nos.bbox
+ } else {
+ BIG_BBOX
+ };
+ clip_bboxes[global_ix as usize] = bbox;
+ draw_monoids[clip_el.ix as usize].path_ix = tos.path_ix;
+ draw_monoids[clip_el.ix as usize].scene_offset =
+ draw_monoids[tos.parent_ix as usize].scene_offset;
+ draw_monoids[clip_el.ix as usize].info_offset =
+ draw_monoids[tos.parent_ix as usize].info_offset;
+ }
+ }
+}
+
+pub fn clip_leaf(_n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let config = resources[0].as_typed();
+ let clip_inp = resources[1].as_slice();
+ let path_bboxes = resources[2].as_slice();
+ let mut draw_monoids = resources[5].as_slice_mut();
+ let mut clip_bboxes = resources[6].as_slice_mut();
+ clip_leaf_main(
+ &config,
+ &clip_inp,
+ &path_bboxes,
+ &mut draw_monoids,
+ &mut clip_bboxes,
+ );
+}
diff --git a/vendor/vello_shaders/src/cpu/clip_reduce.rs b/vendor/vello_shaders/src/cpu/clip_reduce.rs
new file mode 100644
index 00000000..88bae857
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/clip_reduce.rs
@@ -0,0 +1,56 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{Clip, ClipBic, ClipElement, PathBbox};
+
+use super::CpuBinding;
+
+const WG_SIZE: usize = 256;
+
+fn clip_reduce_main(
+ n_wg: u32,
+ clip_inp: &[Clip],
+ path_bboxes: &[PathBbox],
+ reduced: &mut [ClipBic],
+ clip_out: &mut [ClipElement],
+) {
+ let mut scratch = Vec::with_capacity(WG_SIZE);
+ for wg_ix in 0..n_wg {
+ scratch.clear();
+ let mut bic_reduced = ClipBic::default();
+ // reverse scan
+ for local_ix in (0..WG_SIZE).rev() {
+ let global_ix = wg_ix as usize * WG_SIZE + local_ix;
+ let inp = clip_inp[global_ix].path_ix;
+ let is_push = inp >= 0;
+ let bic = ClipBic::new(1 - is_push as u32, is_push as u32);
+ if is_push && bic_reduced.a == 0 {
+ scratch.push(global_ix as u32);
+ }
+ bic_reduced = bic.combine(bic_reduced);
+ }
+ reduced[wg_ix as usize] = bic_reduced;
+ for (i, parent_ix) in scratch.iter().rev().enumerate() {
+ let mut clip_el = ClipElement::default();
+ clip_el.parent_ix = *parent_ix;
+ let path_ix = clip_inp[*parent_ix as usize].path_ix;
+ let path_bbox = path_bboxes[path_ix as usize];
+ clip_el.bbox = [
+ path_bbox.x0 as f32,
+ path_bbox.y0 as f32,
+ path_bbox.x1 as f32,
+ path_bbox.y1 as f32,
+ ];
+ let global_ix = wg_ix as usize * WG_SIZE + i;
+ clip_out[global_ix] = clip_el;
+ }
+ }
+}
+
+pub fn clip_reduce(n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let clip_inp = resources[0].as_slice();
+ let path_bboxes = resources[1].as_slice();
+ let mut reduced = resources[2].as_slice_mut();
+ let mut clip_out = resources[3].as_slice_mut();
+ clip_reduce_main(n_wg, &clip_inp, &path_bboxes, &mut reduced, &mut clip_out);
+}
diff --git a/vendor/vello_shaders/src/cpu/coarse.rs b/vendor/vello_shaders/src/cpu/coarse.rs
new file mode 100644
index 00000000..566ce6f7
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/coarse.rs
@@ -0,0 +1,413 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use std::cmp::max;
+
+use vello_encoding::{
+ BinHeader, BumpAllocators, ConfigUniform, DRAW_INFO_FLAGS_FILL_RULE_BIT, DrawMonoid, DrawTag,
+ Path, Tile,
+};
+
+use super::{
+ CMD_BEGIN_CLIP, CMD_BLUR_RECT, CMD_COLOR, CMD_END, CMD_END_CLIP, CMD_FILL, CMD_IMAGE, CMD_JUMP,
+ CMD_LIN_GRAD, CMD_RAD_GRAD, CMD_SOLID, CMD_SWEEP_GRAD, CpuBinding, PTCL_INITIAL_ALLOC,
+};
+
+// Tiles per bin
+const N_TILE_X: usize = 16;
+const N_TILE_Y: usize = 16;
+const N_TILE: usize = N_TILE_X * N_TILE_Y;
+
+// If changing also change in config.wgsl
+const BLEND_STACK_SPLIT: u32 = 4;
+
+// Pixels per tile
+const TILE_WIDTH: u32 = 16;
+const TILE_HEIGHT: u32 = 16;
+
+const PTCL_INCREMENT: u32 = 256;
+const PTCL_HEADROOM: u32 = 2;
+
+// Modeled in the WGSL as private-scoped variables
+struct TileState {
+ cmd_offset: u32,
+ cmd_limit: u32,
+}
+
+impl TileState {
+ fn new(tile_ix: u32) -> Self {
+ let cmd_offset = tile_ix * PTCL_INITIAL_ALLOC;
+ let cmd_limit = cmd_offset + (PTCL_INITIAL_ALLOC - PTCL_HEADROOM);
+ Self {
+ cmd_offset,
+ cmd_limit,
+ }
+ }
+
+ fn alloc_cmd(
+ &mut self,
+ size: u32,
+ config: &ConfigUniform,
+ bump: &mut BumpAllocators,
+ ptcl: &mut [u32],
+ ) {
+ if self.cmd_offset + size >= self.cmd_limit {
+ let ptcl_dyn_start =
+ config.width_in_tiles * config.height_in_tiles * PTCL_INITIAL_ALLOC;
+ let chunk_size = PTCL_INCREMENT.max(size + PTCL_HEADROOM);
+ let new_cmd = ptcl_dyn_start + bump.ptcl;
+ bump.ptcl += chunk_size;
+ ptcl[self.cmd_offset as usize] = CMD_JUMP;
+ ptcl[self.cmd_offset as usize + 1] = new_cmd;
+ self.cmd_offset = new_cmd;
+ self.cmd_limit = new_cmd + (PTCL_INCREMENT - PTCL_HEADROOM);
+ }
+ }
+
+ fn write(&mut self, ptcl: &mut [u32], offset: u32, value: u32) {
+ ptcl[(self.cmd_offset + offset) as usize] = value;
+ }
+
+ fn write_path(
+ &mut self,
+ config: &ConfigUniform,
+ bump: &mut BumpAllocators,
+ ptcl: &mut [u32],
+ tile: &mut Tile,
+ draw_flags: u32,
+ ) {
+ let n_segs = tile.segment_count_or_ix;
+ if n_segs != 0 {
+ let seg_ix = bump.segments;
+ tile.segment_count_or_ix = !seg_ix;
+ bump.segments += n_segs;
+ self.alloc_cmd(4, config, bump, ptcl);
+ self.write(ptcl, 0, CMD_FILL);
+ let even_odd = (draw_flags & DRAW_INFO_FLAGS_FILL_RULE_BIT) != 0;
+ let size_and_rule = (n_segs << 1) | (even_odd as u32);
+ self.write(ptcl, 1, size_and_rule);
+ self.write(ptcl, 2, seg_ix);
+ self.write(ptcl, 3, tile.backdrop as u32);
+ self.cmd_offset += 4;
+ } else {
+ self.alloc_cmd(1, config, bump, ptcl);
+ self.write(ptcl, 0, CMD_SOLID);
+ self.cmd_offset += 1;
+ }
+ }
+
+ fn write_color(
+ &mut self,
+ config: &ConfigUniform,
+ bump: &mut BumpAllocators,
+ ptcl: &mut [u32],
+ rgba_color: u32,
+ ) {
+ self.alloc_cmd(2, config, bump, ptcl);
+ self.write(ptcl, 0, CMD_COLOR);
+ self.write(ptcl, 1, rgba_color);
+ self.cmd_offset += 2;
+ }
+
+ fn write_image(
+ &mut self,
+ config: &ConfigUniform,
+ bump: &mut BumpAllocators,
+ ptcl: &mut [u32],
+ info_offset: u32,
+ ) {
+ self.alloc_cmd(2, config, bump, ptcl);
+ self.write(ptcl, 0, CMD_IMAGE);
+ self.write(ptcl, 1, info_offset);
+ self.cmd_offset += 2;
+ }
+
+ fn write_grad(
+ &mut self,
+ config: &ConfigUniform,
+ bump: &mut BumpAllocators,
+ ptcl: &mut [u32],
+ ty: u32,
+ index: u32,
+ info_offset: u32,
+ ) {
+ self.alloc_cmd(3, config, bump, ptcl);
+ self.write(ptcl, 0, ty);
+ self.write(ptcl, 1, index);
+ self.write(ptcl, 2, info_offset);
+ self.cmd_offset += 3;
+ }
+
+ fn write_blur_rect(
+ &mut self,
+ config: &ConfigUniform,
+ bump: &mut BumpAllocators,
+ ptcl: &mut [u32],
+ rgba_color: u32,
+ info_offset: u32,
+ ) {
+ self.alloc_cmd(3, config, bump, ptcl);
+ self.write(ptcl, 0, CMD_BLUR_RECT);
+ self.write(ptcl, 1, info_offset);
+ self.write(ptcl, 2, rgba_color);
+ self.cmd_offset += 3;
+ }
+
+ fn write_begin_clip(
+ &mut self,
+ config: &ConfigUniform,
+ bump: &mut BumpAllocators,
+ ptcl: &mut [u32],
+ ) {
+ self.alloc_cmd(1, config, bump, ptcl);
+ self.write(ptcl, 0, CMD_BEGIN_CLIP);
+ self.cmd_offset += 1;
+ }
+
+ fn write_end_clip(
+ &mut self,
+ config: &ConfigUniform,
+ bump: &mut BumpAllocators,
+ ptcl: &mut [u32],
+ blend: u32,
+ alpha: f32,
+ ) {
+ self.alloc_cmd(3, config, bump, ptcl);
+ self.write(ptcl, 0, CMD_END_CLIP);
+ self.write(ptcl, 1, blend);
+ self.write(ptcl, 2, f32::to_bits(alpha));
+ self.cmd_offset += 3;
+ }
+}
+
+fn coarse_main(
+ config: &ConfigUniform,
+ scene: &[u32],
+ draw_monoids: &[DrawMonoid],
+ bin_headers: &[BinHeader],
+ info_bin_data: &[u32],
+ paths: &[Path],
+ tiles: &mut [Tile],
+ bump: &mut BumpAllocators,
+ ptcl: &mut [u32],
+) {
+ let width_in_tiles = config.width_in_tiles;
+ let height_in_tiles = config.height_in_tiles;
+ let width_in_bins = width_in_tiles.div_ceil(N_TILE_X as u32);
+ let height_in_bins = height_in_tiles.div_ceil(N_TILE_Y as u32);
+ let n_bins = width_in_bins * height_in_bins;
+ let aligned_n_bins = (n_bins + 255) & !255;
+ let bin_data_start = config.layout.bin_data_start;
+ let drawtag_base = config.layout.draw_tag_base;
+ let mut compacted = vec![vec![]; N_TILE];
+ let n_partitions = config.layout.n_draw_objects.div_ceil(N_TILE as u32);
+ for bin in 0..n_bins {
+ for v in &mut compacted {
+ v.clear();
+ }
+ let bin_x = bin % width_in_bins;
+ let bin_y = bin / width_in_bins;
+ let bin_tile_x = N_TILE_X as u32 * bin_x;
+ let bin_tile_y = N_TILE_Y as u32 * bin_y;
+ for part in 0..n_partitions {
+ let in_ix = part * aligned_n_bins + bin;
+ let bin_header = bin_headers[in_ix as usize];
+ let start = bin_data_start + bin_header.chunk_offset;
+ for i in 0..bin_header.element_count {
+ let drawobj_ix = info_bin_data[(start + i) as usize];
+ let tag = scene[(drawtag_base + drawobj_ix) as usize];
+ if DrawTag(tag) != DrawTag::NOP {
+ let draw_monoid = draw_monoids[drawobj_ix as usize];
+ let path_ix = draw_monoid.path_ix;
+ let path = paths[path_ix as usize];
+ let dx = path.bbox[0] as i32 - bin_tile_x as i32;
+ let dy = path.bbox[1] as i32 - bin_tile_y as i32;
+ let x0 = dx.clamp(0, N_TILE_X as i32);
+ let y0 = dy.clamp(0, N_TILE_Y as i32);
+ let x1 = (path.bbox[2] as i32 - bin_tile_x as i32).clamp(0, N_TILE_X as i32);
+ let y1 = (path.bbox[3] as i32 - bin_tile_y as i32).clamp(0, N_TILE_Y as i32);
+ for y in y0..y1 {
+ for x in x0..x1 {
+ compacted[(y * N_TILE_X as i32 + x) as usize].push(drawobj_ix);
+ }
+ }
+ }
+ }
+ }
+ // compacted now has the list of draw objects for each tile.
+ // While the WGSL source does at most 256 draw objects at a time,
+ // this version does all the draw objects in a tile.
+ for tile_ix in 0..N_TILE {
+ let tile_x = (tile_ix % N_TILE_X) as u32;
+ let tile_y = (tile_ix / N_TILE_X) as u32;
+ let this_tile_ix = (bin_tile_y + tile_y) * width_in_tiles + bin_tile_x + tile_x;
+ let mut tile_state = TileState::new(this_tile_ix);
+ let blend_offset = tile_state.cmd_offset;
+ tile_state.cmd_offset += 1;
+ let mut clip_depth = 0;
+ let mut render_blend_depth = 0;
+ let mut max_blend_depth = 0_u32;
+ let mut clip_zero_depth = 0;
+ for drawobj_ix in &compacted[tile_ix] {
+ let drawtag = scene[(drawtag_base + drawobj_ix) as usize];
+ if clip_zero_depth == 0 {
+ let draw_monoid = draw_monoids[*drawobj_ix as usize];
+ let path_ix = draw_monoid.path_ix;
+ let path = paths[path_ix as usize];
+ let bbox = path.bbox;
+ let stride = bbox[2] - bbox[0];
+ let x = bin_tile_x + tile_x - bbox[0];
+ let y = bin_tile_y + tile_y - bbox[1];
+ let tile = &mut tiles[(path.tiles + y * stride + x) as usize];
+ let is_clip = (drawtag & 1) != 0;
+ let mut is_blend = false;
+ let dd = config.layout.draw_data_base + draw_monoid.scene_offset;
+ let di = draw_monoid.info_offset;
+ if is_clip {
+ const BLEND_CLIP: u32 = (128 << 8) | 3;
+ let blend = scene[dd as usize];
+ is_blend = blend != BLEND_CLIP;
+ }
+
+ let draw_flags = info_bin_data[di as usize];
+ let even_odd = (draw_flags & DRAW_INFO_FLAGS_FILL_RULE_BIT) != 0;
+ let n_segs = tile.segment_count_or_ix;
+
+ // If this draw object represents an even-odd fill and we know that no line segment
+ // crosses this tile and then this draw object should not contribute to the tile if its
+ // backdrop (i.e. the winding number of its top-left corner) is even.
+ let backdrop_clear = if even_odd {
+ tile.backdrop.abs() & 1
+ } else {
+ tile.backdrop
+ } == 0;
+ let include_tile = n_segs != 0 || (backdrop_clear == is_clip) || is_blend;
+ if include_tile {
+ match DrawTag(drawtag) {
+ DrawTag::COLOR => {
+ tile_state.write_path(config, bump, ptcl, tile, draw_flags);
+ let rgba_color = scene[dd as usize];
+ tile_state.write_color(config, bump, ptcl, rgba_color);
+ }
+ DrawTag::IMAGE => {
+ tile_state.write_path(config, bump, ptcl, tile, draw_flags);
+ tile_state.write_image(config, bump, ptcl, di + 1);
+ }
+ DrawTag::LINEAR_GRADIENT => {
+ tile_state.write_path(config, bump, ptcl, tile, draw_flags);
+ let index = scene[dd as usize];
+ tile_state.write_grad(
+ config,
+ bump,
+ ptcl,
+ CMD_LIN_GRAD,
+ index,
+ di + 1,
+ );
+ }
+ DrawTag::RADIAL_GRADIENT => {
+ tile_state.write_path(config, bump, ptcl, tile, draw_flags);
+ let index = scene[dd as usize];
+ tile_state.write_grad(
+ config,
+ bump,
+ ptcl,
+ CMD_RAD_GRAD,
+ index,
+ di + 1,
+ );
+ }
+ DrawTag::SWEEP_GRADIENT => {
+ tile_state.write_path(config, bump, ptcl, tile, draw_flags);
+ let index = scene[dd as usize];
+ tile_state.write_grad(
+ config,
+ bump,
+ ptcl,
+ CMD_SWEEP_GRAD,
+ index,
+ di + 1,
+ );
+ }
+ DrawTag::BLUR_RECT => {
+ tile_state.write_path(config, bump, ptcl, tile, draw_flags);
+ let rgba_color = scene[dd as usize];
+ tile_state.write_blur_rect(config, bump, ptcl, rgba_color, di + 1);
+ }
+ DrawTag::BEGIN_CLIP => {
+ let even_odd = (draw_flags & DRAW_INFO_FLAGS_FILL_RULE_BIT) != 0;
+ let backdrop_clear = if even_odd {
+ tile.backdrop.abs() & 1 == 0
+ } else {
+ tile.backdrop == 0
+ };
+ if tile.segment_count_or_ix == 0 && backdrop_clear {
+ clip_zero_depth = clip_depth + 1;
+ } else {
+ tile_state.write_begin_clip(config, bump, ptcl);
+ // TODO: Do we need to track this separately, seems like it
+ // is always the same as clip_depth in this code path
+ render_blend_depth += 1;
+ max_blend_depth = max(render_blend_depth, max_blend_depth);
+ }
+ clip_depth += 1;
+ }
+ DrawTag::END_CLIP => {
+ clip_depth -= 1;
+ tile_state.write_path(config, bump, ptcl, tile, draw_flags);
+ let blend = scene[dd as usize];
+ let alpha = f32::from_bits(scene[dd as usize + 1]);
+ tile_state.write_end_clip(config, bump, ptcl, blend, alpha);
+ render_blend_depth -= 1;
+ }
+ _ => todo!(),
+ }
+ }
+ } else {
+ // In "clip zero" state, suppress all drawing
+ match DrawTag(drawtag) {
+ DrawTag::BEGIN_CLIP => clip_depth += 1,
+ DrawTag::END_CLIP => {
+ if clip_depth == clip_zero_depth {
+ clip_zero_depth = 0;
+ }
+ clip_depth -= 1;
+ }
+ _ => (),
+ }
+ }
+ }
+
+ if bin_tile_x + tile_x < width_in_tiles && bin_tile_y + tile_y < height_in_tiles {
+ ptcl[tile_state.cmd_offset as usize] = CMD_END;
+ let scratch_size =
+ (max_blend_depth.saturating_sub(BLEND_STACK_SPLIT)) * TILE_WIDTH * TILE_HEIGHT;
+ ptcl[blend_offset as usize] = bump.blend;
+ bump.blend += scratch_size;
+ }
+ }
+ }
+}
+
+pub fn coarse(_n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let config = resources[0].as_typed();
+ let scene = resources[1].as_slice();
+ let draw_monoids = resources[2].as_slice();
+ let bin_headers = resources[3].as_slice();
+ let info_bin_data = resources[4].as_slice();
+ let paths = resources[5].as_slice();
+ let mut tiles = resources[6].as_slice_mut();
+ let mut bump = resources[7].as_typed_mut();
+ let mut ptcl = resources[8].as_slice_mut();
+ coarse_main(
+ &config,
+ &scene,
+ &draw_monoids,
+ &bin_headers,
+ &info_bin_data,
+ &paths,
+ &mut tiles,
+ &mut bump,
+ &mut ptcl,
+ );
+}
diff --git a/vendor/vello_shaders/src/cpu/draw_leaf.rs b/vendor/vello_shaders/src/cpu/draw_leaf.rs
new file mode 100644
index 00000000..6f709010
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/draw_leaf.rs
@@ -0,0 +1,249 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{Clip, ConfigUniform, DrawMonoid, DrawTag, Monoid, PathBbox};
+
+use super::{
+ CpuBinding, RAD_GRAD_KIND_CIRCULAR, RAD_GRAD_KIND_CONE, RAD_GRAD_KIND_FOCAL_ON_CIRCLE,
+ RAD_GRAD_KIND_STRIP, RAD_GRAD_SWAPPED,
+ util::{Transform, Vec2, read_draw_tag_from_scene},
+};
+
+const WG_SIZE: usize = 256;
+
+fn draw_leaf_main(
+ n_wg: u32,
+ config: &ConfigUniform,
+ scene: &[u32],
+ reduced: &[DrawMonoid],
+ path_bbox: &[PathBbox],
+ draw_monoid: &mut [DrawMonoid],
+ info: &mut [u32],
+ clip_inp: &mut [Clip],
+) {
+ let num_blocks_total = (config.layout.n_draw_objects as usize).div_ceil(WG_SIZE);
+ let n_blocks_base = num_blocks_total / WG_SIZE;
+ let remainder = num_blocks_total % WG_SIZE;
+ let mut prefix = DrawMonoid::default();
+ for i in 0..n_wg as usize {
+ let first_block = n_blocks_base * i + i.min(remainder);
+ let n_blocks = n_blocks_base + (i < remainder) as usize;
+ let mut m = prefix;
+ for j in 0..WG_SIZE * n_blocks {
+ let ix = (first_block * WG_SIZE) as u32 + j as u32;
+ let tag_raw = read_draw_tag_from_scene(config, scene, ix);
+ let tag_word = DrawTag(tag_raw);
+ // store exclusive prefix sum
+ if ix < config.layout.n_draw_objects {
+ draw_monoid[ix as usize] = m;
+ }
+ let m_next = m.combine(&DrawMonoid::new(tag_word));
+ let dd = config.layout.draw_data_base + m.scene_offset;
+ let di = m.info_offset as usize;
+ if tag_word == DrawTag::COLOR
+ || tag_word == DrawTag::LINEAR_GRADIENT
+ || tag_word == DrawTag::RADIAL_GRADIENT
+ || tag_word == DrawTag::SWEEP_GRADIENT
+ || tag_word == DrawTag::IMAGE
+ || tag_word == DrawTag::BEGIN_CLIP
+ || tag_word == DrawTag::BLUR_RECT
+ {
+ let bbox = path_bbox[m.path_ix as usize];
+ let transform = Transform::read(config.layout.transform_base, bbox.trans_ix, scene);
+ let draw_flags = bbox.draw_flags;
+ match tag_word {
+ DrawTag::COLOR => {
+ info[di] = draw_flags;
+ }
+ DrawTag::LINEAR_GRADIENT => {
+ info[di] = draw_flags;
+ let p0 = Vec2::new(
+ f32::from_bits(scene[dd as usize + 1]),
+ f32::from_bits(scene[dd as usize + 2]),
+ );
+ let p1 = Vec2::new(
+ f32::from_bits(scene[dd as usize + 3]),
+ f32::from_bits(scene[dd as usize + 4]),
+ );
+ let p0 = transform.apply(p0);
+ let p1 = transform.apply(p1);
+ let dxy = p1 - p0;
+ let scale = 1.0 / dxy.dot(dxy);
+ let line_xy = dxy * scale;
+ let line_c = -p0.dot(line_xy);
+ info[di + 1] = f32::to_bits(line_xy.x);
+ info[di + 2] = f32::to_bits(line_xy.y);
+ info[di + 3] = f32::to_bits(line_c);
+ }
+ DrawTag::RADIAL_GRADIENT => {
+ const GRADIENT_EPSILON: f32 = 1.0_f32 / (1 << 12) as f32;
+ info[di] = draw_flags;
+ let mut p0 = Vec2::new(
+ f32::from_bits(scene[dd as usize + 1]),
+ f32::from_bits(scene[dd as usize + 2]),
+ );
+ let mut p1 = Vec2::new(
+ f32::from_bits(scene[dd as usize + 3]),
+ f32::from_bits(scene[dd as usize + 4]),
+ );
+ let mut r0 = f32::from_bits(scene[dd as usize + 5]);
+ let mut r1 = f32::from_bits(scene[dd as usize + 6]);
+ let user_to_gradient = transform.inverse();
+ let xform;
+ let mut focal_x = 0.0;
+ let radius;
+ let mut kind;
+ let mut flags = 0;
+ if (r0 - r1).abs() < GRADIENT_EPSILON {
+ // When the radii are the same, emit a strip gradient
+ kind = RAD_GRAD_KIND_STRIP;
+ let scaled = r0 / p0.distance(p1);
+ xform = two_point_to_unit_line(p0, p1) * user_to_gradient;
+ radius = scaled * scaled;
+ } else {
+ // Assume a two point conical gradient unless the centers
+ // are equal.
+ kind = RAD_GRAD_KIND_CONE;
+ if p0 == p1 {
+ kind = RAD_GRAD_KIND_CIRCULAR;
+ // Nudge p0 a bit to avoid denormals.
+ p0.x += GRADIENT_EPSILON;
+ }
+ if r1 == 0.0 {
+ // If r1 == 0.0, swap the points and radii
+ flags |= RAD_GRAD_SWAPPED;
+ core::mem::swap(&mut p0, &mut p1);
+ core::mem::swap(&mut r0, &mut r1);
+ }
+ focal_x = r0 / (r0 - r1);
+ let cf = (1.0 - focal_x) * p0 + focal_x * p1;
+ radius = r1 / cf.distance(p1);
+ let user_to_unit_line =
+ two_point_to_unit_line(cf, p1) * user_to_gradient;
+ let user_to_scaled;
+ // When r == 1.0, focal point is on circle
+ if (radius - 1.0).abs() <= GRADIENT_EPSILON {
+ kind = RAD_GRAD_KIND_FOCAL_ON_CIRCLE;
+ let scale = 0.5 * (1.0 - focal_x).abs();
+ user_to_scaled = Transform([scale, 0.0, 0.0, scale, 0.0, 0.0])
+ * user_to_unit_line;
+ } else {
+ let a = radius * radius - 1.0;
+ let scale_ratio = (1.0 - focal_x).abs() / a;
+ let scale_x = radius * scale_ratio;
+ let scale_y = a.abs().sqrt() * scale_ratio;
+ user_to_scaled = Transform([scale_x, 0.0, 0.0, scale_y, 0.0, 0.0])
+ * user_to_unit_line;
+ }
+ xform = user_to_scaled;
+ }
+ info[di + 1] = f32::to_bits(xform.0[0]);
+ info[di + 2] = f32::to_bits(xform.0[1]);
+ info[di + 3] = f32::to_bits(xform.0[2]);
+ info[di + 4] = f32::to_bits(xform.0[3]);
+ info[di + 5] = f32::to_bits(xform.0[4]);
+ info[di + 6] = f32::to_bits(xform.0[5]);
+ info[di + 7] = f32::to_bits(focal_x);
+ info[di + 8] = f32::to_bits(radius);
+ info[di + 9] = (flags << 3) | kind;
+ }
+ DrawTag::SWEEP_GRADIENT => {
+ info[di] = draw_flags;
+ let p0 = Vec2::new(
+ f32::from_bits(scene[dd as usize + 1]),
+ f32::from_bits(scene[dd as usize + 2]),
+ );
+ let xform =
+ (transform * Transform([1.0, 0.0, 0.0, 1.0, p0.x, p0.y])).inverse();
+ info[di + 1] = f32::to_bits(xform.0[0]);
+ info[di + 2] = f32::to_bits(xform.0[1]);
+ info[di + 3] = f32::to_bits(xform.0[2]);
+ info[di + 4] = f32::to_bits(xform.0[3]);
+ info[di + 5] = f32::to_bits(xform.0[4]);
+ info[di + 6] = f32::to_bits(xform.0[5]);
+ info[di + 7] = scene[dd as usize + 3];
+ info[di + 8] = scene[dd as usize + 4];
+ }
+ DrawTag::IMAGE => {
+ info[di] = draw_flags;
+ let xform = transform.inverse();
+ info[di + 1] = f32::to_bits(xform.0[0]);
+ info[di + 2] = f32::to_bits(xform.0[1]);
+ info[di + 3] = f32::to_bits(xform.0[2]);
+ info[di + 4] = f32::to_bits(xform.0[3]);
+ info[di + 5] = f32::to_bits(xform.0[4]);
+ info[di + 6] = f32::to_bits(xform.0[5]);
+ info[di + 7] = scene[dd as usize];
+ info[di + 8] = scene[dd as usize + 1];
+ info[di + 9] = scene[dd as usize + 2];
+ }
+ DrawTag::BLUR_RECT => {
+ info[di] = draw_flags;
+ let xform = transform.inverse();
+ info[di + 1] = f32::to_bits(xform.0[0]);
+ info[di + 2] = f32::to_bits(xform.0[1]);
+ info[di + 3] = f32::to_bits(xform.0[2]);
+ info[di + 4] = f32::to_bits(xform.0[3]);
+ info[di + 5] = f32::to_bits(xform.0[4]);
+ info[di + 6] = f32::to_bits(xform.0[5]);
+ info[di + 7] = scene[dd as usize + 1];
+ info[di + 8] = scene[dd as usize + 2];
+ info[di + 9] = scene[dd as usize + 3];
+ info[di + 10] = scene[dd as usize + 4];
+ }
+ DrawTag::BEGIN_CLIP => {
+ info[di] = draw_flags;
+ }
+ _ => todo!("unhandled draw tag {:x}", tag_word.0),
+ }
+ }
+ if tag_word == DrawTag::BEGIN_CLIP {
+ let path_ix = m.path_ix as i32;
+ clip_inp[m.clip_ix as usize] = Clip { ix, path_ix };
+ } else if tag_word == DrawTag::END_CLIP {
+ let path_ix = !ix as i32;
+ clip_inp[m.clip_ix as usize] = Clip { ix, path_ix };
+ }
+ m = m_next;
+ }
+ prefix = prefix.combine(&reduced[i]);
+ }
+}
+
+pub fn draw_leaf(n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let config = resources[0].as_typed();
+ let scene = resources[1].as_slice();
+ let reduced = resources[2].as_slice();
+ let path_bbox = resources[3].as_slice();
+ let mut draw_monoid = resources[4].as_slice_mut();
+ let mut info = resources[5].as_slice_mut();
+ let mut clip_inp = resources[6].as_slice_mut();
+ draw_leaf_main(
+ n_wg,
+ &config,
+ &scene,
+ &reduced,
+ &path_bbox,
+ &mut draw_monoid,
+ &mut info,
+ &mut clip_inp,
+ );
+}
+
+fn two_point_to_unit_line(p0: Vec2, p1: Vec2) -> Transform {
+ let tmp1 = from_poly2(p0, p1);
+ let inv = tmp1.inverse();
+ let tmp2 = from_poly2(Vec2::default(), Vec2::new(1.0, 0.0));
+ tmp2 * inv
+}
+
+fn from_poly2(p0: Vec2, p1: Vec2) -> Transform {
+ Transform([
+ p1.y - p0.y,
+ p0.x - p1.x,
+ p1.x - p0.x,
+ p1.y - p0.y,
+ p0.x,
+ p0.y,
+ ])
+}
diff --git a/vendor/vello_shaders/src/cpu/draw_reduce.rs b/vendor/vello_shaders/src/cpu/draw_reduce.rs
new file mode 100644
index 00000000..db88c84f
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/draw_reduce.rs
@@ -0,0 +1,32 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{ConfigUniform, DrawMonoid, DrawTag, Monoid};
+
+use super::{CpuBinding, util::read_draw_tag_from_scene};
+
+const WG_SIZE: usize = 256;
+
+fn draw_reduce_main(n_wg: u32, config: &ConfigUniform, scene: &[u32], reduced: &mut [DrawMonoid]) {
+ let num_blocks_total = (config.layout.n_draw_objects as usize).div_ceil(WG_SIZE);
+ let n_blocks_base = num_blocks_total / WG_SIZE;
+ let remainder = num_blocks_total % WG_SIZE;
+ for i in 0..n_wg as usize {
+ let first_block = n_blocks_base * i + i.min(remainder);
+ let n_blocks = n_blocks_base + (i < remainder) as usize;
+ let mut m = DrawMonoid::default();
+ for j in 0..WG_SIZE * n_blocks {
+ let ix = (first_block * WG_SIZE) as u32 + j as u32;
+ let tag = read_draw_tag_from_scene(config, scene, ix);
+ m = m.combine(&DrawMonoid::new(DrawTag(tag)));
+ }
+ reduced[i] = m;
+ }
+}
+
+pub fn draw_reduce(n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let config = resources[0].as_typed();
+ let scene = resources[1].as_slice();
+ let mut reduced = resources[2].as_slice_mut();
+ draw_reduce_main(n_wg, &config, &scene, &mut reduced);
+}
diff --git a/vendor/vello_shaders/src/cpu/euler.rs b/vendor/vello_shaders/src/cpu/euler.rs
new file mode 100644
index 00000000..cc3ee1ca
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/euler.rs
@@ -0,0 +1,337 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+//! Utility functions for Euler Spiral based stroke expansion.
+
+#![expect(
+ clippy::excessive_precision,
+ reason = "Uses the same constants as the f64 version"
+)]
+
+use super::util::Vec2;
+use std::f32::consts::FRAC_PI_4;
+
+// Threshold for tangents to be considered near zero length
+pub(crate) const TANGENT_THRESH: f32 = 1e-6;
+
+/// This struct contains parameters derived from a cubic Bézier for the
+/// purpose of fitting a G1 continuous Euler spiral segment and estimating
+/// the Fréchet distance.
+///
+/// The tangent angles represent deviation from the chord, so that when they
+/// are equal, the corresponding Euler spiral is a circular arc.
+#[derive(Debug)]
+pub(crate) struct CubicParams {
+ /// Tangent angle relative to chord at start.
+ pub(crate) th0: f32,
+ /// Tangent angle relative to chord at end.
+ pub(crate) th1: f32,
+ /// The effective chord length, always a robustly nonzero value.
+ pub(crate) chord_len: f32,
+ /// The estimated error between the source cubic and the proposed Euler spiral.
+ pub(crate) err: f32,
+}
+
+#[derive(Debug)]
+pub(crate) struct EulerParams {
+ pub(crate) th0: f32,
+ // th1 need not be explicitly stored, as it can be derived from k0 - th0
+ // See #vello > Euler Spiral `th1` param
+ // https://xi.zulipchat.com/#narrow/channel/197075-vello/topic/Euler.20Spiral.20.60th1.60.20param/with/446074149
+ pub(crate) k0: f32,
+ pub(crate) k1: f32,
+ pub(crate) ch: f32,
+}
+
+#[derive(Debug)]
+pub(crate) struct EulerSeg {
+ pub(crate) p0: Vec2,
+ pub(crate) p1: Vec2,
+ pub(crate) params: EulerParams,
+}
+
+impl CubicParams {
+ /// Compute parameters from endpoints and derivatives.
+ ///
+ /// This function is designed to be robust across a wide range of inputs. In
+ /// particular, it splits between near-zero chord length and the happy path.
+ /// In the former case, the parameters for the Euler spiral would not be valid,
+ /// so it proposes a straight line and computes a pretty good (conservative)
+ /// estimate of the Fréchet distance between that line and the source cubic.
+ ///
+ /// Computing an accurate estimate here fixes two tricky cases: very short
+ /// lines, in which the error will be below threshold and the flatten logic will
+ /// output a single line segment without subdividing, and loop cases with a
+ /// short chord, in which case the error will exceed the threshold, and the
+ /// chords of the subdivided pieces will be longer.
+ ///
+ /// An additional case is the near-cusp where the proposed Euler spiral has
+ /// a 180 degree U-turn (or, more generally, one angle exceeds 90 degrees and
+ /// the other does not). In that case, the resulting Euler spiral is quite
+ /// well defined (with finite curvature, so that its offset will generate a
+ /// near-semicircle, preserving G1 continuity), but the analytic error
+ /// calculation would be a huge overestimate. In that case, we just return
+ /// a rough estimate of the distance between the chord and the spiral segment.
+ pub(crate) fn from_points_derivs(p0: Vec2, p1: Vec2, q0: Vec2, q1: Vec2, dt: f32) -> Self {
+ let chord = p1 - p0;
+ let chord_squared = chord.length_squared();
+ let chord_len = chord_squared.sqrt();
+ // Chord is near-zero; straight line case.
+ if chord_squared < TANGENT_THRESH.powi(2) {
+ // This error estimate was determined empirically through randomized
+ // testing, though it is likely it can be derived analytically.
+ let chord_err = ((9. / 32.0) * (q0.length_squared() + q1.length_squared())).sqrt() * dt;
+ return Self {
+ th0: 0.0,
+ th1: 0.0,
+ chord_len: TANGENT_THRESH,
+ err: chord_err,
+ };
+ }
+ let scale = dt / chord_squared;
+ let h0 = Vec2::new(
+ q0.x * chord.x + q0.y * chord.y,
+ q0.y * chord.x - q0.x * chord.y,
+ );
+ let th0 = h0.atan2();
+ let d0 = h0.length() * scale;
+ let h1 = Vec2::new(
+ q1.x * chord.x + q1.y * chord.y,
+ q1.x * chord.y - q1.y * chord.x,
+ );
+ let th1 = h1.atan2();
+ let d1 = h1.length() * scale;
+ // Robustness note: we may want to clamp the magnitude of the angles to
+ // a bit less than pi. Perhaps here, perhaps downstream.
+
+ // Estimate error of geometric Hermite interpolation to Euler spiral.
+ let cth0 = th0.cos();
+ let cth1 = th1.cos();
+ let mut err = if cth0 * cth1 < 0.0 {
+ // A value of 2.0 represents the approximate worst case distance
+ // from an Euler spiral with 0 and pi tangents to the chord. It
+ // is not very critical; doubling the value would result in one more
+ // subdivision in effectively a binary search for the cusp, while too
+ // small a value may result in the actual error exceeding the bound.
+ 2.0
+ } else {
+ // Protect against divide-by-zero. This happens with a double cusp, so
+ // should in the general case cause subdivisions.
+ let e0 = (2. / 3.) / (1.0 + cth0).max(1e-9);
+ let e1 = (2. / 3.) / (1.0 + cth1).max(1e-9);
+ let s0 = th0.sin();
+ let s1 = th1.sin();
+ // Note: some other versions take sin of s0 + s1 instead. Those are incorrect.
+ // Strangely, calibration is the same, but more work could be done.
+ let s01 = cth0 * s1 + cth1 * s0;
+ let amin = 0.15 * (2. * e0 * s0 + 2. * e1 * s1 - e0 * e1 * s01);
+ let a = 0.15 * (2. * d0 * s0 + 2. * d1 * s1 - d0 * d1 * s01);
+ let aerr = (a - amin).abs();
+ let symm = (th0 + th1).abs();
+ let asymm = (th0 - th1).abs();
+ let dist = (d0 - e0).hypot(d1 - e1);
+ let ctr = 4.625e-6 * symm.powi(5) + 7.5e-3 * asymm * symm.powi(2);
+ let halo_symm = 5e-3 * symm * dist;
+ let halo_asymm = 7e-2 * asymm * dist;
+ /*
+ println!(" e0: {e0}");
+ println!(" e1: {e1}");
+ println!(" s0: {s0}");
+ println!(" s1: {s1}");
+ println!(" s01: {s01}");
+ println!(" amin: {amin}");
+ println!(" a: {a}");
+ println!(" aerr: {aerr}");
+ println!(" symm: {symm}");
+ println!(" asymm: {asymm}");
+ println!(" dist: {dist}");
+ println!(" ctr: {ctr}");
+ println!(" halo_symm: {halo_symm}");
+ println!(" halo_asymm: {halo_asymm}");
+ */
+ ctr + 1.55 * aerr + halo_symm + halo_asymm
+ };
+ err *= chord_len;
+ Self {
+ th0,
+ th1,
+ chord_len,
+ err,
+ }
+ }
+}
+
+impl EulerParams {
+ pub(crate) fn from_angles(th0: f32, th1: f32) -> Self {
+ let k0 = th0 + th1;
+ let dth = th1 - th0;
+ let d2 = dth * dth;
+ let k2 = k0 * k0;
+ let mut a = 6.0;
+ a -= d2 * (1. / 70.);
+ a -= (d2 * d2) * (1. / 10780.);
+ a += (d2 * d2 * d2) * 2.769178184818219e-07;
+ let b = -0.1 + d2 * (1. / 4200.) + d2 * d2 * 1.6959677820260655e-05;
+ let c = -1. / 1400. + d2 * 6.84915970574303e-05 - k2 * 7.936475029053326e-06;
+ a += (b + c * k2) * k2;
+ let k1 = dth * a;
+
+ // calculation of chord
+ let mut ch = 1.0;
+ ch -= d2 * (1. / 40.);
+ ch += (d2 * d2) * 0.00034226190482569864;
+ ch -= (d2 * d2 * d2) * 1.9349474568904524e-06;
+ let b = -1. / 24. + d2 * 0.0024702380951963226 - d2 * d2 * 3.7297408997537985e-05;
+ let c = 1. / 1920. - d2 * 4.87350869747975e-05 - k2 * 3.1001936068463107e-06;
+ ch += (b + c * k2) * k2;
+ Self { th0, k0, k1, ch }
+ }
+
+ pub(crate) fn eval_th(&self, t: f32) -> f32 {
+ (self.k0 + 0.5 * self.k1 * (t - 1.0)) * t - self.th0
+ }
+
+ /// Evaluate the curve at the given parameter.
+ ///
+ /// The parameter is in the range 0..1, and the result goes from (0, 0) to (1, 0).
+ fn eval(&self, t: f32) -> Vec2 {
+ let thm = self.eval_th(t * 0.5);
+ let k0 = self.k0;
+ let k1 = self.k1;
+ let (u, v) = integ_euler_10((k0 + k1 * (0.5 * t - 0.5)) * t, k1 * t * t);
+ let s = t / self.ch * thm.sin();
+ let c = t / self.ch * thm.cos();
+ let x = u * c - v * s;
+ let y = -v * c - u * s;
+ Vec2::new(x, y)
+ }
+
+ // Offset provided is in same units as curve; chord is normalized to (1, 0).
+ fn eval_with_offset(&self, t: f32, offset: f32) -> Vec2 {
+ let th = self.eval_th(t);
+ let v = Vec2::new(offset * th.sin(), offset * th.cos());
+ self.eval(t) + v
+ }
+}
+
+impl EulerSeg {
+ pub(crate) fn from_params(p0: Vec2, p1: Vec2, params: EulerParams) -> Self {
+ Self { p0, p1, params }
+ }
+
+ #[expect(unused, reason = "Unclear why this code exists")]
+ pub(crate) fn eval(&self, t: f32) -> Vec2 {
+ let Vec2 { x, y } = self.params.eval(t);
+ let chord = self.p1 - self.p0;
+ Vec2::new(
+ self.p0.x + chord.x * x - chord.y * y,
+ self.p0.y + chord.x * y + chord.y * x,
+ )
+ }
+
+ // Note: offset provided is normalized so that 1 = chord length, while
+ // the return value is in the same coordinate space as the endpoints.
+ pub(crate) fn eval_with_offset(&self, t: f32, normalized_offset: f32) -> Vec2 {
+ let chord = self.p1 - self.p0;
+ let Vec2 { x, y } = self.params.eval_with_offset(t, normalized_offset);
+ Vec2::new(
+ self.p0.x + chord.x * x - chord.y * y,
+ self.p0.y + chord.x * y + chord.y * x,
+ )
+ }
+}
+
+/// Integrate Euler spiral.
+///
+/// This is a 10th order polynomial. The evaluation method is explained in
+/// Raph's thesis in section 8.1.2.
+///
+/// This choice of polynomial is fairly conservative, as it will produce
+/// very good accuracy for angles up to about 1 radian, and those angles
+/// should almost never happen (the exception being cusps). One possibility
+/// to explore is using a lower degree polynomial here, but changing the
+/// tuning parameters for subdivision so the additional error here is also
+/// factored into the error threshold. However, two cautions against that:
+/// First, it doesn't really address the cusp case, where angles will remain
+/// large even after further subdivision, and second, the cost of even this
+/// more conservative choice is modest; it's just some multiply-adds.
+fn integ_euler_10(k0: f32, k1: f32) -> (f32, f32) {
+ let t1_1 = k0;
+ let t1_2 = 0.5 * k1;
+ let t2_2 = t1_1 * t1_1;
+ let t2_3 = 2. * (t1_1 * t1_2);
+ let t2_4 = t1_2 * t1_2;
+ let t3_4 = t2_2 * t1_2 + t2_3 * t1_1;
+ let t3_6 = t2_4 * t1_2;
+ let t4_4 = t2_2 * t2_2;
+ let t4_5 = 2. * (t2_2 * t2_3);
+ let t4_6 = 2. * (t2_2 * t2_4) + t2_3 * t2_3;
+ let t4_7 = 2. * (t2_3 * t2_4);
+ let t4_8 = t2_4 * t2_4;
+ let t5_6 = t4_4 * t1_2 + t4_5 * t1_1;
+ let t5_8 = t4_6 * t1_2 + t4_7 * t1_1;
+ let t6_6 = t4_4 * t2_2;
+ let t6_7 = t4_4 * t2_3 + t4_5 * t2_2;
+ let t6_8 = t4_4 * t2_4 + t4_5 * t2_3 + t4_6 * t2_2;
+ let t7_8 = t6_6 * t1_2 + t6_7 * t1_1;
+ let t8_8 = t6_6 * t2_2;
+ let mut u = 1.;
+ u -= (1. / 24.) * t2_2 + (1. / 160.) * t2_4;
+ u += (1. / 1920.) * t4_4 + (1. / 10752.) * t4_6 + (1. / 55296.) * t4_8;
+ u -= (1. / 322560.) * t6_6 + (1. / 1658880.) * t6_8;
+ u += (1. / 92897280.) * t8_8;
+ let mut v = (1. / 12.) * t1_2;
+ v -= (1. / 480.) * t3_4 + (1. / 2688.) * t3_6;
+ v += (1. / 53760.) * t5_6 + (1. / 276480.) * t5_8;
+ v -= (1. / 11612160.) * t7_8;
+ (u, v)
+}
+
+const BREAK1: f32 = 0.8;
+const BREAK2: f32 = 1.25;
+const BREAK3: f32 = 2.1;
+const SIN_SCALE: f32 = 1.0976991822760038;
+const QUAD_A1: f32 = 0.6406;
+const QUAD_B1: f32 = -0.81;
+const QUAD_C1: f32 = 0.9148117935952064;
+const QUAD_A2: f32 = 0.5;
+const QUAD_B2: f32 = -0.156;
+const QUAD_C2: f32 = 0.16145779359520596;
+
+pub(crate) fn espc_int_approx(x: f32) -> f32 {
+ let y = x.abs();
+ let a = if y < BREAK1 {
+ (SIN_SCALE * y).sin() * (1.0 / SIN_SCALE)
+ } else if y < BREAK2 {
+ (8.0_f32.sqrt() / 3.0) * (y - 1.0) * (y - 1.0).abs().sqrt() + FRAC_PI_4
+ } else {
+ let (a, b, c) = if y < BREAK3 {
+ (QUAD_A1, QUAD_B1, QUAD_C1)
+ } else {
+ (QUAD_A2, QUAD_B2, QUAD_C2)
+ };
+ a * y * y + b * y + c
+ };
+ a.copysign(x)
+}
+
+pub(crate) fn espc_int_inv_approx(x: f32) -> f32 {
+ let y = x.abs();
+ let a = if y < 0.7010707591262915 {
+ (x * SIN_SCALE).asin() * (1.0 / SIN_SCALE)
+ } else if y < 0.903249293595206 {
+ let b = y - FRAC_PI_4;
+ let u = b.abs().powf(2. / 3.).copysign(b);
+ u * (9.0_f32 / 8.).cbrt() + 1.0
+ } else {
+ let (u, v, w) = if y < 2.038857793595206 {
+ const B: f32 = 0.5 * QUAD_B1 / QUAD_A1;
+ (B * B - QUAD_C1 / QUAD_A1, 1.0 / QUAD_A1, B)
+ } else {
+ const B: f32 = 0.5 * QUAD_B2 / QUAD_A2;
+ (B * B - QUAD_C2 / QUAD_A2, 1.0 / QUAD_A2, B)
+ };
+ (u + v * y).sqrt() - w
+ };
+ a.copysign(x)
+}
diff --git a/vendor/vello_shaders/src/cpu/fine.rs b/vendor/vello_shaders/src/cpu/fine.rs
new file mode 100644
index 00000000..85f78c0b
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/fine.rs
@@ -0,0 +1,182 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{ConfigUniform, PathSegment, Tile};
+
+use super::{CMD_COLOR, CMD_END, CMD_FILL, CMD_JUMP, CMD_SOLID, CpuTexture, PTCL_INITIAL_ALLOC};
+
+// These should also move into a common area
+const TILE_WIDTH: usize = 16;
+const TILE_HEIGHT: usize = 16;
+const TILE_SIZE: usize = TILE_WIDTH * TILE_HEIGHT;
+
+fn read_color(ptcl: &[u32], offset: u32) -> u32 {
+ ptcl[(offset + 1) as usize]
+}
+
+struct CmdFill {
+ size_and_rule: u32,
+ seg_data: u32,
+ backdrop: i32,
+}
+
+fn read_fill(ptcl: &[u32], offset: u32) -> CmdFill {
+ let size_and_rule = ptcl[(offset + 1) as usize];
+ let seg_data = ptcl[(offset + 2) as usize];
+ let backdrop = ptcl[(offset + 3) as usize] as i32;
+ CmdFill {
+ size_and_rule,
+ seg_data,
+ backdrop,
+ }
+}
+
+fn unpack4x8unorm(x: u32) -> [f32; 4] {
+ let mut result = [0.0; 4];
+ for i in 0..4 {
+ result[i] = ((x >> (i * 8)) & 0xff) as f32 * (1.0 / 255.0);
+ }
+ result
+}
+
+fn pack4x8unorm(x: [f32; 4]) -> u32 {
+ let mut result = 0;
+ for i in 0..4 {
+ let byte = (x[i].clamp(0.0, 1.0) * 255.0).round() as u32;
+ result |= byte << (i * 8);
+ }
+ result
+}
+
+fn fill_path(area: &mut [f32], segments: &[PathSegment], fill: &CmdFill, x_tile: f32, y_tile: f32) {
+ let n_segs = fill.size_and_rule >> 1;
+ let even_odd = (fill.size_and_rule & 1) != 0;
+ let backdrop_f = fill.backdrop as f32;
+ for a in area.iter_mut() {
+ *a = backdrop_f;
+ }
+ for segment in &segments[fill.seg_data as usize..][..n_segs as usize] {
+ let delta = [
+ segment.point1[0] - segment.point0[0],
+ segment.point1[1] - segment.point0[1],
+ ];
+ for yi in 0..TILE_HEIGHT {
+ let y = segment.point0[1] - (y_tile + yi as f32);
+ let y0 = y.clamp(0.0, 1.0);
+ let y1 = (y + delta[1]).clamp(0.0, 1.0);
+ let dy = y0 - y1;
+ let y_edge =
+ delta[0].signum() * (y_tile + yi as f32 - segment.y_edge + 1.0).clamp(0.0, 1.0);
+ if dy != 0.0 {
+ let vec_y_recip = delta[1].recip();
+ let t0 = (y0 - y) * vec_y_recip;
+ let t1 = (y1 - y) * vec_y_recip;
+ let startx = segment.point0[0] - x_tile;
+ let x0 = startx + t0 * delta[0];
+ let x1 = startx + t1 * delta[0];
+ let xmin0 = x0.min(x1);
+ let xmax0 = x0.max(x1);
+ for i in 0..TILE_WIDTH {
+ let i_f = i as f32;
+ let xmin = (xmin0 - i_f).min(1.0) - 1.0e-6;
+ let xmax = xmax0 - i_f;
+ let b = xmax.min(1.0);
+ let c = b.max(0.0);
+ let d = xmin.max(0.0);
+ let a = (b + 0.5 * (d * d - c * c) - xmin) / (xmax - xmin);
+ area[yi * TILE_WIDTH + i] += y_edge + a * dy;
+ }
+ } else if y_edge != 0.0 {
+ for i in 0..TILE_WIDTH {
+ area[yi * TILE_WIDTH + i] += y_edge;
+ }
+ }
+ }
+ }
+ if even_odd {
+ for a in area.iter_mut() {
+ {
+ *a = (*a - 2.0 * (0.5 * *a).round()).abs();
+ }
+ }
+ } else {
+ for a in area.iter_mut() {
+ {
+ *a = a.abs().min(1.0);
+ }
+ }
+ }
+}
+
+#[expect(unused, reason = "Draft code as textures not wired up")]
+fn fine_main(
+ config: &ConfigUniform,
+ tiles: &[Tile],
+ segments: &[PathSegment],
+ output: &mut CpuTexture,
+ ptcl: &[u32],
+ info: &[u32],
+ // TODO: image texture resources
+ // TODO: masks?
+) {
+ let width_in_tiles = config.width_in_tiles;
+ let height_in_tiles = config.height_in_tiles;
+ let n_tiles = width_in_tiles * height_in_tiles;
+ let mut area = vec![0.0_f32; TILE_SIZE];
+ let mut rgba = vec![[0.0_f32; 4]; TILE_SIZE];
+ for tile_ix in 0..n_tiles {
+ rgba.fill([0.0; 4]);
+ area.fill(0.0);
+ let tile_x = tile_ix % width_in_tiles;
+ let tile_y = tile_ix / width_in_tiles;
+ let mut cmd_ix = tile_ix * PTCL_INITIAL_ALLOC;
+ // skip over blend stack allocation
+ cmd_ix += 1;
+ loop {
+ let tag = ptcl[cmd_ix as usize];
+ if tag == CMD_END {
+ break;
+ }
+ match tag {
+ CMD_FILL => {
+ let fill = read_fill(ptcl, cmd_ix);
+ // x0 and y0 will go away when we do tile-relative coords
+ let x0 = (tile_x as usize * TILE_WIDTH) as f32;
+ let y0 = (tile_y as usize * TILE_HEIGHT) as f32;
+ fill_path(&mut area, segments, &fill, x0, y0);
+ cmd_ix += 4;
+ }
+ CMD_SOLID => {
+ area.fill(1.0);
+ cmd_ix += 2;
+ }
+ CMD_COLOR => {
+ let color = read_color(ptcl, cmd_ix);
+ let fg = unpack4x8unorm(color);
+ let fg = [fg[3], fg[2], fg[1], fg[0]];
+ for i in 0..TILE_SIZE {
+ let ai = area[i];
+ let fg_i = [fg[0] * ai, fg[1] * ai, fg[2] * ai, fg[3] * ai];
+ for j in 0..4 {
+ rgba[i][j] = rgba[i][j] * (1.0 - fg_i[3]) + fg_i[j];
+ }
+ }
+ cmd_ix += 2;
+ }
+ CMD_JUMP => {
+ cmd_ix = ptcl[(cmd_ix + 1) as usize];
+ }
+ _ => todo!("unhandled ptcl command {tag}"),
+ }
+ }
+ // Write tile (in rgba)
+ for y in 0..TILE_HEIGHT {
+ let base =
+ output.width * (tile_y as usize * TILE_HEIGHT + y) + tile_x as usize * TILE_WIDTH;
+ for x in 0..TILE_WIDTH {
+ let rgba32 = pack4x8unorm(rgba[y * TILE_WIDTH + x]);
+ output.pixels[base + x] = rgba32;
+ }
+ }
+ }
+}
diff --git a/vendor/vello_shaders/src/cpu/flatten.rs b/vendor/vello_shaders/src/cpu/flatten.rs
new file mode 100644
index 00000000..26e42493
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/flatten.rs
@@ -0,0 +1,863 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use std::f32::consts::FRAC_1_SQRT_2;
+
+use super::{
+ CpuBinding,
+ euler::{
+ CubicParams, EulerParams, EulerSeg, TANGENT_THRESH, espc_int_approx, espc_int_inv_approx,
+ },
+ util::{ROBUST_EPSILON, Transform, Vec2},
+};
+use vello_encoding::math::f16_to_f32;
+use vello_encoding::{
+ BumpAllocators, ConfigUniform, DRAW_INFO_FLAGS_FILL_RULE_BIT, LineSoup, Monoid, PathBbox,
+ PathMonoid, PathTag, Style,
+};
+
+// TODO: remove this
+macro_rules! log {
+ ($($arg:tt)*) => {{
+ //println!($($arg)*);
+ }};
+}
+
+// Note to readers: this file contains sophisticated techniques for expanding stroke
+// outlines to flattened filled outlines, based on Euler spirals as an intermediate
+// curve representation. In some cases, there are explanatory comments in the
+// corresponding `cpu_shaders/` files (`flatten.rs` and the supporting `euler.rs`).
+// A paper is in the works explaining the techniques in more detail.
+
+/// Threshold below which a derivative is considered too small.
+const DERIV_THRESH: f32 = 1e-6;
+/// Amount to nudge t when derivative is near-zero.
+const DERIV_EPS: f32 = 1e-6;
+// Limit for subdivision of cubic Béziers.
+const SUBDIV_LIMIT: f32 = 1.0 / 65536.0;
+
+/// Evaluate both the point and derivative of a cubic bezier.
+fn eval_cubic_and_deriv(p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2, t: f32) -> (Vec2, Vec2) {
+ let m = 1.0 - t;
+ let mm = m * m;
+ let mt = m * t;
+ let tt = t * t;
+ let p = p0 * (mm * m) + (p1 * (3.0 * mm) + p2 * (3.0 * mt) + p3 * tt) * t;
+ let q = (p1 - p0) * mm + (p2 - p1) * (2.0 * mt) + (p3 - p2) * tt;
+ (p, q)
+}
+
+fn cubic_start_tangent(p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2) -> Vec2 {
+ let d01 = p1 - p0;
+ let d02 = p2 - p0;
+ let d03 = p3 - p0;
+ if d01.length_squared() > ROBUST_EPSILON {
+ d01
+ } else if d02.length_squared() > ROBUST_EPSILON {
+ d02
+ } else {
+ d03
+ }
+}
+
+fn cubic_end_tangent(p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2) -> Vec2 {
+ let d23 = p3 - p2;
+ let d13 = p3 - p1;
+ let d03 = p3 - p0;
+ if d23.length_squared() > ROBUST_EPSILON {
+ d23
+ } else if d13.length_squared() > ROBUST_EPSILON {
+ d13
+ } else {
+ d03
+ }
+}
+
+fn write_line(
+ line_ix: usize,
+ path_ix: u32,
+ p0: Vec2,
+ p1: Vec2,
+ bbox: &mut IntBbox,
+ lines: &mut [LineSoup],
+) {
+ assert!(
+ !p0.is_nan() && !p1.is_nan(),
+ "wrote NaNs: p0: {p0:?}, p1: {p1:?}"
+ );
+ bbox.add_pt(p0);
+ bbox.add_pt(p1);
+ lines[line_ix] = LineSoup {
+ path_ix,
+ _padding: Default::default(),
+ p0: p0.to_array(),
+ p1: p1.to_array(),
+ };
+}
+
+fn write_line_with_transform(
+ line_ix: usize,
+ path_ix: u32,
+ p0: Vec2,
+ p1: Vec2,
+ transform: &Transform,
+ bbox: &mut IntBbox,
+ lines: &mut [LineSoup],
+) {
+ write_line(
+ line_ix,
+ path_ix,
+ transform.apply(p0),
+ transform.apply(p1),
+ bbox,
+ lines,
+ );
+}
+
+fn output_line(
+ path_ix: u32,
+ p0: Vec2,
+ p1: Vec2,
+ line_ix: &mut usize,
+ bbox: &mut IntBbox,
+ lines: &mut [LineSoup],
+) {
+ write_line(*line_ix, path_ix, p0, p1, bbox, lines);
+ *line_ix += 1;
+}
+
+fn output_line_with_transform(
+ path_ix: u32,
+ p0: Vec2,
+ p1: Vec2,
+ transform: &Transform,
+ line_ix: &mut usize,
+ lines: &mut [LineSoup],
+ bbox: &mut IntBbox,
+) {
+ write_line_with_transform(*line_ix, path_ix, p0, p1, transform, bbox, lines);
+ *line_ix += 1;
+}
+
+fn output_two_lines_with_transform(
+ path_ix: u32,
+ p00: Vec2,
+ p01: Vec2,
+ p10: Vec2,
+ p11: Vec2,
+ transform: &Transform,
+ line_ix: &mut usize,
+ lines: &mut [LineSoup],
+ bbox: &mut IntBbox,
+) {
+ write_line_with_transform(*line_ix, path_ix, p00, p01, transform, bbox, lines);
+ write_line_with_transform(*line_ix + 1, path_ix, p10, p11, transform, bbox, lines);
+ *line_ix += 2;
+}
+
+fn flatten_arc(
+ path_ix: u32,
+ begin: Vec2,
+ end: Vec2,
+ center: Vec2,
+ angle: f32,
+ transform: &Transform,
+ line_ix: &mut usize,
+ lines: &mut [LineSoup],
+ bbox: &mut IntBbox,
+) {
+ const MIN_THETA: f32 = 0.0001;
+
+ let mut p0 = transform.apply(begin);
+ let mut r = begin - center;
+ let tol: f32 = 0.25;
+ let radius = tol.max((p0 - transform.apply(center)).length());
+ let theta = (2. * (1. - tol / radius).acos()).max(MIN_THETA);
+
+ // Always output at least one line so that we always draw the chord.
+ let n_lines = ((angle / theta).ceil() as u32).max(1);
+
+ let (s, c) = theta.sin_cos();
+ let rot = Transform([c, -s, s, c, 0., 0.]);
+
+ for _ in 0..(n_lines - 1) {
+ r = rot.apply(r);
+ let p1 = transform.apply(center + r);
+ output_line(path_ix, p0, p1, line_ix, bbox, lines);
+ p0 = p1;
+ }
+ let p1 = transform.apply(end);
+ output_line(path_ix, p0, p1, line_ix, bbox, lines);
+}
+
+/// A robustness strategy for the ESPC integral
+enum EspcRobust {
+ /// Both k1 and dist are large enough to divide by robustly.
+ Normal,
+ /// k1 is low, so model curve as a circular arc.
+ LowK1,
+ /// dist is low, so model curve as just an Euler spiral.
+ LowDist,
+}
+
+fn flatten_euler(
+ cubic: &CubicPoints,
+ path_ix: u32,
+ local_to_device: &Transform,
+ offset: f32,
+ start_p: Vec2,
+ end_p: Vec2,
+ line_ix: &mut usize,
+ lines: &mut [LineSoup],
+ bbox: &mut IntBbox,
+) {
+ // Flatten in local coordinates if this is a stroke. Flatten in device space otherwise.
+ let (p0, p1, p2, p3, scale, transform) = if offset == 0. {
+ (
+ local_to_device.apply(cubic.p0),
+ local_to_device.apply(cubic.p1),
+ local_to_device.apply(cubic.p2),
+ local_to_device.apply(cubic.p3),
+ 1.,
+ Transform::identity(),
+ )
+ } else {
+ let t = local_to_device.0;
+ let scale = 0.5
+ * (Vec2::new(t[0] + t[3], t[1] - t[2]).length()
+ + Vec2::new(t[0] - t[3], t[1] + t[2]).length());
+ (
+ cubic.p0,
+ cubic.p1,
+ cubic.p2,
+ cubic.p3,
+ scale,
+ local_to_device.clone(),
+ )
+ };
+ let (t_start, t_end) = if offset == 0.0 {
+ (p0, p3)
+ } else {
+ (start_p, end_p)
+ };
+
+ // Drop zero length lines. This is an exact equality test because dropping very short
+ // line segments may result in loss of watertightness. The parallel curves of zero
+ // length lines add nothing to stroke outlines, but we still may need to draw caps.
+ if p0 == p1 && p0 == p2 && p0 == p3 {
+ return;
+ }
+
+ let tol: f32 = 0.25;
+ let mut t0_u: u32 = 0;
+ let mut dt: f32 = 1.;
+ let mut last_p = p0;
+ let mut last_q = p1 - p0;
+ // We want to avoid near zero derivatives, so the general technique is to
+ // detect, then sample a nearby t value if it fails to meet the threshold.
+ if last_q.length_squared() < DERIV_THRESH.powi(2) {
+ last_q = eval_cubic_and_deriv(p0, p1, p2, p3, DERIV_EPS).1;
+ }
+ let mut last_t = 0.;
+ let mut lp0 = t_start;
+
+ loop {
+ let t0 = (t0_u as f32) * dt;
+ if t0 == 1. {
+ break;
+ }
+ log!("@@@ loop start: t0: {t0}, dt: {dt}");
+ let mut t1 = t0 + dt;
+ let this_p0 = last_p;
+ let this_q0 = last_q;
+ let (mut this_p1, mut this_q1) = eval_cubic_and_deriv(p0, p1, p2, p3, t1);
+ if this_q1.length_squared() < DERIV_THRESH.powi(2) {
+ let (new_p1, new_q1) = eval_cubic_and_deriv(p0, p1, p2, p3, t1 - DERIV_EPS);
+ this_q1 = new_q1;
+ // Change just the derivative at the endpoint, but also move the point so it
+ // matches the derivative exactly if in the interior.
+ if t1 < 1. {
+ this_p1 = new_p1;
+ t1 -= DERIV_EPS;
+ }
+ }
+ let actual_dt = t1 - last_t;
+ let cubic_params =
+ CubicParams::from_points_derivs(this_p0, this_p1, this_q0, this_q1, actual_dt);
+ log!(
+ "@@@ loop: p0={this_p0:?} p1={this_p1:?} q0={this_q0:?} q1={this_q1:?} {cubic_params:?} t0: {t0}, t1: {t1}, dt: {dt}"
+ );
+ if cubic_params.err * scale <= tol || dt <= SUBDIV_LIMIT {
+ log!("@@@ error within tolerance");
+ let euler_params = EulerParams::from_angles(cubic_params.th0, cubic_params.th1);
+ let es = EulerSeg::from_params(this_p0, this_p1, euler_params);
+
+ let (k0, k1) = (es.params.k0 - 0.5 * es.params.k1, es.params.k1);
+
+ // compute forward integral to determine number of subdivisions
+ let normalized_offset = offset / cubic_params.chord_len;
+ let dist_scaled = normalized_offset * es.params.ch;
+ // The number of subdivisions for curvature = 1
+ let scale_multiplier = 0.5
+ * FRAC_1_SQRT_2
+ * (scale * cubic_params.chord_len / (es.params.ch * tol)).sqrt();
+ // TODO: tune these thresholds
+ const K1_THRESH: f32 = 1e-3;
+ const DIST_THRESH: f32 = 1e-3;
+ let mut a = 0.0;
+ let mut b = 0.0;
+ let mut integral = 0.0;
+ let mut int0 = 0.0;
+ let (n_frac, robust) = if k1.abs() < K1_THRESH {
+ let k = k0 + 0.5 * k1;
+ let n_frac = (k * (k * dist_scaled + 1.0)).abs().sqrt();
+ (n_frac, EspcRobust::LowK1)
+ } else if dist_scaled.abs() < DIST_THRESH {
+ let f = |x: f32| x * x.abs().sqrt();
+ a = k1;
+ b = k0;
+ int0 = f(b);
+ let int1 = f(a + b);
+ integral = int1 - int0;
+ //println!("int0={int0}, int1={int1} a={a} b={b}");
+ let n_frac = (2. / 3.) * integral / a;
+ (n_frac, EspcRobust::LowDist)
+ } else {
+ a = -2.0 * dist_scaled * k1;
+ b = -1.0 - 2.0 * dist_scaled * k0;
+ int0 = espc_int_approx(b);
+ let int1 = espc_int_approx(a + b);
+ integral = int1 - int0;
+ let k_peak = k0 - k1 * b / a;
+ let integrand_peak = (k_peak * (k_peak * dist_scaled + 1.0)).abs().sqrt();
+ let scaled_int = integral * integrand_peak / a;
+ let n_frac = scaled_int;
+ (n_frac, EspcRobust::Normal)
+ };
+ let n = (n_frac * scale_multiplier).ceil().clamp(1.0, 100.0);
+
+ // Flatten line segments
+ log!("@@@ loop: lines: {n}");
+ assert!(!n.is_nan());
+ for i in 0..n as usize {
+ let lp1 = if i == n as usize - 1 && t1 == 1.0 {
+ t_end
+ } else {
+ let t = (i + 1) as f32 / n;
+ let s = match robust {
+ EspcRobust::LowK1 => t,
+ // Note opportunities to minimize divergence
+ EspcRobust::LowDist => {
+ let c = (integral * t + int0).cbrt();
+ let inv = c * c.abs();
+ (inv - b) / a
+ }
+ EspcRobust::Normal => {
+ let inv = espc_int_inv_approx(integral * t + int0);
+ (inv - b) / a
+ }
+ };
+ es.eval_with_offset(s, normalized_offset)
+ };
+ let l0 = if offset >= 0. { lp0 } else { lp1 };
+ let l1 = if offset >= 0. { lp1 } else { lp0 };
+ output_line_with_transform(path_ix, l0, l1, &transform, line_ix, lines, bbox);
+ lp0 = lp1;
+ }
+ last_p = this_p1;
+ last_q = this_q1;
+ last_t = t1;
+ // Advance segment to next range. Beginning of segment is the end of
+ // this one. The number of trailing zeros represents the number of stack
+ // frames to pop in the recursive version of adaptive subdivision, and
+ // each stack pop represents doubling of the size of the range.
+ t0_u += 1;
+ let shift = t0_u.trailing_zeros();
+ t0_u >>= shift;
+ dt *= (1 << shift) as f32;
+ } else {
+ // Subdivide; halve the size of the range while retaining its start.
+ t0_u = t0_u.saturating_mul(2);
+ dt *= 0.5;
+ }
+ }
+}
+
+fn draw_cap(
+ path_ix: u32,
+ cap_style: u32,
+ point: Vec2,
+ cap0: Vec2,
+ cap1: Vec2,
+ offset_tangent: Vec2,
+ transform: &Transform,
+ line_ix: &mut usize,
+ lines: &mut [LineSoup],
+ bbox: &mut IntBbox,
+) {
+ if cap_style == Style::FLAGS_CAP_BITS_ROUND {
+ flatten_arc(
+ path_ix,
+ cap0,
+ cap1,
+ point,
+ std::f32::consts::PI,
+ transform,
+ line_ix,
+ lines,
+ bbox,
+ );
+ return;
+ }
+
+ let mut start = cap0;
+ let mut end = cap1;
+ if cap_style == Style::FLAGS_CAP_BITS_SQUARE {
+ let v = offset_tangent;
+ let p0 = start + v;
+ let p1 = end + v;
+ output_line_with_transform(path_ix, start, p0, transform, line_ix, lines, bbox);
+ output_line_with_transform(path_ix, p1, end, transform, line_ix, lines, bbox);
+ start = p0;
+ end = p1;
+ }
+ output_line_with_transform(path_ix, start, end, transform, line_ix, lines, bbox);
+}
+
+fn draw_join(
+ path_ix: u32,
+ style_flags: u32,
+ p0: Vec2,
+ tan_prev: Vec2,
+ tan_next: Vec2,
+ n_prev: Vec2,
+ n_next: Vec2,
+ transform: &Transform,
+ line_ix: &mut usize,
+ lines: &mut [LineSoup],
+ bbox: &mut IntBbox,
+) {
+ let mut front0 = p0 + n_prev;
+ let front1 = p0 + n_next;
+ let mut back0 = p0 - n_next;
+ let back1 = p0 - n_prev;
+
+ let cr = tan_prev.x * tan_next.y - tan_prev.y * tan_next.x;
+ let d = tan_prev.dot(tan_next);
+
+ match style_flags & Style::FLAGS_JOIN_MASK {
+ Style::FLAGS_JOIN_BITS_BEVEL => {
+ if front0 != front1 && back0 != back1 {
+ output_two_lines_with_transform(
+ path_ix, front0, front1, back0, back1, transform, line_ix, lines, bbox,
+ );
+ }
+ }
+ Style::FLAGS_JOIN_BITS_MITER => {
+ let hypot = cr.hypot(d);
+ let miter_limit = f16_to_f32((style_flags & Style::MITER_LIMIT_MASK) as u16);
+
+ if 2. * hypot < (hypot + d) * miter_limit * miter_limit
+ && cr.abs() > TANGENT_THRESH.powi(2)
+ {
+ let is_backside = cr > 0.;
+ let fp_last = if is_backside { back1 } else { front0 };
+ let fp_this = if is_backside { back0 } else { front1 };
+ let p = if is_backside { back0 } else { front0 };
+
+ let v = fp_this - fp_last;
+ let h = (tan_prev.x * v.y - tan_prev.y * v.x) / cr;
+ let miter_pt = fp_this - tan_next * h;
+
+ output_line_with_transform(path_ix, p, miter_pt, transform, line_ix, lines, bbox);
+
+ if is_backside {
+ back0 = miter_pt;
+ } else {
+ front0 = miter_pt;
+ }
+ }
+ output_two_lines_with_transform(
+ path_ix, front0, front1, back0, back1, transform, line_ix, lines, bbox,
+ );
+ }
+ Style::FLAGS_JOIN_BITS_ROUND => {
+ let (arc0, arc1, other0, other1) = if cr > 0. {
+ (back0, back1, front0, front1)
+ } else {
+ (front0, front1, back0, back1)
+ };
+ flatten_arc(
+ path_ix,
+ arc0,
+ arc1,
+ p0,
+ cr.atan2(d).abs(),
+ transform,
+ line_ix,
+ lines,
+ bbox,
+ );
+ output_line_with_transform(path_ix, other0, other1, transform, line_ix, lines, bbox);
+ }
+ _ => unreachable!(),
+ }
+}
+
+fn read_f32_point(ix: u32, pathdata: &[u32]) -> Vec2 {
+ let x = f32::from_bits(pathdata[ix as usize]);
+ let y = f32::from_bits(pathdata[ix as usize + 1]);
+ Vec2 { x, y }
+}
+
+fn read_i16_point(ix: u32, pathdata: &[u32]) -> Vec2 {
+ let raw = pathdata[ix as usize];
+ let x = (((raw << 16) as i32) >> 16) as f32;
+ let y = ((raw as i32) >> 16) as f32;
+ Vec2 { x, y }
+}
+
+#[derive(Debug)]
+struct IntBbox {
+ x0: i32,
+ y0: i32,
+ x1: i32,
+ y1: i32,
+}
+
+impl Default for IntBbox {
+ fn default() -> Self {
+ Self {
+ x0: 0x7fff_ffff,
+ y0: 0x7fff_ffff,
+ x1: -0x8000_0000,
+ y1: -0x8000_0000,
+ }
+ }
+}
+
+impl IntBbox {
+ fn add_pt(&mut self, pt: Vec2) {
+ self.x0 = self.x0.min(pt.x.floor() as i32);
+ self.y0 = self.y0.min(pt.y.floor() as i32);
+ self.x1 = self.x1.max(pt.x.ceil() as i32);
+ self.y1 = self.y1.max(pt.y.ceil() as i32);
+ }
+}
+
+struct PathTagData {
+ tag_byte: u8,
+ monoid: PathMonoid,
+}
+
+fn compute_tag_monoid(ix: usize, pathtags: &[u32], tag_monoids: &[PathMonoid]) -> PathTagData {
+ let tag_word = pathtags[ix >> 2];
+ let shift = (ix & 3) * 8;
+ let mut tm = PathMonoid::new(tag_word & ((1 << shift) - 1));
+ let tag_byte = ((tag_word >> shift) & 0xff) as u8;
+ if tag_byte != 0 {
+ tm = tag_monoids[ix >> 2].combine(&tm);
+ }
+ // We no longer encode an initial transform and style so these
+ // are off by one.
+ // We wrap here because these values will return to positive values later
+ // (when we add style_base)
+ tm.trans_ix = tm.trans_ix.wrapping_sub(1);
+ tm.style_ix = tm.style_ix.wrapping_sub(size_of::<Style>() as u32 / 4);
+ PathTagData {
+ tag_byte,
+ monoid: tm,
+ }
+}
+
+#[derive(Debug)]
+struct CubicPoints {
+ p0: Vec2,
+ p1: Vec2,
+ p2: Vec2,
+ p3: Vec2,
+}
+
+fn read_path_segment(tag: &PathTagData, is_stroke: bool, pathdata: &[u32]) -> CubicPoints {
+ let mut p0;
+ let mut p1;
+ let mut p2 = Vec2::default();
+ let mut p3 = Vec2::default();
+
+ let mut seg_type = tag.tag_byte & PATH_TAG_SEG_TYPE;
+ let pathseg_offset = tag.monoid.pathseg_offset;
+ let is_stroke_cap_marker = is_stroke && (tag.tag_byte & PathTag::SUBPATH_END_BIT) != 0;
+ let is_open = seg_type == PATH_TAG_QUADTO;
+
+ if (tag.tag_byte & PATH_TAG_F32) != 0 {
+ p0 = read_f32_point(pathseg_offset, pathdata);
+ p1 = read_f32_point(pathseg_offset + 2, pathdata);
+ if seg_type >= PATH_TAG_QUADTO {
+ p2 = read_f32_point(pathseg_offset + 4, pathdata);
+ if seg_type == PATH_TAG_CUBICTO {
+ p3 = read_f32_point(pathseg_offset + 6, pathdata);
+ }
+ }
+ } else {
+ p0 = read_i16_point(pathseg_offset, pathdata);
+ p1 = read_i16_point(pathseg_offset + 1, pathdata);
+ if seg_type >= PATH_TAG_QUADTO {
+ p2 = read_i16_point(pathseg_offset + 2, pathdata);
+ if seg_type == PATH_TAG_CUBICTO {
+ p3 = read_i16_point(pathseg_offset + 3, pathdata);
+ }
+ }
+ }
+
+ if is_stroke_cap_marker && is_open {
+ p0 = p1;
+ p1 = p2;
+ seg_type = PATH_TAG_LINETO;
+ }
+
+ // Degree-raise
+ if seg_type == PATH_TAG_LINETO {
+ p3 = p1;
+ p2 = p3.mix(p0, 1.0 / 3.0);
+ p1 = p0.mix(p3, 1.0 / 3.0);
+ } else if seg_type == PATH_TAG_QUADTO {
+ p3 = p2;
+ p2 = p1.mix(p2, 1.0 / 3.0);
+ p1 = p1.mix(p0, 1.0 / 3.0);
+ }
+
+ CubicPoints { p0, p1, p2, p3 }
+}
+
+struct NeighboringSegment {
+ do_join: bool,
+ tangent: Vec2,
+}
+
+fn read_neighboring_segment(
+ ix: usize,
+ pathtags: &[u32],
+ pathdata: &[u32],
+ tag_monoids: &[PathMonoid],
+) -> NeighboringSegment {
+ let tag = compute_tag_monoid(ix, pathtags, tag_monoids);
+ let pts = read_path_segment(&tag, true, pathdata);
+
+ let is_closed = (tag.tag_byte & PATH_TAG_SEG_TYPE) == PATH_TAG_LINETO;
+ let is_stroke_cap_marker = (tag.tag_byte & PathTag::SUBPATH_END_BIT) != 0;
+ let do_join = !is_stroke_cap_marker || is_closed;
+ let tangent = if is_stroke_cap_marker {
+ pts.p3 - pts.p0
+ } else {
+ cubic_start_tangent(pts.p0, pts.p1, pts.p2, pts.p3)
+ };
+ NeighboringSegment { do_join, tangent }
+}
+
+const WG_SIZE: usize = 256;
+
+const PATH_TAG_SEG_TYPE: u8 = 3;
+const PATH_TAG_PATH: u8 = 0x10;
+const PATH_TAG_LINETO: u8 = 1;
+const PATH_TAG_QUADTO: u8 = 2;
+const PATH_TAG_CUBICTO: u8 = 3;
+const PATH_TAG_F32: u8 = 8;
+
+fn flatten_main(
+ n_wg: u32,
+ config: &ConfigUniform,
+ scene: &[u32],
+ tag_monoids: &[PathMonoid],
+ path_bboxes: &mut [PathBbox],
+ bump: &mut BumpAllocators,
+ lines: &mut [LineSoup],
+) {
+ let mut line_ix = 0;
+ let pathtags = &scene[config.layout.path_tag_base as usize..];
+ let pathdata = &scene[config.layout.path_data_base as usize..];
+
+ for ix in 0..n_wg as usize * WG_SIZE {
+ let mut bbox = IntBbox::default();
+ let tag = compute_tag_monoid(ix, pathtags, tag_monoids);
+ let path_ix = tag.monoid.path_ix;
+ let style_ix = tag.monoid.style_ix;
+ let trans_ix = tag.monoid.trans_ix;
+ let style_flags = scene[(config.layout.style_base.wrapping_add(style_ix)) as usize];
+ if (tag.tag_byte & PATH_TAG_PATH) != 0 {
+ let out = &mut path_bboxes[path_ix as usize];
+ out.draw_flags = if (style_flags & Style::FLAGS_FILL_BIT) == 0 {
+ 0
+ } else {
+ DRAW_INFO_FLAGS_FILL_RULE_BIT
+ };
+ out.trans_ix = trans_ix;
+ }
+
+ let seg_type = tag.tag_byte & PATH_TAG_SEG_TYPE;
+ if seg_type != 0 {
+ let is_stroke = (style_flags & Style::FLAGS_STYLE_BIT) != 0;
+ let transform = Transform::read(config.layout.transform_base, trans_ix, scene);
+ let pts = read_path_segment(&tag, is_stroke, pathdata);
+
+ if is_stroke {
+ let linewidth =
+ f32::from_bits(scene[(config.layout.style_base + style_ix + 1) as usize]);
+ let offset = 0.5 * linewidth;
+
+ let is_open = seg_type != PATH_TAG_LINETO;
+ let is_stroke_cap_marker = (tag.tag_byte & PathTag::SUBPATH_END_BIT) != 0;
+ if is_stroke_cap_marker {
+ if is_open {
+ // Draw start cap
+ let tangent = pts.p3 - pts.p0;
+ let offset_tangent = offset * tangent.normalize();
+ let n = Vec2::new(-offset_tangent.y, offset_tangent.x);
+ draw_cap(
+ path_ix,
+ (style_flags & Style::FLAGS_START_CAP_MASK) >> 2,
+ pts.p0,
+ pts.p0 - n,
+ pts.p0 + n,
+ -offset_tangent,
+ &transform,
+ &mut line_ix,
+ lines,
+ &mut bbox,
+ );
+ } else {
+ // Don't draw anything if the path is closed.
+ }
+ } else {
+ // Read the neighboring segment.
+ let neighbor =
+ read_neighboring_segment(ix + 1, pathtags, pathdata, tag_monoids);
+ let tan_prev = cubic_end_tangent(pts.p0, pts.p1, pts.p2, pts.p3);
+ let tan_next = neighbor.tangent;
+ let tan_start = cubic_start_tangent(pts.p0, pts.p1, pts.p2, pts.p3);
+ // TODO: be consistent w/ robustness here
+
+ // TODO: add NaN assertions to CPU shaders PR (when writing lines)
+ // TODO: not all zero-length segments are getting filtered out
+ // TODO: this is a hack. How to handle caps on degenerate stroke?
+ // TODO: debug tricky stroke by isolation
+ let tan_start = if tan_start.length_squared() < TANGENT_THRESH.powi(2) {
+ Vec2::new(TANGENT_THRESH, 0.)
+ } else {
+ tan_start
+ };
+ let tan_prev = if tan_prev.length_squared() < TANGENT_THRESH.powi(2) {
+ Vec2::new(TANGENT_THRESH, 0.)
+ } else {
+ tan_prev
+ };
+ let tan_next = if tan_next.length_squared() < TANGENT_THRESH.powi(2) {
+ Vec2::new(TANGENT_THRESH, 0.)
+ } else {
+ tan_next
+ };
+
+ let n_start = offset * Vec2::new(-tan_start.y, tan_start.x).normalize();
+ let offset_tangent = offset * tan_prev.normalize();
+ let n_prev = Vec2::new(-offset_tangent.y, offset_tangent.x);
+ let tan_next_norm = tan_next.normalize();
+ let n_next = offset * Vec2::new(-tan_next_norm.y, tan_next_norm.x);
+ log!("@ tan_prev: {:#?}", tan_prev);
+ log!("@ tan_next: {:#?}", tan_next);
+
+ // Render offset curves
+ flatten_euler(
+ &pts,
+ path_ix,
+ &transform,
+ offset,
+ pts.p0 + n_start,
+ pts.p3 + n_prev,
+ &mut line_ix,
+ lines,
+ &mut bbox,
+ );
+ flatten_euler(
+ &pts,
+ path_ix,
+ &transform,
+ -offset,
+ pts.p0 - n_start,
+ pts.p3 - n_prev,
+ &mut line_ix,
+ lines,
+ &mut bbox,
+ );
+
+ if neighbor.do_join {
+ draw_join(
+ path_ix,
+ style_flags,
+ pts.p3,
+ tan_prev,
+ tan_next,
+ n_prev,
+ n_next,
+ &transform,
+ &mut line_ix,
+ lines,
+ &mut bbox,
+ );
+ } else {
+ // Draw end cap.
+ draw_cap(
+ path_ix,
+ style_flags & Style::FLAGS_END_CAP_MASK,
+ pts.p3,
+ pts.p3 + n_prev,
+ pts.p3 - n_prev,
+ offset_tangent,
+ &transform,
+ &mut line_ix,
+ lines,
+ &mut bbox,
+ );
+ }
+ }
+ } else {
+ flatten_euler(
+ &pts,
+ path_ix,
+ &transform,
+ /*offset*/ 0.,
+ pts.p0,
+ pts.p3,
+ &mut line_ix,
+ lines,
+ &mut bbox,
+ );
+ }
+ }
+
+ if (path_ix as usize) < path_bboxes.len() && (bbox.x1 > bbox.x0 || bbox.y1 > bbox.y0) {
+ let out = &mut path_bboxes[path_ix as usize];
+ out.x0 = out.x0.min(bbox.x0);
+ out.y0 = out.y0.min(bbox.y0);
+ out.x1 = out.x1.max(bbox.x1);
+ out.y1 = out.y1.max(bbox.y1);
+ }
+ }
+ bump.lines = line_ix as u32;
+}
+
+pub fn flatten(n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let config = resources[0].as_typed();
+ let scene = resources[1].as_slice();
+ let tag_monoids = resources[2].as_slice();
+ let mut path_bboxes = resources[3].as_slice_mut();
+ let mut bump = resources[4].as_typed_mut();
+ let mut lines = resources[5].as_slice_mut();
+ flatten_main(
+ n_wg,
+ &config,
+ &scene,
+ &tag_monoids,
+ &mut path_bboxes,
+ &mut bump,
+ &mut lines,
+ );
+}
diff --git a/vendor/vello_shaders/src/cpu/path_count.rs b/vendor/vello_shaders/src/cpu/path_count.rs
new file mode 100644
index 00000000..f59fbdee
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/path_count.rs
@@ -0,0 +1,164 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{BumpAllocators, LineSoup, Path, SegmentCount, Tile};
+
+use super::{
+ CpuBinding,
+ util::{ONE_MINUS_ULP, ROBUST_EPSILON, Vec2, span},
+};
+
+const TILE_SCALE: f32 = 1.0 / 16.0;
+
+fn path_count_main(
+ bump: &mut BumpAllocators,
+ lines: &[LineSoup],
+ paths: &[Path],
+ tile: &mut [Tile],
+ seg_counts: &mut [SegmentCount],
+) {
+ for line_ix in 0..bump.lines {
+ let line = lines[line_ix as usize];
+ let p0 = Vec2::from_array(line.p0);
+ let p1 = Vec2::from_array(line.p1);
+ let is_down = p1.y >= p0.y;
+ let (xy0, xy1) = if is_down { (p0, p1) } else { (p1, p0) };
+ let s0 = xy0 * TILE_SCALE;
+ let s1 = xy1 * TILE_SCALE;
+ let count_x = span(s0.x, s1.x) - 1;
+ let count = count_x + span(s0.y, s1.y);
+
+ let dx = (s1.x - s0.x).abs();
+ let dy = s1.y - s0.y;
+ if dx + dy == 0.0 {
+ continue;
+ }
+ if dy == 0.0 && s0.y.floor() == s0.y {
+ continue;
+ }
+ let idxdy = 1.0 / (dx + dy);
+ let mut a = dx * idxdy;
+ let is_positive_slope = s1.x >= s0.x;
+ let sign = if is_positive_slope { 1.0 } else { -1.0 };
+ let xt0 = (s0.x * sign).floor();
+ let c = s0.x * sign - xt0;
+ let y0 = s0.y.floor();
+ let ytop = if s0.y == s1.y { s0.y.ceil() } else { y0 + 1.0 };
+ let b = ((dy * c + dx * (ytop - s0.y)) * idxdy).min(ONE_MINUS_ULP);
+ let robust_err = (a * (count as f32 - 1.0) + b).floor() - count_x as f32;
+ if robust_err != 0.0 {
+ a -= ROBUST_EPSILON.copysign(robust_err);
+ }
+ let x0 = xt0 * sign + if is_positive_slope { 0.0 } else { -1.0 };
+
+ let path = paths[line.path_ix as usize];
+ let bbox = path.bbox;
+ let bbox = [
+ bbox[0] as i32,
+ bbox[1] as i32,
+ bbox[2] as i32,
+ bbox[3] as i32,
+ ];
+ let xmin = s0.x.min(s1.x);
+ let stride = bbox[2] - bbox[0];
+ if s0.y >= bbox[3] as f32 || s1.y < bbox[1] as f32 || xmin >= bbox[2] as f32 || stride == 0
+ {
+ continue;
+ }
+ // Clip line to bounding box. Clipping is done in "i" space.
+ let mut imin = 0;
+ if s0.y < bbox[1] as f32 {
+ let mut iminf = ((bbox[1] as f32 - y0 + b - a) / (1.0 - a)).round() - 1.0;
+ if y0 + iminf - (a * iminf + b).floor() < bbox[1] as f32 {
+ iminf += 1.0;
+ }
+ imin = iminf as u32;
+ }
+ let mut imax = count;
+ if s1.y > bbox[3] as f32 {
+ let mut imaxf = ((bbox[3] as f32 - y0 + b - a) / (1.0 - a)).round() - 1.0;
+ if y0 + imaxf - (a * imaxf + b).floor() < bbox[3] as f32 {
+ imaxf += 1.0;
+ }
+ imax = imaxf as u32;
+ }
+ let delta = if is_down { -1 } else { 1 };
+ let mut ymin = 0;
+ let mut ymax = 0;
+ if s0.x.max(s1.x) < bbox[0] as f32 {
+ ymin = s0.y.ceil() as i32;
+ ymax = s1.y.ceil() as i32;
+ imax = imin;
+ } else {
+ let fudge = if is_positive_slope { 0.0 } else { 1.0 };
+ if xmin < bbox[0] as f32 {
+ let mut f = ((sign * (bbox[0] as f32 - x0) - b + fudge) / a).round();
+ if (x0 + sign * (a * f + b).floor() < bbox[0] as f32) == is_positive_slope {
+ f += 1.0;
+ }
+ let ynext = (y0 + f - (a * f + b).floor() + 1.0) as i32;
+ if is_positive_slope {
+ if f as u32 > imin {
+ ymin = (y0 + if y0 == s0.y { 0.0 } else { 1.0 }) as i32;
+ ymax = ynext;
+ imin = f as u32;
+ }
+ } else if (f as u32) < imax {
+ ymin = ynext;
+ ymax = s1.y.ceil() as i32;
+ imax = f as u32;
+ }
+ }
+ if s0.x.max(s1.x) > bbox[2] as f32 {
+ let mut f = ((sign * (bbox[2] as f32 - x0) - b + fudge) / a).round();
+ if (x0 + sign * (a * f + b).floor() < bbox[2] as f32) == is_positive_slope {
+ f += 1.0;
+ }
+ if is_positive_slope {
+ imax = imax.min(f as u32);
+ } else {
+ imin = imin.max(f as u32);
+ }
+ }
+ }
+ imax = imin.max(imax);
+ ymin = ymin.max(bbox[1]);
+ ymax = ymax.min(bbox[3]);
+ for y in ymin..ymax {
+ let base = path.tiles as i32 + (y - bbox[1]) * stride;
+ tile[base as usize].backdrop += delta;
+ }
+ let mut last_z = (a * (imin as f32 - 1.0) + b).floor();
+ let seg_base = bump.seg_counts;
+ bump.seg_counts += imax - imin;
+ for i in imin..imax {
+ let zf = a * i as f32 + b;
+ let z = zf.floor();
+ let y = (y0 + i as f32 - z) as i32;
+ let x = (x0 + sign * z) as i32;
+ let base = path.tiles as i32 + (y - bbox[1]) * stride - bbox[0];
+ let top_edge = if i == 0 { y0 == s0.y } else { last_z == z };
+ if top_edge && x + 1 < bbox[2] {
+ let x_bump = (x + 1).max(bbox[0]);
+ tile[(base + x_bump) as usize].backdrop += delta;
+ }
+ // .segments is another name for the .count field; it's overloaded
+ let seg_within_slice = tile[(base + x) as usize].segment_count_or_ix;
+ tile[(base + x) as usize].segment_count_or_ix += 1;
+ let counts = (seg_within_slice << 16) | i;
+ let seg_count = SegmentCount { line_ix, counts };
+ seg_counts[(seg_base + i - imin) as usize] = seg_count;
+ last_z = z;
+ }
+ }
+}
+
+pub fn path_count(_n_wg: u32, resources: &[CpuBinding<'_>]) {
+ // config is binding 0
+ let mut bump = resources[1].as_typed_mut();
+ let lines = resources[2].as_slice();
+ let paths = resources[3].as_slice();
+ let mut tile = resources[4].as_slice_mut();
+ let mut seg_counts = resources[5].as_slice_mut();
+ path_count_main(&mut bump, &lines, &paths, &mut tile, &mut seg_counts);
+}
diff --git a/vendor/vello_shaders/src/cpu/path_count_setup.rs b/vendor/vello_shaders/src/cpu/path_count_setup.rs
new file mode 100644
index 00000000..88da9fa8
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/path_count_setup.rs
@@ -0,0 +1,21 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{BumpAllocators, IndirectCount};
+
+use super::CpuBinding;
+
+const WG_SIZE: usize = 256;
+
+fn path_count_setup_main(bump: &BumpAllocators, indirect: &mut IndirectCount) {
+ let lines = bump.lines;
+ indirect.count_x = lines.div_ceil(WG_SIZE as u32);
+ indirect.count_y = 1;
+ indirect.count_z = 1;
+}
+
+pub fn path_count_setup(_n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let bump = resources[0].as_typed();
+ let mut indirect = resources[1].as_typed_mut();
+ path_count_setup_main(&bump, &mut indirect);
+}
diff --git a/vendor/vello_shaders/src/cpu/path_tiling.rs b/vendor/vello_shaders/src/cpu/path_tiling.rs
new file mode 100644
index 00000000..0be1c81e
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/path_tiling.rs
@@ -0,0 +1,183 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{BumpAllocators, LineSoup, Path, PathSegment, SegmentCount, Tile};
+
+use super::{
+ CpuBinding,
+ util::{ONE_MINUS_ULP, ROBUST_EPSILON, Vec2, span},
+};
+
+const TILE_WIDTH: u32 = 16;
+const TILE_HEIGHT: u32 = 16;
+const TILE_SCALE: f32 = 1.0 / 16.0;
+
+fn path_tiling_main(
+ bump: &mut BumpAllocators,
+ seg_counts: &[SegmentCount],
+ lines: &[LineSoup],
+ paths: &[Path],
+ tiles: &[Tile],
+ segments: &mut [PathSegment],
+) {
+ for seg_ix in 0..bump.seg_counts {
+ let seg_count = seg_counts[seg_ix as usize];
+ let line = lines[seg_count.line_ix as usize];
+ let counts = seg_count.counts;
+ let seg_within_slice = counts >> 16;
+ let seg_within_line = counts & 0xffff;
+
+ // coarse rasterization logic
+ let p0 = Vec2::from_array(line.p0);
+ let p1 = Vec2::from_array(line.p1);
+ let is_down = p1.y >= p0.y;
+ let (mut xy0, mut xy1) = if is_down { (p0, p1) } else { (p1, p0) };
+ let s0 = xy0 * TILE_SCALE;
+ let s1 = xy1 * TILE_SCALE;
+ let count_x = span(s0.x, s1.x) - 1;
+ let count = count_x + span(s0.y, s1.y);
+
+ let dx = (s1.x - s0.x).abs();
+ let dy = s1.y - s0.y;
+ let idxdy = 1.0 / (dx + dy);
+ let mut a = dx * idxdy;
+ let is_positive_slope = s1.x >= s0.x;
+ let sign = if is_positive_slope { 1.0 } else { -1.0 };
+ let xt0 = (s0.x * sign).floor();
+ let c = s0.x * sign - xt0;
+ let y0 = s0.y.floor();
+ let ytop = if s0.y == s1.y { s0.y.ceil() } else { y0 + 1.0 };
+ let b = ((dy * c + dx * (ytop - s0.y)) * idxdy).min(ONE_MINUS_ULP);
+ let robust_err = (a * (count as f32 - 1.0) + b).floor() - count_x as f32;
+ if robust_err != 0.0 {
+ a -= ROBUST_EPSILON.copysign(robust_err);
+ }
+ let x0 = xt0 * sign + if is_positive_slope { 0.0 } else { -1.0 };
+ let z = (a * seg_within_line as f32 + b).floor();
+ let x = x0 as i32 + (sign * z) as i32;
+ let y = (y0 + seg_within_line as f32 - z) as i32;
+
+ let path = paths[line.path_ix as usize];
+ let bbox = path.bbox;
+ let bbox = [
+ bbox[0] as i32,
+ bbox[1] as i32,
+ bbox[2] as i32,
+ bbox[3] as i32,
+ ];
+ let stride = bbox[2] - bbox[0];
+ let tile_ix = path.tiles as i32 + (y - bbox[1]) * stride + x - bbox[0];
+ let tile = tiles[tile_ix as usize];
+ let seg_start = !tile.segment_count_or_ix;
+ if (seg_start as i32) < 0 {
+ continue;
+ }
+ let tile_xy = Vec2::new(x as f32 * TILE_WIDTH as f32, y as f32 * TILE_HEIGHT as f32);
+ let tile_xy1 = tile_xy + Vec2::new(TILE_WIDTH as f32, TILE_HEIGHT as f32);
+
+ if seg_within_line > 0 {
+ let z_prev = (a * (seg_within_line as f32 - 1.0) + b).floor();
+ if z == z_prev {
+ // Top edge is clipped
+ let mut xt = xy0.x + (xy1.x - xy0.x) * (tile_xy.y - xy0.y) / (xy1.y - xy0.y);
+ xt = xt.clamp(tile_xy.x + 1e-3, tile_xy1.x);
+ xy0 = Vec2::new(xt, tile_xy.y);
+ } else {
+ // If is_positive_slope, left edge is clipped, otherwise right
+ let x_clip = if is_positive_slope {
+ tile_xy.x
+ } else {
+ tile_xy1.x
+ };
+ let mut yt = xy0.y + (xy1.y - xy0.y) * (x_clip - xy0.x) / (xy1.x - xy0.x);
+ yt = yt.clamp(tile_xy.y + 1e-3, tile_xy1.y);
+ xy0 = Vec2::new(x_clip, yt);
+ }
+ }
+ if seg_within_line < count - 1 {
+ let z_next = (a * (seg_within_line as f32 + 1.0) + b).floor();
+ if z == z_next {
+ // Bottom edge is clipped
+ let mut xt = xy0.x + (xy1.x - xy0.x) * (tile_xy1.y - xy0.y) / (xy1.y - xy0.y);
+ xt = xt.clamp(tile_xy.x + 1e-3, tile_xy1.x);
+ xy1 = Vec2::new(xt, tile_xy1.y);
+ } else {
+ // If is_positive_slope, right edge is clipped, otherwise left
+ let x_clip = if is_positive_slope {
+ tile_xy1.x
+ } else {
+ tile_xy.x
+ };
+ let mut yt = xy0.y + (xy1.y - xy0.y) * (x_clip - xy0.x) / (xy1.x - xy0.x);
+ yt = yt.clamp(tile_xy.y + 1e-3, tile_xy1.y);
+ xy1 = Vec2::new(x_clip, yt);
+ }
+ }
+ let mut y_edge = 1e9;
+ // Apply numerical robustness logic
+ let mut p0 = xy0 - tile_xy;
+ let mut p1 = xy1 - tile_xy;
+ const EPSILON: f32 = 1e-6;
+ if p0.x == 0.0 {
+ if p1.x == 0.0 {
+ p0.x = EPSILON;
+ if p0.y == 0.0 {
+ // Entire tile
+ p1.x = EPSILON;
+ p1.y = TILE_HEIGHT as f32;
+ } else {
+ // Make segment disappear
+ p1.x = 2.0 * EPSILON;
+ p1.y = p0.y;
+ }
+ } else if p0.y == 0.0 {
+ p0.x = EPSILON;
+ } else {
+ y_edge = p0.y;
+ }
+ } else if p1.x == 0.0 {
+ if p1.y == 0.0 {
+ p1.x = EPSILON;
+ } else {
+ y_edge = p1.y;
+ }
+ }
+ if p0.x == p0.x.floor() && p0.x != 0.0 {
+ p0.x -= EPSILON;
+ }
+ if p1.x == p1.x.floor() && p1.x != 0.0 {
+ p1.x -= EPSILON;
+ }
+ if !is_down {
+ (p0, p1) = (p1, p0);
+ }
+ let segment = PathSegment {
+ point0: p0.to_array(),
+ point1: p1.to_array(),
+ y_edge,
+ _padding: Default::default(),
+ };
+ assert!(p0.x >= 0.0 && p0.x <= TILE_WIDTH as f32);
+ assert!(p0.y >= 0.0 && p0.y <= TILE_HEIGHT as f32);
+ assert!(p1.x >= 0.0 && p1.x <= TILE_WIDTH as f32);
+ assert!(p1.y >= 0.0 && p1.y <= TILE_HEIGHT as f32);
+ segments[(seg_start + seg_within_slice) as usize] = segment;
+ }
+}
+
+pub fn path_tiling(_n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let mut bump = resources[0].as_typed_mut();
+ let seg_counts = resources[1].as_slice();
+ let lines = resources[2].as_slice();
+ let paths = resources[3].as_slice();
+ let tiles = resources[4].as_slice();
+ let mut segments = resources[5].as_slice_mut();
+ path_tiling_main(
+ &mut bump,
+ &seg_counts,
+ &lines,
+ &paths,
+ &tiles,
+ &mut segments,
+ );
+}
diff --git a/vendor/vello_shaders/src/cpu/path_tiling_setup.rs b/vendor/vello_shaders/src/cpu/path_tiling_setup.rs
new file mode 100644
index 00000000..72006af4
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/path_tiling_setup.rs
@@ -0,0 +1,22 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{BumpAllocators, IndirectCount};
+
+use super::CpuBinding;
+
+const WG_SIZE: usize = 256;
+
+fn path_tiling_setup_main(bump: &BumpAllocators, indirect: &mut IndirectCount) {
+ let segments = bump.seg_counts;
+ indirect.count_x = segments.div_ceil(WG_SIZE as u32);
+ indirect.count_y = 1;
+ indirect.count_z = 1;
+}
+
+pub fn path_tiling_setup(_n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let bump = resources[0].as_typed();
+ let mut indirect = resources[1].as_typed_mut();
+ // binding 2 is ptcl, which we would need if we propagate failure
+ path_tiling_setup_main(&bump, &mut indirect);
+}
diff --git a/vendor/vello_shaders/src/cpu/pathtag_reduce.rs b/vendor/vello_shaders/src/cpu/pathtag_reduce.rs
new file mode 100644
index 00000000..34972887
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/pathtag_reduce.rs
@@ -0,0 +1,32 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{ConfigUniform, Monoid, PathMonoid};
+
+use super::CpuBinding;
+
+const WG_SIZE: usize = 256;
+
+fn pathtag_reduce_main(
+ n_wg: u32,
+ config: &ConfigUniform,
+ scene: &[u32],
+ reduced: &mut [PathMonoid],
+) {
+ let pathtag_base = config.layout.path_tag_base;
+ for i in 0..n_wg {
+ let mut m = PathMonoid::default();
+ for j in 0..WG_SIZE {
+ let tag = scene[(pathtag_base + i * WG_SIZE as u32) as usize + j];
+ m = m.combine(&PathMonoid::new(tag));
+ }
+ reduced[i as usize] = m;
+ }
+}
+
+pub fn pathtag_reduce(n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let config = resources[0].as_typed();
+ let scene = resources[1].as_slice();
+ let mut reduced = resources[2].as_slice_mut();
+ pathtag_reduce_main(n_wg, &config, &scene, &mut reduced);
+}
diff --git a/vendor/vello_shaders/src/cpu/pathtag_scan.rs b/vendor/vello_shaders/src/cpu/pathtag_scan.rs
new file mode 100644
index 00000000..a654cb96
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/pathtag_scan.rs
@@ -0,0 +1,37 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{ConfigUniform, Monoid, PathMonoid};
+
+use super::CpuBinding;
+
+const WG_SIZE: usize = 256;
+
+fn pathtag_scan_main(
+ n_wg: u32,
+ config: &ConfigUniform,
+ scene: &[u32],
+ reduced: &[PathMonoid],
+ tag_monoids: &mut [PathMonoid],
+) {
+ let pathtag_base = config.layout.path_tag_base;
+ let mut prefix = PathMonoid::default();
+ for i in 0..n_wg {
+ let mut m = prefix;
+ for j in 0..WG_SIZE {
+ let ix = (i * WG_SIZE as u32) as usize + j;
+ tag_monoids[ix] = m;
+ let tag = scene[pathtag_base as usize + ix];
+ m = m.combine(&PathMonoid::new(tag));
+ }
+ prefix = prefix.combine(&reduced[i as usize]);
+ }
+}
+
+pub fn pathtag_scan(n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let config = resources[0].as_typed();
+ let scene = resources[1].as_slice();
+ let reduced = resources[2].as_slice();
+ let mut tag_monoids = resources[3].as_slice_mut();
+ pathtag_scan_main(n_wg, &config, &scene, &reduced, &mut tag_monoids);
+}
diff --git a/vendor/vello_shaders/src/cpu/tile_alloc.rs b/vendor/vello_shaders/src/cpu/tile_alloc.rs
new file mode 100644
index 00000000..e67d0d9c
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/tile_alloc.rs
@@ -0,0 +1,72 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+use vello_encoding::{BumpAllocators, ConfigUniform, DrawTag, Path, Tile};
+
+use super::CpuBinding;
+
+const TILE_WIDTH: usize = 16;
+const TILE_HEIGHT: usize = 16;
+const SX: f32 = 1.0 / (TILE_WIDTH as f32);
+const SY: f32 = 1.0 / (TILE_HEIGHT as f32);
+
+fn tile_alloc_main(
+ config: &ConfigUniform,
+ scene: &[u32],
+ draw_bboxes: &[[f32; 4]],
+ bump: &mut BumpAllocators,
+ paths: &mut [Path],
+ tiles: &mut [Tile],
+) {
+ let drawtag_base = config.layout.draw_tag_base;
+ let width_in_tiles = config.width_in_tiles as i32;
+ let height_in_tiles = config.height_in_tiles as i32;
+ for drawobj_ix in 0..config.layout.n_draw_objects {
+ let drawtag = DrawTag(scene[(drawtag_base + drawobj_ix) as usize]);
+ let mut x0 = 0;
+ let mut y0 = 0;
+ let mut x1 = 0;
+ let mut y1 = 0;
+ if drawtag != DrawTag::NOP && drawtag != DrawTag::END_CLIP {
+ let bbox = draw_bboxes[drawobj_ix as usize];
+ if bbox[0] < bbox[2] && bbox[1] < bbox[3] {
+ x0 = (bbox[0] * SX).floor() as i32;
+ y0 = (bbox[1] * SY).floor() as i32;
+ x1 = (bbox[2] * SX).ceil() as i32;
+ y1 = (bbox[3] * SY).ceil() as i32;
+ }
+ }
+ let ux0 = x0.clamp(0, width_in_tiles) as u32;
+ let uy0 = y0.clamp(0, height_in_tiles) as u32;
+ let ux1 = x1.clamp(0, width_in_tiles) as u32;
+ let uy1 = y1.clamp(0, height_in_tiles) as u32;
+ let tile_count = (ux1 - ux0) * (uy1 - uy0);
+ let offset = bump.tile;
+ bump.tile += tile_count;
+ // We construct it this way because padding is private.
+ let mut path = Path::default();
+ path.bbox = [ux0, uy0, ux1, uy1];
+ path.tiles = offset;
+ paths[drawobj_ix as usize] = path;
+ for i in 0..tile_count {
+ tiles[(offset + i) as usize] = Tile::default();
+ }
+ }
+}
+
+pub fn tile_alloc(_n_wg: u32, resources: &[CpuBinding<'_>]) {
+ let config = resources[0].as_typed();
+ let scene = resources[1].as_slice();
+ let draw_bboxes = resources[2].as_slice();
+ let mut bump = resources[3].as_typed_mut();
+ let mut paths = resources[4].as_slice_mut();
+ let mut tiles = resources[5].as_slice_mut();
+ tile_alloc_main(
+ &config,
+ &scene,
+ &draw_bboxes,
+ &mut bump,
+ &mut paths,
+ &mut tiles,
+ );
+}
diff --git a/vendor/vello_shaders/src/cpu/util.rs b/vendor/vello_shaders/src/cpu/util.rs
new file mode 100644
index 00000000..ec801ebe
--- /dev/null
+++ b/vendor/vello_shaders/src/cpu/util.rs
@@ -0,0 +1,228 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
+
+//! Utility types
+
+use std::ops::Mul;
+use vello_encoding::ConfigUniform;
+
+#[derive(Clone, Copy, Default, Debug, PartialEq)]
+#[repr(C)]
+pub struct Vec2 {
+ pub x: f32,
+ pub y: f32,
+}
+
+impl std::ops::Add for Vec2 {
+ type Output = Self;
+
+ fn add(self, rhs: Self) -> Self {
+ Self {
+ x: self.x + rhs.x,
+ y: self.y + rhs.y,
+ }
+ }
+}
+
+impl std::ops::Sub for Vec2 {
+ type Output = Self;
+
+ fn sub(self, rhs: Self) -> Self {
+ Self {
+ x: self.x - rhs.x,
+ y: self.y - rhs.y,
+ }
+ }
+}
+
+impl Mul<f32> for Vec2 {
+ type Output = Self;
+
+ fn mul(self, rhs: f32) -> Self {
+ Self {
+ x: self.x * rhs,
+ y: self.y * rhs,
+ }
+ }
+}
+
+impl std::ops::Div<f32> for Vec2 {
+ type Output = Self;
+
+ fn div(self, rhs: f32) -> Self {
+ Self {
+ x: self.x / rhs,
+ y: self.y / rhs,
+ }
+ }
+}
+
+impl Mul<Vec2> for f32 {
+ type Output = Vec2;
+
+ fn mul(self, rhs: Vec2) -> Self::Output {
+ rhs * self
+ }
+}
+
+impl std::ops::Neg for Vec2 {
+ type Output = Self;
+
+ fn neg(self) -> Self::Output {
+ Self::new(-self.x, -self.y)
+ }
+}
+
+impl Vec2 {
+ pub fn new(x: f32, y: f32) -> Self {
+ Self { x, y }
+ }
+
+ pub fn dot(self, other: Self) -> f32 {
+ self.x * other.x + self.y * other.y
+ }
+
+ pub fn cross(self, other: Self) -> f32 {
+ (self.x * other.y) - (self.y * other.x)
+ }
+
+ pub fn length(self) -> f32 {
+ self.x.hypot(self.y)
+ }
+
+ pub fn length_squared(self) -> f32 {
+ self.dot(self)
+ }
+
+ pub fn distance(self, other: Self) -> f32 {
+ (self - other).length()
+ }
+
+ pub fn to_array(self) -> [f32; 2] {
+ [self.x, self.y]
+ }
+
+ pub fn from_array(a: [f32; 2]) -> Self {
+ Self { x: a[0], y: a[1] }
+ }
+
+ pub fn mix(self, other: Self, t: f32) -> Self {
+ let x = self.x + (other.x - self.x) * t;
+ let y = self.y + (other.y - self.y) * t;
+ Self { x, y }
+ }
+
+ pub fn normalize(self) -> Self {
+ self / self.length()
+ }
+
+ pub fn atan2(self) -> f32 {
+ self.y.atan2(self.x)
+ }
+
+ pub fn is_nan(self) -> bool {
+ self.x.is_nan() || self.y.is_nan()
+ }
+
+ pub fn min(self, other: Self) -> Self {
+ Self::new(self.x.min(other.x), self.y.min(other.y))
+ }
+
+ pub fn max(self, other: Self) -> Self {
+ Self::new(self.x.max(other.x), self.y.max(other.y))
+ }
+}
+
+#[derive(Clone)]
+pub(crate) struct Transform(pub(crate) [f32; 6]);
+
+impl Transform {
+ pub(crate) fn identity() -> Self {
+ Self([1., 0., 0., 1., 0., 0.])
+ }
+
+ pub(crate) fn apply(&self, p: Vec2) -> Vec2 {
+ let z = self.0;
+ let x = z[0] * p.x + z[2] * p.y + z[4];
+ let y = z[1] * p.x + z[3] * p.y + z[5];
+ Vec2 { x, y }
+ }
+
+ pub(crate) fn inverse(&self) -> Self {
+ let z = self.0;
+ let inv_det = (z[0] * z[3] - z[1] * z[2]).recip();
+ let inv_mat = [
+ z[3] * inv_det,
+ -z[1] * inv_det,
+ -z[2] * inv_det,
+ z[0] * inv_det,
+ ];
+ Self([
+ inv_mat[0],
+ inv_mat[1],
+ inv_mat[2],
+ inv_mat[3],
+ -(inv_mat[0] * z[4] + inv_mat[2] * z[5]),
+ -(inv_mat[1] * z[4] + inv_mat[3] * z[5]),
+ ])
+ }
+
+ pub(crate) fn read(transform_base: u32, ix: u32, data: &[u32]) -> Self {
+ let mut z = [0.0; 6];
+ let base = (transform_base + ix * 6) as usize;
+ for i in 0..6 {
+ z[i] = f32::from_bits(data[base + i]);
+ }
+ Self(z)
+ }
+}
+
+impl Mul for Transform {
+ type Output = Self;
+
+ #[inline]
+ fn mul(self, other: Self) -> Self {
+ Self([
+ self.0[0] * other.0[0] + self.0[2] * other.0[1],
+ self.0[1] * other.0[0] + self.0[3] * other.0[1],
+ self.0[0] * other.0[2] + self.0[2] * other.0[3],
+ self.0[1] * other.0[2] + self.0[3] * other.0[3],
+ self.0[0] * other.0[4] + self.0[2] * other.0[5] + self.0[4],
+ self.0[1] * other.0[4] + self.0[3] * other.0[5] + self.0[5],
+ ])
+ }
+}
+
+pub(crate) fn span(a: f32, b: f32) -> u32 {
+ (a.max(b).ceil() - a.min(b).floor()).max(1.0) as u32
+}
+
+const DRAWTAG_NOP: u32 = 0;
+
+/// Read draw tag, guarded by number of draw objects.
+///
+/// The `ix` argument is allowed to exceed the number of draw objects,
+/// in which case a NOP is returned.
+pub(crate) fn read_draw_tag_from_scene(config: &ConfigUniform, scene: &[u32], ix: u32) -> u32 {
+ if ix < config.layout.n_draw_objects {
+ let tag_ix = config.layout.draw_tag_base + ix;
+ scene[tag_ix as usize]
+ } else {
+ DRAWTAG_NOP
+ }
+}
+
+/// The largest floating point value strictly less than 1.
+///
+/// This value is used to limit the value of b so that its floor is strictly less
+/// than 1. That guarantees that floor(a * i + b) == 0 for i == 0, which lands on
+/// the correct first tile.
+pub(crate) const ONE_MINUS_ULP: f32 = 0.99999994;
+
+/// An epsilon to be applied in path numerical robustness.
+///
+/// When floor(a * (n - 1) + b) does not match the expected value (the width in
+/// grid cells minus one), this delta is applied to a to push it in the correct
+/// direction. The theory is that a is not off by more than a few ulp, and it's
+/// always in the range of 0..1.
+pub(crate) const ROBUST_EPSILON: f32 = 2e-7;
diff --git a/vendor/vello_shaders/src/lib.rs b/vendor/vello_shaders/src/lib.rs
new file mode 100644
index 00000000..cedd0551
--- /dev/null
+++ b/vendor/vello_shaders/src/lib.rs
@@ -0,0 +1,141 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+
+//! This is a utility library to help integrate the [Vello] shader modules into any renderer
+//! project. It provides the necessary metadata to construct the individual compute pipelines
+//! on any GPU API while leaving the responsibility of all API interactions
+//! (such as resource management and command encoding) up to the client.
+//!
+//! The shaders can be pre-compiled to any target shading language at build time based on
+//! feature flags. Currently only WGSL and Metal Shading Language are supported.
+//!
+//! Your first choice should be to use the build time generated [`SHADERS`].
+//!
+//! Alternatively you could use runtime compiled shaders via the [`compile`] module
+//! by enabling the `compile` feature. This option is useful for active development
+//! as it enables you to do hot reloading of shaders.
+//!
+//! [Vello]: https://github.com/linebender/vello
+
+// LINEBENDER LINT SET - lib.rs - v2
+// See https://linebender.org/wiki/canonical-lints/
+// These lints aren't included in Cargo.toml because they
+// shouldn't apply to examples and tests
+#![warn(unused_crate_dependencies)]
+#![warn(clippy::print_stdout, clippy::print_stderr)]
+// Targeting e.g. 32-bit means structs containing usize can give false positives for 64-bit.
+#![cfg_attr(target_pointer_width = "64", warn(clippy::trivially_copy_pass_by_ref))]
+// END LINEBENDER LINT SET
+#![cfg_attr(docsrs, feature(doc_cfg))]
+// The following lints are part of the Linebender standard set,
+// but resolving them has been deferred for now.
+// Feel free to send a PR that solves one or more of these.
+// Need to allow instead of expect until Rust 1.83 https://github.com/rust-lang/rust/pull/130025
+#![allow(missing_docs, reason = "We have many as-yet undocumented items.")]
+#![expect(missing_debug_implementations, reason = "Deferred")]
+#![allow(
+ unnameable_types,
+ clippy::cast_possible_truncation,
+ clippy::missing_assert_message,
+ clippy::print_stdout,
+ clippy::todo,
+ reason = "Deferred, only apply in some feature sets so not expect"
+)]
+
+mod types;
+
+#[cfg(feature = "compile")]
+pub mod compile;
+#[cfg(feature = "cpu")]
+pub mod cpu;
+
+#[cfg(feature = "msl")]
+pub use types::msl;
+pub use types::{BindType, BindingInfo, WorkgroupBufferInfo};
+
+use std::borrow::Cow;
+
+#[derive(Clone, Debug)]
+pub struct ComputeShader<'a> {
+ pub name: Cow<'a, str>,
+ pub workgroup_size: [u32; 3],
+ pub bindings: Cow<'a, [BindType]>,
+ pub workgroup_buffers: Cow<'a, [WorkgroupBufferInfo]>,
+
+ #[cfg(feature = "wgsl")]
+ pub wgsl: WgslSource<'a>,
+
+ #[cfg(feature = "msl")]
+ pub msl: MslSource<'a>,
+}
+
+#[cfg(feature = "wgsl")]
+#[derive(Clone, Debug)]
+pub struct WgslSource<'a> {
+ pub code: Cow<'a, str>,
+
+ /// Contains the binding index of each resource listed in `ComputeShader::bindings`.
+ /// This is guaranteed to have the same element count as `ComputeShader::bindings`.
+ ///
+ /// In WGSL, each index directly corresponds to the value of the corresponding
+ /// `@binding(..)` declaration in the shader source. The bind group index (i.e.
+ /// value of `@group(..)`) is always 0.
+ ///
+ /// Example:
+ /// --------
+ /// ```wgsl
+ /// // An unused binding (i.e. declaration is not reachable from the entry-point)
+ /// @group(0) @binding(0) var<uniform> foo: Foo;
+ ///
+ /// // Used bindings:
+ /// @group(0) @binding(1) var<storage> buffer: Buffer;
+ /// @group(0) @binding(2) var tex: texture_2d<f32>;
+ /// ```
+ /// This results in the following bindings:
+ /// ```rust,ignore
+ /// bindings: [BindType::Buffer, BindType::ImageRead],
+ /// // ...
+ /// wgsl: WgslSource {
+ /// code: /* ... */,
+ /// binding_indices: [1, 2],
+ /// },
+ /// ```
+ pub binding_indices: Cow<'a, [u8]>,
+}
+
+#[cfg(feature = "msl")]
+#[derive(Clone, Debug)]
+pub struct MslSource<'a> {
+ pub code: Cow<'a, str>,
+
+ /// Contains the binding index of each resource listed in [`ComputeShader::bindings`].
+ /// This is guaranteed to have the same element count as `ComputeShader::bindings`.
+ ///
+ /// In MSL, each index is scoped to the index range of the corresponding resource type.
+ ///
+ /// Example:
+ /// --------
+ /// ```wgsl
+ /// // An unused binding (i.e. declaration is not reachable from the entry-point)
+ /// @group(0) @binding(0) var<uniform> foo: Foo;
+ ///
+ /// // Used bindings:
+ /// @group(0) @binding(1) var<storage> buffer: Buffer;
+ /// @group(0) @binding(2) var tex: texture_2d<f32>;
+ /// ```
+ /// This results in the following bindings:
+ /// ```rust,ignore
+ /// bindings: [BindType::Buffer, BindType::ImageRead],
+ /// // ...
+ /// msl: MslSource {
+ /// code: /* ... */,
+ /// // In MSL these would be declared as `[[buffer(0)]]` and `[[texture(0)]]`.
+ /// binding_indices: [msl::BindingIndex::Buffer(0), msl::BindingIndex::Texture(0)],
+ /// },
+ /// ```
+ pub binding_indices: Cow<'a, [msl::BindingIndex]>,
+}
+
+include!(concat!(env!("OUT_DIR"), "/shaders.rs"));
+
+pub use generated::SHADERS;
diff --git a/vendor/vello_shaders/src/types.rs b/vendor/vello_shaders/src/types.rs
new file mode 100644
index 00000000..375a7b92
--- /dev/null
+++ b/vendor/vello_shaders/src/types.rs
@@ -0,0 +1,60 @@
+// Copyright 2023 the Vello Authors
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+
+//! Types that are shared between the main crate and build.
+
+/// The type of resource that will be bound to a slot in a shader.
+#[derive(Copy, Clone, PartialEq, Eq, Debug)]
+pub enum BindType {
+ /// A storage buffer with read/write access.
+ Buffer,
+ /// A storage buffer with read only access.
+ BufReadOnly,
+ /// A small storage buffer to be used as uniforms.
+ Uniform,
+ /// A storage image.
+ Image,
+ /// A storage image with read only access.
+ ImageRead,
+ // TODO: Sampler, maybe others
+}
+
+impl BindType {
+ pub fn is_mutable(self) -> bool {
+ matches!(self, Self::Buffer | Self::Image)
+ }
+}
+
+#[derive(Clone, Debug)]
+pub struct BindingInfo {
+ pub name: Option<String>,
+ pub location: (u32, u32),
+ pub ty: BindType,
+}
+
+#[derive(Clone, Debug)]
+pub struct WorkgroupBufferInfo {
+ pub size_in_bytes: u32,
+ /// The order in which the workgroup variable is declared in the shader module.
+ pub index: u32,
+}
+
+#[cfg(feature = "msl")]
+pub mod msl {
+ use std::fmt;
+
+ #[derive(Clone)]
+ pub enum BindingIndex {
+ Buffer(u8),
+ Texture(u8),
+ }
+
+ impl fmt::Debug for BindingIndex {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match *self {
+ Self::Buffer(i) => write!(f, "msl::BindingIndex::Buffer({i})"),
+ Self::Texture(i) => write!(f, "msl::BindingIndex::Texture({i})"),
+ }
+ }
+ }
+}
diff --git a/vendor/vendor.toml b/vendor/vendor.toml
index db09f769..c4c24255 100644
--- a/vendor/vendor.toml
+++ b/vendor/vendor.toml
@@ -143,3 +143,10 @@ upstream = "crates.io:0.12.2"
kind = "bump"
reason = "bevy_reflect 0.20 (Firewheel#144)"
exit = "a Firewheel release with #144"
+
+[vello_shaders]
+path = "vendor/vello_shaders"
+upstream = "crates.io:0.11.0"
+kind = "patch"
+reason = "linear-light blending in fine.wgsl (Config.blend_linear, set by vello_encoding's set_blend_linear): every colour, ramp and texel decoded from sRGB, blended, and encoded once, the blend stack kept sRGB-encoded, so raea-page blends a bevy_ui page as Bevy's UI does on an sRGB target"
+exit = "a Vello release that blends in linear light on request"