Repository navigation
Commit 5624a7f
fix: Signed right shift losing a bit on exact operands
bitwiseSignedRightShift divided by pow(2.0, float(shifts)), but pow is
approximate on most GPUs — it is usually exp2(y * log2(x)) — so the
divisor could land ~1 ulp high. The quotient then fell just short of a
whole number and floor() discarded it: 2 >> 1 returned 0, 8 >> 1
returned 3, 8 >> 3 returned 0.
Only even left operands were affected. Odd ones carry a fractional part
large enough to absorb the error, which is why 3 >> 1 and 5 >> 1 were
always right and the breakage looked arbitrary.
Use _pow2 instead, the exact constant-multiply helper already added for
the same class of bug in the float packing (#659). Applied to both the
webgl and webgl2 shaders, with a forward declaration since _pow2 is
defined further down.
The other shift and bitwise operators are integer loops that never
touched pow, which matches the failure set exactly.
macOS suite goes 9 -> 3 failures; only the Infinity encoding family is
left. Verified exhaustively against JS semantics for `>>` over a wide
value range including negatives (0/484 mismatches, was 7/100 on the
0-9 grid alone), the other five bitwise operators unchanged, and 9
BrowserStack targets green — the webgl2 path has no node coverage.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent ec8e295 commit 5624a7f
7 files changed
Lines changed: 65 additions & 14 deletions
File tree
- dist
- src/backend
- web-gl2
- web-gl
- test/browserstack
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
6617 | 6617 | | |
6618 | 6618 | | |
6619 | 6619 | | |
| 6620 | + | |
| 6621 | + | |
6620 | 6622 | | |
6621 | | - | |
| 6623 | + | |
| 6624 | + | |
| 6625 | + | |
| 6626 | + | |
| 6627 | + | |
6622 | 6628 | | |
6623 | 6629 | | |
6624 | 6630 | | |
| |||
11358 | 11364 | | |
11359 | 11365 | | |
11360 | 11366 | | |
| 11367 | + | |
| 11368 | + | |
11361 | 11369 | | |
11362 | | - | |
| 11370 | + | |
| 11371 | + | |
| 11372 | + | |
| 11373 | + | |
| 11374 | + | |
11363 | 11375 | | |
11364 | 11376 | | |
11365 | 11377 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
12071 | 12071 | | |
12072 | 12072 | | |
12073 | 12073 | | |
| 12074 | + | |
| 12075 | + | |
12074 | 12076 | | |
12075 | | - | |
| 12077 | + | |
| 12078 | + | |
| 12079 | + | |
| 12080 | + | |
| 12081 | + | |
12076 | 12082 | | |
12077 | 12083 | | |
12078 | 12084 | | |
| |||
16812 | 16818 | | |
16813 | 16819 | | |
16814 | 16820 | | |
| 16821 | + | |
| 16822 | + | |
16815 | 16823 | | |
16816 | | - | |
| 16824 | + | |
| 16825 | + | |
| 16826 | + | |
| 16827 | + | |
| 16828 | + | |
16817 | 16829 | | |
16818 | 16830 | | |
16819 | 16831 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
| 196 | + | |
195 | 197 | | |
196 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
197 | 203 | | |
198 | 204 | | |
199 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
157 | 159 | | |
158 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
159 | 165 | | |
160 | 166 | | |
161 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
192 | 207 | | |
193 | 208 | | |
194 | 209 | | |
| |||
0 commit comments