@deck.gl/extensions 9.3.0-alpha.3 → 9.3.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.dev.js CHANGED
@@ -85,7 +85,7 @@ var __exports__ = (() => {
85
85
  var import_core2 = __toESM(require_core(), 1);
86
86
  var uniformBlock = (
87
87
  /* glsl */
88
- `uniform brushingUniforms {
88
+ `layout(std140) uniform brushingUniforms {
89
89
  bool enabled;
90
90
  highp int target;
91
91
  vec2 mousePos;
@@ -269,24 +269,18 @@ ${fragment}
269
269
  // src/data-filter/shader-module.ts
270
270
  var uniformBlock2 = (
271
271
  /* glsl */
272
- `uniform dataFilterUniforms {
272
+ `layout(std140) uniform dataFilterUniforms {
273
273
  bool useSoftMargin;
274
274
  bool enabled;
275
275
  bool transformSize;
276
276
  bool transformColor;
277
- #ifdef DATAFILTER_TYPE
278
- DATAFILTER_TYPE min;
279
- DATAFILTER_TYPE softMin;
280
- DATAFILTER_TYPE softMax;
281
- DATAFILTER_TYPE max;
282
- #ifdef DATAFILTER_DOUBLE
283
- DATAFILTER_TYPE min64High;
284
- DATAFILTER_TYPE max64High;
285
- #endif
286
- #endif
287
- #ifdef DATACATEGORY_TYPE
277
+ vec4 min;
278
+ vec4 softMin;
279
+ vec4 softMax;
280
+ vec4 max;
281
+ vec4 min64High;
282
+ vec4 max64High;
288
283
  highp uvec4 categoryBitMask;
289
- #endif
290
284
  } dataFilter;
291
285
  `
292
286
  );
@@ -306,6 +300,86 @@ ${fragment}
306
300
 
307
301
  out float dataFilter_value;
308
302
 
303
+ #ifdef DATAFILTER_TYPE
304
+ float dataFilter_getMin(float _) {
305
+ return dataFilter.min.x;
306
+ }
307
+ vec2 dataFilter_getMin(vec2 _) {
308
+ return dataFilter.min.xy;
309
+ }
310
+ vec3 dataFilter_getMin(vec3 _) {
311
+ return dataFilter.min.xyz;
312
+ }
313
+ vec4 dataFilter_getMin(vec4 _) {
314
+ return dataFilter.min;
315
+ }
316
+
317
+ float dataFilter_getSoftMin(float _) {
318
+ return dataFilter.softMin.x;
319
+ }
320
+ vec2 dataFilter_getSoftMin(vec2 _) {
321
+ return dataFilter.softMin.xy;
322
+ }
323
+ vec3 dataFilter_getSoftMin(vec3 _) {
324
+ return dataFilter.softMin.xyz;
325
+ }
326
+ vec4 dataFilter_getSoftMin(vec4 _) {
327
+ return dataFilter.softMin;
328
+ }
329
+
330
+ float dataFilter_getSoftMax(float _) {
331
+ return dataFilter.softMax.x;
332
+ }
333
+ vec2 dataFilter_getSoftMax(vec2 _) {
334
+ return dataFilter.softMax.xy;
335
+ }
336
+ vec3 dataFilter_getSoftMax(vec3 _) {
337
+ return dataFilter.softMax.xyz;
338
+ }
339
+ vec4 dataFilter_getSoftMax(vec4 _) {
340
+ return dataFilter.softMax;
341
+ }
342
+
343
+ float dataFilter_getMax(float _) {
344
+ return dataFilter.max.x;
345
+ }
346
+ vec2 dataFilter_getMax(vec2 _) {
347
+ return dataFilter.max.xy;
348
+ }
349
+ vec3 dataFilter_getMax(vec3 _) {
350
+ return dataFilter.max.xyz;
351
+ }
352
+ vec4 dataFilter_getMax(vec4 _) {
353
+ return dataFilter.max;
354
+ }
355
+
356
+ float dataFilter_getMin64High(float _) {
357
+ return dataFilter.min64High.x;
358
+ }
359
+ vec2 dataFilter_getMin64High(vec2 _) {
360
+ return dataFilter.min64High.xy;
361
+ }
362
+ vec3 dataFilter_getMin64High(vec3 _) {
363
+ return dataFilter.min64High.xyz;
364
+ }
365
+ vec4 dataFilter_getMin64High(vec4 _) {
366
+ return dataFilter.min64High;
367
+ }
368
+
369
+ float dataFilter_getMax64High(float _) {
370
+ return dataFilter.max64High.x;
371
+ }
372
+ vec2 dataFilter_getMax64High(vec2 _) {
373
+ return dataFilter.max64High.xy;
374
+ }
375
+ vec3 dataFilter_getMax64High(vec3 _) {
376
+ return dataFilter.max64High.xyz;
377
+ }
378
+ vec4 dataFilter_getMax64High(vec4 _) {
379
+ return dataFilter.max64High;
380
+ }
381
+ #endif
382
+
309
383
  float dataFilter_reduceValue(float value) {
310
384
  return value;
311
385
  }
@@ -321,23 +395,27 @@ float dataFilter_reduceValue(vec4 value) {
321
395
 
322
396
  #ifdef DATAFILTER_TYPE
323
397
  void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {
398
+ DATAFILTER_TYPE dataFilter_min = dataFilter_getMin(valueFromMin);
399
+ DATAFILTER_TYPE dataFilter_softMin = dataFilter_getSoftMin(valueFromMin);
400
+ DATAFILTER_TYPE dataFilter_softMax = dataFilter_getSoftMax(valueFromMin);
401
+ DATAFILTER_TYPE dataFilter_max = dataFilter_getMax(valueFromMin);
324
402
  if (dataFilter.useSoftMargin) {
325
403
  // smoothstep results are undefined if edge0 \u2265 edge1
326
404
  // Fallback to ignore filterSoftRange if it is truncated by filterRange
327
405
  DATAFILTER_TYPE leftInRange = mix(
328
- smoothstep(dataFilter.min, dataFilter.softMin, valueFromMin),
329
- step(dataFilter.min, valueFromMin),
330
- step(dataFilter.softMin, dataFilter.min)
406
+ smoothstep(dataFilter_min, dataFilter_softMin, valueFromMin),
407
+ step(dataFilter_min, valueFromMin),
408
+ step(dataFilter_softMin, dataFilter_min)
331
409
  );
332
410
  DATAFILTER_TYPE rightInRange = mix(
333
- 1.0 - smoothstep(dataFilter.softMax, dataFilter.max, valueFromMax),
334
- step(valueFromMax, dataFilter.max),
335
- step(dataFilter.max, dataFilter.softMax)
411
+ 1.0 - smoothstep(dataFilter_softMax, dataFilter_max, valueFromMax),
412
+ step(valueFromMax, dataFilter_max),
413
+ step(dataFilter_max, dataFilter_softMax)
336
414
  );
337
415
  dataFilter_value = dataFilter_reduceValue(leftInRange * rightInRange);
338
416
  } else {
339
417
  dataFilter_value = dataFilter_reduceValue(
340
- step(dataFilter.min, valueFromMin) * step(valueFromMax, dataFilter.max)
418
+ step(dataFilter_min, valueFromMin) * step(valueFromMax, dataFilter_max)
341
419
  );
342
420
  }
343
421
  }
@@ -363,9 +441,9 @@ float dataFilter_reduceValue(vec4 value) {
363
441
  dataFilter_bits &= 1u;
364
442
 
365
443
  #if DATACATEGORY_CHANNELS == 1
366
- if(dataFilter_bits == 0u) dataFilter_value = 0.0;
444
+ if (dataFilter_bits == 0u) dataFilter_value = 0.0;
367
445
  #else
368
- if(any(equal(dataFilter_bits, DATACATEGORY_TYPE(0u)))) dataFilter_value = 0.0;
446
+ if (any(equal(dataFilter_bits, DATACATEGORY_TYPE(0u)))) dataFilter_value = 0.0;
369
447
  #endif
370
448
  }
371
449
  #endif
@@ -397,17 +475,23 @@ ${fragment2}
397
475
  categoryBitMask
398
476
  } = opts;
399
477
  const filterSoftRange = opts.filterSoftRange || filterRange;
478
+ const padRange = (value) => {
479
+ if (Array.isArray(value)) {
480
+ return [value[0] || 0, value[1] || 0, value[2] || 0, value[3] || 0];
481
+ }
482
+ return [value, 0, 0, 0];
483
+ };
400
484
  return {
401
485
  ...Number.isFinite(filterRange[0]) ? {
402
- min: filterRange[0],
403
- softMin: filterSoftRange[0],
404
- softMax: filterSoftRange[1],
405
- max: filterRange[1]
486
+ min: padRange(filterRange[0]),
487
+ softMin: padRange(filterSoftRange[0]),
488
+ softMax: padRange(filterSoftRange[1]),
489
+ max: padRange(filterRange[1])
406
490
  } : {
407
- min: filterRange.map((r) => r[0]),
408
- softMin: filterSoftRange.map((r) => r[0]),
409
- softMax: filterSoftRange.map((r) => r[1]),
410
- max: filterRange.map((r) => r[1])
491
+ min: padRange(filterRange.map((r) => r[0])),
492
+ softMin: padRange(filterSoftRange.map((r) => r[0])),
493
+ softMax: padRange(filterSoftRange.map((r) => r[1])),
494
+ max: padRange(filterRange.map((r) => r[1]))
411
495
  },
412
496
  enabled: filterEnabled,
413
497
  useSoftMargin: Boolean(opts.filterSoftRange),
@@ -421,25 +505,14 @@ ${fragment2}
421
505
  return {};
422
506
  }
423
507
  const uniforms = getUniforms(opts);
424
- if (Number.isFinite(uniforms.min)) {
425
- const min64High = Math.fround(uniforms.min);
426
- uniforms.min -= min64High;
427
- uniforms.softMin -= min64High;
428
- uniforms.min64High = min64High;
429
- const max64High = Math.fround(uniforms.max);
430
- uniforms.max -= max64High;
431
- uniforms.softMax -= max64High;
432
- uniforms.max64High = max64High;
433
- } else {
434
- const min64High = uniforms.min.map(Math.fround);
435
- uniforms.min = uniforms.min.map((x, i) => x - min64High[i]);
436
- uniforms.softMin = uniforms.softMin.map((x, i) => x - min64High[i]);
437
- uniforms.min64High = min64High;
438
- const max64High = uniforms.max.map(Math.fround);
439
- uniforms.max = uniforms.max.map((x, i) => x - max64High[i]);
440
- uniforms.softMax = uniforms.softMax.map((x, i) => x - max64High[i]);
441
- uniforms.max64High = max64High;
442
- }
508
+ const min64High = uniforms.min.map(Math.fround);
509
+ uniforms.min = uniforms.min.map((x, i) => x - min64High[i]);
510
+ uniforms.softMin = uniforms.softMin.map((x, i) => x - min64High[i]);
511
+ uniforms.min64High = min64High;
512
+ const max64High = uniforms.max.map(Math.fround);
513
+ uniforms.max = uniforms.max.map((x, i) => x - max64High[i]);
514
+ uniforms.softMax = uniforms.softMax.map((x, i) => x - max64High[i]);
515
+ uniforms.max64High = max64High;
443
516
  return uniforms;
444
517
  }
445
518
  var inject2 = {
@@ -451,8 +524,8 @@ ${fragment2}
451
524
  #ifdef DATAFILTER_TYPE
452
525
  #ifdef DATAFILTER_DOUBLE
453
526
  dataFilter_setValue(
454
- filterValues - dataFilter.min64High + filterValues64Low,
455
- filterValues - dataFilter.max64High + filterValues64Low
527
+ filterValues - dataFilter_getMin64High(filterValues) + filterValues64Low,
528
+ filterValues - dataFilter_getMax64High(filterValues) + filterValues64Low
456
529
  );
457
530
  #else
458
531
  dataFilter_setValue(filterValues, filterValues);
@@ -492,27 +565,19 @@ ${fragment2}
492
565
  )
493
566
  };
494
567
  function uniformTypesFromOptions(opts) {
495
- const { categorySize, filterSize, fp64: fp642 } = opts;
496
568
  const uniformTypes = {
497
569
  useSoftMargin: "i32",
498
570
  enabled: "i32",
499
571
  transformSize: "i32",
500
- transformColor: "i32"
572
+ transformColor: "i32",
573
+ min: "vec4<f32>",
574
+ softMin: "vec4<f32>",
575
+ softMax: "vec4<f32>",
576
+ max: "vec4<f32>",
577
+ min64High: "vec4<f32>",
578
+ max64High: "vec4<f32>",
579
+ categoryBitMask: "vec4<u32>"
501
580
  };
502
- if (filterSize) {
503
- const uniformFormat = filterSize === 1 ? "f32" : `vec${filterSize}<f32>`;
504
- uniformTypes.min = uniformFormat;
505
- uniformTypes.softMin = uniformFormat;
506
- uniformTypes.softMax = uniformFormat;
507
- uniformTypes.max = uniformFormat;
508
- if (fp642) {
509
- uniformTypes.min64High = uniformFormat;
510
- uniformTypes.max64High = uniformFormat;
511
- }
512
- }
513
- if (categorySize) {
514
- uniformTypes.categoryBitMask = "vec4<i32>";
515
- }
516
581
  return uniformTypes;
517
582
  }
518
583
  var dataFilter = {
@@ -1407,8 +1472,9 @@ void main() {
1407
1472
  var fp64arithmeticShader = (
1408
1473
  /* glsl */
1409
1474
  `
1410
- uniform fp64arithmeticUniforms {
1475
+ layout(std140) uniform fp64arithmeticUniforms {
1411
1476
  uniform float ONE;
1477
+ uniform float SPLIT;
1412
1478
  } fp64;
1413
1479
 
1414
1480
  /*
@@ -1418,6 +1484,12 @@ The purpose of this workaround is to prevent shader compilers from
1418
1484
  optimizing away necessary arithmetic operations by swapping their sequences
1419
1485
  or transform the equation to some 'equivalent' form.
1420
1486
 
1487
+ These helpers implement Dekker/Veltkamp-style error tracking. If the compiler
1488
+ folds constants or reassociates the arithmetic, the high/low split can stop
1489
+ tracking the rounding error correctly. That failure mode tends to look fine in
1490
+ simple coordinate setup, but then breaks down inside iterative arithmetic such
1491
+ as fp64 Mandelbrot loops.
1492
+
1421
1493
  The method is to multiply an artifical variable, ONE, which will be known to
1422
1494
  the compiler to be 1 only at runtime. The whole expression is then represented
1423
1495
  as a polynomial with respective to ONE. In the coefficients of all terms, only one a
@@ -1426,17 +1498,23 @@ and one b should appear
1426
1498
  err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE
1427
1499
  */
1428
1500
 
1429
- // Divide float number to high and low floats to extend fraction bits
1430
- vec2 split(float a) {
1431
- const float SPLIT = 4097.0;
1432
- float t = a * SPLIT;
1501
+ float prevent_fp64_optimization(float value) {
1433
1502
  #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
1434
- float a_hi = t * fp64.ONE - (t - a);
1435
- float a_lo = a * fp64.ONE - a_hi;
1503
+ return value + fp64.ONE * 0.0;
1436
1504
  #else
1437
- float a_hi = t - (t - a);
1438
- float a_lo = a - a_hi;
1505
+ return value;
1439
1506
  #endif
1507
+ }
1508
+
1509
+ // Divide float number to high and low floats to extend fraction bits
1510
+ vec2 split(float a) {
1511
+ // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker
1512
+ // split into a constant expression and reassociate the recovery steps.
1513
+ float split = prevent_fp64_optimization(fp64.SPLIT);
1514
+ float t = prevent_fp64_optimization(a * split);
1515
+ float temp = t - a;
1516
+ float a_hi = t - temp;
1517
+ float a_lo = a - a_hi;
1440
1518
  return vec2(a_hi, a_lo);
1441
1519
  }
1442
1520
 
@@ -1500,8 +1578,26 @@ vec2 twoProd(float a, float b) {
1500
1578
  float prod = a * b;
1501
1579
  vec2 a_fp64 = split(a);
1502
1580
  vec2 b_fp64 = split(b);
1503
- float err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +
1504
- a_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;
1581
+ // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend
1582
+ // on the split terms and cross terms staying in the original evaluation
1583
+ // order. If the compiler folds or reassociates them, the low part tends to
1584
+ // collapse to zero or NaN on some drivers.
1585
+ float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);
1586
+ float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);
1587
+ float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);
1588
+ float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);
1589
+ #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
1590
+ float err1 = (highProduct - prod) * fp64.ONE;
1591
+ float err2 = crossProduct1 * fp64.ONE * fp64.ONE;
1592
+ float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;
1593
+ float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;
1594
+ #else
1595
+ float err1 = highProduct - prod;
1596
+ float err2 = crossProduct1;
1597
+ float err3 = crossProduct2;
1598
+ float err4 = lowProduct;
1599
+ #endif
1600
+ float err = ((err1 + err2) + err3) + err4;
1505
1601
  return vec2(prod, err);
1506
1602
  }
1507
1603
 
@@ -1577,6 +1673,218 @@ vec2 sqrt_fp64(vec2 a) {
1577
1673
  `
1578
1674
  );
1579
1675
 
1676
+ // ../../node_modules/@luma.gl/shadertools/dist/modules/math/fp64/fp64-arithmetic-wgsl.js
1677
+ var fp64arithmeticWGSL = (
1678
+ /* wgsl */
1679
+ `struct Fp64ArithmeticUniforms {
1680
+ ONE: f32,
1681
+ SPLIT: f32,
1682
+ };
1683
+
1684
+ @group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms;
1685
+
1686
+ fn fp64_nan(seed: f32) -> f32 {
1687
+ let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0);
1688
+ return bitcast<f32>(nanBits);
1689
+ }
1690
+
1691
+ fn fp64_runtime_zero() -> f32 {
1692
+ return fp64arithmetic.ONE * 0.0;
1693
+ }
1694
+
1695
+ fn prevent_fp64_optimization(value: f32) -> f32 {
1696
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
1697
+ return value + fp64_runtime_zero();
1698
+ #else
1699
+ return value;
1700
+ #endif
1701
+ }
1702
+
1703
+ fn split(a: f32) -> vec2f {
1704
+ let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero());
1705
+ let t = prevent_fp64_optimization(a * splitValue);
1706
+ let temp = prevent_fp64_optimization(t - a);
1707
+ let aHi = prevent_fp64_optimization(t - temp);
1708
+ let aLo = prevent_fp64_optimization(a - aHi);
1709
+ return vec2f(aHi, aLo);
1710
+ }
1711
+
1712
+ fn split2(a: vec2f) -> vec2f {
1713
+ var b = split(a.x);
1714
+ b.y = b.y + a.y;
1715
+ return b;
1716
+ }
1717
+
1718
+ fn quickTwoSum(a: f32, b: f32) -> vec2f {
1719
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
1720
+ let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE);
1721
+ let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE);
1722
+ #else
1723
+ let sum = prevent_fp64_optimization(a + b);
1724
+ let err = prevent_fp64_optimization(b - (sum - a));
1725
+ #endif
1726
+ return vec2f(sum, err);
1727
+ }
1728
+
1729
+ fn twoSum(a: f32, b: f32) -> vec2f {
1730
+ let s = prevent_fp64_optimization(a + b);
1731
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
1732
+ let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);
1733
+ let err =
1734
+ prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *
1735
+ fp64arithmetic.ONE *
1736
+ fp64arithmetic.ONE *
1737
+ fp64arithmetic.ONE) +
1738
+ prevent_fp64_optimization(b - v);
1739
+ #else
1740
+ let v = prevent_fp64_optimization(s - a);
1741
+ let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v);
1742
+ #endif
1743
+ return vec2f(s, err);
1744
+ }
1745
+
1746
+ fn twoSub(a: f32, b: f32) -> vec2f {
1747
+ let s = prevent_fp64_optimization(a - b);
1748
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
1749
+ let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);
1750
+ let err =
1751
+ prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *
1752
+ fp64arithmetic.ONE *
1753
+ fp64arithmetic.ONE *
1754
+ fp64arithmetic.ONE) -
1755
+ prevent_fp64_optimization(b + v);
1756
+ #else
1757
+ let v = prevent_fp64_optimization(s - a);
1758
+ let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v);
1759
+ #endif
1760
+ return vec2f(s, err);
1761
+ }
1762
+
1763
+ fn twoSqr(a: f32) -> vec2f {
1764
+ let prod = prevent_fp64_optimization(a * a);
1765
+ let aFp64 = split(a);
1766
+ let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x);
1767
+ let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y);
1768
+ let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y);
1769
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
1770
+ let err =
1771
+ (prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE +
1772
+ crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) +
1773
+ lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;
1774
+ #else
1775
+ let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct);
1776
+ #endif
1777
+ return vec2f(prod, err);
1778
+ }
1779
+
1780
+ fn twoProd(a: f32, b: f32) -> vec2f {
1781
+ let prod = prevent_fp64_optimization(a * b);
1782
+ let aFp64 = split(a);
1783
+ let bFp64 = split(b);
1784
+ let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x);
1785
+ let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y);
1786
+ let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x);
1787
+ let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y);
1788
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
1789
+ let err1 = (highProduct - prod) * fp64arithmetic.ONE;
1790
+ let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE;
1791
+ let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;
1792
+ let err4 =
1793
+ lowProduct *
1794
+ fp64arithmetic.ONE *
1795
+ fp64arithmetic.ONE *
1796
+ fp64arithmetic.ONE *
1797
+ fp64arithmetic.ONE;
1798
+ #else
1799
+ let err1 = highProduct - prod;
1800
+ let err2 = crossProduct1;
1801
+ let err3 = crossProduct2;
1802
+ let err4 = lowProduct;
1803
+ #endif
1804
+ let err12InputA = prevent_fp64_optimization(err1);
1805
+ let err12InputB = prevent_fp64_optimization(err2);
1806
+ let err12 = prevent_fp64_optimization(err12InputA + err12InputB);
1807
+ let err123InputA = prevent_fp64_optimization(err12);
1808
+ let err123InputB = prevent_fp64_optimization(err3);
1809
+ let err123 = prevent_fp64_optimization(err123InputA + err123InputB);
1810
+ let err1234InputA = prevent_fp64_optimization(err123);
1811
+ let err1234InputB = prevent_fp64_optimization(err4);
1812
+ let err = prevent_fp64_optimization(err1234InputA + err1234InputB);
1813
+ return vec2f(prod, err);
1814
+ }
1815
+
1816
+ fn sum_fp64(a: vec2f, b: vec2f) -> vec2f {
1817
+ var s = twoSum(a.x, b.x);
1818
+ let t = twoSum(a.y, b.y);
1819
+ s.y = prevent_fp64_optimization(s.y + t.x);
1820
+ s = quickTwoSum(s.x, s.y);
1821
+ s.y = prevent_fp64_optimization(s.y + t.y);
1822
+ s = quickTwoSum(s.x, s.y);
1823
+ return s;
1824
+ }
1825
+
1826
+ fn sub_fp64(a: vec2f, b: vec2f) -> vec2f {
1827
+ var s = twoSub(a.x, b.x);
1828
+ let t = twoSub(a.y, b.y);
1829
+ s.y = prevent_fp64_optimization(s.y + t.x);
1830
+ s = quickTwoSum(s.x, s.y);
1831
+ s.y = prevent_fp64_optimization(s.y + t.y);
1832
+ s = quickTwoSum(s.x, s.y);
1833
+ return s;
1834
+ }
1835
+
1836
+ fn mul_fp64(a: vec2f, b: vec2f) -> vec2f {
1837
+ var prod = twoProd(a.x, b.x);
1838
+ let crossProduct1 = prevent_fp64_optimization(a.x * b.y);
1839
+ prod.y = prevent_fp64_optimization(prod.y + crossProduct1);
1840
+ #ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
1841
+ prod = split2(prod);
1842
+ #endif
1843
+ prod = quickTwoSum(prod.x, prod.y);
1844
+ let crossProduct2 = prevent_fp64_optimization(a.y * b.x);
1845
+ prod.y = prevent_fp64_optimization(prod.y + crossProduct2);
1846
+ #ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
1847
+ prod = split2(prod);
1848
+ #endif
1849
+ prod = quickTwoSum(prod.x, prod.y);
1850
+ return prod;
1851
+ }
1852
+
1853
+ fn div_fp64(a: vec2f, b: vec2f) -> vec2f {
1854
+ let xn = prevent_fp64_optimization(1.0 / b.x);
1855
+ let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero()));
1856
+ let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x);
1857
+ let prod = twoProd(xn, diff);
1858
+ return sum_fp64(yn, prod);
1859
+ }
1860
+
1861
+ fn sqrt_fp64(a: vec2f) -> vec2f {
1862
+ if (a.x == 0.0 && a.y == 0.0) {
1863
+ return vec2f(0.0, 0.0);
1864
+ }
1865
+ if (a.x < 0.0) {
1866
+ let nanValue = fp64_nan(a.x);
1867
+ return vec2f(nanValue, nanValue);
1868
+ }
1869
+
1870
+ let x = prevent_fp64_optimization(1.0 / sqrt(a.x));
1871
+ let yn = prevent_fp64_optimization(a.x * x);
1872
+ #ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
1873
+ let ynSqr = twoSqr(yn) * fp64arithmetic.ONE;
1874
+ #else
1875
+ let ynSqr = twoSqr(yn);
1876
+ #endif
1877
+ let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x);
1878
+ let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff);
1879
+ #ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
1880
+ return sum_fp64(split(yn), prod);
1881
+ #else
1882
+ return sum_fp64(vec2f(yn, 0.0), prod);
1883
+ #endif
1884
+ }
1885
+ `
1886
+ );
1887
+
1580
1888
  // ../../node_modules/@luma.gl/shadertools/dist/modules/math/fp64/fp64-functions-glsl.js
1581
1889
  var fp64functionShader = (
1582
1890
  /* glsl */
@@ -2255,13 +2563,18 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
2255
2563
  // ../../node_modules/@luma.gl/shadertools/dist/modules/math/fp64/fp64.js
2256
2564
  var defaultUniforms = {
2257
2565
  // Used in LUMA_FP64_CODE_ELIMINATION_WORKAROUND
2258
- ONE: 1
2566
+ ONE: 1,
2567
+ // Runtime split factor for Dekker splitting. Keeping this as a uniform helps
2568
+ // prevent aggressive constant folding in shader compilers.
2569
+ SPLIT: 4097
2259
2570
  };
2260
2571
  var fp64arithmetic = {
2261
2572
  name: "fp64arithmetic",
2573
+ source: fp64arithmeticWGSL,
2574
+ fs: fp64arithmeticShader,
2262
2575
  vs: fp64arithmeticShader,
2263
2576
  defaultUniforms,
2264
- uniformTypes: { ONE: "f32" },
2577
+ uniformTypes: { ONE: "f32", SPLIT: "f32" },
2265
2578
  // Additional Functions
2266
2579
  fp64ify,
2267
2580
  fp64LowPart,
@@ -2284,7 +2597,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
2284
2597
  var project64_glsl_default = `
2285
2598
  const vec2 WORLD_SCALE_FP64 = vec2(81.4873275756836, 0.0000032873668232014097);
2286
2599
 
2287
- uniform project64Uniforms {
2600
+ layout(std140) uniform project64Uniforms {
2288
2601
  vec2 scale;
2289
2602
  mat4 viewProjectionMatrix;
2290
2603
  mat4 viewProjectionMatrix64Low;
@@ -2460,7 +2773,7 @@ vDashOffset = 0.0;
2460
2773
  #endif
2461
2774
  `,
2462
2775
  "fs:#decl": `
2463
- uniform pathStyleUniforms {
2776
+ layout(std140) uniform pathStyleUniforms {
2464
2777
  float dashAlignMode;
2465
2778
  bool dashGapPickable;
2466
2779
  } pathStyle;
@@ -2652,7 +2965,7 @@ in float instanceOffsets;
2652
2965
  var import_core9 = __toESM(require_core(), 1);
2653
2966
  var uniformBlock3 = (
2654
2967
  /* glsl */
2655
- `uniform fillUniforms {
2968
+ `layout(std140) uniform fillUniforms {
2656
2969
  vec2 patternTextureSize;
2657
2970
  bool patternEnabled;
2658
2971
  bool patternMask;
@@ -2877,7 +3190,7 @@ ${patternFs}
2877
3190
  var shaderFunction = (
2878
3191
  /* glsl */
2879
3192
  `
2880
- uniform clipUniforms {
3193
+ layout(std140) uniform clipUniforms {
2881
3194
  vec4 bounds;
2882
3195
  } clip;
2883
3196
 
@@ -3001,7 +3314,7 @@ in float collisionPriorities;
3001
3314
 
3002
3315
  uniform sampler2D collision_texture;
3003
3316
 
3004
- uniform collisionUniforms {
3317
+ layout(std140) uniform collisionUniforms {
3005
3318
  bool sort;
3006
3319
  bool enabled;
3007
3320
  } collision;
@@ -3383,7 +3696,7 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
3383
3696
  var import_core17 = __toESM(require_core(), 1);
3384
3697
  var uniformBlock4 = (
3385
3698
  /* glsl */
3386
- `uniform maskUniforms {
3699
+ `layout(std140) uniform maskUniforms {
3387
3700
  vec4 bounds;
3388
3701
  highp int channel;
3389
3702
  bool enabled;
@@ -3951,7 +4264,7 @@ in vec2 mask_texCoords;
3951
4264
  // eslint-disable-next-line prefer-template
3952
4265
  TERRAIN_MODE_CONSTANTS + /* glsl */
3953
4266
  `
3954
- uniform terrainUniforms {
4267
+ layout(std140) uniform terrainUniforms {
3955
4268
  float mode;
3956
4269
  vec4 bounds;
3957
4270
  } terrain;
@@ -4086,7 +4399,7 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
4086
4399
  }
4087
4400
  };
4088
4401
 
4089
- // ../../node_modules/@luma.gl/constants/dist/webgl-constants.js
4402
+ // ../../node_modules/@luma.gl/webgl/dist/constants/webgl-constants.js
4090
4403
  var GLEnum;
4091
4404
  (function(GLEnum2) {
4092
4405
  GLEnum2[GLEnum2["DEPTH_BUFFER_BIT"] = 256] = "DEPTH_BUFFER_BIT";
@@ -19,8 +19,8 @@ type FillStyleModuleBindings = {
19
19
  declare function getPatternUniforms(opts?: FillStyleModuleProps | {}): FillStyleModuleBindings & FillStyleModuleUniforms;
20
20
  export declare const patternShaders: {
21
21
  readonly name: "fill";
22
- readonly vs: "\nuniform fillUniforms {\n vec2 patternTextureSize;\n bool patternEnabled;\n bool patternMask;\n vec2 uvCoordinateOrigin;\n vec2 uvCoordinateOrigin64Low;\n} fill;\n\n\nin vec4 fillPatternFrames;\nin float fillPatternScales;\nin vec2 fillPatternOffsets;\n\nout vec2 fill_uv;\nout vec4 fill_patternBounds;\nout vec4 fill_patternPlacement;\n\n";
23
- readonly fs: "\nuniform fillUniforms {\n vec2 patternTextureSize;\n bool patternEnabled;\n bool patternMask;\n vec2 uvCoordinateOrigin;\n vec2 uvCoordinateOrigin64Low;\n} fill;\n\n\nuniform sampler2D fill_patternTexture;\n\nin vec4 fill_patternBounds;\nin vec4 fill_patternPlacement;\nin vec2 fill_uv;\n\nconst float FILL_UV_SCALE = 512.0 / 40000000.0;\n\n";
22
+ readonly vs: "\nlayout(std140) uniform fillUniforms {\n vec2 patternTextureSize;\n bool patternEnabled;\n bool patternMask;\n vec2 uvCoordinateOrigin;\n vec2 uvCoordinateOrigin64Low;\n} fill;\n\n\nin vec4 fillPatternFrames;\nin float fillPatternScales;\nin vec2 fillPatternOffsets;\n\nout vec2 fill_uv;\nout vec4 fill_patternBounds;\nout vec4 fill_patternPlacement;\n\n";
23
+ readonly fs: "\nlayout(std140) uniform fillUniforms {\n vec2 patternTextureSize;\n bool patternEnabled;\n bool patternMask;\n vec2 uvCoordinateOrigin;\n vec2 uvCoordinateOrigin64Low;\n} fill;\n\n\nuniform sampler2D fill_patternTexture;\n\nin vec4 fill_patternBounds;\nin vec4 fill_patternPlacement;\nin vec2 fill_uv;\n\nconst float FILL_UV_SCALE = 512.0 / 40000000.0;\n\n";
24
24
  readonly inject: {
25
25
  'vs:DECKGL_FILTER_GL_POSITION': string;
26
26
  'vs:DECKGL_FILTER_COLOR': string;
@@ -3,7 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
  import { project, fp64LowPart } from '@deck.gl/core';
5
5
  const uniformBlock = /* glsl */ `\
6
- uniform fillUniforms {
6
+ layout(std140) uniform fillUniforms {
7
7
  vec2 patternTextureSize;
8
8
  bool patternEnabled;
9
9
  bool patternMask;