@luma.gl/core 9.0.17 → 9.1.0-alpha.10
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/adapter/adapter.d.ts +11 -0
- package/dist/adapter/adapter.d.ts.map +1 -0
- package/dist/adapter/adapter.js +8 -0
- package/dist/adapter/canvas-context.d.ts +5 -0
- package/dist/adapter/canvas-context.d.ts.map +1 -1
- package/dist/adapter/device.d.ts +23 -11
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +22 -20
- package/dist/adapter/luma.d.ts +70 -0
- package/dist/adapter/luma.d.ts.map +1 -0
- package/dist/adapter/luma.js +159 -0
- package/dist/adapter/resources/buffer.js +5 -5
- package/dist/adapter/resources/compute-pipeline.d.ts +2 -0
- package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/compute-pipeline.js +3 -0
- package/dist/adapter/resources/external-texture.d.ts +1 -1
- package/dist/adapter/resources/external-texture.d.ts.map +1 -1
- package/dist/adapter/resources/external-texture.js +1 -1
- package/dist/adapter/resources/framebuffer.d.ts +3 -3
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/framebuffer.js +2 -83
- package/dist/adapter/resources/render-pass.d.ts +2 -2
- package/dist/adapter/resources/render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.d.ts +2 -5
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/resource.d.ts +3 -3
- package/dist/adapter/resources/resource.d.ts.map +1 -1
- package/dist/adapter/resources/resource.js +1 -1
- package/dist/adapter/resources/shader.d.ts +5 -2
- package/dist/adapter/resources/shader.d.ts.map +1 -1
- package/dist/adapter/resources/shader.js +15 -9
- package/dist/adapter/resources/texture-view.d.ts +1 -1
- package/dist/adapter/resources/texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/texture.d.ts +144 -47
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/texture.js +120 -12
- package/dist/adapter/resources/transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/vertex-array.d.ts +1 -1
- package/dist/adapter/resources/vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/vertex-array.js +6 -2
- package/dist/adapter/types/{types.d.ts → attachments.d.ts} +7 -17
- package/dist/adapter/types/attachments.d.ts.map +1 -0
- package/dist/adapter/types/buffer-layout.d.ts +1 -1
- package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
- package/dist/adapter/types/compiler-message.d.ts.map +1 -0
- package/dist/adapter/types/parameters.d.ts +4 -6
- package/dist/adapter/types/parameters.d.ts.map +1 -1
- package/dist/adapter/types/parameters.js +1 -0
- package/dist/adapter/types/shader-layout.d.ts +23 -3
- package/dist/adapter/types/shader-layout.d.ts.map +1 -1
- package/dist/adapter/types/uniforms.d.ts +4 -0
- package/dist/adapter/types/uniforms.d.ts.map +1 -0
- package/dist/{lib/compiler-log → adapter-utils}/format-compiler-log.d.ts +1 -1
- package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -0
- package/dist/{adapter/attribute-utils → adapter-utils}/get-attribute-from-layouts.d.ts +4 -11
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -0
- package/dist/{adapter/attribute-utils → adapter-utils}/get-attribute-from-layouts.js +10 -30
- package/dist/adapter-utils/is-uniform-value.d.ts +3 -0
- package/dist/adapter-utils/is-uniform-value.d.ts.map +1 -0
- package/dist/adapter-utils/is-uniform-value.js +7 -0
- package/dist/dist.dev.js +635 -821
- package/dist/dist.min.js +6 -6
- package/dist/{adapter/type-utils → gpu-type-utils}/decode-attribute-type.d.ts +3 -3
- package/dist/gpu-type-utils/decode-attribute-type.d.ts.map +1 -0
- package/dist/{adapter/type-utils → gpu-type-utils}/decode-data-type.d.ts +1 -1
- package/dist/gpu-type-utils/decode-data-type.d.ts.map +1 -0
- package/dist/{adapter/type-utils → gpu-type-utils}/decode-shader-types.d.ts +1 -1
- package/dist/gpu-type-utils/decode-shader-types.d.ts.map +1 -0
- package/dist/{adapter/type-utils → gpu-type-utils}/decode-shader-types.js +0 -2
- package/dist/gpu-type-utils/decode-texture-format.d.ts +43 -0
- package/dist/gpu-type-utils/decode-texture-format.d.ts.map +1 -0
- package/dist/{adapter/type-utils → gpu-type-utils}/decode-texture-format.js +67 -31
- package/dist/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.d.ts +1 -1
- package/dist/gpu-type-utils/decode-vertex-format.d.ts.map +1 -0
- package/dist/gpu-type-utils/shader-types.d.ts.map +1 -0
- package/dist/{adapter/types → gpu-type-utils}/texture-formats.d.ts +3 -5
- package/dist/gpu-type-utils/texture-formats.d.ts.map +1 -0
- package/dist/{adapter/type-utils → gpu-type-utils}/vertex-format-from-attribute.d.ts +2 -2
- package/dist/gpu-type-utils/vertex-format-from-attribute.d.ts.map +1 -0
- package/dist/gpu-type-utils/vertex-formats.d.ts.map +1 -0
- package/dist/{adapter/type-utils → gpu-type-utils}/wgsl-utils.d.ts +1 -1
- package/dist/gpu-type-utils/wgsl-utils.d.ts.map +1 -0
- package/dist/index.cjs +396 -567
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +28 -44
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -37
- package/dist/{lib/uniforms → portable}/uniform-block.d.ts +3 -3
- package/dist/portable/uniform-block.d.ts.map +1 -0
- package/dist/{lib/uniforms → portable}/uniform-block.js +2 -2
- package/dist/{lib/uniforms → portable}/uniform-buffer-layout.d.ts +2 -2
- package/dist/portable/uniform-buffer-layout.d.ts.map +1 -0
- package/dist/{lib/uniforms → portable}/uniform-buffer-layout.js +6 -7
- package/dist/{lib/uniforms → portable}/uniform-store.d.ts +9 -4
- package/dist/portable/uniform-store.d.ts.map +1 -0
- package/dist/{lib/uniforms → portable}/uniform-store.js +11 -9
- package/dist/types.d.ts +0 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/array-equal.d.ts.map +1 -1
- package/dist/utils/array-equal.js +6 -7
- package/dist/utils/array-utils-flat.d.ts +1 -7
- package/dist/utils/array-utils-flat.d.ts.map +1 -1
- package/dist/utils/array-utils-flat.js +0 -23
- package/dist/utils/is-array.d.ts +3 -3
- package/dist/utils/is-array.d.ts.map +1 -1
- package/dist/utils/is-array.js +2 -2
- package/dist/utils/uid.d.ts +7 -0
- package/dist/utils/uid.d.ts.map +1 -0
- package/dist/utils/{utils.js → uid.js} +0 -11
- package/package.json +5 -5
- package/src/adapter/adapter.ts +16 -0
- package/src/adapter/canvas-context.ts +6 -0
- package/src/adapter/device.ts +52 -36
- package/src/adapter/luma.ts +219 -0
- package/src/adapter/resources/buffer.ts +5 -5
- package/src/adapter/resources/command-encoder.ts +1 -1
- package/src/adapter/resources/compute-pass.ts +3 -3
- package/src/adapter/resources/compute-pipeline.ts +6 -3
- package/src/adapter/resources/external-texture.ts +2 -2
- package/src/adapter/resources/framebuffer.ts +5 -92
- package/src/adapter/resources/query-set.ts +2 -2
- package/src/adapter/resources/render-pass.ts +11 -7
- package/src/adapter/resources/render-pipeline.ts +3 -6
- package/src/adapter/resources/resource.ts +7 -7
- package/src/adapter/resources/shader.ts +18 -11
- package/src/adapter/resources/texture-view.ts +5 -5
- package/src/adapter/resources/texture.ts +285 -76
- package/src/adapter/resources/transform-feedback.ts +1 -1
- package/src/adapter/resources/vertex-array.ts +7 -3
- package/src/adapter/types/{types.ts → attachments.ts} +10 -18
- package/src/adapter/types/buffer-layout.ts +1 -1
- package/src/adapter/types/parameters.ts +14 -14
- package/src/adapter/types/shader-layout.ts +31 -29
- package/src/adapter/types/uniforms.ts +10 -0
- package/src/{lib/compiler-log → adapter-utils}/format-compiler-log.ts +1 -1
- package/src/{adapter/attribute-utils → adapter-utils}/get-attribute-from-layouts.ts +18 -42
- package/src/adapter-utils/is-uniform-value.ts +10 -0
- package/src/{adapter/type-utils → gpu-type-utils}/decode-attribute-type.ts +3 -3
- package/src/{adapter/type-utils → gpu-type-utils}/decode-data-type.ts +1 -1
- package/src/{adapter/type-utils → gpu-type-utils}/decode-shader-types.ts +1 -3
- package/src/{adapter/type-utils → gpu-type-utils}/decode-texture-format.ts +99 -39
- package/src/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.ts +1 -1
- package/src/{adapter/types → gpu-type-utils}/texture-formats.ts +3 -14
- package/src/{adapter/type-utils → gpu-type-utils}/vertex-format-from-attribute.ts +2 -2
- package/src/{adapter/type-utils → gpu-type-utils}/wgsl-utils.ts +1 -1
- package/src/index.ts +67 -83
- package/src/{lib/uniforms → portable}/uniform-block.ts +5 -5
- package/src/{lib/uniforms → portable}/uniform-buffer-layout.ts +9 -9
- package/src/{lib/uniforms → portable}/uniform-store.ts +20 -12
- package/src/types.ts +0 -12
- package/src/utils/array-equal.ts +6 -7
- package/src/utils/array-utils-flat.ts +1 -31
- package/src/utils/is-array.ts +5 -5
- package/src/utils/{utils.ts → uid.ts} +0 -12
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.d.ts.map +0 -1
- package/dist/adapter/type-utils/decode-attribute-type.d.ts.map +0 -1
- package/dist/adapter/type-utils/decode-data-type.d.ts.map +0 -1
- package/dist/adapter/type-utils/decode-shader-types.d.ts.map +0 -1
- package/dist/adapter/type-utils/decode-texture-format.d.ts +0 -23
- package/dist/adapter/type-utils/decode-texture-format.d.ts.map +0 -1
- package/dist/adapter/type-utils/decode-vertex-format.d.ts.map +0 -1
- package/dist/adapter/type-utils/vertex-format-from-attribute.d.ts.map +0 -1
- package/dist/adapter/type-utils/wgsl-utils.d.ts.map +0 -1
- package/dist/adapter/types/accessor.d.ts +0 -23
- package/dist/adapter/types/accessor.d.ts.map +0 -1
- package/dist/adapter/types/shader-types.d.ts.map +0 -1
- package/dist/adapter/types/texture-formats.d.ts.map +0 -1
- package/dist/adapter/types/types.d.ts.map +0 -1
- package/dist/adapter/types/vertex-formats.d.ts.map +0 -1
- package/dist/init.d.ts +0 -5
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -37
- package/dist/lib/compiler-log/compiler-message.d.ts.map +0 -1
- package/dist/lib/compiler-log/format-compiler-log.d.ts.map +0 -1
- package/dist/lib/compiler-log/get-shader-info.d.ts +0 -9
- package/dist/lib/compiler-log/get-shader-info.d.ts.map +0 -1
- package/dist/lib/compiler-log/get-shader-info.js +0 -29
- package/dist/lib/luma.d.ts +0 -38
- package/dist/lib/luma.d.ts.map +0 -1
- package/dist/lib/luma.js +0 -141
- package/dist/lib/uniforms/uniform-block.d.ts.map +0 -1
- package/dist/lib/uniforms/uniform-buffer-layout.d.ts.map +0 -1
- package/dist/lib/uniforms/uniform-store.d.ts.map +0 -1
- package/dist/lib/uniforms/uniform.d.ts +0 -10
- package/dist/lib/uniforms/uniform.d.ts.map +0 -1
- package/dist/lib/uniforms/uniform.js +0 -20
- package/dist/utils/assert.d.ts +0 -2
- package/dist/utils/assert.d.ts.map +0 -1
- package/dist/utils/assert.js +0 -10
- package/dist/utils/cast.d.ts +0 -3
- package/dist/utils/cast.d.ts.map +0 -1
- package/dist/utils/cast.js +0 -7
- package/dist/utils/check-props.d.ts +0 -7
- package/dist/utils/check-props.d.ts.map +0 -1
- package/dist/utils/check-props.js +0 -36
- package/dist/utils/deep-equal.d.ts +0 -9
- package/dist/utils/deep-equal.d.ts.map +0 -1
- package/dist/utils/deep-equal.js +0 -50
- package/dist/utils/format-value.d.ts +0 -7
- package/dist/utils/format-value.d.ts.map +0 -1
- package/dist/utils/format-value.js +0 -39
- package/dist/utils/load-file.d.ts +0 -35
- package/dist/utils/load-file.d.ts.map +0 -1
- package/dist/utils/load-file.js +0 -74
- package/dist/utils/random.d.ts +0 -5
- package/dist/utils/random.d.ts.map +0 -1
- package/dist/utils/random.js +0 -18
- package/dist/utils/request-animation-frame.d.ts +0 -3
- package/dist/utils/request-animation-frame.d.ts.map +0 -1
- package/dist/utils/request-animation-frame.js +0 -16
- package/dist/utils/stub-methods.d.ts +0 -2
- package/dist/utils/stub-methods.d.ts.map +0 -1
- package/dist/utils/stub-methods.js +0 -19
- package/dist/utils/utils.d.ts +0 -9
- package/dist/utils/utils.d.ts.map +0 -1
- package/src/adapter/types/accessor.ts +0 -37
- package/src/init.ts +0 -53
- package/src/lib/compiler-log/get-shader-info.ts +0 -42
- package/src/lib/luma.ts +0 -190
- package/src/lib/uniforms/uniform.ts +0 -31
- package/src/utils/assert.ts +0 -11
- package/src/utils/cast.ts +0 -8
- package/src/utils/check-props.ts +0 -82
- package/src/utils/deep-equal.ts +0 -51
- package/src/utils/format-value.ts +0 -47
- package/src/utils/load-file.ts +0 -91
- package/src/utils/random.ts +0 -21
- package/src/utils/request-animation-frame.ts +0 -19
- package/src/utils/stub-methods.ts +0 -29
- /package/dist/adapter/types/{accessor.js → attachments.js} +0 -0
- /package/dist/{lib/compiler-log → adapter/types}/compiler-message.d.ts +0 -0
- /package/dist/{lib/compiler-log → adapter/types}/compiler-message.js +0 -0
- /package/dist/adapter/types/{shader-types.js → uniforms.js} +0 -0
- /package/dist/{lib/compiler-log → adapter-utils}/format-compiler-log.js +0 -0
- /package/dist/{adapter/type-utils → gpu-type-utils}/decode-attribute-type.js +0 -0
- /package/dist/{adapter/type-utils → gpu-type-utils}/decode-data-type.js +0 -0
- /package/dist/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.js +0 -0
- /package/dist/{adapter/types → gpu-type-utils}/shader-types.d.ts +0 -0
- /package/dist/{adapter/types/texture-formats.js → gpu-type-utils/shader-types.js} +0 -0
- /package/dist/{adapter/types/types.js → gpu-type-utils/texture-formats.js} +0 -0
- /package/dist/{adapter/type-utils → gpu-type-utils}/vertex-format-from-attribute.js +0 -0
- /package/dist/{adapter/types → gpu-type-utils}/vertex-formats.d.ts +0 -0
- /package/dist/{adapter/types → gpu-type-utils}/vertex-formats.js +0 -0
- /package/dist/{adapter/type-utils → gpu-type-utils}/wgsl-utils.js +0 -0
- /package/src/{lib/compiler-log → adapter/types}/compiler-message.ts +0 -0
- /package/src/{adapter/types → gpu-type-utils}/shader-types.ts +0 -0
- /package/src/{adapter/types → gpu-type-utils}/vertex-formats.ts +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Device, DeviceProps } from "./device.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create and attach devices for a specific backend.
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class Adapter {
|
|
6
|
+
abstract type: string;
|
|
7
|
+
abstract isSupported(): boolean;
|
|
8
|
+
abstract create(props: DeviceProps): Promise<Device>;
|
|
9
|
+
abstract attach?(handle: unknown): Promise<Device>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,oBAAiB;AAE7C;;GAEG;AACH,8BAAsB,OAAO;IAE3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,IAAI,OAAO;IAC/B,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IACpD,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;CACnD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Device } from "./device.js";
|
|
2
2
|
import type { Framebuffer } from "./resources/framebuffer.js";
|
|
3
|
+
import type { TextureFormat } from "../gpu-type-utils/texture-formats.js";
|
|
3
4
|
/** Properties for a CanvasContext */
|
|
4
5
|
export type CanvasContextProps = {
|
|
5
6
|
/** If canvas not supplied, will be created and added to the DOM. If string, will be looked up in the DOM */
|
|
@@ -36,6 +37,10 @@ export declare abstract class CanvasContext {
|
|
|
36
37
|
readonly htmlCanvas?: HTMLCanvasElement;
|
|
37
38
|
readonly offscreenCanvas?: OffscreenCanvas;
|
|
38
39
|
readonly type: 'html-canvas' | 'offscreen-canvas' | 'node';
|
|
40
|
+
/** Format of returned textures: "bgra8unorm", "rgba8unorm" */
|
|
41
|
+
abstract readonly format: TextureFormat;
|
|
42
|
+
/** Default stencil format for depth textures */
|
|
43
|
+
abstract readonly depthStencilFormat: TextureFormat;
|
|
39
44
|
width: number;
|
|
40
45
|
height: number;
|
|
41
46
|
readonly resizeObserver: ResizeObserver | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/canvas-context.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,MAAM,EAAC,oBAAiB;AACrC,OAAO,KAAK,EAAC,WAAW,EAAC,mCAAgC;
|
|
1
|
+
{"version":3,"file":"canvas-context.d.ts","sourceRoot":"","sources":["../../src/adapter/canvas-context.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,MAAM,EAAC,oBAAiB;AACrC,OAAO,KAAK,EAAC,WAAW,EAAC,mCAAgC;AAEzD,OAAO,KAAK,EAAC,aAAa,EAAC,6CAA0C;AAKrE,qCAAqC;AACrC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,4GAA4G;IAC5G,MAAM,CAAC,EAAE,iBAAiB,GAAG,eAAe,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7D,0GAA0G;IAC1G,SAAS,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;IACxC,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACnC,yCAAyC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qEAAqE;IACrE,UAAU,CAAC,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IAAI,MAAM;IAKnB;;OAEG;IACH,gBAAgB,IAAI,MAAM;IAY1B;;OAEG;IACH,iBAAiB,CACf,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,GAAE,OAAc,GACtB;QACD,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB;IAMD;;;OAGG;IACH,mBAAmB,CACjB,gBAAgB,EAAE,MAAM,EACxB,OAAO,GAAE;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAM,GAC9C,IAAI;IAwDP,0GAA0G;IAC1G,oBAAoB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAUxC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;KACpC,GAAG,IAAI;IAER,0DAA0D;IAC1D,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI;IAEjC;;;OAGG;IACH,SAAS,CAAC,uBAAuB,CAAC,EAAE,EAAE,MAAM;CAK7C"}
|
package/dist/adapter/device.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StatsManager } from "../utils/stats-manager.js";
|
|
2
|
-
import type { TextureFormat } from "
|
|
2
|
+
import type { TextureFormat } from "../gpu-type-utils//texture-formats.js";
|
|
3
3
|
import type { CanvasContext, CanvasContextProps } from "./canvas-context.js";
|
|
4
4
|
import type { BufferProps } from "./resources/buffer.js";
|
|
5
5
|
import { Buffer } from "./resources/buffer.js";
|
|
@@ -7,7 +7,7 @@ import type { RenderPipeline, RenderPipelineProps } from "./resources/render-pip
|
|
|
7
7
|
import type { ComputePipeline, ComputePipelineProps } from "./resources/compute-pipeline.js";
|
|
8
8
|
import type { Sampler, SamplerProps } from "./resources/sampler.js";
|
|
9
9
|
import type { Shader, ShaderProps } from "./resources/shader.js";
|
|
10
|
-
import type { Texture, TextureProps
|
|
10
|
+
import type { Texture, TextureProps } from "./resources/texture.js";
|
|
11
11
|
import type { ExternalTexture, ExternalTextureProps } from "./resources/external-texture.js";
|
|
12
12
|
import type { Framebuffer, FramebufferProps } from "./resources/framebuffer.js";
|
|
13
13
|
import type { RenderPass, RenderPassProps } from "./resources/render-pass.js";
|
|
@@ -105,13 +105,13 @@ export declare abstract class DeviceLimits {
|
|
|
105
105
|
export declare class DeviceFeatures {
|
|
106
106
|
protected features: Set<DeviceFeature>;
|
|
107
107
|
protected disabledFeatures?: Partial<Record<DeviceFeature, boolean>>;
|
|
108
|
-
constructor(features: DeviceFeature[], disabledFeatures: Partial<Record<DeviceFeature, boolean>>);
|
|
108
|
+
constructor(features: DeviceFeature[] | undefined, disabledFeatures: Partial<Record<DeviceFeature, boolean>>);
|
|
109
109
|
[Symbol.iterator](): IterableIterator<DeviceFeature>;
|
|
110
110
|
has(feature: DeviceFeature): boolean;
|
|
111
111
|
}
|
|
112
112
|
/** Device feature names */
|
|
113
113
|
export type DeviceFeature = WebGPUDeviceFeature | WebGLDeviceFeature | WebGLCompressedTextureFeatures;
|
|
114
|
-
export type WebGPUDeviceFeature = 'depth-clip-control' | 'indirect-first-instance' | 'timestamp-query' | 'shader-f16' | '
|
|
114
|
+
export type WebGPUDeviceFeature = 'depth-clip-control' | 'indirect-first-instance' | 'timestamp-query' | 'shader-f16' | 'depth32float-stencil8' | 'rg11b10ufloat-renderable' | 'float32-filterable' | 'bgra8unorm-storage' | 'texture-compression-bc' | 'texture-compression-etc2' | 'texture-compression-astc';
|
|
115
115
|
export type WebGLDeviceFeature = 'timer-query-webgl' | 'compilation-status-async-webgl' | 'provoking-vertex-webgl' | 'polygon-mode-webgl' | 'shader-noperspective-interpolation-webgl' | 'shader-conservative-depth-webgl' | 'shader-clip-cull-distance-webgl' | 'float32-renderable-webgl' | 'float16-renderable-webgl' | 'rgb9e5ufloat_renderable-webgl' | 'snorm8-renderable-webgl' | 'norm16-renderable-webgl' | 'snorm16-renderable-webgl' | 'float16-filterable-webgl' | 'texture-filterable-anisotropic-webgl' | 'bgra8unorm-storage' | 'texture-blend-float-webgl';
|
|
116
116
|
type WebGLCompressedTextureFeatures = 'texture-compression-bc5-webgl' | 'texture-compression-bc7-webgl' | 'texture-compression-etc1-webgl' | 'texture-compression-pvrtc-webgl' | 'texture-compression-atc-webgl';
|
|
117
117
|
/** Device properties */
|
|
@@ -125,27 +125,39 @@ export type DeviceProps = {
|
|
|
125
125
|
requestMaxLimits?: boolean;
|
|
126
126
|
/** Error handling */
|
|
127
127
|
onError?: (error: Error) => unknown;
|
|
128
|
+
gl?: WebGL2RenderingContext | null;
|
|
128
129
|
/** WebGL: Instrument WebGL2RenderingContext (at the expense of performance) */
|
|
129
130
|
debug?: boolean;
|
|
130
131
|
/** Break on WebGL functions matching these strings */
|
|
131
132
|
break?: string[];
|
|
132
133
|
/** WebGL: Initialize the SpectorJS WebGL debugger */
|
|
133
|
-
|
|
134
|
+
debugWithSpectorJS?: boolean;
|
|
135
|
+
/** SpectorJS URL. Override if CDN is down or different SpectorJS version is desired */
|
|
136
|
+
spectorUrl?: string;
|
|
137
|
+
/** Set to false to disable WebGL state management instrumentation: TODO- Unclear if still supported / useful */
|
|
138
|
+
manageState?: boolean;
|
|
134
139
|
/** Initialize all features on startup */
|
|
135
140
|
initalizeFeatures?: boolean;
|
|
136
141
|
/** Disable specific features */
|
|
137
142
|
disabledFeatures?: Partial<Record<DeviceFeature, boolean>>;
|
|
138
|
-
/**
|
|
139
|
-
|
|
140
|
-
gl?: WebGL2RenderingContext | null;
|
|
143
|
+
/** Never destroy cached shaders and pipelines */
|
|
144
|
+
_factoryDestroyPolicy?: 'unused' | 'never';
|
|
141
145
|
};
|
|
146
|
+
/**
|
|
147
|
+
* Create and attach devices for a specific backend. Currently static methods on each device
|
|
148
|
+
*/
|
|
149
|
+
export interface DeviceFactory {
|
|
150
|
+
type: string;
|
|
151
|
+
isSupported(): boolean;
|
|
152
|
+
create(props: DeviceProps): Promise<Device>;
|
|
153
|
+
attach?(handle: unknown): Device;
|
|
154
|
+
}
|
|
142
155
|
/**
|
|
143
156
|
* WebGPU Device/WebGL context abstraction
|
|
144
157
|
*/
|
|
145
158
|
export declare abstract class Device {
|
|
146
159
|
static defaultProps: Required<DeviceProps>;
|
|
147
160
|
get [Symbol.toStringTag](): string;
|
|
148
|
-
static VERSION: string;
|
|
149
161
|
constructor(props: DeviceProps);
|
|
150
162
|
/** id of this device, primarily for debugging */
|
|
151
163
|
readonly id: string;
|
|
@@ -191,6 +203,8 @@ export declare abstract class Device {
|
|
|
191
203
|
* @note primarily intended for testing how application reacts to device loss
|
|
192
204
|
*/
|
|
193
205
|
loseDevice(): boolean;
|
|
206
|
+
/** Report error (normally for unhandled device errors) */
|
|
207
|
+
error(error: Error): void;
|
|
194
208
|
/** Default / primary canvas context. Can be null as WebGPU devices can be created without a CanvasContext */
|
|
195
209
|
abstract canvasContext: CanvasContext | null;
|
|
196
210
|
/** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */
|
|
@@ -204,8 +218,6 @@ export declare abstract class Device {
|
|
|
204
218
|
/** Create a texture */
|
|
205
219
|
abstract _createTexture(props: TextureProps): Texture;
|
|
206
220
|
createTexture(props: TextureProps): Texture;
|
|
207
|
-
createTexture(data: Promise<TextureData>): Texture;
|
|
208
|
-
createTexture(url: string): Texture;
|
|
209
221
|
/** Create a temporary texture view of a video source */
|
|
210
222
|
abstract createExternalTexture(props: ExternalTextureProps): ExternalTexture;
|
|
211
223
|
/** Create a sampler */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/adapter/device.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/adapter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AC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,CAAA;KAAC,GAAG,IAAI;IAIhG,oEAAoE;IACpE,UAAU,IAAI,IAAI;IAIlB,SAAS,EAAE,MAAM,CAAK;IAEtB,kEAAkE;IAClE,kBAAkB,IAAI,MAAM;IAM5B,qCAAqC;IACrC,OAAO,CAAC,KAAK,EAAE,KAAK;IAMpB,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,GAAG,eAAe,GAAG,WAAW;CAqB3F"}
|
package/dist/adapter/device.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { VERSION } from "../init.js";
|
|
5
4
|
import { lumaStats } from "../utils/stats-manager.js";
|
|
6
5
|
import { log } from "../utils/log.js";
|
|
7
|
-
import { uid } from "../utils/
|
|
6
|
+
import { uid } from "../utils/uid.js";
|
|
8
7
|
import { Buffer } from "./resources/buffer.js";
|
|
9
|
-
import { isTextureFormatCompressed } from "
|
|
8
|
+
import { isTextureFormatCompressed } from "../gpu-type-utils/decode-texture-format.js";
|
|
10
9
|
/** Limits for a device (max supported sizes of resources, max number of bindings etc) */
|
|
11
10
|
export class DeviceLimits {
|
|
12
11
|
}
|
|
@@ -22,7 +21,7 @@ export class DeviceFeatures {
|
|
|
22
21
|
yield* this.features;
|
|
23
22
|
}
|
|
24
23
|
has(feature) {
|
|
25
|
-
return !this.disabledFeatures[feature] && this.features.has(feature);
|
|
24
|
+
return !this.disabledFeatures?.[feature] && this.features.has(feature);
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
/**
|
|
@@ -37,14 +36,9 @@ export class Device {
|
|
|
37
36
|
width: 800, // width are height are only used by headless gl
|
|
38
37
|
height: 600,
|
|
39
38
|
requestMaxLimits: true,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// TODO - Change these after confirming things work as expected
|
|
44
|
-
initalizeFeatures: true,
|
|
45
|
-
disabledFeatures: {
|
|
46
|
-
'compilation-status-async-webgl': true
|
|
47
|
-
},
|
|
39
|
+
// Callbacks
|
|
40
|
+
onError: (error) => log.error(error.message),
|
|
41
|
+
gl: null,
|
|
48
42
|
// alpha: undefined,
|
|
49
43
|
// depth: undefined,
|
|
50
44
|
// stencil: undefined,
|
|
@@ -52,14 +46,21 @@ export class Device {
|
|
|
52
46
|
// premultipliedAlpha: undefined,
|
|
53
47
|
// preserveDrawingBuffer: undefined,
|
|
54
48
|
// failIfMajorPerformanceCaveat: undefined
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
debug: Boolean(log.get('debug')), // Instrument context (at the expense of performance)
|
|
50
|
+
break: log.get('break') || [],
|
|
51
|
+
// WebGL specific debugging
|
|
52
|
+
debugWithSpectorJS: undefined,
|
|
53
|
+
spectorUrl: undefined,
|
|
54
|
+
// TODO - Change these after confirming things work as expected
|
|
55
|
+
initalizeFeatures: true,
|
|
56
|
+
disabledFeatures: {
|
|
57
|
+
'compilation-status-async-webgl': true
|
|
58
|
+
},
|
|
59
|
+
_factoryDestroyPolicy: 'unused'
|
|
58
60
|
};
|
|
59
61
|
get [Symbol.toStringTag]() {
|
|
60
62
|
return 'Device';
|
|
61
63
|
}
|
|
62
|
-
static VERSION = VERSION;
|
|
63
64
|
constructor(props) {
|
|
64
65
|
this.props = { ...Device.defaultProps, ...props };
|
|
65
66
|
this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
|
|
@@ -86,6 +87,10 @@ export class Device {
|
|
|
86
87
|
loseDevice() {
|
|
87
88
|
return false;
|
|
88
89
|
}
|
|
90
|
+
/** Report error (normally for unhandled device errors) */
|
|
91
|
+
error(error) {
|
|
92
|
+
this.props.onError(error);
|
|
93
|
+
}
|
|
89
94
|
/** Returns the default / primary canvas context. Throws an error if no canvas context is available (a WebGPU compute device) */
|
|
90
95
|
getCanvasContext() {
|
|
91
96
|
if (!this.canvasContext) {
|
|
@@ -93,11 +98,8 @@ export class Device {
|
|
|
93
98
|
}
|
|
94
99
|
return this.canvasContext;
|
|
95
100
|
}
|
|
101
|
+
// createTexture(data: Promise<TextureData>): Texture;
|
|
96
102
|
createTexture(props) {
|
|
97
|
-
// Signature: new Texture2D(gl, url | Promise)
|
|
98
|
-
if (props instanceof Promise || typeof props === 'string') {
|
|
99
|
-
props = { data: props };
|
|
100
|
-
}
|
|
101
103
|
return this._createTexture(props);
|
|
102
104
|
}
|
|
103
105
|
createCommandEncoder(props = {}) {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Log } from '@probe.gl/log';
|
|
2
|
+
import type { DeviceProps } from "./device.js";
|
|
3
|
+
import { Device } from "./device.js";
|
|
4
|
+
import { Adapter } from "./adapter.js";
|
|
5
|
+
import { StatsManager } from "../utils/stats-manager.js";
|
|
6
|
+
declare global {
|
|
7
|
+
var luma: Luma;
|
|
8
|
+
}
|
|
9
|
+
/** Properties for creating a new device */
|
|
10
|
+
export type CreateDeviceProps = DeviceProps & {
|
|
11
|
+
/** Selects the type of device. `best-available` uses webgpu if available, then webgl. */
|
|
12
|
+
type?: 'webgl' | 'webgpu' | 'unknown' | 'best-available';
|
|
13
|
+
adapters?: Adapter[];
|
|
14
|
+
};
|
|
15
|
+
/** Properties for attaching an existing WebGL context or WebGPU device to a new luma Device */
|
|
16
|
+
export type AttachDeviceProps = DeviceProps & {
|
|
17
|
+
/** Externally created WebGL context or WebGPU device */
|
|
18
|
+
handle: unknown;
|
|
19
|
+
/** List of adapters. Will also search any pre-registered adapterss */
|
|
20
|
+
adapters?: Adapter[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Entry point to the luma.gl GPU abstraction
|
|
24
|
+
* Register WebGPU and/or WebGL adapters (controls application bundle size)
|
|
25
|
+
* Run-time selection of the first available Device
|
|
26
|
+
*/
|
|
27
|
+
export declare class Luma {
|
|
28
|
+
static defaultProps: Required<CreateDeviceProps>;
|
|
29
|
+
/** Global stats for all devices */
|
|
30
|
+
readonly stats: StatsManager;
|
|
31
|
+
/**
|
|
32
|
+
* Global log
|
|
33
|
+
*
|
|
34
|
+
* Assign luma.log.level in console to control logging: \
|
|
35
|
+
* 0: none, 1: minimal, 2: verbose, 3: attribute/uniforms, 4: gl logs
|
|
36
|
+
* luma.log.break[], set to gl funcs, luma.log.profile[] set to model names`;
|
|
37
|
+
*/
|
|
38
|
+
readonly log: Log;
|
|
39
|
+
/** Version of luma.gl */
|
|
40
|
+
readonly VERSION: string;
|
|
41
|
+
spector: unknown;
|
|
42
|
+
protected preregisteredAdapters: Map<string, Adapter>;
|
|
43
|
+
constructor();
|
|
44
|
+
registerAdapters(adapters: Adapter[]): void;
|
|
45
|
+
/** Get type strings for supported Devices */
|
|
46
|
+
getSupportedAdapters(adapters?: Adapter[]): string[];
|
|
47
|
+
/** Get type strings for best available Device */
|
|
48
|
+
getBestAvailableAdapter(adapters?: Adapter[]): 'webgpu' | 'webgl' | null;
|
|
49
|
+
setDefaultDeviceProps(props: CreateDeviceProps): void;
|
|
50
|
+
/** Creates a device. Asynchronously. */
|
|
51
|
+
createDevice(props?: CreateDeviceProps): Promise<Device>;
|
|
52
|
+
/** Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice). */
|
|
53
|
+
attachDevice(props: AttachDeviceProps): Promise<Device>;
|
|
54
|
+
/**
|
|
55
|
+
* Override `HTMLCanvasContext.getCanvas()` to always create WebGL2 contexts with additional WebGL1 compatibility.
|
|
56
|
+
* Useful when attaching luma to a context from an external library does not support creating WebGL2 contexts.
|
|
57
|
+
*/
|
|
58
|
+
enforceWebGL2(enforce?: boolean, adapters?: Adapter[]): void;
|
|
59
|
+
/** Convert a list of adapters to a map */
|
|
60
|
+
protected getAdapterMap(adapters?: Adapter[]): Map<string, Adapter>;
|
|
61
|
+
/** @deprecated Use registerAdapters */
|
|
62
|
+
registerDevices(deviceClasses: any[]): void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Entry point to the luma.gl GPU abstraction
|
|
66
|
+
* Register WebGPU and/or WebGL adapters (controls application bundle size)
|
|
67
|
+
* Run-time selection of the first available Device
|
|
68
|
+
*/
|
|
69
|
+
export declare const luma: Luma;
|
|
70
|
+
//# sourceMappingURL=luma.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"luma.d.ts","sourceRoot":"","sources":["../../src/adapter/luma.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,EAAC,WAAW,EAAC,oBAAiB;AAC1C,OAAO,EAAC,MAAM,EAAC,oBAAiB;AAChC,OAAO,EAAC,OAAO,EAAC,qBAAkB;AAClC,OAAO,EAAC,YAAY,EAAC,kCAA+B;AAIpD,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,IAAI,EAAE,IAAI,CAAC;CAChB;AAOD,2CAA2C;AAC3C,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG;IAC5C,yFAAyF;IACzF,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,gBAAgB,CAAC;IACzD,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB,CAAC;AAEF,+FAA+F;AAC/F,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG;IAC5C,wDAAwD;IACxD,MAAM,EAAE,OAAO,CAAC;IAChB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,IAAI;IACf,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAI9C;IAEF,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAa;IAEzC;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAO;IAExB,yBAAyB;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAGmD;IAE3E,OAAO,EAAE,OAAO,CAAC;IAEjB,SAAS,CAAC,qBAAqB,uBAA8B;;IAkB7D,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAM3C,6CAA6C;IAC7C,oBAAoB,CAAC,QAAQ,GAAE,OAAO,EAAO,GAAG,MAAM,EAAE;IAQxD,iDAAiD;IACjD,uBAAuB,CAAC,QAAQ,GAAE,OAAO,EAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI;IAW5E,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAIrD,wCAAwC;IAClC,YAAY,CAAC,KAAK,GAAE,iBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IA0BlE,kFAAkF;IAC5E,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IA+B7D;;;OAGG;IACH,aAAa,CAAC,OAAO,GAAE,OAAc,EAAE,QAAQ,GAAE,OAAO,EAAO,GAAG,IAAI;IAStE,0CAA0C;IAC1C,SAAS,CAAC,aAAa,CAAC,QAAQ,GAAE,OAAO,EAAO,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAUvE,uCAAuC;IACvC,eAAe,CAAC,aAAa,EAAE,GAAG,EAAE,GAAG,IAAI;CAS5C;AAED;;;;GAIG;AACH,eAAO,MAAM,IAAI,MAAa,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Device } from "./device.js";
|
|
5
|
+
import { lumaStats } from "../utils/stats-manager.js";
|
|
6
|
+
import { log } from "../utils/log.js";
|
|
7
|
+
const STARTUP_MESSAGE = 'set luma.log.level=1 (or higher) to trace rendering';
|
|
8
|
+
const ERROR_MESSAGE = 'No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.';
|
|
9
|
+
/**
|
|
10
|
+
* Entry point to the luma.gl GPU abstraction
|
|
11
|
+
* Register WebGPU and/or WebGL adapters (controls application bundle size)
|
|
12
|
+
* Run-time selection of the first available Device
|
|
13
|
+
*/
|
|
14
|
+
export class Luma {
|
|
15
|
+
static defaultProps = {
|
|
16
|
+
...Device.defaultProps,
|
|
17
|
+
type: 'best-available',
|
|
18
|
+
adapters: undefined
|
|
19
|
+
};
|
|
20
|
+
/** Global stats for all devices */
|
|
21
|
+
stats = lumaStats;
|
|
22
|
+
/**
|
|
23
|
+
* Global log
|
|
24
|
+
*
|
|
25
|
+
* Assign luma.log.level in console to control logging: \
|
|
26
|
+
* 0: none, 1: minimal, 2: verbose, 3: attribute/uniforms, 4: gl logs
|
|
27
|
+
* luma.log.break[], set to gl funcs, luma.log.profile[] set to model names`;
|
|
28
|
+
*/
|
|
29
|
+
log = log;
|
|
30
|
+
/** Version of luma.gl */
|
|
31
|
+
VERSION =
|
|
32
|
+
// Version detection using build plugin
|
|
33
|
+
// @ts-expect-error no-undef
|
|
34
|
+
typeof "9.1.0-alpha.10" !== 'undefined' ? "9.1.0-alpha.10" : 'running from source';
|
|
35
|
+
spector;
|
|
36
|
+
preregisteredAdapters = new Map();
|
|
37
|
+
constructor() {
|
|
38
|
+
if (globalThis.luma) {
|
|
39
|
+
if (globalThis.luma.VERSION !== this.VERSION) {
|
|
40
|
+
log.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)();
|
|
41
|
+
log.error(`'yarn why @luma.gl/core' can help identify the source of the conflict`)();
|
|
42
|
+
throw new Error(`luma.gl - multiple versions detected: see console log`);
|
|
43
|
+
}
|
|
44
|
+
log.error('This version of luma.gl has already been initialized')();
|
|
45
|
+
}
|
|
46
|
+
log.log(1, `${this.VERSION} - ${STARTUP_MESSAGE}`)();
|
|
47
|
+
globalThis.luma = this;
|
|
48
|
+
}
|
|
49
|
+
registerAdapters(adapters) {
|
|
50
|
+
for (const deviceClass of adapters) {
|
|
51
|
+
this.preregisteredAdapters.set(deviceClass.type, deviceClass);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Get type strings for supported Devices */
|
|
55
|
+
getSupportedAdapters(adapters = []) {
|
|
56
|
+
const adapterMap = this.getAdapterMap(adapters);
|
|
57
|
+
return Array.from(adapterMap)
|
|
58
|
+
.map(([, adapter]) => adapter)
|
|
59
|
+
.filter(adapter => adapter.isSupported?.())
|
|
60
|
+
.map(adapter => adapter.type);
|
|
61
|
+
}
|
|
62
|
+
/** Get type strings for best available Device */
|
|
63
|
+
getBestAvailableAdapter(adapters = []) {
|
|
64
|
+
const adapterMap = this.getAdapterMap(adapters);
|
|
65
|
+
if (adapterMap.get('webgpu')?.isSupported?.()) {
|
|
66
|
+
return 'webgpu';
|
|
67
|
+
}
|
|
68
|
+
if (adapterMap.get('webgl')?.isSupported?.()) {
|
|
69
|
+
return 'webgl';
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
setDefaultDeviceProps(props) {
|
|
74
|
+
Object.assign(Luma.defaultProps, props);
|
|
75
|
+
}
|
|
76
|
+
/** Creates a device. Asynchronously. */
|
|
77
|
+
async createDevice(props = {}) {
|
|
78
|
+
props = { ...Luma.defaultProps, ...props };
|
|
79
|
+
// Should be handled by attach device
|
|
80
|
+
// if (props.gl) {
|
|
81
|
+
// props.type = 'webgl';
|
|
82
|
+
// }
|
|
83
|
+
const adapterMap = this.getAdapterMap(props.adapters);
|
|
84
|
+
let type = props.type || '';
|
|
85
|
+
if (type === 'best-available') {
|
|
86
|
+
type = this.getBestAvailableAdapter(props.adapters) || type;
|
|
87
|
+
}
|
|
88
|
+
const adapters = this.getAdapterMap(props.adapters) || adapterMap;
|
|
89
|
+
const adapter = adapters.get(type);
|
|
90
|
+
const device = await adapter?.create?.(props);
|
|
91
|
+
if (device) {
|
|
92
|
+
return device;
|
|
93
|
+
}
|
|
94
|
+
throw new Error(ERROR_MESSAGE);
|
|
95
|
+
}
|
|
96
|
+
/** Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice). */
|
|
97
|
+
async attachDevice(props) {
|
|
98
|
+
const adapters = this.getAdapterMap(props.adapters);
|
|
99
|
+
// WebGL
|
|
100
|
+
let type = '';
|
|
101
|
+
if (props.handle instanceof WebGL2RenderingContext) {
|
|
102
|
+
type = 'webgl';
|
|
103
|
+
}
|
|
104
|
+
// TODO - WebGPU does not yet have a stable API
|
|
105
|
+
// if (props.handle instanceof GPUDevice) {
|
|
106
|
+
// const WebGPUDevice = adapters.get('webgpu') as any;
|
|
107
|
+
// if (WebGPUDevice) {
|
|
108
|
+
// return (await WebGPUDevice.attach(props.handle)) as Device;
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
111
|
+
// null
|
|
112
|
+
if (props.handle === null) {
|
|
113
|
+
type = 'unknown';
|
|
114
|
+
}
|
|
115
|
+
const adapter = adapters.get(type);
|
|
116
|
+
const device = await adapter?.attach?.(null);
|
|
117
|
+
if (device) {
|
|
118
|
+
return device;
|
|
119
|
+
}
|
|
120
|
+
throw new Error(ERROR_MESSAGE);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Override `HTMLCanvasContext.getCanvas()` to always create WebGL2 contexts with additional WebGL1 compatibility.
|
|
124
|
+
* Useful when attaching luma to a context from an external library does not support creating WebGL2 contexts.
|
|
125
|
+
*/
|
|
126
|
+
enforceWebGL2(enforce = true, adapters = []) {
|
|
127
|
+
const adapterMap = this.getAdapterMap(adapters);
|
|
128
|
+
const webgl2Adapter = adapterMap.get('webgl');
|
|
129
|
+
if (!webgl2Adapter) {
|
|
130
|
+
log.warn('enforceWebGL2: webgl adapter not found')();
|
|
131
|
+
}
|
|
132
|
+
webgl2Adapter?.enforceWebGL2?.(enforce);
|
|
133
|
+
}
|
|
134
|
+
/** Convert a list of adapters to a map */
|
|
135
|
+
getAdapterMap(adapters = []) {
|
|
136
|
+
const map = new Map(this.preregisteredAdapters);
|
|
137
|
+
for (const adapter of adapters) {
|
|
138
|
+
map.set(adapter.type, adapter);
|
|
139
|
+
}
|
|
140
|
+
return map;
|
|
141
|
+
}
|
|
142
|
+
// DEPRECATED
|
|
143
|
+
/** @deprecated Use registerAdapters */
|
|
144
|
+
registerDevices(deviceClasses) {
|
|
145
|
+
log.warn('luma.registerDevices() is deprecated, use luma.registerAdapters() instead');
|
|
146
|
+
for (const deviceClass of deviceClasses) {
|
|
147
|
+
const adapter = deviceClass.adapter;
|
|
148
|
+
if (adapter) {
|
|
149
|
+
this.preregisteredAdapters.set(adapter.type, adapter);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Entry point to the luma.gl GPU abstraction
|
|
156
|
+
* Register WebGPU and/or WebGL adapters (controls application bundle size)
|
|
157
|
+
* Run-time selection of the first available Device
|
|
158
|
+
*/
|
|
159
|
+
export const luma = new Luma();
|
|
@@ -65,16 +65,16 @@ export class Buffer extends Resource {
|
|
|
65
65
|
debugData = new ArrayBuffer(0);
|
|
66
66
|
/** This doesn't handle partial non-zero offset updates correctly */
|
|
67
67
|
_setDebugData(data, byteOffset, byteLength) {
|
|
68
|
-
const
|
|
68
|
+
const arrayBuffer = ArrayBuffer.isView(data) ? data.buffer : data;
|
|
69
69
|
const debugDataLength = Math.min(data ? data.byteLength : byteLength, Buffer.DEBUG_DATA_MAX_LENGTH);
|
|
70
|
-
if (
|
|
70
|
+
if (arrayBuffer === null) {
|
|
71
71
|
this.debugData = new ArrayBuffer(debugDataLength);
|
|
72
72
|
}
|
|
73
|
-
else if (byteOffset === 0 && byteLength ===
|
|
74
|
-
this.debugData =
|
|
73
|
+
else if (byteOffset === 0 && byteLength === arrayBuffer.byteLength) {
|
|
74
|
+
this.debugData = arrayBuffer.slice(0, debugDataLength);
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
|
-
this.debugData =
|
|
77
|
+
this.debugData = arrayBuffer.slice(byteOffset, byteOffset + debugDataLength);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -23,6 +23,8 @@ export declare abstract class ComputePipeline extends Resource<ComputePipelinePr
|
|
|
23
23
|
static defaultProps: Required<ComputePipelineProps>;
|
|
24
24
|
get [Symbol.toStringTag](): string;
|
|
25
25
|
hash: string;
|
|
26
|
+
/** The merged shader layout */
|
|
27
|
+
shaderLayout: ComputeShaderLayout;
|
|
26
28
|
constructor(device: Device, props: ComputePipelineProps);
|
|
27
29
|
/**
|
|
28
30
|
* @todo Use renderpass.setBindings() ?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/compute-pipeline.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,sBAAmB;AACnD,OAAO,KAAK,EAAC,mBAAmB,EAAE,OAAO,EAAC,kCAA+B;AACzE,OAAO,KAAK,EAAC,MAAM,EAAC,qBAAkB;AACtC,OAAO,KAAK,EAAC,MAAM,EAAC,oBAAiB;AAErC;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iHAAiH;IACjH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,8BAAsB,eAAgB,SAAQ,QAAQ,CAAC,oBAAoB,CAAC;IAC1E,OAAgB,YAAY,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAM1D;IAEF,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;IAED,IAAI,EAAE,MAAM,CAAM;
|
|
1
|
+
{"version":3,"file":"compute-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/compute-pipeline.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,sBAAmB;AACnD,OAAO,KAAK,EAAC,mBAAmB,EAAE,OAAO,EAAC,kCAA+B;AACzE,OAAO,KAAK,EAAC,MAAM,EAAC,qBAAkB;AACtC,OAAO,KAAK,EAAC,MAAM,EAAC,oBAAiB;AAErC;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iHAAiH;IACjH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,8BAAsB,eAAgB,SAAQ,QAAQ,CAAC,oBAAoB,CAAC;IAC1E,OAAgB,YAAY,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAM1D;IAEF,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;IAED,IAAI,EAAE,MAAM,CAAM;IAClB,+BAA+B;IAC/B,YAAY,EAAE,mBAAmB,CAAC;gBAEtB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB;IAKvD;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAC9D"}
|
|
@@ -17,7 +17,10 @@ export class ComputePipeline extends Resource {
|
|
|
17
17
|
return 'ComputePipeline';
|
|
18
18
|
}
|
|
19
19
|
hash = '';
|
|
20
|
+
/** The merged shader layout */
|
|
21
|
+
shaderLayout;
|
|
20
22
|
constructor(device, props) {
|
|
21
23
|
super(device, props, ComputePipeline.defaultProps);
|
|
24
|
+
this.shaderLayout = props.shaderLayout;
|
|
22
25
|
}
|
|
23
26
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Device } from "../device.js";
|
|
2
2
|
import { Resource, ResourceProps } from "./resource.js";
|
|
3
3
|
export type ExternalTextureProps = ResourceProps & {
|
|
4
|
-
source: HTMLVideoElement
|
|
4
|
+
source: HTMLVideoElement;
|
|
5
5
|
colorSpace?: 'srgb';
|
|
6
6
|
};
|
|
7
7
|
export declare abstract class ExternalTexture extends Resource<ExternalTextureProps> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/external-texture.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,qBAAkB;AACtC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,sBAAmB;AAEnD,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,MAAM,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"external-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/external-texture.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,qBAAkB;AACtC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,sBAAmB;AAEnD,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AACF,8BAAsB,eAAgB,SAAQ,QAAQ,CAAC,oBAAoB,CAAC;IAC1E,OAAgB,YAAY,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAI1D;IAEF,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;gBAEW,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB;CAGxD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ColorTextureFormat, DepthStencilTextureFormat, TextureFormat } from "
|
|
1
|
+
import type { ColorTextureFormat, DepthStencilTextureFormat, TextureFormat } from "../../gpu-type-utils/texture-formats.js";
|
|
2
2
|
import type { Device } from "../device.js";
|
|
3
3
|
import { Resource, ResourceProps } from "./resource.js";
|
|
4
4
|
import { Texture } from "./texture.js";
|
|
@@ -21,9 +21,9 @@ export declare abstract class Framebuffer extends Resource<FramebufferProps> {
|
|
|
21
21
|
/** Height of all attachments in this framebuffer */
|
|
22
22
|
height: number;
|
|
23
23
|
/** Color attachments */
|
|
24
|
-
colorAttachments: TextureView[];
|
|
24
|
+
abstract colorAttachments: TextureView[];
|
|
25
25
|
/** Depth-stencil attachment, if provided */
|
|
26
|
-
depthStencilAttachment: TextureView | null;
|
|
26
|
+
abstract depthStencilAttachment: TextureView | null;
|
|
27
27
|
constructor(device: Device, props?: FramebufferProps);
|
|
28
28
|
/**
|
|
29
29
|
* Resizes all attachments
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/framebuffer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EACzB,aAAa,EACd,
|
|
1
|
+
{"version":3,"file":"framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/framebuffer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EACzB,aAAa,EACd,gDAA6C;AAC9C,OAAO,KAAK,EAAC,MAAM,EAAC,qBAAkB;AACtC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,sBAAmB;AACnD,OAAO,EAAC,OAAO,EAAC,qBAAkB;AAClC,OAAO,EAAC,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