@genome-spy/core 0.18.0 → 0.19.1
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/index.js +44 -117
- package/dist/schema.json +0 -4
- package/package.json +3 -2
- package/src/data/collector.js +9 -4
- package/src/data/collector.test.js +2 -0
- package/src/data/dataFlow.test.js +2 -0
- package/src/data/flow.test.js +1 -0
- package/src/data/flowNode.test.js +1 -0
- package/src/data/flowOptimizer.js +6 -0
- package/src/data/flowOptimizer.test.js +1 -0
- package/src/data/formats/fasta.test.js +1 -0
- package/src/data/sources/inlineSource.test.js +1 -0
- package/src/data/sources/sequenceSource.test.js +1 -0
- package/src/data/transforms/clone.test.js +1 -0
- package/src/data/transforms/coverage.test.js +1 -0
- package/src/data/transforms/filter.test.js +1 -0
- package/src/data/transforms/flattenDelimited.test.js +1 -0
- package/src/data/transforms/flattenSequence.test.js +1 -0
- package/src/data/transforms/formula.test.js +1 -0
- package/src/data/transforms/identifier.test.js +1 -0
- package/src/data/transforms/pileup.test.js +1 -0
- package/src/data/transforms/project.test.js +1 -0
- package/src/data/transforms/regexExtract.test.js +1 -0
- package/src/data/transforms/regexFold.test.js +1 -0
- package/src/data/transforms/sample.test.js +1 -0
- package/src/data/transforms/stack.test.js +1 -0
- package/src/encoder/accessor.test.js +1 -0
- package/src/encoder/encoder.test.js +1 -0
- package/src/genome/genome.js +14 -2
- package/src/genome/genome.test.js +36 -0
- package/src/genome/scaleIndex.js +3 -2
- package/src/genome/scaleIndex.test.js +23 -6
- package/src/genome/scaleLocus.test.js +1 -0
- package/src/gl/dataToVertices.js +9 -6
- package/src/gl/includes/common.glsl +3 -3
- package/src/gl/includes/scales.glsl +33 -2
- package/src/gl/point.vertex.glsl +0 -2
- package/src/gl/rule.vertex.glsl +1 -1
- package/src/gl/webGLHelper.js +0 -3
- package/src/marks/mark.js +10 -13
- package/src/scale/glslScaleGenerator.js +56 -17
- package/src/scale/scale.test.js +1 -0
- package/src/scale/ticks.test.js +1 -0
- package/src/spec/scale.d.ts +0 -9
- package/src/utils/addBaseUrl.test.js +1 -0
- package/src/utils/cloner.test.js +1 -0
- package/src/utils/coalesce.test.js +1 -0
- package/src/utils/concatIterables.test.js +1 -0
- package/src/utils/domainArray.test.js +1 -0
- package/src/utils/indexer.test.js +1 -0
- package/src/utils/iterateNestedMaps.test.js +1 -0
- package/src/utils/kWayMerge.test.js +1 -0
- package/src/utils/layout/flexLayout.test.js +1 -0
- package/src/utils/layout/rectangle.test.js +1 -0
- package/src/utils/mergeObjects.test.js +1 -0
- package/src/utils/numberExtractor.test.js +1 -0
- package/src/utils/propertyCacher.test.js +1 -0
- package/src/utils/propertyCoalescer.test.js +1 -0
- package/src/utils/reservationMap.test.js +1 -0
- package/src/utils/topK.test.js +1 -0
- package/src/utils/variableTools.test.js +1 -0
- package/src/view/axisResolution.test.js +1 -0
- package/src/view/flowBuilder.test.js +1 -0
- package/src/view/scaleResolution.js +5 -11
- package/src/view/scaleResolution.test.js +1 -0
- package/src/view/unitView.js +8 -4
- package/src/view/view.test.js +1 -0
- package/src/view/viewFactory.test.js +1 -0
- package/src/gl/includes/fp64-arithmetic.glsl +0 -187
- package/src/gl/includes/fp64-utils.js +0 -142
- package/src/gl/includes/scales_fp64.glsl +0 -30
|
@@ -109,8 +109,8 @@ export function generateScaleGlsl(channel, scale, channelDef) {
|
|
|
109
109
|
const domainUniformName = DOMAIN_PREFIX + primary;
|
|
110
110
|
const rangeName = RANGE_PREFIX + primary;
|
|
111
111
|
|
|
112
|
-
const
|
|
113
|
-
const attributeType =
|
|
112
|
+
const hp = isHighPrecisionScale(scale.type);
|
|
113
|
+
const attributeType = hp ? "vec2" : "float";
|
|
114
114
|
|
|
115
115
|
const domainLength = scale.domain ? scale.domain().length : undefined;
|
|
116
116
|
|
|
@@ -127,9 +127,6 @@ export function generateScaleGlsl(channel, scale, channelDef) {
|
|
|
127
127
|
glsl.push("");
|
|
128
128
|
|
|
129
129
|
glsl.push(`#define ${channel}_DEFINED`);
|
|
130
|
-
if (fp64) {
|
|
131
|
-
glsl.push(`#define ${channel}_FP64`);
|
|
132
|
-
}
|
|
133
130
|
|
|
134
131
|
const { transform } = splitScaleType(scale.type);
|
|
135
132
|
|
|
@@ -139,11 +136,7 @@ export function generateScaleGlsl(channel, scale, channelDef) {
|
|
|
139
136
|
*/
|
|
140
137
|
const makeScaleCall = (name, ...args) =>
|
|
141
138
|
// eslint-disable-next-line no-useless-call
|
|
142
|
-
makeFunctionCall.apply(null, [
|
|
143
|
-
name + (fp64 ? "Fp64" : ""),
|
|
144
|
-
"value",
|
|
145
|
-
...args,
|
|
146
|
-
]);
|
|
139
|
+
makeFunctionCall.apply(null, [name, "value", ...args]);
|
|
147
140
|
|
|
148
141
|
let functionCall;
|
|
149
142
|
switch (transform) {
|
|
@@ -181,6 +174,17 @@ export function generateScaleGlsl(channel, scale, channelDef) {
|
|
|
181
174
|
|
|
182
175
|
case "index":
|
|
183
176
|
case "locus":
|
|
177
|
+
functionCall = makeScaleCall(
|
|
178
|
+
"scaleBandHp",
|
|
179
|
+
"domain",
|
|
180
|
+
rangeName,
|
|
181
|
+
scale.paddingInner(),
|
|
182
|
+
scale.paddingOuter(),
|
|
183
|
+
scale.align(),
|
|
184
|
+
// @ts-expect-error TODO: fix typing
|
|
185
|
+
channelDef.band ?? 0.5
|
|
186
|
+
);
|
|
187
|
+
break;
|
|
184
188
|
case "point":
|
|
185
189
|
case "band":
|
|
186
190
|
functionCall = makeScaleCall(
|
|
@@ -296,10 +300,13 @@ export function generateScaleGlsl(channel, scale, channelDef) {
|
|
|
296
300
|
if (functionCall) {
|
|
297
301
|
const name = domainUniformName;
|
|
298
302
|
if (usesDomain) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
+
if (hp) {
|
|
304
|
+
scaleBody.push(`vec3 domain = ${name};`);
|
|
305
|
+
} else {
|
|
306
|
+
scaleBody.push(
|
|
307
|
+
`vec2 domain = vec2(${name}[slot], ${name}[slot + 1]);`
|
|
308
|
+
);
|
|
309
|
+
}
|
|
303
310
|
}
|
|
304
311
|
|
|
305
312
|
scaleBody.push(`float transformed = ${functionCall};`);
|
|
@@ -344,9 +351,9 @@ ${returnType} ${SCALED_FUNCTION_PREFIX}${channel}() {
|
|
|
344
351
|
isContinuous(scale.type) || isDiscretizing(scale.type)
|
|
345
352
|
? domainLength
|
|
346
353
|
: 2;
|
|
347
|
-
domainUniform =
|
|
348
|
-
|
|
349
|
-
|
|
354
|
+
domainUniform = hp
|
|
355
|
+
? `highp vec3 ${domainUniformName};`
|
|
356
|
+
: `mediump float ${domainUniformName}[${length}];`;
|
|
350
357
|
}
|
|
351
358
|
|
|
352
359
|
return {
|
|
@@ -447,3 +454,35 @@ function makeFunctionCall(name, ...args) {
|
|
|
447
454
|
|
|
448
455
|
return `${name}(${fixedArgs.join(", ")})`;
|
|
449
456
|
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
*
|
|
460
|
+
* @param {string} type
|
|
461
|
+
*/
|
|
462
|
+
export function isHighPrecisionScale(type) {
|
|
463
|
+
return type == "index" || type == "locus";
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* @param {number} x
|
|
468
|
+
* @param {number[]} [arr]
|
|
469
|
+
*/
|
|
470
|
+
export function splitHighPrecision(x, arr) {
|
|
471
|
+
// Maximum precise index number is 2^(23 + 11) ~ 17G
|
|
472
|
+
// Higher number increases precision but makes zooming unstable
|
|
473
|
+
const bs = 2 ** 11;
|
|
474
|
+
|
|
475
|
+
const lo = x % bs;
|
|
476
|
+
const hi = Math.round(x - lo);
|
|
477
|
+
arr ??= [];
|
|
478
|
+
arr[0] = hi;
|
|
479
|
+
arr[1] = lo;
|
|
480
|
+
return arr;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* @param {number[]} domain
|
|
485
|
+
*/
|
|
486
|
+
export function toHighPrecisionDomainUniform(domain) {
|
|
487
|
+
return [...splitHighPrecision(domain[0]), domain[1] - domain[0]];
|
|
488
|
+
}
|
package/src/scale/scale.test.js
CHANGED
package/src/scale/ticks.test.js
CHANGED
package/src/spec/scale.d.ts
CHANGED
|
@@ -221,15 +221,6 @@ export interface Scale {
|
|
|
221
221
|
* If `true` and the scale is used on a positional channel, it can bee zoomed and translated interactively.
|
|
222
222
|
*/
|
|
223
223
|
zoom?: boolean | ZoomParams;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Use emulated 64bit floating points on the GPU to increase precision.
|
|
227
|
-
*
|
|
228
|
-
* Emulation has a performance cost when compared to the native 32bit processing, but the effect is negligible in the most cases.
|
|
229
|
-
*
|
|
230
|
-
* __Default value:__ `true` for `"locus"` scale, `false` for others.
|
|
231
|
-
*/
|
|
232
|
-
fp64?: boolean;
|
|
233
224
|
}
|
|
234
225
|
|
|
235
226
|
export interface SchemeParams {
|
package/src/utils/cloner.test.js
CHANGED
package/src/utils/topK.test.js
CHANGED
|
@@ -228,11 +228,6 @@ export default class ScaleResolution {
|
|
|
228
228
|
props.domain = [props.domainMin ?? 0, props.domainMax ?? 1];
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
// Genomic coordinates need higher precision
|
|
232
|
-
if (props.type == LOCUS && !("fp64" in props)) {
|
|
233
|
-
props.fp64 = true;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
231
|
// Reverse discrete y axis
|
|
237
232
|
if (
|
|
238
233
|
this.channel == "y" &&
|
|
@@ -331,11 +326,6 @@ export default class ScaleResolution {
|
|
|
331
326
|
scale.genome(this.getGenome());
|
|
332
327
|
}
|
|
333
328
|
|
|
334
|
-
// Tag the scale and inform encoders and shaders that emulated
|
|
335
|
-
// 64bit floats should be used.
|
|
336
|
-
// N.B. the tag is lost upon scale.clone().
|
|
337
|
-
scale.fp64 = !!props.fp64;
|
|
338
|
-
|
|
339
329
|
if (isContinuous(scale.type)) {
|
|
340
330
|
this._zoomExtent = this._getZoomExtent();
|
|
341
331
|
}
|
|
@@ -405,12 +395,16 @@ export default class ScaleResolution {
|
|
|
405
395
|
let newDomain = [...oldDomain];
|
|
406
396
|
|
|
407
397
|
// @ts-expect-error
|
|
408
|
-
|
|
398
|
+
let anchor = scale.invert(scaleAnchor);
|
|
409
399
|
|
|
410
400
|
if (this.getScaleProps().reverse) {
|
|
411
401
|
pan = -pan;
|
|
412
402
|
}
|
|
413
403
|
|
|
404
|
+
if ("align" in scale) {
|
|
405
|
+
anchor += scale.align();
|
|
406
|
+
}
|
|
407
|
+
|
|
414
408
|
// TODO: symlog
|
|
415
409
|
switch (scale.type) {
|
|
416
410
|
case "linear":
|
package/src/view/unitView.js
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import createDomain from "../utils/domainArray";
|
|
18
18
|
import AxisResolution from "./axisResolution";
|
|
19
19
|
import { isAggregateSamplesSpec } from "./viewFactory";
|
|
20
|
+
import { peek } from "../utils/arrayUtils";
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
*
|
|
@@ -337,10 +338,13 @@ export default class UnitView extends ContainerView {
|
|
|
337
338
|
if (isAggregateSamplesSpec(this.spec)) {
|
|
338
339
|
// TODO: Support multiple
|
|
339
340
|
for (const sumSpec of this.spec.aggregateSamples) {
|
|
340
|
-
sumSpec.transform
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
const transform = sumSpec.transform ?? [];
|
|
342
|
+
if (transform.length && peek(transform).type != "collect") {
|
|
343
|
+
// MergeFacets must be a direct child of Collector
|
|
344
|
+
transform.push({ type: "collect" });
|
|
345
|
+
}
|
|
346
|
+
transform.push({ type: "mergeFacets" });
|
|
347
|
+
sumSpec.transform = transform;
|
|
344
348
|
|
|
345
349
|
sumSpec.encoding = {
|
|
346
350
|
...(sumSpec.encoding ?? {}),
|
package/src/view/view.test.js
CHANGED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
// Adapted from luma.gl - https://github.com/uber/luma.gl
|
|
2
|
-
|
|
3
|
-
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
4
|
-
//
|
|
5
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
// in the Software without restriction, including without limitation the rights
|
|
8
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
// furnished to do so, subject to the following conditions:
|
|
11
|
-
//
|
|
12
|
-
// The above copyright notice and this permission notice shall be included in
|
|
13
|
-
// all copies or substantial portions of the Software.
|
|
14
|
-
//
|
|
15
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
// THE SOFTWARE.
|
|
22
|
-
|
|
23
|
-
uniform float ONE;
|
|
24
|
-
|
|
25
|
-
/*
|
|
26
|
-
About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
27
|
-
|
|
28
|
-
The purpose of this workaround is to prevent shader compilers from
|
|
29
|
-
optimizing away necessary arithmetic operations by swapping their sequences
|
|
30
|
-
or transform the equation to some 'equivalent' from.
|
|
31
|
-
|
|
32
|
-
The method is to multiply an artifical variable, ONE, which will be known to
|
|
33
|
-
the compiler to be 1 only at runtime. The whole expression is then represented
|
|
34
|
-
as a polynomial with respective to ONE. In the coefficients of all terms, only one a
|
|
35
|
-
and one b should appear
|
|
36
|
-
|
|
37
|
-
err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
// Divide float number to high and low floats to extend fraction bits
|
|
41
|
-
vec2 split(float a) {
|
|
42
|
-
const float SPLIT = 4097.0;
|
|
43
|
-
float t = a * SPLIT;
|
|
44
|
-
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
45
|
-
float a_hi = t * ONE - (t - a);
|
|
46
|
-
float a_lo = a * ONE - a_hi;
|
|
47
|
-
#else
|
|
48
|
-
float a_hi = t - (t - a);
|
|
49
|
-
float a_lo = a - a_hi;
|
|
50
|
-
#endif
|
|
51
|
-
return vec2(a_hi, a_lo);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Divide float number again when high float uses too many fraction bits
|
|
55
|
-
vec2 split2(vec2 a) {
|
|
56
|
-
vec2 b = split(a.x);
|
|
57
|
-
b.y += a.y;
|
|
58
|
-
return b;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Special sum operation when a > b
|
|
62
|
-
vec2 quickTwoSum(float a, float b) {
|
|
63
|
-
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
64
|
-
float sum = (a + b) * ONE;
|
|
65
|
-
float err = b - (sum - a) * ONE;
|
|
66
|
-
#else
|
|
67
|
-
float sum = a + b;
|
|
68
|
-
float err = b - (sum - a);
|
|
69
|
-
#endif
|
|
70
|
-
return vec2(sum, err);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// General sum operation
|
|
74
|
-
vec2 twoSum(float a, float b) {
|
|
75
|
-
float s = (a + b);
|
|
76
|
-
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
77
|
-
float v = (s * ONE - a) * ONE;
|
|
78
|
-
float err = (a - (s - v) * ONE) * ONE * ONE * ONE + (b - v);
|
|
79
|
-
#else
|
|
80
|
-
float v = s - a;
|
|
81
|
-
float err = (a - (s - v)) + (b - v);
|
|
82
|
-
#endif
|
|
83
|
-
return vec2(s, err);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
vec2 twoSub(float a, float b) {
|
|
87
|
-
float s = (a - b);
|
|
88
|
-
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
89
|
-
float v = (s * ONE - a) * ONE;
|
|
90
|
-
float err = (a - (s - v) * ONE) * ONE * ONE * ONE - (b + v);
|
|
91
|
-
#else
|
|
92
|
-
float v = s - a;
|
|
93
|
-
float err = (a - (s - v)) - (b + v);
|
|
94
|
-
#endif
|
|
95
|
-
return vec2(s, err);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
vec2 twoSqr(float a) {
|
|
99
|
-
float prod = a * a;
|
|
100
|
-
vec2 a_fp64 = split(a);
|
|
101
|
-
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
102
|
-
float err = ((a_fp64.x * a_fp64.x - prod) * ONE + 2.0 * a_fp64.x *
|
|
103
|
-
a_fp64.y * ONE * ONE) + a_fp64.y * a_fp64.y * ONE * ONE * ONE;
|
|
104
|
-
#else
|
|
105
|
-
float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;
|
|
106
|
-
#endif
|
|
107
|
-
return vec2(prod, err);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
vec2 twoProd(float a, float b) {
|
|
111
|
-
float prod = a * b;
|
|
112
|
-
vec2 a_fp64 = split(a);
|
|
113
|
-
vec2 b_fp64 = split(b);
|
|
114
|
-
float err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +
|
|
115
|
-
a_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;
|
|
116
|
-
return vec2(prod, err);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
vec2 sum_fp64(vec2 a, vec2 b) {
|
|
120
|
-
vec2 s, t;
|
|
121
|
-
s = twoSum(a.x, b.x);
|
|
122
|
-
t = twoSum(a.y, b.y);
|
|
123
|
-
s.y += t.x;
|
|
124
|
-
s = quickTwoSum(s.x, s.y);
|
|
125
|
-
s.y += t.y;
|
|
126
|
-
s = quickTwoSum(s.x, s.y);
|
|
127
|
-
return s;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
vec2 sub_fp64(vec2 a, vec2 b) {
|
|
131
|
-
vec2 s, t;
|
|
132
|
-
s = twoSub(a.x, b.x);
|
|
133
|
-
t = twoSub(a.y, b.y);
|
|
134
|
-
s.y += t.x;
|
|
135
|
-
s = quickTwoSum(s.x, s.y);
|
|
136
|
-
s.y += t.y;
|
|
137
|
-
s = quickTwoSum(s.x, s.y);
|
|
138
|
-
return s;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
vec2 mul_fp64(vec2 a, vec2 b) {
|
|
142
|
-
vec2 prod = twoProd(a.x, b.x);
|
|
143
|
-
// y component is for the error
|
|
144
|
-
prod.y += a.x * b.y;
|
|
145
|
-
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
|
146
|
-
prod = split2(prod);
|
|
147
|
-
#endif
|
|
148
|
-
prod = quickTwoSum(prod.x, prod.y);
|
|
149
|
-
prod.y += a.y * b.x;
|
|
150
|
-
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
|
151
|
-
prod = split2(prod);
|
|
152
|
-
#endif
|
|
153
|
-
prod = quickTwoSum(prod.x, prod.y);
|
|
154
|
-
return prod;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
vec2 div_fp64(vec2 a, vec2 b) {
|
|
158
|
-
float xn = 1.0 / b.x;
|
|
159
|
-
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
|
160
|
-
vec2 yn = mul_fp64(a, vec2(xn, 0));
|
|
161
|
-
#else
|
|
162
|
-
vec2 yn = a * xn;
|
|
163
|
-
#endif
|
|
164
|
-
float diff = (sub_fp64(a, mul_fp64(b, yn))).x;
|
|
165
|
-
vec2 prod = twoProd(xn, diff);
|
|
166
|
-
return sum_fp64(yn, prod);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
vec2 sqrt_fp64(vec2 a) {
|
|
170
|
-
if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);
|
|
171
|
-
if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);
|
|
172
|
-
|
|
173
|
-
float x = 1.0 / sqrt(a.x);
|
|
174
|
-
float yn = a.x * x;
|
|
175
|
-
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
176
|
-
vec2 yn_sqr = twoSqr(yn) * ONE;
|
|
177
|
-
#else
|
|
178
|
-
vec2 yn_sqr = twoSqr(yn);
|
|
179
|
-
#endif
|
|
180
|
-
float diff = sub_fp64(a, yn_sqr).x;
|
|
181
|
-
vec2 prod = twoProd(x * 0.5, diff);
|
|
182
|
-
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
|
183
|
-
return sum_fp64(split(yn), prod);
|
|
184
|
-
#else
|
|
185
|
-
return sum_fp64(vec2(yn, 0.0), prod);
|
|
186
|
-
#endif
|
|
187
|
-
}
|