@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
package/src/adapter/device.ts
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {VERSION} from '../init';
|
|
6
5
|
import {StatsManager, lumaStats} from '../utils/stats-manager';
|
|
7
6
|
import {log} from '../utils/log';
|
|
8
|
-
import {uid} from '../utils/
|
|
9
|
-
import type {TextureFormat} from '
|
|
7
|
+
import {uid} from '../utils/uid';
|
|
8
|
+
import type {TextureFormat} from '../gpu-type-utils//texture-formats';
|
|
10
9
|
import type {CanvasContext, CanvasContextProps} from './canvas-context';
|
|
11
10
|
import type {BufferProps} from './resources/buffer';
|
|
12
11
|
import {Buffer} from './resources/buffer';
|
|
@@ -14,7 +13,7 @@ import type {RenderPipeline, RenderPipelineProps} from './resources/render-pipel
|
|
|
14
13
|
import type {ComputePipeline, ComputePipelineProps} from './resources/compute-pipeline';
|
|
15
14
|
import type {Sampler, SamplerProps} from './resources/sampler';
|
|
16
15
|
import type {Shader, ShaderProps} from './resources/shader';
|
|
17
|
-
import type {Texture, TextureProps
|
|
16
|
+
import type {Texture, TextureProps} from './resources/texture';
|
|
18
17
|
import type {ExternalTexture, ExternalTextureProps} from './resources/external-texture';
|
|
19
18
|
import type {Framebuffer, FramebufferProps} from './resources/framebuffer';
|
|
20
19
|
import type {RenderPass, RenderPassProps} from './resources/render-pass';
|
|
@@ -24,7 +23,7 @@ import type {VertexArray, VertexArrayProps} from './resources/vertex-array';
|
|
|
24
23
|
import type {TransformFeedback, TransformFeedbackProps} from './resources/transform-feedback';
|
|
25
24
|
import type {QuerySet, QuerySetProps} from './resources/query-set';
|
|
26
25
|
|
|
27
|
-
import {isTextureFormatCompressed} from '
|
|
26
|
+
import {isTextureFormatCompressed} from '../gpu-type-utils/decode-texture-format';
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
29
|
* Identifies the GPU vendor and driver.
|
|
@@ -131,7 +130,7 @@ export class DeviceFeatures {
|
|
|
131
130
|
}
|
|
132
131
|
|
|
133
132
|
has(feature: DeviceFeature): boolean {
|
|
134
|
-
return !this.disabledFeatures[feature] && this.features.has(feature);
|
|
133
|
+
return !this.disabledFeatures?.[feature] && this.features.has(feature);
|
|
135
134
|
}
|
|
136
135
|
}
|
|
137
136
|
|
|
@@ -146,7 +145,6 @@ export type WebGPUDeviceFeature =
|
|
|
146
145
|
| 'indirect-first-instance'
|
|
147
146
|
| 'timestamp-query'
|
|
148
147
|
| 'shader-f16'
|
|
149
|
-
| 'depth24unorm-stencil8'
|
|
150
148
|
| 'depth32float-stencil8'
|
|
151
149
|
| 'rg11b10ufloat-renderable' // Is the rg11b10ufloat texture format renderable?
|
|
152
150
|
| 'float32-filterable' // Is the float32 format filterable?
|
|
@@ -219,26 +217,42 @@ export type DeviceProps = {
|
|
|
219
217
|
/** Error handling */
|
|
220
218
|
onError?: (error: Error) => unknown;
|
|
221
219
|
|
|
222
|
-
//
|
|
220
|
+
// @deprecated Attach to existing context. Rename to handle? Use Device.attach?
|
|
221
|
+
gl?: WebGL2RenderingContext | null;
|
|
223
222
|
|
|
223
|
+
// DEBUG SETTINGS
|
|
224
224
|
/** WebGL: Instrument WebGL2RenderingContext (at the expense of performance) */
|
|
225
225
|
debug?: boolean;
|
|
226
226
|
/** Break on WebGL functions matching these strings */
|
|
227
227
|
break?: string[];
|
|
228
|
+
|
|
228
229
|
/** WebGL: Initialize the SpectorJS WebGL debugger */
|
|
229
|
-
|
|
230
|
+
debugWithSpectorJS?: boolean;
|
|
231
|
+
/** SpectorJS URL. Override if CDN is down or different SpectorJS version is desired */
|
|
232
|
+
spectorUrl?: string;
|
|
233
|
+
|
|
234
|
+
// EXPERIMENTAL SETTINGS
|
|
235
|
+
/** Set to false to disable WebGL state management instrumentation: TODO- Unclear if still supported / useful */
|
|
236
|
+
manageState?: boolean;
|
|
230
237
|
/** Initialize all features on startup */
|
|
231
238
|
initalizeFeatures?: boolean;
|
|
232
239
|
/** Disable specific features */
|
|
233
240
|
disabledFeatures?: Partial<Record<DeviceFeature, boolean>>;
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
manageState?: boolean;
|
|
237
|
-
|
|
238
|
-
// @deprecated Attach to existing context. Rename to handle? Use Device.attach?
|
|
239
|
-
gl?: WebGL2RenderingContext | null;
|
|
241
|
+
/** Never destroy cached shaders and pipelines */
|
|
242
|
+
_factoryDestroyPolicy?: 'unused' | 'never';
|
|
240
243
|
};
|
|
241
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Create and attach devices for a specific backend. Currently static methods on each device
|
|
247
|
+
*/
|
|
248
|
+
export interface DeviceFactory {
|
|
249
|
+
// new (props: DeviceProps): Device; Constructor isn't used
|
|
250
|
+
type: string;
|
|
251
|
+
isSupported(): boolean;
|
|
252
|
+
create(props: DeviceProps): Promise<Device>;
|
|
253
|
+
attach?(handle: unknown): Device;
|
|
254
|
+
}
|
|
255
|
+
|
|
242
256
|
/**
|
|
243
257
|
* WebGPU Device/WebGL context abstraction
|
|
244
258
|
*/
|
|
@@ -250,17 +264,12 @@ export abstract class Device {
|
|
|
250
264
|
manageState: true,
|
|
251
265
|
width: 800, // width are height are only used by headless gl
|
|
252
266
|
height: 600,
|
|
253
|
-
|
|
254
267
|
requestMaxLimits: true,
|
|
255
|
-
debug: Boolean(log.get('debug')), // Instrument context (at the expense of performance)
|
|
256
|
-
spector: Boolean(log.get('spector') || log.get('spectorjs')), // Initialize the SpectorJS WebGL debugger
|
|
257
|
-
break: [],
|
|
258
268
|
|
|
259
|
-
//
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
},
|
|
269
|
+
// Callbacks
|
|
270
|
+
onError: (error: Error) => log.error(error.message),
|
|
271
|
+
|
|
272
|
+
gl: null,
|
|
264
273
|
|
|
265
274
|
// alpha: undefined,
|
|
266
275
|
// depth: undefined,
|
|
@@ -270,18 +279,25 @@ export abstract class Device {
|
|
|
270
279
|
// preserveDrawingBuffer: undefined,
|
|
271
280
|
// failIfMajorPerformanceCaveat: undefined
|
|
272
281
|
|
|
273
|
-
|
|
282
|
+
debug: Boolean(log.get('debug')), // Instrument context (at the expense of performance)
|
|
283
|
+
break: (log.get('break') as string[]) || [],
|
|
274
284
|
|
|
275
|
-
//
|
|
276
|
-
|
|
285
|
+
// WebGL specific debugging
|
|
286
|
+
debugWithSpectorJS: undefined!,
|
|
287
|
+
spectorUrl: undefined!,
|
|
288
|
+
|
|
289
|
+
// TODO - Change these after confirming things work as expected
|
|
290
|
+
initalizeFeatures: true,
|
|
291
|
+
disabledFeatures: {
|
|
292
|
+
'compilation-status-async-webgl': true
|
|
293
|
+
},
|
|
294
|
+
_factoryDestroyPolicy: 'unused'
|
|
277
295
|
};
|
|
278
296
|
|
|
279
297
|
get [Symbol.toStringTag](): string {
|
|
280
298
|
return 'Device';
|
|
281
299
|
}
|
|
282
300
|
|
|
283
|
-
static VERSION = VERSION;
|
|
284
|
-
|
|
285
301
|
constructor(props: DeviceProps) {
|
|
286
302
|
this.props = {...Device.defaultProps, ...props};
|
|
287
303
|
this.id = this.props.id || uid(this[Symbol.toStringTag].toLowerCase());
|
|
@@ -343,6 +359,11 @@ export abstract class Device {
|
|
|
343
359
|
return false;
|
|
344
360
|
}
|
|
345
361
|
|
|
362
|
+
/** Report error (normally for unhandled device errors) */
|
|
363
|
+
error(error: Error): void {
|
|
364
|
+
this.props.onError(error);
|
|
365
|
+
}
|
|
366
|
+
|
|
346
367
|
// Canvas context
|
|
347
368
|
|
|
348
369
|
/** Default / primary canvas context. Can be null as WebGPU devices can be created without a CanvasContext */
|
|
@@ -370,14 +391,9 @@ export abstract class Device {
|
|
|
370
391
|
/** Create a texture */
|
|
371
392
|
abstract _createTexture(props: TextureProps): Texture;
|
|
372
393
|
createTexture(props: TextureProps): Texture;
|
|
373
|
-
createTexture(data: Promise<TextureData>): Texture;
|
|
374
|
-
createTexture(url: string): Texture;
|
|
394
|
+
// createTexture(data: Promise<TextureData>): Texture;
|
|
375
395
|
|
|
376
|
-
createTexture(props: TextureProps
|
|
377
|
-
// Signature: new Texture2D(gl, url | Promise)
|
|
378
|
-
if (props instanceof Promise || typeof props === 'string') {
|
|
379
|
-
props = {data: props};
|
|
380
|
-
}
|
|
396
|
+
createTexture(props: TextureProps): Texture {
|
|
381
397
|
return this._createTexture(props);
|
|
382
398
|
}
|
|
383
399
|
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Log} from '@probe.gl/log';
|
|
6
|
+
import type {DeviceProps} from './device';
|
|
7
|
+
import {Device} from './device';
|
|
8
|
+
import {Adapter} from './adapter';
|
|
9
|
+
import {StatsManager} from '../utils/stats-manager';
|
|
10
|
+
import {lumaStats} from '../utils/stats-manager';
|
|
11
|
+
import {log} from '../utils/log';
|
|
12
|
+
|
|
13
|
+
declare global {
|
|
14
|
+
// eslint-disable-next-line no-var
|
|
15
|
+
var luma: Luma;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const STARTUP_MESSAGE = 'set luma.log.level=1 (or higher) to trace rendering';
|
|
19
|
+
|
|
20
|
+
const ERROR_MESSAGE =
|
|
21
|
+
'No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.';
|
|
22
|
+
|
|
23
|
+
/** Properties for creating a new device */
|
|
24
|
+
export type CreateDeviceProps = DeviceProps & {
|
|
25
|
+
/** Selects the type of device. `best-available` uses webgpu if available, then webgl. */
|
|
26
|
+
type?: 'webgl' | 'webgpu' | 'unknown' | 'best-available';
|
|
27
|
+
adapters?: Adapter[];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** Properties for attaching an existing WebGL context or WebGPU device to a new luma Device */
|
|
31
|
+
export type AttachDeviceProps = DeviceProps & {
|
|
32
|
+
/** Externally created WebGL context or WebGPU device */
|
|
33
|
+
handle: unknown; // WebGL2RenderingContext | GPUDevice | null;
|
|
34
|
+
/** List of adapters. Will also search any pre-registered adapterss */
|
|
35
|
+
adapters?: Adapter[];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Entry point to the luma.gl GPU abstraction
|
|
40
|
+
* Register WebGPU and/or WebGL adapters (controls application bundle size)
|
|
41
|
+
* Run-time selection of the first available Device
|
|
42
|
+
*/
|
|
43
|
+
export class Luma {
|
|
44
|
+
static defaultProps: Required<CreateDeviceProps> = {
|
|
45
|
+
...Device.defaultProps,
|
|
46
|
+
type: 'best-available',
|
|
47
|
+
adapters: undefined!
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** Global stats for all devices */
|
|
51
|
+
readonly stats: StatsManager = lumaStats;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Global log
|
|
55
|
+
*
|
|
56
|
+
* Assign luma.log.level in console to control logging: \
|
|
57
|
+
* 0: none, 1: minimal, 2: verbose, 3: attribute/uniforms, 4: gl logs
|
|
58
|
+
* luma.log.break[], set to gl funcs, luma.log.profile[] set to model names`;
|
|
59
|
+
*/
|
|
60
|
+
readonly log: Log = log;
|
|
61
|
+
|
|
62
|
+
/** Version of luma.gl */
|
|
63
|
+
readonly VERSION: string =
|
|
64
|
+
// Version detection using build plugin
|
|
65
|
+
// @ts-expect-error no-undef
|
|
66
|
+
typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'running from source';
|
|
67
|
+
|
|
68
|
+
spector: unknown;
|
|
69
|
+
|
|
70
|
+
protected preregisteredAdapters = new Map<string, Adapter>();
|
|
71
|
+
|
|
72
|
+
constructor() {
|
|
73
|
+
if (globalThis.luma) {
|
|
74
|
+
if (globalThis.luma.VERSION !== this.VERSION) {
|
|
75
|
+
log.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)();
|
|
76
|
+
log.error(`'yarn why @luma.gl/core' can help identify the source of the conflict`)();
|
|
77
|
+
throw new Error(`luma.gl - multiple versions detected: see console log`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
log.error('This version of luma.gl has already been initialized')();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
log.log(1, `${this.VERSION} - ${STARTUP_MESSAGE}`)();
|
|
84
|
+
|
|
85
|
+
globalThis.luma = this;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
registerAdapters(adapters: Adapter[]): void {
|
|
89
|
+
for (const deviceClass of adapters) {
|
|
90
|
+
this.preregisteredAdapters.set(deviceClass.type, deviceClass);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Get type strings for supported Devices */
|
|
95
|
+
getSupportedAdapters(adapters: Adapter[] = []): string[] {
|
|
96
|
+
const adapterMap = this.getAdapterMap(adapters);
|
|
97
|
+
return Array.from(adapterMap)
|
|
98
|
+
.map(([, adapter]) => adapter)
|
|
99
|
+
.filter(adapter => adapter.isSupported?.())
|
|
100
|
+
.map(adapter => adapter.type);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Get type strings for best available Device */
|
|
104
|
+
getBestAvailableAdapter(adapters: Adapter[] = []): 'webgpu' | 'webgl' | null {
|
|
105
|
+
const adapterMap = this.getAdapterMap(adapters);
|
|
106
|
+
if (adapterMap.get('webgpu')?.isSupported?.()) {
|
|
107
|
+
return 'webgpu';
|
|
108
|
+
}
|
|
109
|
+
if (adapterMap.get('webgl')?.isSupported?.()) {
|
|
110
|
+
return 'webgl';
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
setDefaultDeviceProps(props: CreateDeviceProps): void {
|
|
116
|
+
Object.assign(Luma.defaultProps, props);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Creates a device. Asynchronously. */
|
|
120
|
+
async createDevice(props: CreateDeviceProps = {}): Promise<Device> {
|
|
121
|
+
props = {...Luma.defaultProps, ...props};
|
|
122
|
+
|
|
123
|
+
// Should be handled by attach device
|
|
124
|
+
// if (props.gl) {
|
|
125
|
+
// props.type = 'webgl';
|
|
126
|
+
// }
|
|
127
|
+
|
|
128
|
+
const adapterMap = this.getAdapterMap(props.adapters);
|
|
129
|
+
|
|
130
|
+
let type: string = props.type || '';
|
|
131
|
+
if (type === 'best-available') {
|
|
132
|
+
type = this.getBestAvailableAdapter(props.adapters) || type;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const adapters = this.getAdapterMap(props.adapters) || adapterMap;
|
|
136
|
+
|
|
137
|
+
const adapter = adapters.get(type);
|
|
138
|
+
const device = await adapter?.create?.(props);
|
|
139
|
+
if (device) {
|
|
140
|
+
return device;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
throw new Error(ERROR_MESSAGE);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice). */
|
|
147
|
+
async attachDevice(props: AttachDeviceProps): Promise<Device> {
|
|
148
|
+
const adapters = this.getAdapterMap(props.adapters);
|
|
149
|
+
|
|
150
|
+
// WebGL
|
|
151
|
+
let type = '';
|
|
152
|
+
if (props.handle instanceof WebGL2RenderingContext) {
|
|
153
|
+
type = 'webgl';
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// TODO - WebGPU does not yet have a stable API
|
|
157
|
+
// if (props.handle instanceof GPUDevice) {
|
|
158
|
+
// const WebGPUDevice = adapters.get('webgpu') as any;
|
|
159
|
+
// if (WebGPUDevice) {
|
|
160
|
+
// return (await WebGPUDevice.attach(props.handle)) as Device;
|
|
161
|
+
// }
|
|
162
|
+
// }
|
|
163
|
+
|
|
164
|
+
// null
|
|
165
|
+
if (props.handle === null) {
|
|
166
|
+
type = 'unknown';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const adapter = adapters.get(type);
|
|
170
|
+
const device = await adapter?.attach?.(null);
|
|
171
|
+
if (device) {
|
|
172
|
+
return device;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
throw new Error(ERROR_MESSAGE);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Override `HTMLCanvasContext.getCanvas()` to always create WebGL2 contexts with additional WebGL1 compatibility.
|
|
180
|
+
* Useful when attaching luma to a context from an external library does not support creating WebGL2 contexts.
|
|
181
|
+
*/
|
|
182
|
+
enforceWebGL2(enforce: boolean = true, adapters: Adapter[] = []): void {
|
|
183
|
+
const adapterMap = this.getAdapterMap(adapters);
|
|
184
|
+
const webgl2Adapter = adapterMap.get('webgl');
|
|
185
|
+
if (!webgl2Adapter) {
|
|
186
|
+
log.warn('enforceWebGL2: webgl adapter not found')();
|
|
187
|
+
}
|
|
188
|
+
(webgl2Adapter as any)?.enforceWebGL2?.(enforce);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Convert a list of adapters to a map */
|
|
192
|
+
protected getAdapterMap(adapters: Adapter[] = []): Map<string, Adapter> {
|
|
193
|
+
const map = new Map(this.preregisteredAdapters);
|
|
194
|
+
for (const adapter of adapters) {
|
|
195
|
+
map.set(adapter.type, adapter);
|
|
196
|
+
}
|
|
197
|
+
return map;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// DEPRECATED
|
|
201
|
+
|
|
202
|
+
/** @deprecated Use registerAdapters */
|
|
203
|
+
registerDevices(deviceClasses: any[]): void {
|
|
204
|
+
log.warn('luma.registerDevices() is deprecated, use luma.registerAdapters() instead');
|
|
205
|
+
for (const deviceClass of deviceClasses) {
|
|
206
|
+
const adapter = deviceClass.adapter as Adapter;
|
|
207
|
+
if (adapter) {
|
|
208
|
+
this.preregisteredAdapters.set(adapter.type, adapter);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Entry point to the luma.gl GPU abstraction
|
|
216
|
+
* Register WebGPU and/or WebGL adapters (controls application bundle size)
|
|
217
|
+
* Run-time selection of the first available Device
|
|
218
|
+
*/
|
|
219
|
+
export const luma = new Luma();
|
|
@@ -107,17 +107,17 @@ export abstract class Buffer extends Resource<BufferProps> {
|
|
|
107
107
|
byteOffset: number,
|
|
108
108
|
byteLength: number
|
|
109
109
|
): void {
|
|
110
|
-
const
|
|
110
|
+
const arrayBuffer: ArrayBuffer | null = ArrayBuffer.isView(data) ? data.buffer : data;
|
|
111
111
|
const debugDataLength = Math.min(
|
|
112
112
|
data ? data.byteLength : byteLength,
|
|
113
113
|
Buffer.DEBUG_DATA_MAX_LENGTH
|
|
114
114
|
);
|
|
115
|
-
if (
|
|
115
|
+
if (arrayBuffer === null) {
|
|
116
116
|
this.debugData = new ArrayBuffer(debugDataLength);
|
|
117
|
-
} else if (byteOffset === 0 && byteLength ===
|
|
118
|
-
this.debugData =
|
|
117
|
+
} else if (byteOffset === 0 && byteLength === arrayBuffer.byteLength) {
|
|
118
|
+
this.debugData = arrayBuffer.slice(0, debugDataLength);
|
|
119
119
|
} else {
|
|
120
|
-
this.debugData =
|
|
120
|
+
this.debugData = arrayBuffer.slice(byteOffset, byteOffset + debugDataLength);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -133,7 +133,7 @@ export type CommandEncoderProps = ResourceProps & {
|
|
|
133
133
|
export abstract class CommandEncoder extends Resource<CommandEncoderProps> {
|
|
134
134
|
static override defaultProps: Required<CommandEncoderProps> = {
|
|
135
135
|
...Resource.defaultProps,
|
|
136
|
-
measureExecutionTime: undefined
|
|
136
|
+
measureExecutionTime: undefined!
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
override get [Symbol.toStringTag](): string {
|
|
@@ -20,9 +20,9 @@ export type ComputePassProps = ResourceProps & {
|
|
|
20
20
|
export abstract class ComputePass extends Resource<ComputePassProps> {
|
|
21
21
|
static override defaultProps: Required<ComputePassProps> = {
|
|
22
22
|
...Resource.defaultProps,
|
|
23
|
-
timestampQuerySet: undefined
|
|
24
|
-
beginTimestampIndex: undefined
|
|
25
|
-
endTimestampIndex: undefined
|
|
23
|
+
timestampQuerySet: undefined!,
|
|
24
|
+
beginTimestampIndex: undefined!,
|
|
25
|
+
endTimestampIndex: undefined!
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
override get [Symbol.toStringTag](): string {
|
|
@@ -28,10 +28,10 @@ export type ComputePipelineProps = ResourceProps & {
|
|
|
28
28
|
export abstract class ComputePipeline extends Resource<ComputePipelineProps> {
|
|
29
29
|
static override defaultProps: Required<ComputePipelineProps> = {
|
|
30
30
|
...Resource.defaultProps,
|
|
31
|
-
shader: undefined
|
|
32
|
-
entryPoint: undefined
|
|
31
|
+
shader: undefined!,
|
|
32
|
+
entryPoint: undefined!,
|
|
33
33
|
constants: {},
|
|
34
|
-
shaderLayout: undefined
|
|
34
|
+
shaderLayout: undefined!
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
override get [Symbol.toStringTag](): string {
|
|
@@ -39,9 +39,12 @@ export abstract class ComputePipeline extends Resource<ComputePipelineProps> {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
hash: string = '';
|
|
42
|
+
/** The merged shader layout */
|
|
43
|
+
shaderLayout: ComputeShaderLayout;
|
|
42
44
|
|
|
43
45
|
constructor(device: Device, props: ComputePipelineProps) {
|
|
44
46
|
super(device, props, ComputePipeline.defaultProps);
|
|
47
|
+
this.shaderLayout = props.shaderLayout!;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
/**
|
|
@@ -6,13 +6,13 @@ import type {Device} from '../device';
|
|
|
6
6
|
import {Resource, ResourceProps} from './resource';
|
|
7
7
|
|
|
8
8
|
export type ExternalTextureProps = ResourceProps & {
|
|
9
|
-
source: HTMLVideoElement | null;
|
|
9
|
+
source: HTMLVideoElement; // | null;
|
|
10
10
|
colorSpace?: 'srgb';
|
|
11
11
|
};
|
|
12
12
|
export abstract class ExternalTexture extends Resource<ExternalTextureProps> {
|
|
13
13
|
static override defaultProps: Required<ExternalTextureProps> = {
|
|
14
14
|
...Resource.defaultProps,
|
|
15
|
-
source:
|
|
15
|
+
source: undefined!,
|
|
16
16
|
colorSpace: 'srgb'
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
ColorTextureFormat,
|
|
7
7
|
DepthStencilTextureFormat,
|
|
8
8
|
TextureFormat
|
|
9
|
-
} from '
|
|
9
|
+
} from '../../gpu-type-utils/texture-formats';
|
|
10
10
|
import type {Device} from '../device';
|
|
11
11
|
import {Resource, ResourceProps} from './resource';
|
|
12
12
|
import {Texture} from './texture';
|
|
@@ -42,17 +42,14 @@ export abstract class Framebuffer extends Resource<FramebufferProps> {
|
|
|
42
42
|
/** Height of all attachments in this framebuffer */
|
|
43
43
|
height: number;
|
|
44
44
|
/** Color attachments */
|
|
45
|
-
colorAttachments: TextureView[]
|
|
45
|
+
abstract colorAttachments: TextureView[];
|
|
46
46
|
/** Depth-stencil attachment, if provided */
|
|
47
|
-
depthStencilAttachment: TextureView | null
|
|
47
|
+
abstract depthStencilAttachment: TextureView | null;
|
|
48
48
|
|
|
49
49
|
constructor(device: Device, props: FramebufferProps = {}) {
|
|
50
50
|
super(device, props, Framebuffer.defaultProps);
|
|
51
51
|
this.width = this.props.width;
|
|
52
52
|
this.height = this.props.height;
|
|
53
|
-
|
|
54
|
-
// NOTE: call from subclass constructor as we cannot call overridden methods here (subclass not yet constructed)
|
|
55
|
-
// this.autoCreateAttachmentTextures();
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
/**
|
|
@@ -139,7 +136,7 @@ export abstract class Framebuffer extends Resource<FramebufferProps> {
|
|
|
139
136
|
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
140
137
|
if (this.colorAttachments[i]) {
|
|
141
138
|
const resizedTexture = this.device._createTexture({
|
|
142
|
-
...this.colorAttachments[i].props,
|
|
139
|
+
...this.colorAttachments[i].texture.props,
|
|
143
140
|
width,
|
|
144
141
|
height
|
|
145
142
|
});
|
|
@@ -151,7 +148,7 @@ export abstract class Framebuffer extends Resource<FramebufferProps> {
|
|
|
151
148
|
|
|
152
149
|
if (this.depthStencilAttachment) {
|
|
153
150
|
const resizedTexture = this.device._createTexture({
|
|
154
|
-
...this.depthStencilAttachment.props,
|
|
151
|
+
...this.depthStencilAttachment.texture.props,
|
|
155
152
|
width,
|
|
156
153
|
height
|
|
157
154
|
});
|
|
@@ -161,87 +158,3 @@ export abstract class Framebuffer extends Resource<FramebufferProps> {
|
|
|
161
158
|
}
|
|
162
159
|
}
|
|
163
160
|
}
|
|
164
|
-
|
|
165
|
-
// TODO - remove if not needed
|
|
166
|
-
|
|
167
|
-
// Create a color attachment for WebGL *
|
|
168
|
-
// protected override createColorTexture(colorAttachment: Required<ColorAttachment>): Required<ColorAttachment> {
|
|
169
|
-
// return this.device._createTexture({
|
|
170
|
-
// id: `${this.id}-color`,
|
|
171
|
-
// data: null, // reserves texture memory, but texels are undefined
|
|
172
|
-
// format,
|
|
173
|
-
// // type: GL.UNSIGNED_BYTE,
|
|
174
|
-
// width: this.width,
|
|
175
|
-
// height: this.height,
|
|
176
|
-
// // Note: Mipmapping can be disabled by texture resource when we resize the texture
|
|
177
|
-
// // to a non-power-of-two dimenstion (NPOT texture) under WebGL1. To have consistant
|
|
178
|
-
// // behavior we always disable mipmaps.
|
|
179
|
-
// mipmaps: false,
|
|
180
|
-
// // Set MIN and MAG filtering parameters so mipmaps are not used in sampling.
|
|
181
|
-
// // Use LINEAR so subpixel algos like fxaa work.
|
|
182
|
-
// // Set WRAP modes that support NPOT textures too.
|
|
183
|
-
// sampler: {
|
|
184
|
-
// minFilter: 'linear',
|
|
185
|
-
// magFilter: 'linear',
|
|
186
|
-
// addressModeU: 'clamp-to-edge',
|
|
187
|
-
// addressModeV: 'clamp-to-edge'
|
|
188
|
-
// }
|
|
189
|
-
// // parameters: {
|
|
190
|
-
// // [GL.TEXTURE_MIN_FILTER]: GL.LINEAR,
|
|
191
|
-
// // [GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
|
|
192
|
-
// // [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
|
|
193
|
-
// // [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE
|
|
194
|
-
// // }
|
|
195
|
-
// });
|
|
196
|
-
// }
|
|
197
|
-
|
|
198
|
-
// /** Returns fully populated attachment object. */
|
|
199
|
-
// protected normalizeColorAttachment(
|
|
200
|
-
// attachment: Texture | ColorTextureFormat
|
|
201
|
-
// ): Required<ColorAttachment> {
|
|
202
|
-
|
|
203
|
-
// const COLOR_ATTACHMENT_DEFAULTS: Required<ColorAttachment> = {
|
|
204
|
-
// texture: undefined!,
|
|
205
|
-
// format: undefined!,
|
|
206
|
-
// clearValue: [0.0, 0.0, 0.0, 0.0],
|
|
207
|
-
// loadOp: 'clear',
|
|
208
|
-
// storeOp: 'store'
|
|
209
|
-
// };
|
|
210
|
-
|
|
211
|
-
// if (attachment instanceof Texture) {
|
|
212
|
-
// return {...COLOR_ATTACHMENT_DEFAULTS, texture: attachment};
|
|
213
|
-
// }
|
|
214
|
-
// if (typeof attachment === 'string') {
|
|
215
|
-
// return {...COLOR_ATTACHMENT_DEFAULTS, format: attachment};
|
|
216
|
-
// }
|
|
217
|
-
// return {...COLOR_ATTACHMENT_DEFAULTS, ...attachment};
|
|
218
|
-
// }
|
|
219
|
-
|
|
220
|
-
// /** Wraps texture inside fully populated attachment object. */
|
|
221
|
-
// protected normalizeDepthStencilAttachment(
|
|
222
|
-
// attachment: DepthStencilAttachment | Texture | DepthStencilTextureFormat
|
|
223
|
-
// ): Required<DepthStencilAttachment> {
|
|
224
|
-
// const DEPTH_STENCIL_ATTACHMENT_DEFAULTS: Required<DepthStencilAttachment> = {
|
|
225
|
-
// texture: undefined!,
|
|
226
|
-
// format: undefined!,
|
|
227
|
-
|
|
228
|
-
// depthClearValue: 1.0,
|
|
229
|
-
// depthLoadOp: 'clear',
|
|
230
|
-
// depthStoreOp: 'store',
|
|
231
|
-
// depthReadOnly: false,
|
|
232
|
-
|
|
233
|
-
// stencilClearValue: 0,
|
|
234
|
-
// stencilLoadOp: 'clear',
|
|
235
|
-
// stencilStoreOp: 'store',
|
|
236
|
-
// stencilReadOnly: false
|
|
237
|
-
// };
|
|
238
|
-
|
|
239
|
-
// if (typeof attachment === 'string') {
|
|
240
|
-
// return {...DEPTH_STENCIL_ATTACHMENT_DEFAULTS, format: attachment};
|
|
241
|
-
// }
|
|
242
|
-
// // @ts-expect-error attachment instanceof Texture doesn't cover Renderbuffer
|
|
243
|
-
// if (attachment.handle || attachment instanceof Texture) {
|
|
244
|
-
// return {...DEPTH_STENCIL_ATTACHMENT_DEFAULTS, texture: attachment as Texture};
|
|
245
|
-
// }
|
|
246
|
-
// return {...DEPTH_STENCIL_ATTACHMENT_DEFAULTS, ...attachment};
|
|
247
|
-
// }
|
|
@@ -27,8 +27,8 @@ export type QuerySetProps = ResourceProps & {
|
|
|
27
27
|
export abstract class QuerySet extends Resource<QuerySetProps> {
|
|
28
28
|
static override defaultProps: Required<QuerySetProps> = {
|
|
29
29
|
...Resource.defaultProps,
|
|
30
|
-
type: undefined
|
|
31
|
-
count: undefined
|
|
30
|
+
type: undefined!,
|
|
31
|
+
count: undefined!
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
get [Symbol.toStringTag](): string {
|
|
@@ -18,8 +18,14 @@ export type RenderPassProps = ResourceProps & {
|
|
|
18
18
|
framebuffer?: Framebuffer | null;
|
|
19
19
|
/** Control viewport, scissor rect, blend constant and stencil ref */
|
|
20
20
|
parameters?: RenderPassParameters;
|
|
21
|
+
|
|
22
|
+
// TODO - API needs to be able to control multiple render targets
|
|
23
|
+
|
|
21
24
|
/** Clear value for color attachment, or `load` to preserve the previous value */
|
|
22
25
|
clearColor?: NumberArray | false;
|
|
26
|
+
/** Whether to disable / discard the output of the rasterizer */
|
|
27
|
+
discard?: boolean;
|
|
28
|
+
|
|
23
29
|
/** Clear value for depth attachment, or `load` to preserve the previous value */
|
|
24
30
|
clearDepth?: number | false;
|
|
25
31
|
/** Clear value for stencil attachment, or `load` to preserve the previous value */
|
|
@@ -28,8 +34,6 @@ export type RenderPassProps = ResourceProps & {
|
|
|
28
34
|
depthReadOnly?: boolean;
|
|
29
35
|
/** Indicates that the stencil component is read only. */
|
|
30
36
|
stencilReadOnly?: boolean;
|
|
31
|
-
/** Whether to disable / discard the output of the rasterizer */
|
|
32
|
-
discard?: boolean;
|
|
33
37
|
|
|
34
38
|
/** QuerySet to write begin/end timestamps to */
|
|
35
39
|
occlusionQuerySet?: QuerySet;
|
|
@@ -54,7 +58,7 @@ export abstract class RenderPass extends Resource<RenderPassProps> {
|
|
|
54
58
|
static override defaultProps: Required<RenderPassProps> = {
|
|
55
59
|
...Resource.defaultProps,
|
|
56
60
|
framebuffer: null,
|
|
57
|
-
parameters: undefined
|
|
61
|
+
parameters: undefined!,
|
|
58
62
|
clearColor: [0, 0, 0, 0],
|
|
59
63
|
clearDepth: 1,
|
|
60
64
|
clearStencil: 0,
|
|
@@ -62,10 +66,10 @@ export abstract class RenderPass extends Resource<RenderPassProps> {
|
|
|
62
66
|
stencilReadOnly: false,
|
|
63
67
|
discard: false,
|
|
64
68
|
|
|
65
|
-
occlusionQuerySet: undefined
|
|
66
|
-
timestampQuerySet: undefined
|
|
67
|
-
beginTimestampIndex: undefined
|
|
68
|
-
endTimestampIndex: undefined
|
|
69
|
+
occlusionQuerySet: undefined!,
|
|
70
|
+
timestampQuerySet: undefined!,
|
|
71
|
+
beginTimestampIndex: undefined!,
|
|
72
|
+
endTimestampIndex: undefined!
|
|
69
73
|
};
|
|
70
74
|
|
|
71
75
|
override get [Symbol.toStringTag](): string {
|