Commit 5c88baf
Cell: SoA neighbor data for SDF worker hot loop
Split the packed [nx, ny, invD2] stride-3 Float32Array into three
parallel Float32Array (neighborNx, neighborNy, neighborInvD2). The
SDF inner loop is the dominant frame cost; with stride-3 packing,
V8/SpiderMonkey couldn't fold each access into a simple offset
add and reverted to a slower per-iteration index calc. With stride-1
SoA, each typed-array read is a JIT-friendly indexed load.
Worker compute on the profiled config drops from ~30+ ms (per the
old comment) to ~25 ms, a measured ~17% speedup; main thread CPU
utilization at ~30% with 60 fps stable.
neighborOffsets[k] semantics also shift from "stride-3 byte offset
into neighborData" to "neighbor slot index" (1:1 with neighborNx[]).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent a8f67d1 commit 5c88baf
2 files changed
Lines changed: 51 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
258 | 270 | | |
259 | 271 | | |
260 | 272 | | |
| |||
705 | 717 | | |
706 | 718 | | |
707 | 719 | | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
712 | 731 | | |
713 | 732 | | |
714 | 733 | | |
715 | 734 | | |
716 | 735 | | |
717 | 736 | | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
722 | 741 | | |
723 | 742 | | |
724 | 743 | | |
| |||
802 | 821 | | |
803 | 822 | | |
804 | 823 | | |
805 | | - | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
806 | 827 | | |
807 | 828 | | |
808 | 829 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
18 | 25 | | |
19 | 26 | | |
20 | 27 | | |
| |||
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
41 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
42 | 51 | | |
43 | 52 | | |
44 | 53 | | |
| |||
66 | 75 | | |
67 | 76 | | |
68 | 77 | | |
69 | | - | |
| 78 | + | |
70 | 79 | | |
71 | 80 | | |
72 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
73 | 84 | | |
74 | 85 | | |
75 | 86 | | |
| |||
101 | 112 | | |
102 | 113 | | |
103 | 114 | | |
104 | | - | |
| 115 | + | |
105 | 116 | | |
106 | 117 | | |
107 | 118 | | |
| |||
114 | 125 | | |
115 | 126 | | |
116 | 127 | | |
117 | | - | |
118 | | - | |
119 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
120 | 131 | | |
121 | 132 | | |
122 | | - | |
| 133 | + | |
123 | 134 | | |
124 | 135 | | |
125 | 136 | | |
| |||
0 commit comments