@luma.gl/engine 9.3.0-alpha.4 → 9.3.0-alpha.8
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/animation-loop/animation-loop.d.ts +8 -4
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +73 -43
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +7 -1
- package/dist/animation-loop/make-animation-loop.js.map +1 -1
- package/dist/animation-loop/request-animation-frame.d.ts.map +1 -1
- package/dist/animation-loop/request-animation-frame.js +23 -6
- package/dist/animation-loop/request-animation-frame.js.map +1 -1
- package/dist/compute/computation.d.ts +3 -7
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +14 -12
- package/dist/compute/computation.js.map +1 -1
- package/dist/dist.dev.js +2310 -1638
- package/dist/dist.min.js +307 -360
- package/dist/dynamic-texture/dynamic-texture.d.ts +12 -5
- package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.js +222 -55
- package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
- package/dist/dynamic-texture/texture-data.d.ts +8 -1
- package/dist/dynamic-texture/texture-data.d.ts.map +1 -1
- package/dist/dynamic-texture/texture-data.js +27 -2
- package/dist/dynamic-texture/texture-data.js.map +1 -1
- package/dist/geometries/cone-geometry.d.ts +3 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js.map +1 -1
- package/dist/geometries/cylinder-geometry.d.ts +2 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-geometry.js +8 -3
- package/dist/geometry/gpu-geometry.js.map +1 -1
- package/dist/index.cjs +2897 -2272
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +12 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/material/material-factory.d.ts +73 -0
- package/dist/material/material-factory.d.ts.map +1 -0
- package/dist/material/material-factory.js +111 -0
- package/dist/material/material-factory.js.map +1 -0
- package/dist/material/material.d.ts +84 -0
- package/dist/material/material.d.ts.map +1 -0
- package/dist/material/material.js +176 -0
- package/dist/material/material.js.map +1 -0
- package/dist/model/model.d.ts +17 -7
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +80 -34
- package/dist/model/model.js.map +1 -1
- package/dist/model/split-uniforms-and-bindings.d.ts +4 -3
- package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -1
- package/dist/model/split-uniforms-and-bindings.js +2 -2
- package/dist/model/split-uniforms-and-bindings.js.map +1 -1
- package/dist/models/billboard-texture-model.d.ts.map +1 -1
- package/dist/models/billboard-texture-model.js +10 -8
- package/dist/models/billboard-texture-model.js.map +1 -1
- package/dist/models/clip-space.js +7 -7
- package/dist/models/directional-light-model.d.ts +7 -0
- package/dist/models/directional-light-model.d.ts.map +1 -0
- package/dist/models/directional-light-model.js +23 -0
- package/dist/models/directional-light-model.js.map +1 -0
- package/dist/models/light-model-utils.d.ts +69 -0
- package/dist/models/light-model-utils.d.ts.map +1 -0
- package/dist/models/light-model-utils.js +395 -0
- package/dist/models/light-model-utils.js.map +1 -0
- package/dist/models/point-light-model.d.ts +7 -0
- package/dist/models/point-light-model.d.ts.map +1 -0
- package/dist/models/point-light-model.js +22 -0
- package/dist/models/point-light-model.js.map +1 -0
- package/dist/models/spot-light-model.d.ts +7 -0
- package/dist/models/spot-light-model.d.ts.map +1 -0
- package/dist/models/spot-light-model.js +23 -0
- package/dist/models/spot-light-model.js.map +1 -0
- package/dist/modules/picking/color-picking.d.ts +5 -9
- package/dist/modules/picking/color-picking.d.ts.map +1 -1
- package/dist/modules/picking/color-picking.js +122 -115
- package/dist/modules/picking/color-picking.js.map +1 -1
- package/dist/modules/picking/index-picking.d.ts +2 -2
- package/dist/modules/picking/index-picking.d.ts.map +1 -1
- package/dist/modules/picking/index-picking.js +36 -16
- package/dist/modules/picking/index-picking.js.map +1 -1
- package/dist/modules/picking/legacy-color-picking.d.ts +26 -0
- package/dist/modules/picking/legacy-color-picking.d.ts.map +1 -0
- package/dist/modules/picking/legacy-color-picking.js +7 -0
- package/dist/modules/picking/legacy-color-picking.js.map +1 -0
- package/dist/modules/picking/picking-manager.d.ts +29 -3
- package/dist/modules/picking/picking-manager.d.ts.map +1 -1
- package/dist/modules/picking/picking-manager.js +188 -41
- package/dist/modules/picking/picking-manager.js.map +1 -1
- package/dist/modules/picking/picking-uniforms.d.ts +12 -11
- package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
- package/dist/modules/picking/picking-uniforms.js +26 -13
- package/dist/modules/picking/picking-uniforms.js.map +1 -1
- package/dist/modules/picking/picking.d.ts +25 -0
- package/dist/modules/picking/picking.d.ts.map +1 -0
- package/dist/modules/picking/picking.js +18 -0
- package/dist/modules/picking/picking.js.map +1 -0
- package/dist/passes/get-fragment-shader.js +11 -30
- package/dist/passes/get-fragment-shader.js.map +1 -1
- package/dist/passes/shader-pass-renderer.d.ts +0 -2
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +4 -31
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/scenegraph/group-node.d.ts +5 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +12 -0
- package/dist/scenegraph/group-node.js.map +1 -1
- package/dist/scenegraph/model-node.d.ts +2 -2
- package/dist/scenegraph/model-node.d.ts.map +1 -1
- package/dist/scenegraph/model-node.js.map +1 -1
- package/dist/scenegraph/scenegraph-node.d.ts +1 -1
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +23 -15
- package/dist/scenegraph/scenegraph-node.js.map +1 -1
- package/dist/shader-inputs.d.ts +9 -7
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/shader-inputs.js +84 -4
- package/dist/shader-inputs.js.map +1 -1
- package/dist/utils/shader-module-utils.d.ts +7 -0
- package/dist/utils/shader-module-utils.d.ts.map +1 -0
- package/dist/utils/shader-module-utils.js +46 -0
- package/dist/utils/shader-module-utils.js.map +1 -0
- package/package.json +4 -4
- package/src/animation-loop/animation-loop.ts +78 -46
- package/src/animation-loop/make-animation-loop.ts +13 -5
- package/src/animation-loop/request-animation-frame.ts +32 -6
- package/src/compute/computation.ts +31 -17
- package/src/dynamic-texture/dynamic-texture.ts +301 -68
- package/src/dynamic-texture/texture-data.ts +39 -4
- package/src/geometries/cone-geometry.ts +6 -1
- package/src/geometries/cylinder-geometry.ts +5 -1
- package/src/geometry/gpu-geometry.ts +8 -3
- package/src/index.ts +29 -4
- package/src/material/material-factory.ts +157 -0
- package/src/material/material.ts +254 -0
- package/src/model/model.ts +122 -50
- package/src/model/split-uniforms-and-bindings.ts +8 -6
- package/src/models/billboard-texture-model.ts +10 -8
- package/src/models/clip-space.ts +7 -7
- package/src/models/directional-light-model.ts +32 -0
- package/src/models/light-model-utils.ts +587 -0
- package/src/models/point-light-model.ts +31 -0
- package/src/models/spot-light-model.ts +32 -0
- package/src/modules/picking/color-picking.ts +123 -122
- package/src/modules/picking/index-picking.ts +36 -16
- package/src/modules/picking/legacy-color-picking.ts +8 -0
- package/src/modules/picking/picking-manager.ts +252 -50
- package/src/modules/picking/picking-uniforms.ts +38 -23
- package/src/modules/picking/picking.ts +22 -0
- package/src/passes/get-fragment-shader.ts +11 -30
- package/src/passes/shader-pass-renderer.ts +4 -33
- package/src/scenegraph/group-node.ts +16 -0
- package/src/scenegraph/model-node.ts +2 -2
- package/src/scenegraph/scenegraph-node.ts +27 -16
- package/src/shader-inputs.ts +165 -15
- package/src/utils/shader-module-utils.ts +65 -0
- package/dist/dynamic-texture/mipmaps.d.ts +0 -6
- package/dist/dynamic-texture/mipmaps.d.ts.map +0 -1
- package/dist/dynamic-texture/mipmaps.js +0 -441
- package/dist/dynamic-texture/mipmaps.js.map +0 -1
- package/dist/factories/pipeline-factory.d.ts +0 -37
- package/dist/factories/pipeline-factory.d.ts.map +0 -1
- package/dist/factories/pipeline-factory.js +0 -181
- package/dist/factories/pipeline-factory.js.map +0 -1
- package/dist/factories/shader-factory.d.ts +0 -22
- package/dist/factories/shader-factory.d.ts.map +0 -1
- package/dist/factories/shader-factory.js +0 -89
- package/dist/factories/shader-factory.js.map +0 -1
- package/dist/types.d.ts +0 -7
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
- package/src/dynamic-texture/mipmaps.ts +0 -517
- package/src/factories/pipeline-factory.ts +0 -225
- package/src/factories/shader-factory.ts +0 -105
- package/src/types.ts +0 -11
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-factory.js","sourceRoot":"","sources":["../../src/factories/pipeline-factory.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAS,cAAc,EAAE,eAAe,EAAE,GAAG,EAAC,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAC,GAAG,EAAC,wBAAqB;AAOjC;;GAEG;AACH,MAAM,OAAO,eAAe;IAC1B,MAAM,CAAC,YAAY,GAAmC,EAAC,GAAG,cAAc,CAAC,YAAY,EAAC,CAAC;IAEvF,0EAA0E;IAC1E,MAAM,CAAC,yBAAyB,CAAC,MAAc;QAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAoB,iBAAiB,CAAC,CAAC;QAC9E,UAAU,CAAC,sBAAsB,KAAK,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;QAClE,OAAO,UAAU,CAAC,sBAAsB,CAAC;IAC3C,CAAC;IAEQ,MAAM,CAAS;IACf,cAAc,CAAU;IACxB,aAAa,CAAqB;IAClC,KAAK,CAAU;IAEhB,YAAY,GAAW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AC3B,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,OAAO;gBACV,wBAAwB;gBACxB,OAAO,GAAG,IAAI,MAAM,MAAM,IAAI,MAAM,IAAI,WAAW,KAAK,gBAAgB,EAAE,CAAC;YAE7E,KAAK,QAAQ,CAAC;YACd;gBACE,2FAA2F;gBAC3F,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;gBACtE,iHAAiH;gBACjH,sCAAsC;gBACtC,OAAO,GAAG,IAAI,MAAM,MAAM,IAAI,MAAM,IAAI,WAAW,IAAI,KAAK,CAAC,QAAQ,IAAI,aAAa,KAAK,gBAAgB,EAAE,CAAC;QAClH,CAAC;IACH,CAAC;IAEO,QAAQ,CAAC,GAAW;QAC1B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1C,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Device, Shader, ShaderProps } from '@luma.gl/core';
|
|
2
|
-
/** Manages a cached pool of Shaders for reuse. */
|
|
3
|
-
export declare class ShaderFactory {
|
|
4
|
-
static readonly defaultProps: Required<ShaderProps>;
|
|
5
|
-
/** Returns the default ShaderFactory for the given {@link Device}, creating one if necessary. */
|
|
6
|
-
static getDefaultShaderFactory(device: Device): ShaderFactory;
|
|
7
|
-
readonly device: Device;
|
|
8
|
-
readonly cachingEnabled: boolean;
|
|
9
|
-
readonly destroyPolicy: 'unused' | 'never';
|
|
10
|
-
readonly debug: boolean;
|
|
11
|
-
private readonly _cache;
|
|
12
|
-
get [Symbol.toStringTag](): string;
|
|
13
|
-
toString(): string;
|
|
14
|
-
/** @internal */
|
|
15
|
-
constructor(device: Device);
|
|
16
|
-
/** Requests a {@link Shader} from the cache, creating a new Shader only if necessary. */
|
|
17
|
-
createShader(props: ShaderProps): Shader;
|
|
18
|
-
/** Releases a previously-requested {@link Shader}, destroying it if no users remain. */
|
|
19
|
-
release(shader: Shader): void;
|
|
20
|
-
protected _hashShader(value: Shader | ShaderProps): string;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=shader-factory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shader-factory.d.ts","sourceRoot":"","sources":["../../src/factories/shader-factory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAM,MAAM,eAAe,CAAC;AAG/D,kDAAkD;AAClD,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,CAA4B;IAE/E,iGAAiG;IACjG,MAAM,CAAC,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAM7D,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAExB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0D;IAEjF,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;IAED,QAAQ,IAAI,MAAM;IAIlB,gBAAgB;gBACJ,MAAM,EAAE,MAAM;IAO1B,yFAAyF;IACzF,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM;IA8BxC,wFAAwF;IACxF,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IA4B7B,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM;CAG3D"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { Shader, log } from '@luma.gl/core';
|
|
5
|
-
/** Manages a cached pool of Shaders for reuse. */
|
|
6
|
-
export class ShaderFactory {
|
|
7
|
-
static defaultProps = { ...Shader.defaultProps };
|
|
8
|
-
/** Returns the default ShaderFactory for the given {@link Device}, creating one if necessary. */
|
|
9
|
-
static getDefaultShaderFactory(device) {
|
|
10
|
-
const moduleData = device.getModuleData('@luma.gl/engine');
|
|
11
|
-
moduleData.defaultShaderFactory ||= new ShaderFactory(device);
|
|
12
|
-
return moduleData.defaultShaderFactory;
|
|
13
|
-
}
|
|
14
|
-
device;
|
|
15
|
-
cachingEnabled;
|
|
16
|
-
destroyPolicy;
|
|
17
|
-
debug;
|
|
18
|
-
_cache = {};
|
|
19
|
-
get [Symbol.toStringTag]() {
|
|
20
|
-
return 'ShaderFactory';
|
|
21
|
-
}
|
|
22
|
-
toString() {
|
|
23
|
-
return `${this[Symbol.toStringTag]}(${this.device.id})`;
|
|
24
|
-
}
|
|
25
|
-
/** @internal */
|
|
26
|
-
constructor(device) {
|
|
27
|
-
this.device = device;
|
|
28
|
-
this.cachingEnabled = device.props._cacheShaders;
|
|
29
|
-
this.destroyPolicy = device.props._cacheDestroyPolicy;
|
|
30
|
-
this.debug = true; // device.props.debugFactories;
|
|
31
|
-
}
|
|
32
|
-
/** Requests a {@link Shader} from the cache, creating a new Shader only if necessary. */
|
|
33
|
-
createShader(props) {
|
|
34
|
-
if (!this.cachingEnabled) {
|
|
35
|
-
return this.device.createShader(props);
|
|
36
|
-
}
|
|
37
|
-
const key = this._hashShader(props);
|
|
38
|
-
let cacheEntry = this._cache[key];
|
|
39
|
-
if (!cacheEntry) {
|
|
40
|
-
const shader = this.device.createShader({
|
|
41
|
-
...props,
|
|
42
|
-
id: props.id ? `${props.id}-cached` : undefined
|
|
43
|
-
});
|
|
44
|
-
this._cache[key] = cacheEntry = { shader, useCount: 1 };
|
|
45
|
-
if (this.debug) {
|
|
46
|
-
log.log(3, `${this}: Created new shader ${shader.id}`)();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
cacheEntry.useCount++;
|
|
51
|
-
if (this.debug) {
|
|
52
|
-
log.log(3, `${this}: Reusing shader ${cacheEntry.shader.id} count=${cacheEntry.useCount}`)();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return cacheEntry.shader;
|
|
56
|
-
}
|
|
57
|
-
/** Releases a previously-requested {@link Shader}, destroying it if no users remain. */
|
|
58
|
-
release(shader) {
|
|
59
|
-
if (!this.cachingEnabled) {
|
|
60
|
-
shader.destroy();
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const key = this._hashShader(shader);
|
|
64
|
-
const cacheEntry = this._cache[key];
|
|
65
|
-
if (cacheEntry) {
|
|
66
|
-
cacheEntry.useCount--;
|
|
67
|
-
if (cacheEntry.useCount === 0) {
|
|
68
|
-
if (this.destroyPolicy === 'unused') {
|
|
69
|
-
delete this._cache[key];
|
|
70
|
-
cacheEntry.shader.destroy();
|
|
71
|
-
if (this.debug) {
|
|
72
|
-
log.log(3, `${this}: Releasing shader ${shader.id}, destroyed`)();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
else if (cacheEntry.useCount < 0) {
|
|
77
|
-
throw new Error(`ShaderFactory: Shader ${shader.id} released too many times`);
|
|
78
|
-
}
|
|
79
|
-
else if (this.debug) {
|
|
80
|
-
log.log(3, `${this}: Releasing shader ${shader.id} count=${cacheEntry.useCount}`)();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// PRIVATE
|
|
85
|
-
_hashShader(value) {
|
|
86
|
-
return `${value.stage}:${value.source}`;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=shader-factory.js.map
|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C,MAAM,CAAC,CAAC;QACrC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,UAAU,EAAE,CAAC;YACf,UAAU,CAAC,QAAQ,EAAE,CAAC;YACtB,IAAI,UAAU,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;gBAC9B,IAAI,IAAI,CAAC,aAAa,KAAK,QAAQ,EAAE,CAAC;oBACpC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;oBACxB,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;oBAC5B,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;wBACf,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI,sBAAsB,MAAM,CAAC,EAAE,aAAa,CAAC,EAAE,CAAC;oBACpE,CAAC;gBACH,CAAC;YACH,CAAC;iBAAM,IAAI,UAAU,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,EAAE,0BAA0B,CAAC,CAAC;YAChF,CAAC;iBAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACtB,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI,sBAAsB,MAAM,CAAC,EAAE,UAAU,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC;YACtF,CAAC;QACH,CAAC;IACH,CAAC;IAED,UAAU;IAEA,WAAW,CAAC,KAA2B;QAC/C,OAAO,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;IAC1C,CAAC"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { PipelineFactory } from "./factories/pipeline-factory.js";
|
|
2
|
-
import type { ShaderFactory } from "./factories/shader-factory.js";
|
|
3
|
-
export type EngineModuleState = {
|
|
4
|
-
defaultPipelineFactory?: PipelineFactory;
|
|
5
|
-
defaultShaderFactory?: ShaderFactory;
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,wCAAqC;AAClE,OAAO,KAAK,EAAC,aAAa,EAAC,sCAAmC;AAE9D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,sBAAsB,CAAC,EAAE,eAAe,CAAC;IACzC,oBAAoB,CAAC,EAAE,aAAa,CAAC;CACtC,CAAC"}
|
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC"}
|
|
@@ -1,517 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
// Forked from https://github.com/greggman/webgpu-utils under MIT license
|
|
6
|
-
// Copyright (c) 2022 Gregg Tavares
|
|
7
|
-
|
|
8
|
-
import type {Device, Texture, TextureFormat, TextureFormatColor} from '@luma.gl/core';
|
|
9
|
-
import {Buffer, textureFormatDecoder} from '@luma.gl/core';
|
|
10
|
-
import {Model} from '../model/model';
|
|
11
|
-
import {Computation} from '../compute/computation';
|
|
12
|
-
|
|
13
|
-
type RenderTextureViewDimension = '2d' | '2d-array' | 'cube' | 'cube-array';
|
|
14
|
-
type TextureCapability = 'render' | 'filter' | 'store';
|
|
15
|
-
type MipmapPath = 'render' | 'compute';
|
|
16
|
-
|
|
17
|
-
const RENDER_DIMENSIONS: ReadonlyArray<RenderTextureViewDimension> = [
|
|
18
|
-
'2d',
|
|
19
|
-
'2d-array',
|
|
20
|
-
'cube',
|
|
21
|
-
'cube-array'
|
|
22
|
-
];
|
|
23
|
-
|
|
24
|
-
const WORKGROUP_SIZE = {
|
|
25
|
-
x: 4,
|
|
26
|
-
y: 4,
|
|
27
|
-
z: 4
|
|
28
|
-
} as const;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Generates mip levels from level 0 to the last mip for an existing texture.
|
|
32
|
-
*/
|
|
33
|
-
export function generateMipmap(device: Device, texture: Texture): void {
|
|
34
|
-
if (texture.mipLevels <= 1) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (device.type !== 'webgpu') {
|
|
39
|
-
throw new Error(
|
|
40
|
-
`Cannot generate mipmaps on device type "${device.type}". Use generateMipmapsWebGL for WebGL devices.`
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (texture.dimension === '3d') {
|
|
45
|
-
generateMipmaps3D(device, texture);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (RENDER_DIMENSIONS.includes(texture.dimension as RenderTextureViewDimension)) {
|
|
50
|
-
generateMipmapsRender(device, texture);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
throw new Error(
|
|
55
|
-
`Cannot generate mipmaps for texture dimension "${texture.dimension}" with WebGPU.`
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function generateMipmapsRender(device: Device, texture: Texture): void {
|
|
60
|
-
validateFormatCapabilities(device, texture, ['render', 'filter'], 'render');
|
|
61
|
-
const colorAttachmentFormat = getColorAttachmentFormat(
|
|
62
|
-
texture.format,
|
|
63
|
-
'render',
|
|
64
|
-
texture.dimension
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const viewDimension = texture.dimension as RenderTextureViewDimension;
|
|
68
|
-
const shader = getRenderMipmapWGSL(viewDimension);
|
|
69
|
-
const sampler = device.createSampler({minFilter: 'linear', magFilter: 'linear'});
|
|
70
|
-
const uniformValues = new Uint32Array(1);
|
|
71
|
-
const uniformsBuffer = device.createBuffer({
|
|
72
|
-
byteLength: 16,
|
|
73
|
-
usage: Buffer.UNIFORM | Buffer.COPY_DST
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const model = new Model(device, {
|
|
77
|
-
source: shader,
|
|
78
|
-
colorAttachmentFormats: [colorAttachmentFormat],
|
|
79
|
-
topology: 'triangle-list',
|
|
80
|
-
vertexCount: 3,
|
|
81
|
-
shaderLayout: {
|
|
82
|
-
attributes: [],
|
|
83
|
-
bindings: [
|
|
84
|
-
{type: 'sampler', name: 'sourceSampler', group: 0, location: 0},
|
|
85
|
-
{
|
|
86
|
-
type: 'texture',
|
|
87
|
-
name: 'sourceTexture',
|
|
88
|
-
group: 0,
|
|
89
|
-
location: 1,
|
|
90
|
-
viewDimension,
|
|
91
|
-
sampleType: 'float'
|
|
92
|
-
},
|
|
93
|
-
{type: 'uniform', name: 'uniforms', group: 0, location: 2}
|
|
94
|
-
]
|
|
95
|
-
},
|
|
96
|
-
bindings: {
|
|
97
|
-
sourceSampler: sampler,
|
|
98
|
-
sourceTexture: texture,
|
|
99
|
-
uniforms: uniformsBuffer
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
let sourceWidth = texture.width;
|
|
104
|
-
let sourceHeight = texture.height;
|
|
105
|
-
const layerCount = texture.dimension === '2d' ? 1 : texture.depth;
|
|
106
|
-
|
|
107
|
-
try {
|
|
108
|
-
for (let baseMipLevel = 1; baseMipLevel < texture.mipLevels; ++baseMipLevel) {
|
|
109
|
-
validateFormatCapabilities(device, texture, ['render', 'filter'], 'render');
|
|
110
|
-
const sourceMipLevel = baseMipLevel - 1;
|
|
111
|
-
const destinationWidth = Math.max(1, sourceWidth >> 1);
|
|
112
|
-
const destinationHeight = Math.max(1, sourceHeight >> 1);
|
|
113
|
-
|
|
114
|
-
const sourceView = texture.createView({
|
|
115
|
-
dimension: viewDimension,
|
|
116
|
-
baseMipLevel: sourceMipLevel,
|
|
117
|
-
mipLevelCount: 1,
|
|
118
|
-
baseArrayLayer: 0,
|
|
119
|
-
arrayLayerCount: texture.depth
|
|
120
|
-
});
|
|
121
|
-
model.setBindings({sourceTexture: sourceView});
|
|
122
|
-
|
|
123
|
-
for (let baseArrayLayer = 0; baseArrayLayer < layerCount; ++baseArrayLayer) {
|
|
124
|
-
uniformValues[0] = baseArrayLayer;
|
|
125
|
-
uniformsBuffer.write(uniformValues);
|
|
126
|
-
|
|
127
|
-
const destinationView = texture.createView({
|
|
128
|
-
dimension: '2d',
|
|
129
|
-
baseMipLevel,
|
|
130
|
-
mipLevelCount: 1,
|
|
131
|
-
baseArrayLayer,
|
|
132
|
-
arrayLayerCount: 1
|
|
133
|
-
});
|
|
134
|
-
const framebuffer = device.createFramebuffer({
|
|
135
|
-
colorAttachments: [destinationView]
|
|
136
|
-
});
|
|
137
|
-
const renderPass = device.beginRenderPass({
|
|
138
|
-
id: `mipmap-generation:${texture.format}:${baseMipLevel}:${baseArrayLayer}`,
|
|
139
|
-
framebuffer
|
|
140
|
-
});
|
|
141
|
-
renderPass.setParameters({
|
|
142
|
-
viewport: [0, 0, destinationWidth, destinationHeight, 0, 1],
|
|
143
|
-
scissorRect: [0, 0, destinationWidth, destinationHeight]
|
|
144
|
-
});
|
|
145
|
-
model.draw(renderPass);
|
|
146
|
-
renderPass.end();
|
|
147
|
-
device.submit();
|
|
148
|
-
|
|
149
|
-
destinationView.destroy();
|
|
150
|
-
framebuffer.destroy();
|
|
151
|
-
}
|
|
152
|
-
sourceView.destroy();
|
|
153
|
-
|
|
154
|
-
sourceWidth = destinationWidth;
|
|
155
|
-
sourceHeight = destinationHeight;
|
|
156
|
-
}
|
|
157
|
-
} finally {
|
|
158
|
-
model.destroy();
|
|
159
|
-
sampler.destroy();
|
|
160
|
-
uniformsBuffer.destroy();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function getColorAttachmentFormat(
|
|
165
|
-
format: TextureFormat,
|
|
166
|
-
path: MipmapPath,
|
|
167
|
-
dimension: string
|
|
168
|
-
): TextureFormatColor {
|
|
169
|
-
if (textureFormatDecoder.isColor(format)) {
|
|
170
|
-
return format;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
throw new Error(
|
|
174
|
-
`Cannot run ${path} mipmap generation for ${dimension} texture with format "${format}". ` +
|
|
175
|
-
`Only color textures can be used for this operation. ` +
|
|
176
|
-
`Required capabilities: color. ` +
|
|
177
|
-
`Actual capabilities: color=false.`
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function generateMipmaps3D(device: Device, texture: Texture): void {
|
|
182
|
-
validateFormatCapabilities(device, texture, ['filter', 'store'], 'compute');
|
|
183
|
-
const format = getColorAttachmentFormat(texture.format, 'compute', texture.dimension);
|
|
184
|
-
|
|
185
|
-
const shaderSource = get3DComputeMipmapWGSL(format);
|
|
186
|
-
const uniformsBuffer = device.createBuffer({
|
|
187
|
-
byteLength: 32,
|
|
188
|
-
usage: Buffer.UNIFORM | Buffer.COPY_DST
|
|
189
|
-
});
|
|
190
|
-
const uniformValues = new Uint32Array(8);
|
|
191
|
-
|
|
192
|
-
let sourceWidth = texture.width;
|
|
193
|
-
let sourceHeight = texture.height;
|
|
194
|
-
let sourceDepth = texture.depth;
|
|
195
|
-
|
|
196
|
-
try {
|
|
197
|
-
for (
|
|
198
|
-
let destinationMipLevel = 1;
|
|
199
|
-
destinationMipLevel < texture.mipLevels;
|
|
200
|
-
++destinationMipLevel
|
|
201
|
-
) {
|
|
202
|
-
validateFormatCapabilities(device, texture, ['filter', 'store'], 'compute');
|
|
203
|
-
const destinationWidth = Math.max(1, sourceWidth >> 1);
|
|
204
|
-
const destinationHeight = Math.max(1, sourceHeight >> 1);
|
|
205
|
-
const destinationDepth = Math.max(1, sourceDepth >> 1);
|
|
206
|
-
|
|
207
|
-
uniformValues[0] = sourceWidth;
|
|
208
|
-
uniformValues[1] = sourceHeight;
|
|
209
|
-
uniformValues[2] = sourceDepth;
|
|
210
|
-
uniformValues[3] = destinationWidth;
|
|
211
|
-
uniformValues[4] = destinationHeight;
|
|
212
|
-
uniformValues[5] = destinationDepth;
|
|
213
|
-
uniformValues[6] = 0;
|
|
214
|
-
uniformsBuffer.write(uniformValues);
|
|
215
|
-
|
|
216
|
-
const sourceView = texture.createView({
|
|
217
|
-
dimension: '3d',
|
|
218
|
-
baseMipLevel: destinationMipLevel - 1,
|
|
219
|
-
mipLevelCount: 1,
|
|
220
|
-
baseArrayLayer: 0,
|
|
221
|
-
arrayLayerCount: 1
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
const destinationView = texture.createView({
|
|
225
|
-
dimension: '3d',
|
|
226
|
-
baseMipLevel: destinationMipLevel,
|
|
227
|
-
mipLevelCount: 1,
|
|
228
|
-
baseArrayLayer: 0,
|
|
229
|
-
arrayLayerCount: 1
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
const computation = new Computation(device, {
|
|
233
|
-
source: shaderSource,
|
|
234
|
-
shaderLayout: {
|
|
235
|
-
bindings: [
|
|
236
|
-
{
|
|
237
|
-
type: 'texture',
|
|
238
|
-
name: 'sourceTexture',
|
|
239
|
-
group: 0,
|
|
240
|
-
location: 0,
|
|
241
|
-
viewDimension: '3d',
|
|
242
|
-
sampleType: 'float'
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
type: 'storage',
|
|
246
|
-
name: 'destinationTexture',
|
|
247
|
-
group: 0,
|
|
248
|
-
location: 1,
|
|
249
|
-
format,
|
|
250
|
-
viewDimension: '3d',
|
|
251
|
-
access: 'write-only'
|
|
252
|
-
},
|
|
253
|
-
{type: 'uniform', name: 'uniforms', group: 0, location: 2}
|
|
254
|
-
]
|
|
255
|
-
},
|
|
256
|
-
bindings: {
|
|
257
|
-
sourceTexture: sourceView,
|
|
258
|
-
destinationTexture: destinationView,
|
|
259
|
-
uniforms: uniformsBuffer
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
const workgroupsX = Math.ceil(destinationWidth / WORKGROUP_SIZE.x);
|
|
264
|
-
const workgroupsY = Math.ceil(destinationHeight / WORKGROUP_SIZE.y);
|
|
265
|
-
const workgroupsZ = Math.ceil(destinationDepth / WORKGROUP_SIZE.z);
|
|
266
|
-
|
|
267
|
-
const computePass = device.beginComputePass({});
|
|
268
|
-
computation.dispatch(computePass, workgroupsX, workgroupsY, workgroupsZ);
|
|
269
|
-
computePass.end();
|
|
270
|
-
device.submit();
|
|
271
|
-
|
|
272
|
-
computation.destroy();
|
|
273
|
-
sourceView.destroy();
|
|
274
|
-
destinationView.destroy();
|
|
275
|
-
|
|
276
|
-
sourceWidth = destinationWidth;
|
|
277
|
-
sourceHeight = destinationHeight;
|
|
278
|
-
sourceDepth = destinationDepth;
|
|
279
|
-
}
|
|
280
|
-
} finally {
|
|
281
|
-
uniformsBuffer.destroy();
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
function validateFormatCapabilities(
|
|
286
|
-
device: Device,
|
|
287
|
-
texture: Texture,
|
|
288
|
-
requiredCapabilities: ReadonlyArray<TextureCapability>,
|
|
289
|
-
path: MipmapPath
|
|
290
|
-
): void {
|
|
291
|
-
const {format, dimension} = texture;
|
|
292
|
-
const capabilities = device.getTextureFormatCapabilities(format);
|
|
293
|
-
const missingCapabilities = requiredCapabilities.filter(capability => !capabilities[capability]);
|
|
294
|
-
|
|
295
|
-
if (missingCapabilities.length > 0) {
|
|
296
|
-
const required = requiredCapabilities.join(' + ');
|
|
297
|
-
const actual = requiredCapabilities
|
|
298
|
-
.map(capability => `${capability}=${capabilities[capability]}`)
|
|
299
|
-
.join(', ');
|
|
300
|
-
throw new Error(
|
|
301
|
-
`Cannot run ${path} mipmap generation for ${dimension} texture with format "${format}". ` +
|
|
302
|
-
`Required capabilities: ${required}. ` +
|
|
303
|
-
`Actual capabilities: ${actual}.`
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
function getSourceTextureType(dimension: RenderTextureViewDimension): string {
|
|
309
|
-
switch (dimension) {
|
|
310
|
-
case '2d':
|
|
311
|
-
return 'texture_2d<f32>';
|
|
312
|
-
case '2d-array':
|
|
313
|
-
return 'texture_2d_array<f32>';
|
|
314
|
-
case 'cube':
|
|
315
|
-
return 'texture_cube<f32>';
|
|
316
|
-
case 'cube-array':
|
|
317
|
-
return 'texture_cube_array<f32>';
|
|
318
|
-
default:
|
|
319
|
-
throw new Error(`Unsupported render dimension "${dimension}" for mipmap generation.`);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function getRenderMipmapWGSL(dimension: RenderTextureViewDimension): string {
|
|
324
|
-
const sourceSnippet = getRenderMipmapSampleSnippet(dimension);
|
|
325
|
-
|
|
326
|
-
return `
|
|
327
|
-
struct MipmapUniforms {
|
|
328
|
-
sourceLayer: u32,
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
fn _touchUniform(uniforms: MipmapUniforms) {
|
|
332
|
-
let unusedSourceLayer = uniforms.sourceLayer;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
const faceMat = array(
|
|
336
|
-
mat3x3f(
|
|
337
|
-
0.0, 0.0, -2.0,
|
|
338
|
-
0.0, -2.0, 0.0,
|
|
339
|
-
1.0, 1.0, 1.0
|
|
340
|
-
), // pos-x
|
|
341
|
-
mat3x3f(
|
|
342
|
-
0.0, 0.0, 2.0,
|
|
343
|
-
0.0, -2.0, 0.0,
|
|
344
|
-
-1.0, 1.0, -1.0
|
|
345
|
-
), // neg-x
|
|
346
|
-
mat3x3f(
|
|
347
|
-
2.0, 0.0, 0.0,
|
|
348
|
-
0.0, 0.0, 2.0,
|
|
349
|
-
-1.0, 1.0, -1.0
|
|
350
|
-
), // pos-y
|
|
351
|
-
mat3x3f(
|
|
352
|
-
2.0, 0.0, 0.0,
|
|
353
|
-
0.0, 0.0, -2.0,
|
|
354
|
-
-1.0, -1.0, 1.0
|
|
355
|
-
), // neg-y
|
|
356
|
-
mat3x3f(
|
|
357
|
-
2.0, 0.0, 0.0,
|
|
358
|
-
0.0, -2.0, 0.0,
|
|
359
|
-
-1.0, 1.0, 1.0
|
|
360
|
-
), // pos-z
|
|
361
|
-
mat3x3f(
|
|
362
|
-
-2.0, 0.0, 0.0,
|
|
363
|
-
0.0, -2.0, 0.0,
|
|
364
|
-
1.0, 1.0, -1.0
|
|
365
|
-
) // neg-z
|
|
366
|
-
);
|
|
367
|
-
|
|
368
|
-
struct FragmentInputs {
|
|
369
|
-
@builtin(position) position: vec4f,
|
|
370
|
-
@location(0) texcoord: vec2f
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
struct VertexOutput {
|
|
374
|
-
@builtin(position) position: vec4f,
|
|
375
|
-
@location(0) texcoord: vec2f
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
@group(0) @binding(0) var sourceSampler: sampler;
|
|
379
|
-
@group(0) @binding(1) var sourceTexture: ${getSourceTextureType(dimension)};
|
|
380
|
-
@group(0) @binding(2) var<uniform> uniforms: MipmapUniforms;
|
|
381
|
-
|
|
382
|
-
@vertex
|
|
383
|
-
fn vertexMain(
|
|
384
|
-
@builtin(vertex_index) vertexIndex: u32
|
|
385
|
-
) -> VertexOutput {
|
|
386
|
-
const positions = array(
|
|
387
|
-
vec2f(-1.0, -1.0),
|
|
388
|
-
vec2f(-1.0, 3.0),
|
|
389
|
-
vec2f( 3.0, -1.0)
|
|
390
|
-
);
|
|
391
|
-
|
|
392
|
-
let xy = positions[vertexIndex];
|
|
393
|
-
return VertexOutput(
|
|
394
|
-
vec4f(xy, 0.0, 1.0),
|
|
395
|
-
xy * vec2f(0.5, -0.5) + vec2f(0.5)
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
@fragment
|
|
400
|
-
fn fragmentMain(fsInput: VertexOutput) -> @location(0) vec4f {
|
|
401
|
-
_touchUniform(uniforms);
|
|
402
|
-
return ${sourceSnippet};
|
|
403
|
-
}
|
|
404
|
-
`;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
function getRenderMipmapSampleSnippet(dimension: RenderTextureViewDimension): string {
|
|
408
|
-
const layer = 'uniforms.sourceLayer';
|
|
409
|
-
|
|
410
|
-
switch (dimension) {
|
|
411
|
-
case '2d':
|
|
412
|
-
return 'textureSampleLevel(sourceTexture, sourceSampler, fsInput.texcoord, 0.0)';
|
|
413
|
-
case '2d-array':
|
|
414
|
-
return (
|
|
415
|
-
'textureSampleLevel(sourceTexture, sourceSampler, fsInput.texcoord, ' +
|
|
416
|
-
`i32(${layer}), 0.0)`
|
|
417
|
-
);
|
|
418
|
-
case 'cube':
|
|
419
|
-
return (
|
|
420
|
-
'textureSampleLevel(sourceTexture, sourceSampler, ' +
|
|
421
|
-
`faceMat[i32(${layer})] * vec3f(fract(fsInput.texcoord), 1.0), 0.0)`
|
|
422
|
-
);
|
|
423
|
-
case 'cube-array':
|
|
424
|
-
return (
|
|
425
|
-
'textureSampleLevel(sourceTexture, sourceSampler, ' +
|
|
426
|
-
`faceMat[i32(${layer} % 6u)] * vec3f(fract(fsInput.texcoord), 1.0), ` +
|
|
427
|
-
`i32(${layer} / 6u), 0.0)`
|
|
428
|
-
);
|
|
429
|
-
default:
|
|
430
|
-
throw new Error(`Unsupported render dimension "${dimension}" for mipmap generation.`);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
function get3DComputeMipmapWGSL(format: TextureFormatColor): string {
|
|
435
|
-
return `
|
|
436
|
-
struct MipmapUniforms {
|
|
437
|
-
sourceWidth: u32,
|
|
438
|
-
sourceHeight: u32,
|
|
439
|
-
sourceDepth: u32,
|
|
440
|
-
destinationWidth: u32,
|
|
441
|
-
destinationHeight: u32,
|
|
442
|
-
destinationDepth: u32,
|
|
443
|
-
padding: u32,
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
@group(0) @binding(0) var sourceTexture: texture_3d<f32>;
|
|
447
|
-
@group(0) @binding(1) var destinationTexture: texture_storage_3d<${format}, write>;
|
|
448
|
-
@group(0) @binding(2) var<uniform> uniforms: MipmapUniforms;
|
|
449
|
-
|
|
450
|
-
@compute @workgroup_size(${WORKGROUP_SIZE.x}, ${WORKGROUP_SIZE.y}, ${WORKGROUP_SIZE.z})
|
|
451
|
-
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
|
|
452
|
-
if (
|
|
453
|
-
id.x >= uniforms.destinationWidth ||
|
|
454
|
-
id.y >= uniforms.destinationHeight ||
|
|
455
|
-
id.z >= uniforms.destinationDepth
|
|
456
|
-
) {
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
let sourceBase = id * 2u;
|
|
461
|
-
let sourceX0 = min(sourceBase.x, uniforms.sourceWidth - 1u);
|
|
462
|
-
let sourceY0 = min(sourceBase.y, uniforms.sourceHeight - 1u);
|
|
463
|
-
let sourceZ0 = min(sourceBase.z, uniforms.sourceDepth - 1u);
|
|
464
|
-
|
|
465
|
-
let sourceX1 = min(sourceBase.x + 1u, uniforms.sourceWidth - 1u);
|
|
466
|
-
let sourceY1 = min(sourceBase.y + 1u, uniforms.sourceHeight - 1u);
|
|
467
|
-
let sourceZ1 = min(sourceBase.z + 1u, uniforms.sourceDepth - 1u);
|
|
468
|
-
|
|
469
|
-
var sum = textureLoad(
|
|
470
|
-
sourceTexture,
|
|
471
|
-
vec3<i32>(i32(sourceX0), i32(sourceY0), i32(sourceZ0)),
|
|
472
|
-
0
|
|
473
|
-
);
|
|
474
|
-
sum += textureLoad(
|
|
475
|
-
sourceTexture,
|
|
476
|
-
vec3<i32>(i32(sourceX1), i32(sourceY0), i32(sourceZ0)),
|
|
477
|
-
0
|
|
478
|
-
);
|
|
479
|
-
sum += textureLoad(
|
|
480
|
-
sourceTexture,
|
|
481
|
-
vec3<i32>(i32(sourceX0), i32(sourceY1), i32(sourceZ0)),
|
|
482
|
-
0
|
|
483
|
-
);
|
|
484
|
-
sum += textureLoad(
|
|
485
|
-
sourceTexture,
|
|
486
|
-
vec3<i32>(i32(sourceX1), i32(sourceY1), i32(sourceZ0)),
|
|
487
|
-
0
|
|
488
|
-
);
|
|
489
|
-
sum += textureLoad(
|
|
490
|
-
sourceTexture,
|
|
491
|
-
vec3<i32>(i32(sourceX0), i32(sourceY0), i32(sourceZ1)),
|
|
492
|
-
0
|
|
493
|
-
);
|
|
494
|
-
sum += textureLoad(
|
|
495
|
-
sourceTexture,
|
|
496
|
-
vec3<i32>(i32(sourceX1), i32(sourceY0), i32(sourceZ1)),
|
|
497
|
-
0
|
|
498
|
-
);
|
|
499
|
-
sum += textureLoad(
|
|
500
|
-
sourceTexture,
|
|
501
|
-
vec3<i32>(i32(sourceX0), i32(sourceY1), i32(sourceZ1)),
|
|
502
|
-
0
|
|
503
|
-
);
|
|
504
|
-
sum += textureLoad(
|
|
505
|
-
sourceTexture,
|
|
506
|
-
vec3<i32>(i32(sourceX1), i32(sourceY1), i32(sourceZ1)),
|
|
507
|
-
0
|
|
508
|
-
);
|
|
509
|
-
|
|
510
|
-
textureStore(
|
|
511
|
-
destinationTexture,
|
|
512
|
-
vec3<i32>(i32(id.x), i32(id.y), i32(id.z)),
|
|
513
|
-
vec4<f32>(sum.xyz / 8.0, sum.w / 8.0)
|
|
514
|
-
);
|
|
515
|
-
}
|
|
516
|
-
`;
|
|
517
|
-
}
|