@luma.gl/graph 10.0.0-alpha.7 → 10.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +5096 -7269
- package/dist/dist.min.js +270 -83
- package/dist/experimental/index.cjs.map +2 -2
- package/dist/experimental/simulation/index.cjs.map +2 -2
- package/dist/gpu-core/compiled-gpu-graph.cjs +99 -14
- package/dist/gpu-core/compiled-gpu-graph.d.ts +26 -4
- package/dist/gpu-core/compiled-gpu-graph.d.ts.map +1 -1
- package/dist/gpu-core/compiled-gpu-graph.js +101 -13
- package/dist/gpu-core/compiled-gpu-graph.js.map +1 -1
- package/dist/gpu-core/gpu-command-graph-compiler.cjs +35 -3
- package/dist/gpu-core/gpu-command-graph-compiler.js +40 -4
- package/dist/gpu-core/gpu-command-graph-compiler.js.map +1 -1
- package/dist/gpu-core/gpu-command-graph-types.d.ts +2 -0
- package/dist/gpu-core/gpu-command-graph-types.d.ts.map +1 -1
- package/dist/gpu-core/gpu-compaction-operation.cjs +56 -0
- package/dist/gpu-core/gpu-compaction-operation.d.ts +20 -0
- package/dist/gpu-core/gpu-compaction-operation.d.ts.map +1 -0
- package/dist/gpu-core/gpu-compaction-operation.js +36 -0
- package/dist/gpu-core/gpu-compaction-operation.js.map +1 -0
- package/dist/gpu-core/gpu-compaction.cjs +35 -3
- package/dist/gpu-core/gpu-compaction.d.ts.map +1 -1
- package/dist/gpu-core/gpu-compaction.js +38 -3
- package/dist/gpu-core/gpu-compaction.js.map +1 -1
- package/dist/gpu-core/gpu-expression-operation.cjs +18 -2
- package/dist/gpu-core/gpu-expression-operation.d.ts +2 -2
- package/dist/gpu-core/gpu-expression-operation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-expression-operation.js +20 -1
- package/dist/gpu-core/gpu-expression-operation.js.map +1 -1
- package/dist/gpu-core/gpu-expression-plan.cjs +140 -29
- package/dist/gpu-core/gpu-expression-plan.d.ts +26 -5
- package/dist/gpu-core/gpu-expression-plan.d.ts.map +1 -1
- package/dist/gpu-core/gpu-expression-plan.js +168 -34
- package/dist/gpu-core/gpu-expression-plan.js.map +1 -1
- package/dist/gpu-core/gpu-graph-compiler.cjs +100 -11
- package/dist/gpu-core/gpu-graph-compiler.d.ts +7 -3
- package/dist/gpu-core/gpu-graph-compiler.d.ts.map +1 -1
- package/dist/gpu-core/gpu-graph-compiler.js +109 -9
- package/dist/gpu-core/gpu-graph-compiler.js.map +1 -1
- package/dist/gpu-core/gpu-graph-declarations.cjs +120 -0
- package/dist/gpu-core/gpu-graph-declarations.d.ts +4 -0
- package/dist/gpu-core/gpu-graph-declarations.d.ts.map +1 -0
- package/dist/gpu-core/gpu-graph-declarations.js +110 -0
- package/dist/gpu-core/gpu-graph-declarations.js.map +1 -0
- package/dist/gpu-core/gpu-graph-validation.cjs +33 -2
- package/dist/gpu-core/gpu-graph-validation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-graph-validation.js +32 -0
- package/dist/gpu-core/gpu-graph-validation.js.map +1 -1
- package/dist/gpu-core/gpu-graph-value.cjs +38 -3
- package/dist/gpu-core/gpu-graph-value.d.ts +50 -4
- package/dist/gpu-core/gpu-graph-value.d.ts.map +1 -1
- package/dist/gpu-core/gpu-graph-value.js +39 -1
- package/dist/gpu-core/gpu-graph-value.js.map +1 -1
- package/dist/gpu-core/gpu-graph.cjs +65 -0
- package/dist/gpu-core/gpu-graph.d.ts +15 -2
- package/dist/gpu-core/gpu-graph.d.ts.map +1 -1
- package/dist/gpu-core/gpu-graph.js +70 -0
- package/dist/gpu-core/gpu-graph.js.map +1 -1
- package/dist/gpu-core/gpu-operation-contract.cjs +5 -0
- package/dist/gpu-core/gpu-operation-contract.d.ts +10 -0
- package/dist/gpu-core/gpu-operation-contract.d.ts.map +1 -1
- package/dist/gpu-core/gpu-operation-contract.js +6 -1
- package/dist/gpu-core/gpu-operation-contract.js.map +1 -1
- package/dist/gpu-core/gpu-scan.cjs +11 -2
- package/dist/gpu-core/gpu-scan.d.ts.map +1 -1
- package/dist/gpu-core/gpu-scan.js +11 -2
- package/dist/gpu-core/gpu-scan.js.map +1 -1
- package/dist/gpu-core/gpu-texture-copy.cjs +53 -0
- package/dist/gpu-core/gpu-texture-copy.d.ts +7 -0
- package/dist/gpu-core/gpu-texture-copy.d.ts.map +1 -0
- package/dist/gpu-core/gpu-texture-copy.js +39 -0
- package/dist/gpu-core/gpu-texture-copy.js.map +1 -0
- package/dist/gpu-core/gpu-texture-plan.cjs +181 -0
- package/dist/gpu-core/gpu-texture-plan.d.ts +32 -0
- package/dist/gpu-core/gpu-texture-plan.d.ts.map +1 -0
- package/dist/gpu-core/gpu-texture-plan.js +215 -0
- package/dist/gpu-core/gpu-texture-plan.js.map +1 -0
- package/dist/gpu-core/gpu-transfer-lowering.cjs +109 -0
- package/dist/gpu-core/gpu-transfer-lowering.d.ts +9 -0
- package/dist/gpu-core/gpu-transfer-lowering.d.ts.map +1 -0
- package/dist/gpu-core/gpu-transfer-lowering.js +88 -0
- package/dist/gpu-core/gpu-transfer-lowering.js.map +1 -0
- package/dist/gpu-core/gpu-transfer-operation.cjs +100 -0
- package/dist/gpu-core/gpu-transfer-operation.d.ts +38 -0
- package/dist/gpu-core/gpu-transfer-operation.d.ts.map +1 -0
- package/dist/gpu-core/gpu-transfer-operation.js +84 -0
- package/dist/gpu-core/gpu-transfer-operation.js.map +1 -0
- package/dist/gpu-core/index.cjs +13 -0
- package/dist/gpu-core/index.cjs.map +3 -3
- package/dist/gpu-core/index.d.ts +11 -1
- package/dist/gpu-core/index.d.ts.map +1 -1
- package/dist/gpu-core/index.js +4 -1
- package/dist/gpu-core/index.js.map +1 -1
- package/dist/gpu-dggs/benchmarks.cjs.map +2 -2
- package/dist/gpu-graph/index.cjs +8 -0
- package/dist/gpu-graph/index.cjs.map +3 -3
- package/dist/gpu-graph/index.d.ts +5 -0
- package/dist/gpu-graph/index.d.ts.map +1 -1
- package/dist/gpu-graph/index.js +2 -0
- package/dist/gpu-graph/index.js.map +1 -1
- package/dist/gpu-graph-algorithms/benchmarks.cjs.map +3 -3
- package/dist/gpu-graph-algorithms/index.cjs.map +2 -2
- package/dist/gpu-physics/gpu-rigid-body-world.cjs +56 -17
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.js +42 -2
- package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
- package/dist/gpu-physics/index.cjs.map +2 -2
- package/dist/gpu-physics/rigid-body-joints.cjs +6 -1
- package/dist/gpu-physics/rigid-body-joints.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-joints.js +9 -1
- package/dist/gpu-physics/rigid-body-joints.js.map +1 -1
- package/dist/gpu-physics/rigid-body-parallel-shaders.cjs +4 -2
- package/dist/gpu-physics/rigid-body-parallel-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-parallel-shaders.js +4 -2
- package/dist/gpu-physics/rigid-body-parallel-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.cjs +1 -0
- package/dist/gpu-physics/rigid-body-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.js +1 -0
- package/dist/gpu-physics/rigid-body-shaders.js.map +1 -1
- package/dist/gpu-pointcloud/index.cjs.map +1 -1
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.cjs +54 -7
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts +11 -4
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.d.ts.map +1 -1
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js +56 -4
- package/dist/gpu-simple-graph/compiled-gpu-expression-graph.js.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph.cjs +16 -0
- package/dist/gpu-simple-graph/gpu-simple-graph.d.ts +11 -4
- package/dist/gpu-simple-graph/gpu-simple-graph.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph.js +18 -0
- package/dist/gpu-simple-graph/gpu-simple-graph.js.map +1 -1
- package/dist/gpu-simple-graph/gpu-transfer-execution.cjs +82 -0
- package/dist/gpu-simple-graph/gpu-transfer-execution.d.ts +7 -0
- package/dist/gpu-simple-graph/gpu-transfer-execution.d.ts.map +1 -0
- package/dist/gpu-simple-graph/gpu-transfer-execution.js +64 -0
- package/dist/gpu-simple-graph/gpu-transfer-execution.js.map +1 -0
- package/dist/gpu-simple-graph/index.cjs +3 -0
- package/dist/gpu-simple-graph/index.cjs.map +3 -3
- package/dist/gpu-simple-graph/index.d.ts +3 -0
- package/dist/gpu-simple-graph/index.d.ts.map +1 -1
- package/dist/gpu-simple-graph/index.js +1 -0
- package/dist/gpu-simple-graph/index.js.map +1 -1
- package/dist/gpu-sql/{lu-sql.cjs → gpu-sql.cjs} +68 -68
- package/dist/gpu-sql/{lu-sql.d.ts → gpu-sql.d.ts} +14 -14
- package/dist/gpu-sql/gpu-sql.d.ts.map +1 -0
- package/dist/gpu-sql/{lu-sql.js → gpu-sql.js} +68 -68
- package/dist/gpu-sql/gpu-sql.js.map +1 -0
- package/dist/gpu-sql/index.cjs +5 -5
- package/dist/gpu-sql/index.cjs.map +2 -2
- package/dist/gpu-sql/index.d.ts +2 -2
- package/dist/gpu-sql/index.d.ts.map +1 -1
- package/dist/gpu-sql/index.js +1 -1
- package/dist/gpu-sql/index.js.map +1 -1
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
- package/src/gpu-core/compiled-gpu-graph.ts +118 -15
- package/src/gpu-core/gpu-command-graph-compiler.ts +38 -6
- package/src/gpu-core/gpu-command-graph-types.ts +2 -0
- package/src/gpu-core/gpu-compaction-operation.ts +49 -0
- package/src/gpu-core/gpu-compaction.ts +47 -3
- package/src/gpu-core/gpu-expression-operation.ts +23 -2
- package/src/gpu-core/gpu-expression-plan.ts +247 -44
- package/src/gpu-core/gpu-graph-compiler.ts +130 -11
- package/src/gpu-core/gpu-graph-declarations.ts +137 -0
- package/src/gpu-core/gpu-graph-validation.ts +32 -0
- package/src/gpu-core/gpu-graph-value.ts +88 -4
- package/src/gpu-core/gpu-graph.ts +104 -2
- package/src/gpu-core/gpu-operation-contract.ts +18 -0
- package/src/gpu-core/gpu-scan.ts +15 -2
- package/src/gpu-core/gpu-texture-copy.ts +51 -0
- package/src/gpu-core/gpu-texture-plan.ts +248 -0
- package/src/gpu-core/gpu-transfer-lowering.ts +102 -0
- package/src/gpu-core/gpu-transfer-operation.ts +110 -0
- package/src/gpu-core/index.ts +22 -1
- package/src/gpu-graph/index.ts +15 -0
- package/src/gpu-physics/gpu-rigid-body-world.ts +44 -3
- package/src/gpu-physics/rigid-body-joints.ts +11 -2
- package/src/gpu-physics/rigid-body-parallel-shaders.ts +4 -2
- package/src/gpu-physics/rigid-body-shaders.ts +1 -0
- package/src/gpu-project/README.md +4 -4
- package/src/gpu-simple-graph/compiled-gpu-expression-graph.ts +90 -8
- package/src/gpu-simple-graph/gpu-simple-graph.ts +56 -3
- package/src/gpu-simple-graph/gpu-transfer-execution.ts +73 -0
- package/src/gpu-simple-graph/index.ts +9 -0
- package/src/gpu-sql/{lu-sql.ts → gpu-sql.ts} +134 -125
- package/src/gpu-sql/index.ts +2 -2
- package/src/index.ts +29 -1
- package/dist/gpu-sql/lu-sql.d.ts.map +0 -1
- package/dist/gpu-sql/lu-sql.js.map +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import { assert } from '@luma.gl/core';
|
|
5
|
+
import { getTextureBindingInfo } from "./gpu-texture-plan.js";
|
|
6
|
+
/** Bit-preserving copies of selected mip/layer ranges; no sampling or format conversion. @internal */
|
|
7
|
+
export function encodeTextureCopy(encoder, input, output) {
|
|
8
|
+
const source = getTextureBindingInfo(input);
|
|
9
|
+
const destination = getTextureBindingInfo(output);
|
|
10
|
+
validateTextureCopy(input, output);
|
|
11
|
+
for (let mipLevel = 0; mipLevel < source.mipLevels; mipLevel++) {
|
|
12
|
+
encoder.copyTextureToTexture({
|
|
13
|
+
sourceTexture: source.texture,
|
|
14
|
+
destinationTexture: destination.texture,
|
|
15
|
+
mipLevel: source.baseMipLevel + mipLevel,
|
|
16
|
+
destinationMipLevel: destination.baseMipLevel + mipLevel,
|
|
17
|
+
origin: [0, 0, source.baseArrayLayer],
|
|
18
|
+
destinationOrigin: [0, 0, destination.baseArrayLayer],
|
|
19
|
+
width: Math.max(1, source.width >> mipLevel),
|
|
20
|
+
height: Math.max(1, source.height >> mipLevel),
|
|
21
|
+
depthOrArrayLayers: source.dimension === '3d' ? Math.max(1, source.depth >> mipLevel) : source.depth
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Validate copy compatibility before encoding any commands. @internal */
|
|
26
|
+
export function validateTextureCopy(input, output) {
|
|
27
|
+
const source = getTextureBindingInfo(input);
|
|
28
|
+
const destination = getTextureBindingInfo(output);
|
|
29
|
+
assert(source.texture !== destination.texture &&
|
|
30
|
+
source.samples === 1 &&
|
|
31
|
+
destination.samples === 1 &&
|
|
32
|
+
source.format === destination.format &&
|
|
33
|
+
source.width === destination.width &&
|
|
34
|
+
source.height === destination.height &&
|
|
35
|
+
source.depth === destination.depth &&
|
|
36
|
+
source.mipLevels === destination.mipLevels &&
|
|
37
|
+
source.dimension === destination.dimension);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=gpu-texture-copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu-texture-copy.js","sourceRoot":"","sources":["../../src/gpu-core/gpu-texture-copy.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC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AA0E;AAC1E,MAAM,UAAU,mBAAmB,CACjC,KAA6B,EAC7B,MAA8B;IAE9B,MAAM,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,CACJ,MAAM,CAAC,OAAO,KAAK,WAAW,CAAC,OAAO;QACpC,MAAM,CAAC,OAAO,KAAK,CAAC;QACpB,WAAW,CAAC,OAAO,KAAK,CAAC;QACzB,MAAM,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM;QACpC,MAAM,CAAC,KAAK,KAAK,WAAW,CAAC,KAAK;QAClC,MAAM,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM;QACpC,MAAM,CAAC,KAAK,KAAK,WAAW,CAAC,KAAK;QAClC,MAAM,CAAC,SAAS,KAAK,WAAW,CAAC,SAAS;QAC1C,MAAM,CAAC,SAAS,KAAK,WAAW,CAAC,SAAS,CAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var gpu_texture_plan_exports = {};
|
|
19
|
+
__export(gpu_texture_plan_exports, {
|
|
20
|
+
GPUTextureInvocation: () => GPUTextureInvocation,
|
|
21
|
+
getBoundTextureViewProps: () => getBoundTextureViewProps,
|
|
22
|
+
getTextureBindingInfo: () => getTextureBindingInfo
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(gpu_texture_plan_exports);
|
|
25
|
+
var import_core = require("@luma.gl/core");
|
|
26
|
+
var import_gpu_operation_contract = require("./gpu-operation-contract.cjs");
|
|
27
|
+
function getTextureBindingInfo(binding) {
|
|
28
|
+
const texture = binding instanceof import_core.TextureView ? binding.texture : binding;
|
|
29
|
+
const props = binding instanceof import_core.TextureView ? binding.props : {};
|
|
30
|
+
const baseMipLevel = props.baseMipLevel ?? 0;
|
|
31
|
+
const baseArrayLayer = props.baseArrayLayer ?? 0;
|
|
32
|
+
const dimension = props.dimension ?? texture.dimension;
|
|
33
|
+
const mipLevels = props.mipLevelCount ?? texture.mipLevels - baseMipLevel;
|
|
34
|
+
const depth = dimension === "3d" ? Math.max(1, texture.depth >> baseMipLevel) : props.arrayLayerCount ?? (dimension === "cube" ? 6 : dimension === "2d" ? 1 : texture.depth - baseArrayLayer);
|
|
35
|
+
(0, import_core.assert)((props.format ?? texture.format) === texture.format && (props.aspect ?? "all") === "all");
|
|
36
|
+
(0, import_core.assert)(!binding.destroyed && !texture.destroyed);
|
|
37
|
+
(0, import_core.assert)(Number.isInteger(baseMipLevel) && baseMipLevel >= 0 && Number.isInteger(mipLevels) && mipLevels > 0 && baseMipLevel + mipLevels <= texture.mipLevels);
|
|
38
|
+
(0, import_core.assert)(Number.isInteger(baseArrayLayer) && baseArrayLayer >= 0 && Number.isInteger(depth) && depth > 0 && (dimension === "3d" ? baseArrayLayer === 0 : baseArrayLayer + depth <= texture.depth));
|
|
39
|
+
return {
|
|
40
|
+
texture,
|
|
41
|
+
format: texture.format,
|
|
42
|
+
dimension,
|
|
43
|
+
width: Math.max(1, texture.width >> baseMipLevel),
|
|
44
|
+
height: Math.max(1, texture.height >> baseMipLevel),
|
|
45
|
+
depth,
|
|
46
|
+
mipLevels,
|
|
47
|
+
samples: texture.samples,
|
|
48
|
+
baseMipLevel,
|
|
49
|
+
baseArrayLayer
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function getBoundTextureViewProps(binding, props = {}) {
|
|
53
|
+
const info = getTextureBindingInfo(binding);
|
|
54
|
+
const baseMipLevel = props.baseMipLevel ?? 0;
|
|
55
|
+
const baseArrayLayer = props.baseArrayLayer ?? 0;
|
|
56
|
+
const dimension = props.dimension ?? info.dimension;
|
|
57
|
+
const mipLevelCount = props.mipLevelCount ?? info.mipLevels - baseMipLevel;
|
|
58
|
+
const arrayLayerCount = props.arrayLayerCount ?? (dimension === "cube" ? 6 : dimension === "2d" || dimension === "3d" ? 1 : info.depth - baseArrayLayer);
|
|
59
|
+
(0, import_core.assert)(baseMipLevel >= 0 && baseMipLevel + mipLevelCount <= info.mipLevels && baseArrayLayer >= 0 && baseArrayLayer + arrayLayerCount <= info.depth);
|
|
60
|
+
return {
|
|
61
|
+
...props,
|
|
62
|
+
dimension,
|
|
63
|
+
baseMipLevel: info.baseMipLevel + baseMipLevel,
|
|
64
|
+
mipLevelCount,
|
|
65
|
+
baseArrayLayer: info.baseArrayLayer + baseArrayLayer,
|
|
66
|
+
arrayLayerCount
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const TEXTURE_USAGE = {
|
|
70
|
+
sampled: import_core.Texture.SAMPLE,
|
|
71
|
+
"storage-read": import_core.Texture.STORAGE,
|
|
72
|
+
"storage-write": import_core.Texture.STORAGE,
|
|
73
|
+
"storage-read-write": import_core.Texture.STORAGE,
|
|
74
|
+
"render-attachment": import_core.Texture.RENDER,
|
|
75
|
+
"copy-source": import_core.Texture.COPY_SRC,
|
|
76
|
+
"copy-destination": import_core.Texture.COPY_DST
|
|
77
|
+
};
|
|
78
|
+
class GPUTextureInvocation {
|
|
79
|
+
values = /* @__PURE__ */ new Map();
|
|
80
|
+
owned = /* @__PURE__ */ new Set();
|
|
81
|
+
constructor(device, declarations, contracts, bindings, targets) {
|
|
82
|
+
const usages = /* @__PURE__ */ new Map();
|
|
83
|
+
const writable = /* @__PURE__ */ new Set();
|
|
84
|
+
for (const contract of contracts)
|
|
85
|
+
for (const use of contract.values) {
|
|
86
|
+
const name = (0, import_gpu_operation_contract.getGPUOperationValueName)(use.value);
|
|
87
|
+
if (!declarations.some((value) => value.id === name))
|
|
88
|
+
continue;
|
|
89
|
+
(0, import_core.assert)(use.textureUsage);
|
|
90
|
+
const usage = use.textureUsage;
|
|
91
|
+
(0, import_core.assert)(use.access === "read" && ["sampled", "storage-read", "copy-source"].includes(usage) || use.access === "write" && ["storage-write", "render-attachment", "copy-destination"].includes(usage) || use.access === "read-write" && ["storage-read-write", "render-attachment"].includes(usage));
|
|
92
|
+
usages.set(name, (usages.get(name) ?? 0) | TEXTURE_USAGE[usage]);
|
|
93
|
+
if (use.access !== "read")
|
|
94
|
+
writable.add(name);
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const pending = new Set(declarations);
|
|
98
|
+
while (pending.size) {
|
|
99
|
+
let progress = false;
|
|
100
|
+
for (const declaration of pending) {
|
|
101
|
+
const descriptor = declaration.descriptor ?? {
|
|
102
|
+
type: "texture",
|
|
103
|
+
format: declaration.format,
|
|
104
|
+
dimension: declaration.dimension,
|
|
105
|
+
extent: declaration.width === void 0 ? void 0 : { width: declaration.width, height: declaration.height, depth: declaration.depth },
|
|
106
|
+
mipLevels: declaration.mipLevels,
|
|
107
|
+
samples: declaration.samples
|
|
108
|
+
};
|
|
109
|
+
const extent = descriptor.extent;
|
|
110
|
+
const template = extent && "like" in extent ? this.values.get(extent.like) : void 0;
|
|
111
|
+
if (extent && "like" in extent && !template)
|
|
112
|
+
continue;
|
|
113
|
+
const source = template ? getTextureBindingInfo(template) : void 0;
|
|
114
|
+
const scale = extent && "like" in extent ? extent.scale ?? [1, 1] : [1, 1];
|
|
115
|
+
(0, import_core.assert)(scale.every((value) => Number.isFinite(value) && value > 0));
|
|
116
|
+
const width = source ? Math.max(1, Math.round(source.width * scale[0])) : extent && "width" in extent ? extent.width : void 0;
|
|
117
|
+
const height = source ? Math.max(1, Math.round(source.height * scale[1])) : extent && "height" in extent ? extent.height : void 0;
|
|
118
|
+
const dimension = descriptor.dimension ?? (source == null ? void 0 : source.dimension) ?? "2d";
|
|
119
|
+
const depth = dimension === "cube" ? 6 : (source == null ? void 0 : source.depth) ?? (extent && "depth" in extent ? extent.depth : void 0);
|
|
120
|
+
const mipLevels = descriptor.mipLevels ?? (source == null ? void 0 : source.mipLevels) ?? 1;
|
|
121
|
+
const samples = descriptor.samples ?? (source == null ? void 0 : source.samples) ?? 1;
|
|
122
|
+
const usage = (usages.get(declaration.id) ?? 0) | declaration.usage;
|
|
123
|
+
(0, import_core.assert)(samples === 1 || !(usage & (import_core.Texture.COPY_SRC | import_core.Texture.COPY_DST)));
|
|
124
|
+
let binding = targets[declaration.id] ?? bindings[declaration.id];
|
|
125
|
+
if (binding === void 0) {
|
|
126
|
+
(0, import_core.assert)(declaration.role !== "input" && !declaration.external && width !== void 0 && height !== void 0 && usage !== 0);
|
|
127
|
+
(0, import_core.assert)(Number.isSafeInteger(width) && width > 0 && Number.isSafeInteger(height) && height > 0);
|
|
128
|
+
const texture = device.createTexture({
|
|
129
|
+
id: declaration.id,
|
|
130
|
+
format: descriptor.format,
|
|
131
|
+
dimension,
|
|
132
|
+
width,
|
|
133
|
+
height,
|
|
134
|
+
depth: depth ?? 1,
|
|
135
|
+
mipLevels,
|
|
136
|
+
samples,
|
|
137
|
+
usage: usage | (samples === 1 ? import_core.Texture.COPY_SRC : 0) | import_core.Texture.SAMPLE
|
|
138
|
+
});
|
|
139
|
+
this.owned.add(texture);
|
|
140
|
+
binding = texture;
|
|
141
|
+
}
|
|
142
|
+
(0, import_core.assert)(binding instanceof import_core.Texture || binding instanceof import_core.TextureView);
|
|
143
|
+
const info = getTextureBindingInfo(binding);
|
|
144
|
+
(0, import_core.assert)(info.samples === 1 || !(usage & (import_core.Texture.COPY_SRC | import_core.Texture.COPY_DST)));
|
|
145
|
+
(0, import_core.assert)(info.texture.device === device && info.format === descriptor.format && info.dimension === dimension && (width === void 0 || info.width === width) && (height === void 0 || info.height === height) && (depth === void 0 || info.depth === depth) && (descriptor.mipLevels === void 0 && declaration.role === "input" || info.mipLevels === mipLevels) && (descriptor.samples === void 0 && declaration.role === "input" || info.samples === samples) && (info.texture.props.usage & usage) === usage);
|
|
146
|
+
this.values.set(declaration.id, binding);
|
|
147
|
+
pending.delete(declaration);
|
|
148
|
+
progress = true;
|
|
149
|
+
}
|
|
150
|
+
(0, import_core.assert)(progress);
|
|
151
|
+
}
|
|
152
|
+
for (const name of writable) {
|
|
153
|
+
const texture = getTextureBindingInfo(this.values.get(name)).texture;
|
|
154
|
+
for (const [otherName, value] of this.values)
|
|
155
|
+
(0, import_core.assert)(name === otherName || getTextureBindingInfo(value).texture !== texture);
|
|
156
|
+
}
|
|
157
|
+
} catch (error) {
|
|
158
|
+
this.destroy();
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
finish(outputs) {
|
|
163
|
+
for (const name of outputs) {
|
|
164
|
+
const value = this.values.get(name);
|
|
165
|
+
if (value instanceof import_core.Texture)
|
|
166
|
+
this.owned.delete(value);
|
|
167
|
+
}
|
|
168
|
+
this.destroy();
|
|
169
|
+
}
|
|
170
|
+
destroy() {
|
|
171
|
+
for (const texture of this.owned)
|
|
172
|
+
texture.destroy();
|
|
173
|
+
this.owned.clear();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
177
|
+
0 && (module.exports = {
|
|
178
|
+
GPUTextureInvocation,
|
|
179
|
+
getBoundTextureViewProps,
|
|
180
|
+
getTextureBindingInfo
|
|
181
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Texture, TextureView, type Device } from '@luma.gl/core';
|
|
2
|
+
import type { GPUVector } from '@luma.gl/graph/gpu-data';
|
|
3
|
+
import type { GPUGraphTexture } from "./gpu-graph-value.js";
|
|
4
|
+
import type { GPUOperationContract } from "./gpu-operation-contract.js";
|
|
5
|
+
import type { GraphTextureViewProps } from "./gpu-command-graph.js";
|
|
6
|
+
export type GPUGraphTextureBinding = Texture | TextureView;
|
|
7
|
+
export type GPUGraphOutput = GPUVector | GPUGraphTextureBinding;
|
|
8
|
+
export type GPUGraphOutputs = Record<string, GPUGraphOutput>;
|
|
9
|
+
/** Selected view geometry, without creating another view. @internal */
|
|
10
|
+
export declare function getTextureBindingInfo(binding: GPUGraphTextureBinding): {
|
|
11
|
+
texture: Texture;
|
|
12
|
+
format: import("@luma.gl/core").TextureFormat;
|
|
13
|
+
dimension: "1d" | "2d" | "2d-array" | "cube" | "cube-array" | "3d";
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
depth: number;
|
|
17
|
+
mipLevels: number;
|
|
18
|
+
samples: number;
|
|
19
|
+
baseMipLevel: number;
|
|
20
|
+
baseArrayLayer: number;
|
|
21
|
+
};
|
|
22
|
+
/** Compose a logical view relative to an execution-supplied view. @internal */
|
|
23
|
+
export declare function getBoundTextureViewProps(binding: TextureView, props?: GraphTextureViewProps): GraphTextureViewProps;
|
|
24
|
+
/** Per-invocation texture allocation and ownership, shared by independent executors. @internal */
|
|
25
|
+
export declare class GPUTextureInvocation {
|
|
26
|
+
readonly values: Map<string, GPUGraphTextureBinding>;
|
|
27
|
+
private readonly owned;
|
|
28
|
+
constructor(device: Device, declarations: readonly GPUGraphTexture[], contracts: readonly GPUOperationContract[], bindings: Readonly<Record<string, GPUVector | number | GPUGraphTextureBinding>>, targets: Readonly<Record<string, GPUGraphOutput>>);
|
|
29
|
+
finish(outputs: readonly string[]): void;
|
|
30
|
+
destroy(): void;
|
|
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C;IA4HnD,MAAM,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAOxC,OAAO,IAAI,IAAI;CAIhB"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import { assert, Texture, TextureView } from '@luma.gl/core';
|
|
5
|
+
import { getGPUOperationValueName } from "./gpu-operation-contract.js";
|
|
6
|
+
/** Selected view geometry, without creating another view. @internal */
|
|
7
|
+
export function getTextureBindingInfo(binding) {
|
|
8
|
+
const texture = binding instanceof TextureView ? binding.texture : binding;
|
|
9
|
+
const props = binding instanceof TextureView ? binding.props : {};
|
|
10
|
+
const baseMipLevel = props.baseMipLevel ?? 0;
|
|
11
|
+
const baseArrayLayer = props.baseArrayLayer ?? 0;
|
|
12
|
+
const dimension = props.dimension ?? texture.dimension;
|
|
13
|
+
const mipLevels = props.mipLevelCount ?? texture.mipLevels - baseMipLevel;
|
|
14
|
+
const depth = dimension === '3d'
|
|
15
|
+
? Math.max(1, texture.depth >> baseMipLevel)
|
|
16
|
+
: (props.arrayLayerCount ??
|
|
17
|
+
(dimension === 'cube' ? 6 : dimension === '2d' ? 1 : texture.depth - baseArrayLayer));
|
|
18
|
+
// Format reinterpretation and partial aspects need separate binding/operation semantics.
|
|
19
|
+
assert((props.format ?? texture.format) === texture.format && (props.aspect ?? 'all') === 'all');
|
|
20
|
+
assert(!binding.destroyed && !texture.destroyed);
|
|
21
|
+
assert(Number.isInteger(baseMipLevel) &&
|
|
22
|
+
baseMipLevel >= 0 &&
|
|
23
|
+
Number.isInteger(mipLevels) &&
|
|
24
|
+
mipLevels > 0 &&
|
|
25
|
+
baseMipLevel + mipLevels <= texture.mipLevels);
|
|
26
|
+
assert(Number.isInteger(baseArrayLayer) &&
|
|
27
|
+
baseArrayLayer >= 0 &&
|
|
28
|
+
Number.isInteger(depth) &&
|
|
29
|
+
depth > 0 &&
|
|
30
|
+
(dimension === '3d' ? baseArrayLayer === 0 : baseArrayLayer + depth <= texture.depth));
|
|
31
|
+
return {
|
|
32
|
+
texture,
|
|
33
|
+
format: texture.format,
|
|
34
|
+
dimension,
|
|
35
|
+
width: Math.max(1, texture.width >> baseMipLevel),
|
|
36
|
+
height: Math.max(1, texture.height >> baseMipLevel),
|
|
37
|
+
depth,
|
|
38
|
+
mipLevels,
|
|
39
|
+
samples: texture.samples,
|
|
40
|
+
baseMipLevel,
|
|
41
|
+
baseArrayLayer
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Compose a logical view relative to an execution-supplied view. @internal */
|
|
45
|
+
export function getBoundTextureViewProps(binding, props = {}) {
|
|
46
|
+
const info = getTextureBindingInfo(binding);
|
|
47
|
+
const baseMipLevel = props.baseMipLevel ?? 0;
|
|
48
|
+
const baseArrayLayer = props.baseArrayLayer ?? 0;
|
|
49
|
+
const dimension = props.dimension ?? info.dimension;
|
|
50
|
+
const mipLevelCount = props.mipLevelCount ?? info.mipLevels - baseMipLevel;
|
|
51
|
+
const arrayLayerCount = props.arrayLayerCount ??
|
|
52
|
+
(dimension === 'cube'
|
|
53
|
+
? 6
|
|
54
|
+
: dimension === '2d' || dimension === '3d'
|
|
55
|
+
? 1
|
|
56
|
+
: info.depth - baseArrayLayer);
|
|
57
|
+
// Nested selections cannot escape the caller-supplied view.
|
|
58
|
+
assert(baseMipLevel >= 0 &&
|
|
59
|
+
baseMipLevel + mipLevelCount <= info.mipLevels &&
|
|
60
|
+
baseArrayLayer >= 0 &&
|
|
61
|
+
baseArrayLayer + arrayLayerCount <= info.depth);
|
|
62
|
+
return {
|
|
63
|
+
...props,
|
|
64
|
+
dimension,
|
|
65
|
+
baseMipLevel: info.baseMipLevel + baseMipLevel,
|
|
66
|
+
mipLevelCount,
|
|
67
|
+
baseArrayLayer: info.baseArrayLayer + baseArrayLayer,
|
|
68
|
+
arrayLayerCount
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const TEXTURE_USAGE = {
|
|
72
|
+
sampled: Texture.SAMPLE,
|
|
73
|
+
'storage-read': Texture.STORAGE,
|
|
74
|
+
'storage-write': Texture.STORAGE,
|
|
75
|
+
'storage-read-write': Texture.STORAGE,
|
|
76
|
+
'render-attachment': Texture.RENDER,
|
|
77
|
+
'copy-source': Texture.COPY_SRC,
|
|
78
|
+
'copy-destination': Texture.COPY_DST
|
|
79
|
+
};
|
|
80
|
+
/** Per-invocation texture allocation and ownership, shared by independent executors. @internal */
|
|
81
|
+
export class GPUTextureInvocation {
|
|
82
|
+
values = new Map();
|
|
83
|
+
owned = new Set();
|
|
84
|
+
constructor(device, declarations, contracts, bindings, targets) {
|
|
85
|
+
const usages = new Map();
|
|
86
|
+
const writable = new Set();
|
|
87
|
+
for (const contract of contracts)
|
|
88
|
+
for (const use of contract.values) {
|
|
89
|
+
const name = getGPUOperationValueName(use.value);
|
|
90
|
+
if (!declarations.some(value => value.id === name))
|
|
91
|
+
continue;
|
|
92
|
+
// Every reusable texture access declares its physical purpose.
|
|
93
|
+
assert(use.textureUsage);
|
|
94
|
+
const usage = use.textureUsage;
|
|
95
|
+
assert((use.access === 'read' && ['sampled', 'storage-read', 'copy-source'].includes(usage)) ||
|
|
96
|
+
(use.access === 'write' &&
|
|
97
|
+
['storage-write', 'render-attachment', 'copy-destination'].includes(usage)) ||
|
|
98
|
+
(use.access === 'read-write' &&
|
|
99
|
+
['storage-read-write', 'render-attachment'].includes(usage)));
|
|
100
|
+
usages.set(name, (usages.get(name) ?? 0) | TEXTURE_USAGE[usage]);
|
|
101
|
+
if (use.access !== 'read')
|
|
102
|
+
writable.add(name);
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const pending = new Set(declarations);
|
|
106
|
+
while (pending.size) {
|
|
107
|
+
let progress = false;
|
|
108
|
+
for (const declaration of pending) {
|
|
109
|
+
const descriptor = declaration.descriptor ?? {
|
|
110
|
+
type: 'texture',
|
|
111
|
+
format: declaration.format,
|
|
112
|
+
dimension: declaration.dimension,
|
|
113
|
+
extent: declaration.width === undefined
|
|
114
|
+
? undefined
|
|
115
|
+
: { width: declaration.width, height: declaration.height, depth: declaration.depth },
|
|
116
|
+
mipLevels: declaration.mipLevels,
|
|
117
|
+
samples: declaration.samples
|
|
118
|
+
};
|
|
119
|
+
const extent = descriptor.extent;
|
|
120
|
+
const template = extent && 'like' in extent ? this.values.get(extent.like) : undefined;
|
|
121
|
+
if (extent && 'like' in extent && !template)
|
|
122
|
+
continue;
|
|
123
|
+
const source = template ? getTextureBindingInfo(template) : undefined;
|
|
124
|
+
const scale = extent && 'like' in extent ? (extent.scale ?? [1, 1]) : [1, 1];
|
|
125
|
+
assert(scale.every(value => Number.isFinite(value) && value > 0));
|
|
126
|
+
const width = source
|
|
127
|
+
? Math.max(1, Math.round(source.width * scale[0]))
|
|
128
|
+
: extent && 'width' in extent
|
|
129
|
+
? extent.width
|
|
130
|
+
: undefined;
|
|
131
|
+
const height = source
|
|
132
|
+
? Math.max(1, Math.round(source.height * scale[1]))
|
|
133
|
+
: extent && 'height' in extent
|
|
134
|
+
? extent.height
|
|
135
|
+
: undefined;
|
|
136
|
+
const dimension = descriptor.dimension ?? source?.dimension ?? '2d';
|
|
137
|
+
// Cube results always contain six faces, including when sized from a 2d input.
|
|
138
|
+
const depth = dimension === 'cube'
|
|
139
|
+
? 6
|
|
140
|
+
: (source?.depth ?? (extent && 'depth' in extent ? extent.depth : undefined));
|
|
141
|
+
const mipLevels = descriptor.mipLevels ?? source?.mipLevels ?? 1;
|
|
142
|
+
const samples = descriptor.samples ?? source?.samples ?? 1;
|
|
143
|
+
const usage = (usages.get(declaration.id) ?? 0) | declaration.usage;
|
|
144
|
+
// Copy commands cannot read or write multisampled storage.
|
|
145
|
+
assert(samples === 1 || !(usage & (Texture.COPY_SRC | Texture.COPY_DST)));
|
|
146
|
+
let binding = targets[declaration.id] ?? bindings[declaration.id];
|
|
147
|
+
if (binding === undefined) {
|
|
148
|
+
// Input textures are always supplied; produced extents must be inferable before encoding.
|
|
149
|
+
assert(declaration.role !== 'input' &&
|
|
150
|
+
!declaration.external &&
|
|
151
|
+
width !== undefined &&
|
|
152
|
+
height !== undefined &&
|
|
153
|
+
usage !== 0);
|
|
154
|
+
assert(Number.isSafeInteger(width) && width > 0 && Number.isSafeInteger(height) && height > 0);
|
|
155
|
+
const texture = device.createTexture({
|
|
156
|
+
id: declaration.id,
|
|
157
|
+
format: descriptor.format,
|
|
158
|
+
dimension,
|
|
159
|
+
width,
|
|
160
|
+
height,
|
|
161
|
+
depth: depth ?? 1,
|
|
162
|
+
mipLevels,
|
|
163
|
+
samples,
|
|
164
|
+
usage: usage | (samples === 1 ? Texture.COPY_SRC : 0) | Texture.SAMPLE
|
|
165
|
+
});
|
|
166
|
+
this.owned.add(texture);
|
|
167
|
+
binding = texture;
|
|
168
|
+
}
|
|
169
|
+
assert(binding instanceof Texture || binding instanceof TextureView);
|
|
170
|
+
const info = getTextureBindingInfo(binding);
|
|
171
|
+
assert(info.samples === 1 || !(usage & (Texture.COPY_SRC | Texture.COPY_DST)));
|
|
172
|
+
assert(info.texture.device === device &&
|
|
173
|
+
info.format === descriptor.format &&
|
|
174
|
+
info.dimension === dimension &&
|
|
175
|
+
(width === undefined || info.width === width) &&
|
|
176
|
+
(height === undefined || info.height === height) &&
|
|
177
|
+
(depth === undefined || info.depth === depth) &&
|
|
178
|
+
((descriptor.mipLevels === undefined && declaration.role === 'input') ||
|
|
179
|
+
info.mipLevels === mipLevels) &&
|
|
180
|
+
((descriptor.samples === undefined && declaration.role === 'input') ||
|
|
181
|
+
info.samples === samples) &&
|
|
182
|
+
(info.texture.props.usage & usage) === usage);
|
|
183
|
+
this.values.set(declaration.id, binding);
|
|
184
|
+
pending.delete(declaration);
|
|
185
|
+
progress = true;
|
|
186
|
+
}
|
|
187
|
+
assert(progress); // Missing or cyclic texture extent dependency.
|
|
188
|
+
}
|
|
189
|
+
// Conservative alias policy: writable values cannot share backing storage with another value.
|
|
190
|
+
for (const name of writable) {
|
|
191
|
+
const texture = getTextureBindingInfo(this.values.get(name)).texture;
|
|
192
|
+
for (const [otherName, value] of this.values)
|
|
193
|
+
assert(name === otherName || getTextureBindingInfo(value).texture !== texture);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
this.destroy();
|
|
198
|
+
throw error;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
finish(outputs) {
|
|
202
|
+
for (const name of outputs) {
|
|
203
|
+
const value = this.values.get(name);
|
|
204
|
+
if (value instanceof Texture)
|
|
205
|
+
this.owned.delete(value);
|
|
206
|
+
}
|
|
207
|
+
this.destroy();
|
|
208
|
+
}
|
|
209
|
+
destroy() {
|
|
210
|
+
for (const texture of this.owned)
|
|
211
|
+
texture.destroy();
|
|
212
|
+
this.owned.clear();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=gpu-texture-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu-texture-plan.js","sourceRoot":"","sources":["../../src/gpu-core/gpu-texture-plan.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAqC,MAAM,eAAe,CAAC;AAI/F,OAAO,EAAC,wBAAwB,EAAC,oCAAiC;AAOlE,uEAAuE;AACvE,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,MAAM,OAAO,GAAG,OAAO,YAAY,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAC3E,MAAM,KAAK,GAA8B,OAAO,YAAY,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7F,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC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KAAK,CAAC;QACd,CAAC;IACH,CAAC;IACD,MAAM,CAAC,OAA0B;QAC/B,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACpC,IAAI,KAAK,YAAY,OAAO;gBAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IACD,OAAO;QACL,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,OAAO,EAAE,CAAC;QACpD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var gpu_transfer_lowering_exports = {};
|
|
19
|
+
__export(gpu_transfer_lowering_exports, {
|
|
20
|
+
lowerGPUCopy: () => lowerGPUCopy,
|
|
21
|
+
lowerGPUTextureCopy: () => lowerGPUTextureCopy,
|
|
22
|
+
lowerGPUUpload: () => lowerGPUUpload
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(gpu_transfer_lowering_exports);
|
|
25
|
+
var import_gpu_texture_copy = require("./gpu-texture-copy.cjs");
|
|
26
|
+
var import_core = require("@luma.gl/core");
|
|
27
|
+
function lowerGPUUpload(operation, context) {
|
|
28
|
+
const output = context.resolveVector(operation.output);
|
|
29
|
+
const chunks = operation.getData();
|
|
30
|
+
for (const [index, destination] of output.data.entries()) {
|
|
31
|
+
if (!destination.length)
|
|
32
|
+
continue;
|
|
33
|
+
const data = chunks[index];
|
|
34
|
+
context.graph.addCopyPass({
|
|
35
|
+
id: `${operation.id}-${index}`,
|
|
36
|
+
resources: [{ buffer: destination, usage: "copy-destination" }],
|
|
37
|
+
compile: ({ device }) => {
|
|
38
|
+
const staging = device.createBuffer({ data, usage: import_core.Buffer.COPY_SRC });
|
|
39
|
+
return {
|
|
40
|
+
encode: ({ commandEncoder, getBuffer }) => {
|
|
41
|
+
const packed = destination.byteStride === destination.rowByteLength;
|
|
42
|
+
for (let row = 0; row < destination.length; row += packed ? destination.length : 1) {
|
|
43
|
+
commandEncoder.copyBufferToBuffer({
|
|
44
|
+
sourceBuffer: staging,
|
|
45
|
+
sourceOffset: row * destination.rowByteLength,
|
|
46
|
+
destinationBuffer: getBuffer(destination),
|
|
47
|
+
destinationOffset: destination.byteOffset + row * destination.byteStride,
|
|
48
|
+
size: packed ? data.byteLength : destination.rowByteLength
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
destroy: () => staging.destroy()
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function lowerGPUCopy(operation, context) {
|
|
59
|
+
const input = context.resolveVector(operation.input);
|
|
60
|
+
const output = context.resolveVector(operation.output);
|
|
61
|
+
(0, import_core.assert)(input.format === output.format && input.data.length === output.data.length);
|
|
62
|
+
for (const [index, source] of input.data.entries()) {
|
|
63
|
+
const destination = output.data[index];
|
|
64
|
+
(0, import_core.assert)(source.length === destination.length);
|
|
65
|
+
if (!source.length)
|
|
66
|
+
continue;
|
|
67
|
+
context.graph.addCopyPass({
|
|
68
|
+
id: `${operation.id}-${index}`,
|
|
69
|
+
resources: [
|
|
70
|
+
{ buffer: source, usage: "copy-source" },
|
|
71
|
+
{ buffer: destination, usage: "copy-destination" }
|
|
72
|
+
],
|
|
73
|
+
compile: () => ({
|
|
74
|
+
encode: ({ commandEncoder, getBuffer }) => {
|
|
75
|
+
const packed = source.byteStride === source.rowByteLength && destination.byteStride === destination.rowByteLength;
|
|
76
|
+
for (let row = 0; row < source.length; row += packed ? source.length : 1) {
|
|
77
|
+
commandEncoder.copyBufferToBuffer({
|
|
78
|
+
sourceBuffer: getBuffer(source),
|
|
79
|
+
sourceOffset: source.byteOffset + row * source.byteStride,
|
|
80
|
+
destinationBuffer: getBuffer(destination),
|
|
81
|
+
destinationOffset: destination.byteOffset + row * destination.byteStride,
|
|
82
|
+
size: source.rowByteLength * (packed ? source.length : 1)
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function lowerGPUTextureCopy(operation, context) {
|
|
91
|
+
const input = context.resolveTextureView(operation.input);
|
|
92
|
+
const output = context.resolveTextureView(operation.output);
|
|
93
|
+
context.graph.addCopyPass({
|
|
94
|
+
id: operation.id,
|
|
95
|
+
resources: [
|
|
96
|
+
{ texture: input, usage: "copy-source" },
|
|
97
|
+
{ texture: output, usage: "copy-destination" }
|
|
98
|
+
],
|
|
99
|
+
compile: () => ({
|
|
100
|
+
encode: ({ commandEncoder, getTextureView }) => (0, import_gpu_texture_copy.encodeTextureCopy)(commandEncoder, getTextureView(input), getTextureView(output))
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
lowerGPUCopy,
|
|
107
|
+
lowerGPUTextureCopy,
|
|
108
|
+
lowerGPUUpload
|
|
109
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GPUOperationLoweringContext } from "./gpu-graph-lowering.js";
|
|
2
|
+
import { GPUUploadOperation, GPUCopyOperation } from "./gpu-transfer-operation.js";
|
|
3
|
+
/** WebGPU transfers participate in command ordering and caller-owned encoding. @internal */
|
|
4
|
+
export declare function lowerGPUUpload<Parameters>(operation: GPUUploadOperation, context: GPUOperationLoweringContext<Parameters>): void;
|
|
5
|
+
/** @internal */
|
|
6
|
+
export declare function lowerGPUCopy<Parameters>(operation: GPUCopyOperation, context: GPUOperationLoweringContext<Parameters>): void;
|
|
7
|
+
/** Texture copies use the same operation and preserve selected mip/layer ranges. @internal */
|
|
8
|
+
export declare function lowerGPUTextureCopy<Parameters>(operation: GPUCopyOperation, context: GPUOperationLoweringContext<Parameters>): void;
|
|
9
|
+
//# sourceMappingURL=gpu-transfer-lowering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu-transfer-lowering.d.ts","sourceRoot":"","sources":["../../src/gpu-core/gpu-transfer-lowering.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,2BAA2B,EAAC,gCAA6B;AACtE,OAAO,EAAC,kBAAkB,EAAE,gBAAgB,EAAC,oCAAiC;AAE9E,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,UAAU,EACvC,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,2BAA2B,CAAC,UAAU,CAAC,GAC/C,IAAI,CA6BN;AAED,gBAAgB;AAChB,wBAAgB,YAAY,CAAC,UAAU,EACrC,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,2BAA2B,CAAC,UAAU,CAAC,GAC/C,IAAI,CAiCN;AAED,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAAC,UAAU,EAC5C,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,2BAA2B,CAAC,UAAU,CAAC,GAC/C,IAAI,CAcN"}
|