@genai-fi/nanogpt 0.10.1 → 0.10.3
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/Generator.js +11761 -171
- package/dist/{RealDiv-DgA3z9oO.js → RealDiv-KAPDe8zB.js} +28 -30
- package/dist/Reshape-BYkmUnAv.js +14 -0
- package/dist/{Reshape-_kILl6tK.js → Reshape-Zt6eb7yh.js} +18 -20
- package/dist/TeachableLLM.js +10 -11
- package/dist/{axis_util-BvHEw88j.js → axis_util-BaG7mf5A.js} +3 -3
- package/dist/backend.js +2 -2
- package/dist/{backend_util-D-rUb2ty.js → backend_util-RCe-rHaj.js} +59 -60
- package/dist/{backend_webgpu-B0u2ndUn.js → backend_webgpu-DE3ACOLx.js} +45 -47
- package/dist/broadcast_to-B3eYlZm7.js +28 -0
- package/dist/checks/appendCache.js +2 -2
- package/dist/checks/attentionMask.js +3 -3
- package/dist/checks/gelu.js +2 -2
- package/dist/checks/matMulGelu.js +7 -11
- package/dist/checks/normRMS.js +9 -9
- package/dist/checks/normRMSGrad.js +3 -3
- package/dist/checks/packUnpack.js +2 -2
- package/dist/checks/qkv.js +12 -13
- package/dist/checks/rope.js +2 -2
- package/dist/clip_by_value-BnO7-a88.js +12 -0
- package/dist/complex-DjxcVmoX.js +11 -0
- package/dist/concat-BV8bt5H-.js +17 -0
- package/dist/{concat_util-DcJk7YHS.js → concat_util-DpW8mL_l.js} +1 -1
- package/dist/{dataset-0xP8GjwI.js → dataset-BcwmTGYc.js} +137 -139
- package/dist/dropout-BcvN9JYi.js +92 -0
- package/dist/expand_dims-DT4tEPwA.js +11 -0
- package/dist/{exports_initializers-xuidcwI4.js → exports_initializers-Hta_rEnm.js} +1 -1
- package/dist/floor-D5QdR_le.js +9 -0
- package/dist/gather-D3JcZUaI.js +9 -0
- package/dist/{gelu-CNLFZWea.js → gelu-CjNPL4OH.js} +10 -11
- package/dist/{gpgpu_math-DDVJCn6-.js → gpgpu_math-DAOmgtXR.js} +841 -1015
- package/dist/{index-CjOj7j-u.js → index-BwexR4lA.js} +262 -263
- package/dist/index-DOvlwCh-.js +3520 -0
- package/dist/{kernel_funcs_utils-Dg_-E44D.js → kernel_funcs_utils-CCzYdUZg.js} +129 -131
- package/dist/layers/BaseLayer.js +14 -15
- package/dist/layers/CausalSelfAttention.js +6 -6
- package/dist/layers/MLP.js +4 -4
- package/dist/layers/PositionEmbedding.js +7 -7
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +9 -9
- package/dist/layers/TiedEmbedding.js +6 -6
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/oldZipLoad.js +13 -14
- package/dist/log_sum_exp-ngO0-4pK.js +39 -0
- package/dist/main.js +49 -50
- package/dist/{matMul16--R5hOwDG.js → matMul16-BWRSOCWB.js} +14 -15
- package/dist/matMulGelu-CzfgT6Wq.js +163 -0
- package/dist/mat_mul-SjpJRLyL.js +11 -0
- package/dist/mod-AnXEvvpo.js +11 -0
- package/dist/models/NanoGPTV1.js +2 -2
- package/dist/models/model.js +13 -14
- package/dist/ones-D2rT0xk2.js +14 -0
- package/dist/ops/adamAdjust.js +1 -1
- package/dist/ops/adamMoments.js +1 -1
- package/dist/ops/add16.js +1 -1
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/concat16.js +2 -2
- package/dist/ops/cpu/adamAdjust.js +13 -14
- package/dist/ops/cpu/adamMoments.js +6 -7
- package/dist/ops/cpu/appendCache.js +7 -8
- package/dist/ops/cpu/attentionMask.js +7 -7
- package/dist/ops/cpu/fusedSoftmax.js +10 -11
- package/dist/ops/cpu/gatherSub.js +9 -10
- package/dist/ops/cpu/gelu.js +9 -10
- package/dist/ops/cpu/matMul16.js +6 -7
- package/dist/ops/cpu/matMulGelu.js +5 -6
- package/dist/ops/cpu/matMulMul.js +3 -4
- package/dist/ops/cpu/mulDropout.js +3 -4
- package/dist/ops/cpu/normRMS.js +10 -11
- package/dist/ops/cpu/qkv.js +8 -9
- package/dist/ops/cpu/rope.js +5 -6
- package/dist/ops/cpu/scatterSub.js +17 -19
- package/dist/ops/dot16.js +2 -2
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/add16.js +11 -12
- package/dist/ops/grads/attentionMask.js +5 -6
- package/dist/ops/grads/gelu.js +3 -4
- package/dist/ops/grads/matMul16.js +4 -5
- package/dist/ops/grads/matMulGelu.js +9 -10
- package/dist/ops/grads/normRMS.js +7 -8
- package/dist/ops/grads/pack16.js +4 -5
- package/dist/ops/grads/qkv.js +17 -19
- package/dist/ops/grads/rope.js +3 -5
- package/dist/ops/grads/softmax16.js +3 -4
- package/dist/ops/grads/unpack16.js +3 -4
- package/dist/ops/grads/utils.d.ts +1 -0
- package/dist/ops/grads/utils.js +8 -4
- package/dist/ops/matMul16.js +3 -3
- package/dist/ops/matMulGelu.js +2 -2
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mul16.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/pack16.js +3 -4
- package/dist/ops/qkv.js +4 -8
- package/dist/ops/reshape16.js +14 -16
- package/dist/ops/rope.d.ts +1 -1
- package/dist/ops/rope.js +3 -8
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/slice16.js +2 -2
- package/dist/ops/softmax16.js +5 -8
- package/dist/ops/sub16.js +1 -1
- package/dist/ops/sum16.js +2 -2
- package/dist/ops/transpose16.js +23 -24
- package/dist/ops/unpack16.js +2 -2
- package/dist/ops/webgl/adamAdjust.js +2 -3
- package/dist/ops/webgl/adamMoments.js +1 -2
- package/dist/ops/webgl/appendCache.js +1 -2
- package/dist/ops/webgl/attentionMask.js +4 -5
- package/dist/ops/webgl/fusedSoftmax.js +4 -6
- package/dist/ops/webgl/gatherSub.js +6 -7
- package/dist/ops/webgl/gelu.js +2 -3
- package/dist/ops/webgl/log.js +11 -12
- package/dist/ops/webgl/matMul16.js +10 -11
- package/dist/ops/webgl/matMulGelu.js +7 -111
- package/dist/ops/webgl/matMulMul.js +9 -10
- package/dist/ops/webgl/mulDropout.js +8 -9
- package/dist/ops/webgl/normRMS.js +2 -3
- package/dist/ops/webgl/qkv.js +5 -6
- package/dist/ops/webgl/rope.js +7 -8
- package/dist/ops/webgl/scatterSub.js +5 -6
- package/dist/ops/webgpu/adamAdjust.js +10 -12
- package/dist/ops/webgpu/adamMoments.js +8 -10
- package/dist/ops/webgpu/add16.js +8 -9
- package/dist/ops/webgpu/appendCache.js +23 -25
- package/dist/ops/webgpu/attentionMask.js +8 -10
- package/dist/ops/webgpu/attentionMask32_program.js +2 -2
- package/dist/ops/webgpu/concat16.js +12 -14
- package/dist/ops/webgpu/gatherSub.js +11 -13
- package/dist/ops/webgpu/gelu.js +28 -29
- package/dist/ops/webgpu/matMul16.js +26 -28
- package/dist/ops/webgpu/matMul16_program.js +4 -5
- package/dist/ops/webgpu/mul16.js +9 -10
- package/dist/ops/webgpu/normRMS.js +15 -17
- package/dist/ops/webgpu/normRMSGrad.js +21 -28
- package/dist/ops/webgpu/pack16.js +12 -13
- package/dist/ops/webgpu/pack16_program.js +2 -2
- package/dist/ops/webgpu/qkv.js +16 -18
- package/dist/ops/webgpu/rope.js +25 -27
- package/dist/ops/webgpu/scatterSub.js +7 -9
- package/dist/ops/webgpu/slice16.js +21 -23
- package/dist/ops/webgpu/softmax16.js +17 -19
- package/dist/ops/webgpu/softmax16_program.js +2 -2
- package/dist/ops/webgpu/softmax16_subgroup_program.js +2 -2
- package/dist/ops/webgpu/softmax16grad.js +7 -8
- package/dist/ops/webgpu/sub16.js +7 -8
- package/dist/ops/webgpu/sum16.js +18 -20
- package/dist/ops/webgpu/transpose16.js +19 -20
- package/dist/ops/webgpu/transpose16_program.js +2 -2
- package/dist/ops/webgpu/transpose16_shared_program.js +11 -12
- package/dist/ops/webgpu/unpack16.js +3 -4
- package/dist/ops/webgpu/utils/binary_op.js +7 -8
- package/dist/ops/webgpu/utils/reductions.js +14 -22
- package/dist/ops-B5yanEdW.js +476 -0
- package/dist/pack16-nQ6JaLo-.js +39 -0
- package/dist/patches/webgpu_backend.js +19 -20
- package/dist/patches/webgpu_base.js +1 -1
- package/dist/patches/webgpu_program.js +21 -22
- package/dist/{random_width-DY6Kk2Dl.js → random_width-or-CEftb.js} +2506 -2761
- package/dist/range-BklejeeW.js +10 -0
- package/dist/relu-CP0ZcxWO.js +9 -0
- package/dist/reshape-ByE68wS9.js +9 -0
- package/dist/resize_nearest_neighbor-B19mCEg2.js +175 -0
- package/dist/rope-Ir4mTyD1.js +24 -0
- package/dist/{scatter_nd_util-5EL-8VAQ.js → scatter_nd_util-lvSiX8q4.js} +1 -1
- package/dist/selu_util-kbhpTdYD.js +44 -0
- package/dist/{shared-BRksrJb3.js → shared-DT1TkE6w.js} +1 -1
- package/dist/{shared-BuAXb4CI.js → shared-dntlHIDQ.js} +343 -345
- package/dist/slice-BfEGSH82.js +12 -0
- package/dist/{slice_util-DtEldBfK.js → slice_util-uTKwiEpW.js} +1 -1
- package/dist/{softmax-ZHVebtR1.js → softmax-CA5jFsLR.js} +4 -5
- package/dist/split-CVLc0w--.js +9 -0
- package/dist/squeeze-C7Z2srUo.js +10 -0
- package/dist/stack-Cf4n9h0N.js +11 -0
- package/dist/step-CINUs5QB.js +261 -0
- package/dist/sum-DWAtNGez.js +11 -0
- package/dist/tensor-DJoc7gJU.js +8 -0
- package/dist/tensor1d-D11P_7Dp.js +11 -0
- package/dist/{tensor2d-G4Ys2GxX.js → tensor2d-Bs9wZRc7.js} +6 -7
- package/dist/{tensor4d-B8roDgtc.js → tensor4d-BARPdTaS.js} +6 -7
- package/dist/{tfjs_backend-kNyO5L2d.js → tfjs_backend-y1cvNhLA.js} +244 -253
- package/dist/tile-mbfagpsB.js +11 -0
- package/dist/training/Adam.js +2 -2
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.js +2 -2
- package/dist/training/sparseCrossEntropy.js +5 -5
- package/dist/transpose-ClWiBS_b.js +36 -0
- package/dist/unsorted_segment_sum-BDDhB_E6.js +277 -0
- package/dist/utilities/dummy.js +3 -3
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/packed.d.ts +1 -4
- package/dist/utilities/packed.js +10 -711
- package/dist/utilities/performance.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/sentences.js +5 -5
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-Bhn5bHYv.js → variable-WawDEaAb.js} +1 -1
- package/dist/{webgpu_program-Cigz-7RF.js → webgpu_program-DuOXPQol.js} +178 -172
- package/dist/{webgpu_util-BBCnKm2X.js → webgpu_util-RxEF33Rj.js} +34 -35
- package/dist/zeros-KnWaWf-X.js +13 -0
- package/dist/zeros_like-DvE73F4e.js +721 -0
- package/package.json +4 -2
- package/dist/Reshape-CF6odzV4.js +0 -16
- package/dist/broadcast_to-CwF7XIeu.js +0 -30
- package/dist/complex-CSlYz-2T.js +0 -13
- package/dist/concat-BHlIJeyT.js +0 -19
- package/dist/dropout-C1pM3f11.js +0 -99
- package/dist/expand_dims-BPG4fwBP.js +0 -13
- package/dist/gather-DykLGqmW.js +0 -10
- package/dist/index-ZyQhjEPo.js +0 -2157
- package/dist/log_sum_exp-DWI-76TI.js +0 -41
- package/dist/mat_mul-DeAh4uTH.js +0 -12
- package/dist/mod-Gt1rMB4n.js +0 -12
- package/dist/mulmat_packed_gpu-BMFhLwta.js +0 -55
- package/dist/ones-CAMiP4I2.js +0 -15
- package/dist/ops-CNI3TwqM.js +0 -645
- package/dist/pack16-CFUqumar.js +0 -41
- package/dist/patches/PackedTensor.d.ts +0 -12
- package/dist/patches/PackedTensor.js +0 -11
- package/dist/patches/engine.d.ts +0 -261
- package/dist/patches/engine.js +0 -10
- package/dist/patches/tape.d.ts +0 -12
- package/dist/patches/tape.js +0 -5
- package/dist/range-BMS52eQi.js +0 -11
- package/dist/reciprocal-CTmshQ9J.js +0 -10
- package/dist/register_all_kernels-Bwu1PTuU.js +0 -12307
- package/dist/relu-yZ2-7WxU.js +0 -10
- package/dist/reshape-DevtBWtf.js +0 -10
- package/dist/rope-B5UUMsPi.js +0 -32
- package/dist/selu_util-D1w6yyTO.js +0 -303
- package/dist/sin-BGfy2HZo.js +0 -16
- package/dist/slice-D_gkkqZK.js +0 -13
- package/dist/split-DrfihRpZ.js +0 -10
- package/dist/squeeze-DZEpeblb.js +0 -11
- package/dist/stack-yOIAalTq.js +0 -13
- package/dist/sum-_fzj5ZTB.js +0 -12
- package/dist/tensor-DdQUJZlz.js +0 -909
- package/dist/tensor-f35l8Odg.js +0 -8
- package/dist/tensor1d-CeZuc-Rv.js +0 -12
- package/dist/tensor_util-DV-FP5Q3.js +0 -523
- package/dist/tile-BzyEiF-F.js +0 -13
- package/dist/transpose-DKELTqhe.js +0 -38
- package/dist/zeros-2gldETuK.js +0 -14
|
@@ -1,182 +1,386 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const o = [{
|
|
23
|
-
paths: ["./" + this.weightDataFileName],
|
|
24
|
-
weights: t.weightSpecs
|
|
25
|
-
}], i = ie(t, o), a = window.URL.createObjectURL(new Blob([JSON.stringify(i)], { type: "application/json" })), s = this.modelJsonAnchor == null ? document.createElement("a") : this.modelJsonAnchor;
|
|
26
|
-
if (s.download = this.modelJsonFileName, s.href = a, await K(() => s.dispatchEvent(new MouseEvent("click"))), t.weightData != null) {
|
|
27
|
-
const c = this.weightDataAnchor == null ? document.createElement("a") : this.weightDataAnchor;
|
|
28
|
-
c.download = this.weightDataFileName, c.href = r, await K(() => c.dispatchEvent(new MouseEvent("click")));
|
|
29
|
-
}
|
|
30
|
-
return { modelArtifactsInfo: ae(t) };
|
|
31
|
-
}
|
|
1
|
+
import { j as $, h as E, aN as X, n as T, aO as ae, V as N, aP as G, l as ie, ad as k, o as ce } from "./index-DOvlwCh-.js";
|
|
2
|
+
import { b as se } from "./backend_util-RCe-rHaj.js";
|
|
3
|
+
const w = {}, M = {
|
|
4
|
+
alpha: !1,
|
|
5
|
+
antialias: !1,
|
|
6
|
+
premultipliedAlpha: !1,
|
|
7
|
+
preserveDrawingBuffer: !1,
|
|
8
|
+
depth: !1,
|
|
9
|
+
stencil: !1,
|
|
10
|
+
failIfMajorPerformanceCaveat: !0
|
|
11
|
+
};
|
|
12
|
+
function ut(e, t) {
|
|
13
|
+
w[e] = t;
|
|
14
|
+
}
|
|
15
|
+
function A(e, t) {
|
|
16
|
+
if (!(e in w) || t != null) {
|
|
17
|
+
const r = le(e, t);
|
|
18
|
+
if (r !== null)
|
|
19
|
+
w[e] = r;
|
|
20
|
+
else
|
|
21
|
+
return console.log("Could not get context for WebGL version", e), null;
|
|
32
22
|
}
|
|
23
|
+
const n = w[e];
|
|
24
|
+
return n == null || n.isContextLost() ? (delete w[e], A(e)) : (n.disable(n.DEPTH_TEST), n.disable(n.STENCIL_TEST), n.disable(n.BLEND), n.disable(n.DITHER), n.disable(n.POLYGON_OFFSET_FILL), n.disable(n.SAMPLE_COVERAGE), n.enable(n.SCISSOR_TEST), n.enable(n.CULL_FACE), n.cullFace(n.BACK), w[e]);
|
|
33
25
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
26
|
+
function ue(e) {
|
|
27
|
+
if (!$().getBool("IS_SAFARI") && typeof OffscreenCanvas < "u" && e === 2)
|
|
28
|
+
return new OffscreenCanvas(300, 150);
|
|
29
|
+
if (typeof document < "u")
|
|
30
|
+
return document.createElement("canvas");
|
|
31
|
+
throw new Error("Cannot create a canvas in this context");
|
|
32
|
+
}
|
|
33
|
+
function le(e, t) {
|
|
34
|
+
if (e !== 1 && e !== 2)
|
|
35
|
+
throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");
|
|
36
|
+
const n = t ?? ue(e);
|
|
37
|
+
return n.addEventListener("webglcontextlost", (r) => {
|
|
38
|
+
r.preventDefault(), delete w[e];
|
|
39
|
+
}, !1), $().getBool("SOFTWARE_WEBGL_ENABLED") && (M.failIfMajorPerformanceCaveat = !1), e === 1 ? (
|
|
40
|
+
// tslint:disable-next-line
|
|
41
|
+
n.getContext("webgl", M) || n.getContext("experimental-webgl", M)
|
|
42
|
+
) : n.getContext("webgl2", M);
|
|
43
|
+
}
|
|
44
|
+
var H;
|
|
45
|
+
(function(e) {
|
|
46
|
+
e[e.DENSE = 0] = "DENSE", e[e.SHARED_BATCH = 1] = "SHARED_BATCH";
|
|
47
|
+
})(H || (H = {}));
|
|
48
|
+
var q;
|
|
49
|
+
(function(e) {
|
|
50
|
+
e[e.RENDER = 0] = "RENDER", e[e.UPLOAD = 1] = "UPLOAD", e[e.PIXELS = 2] = "PIXELS", e[e.DOWNLOAD = 3] = "DOWNLOAD";
|
|
51
|
+
})(q || (q = {}));
|
|
52
|
+
var j;
|
|
53
|
+
(function(e) {
|
|
54
|
+
e[e.UNPACKED_FLOAT16 = 0] = "UNPACKED_FLOAT16", e[e.UNPACKED_FLOAT32 = 1] = "UNPACKED_FLOAT32", e[e.PACKED_4X1_UNSIGNED_BYTE = 2] = "PACKED_4X1_UNSIGNED_BYTE", e[e.PACKED_2X2_FLOAT32 = 3] = "PACKED_2X2_FLOAT32", e[e.PACKED_2X2_FLOAT16 = 4] = "PACKED_2X2_FLOAT16";
|
|
55
|
+
})(j || (j = {}));
|
|
56
|
+
function lt(e, t) {
|
|
57
|
+
return [t, e];
|
|
58
|
+
}
|
|
59
|
+
function ft(e, t) {
|
|
60
|
+
return e * t;
|
|
61
|
+
}
|
|
62
|
+
function xt(e) {
|
|
63
|
+
const t = E(e), n = Math.ceil(t / 4);
|
|
64
|
+
return X(n);
|
|
65
|
+
}
|
|
66
|
+
function fe(e, t) {
|
|
67
|
+
return [
|
|
68
|
+
Math.max(1, Math.ceil(t / 2)),
|
|
69
|
+
Math.max(1, Math.ceil(e / 2))
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
function dt(e, t) {
|
|
73
|
+
const [n, r] = fe(e, t);
|
|
74
|
+
return n * r * 4;
|
|
75
|
+
}
|
|
76
|
+
function K(e, t) {
|
|
77
|
+
const n = e;
|
|
78
|
+
let r, o, a, i, c, s, l, u, f, d;
|
|
79
|
+
return $().getNumber("WEBGL_VERSION") === 2 ? (r = n.R32F, o = n.R16F, a = n.RGBA16F, i = n.RGBA32F, c = n.RED, l = 4, u = 1, f = n.HALF_FLOAT, d = n.FLOAT, s = n.RGBA8) : (r = e.RGBA, o = e.RGBA, a = e.RGBA, i = n.RGBA, c = e.RGBA, l = 4, u = 4, f = t != null ? t.HALF_FLOAT_OES : null, d = e.FLOAT, s = e.RGBA), {
|
|
80
|
+
internalFormatFloat: r,
|
|
81
|
+
internalFormatHalfFloat: o,
|
|
82
|
+
internalFormatPackedHalfFloat: a,
|
|
83
|
+
internalFormatPackedFloat: i,
|
|
84
|
+
textureFormatFloat: c,
|
|
85
|
+
downloadTextureFormat: s,
|
|
86
|
+
downloadUnpackNumChannels: l,
|
|
87
|
+
defaultNumChannels: u,
|
|
88
|
+
textureTypeHalfFloat: f,
|
|
89
|
+
textureTypeFloat: d
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function v(e, t) {
|
|
93
|
+
const n = t();
|
|
94
|
+
return $().getBool("DEBUG") && xe(e), n;
|
|
95
|
+
}
|
|
96
|
+
function xe(e) {
|
|
97
|
+
const t = e.getError();
|
|
98
|
+
if (t !== e.NO_ERROR)
|
|
99
|
+
throw new Error("WebGL Error: " + pe(e, t));
|
|
100
|
+
}
|
|
101
|
+
const de = 596e-10, he = 65504;
|
|
102
|
+
function ht(e) {
|
|
103
|
+
return !!($().getBool("WEBGL_RENDER_FLOAT32_ENABLED") || e === 0 || de < Math.abs(e) && Math.abs(e) < he);
|
|
104
|
+
}
|
|
105
|
+
function pe(e, t) {
|
|
106
|
+
switch (t) {
|
|
107
|
+
case e.NO_ERROR:
|
|
108
|
+
return "NO_ERROR";
|
|
109
|
+
case e.INVALID_ENUM:
|
|
110
|
+
return "INVALID_ENUM";
|
|
111
|
+
case e.INVALID_VALUE:
|
|
112
|
+
return "INVALID_VALUE";
|
|
113
|
+
case e.INVALID_OPERATION:
|
|
114
|
+
return "INVALID_OPERATION";
|
|
115
|
+
case e.INVALID_FRAMEBUFFER_OPERATION:
|
|
116
|
+
return "INVALID_FRAMEBUFFER_OPERATION";
|
|
117
|
+
case e.OUT_OF_MEMORY:
|
|
118
|
+
return "OUT_OF_MEMORY";
|
|
119
|
+
case e.CONTEXT_LOST_WEBGL:
|
|
120
|
+
return "CONTEXT_LOST_WEBGL";
|
|
121
|
+
default:
|
|
122
|
+
return `Unknown error code ${t}`;
|
|
49
123
|
}
|
|
50
|
-
|
|
51
|
-
|
|
124
|
+
}
|
|
125
|
+
function pt(e, t) {
|
|
126
|
+
return C(e, () => e.getExtension(t), 'Extension "' + t + '" not supported on this browser.');
|
|
127
|
+
}
|
|
128
|
+
function vt(e, t) {
|
|
129
|
+
const n = C(e, () => e.createShader(e.VERTEX_SHADER), "Unable to create vertex WebGLShader.");
|
|
130
|
+
if (v(e, () => e.shaderSource(n, t)), v(e, () => e.compileShader(n)), e.getShaderParameter(n, e.COMPILE_STATUS) === !1)
|
|
131
|
+
throw console.log(e.getShaderInfoLog(n)), new Error("Failed to compile vertex shader.");
|
|
132
|
+
return n;
|
|
133
|
+
}
|
|
134
|
+
function ve(e, t) {
|
|
135
|
+
const n = C(e, () => e.createShader(e.FRAGMENT_SHADER), "Unable to create fragment WebGLShader.");
|
|
136
|
+
if (v(e, () => e.shaderSource(n, t)), v(e, () => e.compileShader(n)), $().get("ENGINE_COMPILE_ONLY"))
|
|
137
|
+
return n;
|
|
138
|
+
if (e.getShaderParameter(n, e.COMPILE_STATUS) === !1)
|
|
139
|
+
throw me(t, e.getShaderInfoLog(n)), new Error("Failed to compile fragment shader.");
|
|
140
|
+
return n;
|
|
141
|
+
}
|
|
142
|
+
const $e = /ERROR: [0-9]+:([0-9]+):/g;
|
|
143
|
+
function me(e, t) {
|
|
144
|
+
const n = $e.exec(t);
|
|
145
|
+
if (n == null) {
|
|
146
|
+
console.log(`Couldn't parse line number in error: ${t}`), console.log(e);
|
|
147
|
+
return;
|
|
52
148
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
a.close();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
149
|
+
const r = +n[1], o = e.split(`
|
|
150
|
+
`), a = o.length.toString().length + 2, i = o.map((f, d) => G((d + 1).toString(), a) + f);
|
|
151
|
+
let c = 0;
|
|
152
|
+
for (let f = 0; f < i.length; f++)
|
|
153
|
+
c = Math.max(i[f].length, c);
|
|
154
|
+
const s = i.slice(0, r - 1), l = i.slice(r - 1, r), u = i.slice(r);
|
|
155
|
+
console.log(s.join(`
|
|
156
|
+
`)), console.log(t.split(`
|
|
157
|
+
`)[0]), console.log(`%c ${G(l[0], c)}`, "border:1px solid red; background-color:#e3d2d2; color:#a61717"), console.log(u.join(`
|
|
158
|
+
`));
|
|
159
|
+
}
|
|
160
|
+
function $t(e) {
|
|
161
|
+
return C(e, () => e.createProgram(), "Unable to create WebGLProgram.");
|
|
162
|
+
}
|
|
163
|
+
function mt(e, t) {
|
|
164
|
+
if (v(e, () => e.linkProgram(t)), !$().get("ENGINE_COMPILE_ONLY") && e.getProgramParameter(t, e.LINK_STATUS) === !1)
|
|
165
|
+
throw console.log(e.getProgramInfoLog(t)), new Error("Failed to link vertex and fragment shaders.");
|
|
166
|
+
}
|
|
167
|
+
function Tt(e, t) {
|
|
168
|
+
if (v(e, () => e.validateProgram(t)), e.getProgramParameter(t, e.VALIDATE_STATUS) === !1)
|
|
169
|
+
throw console.log(e.getProgramInfoLog(t)), new Error("Shader program validation failed.");
|
|
79
170
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
171
|
+
function St(e, t) {
|
|
172
|
+
const n = C(e, () => e.createBuffer(), "Unable to create WebGLBuffer");
|
|
173
|
+
return v(e, () => e.bindBuffer(e.ARRAY_BUFFER, n)), v(e, () => e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW)), n;
|
|
174
|
+
}
|
|
175
|
+
function Rt(e, t) {
|
|
176
|
+
const n = C(e, () => e.createBuffer(), "Unable to create WebGLBuffer");
|
|
177
|
+
return v(e, () => e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, n)), v(e, () => e.bufferData(e.ELEMENT_ARRAY_BUFFER, t, e.STATIC_DRAW)), n;
|
|
178
|
+
}
|
|
179
|
+
function Et(e) {
|
|
180
|
+
return C(e, () => e.createTexture(), "Unable to create WebGLTexture.");
|
|
181
|
+
}
|
|
182
|
+
function Ct(e, t) {
|
|
183
|
+
const n = $().getNumber("WEBGL_MAX_TEXTURE_SIZE");
|
|
184
|
+
if (e <= 0 || t <= 0) {
|
|
185
|
+
const r = `[${e}x${t}]`;
|
|
186
|
+
throw new Error("Requested texture size " + r + " is invalid.");
|
|
86
187
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const n = Object.assign({ method: this.DEFAULT_METHOD }, this.requestInit);
|
|
91
|
-
n.body = new FormData();
|
|
92
|
-
const r = [{
|
|
93
|
-
paths: ["./model.weights.bin"],
|
|
94
|
-
weights: t.weightSpecs
|
|
95
|
-
}], o = ie(t, r);
|
|
96
|
-
if (n.body.append("model.json", new Blob([JSON.stringify(o)], { type: Ne }), "model.json"), t.weightData != null) {
|
|
97
|
-
const a = oe.join(t.weightData);
|
|
98
|
-
n.body.append("model.weights.bin", new Blob([a], { type: Ae }), "model.weights.bin");
|
|
99
|
-
}
|
|
100
|
-
const i = await this.fetch(this.path, n);
|
|
101
|
-
if (i.ok)
|
|
102
|
-
return {
|
|
103
|
-
modelArtifactsInfo: ae(t),
|
|
104
|
-
responses: [i]
|
|
105
|
-
};
|
|
106
|
-
throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${i.status}.`);
|
|
188
|
+
if (e > n || t > n) {
|
|
189
|
+
const r = `[${e}x${t}]`, o = `[${n}x${n}]`;
|
|
190
|
+
throw new Error("Requested texture size " + r + " greater than WebGL maximum on this browser / GPU " + o + ".");
|
|
107
191
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
192
|
+
}
|
|
193
|
+
function Ft(e) {
|
|
194
|
+
return C(e, () => e.createFramebuffer(), "Unable to create WebGLFramebuffer.");
|
|
195
|
+
}
|
|
196
|
+
function _t(e, t, n, r, o, a, i) {
|
|
197
|
+
const c = e.getAttribLocation(t, n);
|
|
198
|
+
return c === -1 ? !1 : (v(e, () => e.bindBuffer(e.ARRAY_BUFFER, r)), v(e, () => e.vertexAttribPointer(c, o, e.FLOAT, !1, a, i)), v(e, () => e.enableVertexAttribArray(c)), !0);
|
|
199
|
+
}
|
|
200
|
+
function Te(e, t, n) {
|
|
201
|
+
Re(e, n), v(e, () => e.activeTexture(e.TEXTURE0 + n)), v(e, () => e.bindTexture(e.TEXTURE_2D, t));
|
|
202
|
+
}
|
|
203
|
+
function At(e, t, n) {
|
|
204
|
+
return C(e, () => e.getUniformLocation(t, n), 'uniform "' + n + '" not present in program.');
|
|
205
|
+
}
|
|
206
|
+
function wt(e, t, n) {
|
|
207
|
+
return e.getUniformLocation(t, n);
|
|
208
|
+
}
|
|
209
|
+
function Nt(e, t, n, r) {
|
|
210
|
+
v(e, () => Te(e, t, r)), v(e, () => e.uniform1i(n, r));
|
|
211
|
+
}
|
|
212
|
+
function Ot(e, t, n) {
|
|
213
|
+
v(e, () => e.bindFramebuffer(e.FRAMEBUFFER, n)), v(e, () => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, t, 0));
|
|
214
|
+
}
|
|
215
|
+
function It(e, t) {
|
|
216
|
+
v(e, () => e.bindFramebuffer(e.FRAMEBUFFER, t)), v(e, () => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, null, 0));
|
|
217
|
+
}
|
|
218
|
+
function Lt(e) {
|
|
219
|
+
const t = e.checkFramebufferStatus(e.FRAMEBUFFER);
|
|
220
|
+
if (t !== e.FRAMEBUFFER_COMPLETE)
|
|
221
|
+
throw new Error("Error binding framebuffer: " + Se(e, t));
|
|
222
|
+
}
|
|
223
|
+
function Se(e, t) {
|
|
224
|
+
switch (t) {
|
|
225
|
+
case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
|
226
|
+
return "FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
|
|
227
|
+
case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
|
228
|
+
return "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
|
|
229
|
+
case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
|
|
230
|
+
return "FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
|
|
231
|
+
case e.FRAMEBUFFER_UNSUPPORTED:
|
|
232
|
+
return "FRAMEBUFFER_UNSUPPORTED";
|
|
233
|
+
default:
|
|
234
|
+
return `unknown error ${t}`;
|
|
123
235
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return me(t, (n) => this.loadWeights(n));
|
|
236
|
+
}
|
|
237
|
+
function C(e, t, n) {
|
|
238
|
+
const r = v(e, () => t());
|
|
239
|
+
if (r == null)
|
|
240
|
+
throw new Error(n);
|
|
241
|
+
return r;
|
|
242
|
+
}
|
|
243
|
+
function Re(e, t) {
|
|
244
|
+
const n = e.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1, r = t + e.TEXTURE0;
|
|
245
|
+
if (r < e.TEXTURE0 || r > n) {
|
|
246
|
+
const o = `[gl.TEXTURE0, gl.TEXTURE${n}]`;
|
|
247
|
+
throw new Error(`textureUnit must be in ${o}.`);
|
|
137
248
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
249
|
+
}
|
|
250
|
+
function Z(e, t = 2) {
|
|
251
|
+
return E(e.slice(0, e.length - t));
|
|
252
|
+
}
|
|
253
|
+
function J(e) {
|
|
254
|
+
if (e.length === 0)
|
|
255
|
+
throw Error("Cannot get rows and columns of an empty shape array.");
|
|
256
|
+
return [
|
|
257
|
+
e.length > 1 ? e[e.length - 2] : 1,
|
|
258
|
+
e[e.length - 1]
|
|
259
|
+
];
|
|
260
|
+
}
|
|
261
|
+
function Ut(e) {
|
|
262
|
+
let t = [1, 1, 1];
|
|
263
|
+
return e.length === 0 || e.length === 1 && e[0] === 1 || (t = [Z(e), ...J(e)]), t;
|
|
264
|
+
}
|
|
265
|
+
function Dt(e, t = !1) {
|
|
266
|
+
let n = $().getNumber("WEBGL_MAX_TEXTURE_SIZE"), r = $().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");
|
|
267
|
+
r === 1 / 0 && $().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE") && (r = n / 2), t && (n = n * 2, r = r * 2, e = e.map((c, s) => s >= e.length - 2 ? ae(e[s]) : e[s]), e.length === 1 && (e = [2, e[0]])), e.length !== 2 && (e = N(e).newShape);
|
|
268
|
+
let o = E(e), a = null;
|
|
269
|
+
e.length <= 1 && o <= n ? a = [1, o] : e.length === 2 && e[0] <= n && e[1] <= n ? a = e : e.length === 3 && e[0] * e[1] <= n && e[2] <= n ? a = [e[0] * e[1], e[2]] : e.length === 3 && e[0] <= n && e[1] * e[2] <= n ? a = [e[0], e[1] * e[2]] : e.length === 4 && e[0] * e[1] * e[2] <= n && e[3] <= n ? a = [e[0] * e[1] * e[2], e[3]] : e.length === 4 && e[0] <= n && e[1] * e[2] * e[3] <= n && (a = [e[0], e[1] * e[2] * e[3]]);
|
|
270
|
+
const i = a != null && Math.max(...a) > r && Math.min(...a) <= (t ? 2 : 1) && Math.min(...a) > 0;
|
|
271
|
+
if (a == null || i)
|
|
272
|
+
if (t) {
|
|
273
|
+
const c = Z(e);
|
|
274
|
+
let s = 2, l = 2;
|
|
275
|
+
e.length && ([s, l] = J(e)), o = c * (s / 2) * (l / 2), a = X(o).map((u) => u * 2);
|
|
276
|
+
} else
|
|
277
|
+
a = X(o);
|
|
278
|
+
return a;
|
|
279
|
+
}
|
|
280
|
+
function B(e) {
|
|
281
|
+
return e % 2 === 0;
|
|
282
|
+
}
|
|
283
|
+
function gt(e, t) {
|
|
284
|
+
if (e = e.slice(-2), t = t.slice(-2), T(e, t) || !e.length || !t.length || e[0] === 0 || e[1] === 0 || t[0] === 0 || t[1] === 0)
|
|
285
|
+
return !0;
|
|
286
|
+
if (e.length !== t.length) {
|
|
287
|
+
const n = e[e.length - 1], r = t[t.length - 1];
|
|
288
|
+
if (n === r || B(n) && B(r) && (e[0] === 1 || t[0] === 1))
|
|
289
|
+
return !0;
|
|
141
290
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
291
|
+
return e[1] === t[1] && B(e[0]) && B(t[0]);
|
|
292
|
+
}
|
|
293
|
+
let P, V;
|
|
294
|
+
function bt(e) {
|
|
295
|
+
if (P == null) {
|
|
296
|
+
const t = A(e);
|
|
297
|
+
P = t.getParameter(t.MAX_TEXTURE_SIZE);
|
|
148
298
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
299
|
+
return P;
|
|
300
|
+
}
|
|
301
|
+
function kt(e) {
|
|
302
|
+
if (V == null) {
|
|
303
|
+
const t = A(e);
|
|
304
|
+
V = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);
|
|
152
305
|
}
|
|
306
|
+
return Math.min(16, V);
|
|
153
307
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
{
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
308
|
+
function Mt(e) {
|
|
309
|
+
if (e === 0)
|
|
310
|
+
return 0;
|
|
311
|
+
let t;
|
|
312
|
+
const n = A(e);
|
|
313
|
+
return _(n, "EXT_disjoint_timer_query_webgl2") && e === 2 ? t = 2 : _(n, "EXT_disjoint_timer_query") ? t = 1 : t = 0, t;
|
|
314
|
+
}
|
|
315
|
+
function _(e, t) {
|
|
316
|
+
return e.getExtension(t) != null;
|
|
317
|
+
}
|
|
318
|
+
function Bt(e) {
|
|
319
|
+
try {
|
|
320
|
+
if (A(e) != null)
|
|
321
|
+
return !0;
|
|
322
|
+
} catch (t) {
|
|
323
|
+
return console.log("Error when getting WebGL context: ", t), !1;
|
|
169
324
|
}
|
|
170
|
-
return
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
325
|
+
return !1;
|
|
326
|
+
}
|
|
327
|
+
function yt(e) {
|
|
328
|
+
if (e === 0)
|
|
329
|
+
return !1;
|
|
330
|
+
const t = A(e);
|
|
331
|
+
if (e === 1) {
|
|
332
|
+
if (!_(t, "OES_texture_float"))
|
|
333
|
+
return !1;
|
|
334
|
+
} else if (!_(t, "EXT_color_buffer_float"))
|
|
335
|
+
return !1;
|
|
336
|
+
return W(t);
|
|
337
|
+
}
|
|
338
|
+
function Pt(e) {
|
|
339
|
+
if (e === 0)
|
|
340
|
+
return !1;
|
|
341
|
+
const t = A(e);
|
|
342
|
+
if (e === 1) {
|
|
343
|
+
if (!_(t, "OES_texture_float") || !_(t, "WEBGL_color_buffer_float"))
|
|
344
|
+
return !1;
|
|
345
|
+
} else {
|
|
346
|
+
if (_(t, "EXT_color_buffer_float"))
|
|
347
|
+
return W(t);
|
|
348
|
+
const r = "EXT_color_buffer_half_float";
|
|
349
|
+
if (_(t, r)) {
|
|
350
|
+
const o = t.getExtension(r);
|
|
351
|
+
return Ee(t, o);
|
|
352
|
+
}
|
|
353
|
+
return !1;
|
|
354
|
+
}
|
|
355
|
+
return W(t);
|
|
356
|
+
}
|
|
357
|
+
function W(e) {
|
|
358
|
+
const t = K(e), n = e.createTexture();
|
|
359
|
+
e.bindTexture(e.TEXTURE_2D, n), e.texImage2D(e.TEXTURE_2D, 0, t.internalFormatFloat, 1, 1, 0, t.textureFormatFloat, t.textureTypeFloat, null);
|
|
360
|
+
const a = e.createFramebuffer();
|
|
361
|
+
e.bindFramebuffer(e.FRAMEBUFFER, a), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, n, 0);
|
|
362
|
+
const i = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE;
|
|
363
|
+
return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(n), e.deleteFramebuffer(a), i;
|
|
364
|
+
}
|
|
365
|
+
function Ee(e, t) {
|
|
366
|
+
const n = K(e, t), r = e.createTexture();
|
|
367
|
+
e.bindTexture(e.TEXTURE_2D, r), e.texImage2D(e.TEXTURE_2D, 0, n.internalFormatHalfFloat, 1, 1, 0, n.textureFormatFloat, n.textureTypeHalfFloat, null);
|
|
368
|
+
const i = e.createFramebuffer();
|
|
369
|
+
e.bindFramebuffer(e.FRAMEBUFFER, i), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, r, 0);
|
|
370
|
+
const c = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE;
|
|
371
|
+
return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(r), e.deleteFramebuffer(i), c;
|
|
372
|
+
}
|
|
373
|
+
function Vt(e) {
|
|
374
|
+
return e !== 2 ? !1 : A(e).fenceSync != null;
|
|
375
|
+
}
|
|
376
|
+
function Xt(e, t) {
|
|
377
|
+
Array.isArray(e) || (e = [e]), e.forEach((n) => {
|
|
378
|
+
n != null && ie(n.dtype !== "complex64", () => `${t} does not support complex64 tensors in the WebGL backend.`);
|
|
379
|
+
});
|
|
176
380
|
}
|
|
177
381
|
function L() {
|
|
178
|
-
let e, t, n, r, o, i,
|
|
179
|
-
return
|
|
382
|
+
let e, t, n, r, o, a, i, c, s, l;
|
|
383
|
+
return $().getNumber("WEBGL_VERSION") === 2 ? (e = "#version 300 es", t = "in", n = "out", r = "in", o = "texture", a = "outputColor", i = "out vec4 outputColor;", c = $().getBool("WEBGL2_ISNAN_CUSTOM") ? `
|
|
180
384
|
bool isnan_custom(float val) {
|
|
181
385
|
uint floatToUint = floatBitsToUint(val);
|
|
182
386
|
return (floatToUint & 0x7fffffffu) > 0x7f800000u;
|
|
@@ -188,7 +392,7 @@ function L() {
|
|
|
188
392
|
}
|
|
189
393
|
|
|
190
394
|
#define isnan(value) isnan_custom(value)
|
|
191
|
-
` : "",
|
|
395
|
+
` : "", s = "", l = `
|
|
192
396
|
#define round(value) newRound(value)
|
|
193
397
|
int newRound(float value) {
|
|
194
398
|
return int(floor(value + 0.5));
|
|
@@ -197,7 +401,7 @@ function L() {
|
|
|
197
401
|
ivec4 newRound(vec4 value) {
|
|
198
402
|
return ivec4(floor(value + vec4(0.5)));
|
|
199
403
|
}
|
|
200
|
-
`) : (e = "", t = "attribute", n = "varying", r = "varying", o = "texture2D",
|
|
404
|
+
`) : (e = "", t = "attribute", n = "varying", r = "varying", o = "texture2D", a = "gl_FragColor", i = "", c = `
|
|
201
405
|
#define isnan(value) isnan_custom(value)
|
|
202
406
|
bool isnan_custom(float val) {
|
|
203
407
|
return (val > 0. || val < 1. || val == 0.) ? false : true;
|
|
@@ -205,7 +409,7 @@ function L() {
|
|
|
205
409
|
bvec4 isnan_custom(vec4 val) {
|
|
206
410
|
return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));
|
|
207
411
|
}
|
|
208
|
-
`,
|
|
412
|
+
`, s = `
|
|
209
413
|
uniform float INFINITY;
|
|
210
414
|
|
|
211
415
|
bool isinf(float val) {
|
|
@@ -214,7 +418,7 @@ function L() {
|
|
|
214
418
|
bvec4 isinf(vec4 val) {
|
|
215
419
|
return equal(abs(val), vec4(INFINITY));
|
|
216
420
|
}
|
|
217
|
-
`,
|
|
421
|
+
`, l = `
|
|
218
422
|
int round(float value) {
|
|
219
423
|
return int(floor(value + 0.5));
|
|
220
424
|
}
|
|
@@ -228,57 +432,57 @@ function L() {
|
|
|
228
432
|
varyingVs: n,
|
|
229
433
|
varyingFs: r,
|
|
230
434
|
texture2D: o,
|
|
231
|
-
output:
|
|
232
|
-
defineOutput:
|
|
233
|
-
defineSpecialNaN:
|
|
234
|
-
defineSpecialInf:
|
|
235
|
-
defineRound:
|
|
435
|
+
output: a,
|
|
436
|
+
defineOutput: i,
|
|
437
|
+
defineSpecialNaN: c,
|
|
438
|
+
defineSpecialInf: s,
|
|
439
|
+
defineRound: l
|
|
236
440
|
};
|
|
237
441
|
}
|
|
238
|
-
function
|
|
239
|
-
const r =
|
|
240
|
-
return r.map((o,
|
|
241
|
-
const
|
|
242
|
-
return `${
|
|
442
|
+
function y(e, t, n = "index") {
|
|
443
|
+
const r = k(t);
|
|
444
|
+
return r.map((o, a) => {
|
|
445
|
+
const i = `int ${e[a]} = ${n} / ${o}`, c = a === r.length - 1 ? `int ${e[a + 1]} = ${n} - ${e[a]} * ${o}` : `index -= ${e[a]} * ${o}`;
|
|
446
|
+
return `${i}; ${c};`;
|
|
243
447
|
}).join("");
|
|
244
448
|
}
|
|
245
|
-
function
|
|
246
|
-
const r =
|
|
247
|
-
return r.map((o,
|
|
248
|
-
const
|
|
249
|
-
return `${
|
|
449
|
+
function Q(e, t, n = "index") {
|
|
450
|
+
const r = k(t);
|
|
451
|
+
return r.map((o, a) => {
|
|
452
|
+
const i = `int ${e[a]} = ${n} / outShapeStrides[${a}]`, c = a === r.length - 1 ? `int ${e[a + 1]} = ${n} - ${e[a]} * outShapeStrides[${a}]` : `index -= ${e[a]} * outShapeStrides[${a}]`;
|
|
453
|
+
return `${i}; ${c};`;
|
|
250
454
|
}).join("");
|
|
251
455
|
}
|
|
252
|
-
function
|
|
253
|
-
const n = e.length, r = e.map((
|
|
456
|
+
function Ce(e, t) {
|
|
457
|
+
const n = e.length, r = e.map((a) => `${t}[${a}]`), o = new Array(n - 1);
|
|
254
458
|
o[n - 2] = r[n - 1];
|
|
255
|
-
for (let
|
|
256
|
-
o[
|
|
459
|
+
for (let a = n - 3; a >= 0; --a)
|
|
460
|
+
o[a] = `(${o[a + 1]} * ${r[a + 1]})`;
|
|
257
461
|
return o;
|
|
258
462
|
}
|
|
259
|
-
function
|
|
260
|
-
const r = e.map((
|
|
261
|
-
return o.map((
|
|
262
|
-
const
|
|
263
|
-
return `${
|
|
463
|
+
function Wt(e, t, n = "index") {
|
|
464
|
+
const r = e.map((a, i) => i), o = Ce(r, t);
|
|
465
|
+
return o.map((a, i) => {
|
|
466
|
+
const c = `int ${e[i]} = ${n} / ${o[i]}`, s = i === o.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * ${o[i]}` : `index -= ${e[i]} * ${o[i]}`;
|
|
467
|
+
return `${c}; ${s};`;
|
|
264
468
|
}).join("");
|
|
265
469
|
}
|
|
266
|
-
function
|
|
267
|
-
const t =
|
|
470
|
+
function zt(e) {
|
|
471
|
+
const t = k(e).map((n) => n.toString());
|
|
268
472
|
return `
|
|
269
473
|
int getFlatIndex(ivec3 coords) {
|
|
270
474
|
return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;
|
|
271
475
|
}
|
|
272
476
|
`;
|
|
273
477
|
}
|
|
274
|
-
function
|
|
478
|
+
function Gt() {
|
|
275
479
|
return `
|
|
276
480
|
int getFlatIndex(ivec3 coords) {
|
|
277
481
|
return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;
|
|
278
482
|
}
|
|
279
483
|
`;
|
|
280
484
|
}
|
|
281
|
-
const
|
|
485
|
+
const Ht = `
|
|
282
486
|
const float FLOAT_MAX = 1.70141184e38;
|
|
283
487
|
const float FLOAT_MIN = 1.17549435e-38;
|
|
284
488
|
|
|
@@ -318,28 +522,28 @@ const Mt = `
|
|
|
318
522
|
return c / 255.0;
|
|
319
523
|
}
|
|
320
524
|
`;
|
|
321
|
-
const { getBroadcastDims:
|
|
322
|
-
function
|
|
525
|
+
const { getBroadcastDims: ee } = se;
|
|
526
|
+
function Fe(e, t, n) {
|
|
323
527
|
const r = [];
|
|
324
|
-
if (e.forEach((
|
|
325
|
-
const
|
|
326
|
-
if (
|
|
327
|
-
const { uniformShape: p } =
|
|
528
|
+
if (e.forEach((x) => {
|
|
529
|
+
const h = E(x.shapeInfo.logicalShape);
|
|
530
|
+
if (x.shapeInfo.isUniform ? r.push(`uniform float ${x.name}${h > 1 ? `[${h}]` : ""};`) : (r.push(`uniform sampler2D ${x.name};`), r.push(`uniform int offset${x.name};`)), n.enableShapeUniforms) {
|
|
531
|
+
const { uniformShape: p } = z(n.packedInputs, x.shapeInfo.logicalShape, x.shapeInfo.texShape);
|
|
328
532
|
switch (p.length) {
|
|
329
533
|
case 1:
|
|
330
|
-
r.push(`uniform int ${
|
|
534
|
+
r.push(`uniform int ${x.name}Shape;`);
|
|
331
535
|
break;
|
|
332
536
|
case 2:
|
|
333
|
-
r.push(`uniform ivec2 ${
|
|
537
|
+
r.push(`uniform ivec2 ${x.name}Shape;`);
|
|
334
538
|
break;
|
|
335
539
|
case 3:
|
|
336
|
-
r.push(`uniform ivec3 ${
|
|
540
|
+
r.push(`uniform ivec3 ${x.name}Shape;`);
|
|
337
541
|
break;
|
|
338
542
|
case 4:
|
|
339
|
-
r.push(`uniform ivec4 ${
|
|
543
|
+
r.push(`uniform ivec4 ${x.name}Shape;`);
|
|
340
544
|
break;
|
|
341
545
|
}
|
|
342
|
-
r.push(`uniform ivec2 ${
|
|
546
|
+
r.push(`uniform ivec2 ${x.name}TexShape;`);
|
|
343
547
|
}
|
|
344
548
|
}), n.enableShapeUniforms) {
|
|
345
549
|
switch (t.logicalShape.length) {
|
|
@@ -358,121 +562,121 @@ function Le(e, t, n) {
|
|
|
358
562
|
}
|
|
359
563
|
r.push("uniform ivec2 outTexShape;");
|
|
360
564
|
}
|
|
361
|
-
n.customUniforms && n.customUniforms.forEach((
|
|
362
|
-
r.push(`uniform ${
|
|
565
|
+
n.customUniforms && n.customUniforms.forEach((x) => {
|
|
566
|
+
r.push(`uniform ${x.type} ${x.name}${x.arrayIndex ? `[${x.arrayIndex}]` : ""};`);
|
|
363
567
|
});
|
|
364
568
|
const o = r.join(`
|
|
365
|
-
`),
|
|
366
|
-
`),
|
|
367
|
-
let
|
|
368
|
-
return t.isPacked ? (
|
|
569
|
+
`), a = e.map((x) => _e(x, t, n.packedInputs, n.enableShapeUniforms)).join(`
|
|
570
|
+
`), i = t.texShape, c = L(), s = Ne(c);
|
|
571
|
+
let l, u, f = Le(c);
|
|
572
|
+
return t.isPacked ? (l = Ae(t.logicalShape, i, n.enableShapeUniforms), u = Ie(c)) : (l = we(t.logicalShape, i, n.enableShapeUniforms), u = Oe(c)), n.packedInputs && (f += be), [
|
|
369
573
|
f,
|
|
370
|
-
|
|
371
|
-
l,
|
|
372
|
-
o,
|
|
574
|
+
s,
|
|
373
575
|
u,
|
|
374
|
-
|
|
576
|
+
o,
|
|
577
|
+
l,
|
|
578
|
+
a,
|
|
375
579
|
n.userCode
|
|
376
580
|
].join(`
|
|
377
581
|
`);
|
|
378
582
|
}
|
|
379
|
-
function
|
|
583
|
+
function U(e, t = !1) {
|
|
380
584
|
const n = e.shapeInfo.logicalShape;
|
|
381
585
|
switch (n.length) {
|
|
382
586
|
case 0:
|
|
383
|
-
return
|
|
587
|
+
return qe(e, t);
|
|
384
588
|
case 1:
|
|
385
|
-
return
|
|
589
|
+
return Ye(e, t);
|
|
386
590
|
case 2:
|
|
387
|
-
return
|
|
591
|
+
return Ze(e, t);
|
|
388
592
|
case 3:
|
|
389
|
-
return
|
|
593
|
+
return Qe(e, t);
|
|
390
594
|
case 4:
|
|
391
|
-
return
|
|
595
|
+
return tt(e, t);
|
|
392
596
|
case 5:
|
|
393
|
-
return
|
|
597
|
+
return nt(e);
|
|
394
598
|
case 6:
|
|
395
|
-
return
|
|
599
|
+
return rt(e);
|
|
396
600
|
default:
|
|
397
601
|
throw new Error(`${n.length}-D input sampling is not yet supported`);
|
|
398
602
|
}
|
|
399
603
|
}
|
|
400
|
-
function
|
|
604
|
+
function te(e, t) {
|
|
401
605
|
switch (e.shapeInfo.logicalShape.length) {
|
|
402
606
|
case 0:
|
|
403
|
-
return
|
|
607
|
+
return He(e);
|
|
404
608
|
case 1:
|
|
405
|
-
return
|
|
609
|
+
return je(e, t);
|
|
406
610
|
case 2:
|
|
407
|
-
return
|
|
611
|
+
return Ke(e, t);
|
|
408
612
|
case 3:
|
|
409
|
-
return
|
|
613
|
+
return Je(e, t);
|
|
410
614
|
default:
|
|
411
|
-
return
|
|
615
|
+
return et(e, t);
|
|
412
616
|
}
|
|
413
617
|
}
|
|
414
|
-
function
|
|
618
|
+
function _e(e, t, n = !1, r) {
|
|
415
619
|
let o = "";
|
|
416
|
-
n ? o +=
|
|
417
|
-
const
|
|
418
|
-
return
|
|
620
|
+
n ? o += te(e, r) : o += U(e, r);
|
|
621
|
+
const a = e.shapeInfo.logicalShape, i = t.logicalShape;
|
|
622
|
+
return a.length <= i.length && (n ? o += ot(e, t) : o += at(e, t)), o;
|
|
419
623
|
}
|
|
420
|
-
function
|
|
624
|
+
function Ae(e, t, n) {
|
|
421
625
|
switch (e.length) {
|
|
422
626
|
case 0:
|
|
423
|
-
return
|
|
627
|
+
return ne();
|
|
424
628
|
case 1:
|
|
425
|
-
return
|
|
629
|
+
return ke(e, t, n);
|
|
426
630
|
case 2:
|
|
427
|
-
return
|
|
631
|
+
return ze(e, t, n);
|
|
428
632
|
case 3:
|
|
429
|
-
return
|
|
633
|
+
return Be(e, t, n);
|
|
430
634
|
default:
|
|
431
|
-
return
|
|
635
|
+
return Pe(e, t, n);
|
|
432
636
|
}
|
|
433
637
|
}
|
|
434
|
-
function
|
|
638
|
+
function we(e, t, n) {
|
|
435
639
|
switch (e.length) {
|
|
436
640
|
case 0:
|
|
437
|
-
return
|
|
641
|
+
return ne();
|
|
438
642
|
case 1:
|
|
439
|
-
return
|
|
643
|
+
return Me(e, t, n);
|
|
440
644
|
case 2:
|
|
441
|
-
return
|
|
645
|
+
return Ge(e, t, n);
|
|
442
646
|
case 3:
|
|
443
|
-
return
|
|
647
|
+
return ye(e, t, n);
|
|
444
648
|
case 4:
|
|
445
|
-
return
|
|
649
|
+
return Ve(e, t, n);
|
|
446
650
|
case 5:
|
|
447
|
-
return
|
|
651
|
+
return Xe(e, t);
|
|
448
652
|
case 6:
|
|
449
|
-
return
|
|
653
|
+
return We(e, t);
|
|
450
654
|
default:
|
|
451
655
|
throw new Error(`${e.length}-D output sampling is not yet supported`);
|
|
452
656
|
}
|
|
453
657
|
}
|
|
454
|
-
function
|
|
658
|
+
function Ne(e) {
|
|
455
659
|
return `
|
|
456
660
|
float sampleTexture(sampler2D textureSampler, vec2 uv) {
|
|
457
661
|
return ${e.texture2D}(textureSampler, uv).r;
|
|
458
662
|
}
|
|
459
663
|
`;
|
|
460
664
|
}
|
|
461
|
-
function
|
|
665
|
+
function Oe(e) {
|
|
462
666
|
return `
|
|
463
667
|
void setOutput(float val) {
|
|
464
668
|
${e.output} = vec4(val, 0, 0, 0);
|
|
465
669
|
}
|
|
466
670
|
`;
|
|
467
671
|
}
|
|
468
|
-
function
|
|
672
|
+
function Ie(e) {
|
|
469
673
|
return `
|
|
470
674
|
void setOutput(vec4 val) {
|
|
471
675
|
${e.output} = val;
|
|
472
676
|
}
|
|
473
677
|
`;
|
|
474
678
|
}
|
|
475
|
-
function
|
|
679
|
+
function Le(e) {
|
|
476
680
|
return `${e.version}
|
|
477
681
|
precision highp float;
|
|
478
682
|
precision highp int;
|
|
@@ -528,12 +732,12 @@ function Pe(e) {
|
|
|
528
732
|
return fract((p3.x + p3.y) * p3.z);
|
|
529
733
|
}
|
|
530
734
|
|
|
531
|
-
${
|
|
532
|
-
${
|
|
533
|
-
${
|
|
735
|
+
${Ue}
|
|
736
|
+
${De}
|
|
737
|
+
${ge}
|
|
534
738
|
`;
|
|
535
739
|
}
|
|
536
|
-
const
|
|
740
|
+
const Ue = `
|
|
537
741
|
vec2 uvFromFlat(int texNumR, int texNumC, int index) {
|
|
538
742
|
int texR = index / texNumC;
|
|
539
743
|
int texC = index - texR * texNumC;
|
|
@@ -545,7 +749,7 @@ vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {
|
|
|
545
749
|
int texC = texelIndex - texR * texNumC;
|
|
546
750
|
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
|
|
547
751
|
}
|
|
548
|
-
`,
|
|
752
|
+
`, De = `
|
|
549
753
|
vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,
|
|
550
754
|
int texNumC, int row, int col) {
|
|
551
755
|
int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);
|
|
@@ -553,7 +757,7 @@ vec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,
|
|
|
553
757
|
int texC = texelIndex - texR * texNumC;
|
|
554
758
|
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
|
|
555
759
|
}
|
|
556
|
-
`,
|
|
760
|
+
`, ge = `
|
|
557
761
|
vec2 packedUVfrom3D(int texNumR, int texNumC,
|
|
558
762
|
int texelsInBatch, int texelsInLogicalRow, int b,
|
|
559
763
|
int row, int col) {
|
|
@@ -562,7 +766,7 @@ vec2 packedUVfrom3D(int texNumR, int texNumC,
|
|
|
562
766
|
int texC = index - texR * texNumC;
|
|
563
767
|
return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);
|
|
564
768
|
}
|
|
565
|
-
`,
|
|
769
|
+
`, be = `
|
|
566
770
|
float getChannel(vec4 frag, vec2 innerDims) {
|
|
567
771
|
vec2 modCoord = mod(innerDims, 2.);
|
|
568
772
|
return modCoord.x == 0. ?
|
|
@@ -574,14 +778,14 @@ vec2 packedUVfrom3D(int texNumR, int texNumC,
|
|
|
574
778
|
return modCoord == 0. ? frag.r : frag.g;
|
|
575
779
|
}
|
|
576
780
|
`;
|
|
577
|
-
function
|
|
781
|
+
function ne() {
|
|
578
782
|
return `
|
|
579
783
|
int getOutputCoords() {
|
|
580
784
|
return 0;
|
|
581
785
|
}
|
|
582
786
|
`;
|
|
583
787
|
}
|
|
584
|
-
function
|
|
788
|
+
function ke(e, t, n) {
|
|
585
789
|
const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)];
|
|
586
790
|
return r[0] === 1 ? n ? `
|
|
587
791
|
int getOutputCoords() {
|
|
@@ -614,7 +818,7 @@ function Ge(e, t, n) {
|
|
|
614
818
|
}
|
|
615
819
|
`;
|
|
616
820
|
}
|
|
617
|
-
function
|
|
821
|
+
function Me(e, t, n) {
|
|
618
822
|
return t[0] === 1 ? n ? `
|
|
619
823
|
int getOutputCoords() {
|
|
620
824
|
return int(resultUV.x * float(outTexShape[1]));
|
|
@@ -645,7 +849,7 @@ function ze(e, t, n) {
|
|
|
645
849
|
}
|
|
646
850
|
`;
|
|
647
851
|
}
|
|
648
|
-
function
|
|
852
|
+
function Be(e, t, n) {
|
|
649
853
|
if (n)
|
|
650
854
|
return `
|
|
651
855
|
ivec3 getOutputCoords() {
|
|
@@ -665,15 +869,15 @@ function qe(e, t, n) {
|
|
|
665
869
|
return ivec3(b, r, c);
|
|
666
870
|
}
|
|
667
871
|
`;
|
|
668
|
-
const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)], o = Math.ceil(e[2] / 2),
|
|
872
|
+
const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)], o = Math.ceil(e[2] / 2), a = o * Math.ceil(e[1] / 2);
|
|
669
873
|
return `
|
|
670
874
|
ivec3 getOutputCoords() {
|
|
671
875
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
672
876
|
vec2(${r[0]}, ${r[1]}));
|
|
673
877
|
int index = resTexRC.x * ${r[1]} + resTexRC.y;
|
|
674
878
|
|
|
675
|
-
int b = index / ${
|
|
676
|
-
index -= b * ${
|
|
879
|
+
int b = index / ${a};
|
|
880
|
+
index -= b * ${a};
|
|
677
881
|
|
|
678
882
|
int r = 2 * (index / ${o});
|
|
679
883
|
int c = imod(index, ${o}) * 2;
|
|
@@ -682,18 +886,18 @@ function qe(e, t, n) {
|
|
|
682
886
|
}
|
|
683
887
|
`;
|
|
684
888
|
}
|
|
685
|
-
function
|
|
889
|
+
function ye(e, t, n) {
|
|
686
890
|
if (n)
|
|
687
891
|
return `
|
|
688
892
|
ivec3 getOutputCoords() {
|
|
689
893
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
690
894
|
vec2(outTexShape[0], outTexShape[1]));
|
|
691
895
|
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
|
|
692
|
-
${
|
|
896
|
+
${Q(["r", "c", "d"], e)}
|
|
693
897
|
return ivec3(r, c, d);
|
|
694
898
|
}
|
|
695
899
|
`;
|
|
696
|
-
const r =
|
|
900
|
+
const r = y(["r", "c", "d"], e);
|
|
697
901
|
return `
|
|
698
902
|
ivec3 getOutputCoords() {
|
|
699
903
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
@@ -704,7 +908,7 @@ function je(e, t, n) {
|
|
|
704
908
|
}
|
|
705
909
|
`;
|
|
706
910
|
}
|
|
707
|
-
function
|
|
911
|
+
function Pe(e, t, n) {
|
|
708
912
|
if (n)
|
|
709
913
|
return `
|
|
710
914
|
ivec4 getOutputCoords() {
|
|
@@ -729,43 +933,43 @@ function Je(e, t, n) {
|
|
|
729
933
|
return ivec4(b2, b, r, c);
|
|
730
934
|
}
|
|
731
935
|
`;
|
|
732
|
-
const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)], o = Math.ceil(e[e.length - 1] / 2),
|
|
733
|
-
let
|
|
734
|
-
for (let
|
|
735
|
-
|
|
736
|
-
int b${
|
|
737
|
-
index -= b${
|
|
738
|
-
` +
|
|
936
|
+
const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)], o = Math.ceil(e[e.length - 1] / 2), a = o * Math.ceil(e[e.length - 2] / 2);
|
|
937
|
+
let i = a, c = "", s = "b, r, c";
|
|
938
|
+
for (let l = 2; l < e.length - 1; l++)
|
|
939
|
+
i *= e[e.length - l - 1], c = `
|
|
940
|
+
int b${l} = index / ${i};
|
|
941
|
+
index -= b${l} * ${i};
|
|
942
|
+
` + c, s = `b${l}, ` + s;
|
|
739
943
|
return `
|
|
740
944
|
ivec${e.length} getOutputCoords() {
|
|
741
945
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
742
946
|
vec2(${r[0]}, ${r[1]}));
|
|
743
947
|
int index = resTexRC.x * ${r[1]} + resTexRC.y;
|
|
744
948
|
|
|
745
|
-
${
|
|
949
|
+
${c}
|
|
746
950
|
|
|
747
|
-
int b = index / ${
|
|
748
|
-
index -= b * ${
|
|
951
|
+
int b = index / ${a};
|
|
952
|
+
index -= b * ${a};
|
|
749
953
|
|
|
750
954
|
int r = 2 * (index / ${o});
|
|
751
955
|
int c = imod(index, ${o}) * 2;
|
|
752
956
|
|
|
753
|
-
return ivec${e.length}(${
|
|
957
|
+
return ivec${e.length}(${s});
|
|
754
958
|
}
|
|
755
959
|
`;
|
|
756
960
|
}
|
|
757
|
-
function
|
|
961
|
+
function Ve(e, t, n) {
|
|
758
962
|
if (n)
|
|
759
963
|
return `
|
|
760
964
|
ivec4 getOutputCoords() {
|
|
761
965
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
762
966
|
vec2(outTexShape[0], outTexShape[1]));
|
|
763
967
|
int index = resTexRC.x * outTexShape[1] + resTexRC.y;
|
|
764
|
-
${
|
|
968
|
+
${Q(["r", "c", "d", "d2"], e)}
|
|
765
969
|
return ivec4(r, c, d, d2);
|
|
766
970
|
}
|
|
767
971
|
`;
|
|
768
|
-
const r =
|
|
972
|
+
const r = y(["r", "c", "d", "d2"], e);
|
|
769
973
|
return `
|
|
770
974
|
ivec4 getOutputCoords() {
|
|
771
975
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
@@ -776,8 +980,8 @@ function Ye(e, t, n) {
|
|
|
776
980
|
}
|
|
777
981
|
`;
|
|
778
982
|
}
|
|
779
|
-
function
|
|
780
|
-
const n =
|
|
983
|
+
function Xe(e, t) {
|
|
984
|
+
const n = y(["r", "c", "d", "d2", "d3"], e);
|
|
781
985
|
return `
|
|
782
986
|
ivec5 getOutputCoords() {
|
|
783
987
|
ivec2 resTexRC = ivec2(resultUV.yx * vec2(${t[0]},
|
|
@@ -792,8 +996,8 @@ function Ke(e, t) {
|
|
|
792
996
|
}
|
|
793
997
|
`;
|
|
794
998
|
}
|
|
795
|
-
function
|
|
796
|
-
const n =
|
|
999
|
+
function We(e, t) {
|
|
1000
|
+
const n = y(["r", "c", "d", "d2", "d3", "d4"], e);
|
|
797
1001
|
return `
|
|
798
1002
|
ivec6 getOutputCoords() {
|
|
799
1003
|
ivec2 resTexRC = ivec2(resultUV.yx *
|
|
@@ -807,7 +1011,7 @@ function Ze(e, t) {
|
|
|
807
1011
|
}
|
|
808
1012
|
`;
|
|
809
1013
|
}
|
|
810
|
-
function
|
|
1014
|
+
function ze(e, t, n) {
|
|
811
1015
|
const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)];
|
|
812
1016
|
if (T(e, t))
|
|
813
1017
|
return n ? `
|
|
@@ -847,7 +1051,7 @@ function Qe(e, t, n) {
|
|
|
847
1051
|
}
|
|
848
1052
|
`;
|
|
849
1053
|
}
|
|
850
|
-
function
|
|
1054
|
+
function Ge(e, t, n) {
|
|
851
1055
|
return T(e, t) ? n ? `
|
|
852
1056
|
ivec2 getOutputCoords() {
|
|
853
1057
|
return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));
|
|
@@ -904,10 +1108,10 @@ function et(e, t, n) {
|
|
|
904
1108
|
}
|
|
905
1109
|
`;
|
|
906
1110
|
}
|
|
907
|
-
function
|
|
1111
|
+
function O(e) {
|
|
908
1112
|
return `offset${e}`;
|
|
909
1113
|
}
|
|
910
|
-
function
|
|
1114
|
+
function He(e) {
|
|
911
1115
|
const t = e.name, n = "get" + t.charAt(0).toUpperCase() + t.slice(1), r = L();
|
|
912
1116
|
return `
|
|
913
1117
|
vec4 ${n}() {
|
|
@@ -915,54 +1119,54 @@ function tt(e) {
|
|
|
915
1119
|
}
|
|
916
1120
|
`;
|
|
917
1121
|
}
|
|
918
|
-
function
|
|
1122
|
+
function qe(e, t) {
|
|
919
1123
|
const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1);
|
|
920
1124
|
if (e.shapeInfo.isUniform)
|
|
921
1125
|
return `float ${r}() {return ${n};}`;
|
|
922
|
-
const [o,
|
|
923
|
-
if (o === 1 &&
|
|
1126
|
+
const [o, a] = e.shapeInfo.texShape;
|
|
1127
|
+
if (o === 1 && a === 1)
|
|
924
1128
|
return `
|
|
925
1129
|
float ${r}() {
|
|
926
1130
|
return sampleTexture(${n}, halfCR);
|
|
927
1131
|
}
|
|
928
1132
|
`;
|
|
929
|
-
const
|
|
1133
|
+
const i = O(n);
|
|
930
1134
|
if (t)
|
|
931
1135
|
return `
|
|
932
1136
|
float ${r}() {
|
|
933
|
-
vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], ${
|
|
1137
|
+
vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], ${i});
|
|
934
1138
|
return sampleTexture(${n}, uv);
|
|
935
1139
|
}
|
|
936
1140
|
`;
|
|
937
|
-
const [
|
|
1141
|
+
const [c, s] = e.shapeInfo.texShape;
|
|
938
1142
|
return `
|
|
939
1143
|
float ${r}() {
|
|
940
|
-
vec2 uv = uvFromFlat(${
|
|
1144
|
+
vec2 uv = uvFromFlat(${c}, ${s}, ${i});
|
|
941
1145
|
return sampleTexture(${n}, uv);
|
|
942
1146
|
}
|
|
943
1147
|
`;
|
|
944
1148
|
}
|
|
945
|
-
function
|
|
946
|
-
const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), o = e.shapeInfo.texShape,
|
|
1149
|
+
function je(e, t) {
|
|
1150
|
+
const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), o = e.shapeInfo.texShape, a = L();
|
|
947
1151
|
if (t)
|
|
948
1152
|
return `
|
|
949
1153
|
vec4 ${r}(int index) {
|
|
950
1154
|
ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));
|
|
951
1155
|
vec2 uv = packedUVfrom1D(
|
|
952
1156
|
packedTexShape[0], packedTexShape[1], index);
|
|
953
|
-
return ${
|
|
1157
|
+
return ${a.texture2D}(${n}, uv);
|
|
954
1158
|
}
|
|
955
1159
|
`;
|
|
956
|
-
const
|
|
1160
|
+
const i = [Math.ceil(o[0] / 2), Math.ceil(o[1] / 2)];
|
|
957
1161
|
return `
|
|
958
1162
|
vec4 ${r}(int index) {
|
|
959
1163
|
vec2 uv = packedUVfrom1D(
|
|
960
|
-
${
|
|
961
|
-
return ${
|
|
1164
|
+
${i[0]}, ${i[1]}, index);
|
|
1165
|
+
return ${a.texture2D}(${n}, uv);
|
|
962
1166
|
}
|
|
963
1167
|
`;
|
|
964
1168
|
}
|
|
965
|
-
function
|
|
1169
|
+
function Ye(e, t) {
|
|
966
1170
|
const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1);
|
|
967
1171
|
if (e.shapeInfo.isUniform)
|
|
968
1172
|
return `
|
|
@@ -970,60 +1174,60 @@ function ot(e, t) {
|
|
|
970
1174
|
${D(e)}
|
|
971
1175
|
}
|
|
972
1176
|
`;
|
|
973
|
-
const o = e.shapeInfo.texShape,
|
|
974
|
-
if (
|
|
1177
|
+
const o = e.shapeInfo.texShape, a = o[0], i = o[1];
|
|
1178
|
+
if (i === 1 && a === 1)
|
|
975
1179
|
return `
|
|
976
1180
|
float ${r}(int index) {
|
|
977
1181
|
return sampleTexture(${n}, halfCR);
|
|
978
1182
|
}
|
|
979
1183
|
`;
|
|
980
|
-
const
|
|
981
|
-
return
|
|
1184
|
+
const c = O(n);
|
|
1185
|
+
return i === 1 ? t ? `
|
|
982
1186
|
float ${r}(int index) {
|
|
983
|
-
vec2 uv = vec2(0.5, (float(index + ${
|
|
1187
|
+
vec2 uv = vec2(0.5, (float(index + ${c}) + 0.5) / float(${n}TexShape[0]));
|
|
984
1188
|
return sampleTexture(${n}, uv);
|
|
985
1189
|
}
|
|
986
1190
|
` : `
|
|
987
1191
|
float ${r}(int index) {
|
|
988
|
-
vec2 uv = vec2(0.5, (float(index + ${
|
|
1192
|
+
vec2 uv = vec2(0.5, (float(index + ${c}) + 0.5) / ${a}.0);
|
|
989
1193
|
return sampleTexture(${n}, uv);
|
|
990
1194
|
}
|
|
991
|
-
` :
|
|
1195
|
+
` : a === 1 ? t ? `
|
|
992
1196
|
float ${r}(int index) {
|
|
993
|
-
vec2 uv = vec2((float(index + ${
|
|
1197
|
+
vec2 uv = vec2((float(index + ${c}) + 0.5) / float(${n}TexShape[1]), 0.5);
|
|
994
1198
|
return sampleTexture(${n}, uv);
|
|
995
1199
|
}
|
|
996
1200
|
` : `
|
|
997
1201
|
float ${r}(int index) {
|
|
998
|
-
vec2 uv = vec2((float(index + ${
|
|
1202
|
+
vec2 uv = vec2((float(index + ${c}) + 0.5) / ${i}.0, 0.5);
|
|
999
1203
|
return sampleTexture(${n}, uv);
|
|
1000
1204
|
}
|
|
1001
1205
|
` : t ? `
|
|
1002
1206
|
float ${r}(int index) {
|
|
1003
|
-
vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], index + ${
|
|
1207
|
+
vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], index + ${c});
|
|
1004
1208
|
return sampleTexture(${n}, uv);
|
|
1005
1209
|
}
|
|
1006
1210
|
` : `
|
|
1007
1211
|
float ${r}(int index) {
|
|
1008
|
-
vec2 uv = uvFromFlat(${
|
|
1212
|
+
vec2 uv = uvFromFlat(${a}, ${i}, index + ${c});
|
|
1009
1213
|
return sampleTexture(${n}, uv);
|
|
1010
1214
|
}
|
|
1011
1215
|
`;
|
|
1012
1216
|
}
|
|
1013
|
-
function
|
|
1014
|
-
const n = e.shapeInfo.logicalShape, r = e.name, o = "get" + r.charAt(0).toUpperCase() + r.slice(1),
|
|
1015
|
-
if (
|
|
1217
|
+
function Ke(e, t) {
|
|
1218
|
+
const n = e.shapeInfo.logicalShape, r = e.name, o = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = e.shapeInfo.texShape, i = a[0], c = a[1], s = L();
|
|
1219
|
+
if (a != null && T(n, a))
|
|
1016
1220
|
return t ? `
|
|
1017
1221
|
vec4 ${o}(int row, int col) {
|
|
1018
1222
|
vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);
|
|
1019
1223
|
|
|
1020
|
-
return ${
|
|
1224
|
+
return ${s.texture2D}(${r}, uv);
|
|
1021
1225
|
}
|
|
1022
1226
|
` : `
|
|
1023
1227
|
vec4 ${o}(int row, int col) {
|
|
1024
|
-
vec2 uv = (vec2(col, row) + halfCR) / vec2(${
|
|
1228
|
+
vec2 uv = (vec2(col, row) + halfCR) / vec2(${c}.0, ${i}.0);
|
|
1025
1229
|
|
|
1026
|
-
return ${
|
|
1230
|
+
return ${s.texture2D}(${r}, uv);
|
|
1027
1231
|
}
|
|
1028
1232
|
`;
|
|
1029
1233
|
if (t)
|
|
@@ -1032,20 +1236,20 @@ function it(e, t) {
|
|
|
1032
1236
|
ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));
|
|
1033
1237
|
int valuesPerRow = int(ceil(float(${r}Shape[1]) / 2.0));
|
|
1034
1238
|
vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);
|
|
1035
|
-
return ${
|
|
1239
|
+
return ${s.texture2D}(${r}, uv);
|
|
1036
1240
|
}
|
|
1037
1241
|
`;
|
|
1038
|
-
const
|
|
1242
|
+
const l = [Math.ceil(a[0] / 2), Math.ceil(a[1] / 2)], u = Math.ceil(n[1] / 2);
|
|
1039
1243
|
return `
|
|
1040
1244
|
vec4 ${o}(int row, int col) {
|
|
1041
|
-
vec2 uv = packedUVfrom2D(${
|
|
1042
|
-
return ${
|
|
1245
|
+
vec2 uv = packedUVfrom2D(${u}, ${l[0]}, ${l[1]}, row, col);
|
|
1246
|
+
return ${s.texture2D}(${r}, uv);
|
|
1043
1247
|
}
|
|
1044
1248
|
`;
|
|
1045
1249
|
}
|
|
1046
|
-
function
|
|
1047
|
-
const n = e.shapeInfo.logicalShape, r = e.name, o = "get" + r.charAt(0).toUpperCase() + r.slice(1),
|
|
1048
|
-
if (
|
|
1250
|
+
function Ze(e, t) {
|
|
1251
|
+
const n = e.shapeInfo.logicalShape, r = e.name, o = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = e.shapeInfo.texShape;
|
|
1252
|
+
if (a != null && T(n, a)) {
|
|
1049
1253
|
if (t)
|
|
1050
1254
|
return `
|
|
1051
1255
|
float ${o}(int row, int col) {
|
|
@@ -1053,21 +1257,21 @@ function at(e, t) {
|
|
|
1053
1257
|
return sampleTexture(${r}, uv);
|
|
1054
1258
|
}
|
|
1055
1259
|
`;
|
|
1056
|
-
const d =
|
|
1260
|
+
const d = a[0], x = a[1];
|
|
1057
1261
|
return `
|
|
1058
1262
|
float ${o}(int row, int col) {
|
|
1059
|
-
vec2 uv = (vec2(col, row) + halfCR) / vec2(${
|
|
1263
|
+
vec2 uv = (vec2(col, row) + halfCR) / vec2(${x}.0, ${d}.0);
|
|
1060
1264
|
return sampleTexture(${r}, uv);
|
|
1061
1265
|
}
|
|
1062
1266
|
`;
|
|
1063
1267
|
}
|
|
1064
|
-
const { newShape:
|
|
1065
|
-
if (
|
|
1066
|
-
const d =
|
|
1268
|
+
const { newShape: i, keptDims: c } = N(n), s = i;
|
|
1269
|
+
if (s.length < n.length) {
|
|
1270
|
+
const d = g(e, s), x = ["row", "col"];
|
|
1067
1271
|
return `
|
|
1068
|
-
${
|
|
1272
|
+
${U(d, t)}
|
|
1069
1273
|
float ${o}(int row, int col) {
|
|
1070
|
-
return ${o}(${
|
|
1274
|
+
return ${o}(${b(x, c)});
|
|
1071
1275
|
}
|
|
1072
1276
|
`;
|
|
1073
1277
|
}
|
|
@@ -1078,8 +1282,8 @@ function at(e, t) {
|
|
|
1078
1282
|
${D(e)}
|
|
1079
1283
|
}
|
|
1080
1284
|
`;
|
|
1081
|
-
const
|
|
1082
|
-
return
|
|
1285
|
+
const l = a[0], u = a[1], f = O(r);
|
|
1286
|
+
return u === 1 ? t ? `
|
|
1083
1287
|
float ${o}(int row, int col) {
|
|
1084
1288
|
float index = dot(vec3(row, col, ${f}), vec3(${r}Shape[1], 1, 1));
|
|
1085
1289
|
vec2 uv = vec2(0.5, (index + 0.5) / float(${r}TexShape[0]));
|
|
@@ -1088,10 +1292,10 @@ function at(e, t) {
|
|
|
1088
1292
|
` : `
|
|
1089
1293
|
float ${o}(int row, int col) {
|
|
1090
1294
|
float index = dot(vec3(row, col, ${f}), vec3(${n[1]}, 1, 1));
|
|
1091
|
-
vec2 uv = vec2(0.5, (index + 0.5) / ${
|
|
1295
|
+
vec2 uv = vec2(0.5, (index + 0.5) / ${l}.0);
|
|
1092
1296
|
return sampleTexture(${r}, uv);
|
|
1093
1297
|
}
|
|
1094
|
-
` :
|
|
1298
|
+
` : l === 1 ? t ? `
|
|
1095
1299
|
float ${o}(int row, int col) {
|
|
1096
1300
|
float index = dot(vec3(row, col, ${f}), vec3(${r}Shape[1], 1, 1));
|
|
1097
1301
|
vec2 uv = vec2((index + 0.5) / float(${r}TexShape[1]), 0.5);
|
|
@@ -1100,7 +1304,7 @@ function at(e, t) {
|
|
|
1100
1304
|
` : `
|
|
1101
1305
|
float ${o}(int row, int col) {
|
|
1102
1306
|
float index = dot(vec3(row, col, ${f}), vec3(${n[1]}, 1, 1));
|
|
1103
|
-
vec2 uv = vec2((index + 0.5) / ${
|
|
1307
|
+
vec2 uv = vec2((index + 0.5) / ${u}.0, 0.5);
|
|
1104
1308
|
return sampleTexture(${r}, uv);
|
|
1105
1309
|
}
|
|
1106
1310
|
` : t ? `
|
|
@@ -1114,23 +1318,23 @@ function at(e, t) {
|
|
|
1114
1318
|
float ${o}(int row, int col) {
|
|
1115
1319
|
// Explicitly use integer operations as dot() only works on floats.
|
|
1116
1320
|
int index = row * ${n[1]} + col + ${f};
|
|
1117
|
-
vec2 uv = uvFromFlat(${
|
|
1321
|
+
vec2 uv = uvFromFlat(${l}, ${u}, index);
|
|
1118
1322
|
return sampleTexture(${r}, uv);
|
|
1119
1323
|
}
|
|
1120
1324
|
`;
|
|
1121
1325
|
}
|
|
1122
|
-
function
|
|
1123
|
-
const n = e.shapeInfo.logicalShape, r = e.name, o = "get" + r.charAt(0).toUpperCase() + r.slice(1),
|
|
1326
|
+
function Je(e, t) {
|
|
1327
|
+
const n = e.shapeInfo.logicalShape, r = e.name, o = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = e.shapeInfo.texShape, i = [Math.ceil(a[0] / 2), Math.ceil(a[1] / 2)];
|
|
1124
1328
|
if (n[0] === 1) {
|
|
1125
|
-
const d = n.slice(1),
|
|
1329
|
+
const d = n.slice(1), x = [1, 2], h = g(e, d), p = ["b", "row", "col"];
|
|
1126
1330
|
return `
|
|
1127
|
-
${
|
|
1331
|
+
${te(h, t)}
|
|
1128
1332
|
vec4 ${o}(int b, int row, int col) {
|
|
1129
|
-
return ${o}(${
|
|
1333
|
+
return ${o}(${b(p, x)});
|
|
1130
1334
|
}
|
|
1131
1335
|
`;
|
|
1132
1336
|
}
|
|
1133
|
-
const
|
|
1337
|
+
const c = L();
|
|
1134
1338
|
if (t)
|
|
1135
1339
|
return `
|
|
1136
1340
|
vec4 ${o}(int b, int row, int col) {
|
|
@@ -1139,26 +1343,26 @@ function ct(e, t) {
|
|
|
1139
1343
|
int texelsInBatch = valuesPerRow * int(ceil(float(${r}Shape[1]) / 2.0));
|
|
1140
1344
|
vec2 uv = packedUVfrom3D(
|
|
1141
1345
|
packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);
|
|
1142
|
-
return ${
|
|
1346
|
+
return ${c.texture2D}(${r}, uv);
|
|
1143
1347
|
}
|
|
1144
1348
|
`;
|
|
1145
|
-
const
|
|
1349
|
+
const s = i[0], l = i[1], u = Math.ceil(n[2] / 2), f = u * Math.ceil(n[1] / 2);
|
|
1146
1350
|
return `
|
|
1147
1351
|
vec4 ${o}(int b, int row, int col) {
|
|
1148
1352
|
vec2 uv = packedUVfrom3D(
|
|
1149
|
-
${
|
|
1150
|
-
return ${
|
|
1353
|
+
${s}, ${l}, ${f}, ${u}, b, row, col);
|
|
1354
|
+
return ${c.texture2D}(${r}, uv);
|
|
1151
1355
|
}
|
|
1152
1356
|
`;
|
|
1153
1357
|
}
|
|
1154
|
-
function
|
|
1155
|
-
const n = e.shapeInfo.logicalShape, r = e.name, o = "get" + r.charAt(0).toUpperCase() + r.slice(1),
|
|
1156
|
-
if (
|
|
1157
|
-
const p =
|
|
1358
|
+
function Qe(e, t) {
|
|
1359
|
+
const n = e.shapeInfo.logicalShape, r = e.name, o = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = n[1] * n[2], i = n[2], { newShape: c, keptDims: s } = N(n), l = c;
|
|
1360
|
+
if (l.length < n.length) {
|
|
1361
|
+
const p = g(e, l), m = ["row", "col", "depth"];
|
|
1158
1362
|
return `
|
|
1159
|
-
${
|
|
1363
|
+
${U(p, t)}
|
|
1160
1364
|
float ${o}(int row, int col, int depth) {
|
|
1161
|
-
return ${o}(${
|
|
1365
|
+
return ${o}(${b(m, s)});
|
|
1162
1366
|
}
|
|
1163
1367
|
`;
|
|
1164
1368
|
}
|
|
@@ -1166,12 +1370,12 @@ function st(e, t) {
|
|
|
1166
1370
|
return `
|
|
1167
1371
|
float ${o}(int row, int col, int depth) {
|
|
1168
1372
|
int index = round(dot(vec3(row, col, depth),
|
|
1169
|
-
vec3(${
|
|
1373
|
+
vec3(${a}, ${i}, 1)));
|
|
1170
1374
|
${D(e)}
|
|
1171
1375
|
}
|
|
1172
1376
|
`;
|
|
1173
|
-
const
|
|
1174
|
-
if (d ===
|
|
1377
|
+
const u = e.shapeInfo.texShape, f = u[0], d = u[1], x = e.shapeInfo.flatOffset;
|
|
1378
|
+
if (d === a && x == null)
|
|
1175
1379
|
return t ? `
|
|
1176
1380
|
float ${o}(int row, int col, int depth) {
|
|
1177
1381
|
int stride1 = ${r}Shape[2];
|
|
@@ -1184,13 +1388,13 @@ function st(e, t) {
|
|
|
1184
1388
|
` : `
|
|
1185
1389
|
float ${o}(int row, int col, int depth) {
|
|
1186
1390
|
float texR = float(row);
|
|
1187
|
-
float texC = dot(vec2(col, depth), vec2(${
|
|
1391
|
+
float texC = dot(vec2(col, depth), vec2(${i}, 1));
|
|
1188
1392
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
1189
1393
|
vec2(${d}.0, ${f}.0);
|
|
1190
1394
|
return sampleTexture(${r}, uv);
|
|
1191
1395
|
}
|
|
1192
1396
|
`;
|
|
1193
|
-
if (d ===
|
|
1397
|
+
if (d === i && x == null)
|
|
1194
1398
|
return t ? `
|
|
1195
1399
|
float ${o}(int row, int col, int depth) {
|
|
1196
1400
|
float texR = dot(vec2(row, col), vec2(${r}Shape[1], 1));
|
|
@@ -1206,26 +1410,26 @@ function st(e, t) {
|
|
|
1206
1410
|
return sampleTexture(${r}, uv);
|
|
1207
1411
|
}
|
|
1208
1412
|
`;
|
|
1209
|
-
const
|
|
1413
|
+
const h = O(r);
|
|
1210
1414
|
return t ? `
|
|
1211
1415
|
float ${o}(int row, int col, int depth) {
|
|
1212
1416
|
// Explicitly use integer operations as dot() only works on floats.
|
|
1213
1417
|
int stride0 = ${r}Shape[1] * ${r}Shape[2];
|
|
1214
1418
|
int stride1 = ${r}Shape[2];
|
|
1215
|
-
int index = row * stride0 + col * stride1 + depth + ${
|
|
1419
|
+
int index = row * stride0 + col * stride1 + depth + ${h};
|
|
1216
1420
|
vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);
|
|
1217
1421
|
return sampleTexture(${r}, uv);
|
|
1218
1422
|
}
|
|
1219
1423
|
` : `
|
|
1220
1424
|
float ${o}(int row, int col, int depth) {
|
|
1221
1425
|
// Explicitly use integer operations as dot() only works on floats.
|
|
1222
|
-
int index = row * ${
|
|
1426
|
+
int index = row * ${a} + col * ${i} + depth + ${h};
|
|
1223
1427
|
vec2 uv = uvFromFlat(${f}, ${d}, index);
|
|
1224
1428
|
return sampleTexture(${r}, uv);
|
|
1225
1429
|
}
|
|
1226
1430
|
`;
|
|
1227
1431
|
}
|
|
1228
|
-
function
|
|
1432
|
+
function et(e, t) {
|
|
1229
1433
|
const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), o = L();
|
|
1230
1434
|
if (t)
|
|
1231
1435
|
return `
|
|
@@ -1241,28 +1445,28 @@ function ut(e, t) {
|
|
|
1241
1445
|
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${o.texture2D}(${n}, uv);
|
|
1242
1446
|
}
|
|
1243
1447
|
`;
|
|
1244
|
-
const
|
|
1245
|
-
let d = f * Math.ceil(i
|
|
1246
|
-
for (let p = 2; p <
|
|
1247
|
-
|
|
1448
|
+
const a = e.shapeInfo.logicalShape, i = a.length, c = e.shapeInfo.texShape, s = [Math.ceil(c[0] / 2), Math.ceil(c[1] / 2)], l = s[0], u = s[1], f = Math.ceil(a[i - 1] / 2);
|
|
1449
|
+
let d = f * Math.ceil(a[i - 2] / 2), x = "int b, int row, int col", h = `b * ${d} + (row / 2) * ${f} + (col / 2)`;
|
|
1450
|
+
for (let p = 2; p < i - 1; p++)
|
|
1451
|
+
x = `int b${p}, ` + x, d *= a[i - p - 1], h = `b${p} * ${d} + ` + h;
|
|
1248
1452
|
return `
|
|
1249
|
-
vec4 ${r}(${
|
|
1250
|
-
int index = ${
|
|
1251
|
-
int texR = index / ${
|
|
1252
|
-
int texC = index - texR * ${
|
|
1253
|
-
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${
|
|
1453
|
+
vec4 ${r}(${x}) {
|
|
1454
|
+
int index = ${h};
|
|
1455
|
+
int texR = index / ${u};
|
|
1456
|
+
int texC = index - texR * ${u};
|
|
1457
|
+
vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${u}, ${l});
|
|
1254
1458
|
return ${o.texture2D}(${n}, uv);
|
|
1255
1459
|
}
|
|
1256
1460
|
`;
|
|
1257
1461
|
}
|
|
1258
|
-
function
|
|
1259
|
-
const n = e.shapeInfo.logicalShape, r = e.name, o = "get" + r.charAt(0).toUpperCase() + r.slice(1),
|
|
1260
|
-
if (
|
|
1261
|
-
const R =
|
|
1462
|
+
function tt(e, t) {
|
|
1463
|
+
const n = e.shapeInfo.logicalShape, r = e.name, o = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = n[3], i = n[2] * a, c = n[1] * i, { newShape: s, keptDims: l } = N(n);
|
|
1464
|
+
if (s.length < n.length) {
|
|
1465
|
+
const R = g(e, s), F = ["row", "col", "depth", "depth2"];
|
|
1262
1466
|
return `
|
|
1263
|
-
${
|
|
1467
|
+
${U(R, t)}
|
|
1264
1468
|
float ${o}(int row, int col, int depth, int depth2) {
|
|
1265
|
-
return ${o}(${
|
|
1469
|
+
return ${o}(${b(F, l)});
|
|
1266
1470
|
}
|
|
1267
1471
|
`;
|
|
1268
1472
|
}
|
|
@@ -1270,15 +1474,15 @@ function lt(e, t) {
|
|
|
1270
1474
|
return `
|
|
1271
1475
|
float ${o}(int row, int col, int depth, int depth2) {
|
|
1272
1476
|
int index = round(dot(vec4(row, col, depth, depth2),
|
|
1273
|
-
vec4(${
|
|
1477
|
+
vec4(${c}, ${i}, ${a}, 1)));
|
|
1274
1478
|
${D(e)}
|
|
1275
1479
|
}
|
|
1276
1480
|
`;
|
|
1277
|
-
const
|
|
1278
|
-
if (
|
|
1481
|
+
const u = e.shapeInfo.flatOffset, f = e.shapeInfo.texShape, d = f[0], x = f[1], h = `int stride2 = ${r}Shape[3];`, p = `int stride1 = ${r}Shape[2] * stride2;`, m = `int stride0 = ${r}Shape[1] * stride1;`;
|
|
1482
|
+
if (x === c && u == null)
|
|
1279
1483
|
return t ? `
|
|
1280
1484
|
float ${o}(int row, int col, int depth, int depth2) {
|
|
1281
|
-
${
|
|
1485
|
+
${h}
|
|
1282
1486
|
${p}
|
|
1283
1487
|
float texR = float(row);
|
|
1284
1488
|
float texC =
|
|
@@ -1293,13 +1497,13 @@ function lt(e, t) {
|
|
|
1293
1497
|
float texR = float(row);
|
|
1294
1498
|
float texC =
|
|
1295
1499
|
dot(vec3(col, depth, depth2),
|
|
1296
|
-
vec3(${
|
|
1500
|
+
vec3(${i}, ${a}, 1));
|
|
1297
1501
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
1298
|
-
vec2(${
|
|
1502
|
+
vec2(${x}.0, ${d}.0);
|
|
1299
1503
|
return sampleTexture(${r}, uv);
|
|
1300
1504
|
}
|
|
1301
1505
|
`;
|
|
1302
|
-
if (
|
|
1506
|
+
if (x === a && u == null)
|
|
1303
1507
|
return t ? `
|
|
1304
1508
|
float ${o}(int row, int col, int depth, int depth2) {
|
|
1305
1509
|
float texR = dot(vec3(row, col, depth),
|
|
@@ -1315,17 +1519,17 @@ function lt(e, t) {
|
|
|
1315
1519
|
vec3(${n[1] * n[2]}, ${n[2]}, 1));
|
|
1316
1520
|
float texC = float(depth2);
|
|
1317
1521
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
1318
|
-
vec2(${
|
|
1522
|
+
vec2(${x}.0, ${d}.0);
|
|
1319
1523
|
return sampleTexture(${r}, uv);
|
|
1320
1524
|
}
|
|
1321
1525
|
`;
|
|
1322
|
-
const S =
|
|
1526
|
+
const S = O(r);
|
|
1323
1527
|
return t ? `
|
|
1324
1528
|
float ${o}(int row, int col, int depth, int depth2) {
|
|
1325
1529
|
// Explicitly use integer operations as dot() only works on floats.
|
|
1326
|
-
${
|
|
1530
|
+
${h}
|
|
1327
1531
|
${p}
|
|
1328
|
-
${
|
|
1532
|
+
${m}
|
|
1329
1533
|
int index = row * stride0 + col * stride1 +
|
|
1330
1534
|
depth * stride2 + depth2;
|
|
1331
1535
|
vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index + ${S});
|
|
@@ -1334,21 +1538,21 @@ function lt(e, t) {
|
|
|
1334
1538
|
` : `
|
|
1335
1539
|
float ${o}(int row, int col, int depth, int depth2) {
|
|
1336
1540
|
// Explicitly use integer operations as dot() only works on floats.
|
|
1337
|
-
int index = row * ${
|
|
1338
|
-
depth * ${
|
|
1339
|
-
vec2 uv = uvFromFlat(${d}, ${
|
|
1541
|
+
int index = row * ${c} + col * ${i} +
|
|
1542
|
+
depth * ${a} + depth2;
|
|
1543
|
+
vec2 uv = uvFromFlat(${d}, ${x}, index + ${S});
|
|
1340
1544
|
return sampleTexture(${r}, uv);
|
|
1341
1545
|
}
|
|
1342
1546
|
`;
|
|
1343
1547
|
}
|
|
1344
|
-
function
|
|
1345
|
-
const t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), o = t[4],
|
|
1346
|
-
if (
|
|
1347
|
-
const p =
|
|
1548
|
+
function nt(e) {
|
|
1549
|
+
const t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), o = t[4], a = t[3] * o, i = t[2] * a, c = t[1] * i, { newShape: s, keptDims: l } = N(t);
|
|
1550
|
+
if (s.length < t.length) {
|
|
1551
|
+
const p = g(e, s), m = ["row", "col", "depth", "depth2", "depth3"];
|
|
1348
1552
|
return `
|
|
1349
|
-
${
|
|
1553
|
+
${U(p)}
|
|
1350
1554
|
float ${r}(int row, int col, int depth, int depth2, int depth3) {
|
|
1351
|
-
return ${r}(${
|
|
1555
|
+
return ${r}(${b(m, l)});
|
|
1352
1556
|
}
|
|
1353
1557
|
`;
|
|
1354
1558
|
}
|
|
@@ -1357,24 +1561,24 @@ function ft(e) {
|
|
|
1357
1561
|
float ${r}(int row, int col, int depth, int depth2, int depth3) {
|
|
1358
1562
|
float index = dot(
|
|
1359
1563
|
vec4(row, col, depth, depth2),
|
|
1360
|
-
vec4(${
|
|
1564
|
+
vec4(${c}, ${i}, ${a}, ${o})) +
|
|
1361
1565
|
depth3;
|
|
1362
1566
|
${D(e)}
|
|
1363
1567
|
}
|
|
1364
1568
|
`;
|
|
1365
|
-
const
|
|
1366
|
-
if (
|
|
1569
|
+
const u = e.shapeInfo.flatOffset, f = e.shapeInfo.texShape, d = f[0], x = f[1];
|
|
1570
|
+
if (x === c && u == null)
|
|
1367
1571
|
return `
|
|
1368
1572
|
float ${r}(int row, int col, int depth, int depth2, int depth3) {
|
|
1369
1573
|
int texR = row;
|
|
1370
1574
|
float texC = dot(vec4(col, depth, depth2, depth3),
|
|
1371
|
-
vec4(${
|
|
1575
|
+
vec4(${i}, ${a}, ${o}, 1));
|
|
1372
1576
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
1373
|
-
vec2(${
|
|
1577
|
+
vec2(${x}.0, ${d}.0);
|
|
1374
1578
|
return sampleTexture(${n}, uv);
|
|
1375
1579
|
}
|
|
1376
1580
|
`;
|
|
1377
|
-
if (
|
|
1581
|
+
if (x === o && u == null)
|
|
1378
1582
|
return `
|
|
1379
1583
|
float ${r}(int row, int col, int depth, int depth2, int depth3) {
|
|
1380
1584
|
float texR = dot(
|
|
@@ -1383,62 +1587,62 @@ function ft(e) {
|
|
|
1383
1587
|
${t[2] * t[3]}, ${t[3]}, 1));
|
|
1384
1588
|
int texC = depth3;
|
|
1385
1589
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
1386
|
-
vec2(${
|
|
1590
|
+
vec2(${x}.0, ${d}.0);
|
|
1387
1591
|
return sampleTexture(${n}, uv);
|
|
1388
1592
|
}
|
|
1389
1593
|
`;
|
|
1390
|
-
const
|
|
1594
|
+
const h = O(n);
|
|
1391
1595
|
return `
|
|
1392
1596
|
float ${r}(int row, int col, int depth, int depth2, int depth3) {
|
|
1393
1597
|
// Explicitly use integer operations as dot() only works on floats.
|
|
1394
|
-
int index = row * ${
|
|
1395
|
-
depth2 * ${o} + depth3 + ${
|
|
1396
|
-
vec2 uv = uvFromFlat(${d}, ${
|
|
1598
|
+
int index = row * ${c} + col * ${i} + depth * ${a} +
|
|
1599
|
+
depth2 * ${o} + depth3 + ${h};
|
|
1600
|
+
vec2 uv = uvFromFlat(${d}, ${x}, index);
|
|
1397
1601
|
return sampleTexture(${n}, uv);
|
|
1398
1602
|
}
|
|
1399
1603
|
`;
|
|
1400
1604
|
}
|
|
1401
|
-
function
|
|
1402
|
-
const t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), { newShape: o, keptDims:
|
|
1605
|
+
function rt(e) {
|
|
1606
|
+
const t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), { newShape: o, keptDims: a } = N(t);
|
|
1403
1607
|
if (o.length < t.length) {
|
|
1404
|
-
const
|
|
1608
|
+
const m = g(e, o), S = ["row", "col", "depth", "depth2", "depth3", "depth4"];
|
|
1405
1609
|
return `
|
|
1406
|
-
${
|
|
1610
|
+
${U(m)}
|
|
1407
1611
|
float ${r}(int row, int col, int depth,
|
|
1408
1612
|
int depth2, int depth3, int depth4) {
|
|
1409
|
-
return ${r}(${
|
|
1613
|
+
return ${r}(${b(S, a)});
|
|
1410
1614
|
}
|
|
1411
1615
|
`;
|
|
1412
1616
|
}
|
|
1413
|
-
const
|
|
1617
|
+
const i = t[5], c = t[4] * i, s = t[3] * c, l = t[2] * s, u = t[1] * l;
|
|
1414
1618
|
if (e.shapeInfo.isUniform)
|
|
1415
1619
|
return `
|
|
1416
1620
|
float ${r}(int row, int col, int depth,
|
|
1417
1621
|
int depth2, int depth3, int depth4) {
|
|
1418
1622
|
int index = round(dot(
|
|
1419
1623
|
vec4(row, col, depth, depth2),
|
|
1420
|
-
vec4(${
|
|
1624
|
+
vec4(${u}, ${l}, ${s}, ${c})) +
|
|
1421
1625
|
dot(
|
|
1422
1626
|
vec2(depth3, depth4),
|
|
1423
|
-
vec2(${
|
|
1627
|
+
vec2(${i}, 1)));
|
|
1424
1628
|
${D(e)}
|
|
1425
1629
|
}
|
|
1426
1630
|
`;
|
|
1427
|
-
const f = e.shapeInfo.flatOffset, d = e.shapeInfo.texShape,
|
|
1428
|
-
if (
|
|
1631
|
+
const f = e.shapeInfo.flatOffset, d = e.shapeInfo.texShape, x = d[0], h = d[1];
|
|
1632
|
+
if (h === u && f == null)
|
|
1429
1633
|
return `
|
|
1430
1634
|
float ${r}(int row, int col, int depth,
|
|
1431
1635
|
int depth2, int depth3, int depth4) {
|
|
1432
1636
|
int texR = row;
|
|
1433
1637
|
float texC = dot(vec4(col, depth, depth2, depth3),
|
|
1434
|
-
vec4(${
|
|
1638
|
+
vec4(${l}, ${s}, ${c}, ${i})) +
|
|
1435
1639
|
float(depth4);
|
|
1436
1640
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
1437
|
-
vec2(${
|
|
1641
|
+
vec2(${h}.0, ${x}.0);
|
|
1438
1642
|
return sampleTexture(${n}, uv);
|
|
1439
1643
|
}
|
|
1440
1644
|
`;
|
|
1441
|
-
if (
|
|
1645
|
+
if (h === i && f == null)
|
|
1442
1646
|
return `
|
|
1443
1647
|
float ${r}(int row, int col, int depth,
|
|
1444
1648
|
int depth2, int depth3, int depth4) {
|
|
@@ -1449,18 +1653,18 @@ function ht(e) {
|
|
|
1449
1653
|
${t[4]})) + float(depth3);
|
|
1450
1654
|
int texC = depth4;
|
|
1451
1655
|
vec2 uv = (vec2(texC, texR) + halfCR) /
|
|
1452
|
-
vec2(${
|
|
1656
|
+
vec2(${h}.0, ${x}.0);
|
|
1453
1657
|
return sampleTexture(${n}, uv);
|
|
1454
1658
|
}
|
|
1455
1659
|
`;
|
|
1456
|
-
const p =
|
|
1660
|
+
const p = O(n);
|
|
1457
1661
|
return `
|
|
1458
1662
|
float ${r}(int row, int col, int depth,
|
|
1459
1663
|
int depth2, int depth3, int depth4) {
|
|
1460
1664
|
// Explicitly use integer operations as dot() only works on floats.
|
|
1461
|
-
int index = row * ${
|
|
1462
|
-
depth2 * ${
|
|
1463
|
-
vec2 uv = uvFromFlat(${
|
|
1665
|
+
int index = row * ${u} + col * ${l} + depth * ${s} +
|
|
1666
|
+
depth2 * ${c} + depth3 * ${i} + depth4 + ${p};
|
|
1667
|
+
vec2 uv = uvFromFlat(${x}, ${h}, index);
|
|
1464
1668
|
return sampleTexture(${n}, uv);
|
|
1465
1669
|
}
|
|
1466
1670
|
`;
|
|
@@ -1475,62 +1679,62 @@ function D(e) {
|
|
|
1475
1679
|
}
|
|
1476
1680
|
`;
|
|
1477
1681
|
}
|
|
1478
|
-
function
|
|
1479
|
-
const n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), o = "get" + r + "AtOutCoords",
|
|
1480
|
-
let
|
|
1682
|
+
function ot(e, t) {
|
|
1683
|
+
const n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), o = "get" + r + "AtOutCoords", a = e.shapeInfo.logicalShape.length, i = t.logicalShape.length, c = ee(e.shapeInfo.logicalShape, t.logicalShape), s = re(i), l = i - a;
|
|
1684
|
+
let u;
|
|
1481
1685
|
const f = ["x", "y", "z", "w", "u", "v"];
|
|
1482
|
-
|
|
1686
|
+
a === 0 ? u = "" : i < 2 && c.length >= 1 ? u = "coords = 0;" : u = c.map((R) => `coords.${f[R + l]} = 0;`).join(`
|
|
1483
1687
|
`);
|
|
1484
1688
|
let d = "";
|
|
1485
|
-
|
|
1486
|
-
let
|
|
1689
|
+
i < 2 && a > 0 ? d = "coords" : d = e.shapeInfo.logicalShape.map((R, F) => `coords.${f[F + l]}`).join(", ");
|
|
1690
|
+
let x = "return outputValue;";
|
|
1487
1691
|
const p = E(e.shapeInfo.logicalShape) === 1, S = E(t.logicalShape) === 1;
|
|
1488
|
-
if (
|
|
1489
|
-
|
|
1692
|
+
if (a === 1 && !p && !S)
|
|
1693
|
+
x = `
|
|
1490
1694
|
return vec4(outputValue.xy, outputValue.xy);
|
|
1491
1695
|
`;
|
|
1492
1696
|
else if (p && !S)
|
|
1493
|
-
|
|
1697
|
+
i === 1 ? x = `
|
|
1494
1698
|
return vec4(outputValue.x, outputValue.x, 0., 0.);
|
|
1495
|
-
` :
|
|
1699
|
+
` : x = `
|
|
1496
1700
|
return vec4(outputValue.x);
|
|
1497
1701
|
`;
|
|
1498
|
-
else if (
|
|
1499
|
-
const R =
|
|
1500
|
-
|
|
1702
|
+
else if (c.length) {
|
|
1703
|
+
const R = a - 2, F = a - 1;
|
|
1704
|
+
c.indexOf(R) > -1 && c.indexOf(F) > -1 ? x = "return vec4(outputValue.x);" : c.indexOf(R) > -1 ? x = "return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);" : c.indexOf(F) > -1 && (x = "return vec4(outputValue.xx, outputValue.zz);");
|
|
1501
1705
|
}
|
|
1502
1706
|
return `
|
|
1503
1707
|
vec4 ${o}() {
|
|
1504
|
-
${
|
|
1505
|
-
${
|
|
1708
|
+
${s} coords = getOutputCoords();
|
|
1709
|
+
${u}
|
|
1506
1710
|
vec4 outputValue = get${r}(${d});
|
|
1507
|
-
${
|
|
1711
|
+
${x}
|
|
1508
1712
|
}
|
|
1509
1713
|
`;
|
|
1510
1714
|
}
|
|
1511
|
-
function
|
|
1512
|
-
const n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), o = "get" + r + "AtOutCoords",
|
|
1513
|
-
if (!e.shapeInfo.isUniform &&
|
|
1715
|
+
function at(e, t) {
|
|
1716
|
+
const n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), o = "get" + r + "AtOutCoords", a = t.texShape, i = e.shapeInfo.texShape, c = e.shapeInfo.logicalShape.length, s = t.logicalShape.length;
|
|
1717
|
+
if (!e.shapeInfo.isUniform && c === s && e.shapeInfo.flatOffset == null && T(i, a))
|
|
1514
1718
|
return `
|
|
1515
1719
|
float ${o}() {
|
|
1516
1720
|
return sampleTexture(${n}, resultUV);
|
|
1517
1721
|
}
|
|
1518
1722
|
`;
|
|
1519
|
-
const
|
|
1723
|
+
const l = re(s), u = ee(e.shapeInfo.logicalShape, t.logicalShape), f = s - c;
|
|
1520
1724
|
let d;
|
|
1521
|
-
const
|
|
1522
|
-
|
|
1725
|
+
const x = ["x", "y", "z", "w", "u", "v"];
|
|
1726
|
+
c === 0 ? d = "" : s < 2 && u.length >= 1 ? d = "coords = 0;" : d = u.map((p) => `coords.${x[p + f]} = 0;`).join(`
|
|
1523
1727
|
`);
|
|
1524
|
-
let
|
|
1525
|
-
return
|
|
1728
|
+
let h = "";
|
|
1729
|
+
return s < 2 && c > 0 ? h = "coords" : h = e.shapeInfo.logicalShape.map((p, m) => `coords.${x[m + f]}`).join(", "), `
|
|
1526
1730
|
float ${o}() {
|
|
1527
|
-
${
|
|
1731
|
+
${l} coords = getOutputCoords();
|
|
1528
1732
|
${d}
|
|
1529
|
-
return get${r}(${
|
|
1733
|
+
return get${r}(${h});
|
|
1530
1734
|
}
|
|
1531
1735
|
`;
|
|
1532
1736
|
}
|
|
1533
|
-
function
|
|
1737
|
+
function re(e) {
|
|
1534
1738
|
if (e <= 1)
|
|
1535
1739
|
return "int";
|
|
1536
1740
|
if (e === 2)
|
|
@@ -1545,419 +1749,41 @@ function he(e) {
|
|
|
1545
1749
|
return "ivec6";
|
|
1546
1750
|
throw Error(`GPU for rank ${e} is not yet supported`);
|
|
1547
1751
|
}
|
|
1548
|
-
function
|
|
1549
|
-
const { newShape: r, keptDims: o } =
|
|
1550
|
-
return { useSqueezeShape:
|
|
1752
|
+
function z(e, t, n) {
|
|
1753
|
+
const { newShape: r, keptDims: o } = N(t), a = t.length, i = e && a === 3 && t[0] === 1, c = i ? t.slice(1) : r, s = !e && a > 1 && !T(t, n) && r.length < a || i;
|
|
1754
|
+
return { useSqueezeShape: s, uniformShape: s ? c : t, keptDims: o };
|
|
1551
1755
|
}
|
|
1552
|
-
function
|
|
1756
|
+
function g(e, t) {
|
|
1553
1757
|
const n = JSON.parse(JSON.stringify(e));
|
|
1554
1758
|
return n.shapeInfo.logicalShape = t, n;
|
|
1555
1759
|
}
|
|
1556
|
-
function
|
|
1760
|
+
function b(e, t) {
|
|
1557
1761
|
return t.map((n) => e[n]).join(", ");
|
|
1558
1762
|
}
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
antialias: !1,
|
|
1562
|
-
premultipliedAlpha: !1,
|
|
1563
|
-
preserveDrawingBuffer: !1,
|
|
1564
|
-
depth: !1,
|
|
1565
|
-
stencil: !1,
|
|
1566
|
-
failIfMajorPerformanceCaveat: !0
|
|
1567
|
-
};
|
|
1568
|
-
function Bt(e, t) {
|
|
1569
|
-
A[e] = t;
|
|
1570
|
-
}
|
|
1571
|
-
function _(e, t) {
|
|
1572
|
-
if (!(e in A) || t != null) {
|
|
1573
|
-
const r = vt(e, t);
|
|
1574
|
-
if (r !== null)
|
|
1575
|
-
A[e] = r;
|
|
1576
|
-
else
|
|
1577
|
-
return console.log("Could not get context for WebGL version", e), null;
|
|
1578
|
-
}
|
|
1579
|
-
const n = A[e];
|
|
1580
|
-
return n == null || n.isContextLost() ? (delete A[e], _(e)) : (n.disable(n.DEPTH_TEST), n.disable(n.STENCIL_TEST), n.disable(n.BLEND), n.disable(n.DITHER), n.disable(n.POLYGON_OFFSET_FILL), n.disable(n.SAMPLE_COVERAGE), n.enable(n.SCISSOR_TEST), n.enable(n.CULL_FACE), n.cullFace(n.BACK), A[e]);
|
|
1581
|
-
}
|
|
1582
|
-
function pt(e) {
|
|
1583
|
-
if (!v().getBool("IS_SAFARI") && typeof OffscreenCanvas < "u" && e === 2)
|
|
1584
|
-
return new OffscreenCanvas(300, 150);
|
|
1585
|
-
if (typeof document < "u")
|
|
1586
|
-
return document.createElement("canvas");
|
|
1587
|
-
throw new Error("Cannot create a canvas in this context");
|
|
1588
|
-
}
|
|
1589
|
-
function vt(e, t) {
|
|
1590
|
-
if (e !== 1 && e !== 2)
|
|
1591
|
-
throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");
|
|
1592
|
-
const n = t ?? pt(e);
|
|
1593
|
-
return n.addEventListener("webglcontextlost", (r) => {
|
|
1594
|
-
r.preventDefault(), delete A[e];
|
|
1595
|
-
}, !1), v().getBool("SOFTWARE_WEBGL_ENABLED") && (k.failIfMajorPerformanceCaveat = !1), e === 1 ? (
|
|
1596
|
-
// tslint:disable-next-line
|
|
1597
|
-
n.getContext("webgl", k) || n.getContext("experimental-webgl", k)
|
|
1598
|
-
) : n.getContext("webgl2", k);
|
|
1599
|
-
}
|
|
1600
|
-
var ee;
|
|
1601
|
-
(function(e) {
|
|
1602
|
-
e[e.DENSE = 0] = "DENSE", e[e.SHARED_BATCH = 1] = "SHARED_BATCH";
|
|
1603
|
-
})(ee || (ee = {}));
|
|
1604
|
-
var te;
|
|
1605
|
-
(function(e) {
|
|
1606
|
-
e[e.RENDER = 0] = "RENDER", e[e.UPLOAD = 1] = "UPLOAD", e[e.PIXELS = 2] = "PIXELS", e[e.DOWNLOAD = 3] = "DOWNLOAD";
|
|
1607
|
-
})(te || (te = {}));
|
|
1608
|
-
var ne;
|
|
1609
|
-
(function(e) {
|
|
1610
|
-
e[e.UNPACKED_FLOAT16 = 0] = "UNPACKED_FLOAT16", e[e.UNPACKED_FLOAT32 = 1] = "UNPACKED_FLOAT32", e[e.PACKED_4X1_UNSIGNED_BYTE = 2] = "PACKED_4X1_UNSIGNED_BYTE", e[e.PACKED_2X2_FLOAT32 = 3] = "PACKED_2X2_FLOAT32", e[e.PACKED_2X2_FLOAT16 = 4] = "PACKED_2X2_FLOAT16";
|
|
1611
|
-
})(ne || (ne = {}));
|
|
1612
|
-
function kt(e, t) {
|
|
1613
|
-
return [t, e];
|
|
1614
|
-
}
|
|
1615
|
-
function Pt(e, t) {
|
|
1616
|
-
return e * t;
|
|
1617
|
-
}
|
|
1618
|
-
function Vt(e) {
|
|
1619
|
-
const t = E(e), n = Math.ceil(t / 4);
|
|
1620
|
-
return H(n);
|
|
1621
|
-
}
|
|
1622
|
-
function mt(e, t) {
|
|
1623
|
-
return [
|
|
1624
|
-
Math.max(1, Math.ceil(t / 2)),
|
|
1625
|
-
Math.max(1, Math.ceil(e / 2))
|
|
1626
|
-
];
|
|
1627
|
-
}
|
|
1628
|
-
function Wt(e, t) {
|
|
1629
|
-
const [n, r] = mt(e, t);
|
|
1630
|
-
return n * r * 4;
|
|
1631
|
-
}
|
|
1632
|
-
function de(e, t) {
|
|
1633
|
-
const n = e;
|
|
1634
|
-
let r, o, i, a, s, c, u, l, f, d;
|
|
1635
|
-
return v().getNumber("WEBGL_VERSION") === 2 ? (r = n.R32F, o = n.R16F, i = n.RGBA16F, a = n.RGBA32F, s = n.RED, u = 4, l = 1, f = n.HALF_FLOAT, d = n.FLOAT, c = n.RGBA8) : (r = e.RGBA, o = e.RGBA, i = e.RGBA, a = n.RGBA, s = e.RGBA, u = 4, l = 4, f = t != null ? t.HALF_FLOAT_OES : null, d = e.FLOAT, c = e.RGBA), {
|
|
1636
|
-
internalFormatFloat: r,
|
|
1637
|
-
internalFormatHalfFloat: o,
|
|
1638
|
-
internalFormatPackedHalfFloat: i,
|
|
1639
|
-
internalFormatPackedFloat: a,
|
|
1640
|
-
textureFormatFloat: s,
|
|
1641
|
-
downloadTextureFormat: c,
|
|
1642
|
-
downloadUnpackNumChannels: u,
|
|
1643
|
-
defaultNumChannels: l,
|
|
1644
|
-
textureTypeHalfFloat: f,
|
|
1645
|
-
textureTypeFloat: d
|
|
1646
|
-
};
|
|
1647
|
-
}
|
|
1648
|
-
function m(e, t) {
|
|
1649
|
-
const n = t();
|
|
1650
|
-
return v().getBool("DEBUG") && $t(e), n;
|
|
1651
|
-
}
|
|
1652
|
-
function $t(e) {
|
|
1653
|
-
const t = e.getError();
|
|
1654
|
-
if (t !== e.NO_ERROR)
|
|
1655
|
-
throw new Error("WebGL Error: " + Rt(e, t));
|
|
1656
|
-
}
|
|
1657
|
-
const Tt = 596e-10, St = 65504;
|
|
1658
|
-
function Xt(e) {
|
|
1659
|
-
return !!(v().getBool("WEBGL_RENDER_FLOAT32_ENABLED") || e === 0 || Tt < Math.abs(e) && Math.abs(e) < St);
|
|
1660
|
-
}
|
|
1661
|
-
function Rt(e, t) {
|
|
1662
|
-
switch (t) {
|
|
1663
|
-
case e.NO_ERROR:
|
|
1664
|
-
return "NO_ERROR";
|
|
1665
|
-
case e.INVALID_ENUM:
|
|
1666
|
-
return "INVALID_ENUM";
|
|
1667
|
-
case e.INVALID_VALUE:
|
|
1668
|
-
return "INVALID_VALUE";
|
|
1669
|
-
case e.INVALID_OPERATION:
|
|
1670
|
-
return "INVALID_OPERATION";
|
|
1671
|
-
case e.INVALID_FRAMEBUFFER_OPERATION:
|
|
1672
|
-
return "INVALID_FRAMEBUFFER_OPERATION";
|
|
1673
|
-
case e.OUT_OF_MEMORY:
|
|
1674
|
-
return "OUT_OF_MEMORY";
|
|
1675
|
-
case e.CONTEXT_LOST_WEBGL:
|
|
1676
|
-
return "CONTEXT_LOST_WEBGL";
|
|
1677
|
-
default:
|
|
1678
|
-
return `Unknown error code ${t}`;
|
|
1679
|
-
}
|
|
1680
|
-
}
|
|
1681
|
-
function Ht(e, t) {
|
|
1682
|
-
return C(e, () => e.getExtension(t), 'Extension "' + t + '" not supported on this browser.');
|
|
1683
|
-
}
|
|
1684
|
-
function Gt(e, t) {
|
|
1685
|
-
const n = C(e, () => e.createShader(e.VERTEX_SHADER), "Unable to create vertex WebGLShader.");
|
|
1686
|
-
if (m(e, () => e.shaderSource(n, t)), m(e, () => e.compileShader(n)), e.getShaderParameter(n, e.COMPILE_STATUS) === !1)
|
|
1687
|
-
throw console.log(e.getShaderInfoLog(n)), new Error("Failed to compile vertex shader.");
|
|
1688
|
-
return n;
|
|
1689
|
-
}
|
|
1690
|
-
function Et(e, t) {
|
|
1691
|
-
const n = C(e, () => e.createShader(e.FRAGMENT_SHADER), "Unable to create fragment WebGLShader.");
|
|
1692
|
-
if (m(e, () => e.shaderSource(n, t)), m(e, () => e.compileShader(n)), v().get("ENGINE_COMPILE_ONLY"))
|
|
1693
|
-
return n;
|
|
1694
|
-
if (e.getShaderParameter(n, e.COMPILE_STATUS) === !1)
|
|
1695
|
-
throw wt(t, e.getShaderInfoLog(n)), new Error("Failed to compile fragment shader.");
|
|
1696
|
-
return n;
|
|
1697
|
-
}
|
|
1698
|
-
const Ct = /ERROR: [0-9]+:([0-9]+):/g;
|
|
1699
|
-
function wt(e, t) {
|
|
1700
|
-
const n = Ct.exec(t);
|
|
1701
|
-
if (n == null) {
|
|
1702
|
-
console.log(`Couldn't parse line number in error: ${t}`), console.log(e);
|
|
1703
|
-
return;
|
|
1704
|
-
}
|
|
1705
|
-
const r = +n[1], o = e.split(`
|
|
1706
|
-
`), i = o.length.toString().length + 2, a = o.map((f, d) => Y((d + 1).toString(), i) + f);
|
|
1707
|
-
let s = 0;
|
|
1708
|
-
for (let f = 0; f < a.length; f++)
|
|
1709
|
-
s = Math.max(a[f].length, s);
|
|
1710
|
-
const c = a.slice(0, r - 1), u = a.slice(r - 1, r), l = a.slice(r);
|
|
1711
|
-
console.log(c.join(`
|
|
1712
|
-
`)), console.log(t.split(`
|
|
1713
|
-
`)[0]), console.log(`%c ${Y(u[0], s)}`, "border:1px solid red; background-color:#e3d2d2; color:#a61717"), console.log(l.join(`
|
|
1714
|
-
`));
|
|
1715
|
-
}
|
|
1716
|
-
function zt(e) {
|
|
1717
|
-
return C(e, () => e.createProgram(), "Unable to create WebGLProgram.");
|
|
1718
|
-
}
|
|
1719
|
-
function qt(e, t) {
|
|
1720
|
-
if (m(e, () => e.linkProgram(t)), !v().get("ENGINE_COMPILE_ONLY") && e.getProgramParameter(t, e.LINK_STATUS) === !1)
|
|
1721
|
-
throw console.log(e.getProgramInfoLog(t)), new Error("Failed to link vertex and fragment shaders.");
|
|
1722
|
-
}
|
|
1723
|
-
function jt(e, t) {
|
|
1724
|
-
if (m(e, () => e.validateProgram(t)), e.getProgramParameter(t, e.VALIDATE_STATUS) === !1)
|
|
1725
|
-
throw console.log(e.getProgramInfoLog(t)), new Error("Shader program validation failed.");
|
|
1726
|
-
}
|
|
1727
|
-
function Jt(e, t) {
|
|
1728
|
-
const n = C(e, () => e.createBuffer(), "Unable to create WebGLBuffer");
|
|
1729
|
-
return m(e, () => e.bindBuffer(e.ARRAY_BUFFER, n)), m(e, () => e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW)), n;
|
|
1730
|
-
}
|
|
1731
|
-
function Yt(e, t) {
|
|
1732
|
-
const n = C(e, () => e.createBuffer(), "Unable to create WebGLBuffer");
|
|
1733
|
-
return m(e, () => e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, n)), m(e, () => e.bufferData(e.ELEMENT_ARRAY_BUFFER, t, e.STATIC_DRAW)), n;
|
|
1734
|
-
}
|
|
1735
|
-
function Kt(e) {
|
|
1736
|
-
return C(e, () => e.createTexture(), "Unable to create WebGLTexture.");
|
|
1737
|
-
}
|
|
1738
|
-
function Zt(e, t) {
|
|
1739
|
-
const n = v().getNumber("WEBGL_MAX_TEXTURE_SIZE");
|
|
1740
|
-
if (e <= 0 || t <= 0) {
|
|
1741
|
-
const r = `[${e}x${t}]`;
|
|
1742
|
-
throw new Error("Requested texture size " + r + " is invalid.");
|
|
1743
|
-
}
|
|
1744
|
-
if (e > n || t > n) {
|
|
1745
|
-
const r = `[${e}x${t}]`, o = `[${n}x${n}]`;
|
|
1746
|
-
throw new Error("Requested texture size " + r + " greater than WebGL maximum on this browser / GPU " + o + ".");
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
function Qt(e) {
|
|
1750
|
-
return C(e, () => e.createFramebuffer(), "Unable to create WebGLFramebuffer.");
|
|
1751
|
-
}
|
|
1752
|
-
function en(e, t, n, r, o, i, a) {
|
|
1753
|
-
const s = e.getAttribLocation(t, n);
|
|
1754
|
-
return s === -1 ? !1 : (m(e, () => e.bindBuffer(e.ARRAY_BUFFER, r)), m(e, () => e.vertexAttribPointer(s, o, e.FLOAT, !1, i, a)), m(e, () => e.enableVertexAttribArray(s)), !0);
|
|
1755
|
-
}
|
|
1756
|
-
function Ft(e, t, n) {
|
|
1757
|
-
_t(e, n), m(e, () => e.activeTexture(e.TEXTURE0 + n)), m(e, () => e.bindTexture(e.TEXTURE_2D, t));
|
|
1758
|
-
}
|
|
1759
|
-
function tn(e, t, n) {
|
|
1760
|
-
return C(e, () => e.getUniformLocation(t, n), 'uniform "' + n + '" not present in program.');
|
|
1761
|
-
}
|
|
1762
|
-
function nn(e, t, n) {
|
|
1763
|
-
return e.getUniformLocation(t, n);
|
|
1764
|
-
}
|
|
1765
|
-
function rn(e, t, n, r) {
|
|
1766
|
-
m(e, () => Ft(e, t, r)), m(e, () => e.uniform1i(n, r));
|
|
1767
|
-
}
|
|
1768
|
-
function on(e, t, n) {
|
|
1769
|
-
m(e, () => e.bindFramebuffer(e.FRAMEBUFFER, n)), m(e, () => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, t, 0));
|
|
1770
|
-
}
|
|
1771
|
-
function an(e, t) {
|
|
1772
|
-
m(e, () => e.bindFramebuffer(e.FRAMEBUFFER, t)), m(e, () => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, null, 0));
|
|
1773
|
-
}
|
|
1774
|
-
function cn(e) {
|
|
1775
|
-
const t = e.checkFramebufferStatus(e.FRAMEBUFFER);
|
|
1776
|
-
if (t !== e.FRAMEBUFFER_COMPLETE)
|
|
1777
|
-
throw new Error("Error binding framebuffer: " + gt(e, t));
|
|
1778
|
-
}
|
|
1779
|
-
function gt(e, t) {
|
|
1780
|
-
switch (t) {
|
|
1781
|
-
case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
|
1782
|
-
return "FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
|
|
1783
|
-
case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
|
1784
|
-
return "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
|
|
1785
|
-
case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
|
|
1786
|
-
return "FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
|
|
1787
|
-
case e.FRAMEBUFFER_UNSUPPORTED:
|
|
1788
|
-
return "FRAMEBUFFER_UNSUPPORTED";
|
|
1789
|
-
default:
|
|
1790
|
-
return `unknown error ${t}`;
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
function C(e, t, n) {
|
|
1794
|
-
const r = m(e, () => t());
|
|
1795
|
-
if (r == null)
|
|
1796
|
-
throw new Error(n);
|
|
1797
|
-
return r;
|
|
1798
|
-
}
|
|
1799
|
-
function _t(e, t) {
|
|
1800
|
-
const n = e.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1, r = t + e.TEXTURE0;
|
|
1801
|
-
if (r < e.TEXTURE0 || r > n) {
|
|
1802
|
-
const o = `[gl.TEXTURE0, gl.TEXTURE${n}]`;
|
|
1803
|
-
throw new Error(`textureUnit must be in ${o}.`);
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
function xe(e, t = 2) {
|
|
1807
|
-
return E(e.slice(0, e.length - t));
|
|
1808
|
-
}
|
|
1809
|
-
function pe(e) {
|
|
1810
|
-
if (e.length === 0)
|
|
1811
|
-
throw Error("Cannot get rows and columns of an empty shape array.");
|
|
1812
|
-
return [
|
|
1813
|
-
e.length > 1 ? e[e.length - 2] : 1,
|
|
1814
|
-
e[e.length - 1]
|
|
1815
|
-
];
|
|
1816
|
-
}
|
|
1817
|
-
function sn(e) {
|
|
1818
|
-
let t = [1, 1, 1];
|
|
1819
|
-
return e.length === 0 || e.length === 1 && e[0] === 1 || (t = [xe(e), ...pe(e)]), t;
|
|
1820
|
-
}
|
|
1821
|
-
function un(e, t = !1) {
|
|
1822
|
-
let n = v().getNumber("WEBGL_MAX_TEXTURE_SIZE"), r = v().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");
|
|
1823
|
-
r === 1 / 0 && v().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE") && (r = n / 2), t && (n = n * 2, r = r * 2, e = e.map((s, c) => c >= e.length - 2 ? Te(e[c]) : e[c]), e.length === 1 && (e = [2, e[0]])), e.length !== 2 && (e = I(e).newShape);
|
|
1824
|
-
let o = E(e), i = null;
|
|
1825
|
-
e.length <= 1 && o <= n ? i = [1, o] : e.length === 2 && e[0] <= n && e[1] <= n ? i = e : e.length === 3 && e[0] * e[1] <= n && e[2] <= n ? i = [e[0] * e[1], e[2]] : e.length === 3 && e[0] <= n && e[1] * e[2] <= n ? i = [e[0], e[1] * e[2]] : e.length === 4 && e[0] * e[1] * e[2] <= n && e[3] <= n ? i = [e[0] * e[1] * e[2], e[3]] : e.length === 4 && e[0] <= n && e[1] * e[2] * e[3] <= n && (i = [e[0], e[1] * e[2] * e[3]]);
|
|
1826
|
-
const a = i != null && Math.max(...i) > r && Math.min(...i) <= (t ? 2 : 1) && Math.min(...i) > 0;
|
|
1827
|
-
if (i == null || a)
|
|
1828
|
-
if (t) {
|
|
1829
|
-
const s = xe(e);
|
|
1830
|
-
let c = 2, u = 2;
|
|
1831
|
-
e.length && ([c, u] = pe(e)), o = s * (c / 2) * (u / 2), i = H(o).map((l) => l * 2);
|
|
1832
|
-
} else
|
|
1833
|
-
i = H(o);
|
|
1834
|
-
return i;
|
|
1835
|
-
}
|
|
1836
|
-
function P(e) {
|
|
1837
|
-
return e % 2 === 0;
|
|
1838
|
-
}
|
|
1839
|
-
function ln(e, t) {
|
|
1840
|
-
if (e = e.slice(-2), t = t.slice(-2), T(e, t) || !e.length || !t.length || e[0] === 0 || e[1] === 0 || t[0] === 0 || t[1] === 0)
|
|
1841
|
-
return !0;
|
|
1842
|
-
if (e.length !== t.length) {
|
|
1843
|
-
const n = e[e.length - 1], r = t[t.length - 1];
|
|
1844
|
-
if (n === r || P(n) && P(r) && (e[0] === 1 || t[0] === 1))
|
|
1845
|
-
return !0;
|
|
1846
|
-
}
|
|
1847
|
-
return e[1] === t[1] && P(e[0]) && P(t[0]);
|
|
1848
|
-
}
|
|
1849
|
-
let W, X;
|
|
1850
|
-
function fn(e) {
|
|
1851
|
-
if (W == null) {
|
|
1852
|
-
const t = _(e);
|
|
1853
|
-
W = t.getParameter(t.MAX_TEXTURE_SIZE);
|
|
1854
|
-
}
|
|
1855
|
-
return W;
|
|
1856
|
-
}
|
|
1857
|
-
function hn(e) {
|
|
1858
|
-
if (X == null) {
|
|
1859
|
-
const t = _(e);
|
|
1860
|
-
X = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);
|
|
1861
|
-
}
|
|
1862
|
-
return Math.min(16, X);
|
|
1863
|
-
}
|
|
1864
|
-
function dn(e) {
|
|
1865
|
-
if (e === 0)
|
|
1866
|
-
return 0;
|
|
1867
|
-
let t;
|
|
1868
|
-
const n = _(e);
|
|
1869
|
-
return g(n, "EXT_disjoint_timer_query_webgl2") && e === 2 ? t = 2 : g(n, "EXT_disjoint_timer_query") ? t = 1 : t = 0, t;
|
|
1870
|
-
}
|
|
1871
|
-
function g(e, t) {
|
|
1872
|
-
return e.getExtension(t) != null;
|
|
1873
|
-
}
|
|
1874
|
-
function xn(e) {
|
|
1875
|
-
try {
|
|
1876
|
-
if (_(e) != null)
|
|
1877
|
-
return !0;
|
|
1878
|
-
} catch (t) {
|
|
1879
|
-
return console.log("Error when getting WebGL context: ", t), !1;
|
|
1880
|
-
}
|
|
1881
|
-
return !1;
|
|
1882
|
-
}
|
|
1883
|
-
function pn(e) {
|
|
1884
|
-
if (e === 0)
|
|
1885
|
-
return !1;
|
|
1886
|
-
const t = _(e);
|
|
1887
|
-
if (e === 1) {
|
|
1888
|
-
if (!g(t, "OES_texture_float"))
|
|
1889
|
-
return !1;
|
|
1890
|
-
} else if (!g(t, "EXT_color_buffer_float"))
|
|
1891
|
-
return !1;
|
|
1892
|
-
return G(t);
|
|
1893
|
-
}
|
|
1894
|
-
function vn(e) {
|
|
1895
|
-
if (e === 0)
|
|
1896
|
-
return !1;
|
|
1897
|
-
const t = _(e);
|
|
1898
|
-
if (e === 1) {
|
|
1899
|
-
if (!g(t, "OES_texture_float") || !g(t, "WEBGL_color_buffer_float"))
|
|
1900
|
-
return !1;
|
|
1901
|
-
} else {
|
|
1902
|
-
if (g(t, "EXT_color_buffer_float"))
|
|
1903
|
-
return G(t);
|
|
1904
|
-
const r = "EXT_color_buffer_half_float";
|
|
1905
|
-
if (g(t, r)) {
|
|
1906
|
-
const o = t.getExtension(r);
|
|
1907
|
-
return At(t, o);
|
|
1908
|
-
}
|
|
1909
|
-
return !1;
|
|
1910
|
-
}
|
|
1911
|
-
return G(t);
|
|
1912
|
-
}
|
|
1913
|
-
function G(e) {
|
|
1914
|
-
const t = de(e), n = e.createTexture();
|
|
1915
|
-
e.bindTexture(e.TEXTURE_2D, n), e.texImage2D(e.TEXTURE_2D, 0, t.internalFormatFloat, 1, 1, 0, t.textureFormatFloat, t.textureTypeFloat, null);
|
|
1916
|
-
const i = e.createFramebuffer();
|
|
1917
|
-
e.bindFramebuffer(e.FRAMEBUFFER, i), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, n, 0);
|
|
1918
|
-
const a = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE;
|
|
1919
|
-
return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(n), e.deleteFramebuffer(i), a;
|
|
1920
|
-
}
|
|
1921
|
-
function At(e, t) {
|
|
1922
|
-
const n = de(e, t), r = e.createTexture();
|
|
1923
|
-
e.bindTexture(e.TEXTURE_2D, r), e.texImage2D(e.TEXTURE_2D, 0, n.internalFormatHalfFloat, 1, 1, 0, n.textureFormatFloat, n.textureTypeHalfFloat, null);
|
|
1924
|
-
const a = e.createFramebuffer();
|
|
1925
|
-
e.bindFramebuffer(e.FRAMEBUFFER, a), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, r, 0);
|
|
1926
|
-
const s = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE;
|
|
1927
|
-
return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(r), e.deleteFramebuffer(a), s;
|
|
1928
|
-
}
|
|
1929
|
-
function mn(e) {
|
|
1930
|
-
return e !== 2 ? !1 : _(e).fenceSync != null;
|
|
1931
|
-
}
|
|
1932
|
-
function $n(e, t) {
|
|
1933
|
-
Array.isArray(e) || (e = [e]), e.forEach((n) => {
|
|
1934
|
-
n != null && F(n.dtype !== "complex64", () => `${t} does not support complex64 tensors in the WebGL backend.`);
|
|
1935
|
-
});
|
|
1936
|
-
}
|
|
1937
|
-
function Tn(e, t, n, r) {
|
|
1938
|
-
const o = n.map((l, f) => {
|
|
1763
|
+
function qt(e, t, n, r) {
|
|
1764
|
+
const o = n.map((u, f) => {
|
|
1939
1765
|
const d = {
|
|
1940
|
-
logicalShape:
|
|
1941
|
-
texShape:
|
|
1942
|
-
isUniform:
|
|
1943
|
-
isPacked:
|
|
1766
|
+
logicalShape: u.shape,
|
|
1767
|
+
texShape: u.isUniform ? null : u.texData.texShape,
|
|
1768
|
+
isUniform: u.isUniform,
|
|
1769
|
+
isPacked: u.isUniform ? !1 : u.texData.isPacked,
|
|
1944
1770
|
flatOffset: null
|
|
1945
1771
|
};
|
|
1946
|
-
return
|
|
1947
|
-
}),
|
|
1772
|
+
return u.texData != null && u.texData.slice != null && u.texData.slice.flatOffset > 0 && (d.flatOffset = u.texData.slice.flatOffset), { name: t.variableNames[f], shapeInfo: d };
|
|
1773
|
+
}), a = o.map((u) => u.shapeInfo), i = {
|
|
1948
1774
|
logicalShape: r.shape,
|
|
1949
1775
|
texShape: r.texData.texShape,
|
|
1950
1776
|
isUniform: !1,
|
|
1951
1777
|
isPacked: r.texData.isPacked,
|
|
1952
1778
|
flatOffset: null
|
|
1953
|
-
},
|
|
1954
|
-
return
|
|
1779
|
+
}, c = Fe(o, i, t), s = ve(e.gl, c), l = e.createProgram(s);
|
|
1780
|
+
return $().get("ENGINE_COMPILE_ONLY") ? {
|
|
1955
1781
|
program: t,
|
|
1956
|
-
fragmentShader:
|
|
1957
|
-
source:
|
|
1958
|
-
webGLProgram:
|
|
1959
|
-
inShapeInfos:
|
|
1960
|
-
outShapeInfo:
|
|
1782
|
+
fragmentShader: s,
|
|
1783
|
+
source: c,
|
|
1784
|
+
webGLProgram: l,
|
|
1785
|
+
inShapeInfos: a,
|
|
1786
|
+
outShapeInfo: i,
|
|
1961
1787
|
variablesLocations: null,
|
|
1962
1788
|
customUniformLocations: null,
|
|
1963
1789
|
infLoc: null,
|
|
@@ -1965,232 +1791,232 @@ function Tn(e, t, n, r) {
|
|
|
1965
1791
|
outShapeLocation: null,
|
|
1966
1792
|
outShapeStridesLocation: null,
|
|
1967
1793
|
outTexShapeLocation: null
|
|
1968
|
-
} : (e.buildVao(
|
|
1794
|
+
} : (e.buildVao(l), Object.assign({
|
|
1969
1795
|
program: t,
|
|
1970
|
-
fragmentShader:
|
|
1971
|
-
source:
|
|
1972
|
-
webGLProgram:
|
|
1973
|
-
inShapeInfos:
|
|
1974
|
-
outShapeInfo:
|
|
1975
|
-
},
|
|
1976
|
-
}
|
|
1977
|
-
function
|
|
1796
|
+
fragmentShader: s,
|
|
1797
|
+
source: c,
|
|
1798
|
+
webGLProgram: l,
|
|
1799
|
+
inShapeInfos: a,
|
|
1800
|
+
outShapeInfo: i
|
|
1801
|
+
}, it(e, t, l)));
|
|
1802
|
+
}
|
|
1803
|
+
function it(e, t, n) {
|
|
1978
1804
|
const r = [], o = [];
|
|
1979
|
-
let i,
|
|
1980
|
-
|
|
1981
|
-
const
|
|
1805
|
+
let a, i, c, s = null, l = null;
|
|
1806
|
+
l = e.getUniformLocation(n, "NAN", !1), $().getNumber("WEBGL_VERSION") === 1 && (s = e.getUniformLocation(n, "INFINITY", !1));
|
|
1807
|
+
const u = !1;
|
|
1982
1808
|
for (const f of t.variableNames) {
|
|
1983
1809
|
const d = {
|
|
1984
1810
|
name: f,
|
|
1985
|
-
uniform: e.getUniformLocation(n, f,
|
|
1986
|
-
offset: e.getUniformLocation(n, `offset${f}`,
|
|
1811
|
+
uniform: e.getUniformLocation(n, f, u),
|
|
1812
|
+
offset: e.getUniformLocation(n, `offset${f}`, u)
|
|
1987
1813
|
};
|
|
1988
|
-
t.enableShapeUniforms && (d.shape = e.getUniformLocation(n, `${f}Shape`,
|
|
1814
|
+
t.enableShapeUniforms && (d.shape = e.getUniformLocation(n, `${f}Shape`, u), d.texShape = e.getUniformLocation(n, `${f}TexShape`, u)), r.push(d);
|
|
1989
1815
|
}
|
|
1990
|
-
if (t.enableShapeUniforms && (
|
|
1816
|
+
if (t.enableShapeUniforms && (a = e.getUniformLocation(n, "outShape", u), c = e.getUniformLocation(n, "outShapeStrides", u), i = e.getUniformLocation(n, "outTexShape", u)), t.customUniforms)
|
|
1991
1817
|
for (const f of t.customUniforms)
|
|
1992
|
-
o.push(e.getUniformLocation(n, f.name,
|
|
1818
|
+
o.push(e.getUniformLocation(n, f.name, u));
|
|
1993
1819
|
return {
|
|
1994
1820
|
variablesLocations: r,
|
|
1995
1821
|
customUniformLocations: o,
|
|
1996
|
-
infLoc:
|
|
1997
|
-
nanLoc:
|
|
1998
|
-
outShapeLocation:
|
|
1999
|
-
outShapeStridesLocation:
|
|
2000
|
-
outTexShapeLocation:
|
|
1822
|
+
infLoc: s,
|
|
1823
|
+
nanLoc: l,
|
|
1824
|
+
outShapeLocation: a,
|
|
1825
|
+
outShapeStridesLocation: c,
|
|
1826
|
+
outTexShapeLocation: i
|
|
2001
1827
|
};
|
|
2002
1828
|
}
|
|
2003
|
-
function
|
|
1829
|
+
function Y(e, t) {
|
|
2004
1830
|
if (e.length !== t.length)
|
|
2005
1831
|
throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`);
|
|
2006
1832
|
e.forEach((n, r) => {
|
|
2007
|
-
const o = n.logicalShape,
|
|
2008
|
-
if (!T(o,
|
|
2009
|
-
throw Error(`Binary was compiled with different shapes than the current args. Shapes ${o} and ${
|
|
2010
|
-
if (n.isUniform &&
|
|
1833
|
+
const o = n.logicalShape, a = t[r], i = a.shape;
|
|
1834
|
+
if (!T(o, i))
|
|
1835
|
+
throw Error(`Binary was compiled with different shapes than the current args. Shapes ${o} and ${i} must match`);
|
|
1836
|
+
if (n.isUniform && a.isUniform)
|
|
2011
1837
|
return;
|
|
2012
|
-
const
|
|
2013
|
-
if (!T(
|
|
2014
|
-
throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${
|
|
1838
|
+
const c = n.texShape, s = a.isUniform ? null : a.texData.texShape;
|
|
1839
|
+
if (!T(c, s))
|
|
1840
|
+
throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${c} and ${s} must match`);
|
|
2015
1841
|
});
|
|
2016
1842
|
}
|
|
2017
|
-
function
|
|
2018
|
-
t.program.enableShapeUniforms || (
|
|
2019
|
-
const
|
|
2020
|
-
r.texData.isPacked ? e.setOutputPackedMatrixTexture(
|
|
2021
|
-
for (let
|
|
2022
|
-
const
|
|
1843
|
+
function jt(e, t, n, r, o) {
|
|
1844
|
+
t.program.enableShapeUniforms || (Y(t.inShapeInfos, n), Y([t.outShapeInfo], [r]));
|
|
1845
|
+
const a = r.texData.texture, i = r.texData.texShape;
|
|
1846
|
+
r.texData.isPacked ? e.setOutputPackedMatrixTexture(a.texture, i[0], i[1]) : e.setOutputMatrixTexture(a.texture, i[0], i[1]), e.setProgram(t.webGLProgram), e.bindVertexArray(t.webGLProgram.vao), $().getNumber("WEBGL_VERSION") === 1 && t.infLoc !== null && e.gl.uniform1f(t.infLoc, 1 / 0), t.nanLoc !== null && e.gl.uniform1f(t.nanLoc, NaN);
|
|
1847
|
+
for (let s = 0; s < n.length; ++s) {
|
|
1848
|
+
const l = n[s], { uniform: u, offset: f, shape: d, texShape: x } = t.variablesLocations[s];
|
|
2023
1849
|
if (d) {
|
|
2024
|
-
const { uniformShape:
|
|
2025
|
-
switch (
|
|
1850
|
+
const { uniformShape: h } = z(t.program.packedInputs, l.shape, l.texData.texShape);
|
|
1851
|
+
switch (h.length) {
|
|
2026
1852
|
case 1:
|
|
2027
|
-
e.gl.uniform1iv(d, new Int32Array(
|
|
1853
|
+
e.gl.uniform1iv(d, new Int32Array(h));
|
|
2028
1854
|
break;
|
|
2029
1855
|
case 2:
|
|
2030
|
-
e.gl.uniform2iv(d, new Int32Array(
|
|
1856
|
+
e.gl.uniform2iv(d, new Int32Array(h));
|
|
2031
1857
|
break;
|
|
2032
1858
|
case 3:
|
|
2033
|
-
e.gl.uniform3iv(d, new Int32Array(
|
|
1859
|
+
e.gl.uniform3iv(d, new Int32Array(h));
|
|
2034
1860
|
break;
|
|
2035
1861
|
case 4:
|
|
2036
|
-
e.gl.uniform4iv(d, new Int32Array(
|
|
1862
|
+
e.gl.uniform4iv(d, new Int32Array(h));
|
|
2037
1863
|
break;
|
|
2038
1864
|
}
|
|
2039
1865
|
}
|
|
2040
|
-
if (
|
|
2041
|
-
if (
|
|
2042
|
-
if (E(
|
|
2043
|
-
e.gl.uniform1f(
|
|
1866
|
+
if (x && e.gl.uniform2i(x, l.texData.texShape[0], l.texData.texShape[1]), u != null) {
|
|
1867
|
+
if (l.isUniform) {
|
|
1868
|
+
if (E(l.shape) < 2)
|
|
1869
|
+
e.gl.uniform1f(u, l.uniformValues[0]);
|
|
2044
1870
|
else {
|
|
2045
|
-
let
|
|
2046
|
-
|
|
1871
|
+
let h = l.uniformValues;
|
|
1872
|
+
h instanceof Float32Array || (h = new Float32Array(h)), e.gl.uniform1fv(u, h);
|
|
2047
1873
|
}
|
|
2048
1874
|
continue;
|
|
2049
1875
|
}
|
|
2050
|
-
|
|
1876
|
+
l.texData.slice != null && f != null && e.gl.uniform1i(f, l.texData.slice.flatOffset), e.setInputMatrixTexture(l.texData.texture.texture, u, s);
|
|
2051
1877
|
}
|
|
2052
1878
|
}
|
|
2053
|
-
const
|
|
2054
|
-
if (
|
|
1879
|
+
const c = t.outShapeLocation;
|
|
1880
|
+
if (c)
|
|
2055
1881
|
switch (r.shape.length) {
|
|
2056
1882
|
case 1:
|
|
2057
|
-
e.gl.uniform1iv(
|
|
1883
|
+
e.gl.uniform1iv(c, new Int32Array(r.shape));
|
|
2058
1884
|
break;
|
|
2059
1885
|
case 2:
|
|
2060
|
-
e.gl.uniform2iv(
|
|
1886
|
+
e.gl.uniform2iv(c, new Int32Array(r.shape));
|
|
2061
1887
|
break;
|
|
2062
1888
|
case 3:
|
|
2063
|
-
e.gl.uniform3iv(
|
|
1889
|
+
e.gl.uniform3iv(c, new Int32Array(r.shape));
|
|
2064
1890
|
break;
|
|
2065
1891
|
case 4:
|
|
2066
|
-
e.gl.uniform4iv(
|
|
1892
|
+
e.gl.uniform4iv(c, new Int32Array(r.shape));
|
|
2067
1893
|
break;
|
|
2068
1894
|
}
|
|
2069
1895
|
if (t.outShapeStridesLocation) {
|
|
2070
|
-
const
|
|
1896
|
+
const s = k(r.shape);
|
|
2071
1897
|
switch (r.shape.length) {
|
|
2072
1898
|
case 2:
|
|
2073
|
-
e.gl.uniform1iv(t.outShapeStridesLocation, new Int32Array(
|
|
1899
|
+
e.gl.uniform1iv(t.outShapeStridesLocation, new Int32Array(s));
|
|
2074
1900
|
break;
|
|
2075
1901
|
case 3:
|
|
2076
|
-
e.gl.uniform2iv(t.outShapeStridesLocation, new Int32Array(
|
|
1902
|
+
e.gl.uniform2iv(t.outShapeStridesLocation, new Int32Array(s));
|
|
2077
1903
|
break;
|
|
2078
1904
|
case 4:
|
|
2079
|
-
e.gl.uniform3iv(t.outShapeStridesLocation, new Int32Array(
|
|
1905
|
+
e.gl.uniform3iv(t.outShapeStridesLocation, new Int32Array(s));
|
|
2080
1906
|
break;
|
|
2081
1907
|
}
|
|
2082
1908
|
}
|
|
2083
1909
|
if (t.outTexShapeLocation && e.gl.uniform2i(t.outTexShapeLocation, r.texData.texShape[0], r.texData.texShape[1]), t.program.customUniforms && o)
|
|
2084
|
-
for (let
|
|
2085
|
-
const
|
|
2086
|
-
if (
|
|
2087
|
-
e.gl.uniform1fv(
|
|
2088
|
-
else if (
|
|
2089
|
-
e.gl.uniform2fv(
|
|
2090
|
-
else if (
|
|
2091
|
-
e.gl.uniform3fv(
|
|
2092
|
-
else if (
|
|
2093
|
-
e.gl.uniform4fv(
|
|
2094
|
-
else if (
|
|
2095
|
-
e.gl.uniform1iv(
|
|
2096
|
-
else if (
|
|
2097
|
-
e.gl.uniform2iv(
|
|
2098
|
-
else if (
|
|
2099
|
-
e.gl.uniform3iv(
|
|
2100
|
-
else if (
|
|
2101
|
-
e.gl.uniform4iv(
|
|
1910
|
+
for (let s = 0; s < t.program.customUniforms.length; ++s) {
|
|
1911
|
+
const l = t.program.customUniforms[s], u = t.customUniformLocations[s], f = o[s];
|
|
1912
|
+
if (l.type === "float")
|
|
1913
|
+
e.gl.uniform1fv(u, f);
|
|
1914
|
+
else if (l.type === "vec2")
|
|
1915
|
+
e.gl.uniform2fv(u, f);
|
|
1916
|
+
else if (l.type === "vec3")
|
|
1917
|
+
e.gl.uniform3fv(u, f);
|
|
1918
|
+
else if (l.type === "vec4")
|
|
1919
|
+
e.gl.uniform4fv(u, f);
|
|
1920
|
+
else if (l.type === "int")
|
|
1921
|
+
e.gl.uniform1iv(u, f);
|
|
1922
|
+
else if (l.type === "ivec2")
|
|
1923
|
+
e.gl.uniform2iv(u, f);
|
|
1924
|
+
else if (l.type === "ivec3")
|
|
1925
|
+
e.gl.uniform3iv(u, f);
|
|
1926
|
+
else if (l.type === "ivec4")
|
|
1927
|
+
e.gl.uniform4iv(u, f);
|
|
2102
1928
|
else
|
|
2103
|
-
throw Error(`uniform type ${
|
|
1929
|
+
throw Error(`uniform type ${l.type} is not supported yet.`);
|
|
2104
1930
|
}
|
|
2105
1931
|
e.executeProgram();
|
|
2106
1932
|
}
|
|
2107
|
-
function
|
|
1933
|
+
function Yt(e, t, n) {
|
|
2108
1934
|
let r = "";
|
|
2109
|
-
t.concat(n).forEach((
|
|
2110
|
-
const
|
|
2111
|
-
if (e.enableShapeUniforms && !
|
|
2112
|
-
const
|
|
2113
|
-
let d = "",
|
|
2114
|
-
if (
|
|
2115
|
-
const
|
|
2116
|
-
d = `${
|
|
2117
|
-
} else if (
|
|
2118
|
-
|
|
2119
|
-
else if (
|
|
2120
|
-
const
|
|
2121
|
-
|
|
2122
|
-
}
|
|
2123
|
-
const p =
|
|
2124
|
-
r += `${p}_${
|
|
1935
|
+
t.concat(n).forEach((i) => {
|
|
1936
|
+
const c = i.texData != null && i.texData.slice != null && i.texData.slice.flatOffset > 0;
|
|
1937
|
+
if (e.enableShapeUniforms && !i.isUniform) {
|
|
1938
|
+
const s = i.texData.texShape, { useSqueezeShape: l, uniformShape: u, keptDims: f } = z(e.packedInputs, i.shape, s);
|
|
1939
|
+
let d = "", x = "", h = "";
|
|
1940
|
+
if (u.length === 1 && e.packedInputs) {
|
|
1941
|
+
const I = [Math.ceil(s[0] / 2), Math.ceil(s[1] / 2)];
|
|
1942
|
+
d = `${I[0] > 1}_${I[1] > 1}`;
|
|
1943
|
+
} else if (u.length === 2 && !e.packedInputs)
|
|
1944
|
+
x = `${u[0] > 1}_${u[1] > 1}`;
|
|
1945
|
+
else if (u.length > 2 && !e.packedInputs) {
|
|
1946
|
+
const I = k(u);
|
|
1947
|
+
h = `${I[0] === s[1]}_${I[I.length - 1] === s[1]}`;
|
|
1948
|
+
}
|
|
1949
|
+
const p = i.shape.length, m = u.length === 2 && T(i.shape, s), S = E(i.shape) === 1, R = ce(i.shape, n.shape), F = !e.packedInputs && p === n.shape.length && T(s, n.texData.texShape), oe = e.packedInputs || u.length > 2 ? "" : `${s[0] > 1}_${s[1] > 1}`;
|
|
1950
|
+
r += `${p}_${F}_${l ? f : ""}_${u.length}_${S}_${R}_${m}_${d}_${x}_${h}_${oe}_${c}`;
|
|
2125
1951
|
} else {
|
|
2126
|
-
const
|
|
2127
|
-
r += `${
|
|
1952
|
+
const s = i.isUniform ? "uniform" : i.texData.texShape;
|
|
1953
|
+
r += `${i.shape}_${s}_${c}`;
|
|
2128
1954
|
}
|
|
2129
1955
|
});
|
|
2130
1956
|
const o = e.userCode;
|
|
2131
|
-
let
|
|
2132
|
-
return
|
|
1957
|
+
let a = e.constructor.name;
|
|
1958
|
+
return a += "_" + r + "_" + o + `${$().getNumber("WEBGL_VERSION")}`, a;
|
|
2133
1959
|
}
|
|
2134
|
-
function
|
|
2135
|
-
return
|
|
1960
|
+
function Kt(e) {
|
|
1961
|
+
return $().getBool("WEBGL_USE_SHAPES_UNIFORMS") && e <= 4;
|
|
2136
1962
|
}
|
|
2137
1963
|
export {
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
1964
|
+
jt as $,
|
|
1965
|
+
fe as A,
|
|
1966
|
+
ft as B,
|
|
1967
|
+
dt as C,
|
|
1968
|
+
A as D,
|
|
1969
|
+
Ht as E,
|
|
1970
|
+
pt as F,
|
|
1971
|
+
_ as G,
|
|
1972
|
+
Ft as H,
|
|
1973
|
+
K as I,
|
|
1974
|
+
It as J,
|
|
1975
|
+
$t as K,
|
|
1976
|
+
mt as L,
|
|
1977
|
+
Tt as M,
|
|
1978
|
+
At as N,
|
|
1979
|
+
wt as O,
|
|
1980
|
+
H as P,
|
|
1981
|
+
Nt as Q,
|
|
1982
|
+
Lt as R,
|
|
1983
|
+
Ot as S,
|
|
1984
|
+
q as T,
|
|
1985
|
+
ut as U,
|
|
1986
|
+
j as V,
|
|
1987
|
+
Ut as W,
|
|
1988
|
+
xt as X,
|
|
1989
|
+
ht as Y,
|
|
1990
|
+
Yt as Z,
|
|
1991
|
+
qt as _,
|
|
1992
|
+
zt as a,
|
|
1993
|
+
Dt as a0,
|
|
1994
|
+
me as a1,
|
|
1995
|
+
it as a2,
|
|
1996
|
+
Xt as a3,
|
|
1997
|
+
Wt as b,
|
|
1998
|
+
y as c,
|
|
1999
|
+
Z as d,
|
|
2000
|
+
J as e,
|
|
2001
|
+
re as f,
|
|
2002
|
+
Gt as g,
|
|
2003
|
+
Bt as h,
|
|
2004
|
+
gt as i,
|
|
2005
|
+
bt as j,
|
|
2006
|
+
kt as k,
|
|
2007
|
+
Mt as l,
|
|
2008
|
+
yt as m,
|
|
2009
|
+
Pt as n,
|
|
2010
|
+
Vt as o,
|
|
2185
2011
|
L as p,
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2012
|
+
Q as q,
|
|
2013
|
+
St as r,
|
|
2014
|
+
Rt as s,
|
|
2015
|
+
v as t,
|
|
2016
|
+
Kt as u,
|
|
2017
|
+
lt as v,
|
|
2018
|
+
vt as w,
|
|
2019
|
+
_t as x,
|
|
2020
|
+
Ct as y,
|
|
2021
|
+
Et as z
|
|
2196
2022
|
};
|