@luma.gl/core 9.2.5 → 9.3.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/canvas-context.d.ts +6 -162
- package/dist/adapter/canvas-context.d.ts.map +1 -1
- package/dist/adapter/canvas-context.js +5 -419
- package/dist/adapter/canvas-context.js.map +1 -1
- package/dist/adapter/canvas-observer.d.ts +32 -0
- package/dist/adapter/canvas-observer.d.ts.map +1 -0
- package/dist/adapter/canvas-observer.js +90 -0
- package/dist/adapter/canvas-observer.js.map +1 -0
- package/dist/adapter/canvas-surface.d.ts +150 -0
- package/dist/adapter/canvas-surface.d.ts.map +1 -0
- package/dist/adapter/canvas-surface.js +392 -0
- package/dist/adapter/canvas-surface.js.map +1 -0
- package/dist/adapter/device.d.ts +81 -16
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +196 -10
- package/dist/adapter/device.js.map +1 -1
- package/dist/adapter/luma.js +1 -1
- package/dist/adapter/luma.js.map +1 -1
- package/dist/adapter/presentation-context.d.ts +11 -0
- package/dist/adapter/presentation-context.d.ts.map +1 -0
- package/dist/adapter/presentation-context.js +12 -0
- package/dist/adapter/presentation-context.js.map +1 -0
- package/dist/adapter/resources/buffer.d.ts +5 -5
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js +18 -7
- package/dist/adapter/resources/buffer.js.map +1 -1
- package/dist/adapter/resources/command-buffer.d.ts +3 -1
- package/dist/adapter/resources/command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/command-buffer.js +3 -1
- package/dist/adapter/resources/command-buffer.js.map +1 -1
- package/dist/adapter/resources/command-encoder.d.ts +30 -7
- package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/command-encoder.js +68 -2
- package/dist/adapter/resources/command-encoder.js.map +1 -1
- package/dist/adapter/resources/compute-pipeline.d.ts +2 -2
- package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/fence.d.ts +16 -0
- package/dist/adapter/resources/fence.d.ts.map +1 -0
- package/dist/adapter/resources/fence.js +17 -0
- package/dist/adapter/resources/fence.js.map +1 -0
- package/dist/adapter/resources/framebuffer.d.ts +1 -1
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/framebuffer.js +15 -12
- package/dist/adapter/resources/framebuffer.js.map +1 -1
- package/dist/adapter/resources/query-set.d.ts +17 -1
- package/dist/adapter/resources/query-set.d.ts.map +1 -1
- package/dist/adapter/resources/query-set.js.map +1 -1
- package/dist/adapter/resources/render-pipeline.d.ts +28 -10
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.js +21 -2
- package/dist/adapter/resources/render-pipeline.js.map +1 -1
- package/dist/adapter/resources/resource.d.ts +13 -0
- package/dist/adapter/resources/resource.d.ts.map +1 -1
- package/dist/adapter/resources/resource.js +243 -14
- package/dist/adapter/resources/resource.js.map +1 -1
- package/dist/adapter/resources/shader.js +27 -25
- package/dist/adapter/resources/shader.js.map +1 -1
- package/dist/adapter/resources/shared-render-pipeline.d.ts +22 -0
- package/dist/adapter/resources/shared-render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/shared-render-pipeline.js +25 -0
- package/dist/adapter/resources/shared-render-pipeline.js.map +1 -0
- 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 +168 -28
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/texture.js +284 -25
- package/dist/adapter/resources/texture.js.map +1 -1
- package/dist/adapter/types/attachments.d.ts +1 -1
- package/dist/adapter/types/attachments.d.ts.map +1 -1
- 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/parameters.d.ts +3 -1
- package/dist/adapter/types/parameters.d.ts.map +1 -1
- package/dist/adapter/types/parameters.js +1 -0
- package/dist/adapter/types/parameters.js.map +1 -1
- package/dist/adapter/types/shader-layout.d.ts +10 -6
- package/dist/adapter/types/shader-layout.d.ts.map +1 -1
- package/dist/adapter/types/uniforms.d.ts +6 -0
- package/dist/adapter/types/uniforms.d.ts.map +1 -1
- package/dist/adapter-utils/bind-groups.d.ts +9 -0
- package/dist/adapter-utils/bind-groups.d.ts.map +1 -0
- package/dist/adapter-utils/bind-groups.js +41 -0
- package/dist/adapter-utils/bind-groups.js.map +1 -0
- package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -1
- package/dist/adapter-utils/format-compiler-log.js +23 -15
- package/dist/adapter-utils/format-compiler-log.js.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts +2 -2
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.js +6 -6
- package/dist/adapter-utils/get-attribute-from-layouts.js.map +1 -1
- package/dist/dist.dev.js +2692 -645
- package/dist/dist.min.js +10 -9
- package/dist/factories/bind-group-factory.d.ts +20 -0
- package/dist/factories/bind-group-factory.d.ts.map +1 -0
- package/dist/factories/bind-group-factory.js +79 -0
- package/dist/factories/bind-group-factory.js.map +1 -0
- package/dist/factories/core-module-state.d.ts +7 -0
- package/dist/factories/core-module-state.d.ts.map +1 -0
- package/dist/{shadertypes/data-types/shader-types.js → factories/core-module-state.js} +1 -1
- package/dist/factories/core-module-state.js.map +1 -0
- package/dist/factories/pipeline-factory.d.ts +54 -0
- package/dist/factories/pipeline-factory.d.ts.map +1 -0
- package/dist/factories/pipeline-factory.js +270 -0
- package/dist/factories/pipeline-factory.js.map +1 -0
- package/dist/factories/shader-factory.d.ts +20 -0
- package/dist/factories/shader-factory.d.ts.map +1 -0
- package/dist/factories/shader-factory.js +84 -0
- package/dist/factories/shader-factory.js.map +1 -0
- package/dist/index.cjs +2427 -554
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +30 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/portable/shader-block-writer.d.ts +51 -0
- package/dist/portable/shader-block-writer.d.ts.map +1 -0
- package/dist/portable/shader-block-writer.js +185 -0
- package/dist/portable/shader-block-writer.js.map +1 -0
- package/dist/portable/uniform-block.d.ts +1 -1
- package/dist/portable/uniform-block.d.ts.map +1 -1
- package/dist/portable/uniform-store.d.ts +55 -24
- package/dist/portable/uniform-store.d.ts.map +1 -1
- package/dist/portable/uniform-store.js +73 -25
- package/dist/portable/uniform-store.js.map +1 -1
- package/dist/shadertypes/data-types/data-type-decoder.d.ts +20 -0
- package/dist/shadertypes/data-types/data-type-decoder.d.ts.map +1 -0
- package/dist/shadertypes/data-types/data-type-decoder.js +79 -0
- package/dist/shadertypes/data-types/data-type-decoder.js.map +1 -0
- package/dist/shadertypes/data-types/data-types.d.ts +31 -12
- package/dist/shadertypes/data-types/data-types.d.ts.map +1 -1
- package/dist/shadertypes/data-types/decode-data-types.d.ts.map +1 -1
- package/dist/shadertypes/data-types/decode-data-types.js +2 -1
- package/dist/shadertypes/data-types/decode-data-types.js.map +1 -1
- package/dist/{image-utils → shadertypes/image-types}/image-types.d.ts +0 -6
- package/dist/shadertypes/image-types/image-types.d.ts.map +1 -0
- package/dist/shadertypes/image-types/image-types.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-block-layout.d.ts +72 -0
- package/dist/shadertypes/shader-types/shader-block-layout.d.ts.map +1 -0
- package/dist/shadertypes/shader-types/shader-block-layout.js +209 -0
- package/dist/shadertypes/shader-types/shader-block-layout.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-type-decoder.d.ts +41 -0
- package/dist/shadertypes/shader-types/shader-type-decoder.d.ts.map +1 -0
- package/dist/shadertypes/{data-types/decode-shader-types.js → shader-types/shader-type-decoder.js} +43 -4
- package/dist/shadertypes/shader-types/shader-type-decoder.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-types.d.ts +101 -0
- package/dist/shadertypes/shader-types/shader-types.d.ts.map +1 -0
- package/dist/shadertypes/shader-types/shader-types.js +30 -0
- package/dist/shadertypes/shader-types/shader-types.js.map +1 -0
- package/dist/shadertypes/texture-types/pixel-utils.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/pixel-utils.js +4 -4
- package/dist/shadertypes/texture-types/pixel-utils.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-decoder.d.ts +36 -0
- package/dist/shadertypes/texture-types/texture-format-decoder.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-format-decoder.js +109 -37
- package/dist/shadertypes/texture-types/texture-format-decoder.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-generics.d.ts +34 -0
- package/dist/shadertypes/texture-types/texture-format-generics.d.ts.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-generics.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-table.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-format-table.js +10 -9
- package/dist/shadertypes/texture-types/texture-format-table.js.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-formats.d.ts +51 -17
- package/dist/shadertypes/texture-types/texture-formats.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-formats.js +1 -0
- package/dist/shadertypes/texture-types/texture-formats.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-layout.d.ts +5 -0
- package/dist/shadertypes/texture-types/texture-layout.d.ts.map +1 -0
- package/dist/shadertypes/texture-types/texture-layout.js +41 -0
- package/dist/shadertypes/texture-types/texture-layout.js.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts +24 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.js +106 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.js.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-formats.d.ts +50 -0
- package/dist/shadertypes/vertex-types/vertex-formats.d.ts.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-formats.js.map +1 -0
- package/dist/utils/array-equal.d.ts +1 -1
- package/dist/utils/array-equal.d.ts.map +1 -1
- package/dist/utils/array-equal.js +15 -9
- package/dist/utils/array-equal.js.map +1 -1
- package/dist/utils/assert.d.ts +5 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/assert.js +17 -0
- package/dist/utils/assert.js.map +1 -0
- package/dist/utils/stats-manager.d.ts.map +1 -1
- package/dist/utils/stats-manager.js +61 -1
- package/dist/utils/stats-manager.js.map +1 -1
- package/package.json +6 -6
- package/src/adapter/canvas-context.ts +7 -556
- package/src/adapter/canvas-observer.ts +130 -0
- package/src/adapter/canvas-surface.ts +521 -0
- package/src/adapter/device.ts +312 -24
- package/src/adapter/presentation-context.ts +16 -0
- package/src/adapter/resources/buffer.ts +19 -9
- package/src/adapter/resources/command-buffer.ts +4 -2
- package/src/adapter/resources/command-encoder.ts +101 -10
- package/src/adapter/resources/compute-pipeline.ts +2 -2
- package/src/adapter/resources/fence.ts +32 -0
- package/src/adapter/resources/framebuffer.ts +16 -13
- package/src/adapter/resources/query-set.ts +17 -1
- package/src/adapter/resources/render-pipeline.ts +52 -16
- package/src/adapter/resources/resource.ts +289 -14
- package/src/adapter/resources/shader.ts +28 -28
- package/src/adapter/resources/shared-render-pipeline.ts +40 -0
- package/src/adapter/resources/texture-view.ts +1 -1
- package/src/adapter/resources/texture.ts +427 -49
- package/src/adapter/types/attachments.ts +1 -1
- package/src/adapter/types/buffer-layout.ts +1 -1
- package/src/adapter/types/parameters.ts +4 -1
- package/src/adapter/types/shader-layout.ts +15 -9
- package/src/adapter/types/uniforms.ts +12 -0
- package/src/adapter-utils/bind-groups.ts +71 -0
- package/src/adapter-utils/format-compiler-log.ts +23 -15
- package/src/adapter-utils/get-attribute-from-layouts.ts +8 -11
- package/src/factories/bind-group-factory.ts +139 -0
- package/src/factories/core-module-state.ts +11 -0
- package/src/factories/pipeline-factory.ts +328 -0
- package/src/factories/shader-factory.ts +103 -0
- package/src/index.ts +70 -26
- package/src/portable/shader-block-writer.ts +254 -0
- package/src/portable/uniform-block.ts +1 -1
- package/src/portable/uniform-store.ts +98 -40
- package/src/shadertypes/data-types/data-type-decoder.ts +105 -0
- package/src/shadertypes/data-types/data-types.ts +100 -48
- package/src/shadertypes/data-types/decode-data-types.ts +2 -1
- package/src/{image-utils → shadertypes/image-types}/image-types.ts +0 -7
- package/src/shadertypes/shader-types/shader-block-layout.ts +340 -0
- package/src/shadertypes/{data-types/decode-shader-types.ts → shader-types/shader-type-decoder.ts} +88 -14
- package/src/shadertypes/shader-types/shader-types.ts +207 -0
- package/src/shadertypes/{textures → texture-types}/pixel-utils.ts +4 -4
- package/src/shadertypes/{textures → texture-types}/texture-format-decoder.ts +166 -45
- package/src/shadertypes/{textures → texture-types}/texture-format-generics.ts +42 -48
- package/src/shadertypes/{textures → texture-types}/texture-format-table.ts +10 -9
- package/src/shadertypes/{textures → texture-types}/texture-formats.ts +73 -17
- package/src/shadertypes/texture-types/texture-layout.ts +60 -0
- package/src/shadertypes/vertex-types/vertex-format-decoder.ts +131 -0
- package/src/shadertypes/vertex-types/vertex-formats.ts +183 -0
- package/src/utils/array-equal.ts +21 -9
- package/src/utils/assert.ts +18 -0
- package/src/utils/stats-manager.ts +76 -2
- package/dist/image-utils/image-types.d.ts.map +0 -1
- package/dist/image-utils/image-types.js.map +0 -1
- package/dist/portable/uniform-buffer-layout.d.ts +0 -28
- package/dist/portable/uniform-buffer-layout.d.ts.map +0 -1
- package/dist/portable/uniform-buffer-layout.js +0 -96
- package/dist/portable/uniform-buffer-layout.js.map +0 -1
- package/dist/shadertypes/data-types/decode-shader-types.d.ts +0 -17
- package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +0 -1
- package/dist/shadertypes/data-types/decode-shader-types.js.map +0 -1
- package/dist/shadertypes/data-types/shader-types.d.ts +0 -45
- package/dist/shadertypes/data-types/shader-types.d.ts.map +0 -1
- package/dist/shadertypes/data-types/shader-types.js.map +0 -1
- package/dist/shadertypes/textures/pixel-utils.d.ts.map +0 -1
- package/dist/shadertypes/textures/pixel-utils.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-decoder.d.ts +0 -18
- package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-decoder.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-generics.d.ts +0 -33
- package/dist/shadertypes/textures/texture-format-generics.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-generics.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-table.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-table.js.map +0 -1
- package/dist/shadertypes/textures/texture-formats.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-formats.js.map +0 -1
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts +0 -18
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts.map +0 -1
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js +0 -100
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js.map +0 -1
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts +0 -27
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts.map +0 -1
- package/dist/shadertypes/vertex-arrays/vertex-formats.js.map +0 -1
- package/src/portable/uniform-buffer-layout.ts +0 -118
- package/src/shadertypes/data-types/shader-types.ts +0 -87
- package/src/shadertypes/vertex-arrays/decode-vertex-format.ts +0 -124
- package/src/shadertypes/vertex-arrays/vertex-formats.ts +0 -91
- /package/dist/{image-utils → shadertypes/image-types}/image-types.js +0 -0
- /package/dist/shadertypes/{textures → texture-types}/pixel-utils.d.ts +0 -0
- /package/dist/shadertypes/{textures → texture-types}/texture-format-generics.js +0 -0
- /package/dist/shadertypes/{textures → texture-types}/texture-format-table.d.ts +0 -0
- /package/dist/shadertypes/{vertex-arrays → vertex-types}/vertex-formats.js +0 -0
package/src/adapter/device.ts
CHANGED
|
@@ -5,12 +5,18 @@
|
|
|
5
5
|
import {StatsManager, lumaStats} from '../utils/stats-manager';
|
|
6
6
|
import {log} from '../utils/log';
|
|
7
7
|
import {uid} from '../utils/uid';
|
|
8
|
-
import type {VertexFormat, VertexFormatInfo} from '../shadertypes/vertex-
|
|
9
|
-
import type {
|
|
8
|
+
import type {VertexFormat, VertexFormatInfo} from '../shadertypes/vertex-types/vertex-formats';
|
|
9
|
+
import type {
|
|
10
|
+
TextureFormat,
|
|
11
|
+
TextureFormatInfo,
|
|
12
|
+
CompressedTextureFormat
|
|
13
|
+
} from '../shadertypes/texture-types/texture-formats';
|
|
10
14
|
import type {CanvasContext, CanvasContextProps} from './canvas-context';
|
|
15
|
+
import type {PresentationContext, PresentationContextProps} from './presentation-context';
|
|
11
16
|
import type {BufferProps} from './resources/buffer';
|
|
12
17
|
import {Buffer} from './resources/buffer';
|
|
13
18
|
import type {RenderPipeline, RenderPipelineProps} from './resources/render-pipeline';
|
|
19
|
+
import type {SharedRenderPipeline} from './resources/shared-render-pipeline';
|
|
14
20
|
import type {ComputePipeline, ComputePipelineProps} from './resources/compute-pipeline';
|
|
15
21
|
import type {Sampler, SamplerProps} from './resources/sampler';
|
|
16
22
|
import type {Shader, ShaderProps} from './resources/shader';
|
|
@@ -24,11 +30,14 @@ import type {CommandBuffer} from './resources/command-buffer';
|
|
|
24
30
|
import type {VertexArray, VertexArrayProps} from './resources/vertex-array';
|
|
25
31
|
import type {TransformFeedback, TransformFeedbackProps} from './resources/transform-feedback';
|
|
26
32
|
import type {QuerySet, QuerySetProps} from './resources/query-set';
|
|
33
|
+
import type {Fence} from './resources/fence';
|
|
34
|
+
import type {Bindings, ComputeShaderLayout, ShaderLayout} from './types/shader-layout';
|
|
27
35
|
|
|
28
|
-
import {
|
|
29
|
-
import {textureFormatDecoder} from '../shadertypes/
|
|
30
|
-
import type {ExternalImage} from '../image-
|
|
31
|
-
import {isExternalImage, getExternalImageSize} from '../image-
|
|
36
|
+
import {vertexFormatDecoder} from '../shadertypes/vertex-types/vertex-format-decoder';
|
|
37
|
+
import {textureFormatDecoder} from '../shadertypes/texture-types/texture-format-decoder';
|
|
38
|
+
import type {ExternalImage} from '../shadertypes/image-types/image-types';
|
|
39
|
+
import {isExternalImage, getExternalImageSize} from '../shadertypes/image-types/image-types';
|
|
40
|
+
import {getTextureFormatTable} from '../shadertypes/texture-types/texture-format-table';
|
|
32
41
|
|
|
33
42
|
/**
|
|
34
43
|
* Identifies the GPU vendor and driver.
|
|
@@ -117,6 +126,84 @@ export abstract class DeviceLimits {
|
|
|
117
126
|
abstract maxComputeWorkgroupsPerDimension: number;
|
|
118
127
|
}
|
|
119
128
|
|
|
129
|
+
function formatErrorLogArguments(context: unknown, args: unknown[]): unknown[] {
|
|
130
|
+
const formattedContext = formatErrorLogValue(context);
|
|
131
|
+
const formattedArgs = args.map(formatErrorLogValue).filter(arg => arg !== undefined);
|
|
132
|
+
return [formattedContext, ...formattedArgs].filter(arg => arg !== undefined);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function formatErrorLogValue(value: unknown): unknown {
|
|
136
|
+
if (value === undefined) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
if (
|
|
140
|
+
value === null ||
|
|
141
|
+
typeof value === 'string' ||
|
|
142
|
+
typeof value === 'number' ||
|
|
143
|
+
typeof value === 'boolean'
|
|
144
|
+
) {
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
if (value instanceof Error) {
|
|
148
|
+
return value.message;
|
|
149
|
+
}
|
|
150
|
+
if (Array.isArray(value)) {
|
|
151
|
+
return value.map(formatErrorLogValue);
|
|
152
|
+
}
|
|
153
|
+
if (typeof value === 'object') {
|
|
154
|
+
if (hasCustomToString(value)) {
|
|
155
|
+
const stringValue = String(value);
|
|
156
|
+
if (stringValue !== '[object Object]') {
|
|
157
|
+
return stringValue;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (looksLikeGPUCompilationMessage(value)) {
|
|
162
|
+
return formatGPUCompilationMessage(value);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return value.constructor?.name || 'Object';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return String(value);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function hasCustomToString(value: object): boolean {
|
|
172
|
+
return (
|
|
173
|
+
'toString' in value &&
|
|
174
|
+
typeof value.toString === 'function' &&
|
|
175
|
+
value.toString !== Object.prototype.toString
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function looksLikeGPUCompilationMessage(value: object): value is {
|
|
180
|
+
message?: unknown;
|
|
181
|
+
type?: unknown;
|
|
182
|
+
lineNum?: unknown;
|
|
183
|
+
linePos?: unknown;
|
|
184
|
+
} {
|
|
185
|
+
return 'message' in value && 'type' in value;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function formatGPUCompilationMessage(value: {
|
|
189
|
+
message?: unknown;
|
|
190
|
+
type?: unknown;
|
|
191
|
+
lineNum?: unknown;
|
|
192
|
+
linePos?: unknown;
|
|
193
|
+
}): string {
|
|
194
|
+
const type = typeof value.type === 'string' ? value.type : 'message';
|
|
195
|
+
const message = typeof value.message === 'string' ? value.message : '';
|
|
196
|
+
const lineNum = typeof value.lineNum === 'number' ? value.lineNum : null;
|
|
197
|
+
const linePos = typeof value.linePos === 'number' ? value.linePos : null;
|
|
198
|
+
const location =
|
|
199
|
+
lineNum !== null && linePos !== null
|
|
200
|
+
? ` @ ${lineNum}:${linePos}`
|
|
201
|
+
: lineNum !== null
|
|
202
|
+
? ` @ ${lineNum}`
|
|
203
|
+
: '';
|
|
204
|
+
return `${type}${location}: ${message}`.trim();
|
|
205
|
+
}
|
|
206
|
+
|
|
120
207
|
/** Set-like class for features (lets apps check for WebGL / WebGPU extensions) */
|
|
121
208
|
export class DeviceFeatures {
|
|
122
209
|
protected features: Set<DeviceFeature>;
|
|
@@ -172,7 +259,6 @@ export type WebGPUDeviceFeature =
|
|
|
172
259
|
|
|
173
260
|
export type WebGLDeviceFeature =
|
|
174
261
|
// webgl extension features
|
|
175
|
-
| 'timer-query-webgl' // unify with WebGPU timestamp-query?
|
|
176
262
|
| 'compilation-status-async-webgl' // Non-blocking shader compile/link status query available
|
|
177
263
|
| 'provoking-vertex-webgl' // parameters.provokingVertex
|
|
178
264
|
| 'polygon-mode-webgl' // parameters.polygonMode and parameters.polygonOffsetLine
|
|
@@ -187,6 +273,7 @@ export type WebGLDeviceFeature =
|
|
|
187
273
|
| 'float16-renderable-webgl'
|
|
188
274
|
| 'rgb9e5ufloat-renderable-webgl'
|
|
189
275
|
| 'snorm8-renderable-webgl'
|
|
276
|
+
| 'norm16-webgl'
|
|
190
277
|
| 'norm16-renderable-webgl'
|
|
191
278
|
| 'snorm16-renderable-webgl'
|
|
192
279
|
|
|
@@ -241,18 +328,29 @@ export type DeviceProps = {
|
|
|
241
328
|
/** Error handler. If it returns a probe logger style function, it will be called at the site of the error to optimize console error links. */
|
|
242
329
|
onError?: (error: Error, context?: unknown) => unknown;
|
|
243
330
|
/** Called when the size of a CanvasContext's canvas changes */
|
|
244
|
-
onResize?: (
|
|
331
|
+
onResize?: (
|
|
332
|
+
ctx: CanvasContext | PresentationContext,
|
|
333
|
+
info: {oldPixelSize: [number, number]}
|
|
334
|
+
) => unknown;
|
|
245
335
|
/** Called when the absolute position of a CanvasContext's canvas changes. Must set `CanvasContextProps.trackPosition: true` */
|
|
246
|
-
onPositionChange?: (
|
|
336
|
+
onPositionChange?: (
|
|
337
|
+
ctx: CanvasContext | PresentationContext,
|
|
338
|
+
info: {oldPosition: [number, number]}
|
|
339
|
+
) => unknown;
|
|
247
340
|
/** Called when the visibility of a CanvasContext's canvas changes */
|
|
248
|
-
onVisibilityChange?: (ctx: CanvasContext) => unknown;
|
|
341
|
+
onVisibilityChange?: (ctx: CanvasContext | PresentationContext) => unknown;
|
|
249
342
|
/** Called when the device pixel ratio of a CanvasContext's canvas changes */
|
|
250
|
-
onDevicePixelRatioChange?: (
|
|
343
|
+
onDevicePixelRatioChange?: (
|
|
344
|
+
ctx: CanvasContext | PresentationContext,
|
|
345
|
+
info: {oldRatio: number}
|
|
346
|
+
) => unknown;
|
|
251
347
|
|
|
252
348
|
// DEBUG SETTINGS
|
|
253
349
|
|
|
254
350
|
/** Turn on implementation defined checks that slow down execution but help break where errors occur */
|
|
255
351
|
debug?: boolean;
|
|
352
|
+
/** Enable GPU timestamp collection without enabling all debug validation paths. */
|
|
353
|
+
debugGPUTime?: boolean;
|
|
256
354
|
/** Show shader source in browser? The default is `'error'`, meaning that logs are shown when shader compilation has errors */
|
|
257
355
|
debugShaders?: 'never' | 'errors' | 'warnings' | 'always';
|
|
258
356
|
/** Renders a small version of updated Framebuffers into the primary canvas context. Can be set in console luma.log.set('debug-framebuffers', true) */
|
|
@@ -278,15 +376,31 @@ export type DeviceProps = {
|
|
|
278
376
|
_initializeFeatures?: boolean;
|
|
279
377
|
/** Enable shader caching (via ShaderFactory) */
|
|
280
378
|
_cacheShaders?: boolean;
|
|
281
|
-
/**
|
|
379
|
+
/**
|
|
380
|
+
* Destroy cached shaders when they become unused.
|
|
381
|
+
* Defaults to `false` so repeated create/destroy cycles can still reuse cached shaders.
|
|
382
|
+
* Enable this if the application creates very large numbers of distinct shaders and needs cache eviction.
|
|
383
|
+
*/
|
|
384
|
+
_destroyShaders?: boolean;
|
|
385
|
+
/** Enable pipeline caching (via PipelineFactory) */
|
|
282
386
|
_cachePipelines?: boolean;
|
|
283
|
-
/**
|
|
284
|
-
|
|
387
|
+
/** Enable sharing of backend render-pipeline implementations when caching is enabled. Currently used by WebGL. */
|
|
388
|
+
_sharePipelines?: boolean;
|
|
389
|
+
/**
|
|
390
|
+
* Destroy cached pipelines when they become unused.
|
|
391
|
+
* Defaults to `false` so repeated create/destroy cycles can still reuse cached pipelines.
|
|
392
|
+
* Enable this if the application creates very large numbers of distinct pipelines and needs cache eviction.
|
|
393
|
+
*/
|
|
394
|
+
_destroyPipelines?: boolean;
|
|
285
395
|
|
|
286
396
|
/** @deprecated Internal, Do not use directly! Use `luma.attachDevice()` to attach to pre-created contexts/devices. */
|
|
287
397
|
_handle?: unknown; // WebGL2RenderingContext | GPUDevice | null;
|
|
288
398
|
};
|
|
289
399
|
|
|
400
|
+
type DeviceFactories = {
|
|
401
|
+
bindGroupFactory?: unknown;
|
|
402
|
+
};
|
|
403
|
+
|
|
290
404
|
/** WebGL independent copy of WebGLContextAttributes */
|
|
291
405
|
type WebGLContextProps = {
|
|
292
406
|
/** indicates if the canvas contains an alpha buffer. */
|
|
@@ -349,7 +463,8 @@ export abstract class Device {
|
|
|
349
463
|
log.log(1, `${context} DPR changed ${info.oldRatio} => ${context.devicePixelRatio}`)(),
|
|
350
464
|
|
|
351
465
|
// Debug flags
|
|
352
|
-
debug:
|
|
466
|
+
debug: getDefaultDebugValue(),
|
|
467
|
+
debugGPUTime: false,
|
|
353
468
|
debugShaders: log.get('debug-shaders') || undefined!,
|
|
354
469
|
debugFramebuffers: Boolean(log.get('debug-framebuffers')),
|
|
355
470
|
debugFactories: Boolean(log.get('debug-factories')),
|
|
@@ -360,9 +475,11 @@ export abstract class Device {
|
|
|
360
475
|
// Experimental
|
|
361
476
|
_reuseDevices: false,
|
|
362
477
|
_requestMaxLimits: true,
|
|
363
|
-
_cacheShaders:
|
|
364
|
-
|
|
365
|
-
|
|
478
|
+
_cacheShaders: true,
|
|
479
|
+
_destroyShaders: false,
|
|
480
|
+
_cachePipelines: true,
|
|
481
|
+
_sharePipelines: true,
|
|
482
|
+
_destroyPipelines: false,
|
|
366
483
|
// TODO - Change these after confirming things work as expected
|
|
367
484
|
_initializeFeatures: true,
|
|
368
485
|
_disabledFeatures: {
|
|
@@ -394,13 +511,15 @@ export abstract class Device {
|
|
|
394
511
|
userData: {[key: string]: unknown} = {};
|
|
395
512
|
/** stats */
|
|
396
513
|
readonly statsManager: StatsManager = lumaStats;
|
|
514
|
+
/** Internal per-device factory storage */
|
|
515
|
+
_factories: DeviceFactories = {};
|
|
397
516
|
/** An abstract timestamp used for change tracking */
|
|
398
517
|
timestamp: number = 0;
|
|
399
518
|
|
|
400
519
|
/** True if this device has been reused during device creation (app has multiple references) */
|
|
401
520
|
_reused: boolean = false;
|
|
402
521
|
/** Used by other luma.gl modules to store data on the device */
|
|
403
|
-
|
|
522
|
+
private _moduleData: Record<string, Record<string, unknown>> = {};
|
|
404
523
|
|
|
405
524
|
// Capabilities
|
|
406
525
|
|
|
@@ -419,6 +538,8 @@ export abstract class Device {
|
|
|
419
538
|
abstract preferredDepthFormat: 'depth16' | 'depth24plus' | 'depth32float';
|
|
420
539
|
|
|
421
540
|
protected _textureCaps: Partial<Record<TextureFormat, DeviceTextureFormatCapabilities>> = {};
|
|
541
|
+
/** Internal timestamp query set used when GPU timing collection is enabled for this device. */
|
|
542
|
+
protected _debugGPUTimeQuery: QuerySet | null = null;
|
|
422
543
|
|
|
423
544
|
constructor(props: DeviceProps) {
|
|
424
545
|
this.props = {...Device.defaultProps, ...props};
|
|
@@ -427,8 +548,10 @@ export abstract class Device {
|
|
|
427
548
|
|
|
428
549
|
abstract destroy(): void;
|
|
429
550
|
|
|
551
|
+
// TODO - just expose the shadertypes decoders?
|
|
552
|
+
|
|
430
553
|
getVertexFormatInfo(format: VertexFormat): VertexFormatInfo {
|
|
431
|
-
return getVertexFormatInfo(format);
|
|
554
|
+
return vertexFormatDecoder.getVertexFormatInfo(format);
|
|
432
555
|
}
|
|
433
556
|
|
|
434
557
|
isVertexFormatSupported(format: VertexFormat): boolean {
|
|
@@ -451,9 +574,6 @@ export abstract class Device {
|
|
|
451
574
|
return textureCaps;
|
|
452
575
|
}
|
|
453
576
|
|
|
454
|
-
/** Return the implementation specific alignment for a texture format. 1 on WebGL, 256 on WebGPU */
|
|
455
|
-
abstract getTextureByteAlignment(): number;
|
|
456
|
-
|
|
457
577
|
/** Calculates the number of mip levels for a texture of width, height and in case of 3d textures only, depth */
|
|
458
578
|
getMipLevelCount(width: number, height: number, depth3d: number = 1): number {
|
|
459
579
|
const maxSize = Math.max(width, height, depth3d);
|
|
@@ -490,6 +610,19 @@ export abstract class Device {
|
|
|
490
610
|
return textureFormatDecoder.isCompressed(format);
|
|
491
611
|
}
|
|
492
612
|
|
|
613
|
+
/** Returns the compressed texture formats that can be created and sampled on this device */
|
|
614
|
+
getSupportedCompressedTextureFormats(): CompressedTextureFormat[] {
|
|
615
|
+
const supportedFormats: CompressedTextureFormat[] = [];
|
|
616
|
+
|
|
617
|
+
for (const format of Object.keys(getTextureFormatTable()) as TextureFormat[]) {
|
|
618
|
+
if (this.isTextureFormatCompressed(format) && this.isTextureFormatSupported(format)) {
|
|
619
|
+
supportedFormats.push(format as CompressedTextureFormat);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
return supportedFormats;
|
|
624
|
+
}
|
|
625
|
+
|
|
493
626
|
// DEBUG METHODS
|
|
494
627
|
|
|
495
628
|
pushDebugGroup(groupLabel: string): void {
|
|
@@ -547,8 +680,14 @@ export abstract class Device {
|
|
|
547
680
|
// Call the error handler
|
|
548
681
|
const isHandled = this.props.onError(error, context);
|
|
549
682
|
if (!isHandled) {
|
|
683
|
+
const logArguments = formatErrorLogArguments(context, args);
|
|
550
684
|
// Note: Returns a function that must be called: `device.reportError(...)()`
|
|
551
|
-
return log.error(
|
|
685
|
+
return log.error(
|
|
686
|
+
this.type === 'webgl' ? '%cWebGL' : '%cWebGPU',
|
|
687
|
+
'color: white; background: red; padding: 2px 6px; border-radius: 3px;',
|
|
688
|
+
error.message,
|
|
689
|
+
...logArguments
|
|
690
|
+
);
|
|
552
691
|
}
|
|
553
692
|
return () => {};
|
|
554
693
|
}
|
|
@@ -583,6 +722,9 @@ or create a device with the 'debug: true' prop.`;
|
|
|
583
722
|
/** Creates a new CanvasContext (WebGPU only) */
|
|
584
723
|
abstract createCanvasContext(props?: CanvasContextProps): CanvasContext;
|
|
585
724
|
|
|
725
|
+
/** Creates a presentation context for a destination canvas. WebGL requires the default canvas context to use an OffscreenCanvas. */
|
|
726
|
+
abstract createPresentationContext(props?: PresentationContextProps): PresentationContext;
|
|
727
|
+
|
|
586
728
|
/** Call after rendering a frame (necessary e.g. on WebGL OffscreenCanvas) */
|
|
587
729
|
abstract submit(commandBuffer?: CommandBuffer): void;
|
|
588
730
|
|
|
@@ -622,6 +764,11 @@ or create a device with the 'debug: true' prop.`;
|
|
|
622
764
|
|
|
623
765
|
abstract createQuerySet(props: QuerySetProps): QuerySet;
|
|
624
766
|
|
|
767
|
+
/** Create a fence sync object */
|
|
768
|
+
createFence(): Fence {
|
|
769
|
+
throw new Error('createFence() not implemented');
|
|
770
|
+
}
|
|
771
|
+
|
|
625
772
|
/** Create a RenderPass using the default CommandEncoder */
|
|
626
773
|
beginRenderPass(props?: RenderPassProps): RenderPass {
|
|
627
774
|
return this.commandEncoder.beginRenderPass(props);
|
|
@@ -632,6 +779,101 @@ or create a device with the 'debug: true' prop.`;
|
|
|
632
779
|
return this.commandEncoder.beginComputePass(props);
|
|
633
780
|
}
|
|
634
781
|
|
|
782
|
+
/**
|
|
783
|
+
* Generate mipmaps for a WebGPU texture.
|
|
784
|
+
* WebGPU textures must be created up front with the required mip count, usage flags, and a format that supports the chosen generation path.
|
|
785
|
+
* WebGL uses `Texture.generateMipmapsWebGL()` directly because the backend manages mip generation on the texture object itself.
|
|
786
|
+
*/
|
|
787
|
+
generateMipmapsWebGPU(_texture: Texture): void {
|
|
788
|
+
throw new Error('not implemented');
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/** Internal helper for creating a shareable WebGL render-pipeline implementation. */
|
|
792
|
+
_createSharedRenderPipelineWebGL(_props: RenderPipelineProps): SharedRenderPipeline {
|
|
793
|
+
throw new Error('_createSharedRenderPipelineWebGL() not implemented');
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/** Internal WebGPU-only helper for retrieving the native bind-group layout for a pipeline group. */
|
|
797
|
+
_createBindGroupLayoutWebGPU(
|
|
798
|
+
_pipeline: RenderPipeline | ComputePipeline,
|
|
799
|
+
_group: number
|
|
800
|
+
): unknown {
|
|
801
|
+
throw new Error('_createBindGroupLayoutWebGPU() not implemented');
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/** Internal WebGPU-only helper for creating a native bind group. */
|
|
805
|
+
_createBindGroupWebGPU(
|
|
806
|
+
_bindGroupLayout: unknown,
|
|
807
|
+
_shaderLayout: ShaderLayout | ComputeShaderLayout,
|
|
808
|
+
_bindings: Bindings,
|
|
809
|
+
_group: number
|
|
810
|
+
): unknown {
|
|
811
|
+
throw new Error('_createBindGroupWebGPU() not implemented');
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Internal helper that returns `true` when timestamp-query GPU timing should be
|
|
816
|
+
* collected for this device.
|
|
817
|
+
*/
|
|
818
|
+
_supportsDebugGPUTime(): boolean {
|
|
819
|
+
return (
|
|
820
|
+
this.features.has('timestamp-query') && Boolean(this.props.debug || this.props.debugGPUTime)
|
|
821
|
+
);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Internal helper that enables device-managed GPU timing collection on the
|
|
826
|
+
* default command encoder. Reuses the existing query set if timing is already enabled.
|
|
827
|
+
*
|
|
828
|
+
* @param queryCount - Number of timestamp slots reserved for profiled passes.
|
|
829
|
+
* @returns The device-managed timestamp QuerySet, or `null` when timing is not supported or could not be enabled.
|
|
830
|
+
*/
|
|
831
|
+
_enableDebugGPUTime(queryCount: number = 256): QuerySet | null {
|
|
832
|
+
if (!this._supportsDebugGPUTime()) {
|
|
833
|
+
return null;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
if (this._debugGPUTimeQuery) {
|
|
837
|
+
return this._debugGPUTimeQuery;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
try {
|
|
841
|
+
this._debugGPUTimeQuery = this.createQuerySet({type: 'timestamp', count: queryCount});
|
|
842
|
+
this.commandEncoder = this.createCommandEncoder({
|
|
843
|
+
id: this.commandEncoder.props.id,
|
|
844
|
+
timeProfilingQuerySet: this._debugGPUTimeQuery
|
|
845
|
+
});
|
|
846
|
+
} catch {
|
|
847
|
+
this._debugGPUTimeQuery = null;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
return this._debugGPUTimeQuery;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Internal helper that disables device-managed GPU timing collection and restores
|
|
855
|
+
* the default command encoder to an unprofiled state.
|
|
856
|
+
*/
|
|
857
|
+
_disableDebugGPUTime(): void {
|
|
858
|
+
if (!this._debugGPUTimeQuery) {
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
if (this.commandEncoder.getTimeProfilingQuerySet() === this._debugGPUTimeQuery) {
|
|
863
|
+
this.commandEncoder = this.createCommandEncoder({
|
|
864
|
+
id: this.commandEncoder.props.id
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
this._debugGPUTimeQuery.destroy();
|
|
869
|
+
this._debugGPUTimeQuery = null;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/** Internal helper that returns `true` when device-managed GPU timing is currently active. */
|
|
873
|
+
_isDebugGPUTimeEnabled(): boolean {
|
|
874
|
+
return this._debugGPUTimeQuery !== null;
|
|
875
|
+
}
|
|
876
|
+
|
|
635
877
|
/**
|
|
636
878
|
* Determines what operations are supported on a texture format, checking against supported device features
|
|
637
879
|
* Subclasses override to apply additional checks
|
|
@@ -711,6 +953,15 @@ or create a device with the 'debug: true' prop.`;
|
|
|
711
953
|
throw new Error('not implemented');
|
|
712
954
|
}
|
|
713
955
|
|
|
956
|
+
// INTERNAL LUMA.GL METHODS
|
|
957
|
+
|
|
958
|
+
getModuleData<ModuleDataT extends Record<string, unknown>>(moduleName: string): ModuleDataT {
|
|
959
|
+
this._moduleData[moduleName] ||= {};
|
|
960
|
+
return this._moduleData[moduleName] as ModuleDataT;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// INTERNAL HELPERS
|
|
964
|
+
|
|
714
965
|
// IMPLEMENTATION
|
|
715
966
|
|
|
716
967
|
/** Helper to get the canvas context props */
|
|
@@ -756,6 +1007,10 @@ or create a device with the 'debug: true' prop.`;
|
|
|
756
1007
|
newProps.indexType = 'uint32';
|
|
757
1008
|
} else if (props.data instanceof Uint16Array) {
|
|
758
1009
|
newProps.indexType = 'uint16';
|
|
1010
|
+
} else if (props.data instanceof Uint8Array) {
|
|
1011
|
+
// Convert uint8 to uint16 for WebGPU compatibility (WebGPU doesn't support uint8 indices)
|
|
1012
|
+
newProps.data = new Uint16Array(props.data);
|
|
1013
|
+
newProps.indexType = 'uint16';
|
|
759
1014
|
}
|
|
760
1015
|
}
|
|
761
1016
|
if (!newProps.indexType) {
|
|
@@ -766,3 +1021,36 @@ or create a device with the 'debug: true' prop.`;
|
|
|
766
1021
|
return newProps;
|
|
767
1022
|
}
|
|
768
1023
|
}
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
* Internal helper for resolving the default `debug` prop.
|
|
1027
|
+
* Precedence is: explicit log debug value first, then `NODE_ENV`, then `false`.
|
|
1028
|
+
*/
|
|
1029
|
+
export function _getDefaultDebugValue(logDebugValue: unknown, nodeEnv?: string): boolean {
|
|
1030
|
+
if (logDebugValue !== undefined && logDebugValue !== null) {
|
|
1031
|
+
return Boolean(logDebugValue);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
if (nodeEnv !== undefined) {
|
|
1035
|
+
return nodeEnv !== 'production';
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
return false;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
function getDefaultDebugValue(): boolean {
|
|
1042
|
+
return _getDefaultDebugValue(log.get('debug'), getNodeEnv());
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
function getNodeEnv(): string | undefined {
|
|
1046
|
+
const processObject = (
|
|
1047
|
+
globalThis as typeof globalThis & {
|
|
1048
|
+
process?: {env?: Record<string, string | undefined>};
|
|
1049
|
+
}
|
|
1050
|
+
).process;
|
|
1051
|
+
if (!processObject?.env) {
|
|
1052
|
+
return undefined;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
return processObject.env['NODE_ENV'];
|
|
1056
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {CanvasSurface} from './canvas-surface';
|
|
6
|
+
|
|
7
|
+
export type {CanvasContextProps as PresentationContextProps} from './canvas-surface';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Tracks a destination canvas for presentation.
|
|
11
|
+
* Backend implementations either borrow the default GPU-backed canvas (WebGL)
|
|
12
|
+
* or render directly into the destination canvas (WebGPU).
|
|
13
|
+
*/
|
|
14
|
+
export abstract class PresentationContext extends CanvasSurface {
|
|
15
|
+
abstract present(): void;
|
|
16
|
+
}
|
|
@@ -17,8 +17,8 @@ export type BufferProps = ResourceProps & {
|
|
|
17
17
|
byteLength?: number;
|
|
18
18
|
/** Byte offset into the newly created Buffer to store data at */
|
|
19
19
|
byteOffset?: number;
|
|
20
|
-
/** If props.usage includes Buffer.INDEX */
|
|
21
|
-
indexType?: 'uint16' | 'uint32';
|
|
20
|
+
/** If props.usage includes Buffer.INDEX. Note: uint8 indices are automatically converted to uint16 for WebGPU compatibility */
|
|
21
|
+
indexType?: 'uint8' | 'uint16' | 'uint32';
|
|
22
22
|
/** Data to initialize the buffer with. */
|
|
23
23
|
data?: ArrayBuffer | ArrayBufferView | null;
|
|
24
24
|
/** Callback to initialize data without copy */
|
|
@@ -50,8 +50,8 @@ export abstract class Buffer extends Resource<BufferProps> {
|
|
|
50
50
|
|
|
51
51
|
/** The usage with which this buffer was created */
|
|
52
52
|
readonly usage: number;
|
|
53
|
-
/** For index buffers, whether indices are 16 or 32 bit */
|
|
54
|
-
readonly indexType?: 'uint16' | 'uint32';
|
|
53
|
+
/** For index buffers, whether indices are 8, 16 or 32 bit. Note: uint8 indices are automatically converted to uint16 for WebGPU compatibility */
|
|
54
|
+
readonly indexType?: 'uint8' | 'uint16' | 'uint32';
|
|
55
55
|
/** Length of buffer in bytes */
|
|
56
56
|
abstract byteLength: number;
|
|
57
57
|
/** "Time" of last update, can be used to check if redraw is needed */
|
|
@@ -66,6 +66,8 @@ export abstract class Buffer extends Resource<BufferProps> {
|
|
|
66
66
|
deducedProps.indexType = 'uint32';
|
|
67
67
|
} else if (props.data instanceof Uint16Array) {
|
|
68
68
|
deducedProps.indexType = 'uint16';
|
|
69
|
+
} else if (props.data instanceof Uint8Array) {
|
|
70
|
+
deducedProps.indexType = 'uint8';
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
|
|
@@ -125,20 +127,28 @@ export abstract class Buffer extends Resource<BufferProps> {
|
|
|
125
127
|
/** This doesn't handle partial non-zero offset updates correctly */
|
|
126
128
|
protected _setDebugData(
|
|
127
129
|
data: ArrayBufferView | ArrayBufferLike | null,
|
|
128
|
-
|
|
130
|
+
_byteOffset: number,
|
|
129
131
|
byteLength: number
|
|
130
132
|
): void {
|
|
131
|
-
|
|
133
|
+
let arrayBufferView: ArrayBufferView | null = null;
|
|
134
|
+
let arrayBuffer: ArrayBufferLike | null;
|
|
135
|
+
if (ArrayBuffer.isView(data)) {
|
|
136
|
+
arrayBufferView = data;
|
|
137
|
+
arrayBuffer = data.buffer;
|
|
138
|
+
} else {
|
|
139
|
+
arrayBuffer = data;
|
|
140
|
+
}
|
|
132
141
|
const debugDataLength = Math.min(
|
|
133
142
|
data ? data.byteLength : byteLength,
|
|
134
143
|
Buffer.DEBUG_DATA_MAX_LENGTH
|
|
135
144
|
);
|
|
136
145
|
if (arrayBuffer === null) {
|
|
137
146
|
this.debugData = new ArrayBuffer(debugDataLength);
|
|
138
|
-
} else if (byteOffset === 0 && byteLength === arrayBuffer.byteLength) {
|
|
139
|
-
this.debugData = arrayBuffer.slice(0, debugDataLength);
|
|
140
147
|
} else {
|
|
141
|
-
|
|
148
|
+
const sourceByteOffset = Math.min(arrayBufferView?.byteOffset || 0, arrayBuffer.byteLength);
|
|
149
|
+
const availableByteLength = Math.max(0, arrayBuffer.byteLength - sourceByteOffset);
|
|
150
|
+
const copyByteLength = Math.min(debugDataLength, availableByteLength);
|
|
151
|
+
this.debugData = new Uint8Array(arrayBuffer, sourceByteOffset, copyByteLength).slice().buffer;
|
|
142
152
|
}
|
|
143
153
|
}
|
|
144
154
|
|
|
@@ -11,7 +11,7 @@ import {Resource, ResourceProps} from './resource';
|
|
|
11
11
|
// // onSubmittedWorkDone(): Promise<undefined>;
|
|
12
12
|
|
|
13
13
|
// writeBuffer(options: WriteBufferOptions): void;
|
|
14
|
-
// writeTexture(options:
|
|
14
|
+
// writeTexture(options: TextureWriteOptions): void;
|
|
15
15
|
|
|
16
16
|
// // copyExternalImageToTexture(
|
|
17
17
|
// // GPUImageCopyExternalImage source,
|
|
@@ -23,7 +23,9 @@ import {Resource, ResourceProps} from './resource';
|
|
|
23
23
|
export type CommandBufferProps = ResourceProps & {};
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Represents the finished contents of exactly one CommandEncoder. Backends may store native
|
|
27
|
+
* command buffers or replayable command lists internally, but submission must preserve the same
|
|
28
|
+
* recorded command ordering.
|
|
27
29
|
*/
|
|
28
30
|
export abstract class CommandBuffer extends Resource<CommandBufferProps> {
|
|
29
31
|
override get [Symbol.toStringTag](): string {
|