@luma.gl/core 9.0.11 → 9.1.0-alpha.1
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/LICENSE +34 -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 +10 -8
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +20 -18
- package/dist/{lib → adapter}/luma.d.ts +2 -2
- package/dist/adapter/luma.d.ts.map +1 -0
- package/dist/{lib → adapter}/luma.js +7 -7
- 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 +111 -49
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/texture.js +96 -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} +5 -16
- 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 +2 -6
- package/dist/adapter/types/parameters.d.ts.map +1 -1
- 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 +266 -588
- package/dist/dist.min.js +4 -4
- 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/{adapter/type-utils → gpu-type-utils}/decode-texture-format.d.ts +2 -2
- package/dist/gpu-type-utils/decode-texture-format.d.ts.map +1 -0
- 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 +1 -1
- 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 +190 -411
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +28 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -36
- package/dist/init.js +1 -1
- 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 +4 -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 +2 -2
- 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/canvas-context.ts +6 -0
- package/src/adapter/device.ts +34 -31
- package/src/{lib → adapter}/luma.ts +9 -9
- 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 +226 -77
- 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} +8 -17
- package/src/adapter/types/buffer-layout.ts +1 -1
- package/src/adapter/types/parameters.ts +10 -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 +2 -2
- package/src/{adapter/type-utils → gpu-type-utils}/decode-vertex-format.ts +1 -1
- package/src/{adapter/types → gpu-type-utils}/texture-formats.ts +1 -1
- 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 +69 -84
- 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 +14 -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 +4 -4
- 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.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/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.map +0 -1
- 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/lib/compiler-log/get-shader-info.ts +0 -42
- 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-texture-format.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
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {log} from '
|
|
6
|
-
import type {ShaderLayout, AttributeDeclaration} from '../types/shader-layout';
|
|
7
|
-
import type {BufferLayout} from '../types/buffer-layout';
|
|
8
|
-
import type {ShaderDataType, ShaderAttributeType} from '../
|
|
9
|
-
import {decodeShaderAttributeType} from '../type-utils/decode-attribute-type';
|
|
10
|
-
import type {VertexFormat, VertexType} from '../
|
|
11
|
-
import {decodeVertexFormat} from '../type-utils/decode-vertex-format';
|
|
5
|
+
import {log} from '../utils/log';
|
|
6
|
+
import type {ShaderLayout, AttributeDeclaration} from '../adapter/types/shader-layout';
|
|
7
|
+
import type {BufferLayout} from '../adapter/types/buffer-layout';
|
|
8
|
+
import type {ShaderDataType, ShaderAttributeType} from '../gpu-type-utils/shader-types';
|
|
9
|
+
import {decodeShaderAttributeType} from '../gpu-type-utils/decode-attribute-type';
|
|
10
|
+
import type {VertexFormat, VertexType} from '../gpu-type-utils/vertex-formats';
|
|
11
|
+
import {decodeVertexFormat} from '../gpu-type-utils/decode-vertex-format';
|
|
12
12
|
|
|
13
13
|
/** Resolved info for a buffer / attribute combination to help backend configure it correctly */
|
|
14
14
|
export type AttributeInfo = {
|
|
@@ -64,11 +64,10 @@ export function getAttributeInfosFromLayouts(
|
|
|
64
64
|
): Record<string, AttributeInfo> {
|
|
65
65
|
const attributeInfos: Record<string, AttributeInfo> = {};
|
|
66
66
|
for (const attribute of shaderLayout.attributes) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
);
|
|
67
|
+
const attributeInfo = getAttributeInfoFromLayouts(shaderLayout, bufferLayout, attribute.name);
|
|
68
|
+
if (attributeInfo) {
|
|
69
|
+
attributeInfos[attribute.name] = attributeInfo;
|
|
70
|
+
}
|
|
72
71
|
}
|
|
73
72
|
return attributeInfos;
|
|
74
73
|
}
|
|
@@ -98,7 +97,10 @@ function getAttributeInfoFromLayouts(
|
|
|
98
97
|
name: string
|
|
99
98
|
): AttributeInfo | null {
|
|
100
99
|
const shaderDeclaration = getAttributeFromShaderLayout(shaderLayout, name);
|
|
101
|
-
const bufferMapping: BufferAttributeInfo = getAttributeFromBufferLayout(
|
|
100
|
+
const bufferMapping: BufferAttributeInfo | null = getAttributeFromBufferLayout(
|
|
101
|
+
bufferLayout,
|
|
102
|
+
name
|
|
103
|
+
);
|
|
102
104
|
|
|
103
105
|
// TODO should no longer happen
|
|
104
106
|
if (!shaderDeclaration) {
|
|
@@ -124,7 +126,7 @@ function getAttributeInfoFromLayouts(
|
|
|
124
126
|
normalized: vertexFormatInfo.normalized,
|
|
125
127
|
// integer is a property of the shader declaration
|
|
126
128
|
integer: attributeTypeInfo.integer,
|
|
127
|
-
stepMode: bufferMapping?.stepMode || shaderDeclaration.stepMode,
|
|
129
|
+
stepMode: bufferMapping?.stepMode || shaderDeclaration.stepMode || 'vertex',
|
|
128
130
|
byteOffset: bufferMapping?.byteOffset || 0,
|
|
129
131
|
byteStride: bufferMapping?.byteStride || 0
|
|
130
132
|
};
|
|
@@ -211,6 +213,7 @@ function getAttributeFromAttributesList(
|
|
|
211
213
|
if (typeof bufferLayout.byteStride !== 'number') {
|
|
212
214
|
for (const attributeMapping of bufferLayout.attributes || []) {
|
|
213
215
|
const info = decodeVertexFormat(attributeMapping.format);
|
|
216
|
+
// @ts-ignore
|
|
214
217
|
byteStride += info.byteLength;
|
|
215
218
|
}
|
|
216
219
|
}
|
|
@@ -223,6 +226,7 @@ function getAttributeFromAttributesList(
|
|
|
223
226
|
stepMode: bufferLayout.stepMode,
|
|
224
227
|
vertexFormat: attributeMapping.format,
|
|
225
228
|
byteOffset: attributeMapping.byteOffset,
|
|
229
|
+
// @ts-ignore
|
|
226
230
|
byteStride
|
|
227
231
|
};
|
|
228
232
|
}
|
|
@@ -230,31 +234,3 @@ function getAttributeFromAttributesList(
|
|
|
230
234
|
|
|
231
235
|
return null;
|
|
232
236
|
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Merges an provided shader layout into a base shader layout
|
|
236
|
-
* In WebGL, this allows the auto generated shader layout to be overridden by the application
|
|
237
|
-
* Typically to change the format of the vertex attributes (from float32x4 to uint8x4 etc).
|
|
238
|
-
* @todo Drop this? Aren't all use cases covered by mergeBufferLayout()?
|
|
239
|
-
*/
|
|
240
|
-
export function mergeShaderLayout(
|
|
241
|
-
baseLayout: ShaderLayout,
|
|
242
|
-
overrideLayout: ShaderLayout
|
|
243
|
-
): ShaderLayout {
|
|
244
|
-
// Deep clone the base layout
|
|
245
|
-
const mergedLayout: ShaderLayout = {
|
|
246
|
-
...baseLayout,
|
|
247
|
-
attributes: baseLayout.attributes.map(attribute => ({...attribute}))
|
|
248
|
-
};
|
|
249
|
-
// Merge the attributes
|
|
250
|
-
for (const attribute of overrideLayout?.attributes || []) {
|
|
251
|
-
const baseAttribute = mergedLayout.attributes.find(attr => attr.name === attribute.name);
|
|
252
|
-
if (!baseAttribute) {
|
|
253
|
-
log.warn(`shader layout attribute ${attribute.name} not present in shader`);
|
|
254
|
-
} else {
|
|
255
|
-
baseAttribute.type = attribute.type || baseAttribute.type;
|
|
256
|
-
baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return mergedLayout;
|
|
260
|
-
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {isNumberArray} from '../utils/is-array';
|
|
6
|
+
import {UniformValue} from '../adapter/types/uniforms';
|
|
7
|
+
|
|
8
|
+
export function isUniformValue(value: unknown): value is UniformValue {
|
|
9
|
+
return isNumberArray(value) || typeof value === 'number' || typeof value === 'boolean';
|
|
10
|
+
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {ShaderDataType, ShaderAttributeType} from '
|
|
6
|
-
import {VertexFormat, VertexType} from '
|
|
5
|
+
import {ShaderDataType, ShaderAttributeType} from './shader-types';
|
|
6
|
+
import {VertexFormat, VertexType} from './vertex-formats';
|
|
7
7
|
|
|
8
8
|
/** Information extracted from a ShaderAttributeInfo constant */
|
|
9
9
|
export type ShaderAttributeTypeInfo = {
|
|
@@ -18,7 +18,7 @@ export type ShaderAttributeTypeInfo = {
|
|
|
18
18
|
/** Whether this data type is signed */
|
|
19
19
|
signed: boolean;
|
|
20
20
|
/** The simplest vertex format that matches the shader attribute's data type */
|
|
21
|
-
defaultVertexFormat
|
|
21
|
+
defaultVertexFormat: VertexFormat;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
/** Decodes a vertex type, returning byte length and flags (integer, signed, normalized) */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {DataType, NormalizedDataType} from '
|
|
5
|
+
import {DataType, NormalizedDataType} from './vertex-formats';
|
|
6
6
|
|
|
7
7
|
export type DecodedVertexType = {
|
|
8
8
|
/** WebGPU data type */
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {ShaderUniformType, ShaderDataType} from '../types/shader-types';
|
|
5
|
+
import {ShaderUniformType, ShaderDataType} from './shader-types';
|
|
7
6
|
|
|
8
7
|
const UNIFORM_FORMATS: Record<ShaderUniformType, {type: ShaderDataType; components: number}> = {
|
|
9
8
|
f32: {type: 'f32', components: 1},
|
|
@@ -36,7 +35,6 @@ export function decodeShaderUniformType(format: ShaderUniformType): {
|
|
|
36
35
|
components: number;
|
|
37
36
|
} {
|
|
38
37
|
const decoded = UNIFORM_FORMATS[format];
|
|
39
|
-
assert(format);
|
|
40
38
|
return decoded;
|
|
41
39
|
}
|
|
42
40
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {TextureFormat} from '
|
|
6
|
-
import {VertexType} from '
|
|
5
|
+
import {TextureFormat} from './texture-formats';
|
|
6
|
+
import {VertexType} from './vertex-formats';
|
|
7
7
|
import {decodeVertexType} from './decode-data-type';
|
|
8
8
|
|
|
9
9
|
// prettier-ignore
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {VertexFormat, VertexType} from '
|
|
5
|
+
import {VertexFormat, VertexType} from './vertex-formats';
|
|
6
6
|
import {decodeVertexType} from './decode-data-type';
|
|
7
7
|
|
|
8
8
|
export type VertexFormatInfo = {
|
|
@@ -139,7 +139,7 @@ export type UnsizedColorTextureFormat = 'rgb8unorm-unsized' | 'rgba8unorm-unsize
|
|
|
139
139
|
// 'rgb8unorm-srgb-unsized' |
|
|
140
140
|
// 'rgba8unorm-srgb-unsized'
|
|
141
141
|
|
|
142
|
-
/** Sized formats
|
|
142
|
+
/** Sized formats in WebGL 2 that are not (yet?) supported by WebGPU */
|
|
143
143
|
export type WebGL2ColorTextureFormat =
|
|
144
144
|
| 'r16unorm-webgl'
|
|
145
145
|
| 'r16snorm-webgl'
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {TypedArray, TypedArrayConstructor} from '
|
|
6
|
-
import {VertexFormat} from '
|
|
5
|
+
import {TypedArray, TypedArrayConstructor} from '../types';
|
|
6
|
+
import {VertexFormat} from './vertex-formats';
|
|
7
7
|
|
|
8
8
|
// import {DataType} from '../types/vertex-formats';
|
|
9
9
|
// type Omit<DataType, 'float16'> unfortunately breaks Typescript inferance
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {ShaderAttributeType} from '
|
|
5
|
+
import {ShaderAttributeType} from './shader-types';
|
|
6
6
|
|
|
7
7
|
/** Predeclared aliases @see https://www.w3.org/TR/WGSL/#vector-types */
|
|
8
8
|
export const WGSL_TYPE_ALIAS_MAP: Record<string, ShaderAttributeType> = {
|
package/src/index.ts
CHANGED
|
@@ -4,19 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
export {VERSION} from './init';
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
// NUMERIC TYPES - TODO: could be imported from @math.gl/types
|
|
11
|
-
export type {TypedArray, TypedArrayConstructor, NumberArray, BigIntOrNumberArray} from './types';
|
|
12
|
-
|
|
13
|
-
export {isTypedArray, isNumberArray} from './utils/is-array';
|
|
14
|
-
|
|
15
|
-
// MAIN API ACCESS POINTS
|
|
16
|
-
export {luma} from './lib/luma';
|
|
7
|
+
// MAIN API ACCESS POINT
|
|
8
|
+
export {luma} from './adapter/luma';
|
|
17
9
|
|
|
10
|
+
// ADAPTER (DEVICE AND GPU RESOURCE INTERFACES)
|
|
18
11
|
export type {DeviceProps, DeviceInfo, DeviceFeature} from './adapter/device';
|
|
19
12
|
export {Device, DeviceFeatures, DeviceLimits} from './adapter/device';
|
|
13
|
+
|
|
20
14
|
export type {CanvasContextProps} from './adapter/canvas-context';
|
|
21
15
|
export {CanvasContext} from './adapter/canvas-context';
|
|
22
16
|
|
|
@@ -27,7 +21,7 @@ export {Resource} from './adapter/resources/resource';
|
|
|
27
21
|
export type {BufferProps} from './adapter/resources/buffer';
|
|
28
22
|
export {Buffer} from './adapter/resources/buffer';
|
|
29
23
|
|
|
30
|
-
export type {TextureProps
|
|
24
|
+
export type {TextureProps} from './adapter/resources/texture';
|
|
31
25
|
export {Texture} from './adapter/resources/texture';
|
|
32
26
|
|
|
33
27
|
export type {TextureViewProps} from './adapter/resources/texture-view';
|
|
@@ -72,12 +66,32 @@ export {TransformFeedback} from './adapter/resources/transform-feedback';
|
|
|
72
66
|
export type {QuerySetProps} from './adapter/resources/query-set';
|
|
73
67
|
export {QuerySet} from './adapter/resources/query-set';
|
|
74
68
|
|
|
69
|
+
// PORTABLE API - UNIFORM BUFFERS
|
|
70
|
+
export {UniformBufferLayout} from './portable/uniform-buffer-layout';
|
|
71
|
+
export {UniformBlock} from './portable/uniform-block';
|
|
72
|
+
export {UniformStore} from './portable/uniform-store';
|
|
73
|
+
// TEXTURE TYPES
|
|
74
|
+
|
|
75
75
|
// API TYPES
|
|
76
|
-
export type {
|
|
76
|
+
export type {CompilerMessage} from './adapter/types/compiler-message';
|
|
77
|
+
|
|
78
|
+
export type {
|
|
79
|
+
TextureCompressionFormat,
|
|
80
|
+
TextureCubeFace,
|
|
81
|
+
TextureLevelData,
|
|
82
|
+
ExternalImage,
|
|
83
|
+
TextureData,
|
|
84
|
+
Texture1DData,
|
|
85
|
+
Texture2DData,
|
|
86
|
+
Texture3DData,
|
|
87
|
+
TextureCubeData,
|
|
88
|
+
TextureArrayData,
|
|
89
|
+
TextureCubeArrayData
|
|
90
|
+
} from './adapter/resources/texture';
|
|
91
|
+
|
|
92
|
+
export type {Parameters, PrimitiveTopology, IndexFormat} from './adapter/types/parameters';
|
|
93
|
+
|
|
77
94
|
export type {
|
|
78
|
-
Parameters,
|
|
79
|
-
PrimitiveTopology,
|
|
80
|
-
IndexFormat,
|
|
81
95
|
CullMode,
|
|
82
96
|
FrontFace,
|
|
83
97
|
RasterizationParameters,
|
|
@@ -94,20 +108,7 @@ export type {
|
|
|
94
108
|
ProvokingVertex
|
|
95
109
|
} from './adapter/types/parameters';
|
|
96
110
|
|
|
97
|
-
|
|
98
|
-
export type {VertexFormat, VertexType} from './adapter/types/vertex-formats';
|
|
99
|
-
export type {
|
|
100
|
-
TextureFormat,
|
|
101
|
-
ColorTextureFormat,
|
|
102
|
-
DepthStencilTextureFormat
|
|
103
|
-
} from './adapter/types/texture-formats';
|
|
104
|
-
export type {
|
|
105
|
-
ShaderDataType,
|
|
106
|
-
ShaderAttributeType,
|
|
107
|
-
ShaderUniformType
|
|
108
|
-
} from './adapter/types/shader-types';
|
|
109
|
-
|
|
110
|
-
export type {ColorAttachment, DepthStencilAttachment} from './adapter/types/types';
|
|
111
|
+
export type {ColorAttachment, DepthStencilAttachment} from './adapter/types/attachments';
|
|
111
112
|
|
|
112
113
|
export type {
|
|
113
114
|
ShaderLayout,
|
|
@@ -125,63 +126,40 @@ export type {
|
|
|
125
126
|
VaryingBinding
|
|
126
127
|
} from './adapter/types/shader-layout';
|
|
127
128
|
|
|
128
|
-
export type {UniformValue} from './adapter/types/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
export {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
export
|
|
148
|
-
export {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
export
|
|
152
|
-
export {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
export {StatsManager} from './utils/stats-manager';
|
|
160
|
-
export {assert} from './utils/assert';
|
|
161
|
-
export {cast} from './utils/cast';
|
|
162
|
-
export {log} from './utils/log';
|
|
163
|
-
export {uid, isObjectEmpty} from './utils/utils';
|
|
164
|
-
export {isUniformValue, splitUniformsAndBindings} from './lib/uniforms/uniform';
|
|
165
|
-
export {formatValue} from './utils/format-value';
|
|
166
|
-
export {stubRemovedMethods} from './utils/stub-methods';
|
|
167
|
-
export {checkProps} from './utils/check-props';
|
|
168
|
-
export {setPathPrefix, loadFile, loadImage, loadImageBitmap, loadScript} from './utils/load-file';
|
|
169
|
-
export {getScratchArrayBuffer, getScratchArray, fillArray} from './utils/array-utils-flat';
|
|
170
|
-
export {makeRandomNumberGenerator, random} from './utils/random';
|
|
171
|
-
export {deepEqual} from './utils/deep-equal';
|
|
172
|
-
|
|
173
|
-
// ENGINE - TODO/move to @luma.gl/engine once that module is webgl-independent?
|
|
174
|
-
export {requestAnimationFrame, cancelAnimationFrame} from './utils/request-animation-frame';
|
|
175
|
-
|
|
176
|
-
// SHADER HELPERS
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Marks GLSL shaders for syntax highlighting: glsl`...`
|
|
180
|
-
* Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal
|
|
181
|
-
*/
|
|
129
|
+
export type {UniformValue} from './adapter/types/uniforms';
|
|
130
|
+
|
|
131
|
+
// GPU TYPE UTILS - GPU MEMORY LAYOUT TYPES - EXTERNAL
|
|
132
|
+
|
|
133
|
+
export type {NumberArray} from './types';
|
|
134
|
+
export type {VertexFormat, VertexType} from './gpu-type-utils/vertex-formats';
|
|
135
|
+
export type {
|
|
136
|
+
ShaderDataType,
|
|
137
|
+
ShaderAttributeType,
|
|
138
|
+
ShaderUniformType
|
|
139
|
+
} from './gpu-type-utils/shader-types';
|
|
140
|
+
export type {
|
|
141
|
+
TextureFormat,
|
|
142
|
+
ColorTextureFormat,
|
|
143
|
+
DepthStencilTextureFormat
|
|
144
|
+
} from './gpu-type-utils/texture-formats';
|
|
145
|
+
|
|
146
|
+
// GPU TYPE UTILS - GPU MEMORY LAYOUT HELPERS - CAN BE USED BY APPS BUT MOSTLY USED INTERNALLY
|
|
147
|
+
|
|
148
|
+
export {decodeVertexFormat} from './gpu-type-utils/decode-vertex-format';
|
|
149
|
+
export {decodeTextureFormat} from './gpu-type-utils/decode-texture-format';
|
|
150
|
+
export {decodeShaderUniformType} from './gpu-type-utils/decode-shader-types';
|
|
151
|
+
export {decodeShaderAttributeType} from './gpu-type-utils/decode-attribute-type';
|
|
152
|
+
export {getDataTypeFromTypedArray} from './gpu-type-utils/vertex-format-from-attribute';
|
|
153
|
+
export {getTypedArrayFromDataType} from './gpu-type-utils/vertex-format-from-attribute';
|
|
154
|
+
export {getVertexFormatFromAttribute} from './gpu-type-utils/vertex-format-from-attribute';
|
|
155
|
+
|
|
156
|
+
// GENERAL EXPORTS - FOR APPLICATIONS
|
|
157
|
+
|
|
158
|
+
export type {StatsManager} from './utils/stats-manager'; // TODO - should this be moved to probe.gl?
|
|
159
|
+
/** GLSL syntax highlighting: glsl`...` Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal */
|
|
182
160
|
export const glsl = (x: TemplateStringsArray) => `${x}`;
|
|
183
161
|
|
|
184
|
-
//
|
|
162
|
+
// ADAPTER UTILS - for implementing Device adapters (@luma.gl/webgl and @luma.gl/webgpu)
|
|
185
163
|
|
|
186
164
|
export type {
|
|
187
165
|
CopyBufferToBufferOptions,
|
|
@@ -189,3 +167,10 @@ export type {
|
|
|
189
167
|
CopyTextureToBufferOptions,
|
|
190
168
|
CopyTextureToTextureOptions
|
|
191
169
|
} from './adapter/resources/command-encoder';
|
|
170
|
+
|
|
171
|
+
export type {AttributeInfo} from './adapter-utils/get-attribute-from-layouts';
|
|
172
|
+
export {getAttributeInfosFromLayouts} from './adapter-utils/get-attribute-from-layouts';
|
|
173
|
+
export {getScratchArrayBuffer, getScratchArray} from './utils/array-utils-flat';
|
|
174
|
+
|
|
175
|
+
// INTERNAL UTILS - for use in other luma.gl modules only
|
|
176
|
+
export {log} from './utils/log';
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {ShaderUniformType} from '
|
|
6
|
-
import type {UniformValue} from '
|
|
5
|
+
import type {ShaderUniformType} from '../gpu-type-utils/shader-types';
|
|
6
|
+
import type {UniformValue} from '../adapter/types/uniforms';
|
|
7
7
|
import {
|
|
8
8
|
ShaderLayout,
|
|
9
9
|
UniformInfo,
|
|
10
10
|
UniformBufferBindingLayout
|
|
11
|
-
} from '
|
|
12
|
-
import {arrayEqual, arrayCopy} from '
|
|
11
|
+
} from '../adapter/types/shader-layout';
|
|
12
|
+
import {arrayEqual, arrayCopy} from '../utils/array-equal';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* A uniform block holds values of the of uniform values for one uniform block / buffer.
|
|
@@ -32,7 +32,7 @@ export class UniformBlock<
|
|
|
32
32
|
shaderLayout?: ShaderLayout;
|
|
33
33
|
uniformTypes?: Record<keyof TUniforms, Record<string, ShaderUniformType>>;
|
|
34
34
|
}) {
|
|
35
|
-
this.name = props?.name;
|
|
35
|
+
this.name = props?.name || 'unnamed';
|
|
36
36
|
|
|
37
37
|
// TODO - Extract uniform layout from the shaderLayout object
|
|
38
38
|
if (props?.name && props?.shaderLayout) {
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {ShaderUniformType, ShaderDataType} from '
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import type {ShaderUniformType, ShaderDataType} from '../gpu-type-utils/shader-types';
|
|
6
|
+
import {decodeShaderUniformType, alignTo} from '../gpu-type-utils/decode-shader-types';
|
|
7
|
+
|
|
8
|
+
import type {UniformValue} from '../adapter/types/uniforms';
|
|
9
|
+
import {getScratchArrayBuffer} from '../utils/array-utils-flat';
|
|
10
|
+
import {isNumberArray} from '../utils/is-array';
|
|
11
|
+
import {log} from '../utils/log';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Smallest buffer size that can be used for uniform buffers.
|
|
@@ -85,8 +86,7 @@ export class UniformBufferLayout {
|
|
|
85
86
|
// single value -> just set it
|
|
86
87
|
typedArray[offset] = Number(value);
|
|
87
88
|
} else {
|
|
88
|
-
|
|
89
|
-
if (!numericArray) {
|
|
89
|
+
if (!isNumberArray(value)) {
|
|
90
90
|
log.warn(
|
|
91
91
|
`Supplied value for multi component / array uniform ${name} is not a numeric array: ${value}`
|
|
92
92
|
)();
|
|
@@ -95,7 +95,7 @@ export class UniformBufferLayout {
|
|
|
95
95
|
}
|
|
96
96
|
// vector/matrix -> copy the supplied (typed) array, starting from offset
|
|
97
97
|
// TODO: we should limit or check size in case the supplied data overflows
|
|
98
|
-
typedArray.set(
|
|
98
|
+
typedArray.set(value, offset);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {ShaderUniformType} from '
|
|
6
|
-
import type {UniformValue} from '
|
|
7
|
-
import type {Device} from '
|
|
8
|
-
import {Buffer} from '
|
|
5
|
+
import type {ShaderUniformType} from '../gpu-type-utils/shader-types';
|
|
6
|
+
import type {UniformValue} from '../adapter/types/uniforms';
|
|
7
|
+
import type {Device} from '../adapter/device';
|
|
8
|
+
import {Buffer} from '../adapter/resources/buffer';
|
|
9
|
+
import {log} from '../utils/log';
|
|
9
10
|
import {UniformBlock} from './uniform-block';
|
|
10
11
|
import {UniformBufferLayout} from './uniform-buffer-layout';
|
|
11
|
-
import {log} from '../../utils/log';
|
|
12
12
|
|
|
13
13
|
export type ShaderModuleInputs = {
|
|
14
14
|
uniformTypes?: Record<string, ShaderUniformType>;
|
|
@@ -79,7 +79,7 @@ export class UniformStore<
|
|
|
79
79
|
uniforms: Partial<{[group in keyof TPropGroups]: Partial<TPropGroups[group]>}>
|
|
80
80
|
): void {
|
|
81
81
|
for (const [blockName, uniformValues] of Object.entries(uniforms)) {
|
|
82
|
-
this.uniformBlocks.get(blockName)
|
|
82
|
+
this.uniformBlocks.get(blockName)?.setUniforms(uniformValues);
|
|
83
83
|
// We leverage logging in updateUniformBuffers(), even though slightly less efficient
|
|
84
84
|
// this.updateUniformBuffer(blockName);
|
|
85
85
|
}
|
|
@@ -89,13 +89,14 @@ export class UniformStore<
|
|
|
89
89
|
|
|
90
90
|
/** Get the required minimum length of the uniform buffer */
|
|
91
91
|
getUniformBufferByteLength(uniformBufferName: keyof TPropGroups): number {
|
|
92
|
-
return this.uniformBufferLayouts.get(uniformBufferName)
|
|
92
|
+
return this.uniformBufferLayouts.get(uniformBufferName)?.byteLength || 0;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/** Get formatted binary memory that can be uploaded to a buffer */
|
|
96
96
|
getUniformBufferData(uniformBufferName: keyof TPropGroups): Uint8Array {
|
|
97
|
-
const uniformValues = this.uniformBlocks.get(uniformBufferName)
|
|
98
|
-
|
|
97
|
+
const uniformValues = this.uniformBlocks.get(uniformBufferName)?.getAllUniforms() || {};
|
|
98
|
+
// @ts-ignore
|
|
99
|
+
return this.uniformBufferLayouts.get(uniformBufferName)?.getData(uniformValues);
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
/**
|
|
@@ -132,6 +133,7 @@ export class UniformStore<
|
|
|
132
133
|
this.uniformBuffers.set(uniformBufferName, uniformBuffer);
|
|
133
134
|
}
|
|
134
135
|
// this.updateUniformBuffers();
|
|
136
|
+
// @ts-ignore
|
|
135
137
|
return this.uniformBuffers.get(uniformBufferName);
|
|
136
138
|
}
|
|
137
139
|
|
|
@@ -154,16 +156,16 @@ export class UniformStore<
|
|
|
154
156
|
const uniformBuffer = this.uniformBuffers.get(uniformBufferName);
|
|
155
157
|
|
|
156
158
|
let reason: false | string = false;
|
|
157
|
-
if (uniformBuffer && uniformBlock
|
|
159
|
+
if (uniformBuffer && uniformBlock?.needsRedraw) {
|
|
158
160
|
reason ||= uniformBlock.needsRedraw;
|
|
159
161
|
// This clears the needs redraw flag
|
|
160
162
|
const uniformBufferData = this.getUniformBufferData(uniformBufferName);
|
|
161
163
|
|
|
162
164
|
const uniformBuffer = this.uniformBuffers.get(uniformBufferName);
|
|
163
|
-
uniformBuffer
|
|
165
|
+
uniformBuffer?.write(uniformBufferData);
|
|
164
166
|
|
|
165
167
|
// logging - TODO - don't query the values unnecessarily
|
|
166
|
-
const uniformValues = this.uniformBlocks.get(uniformBufferName)
|
|
168
|
+
const uniformValues = this.uniformBlocks.get(uniformBufferName)?.getAllUniforms();
|
|
167
169
|
log.log(
|
|
168
170
|
4,
|
|
169
171
|
`Writing to uniform buffer ${String(uniformBufferName)}`,
|
package/src/types.ts
CHANGED
|
@@ -23,15 +23,3 @@ export type TypedArrayConstructor =
|
|
|
23
23
|
export type BigIntTypedArray = BigInt64Array | BigUint64Array;
|
|
24
24
|
|
|
25
25
|
export type BigIntOrNumberArray = NumberArray | BigIntTypedArray;
|
|
26
|
-
|
|
27
|
-
/** Get the constructor type of a type */
|
|
28
|
-
export interface ConstructorOf<T> {
|
|
29
|
-
new (...args: unknown[]): T;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Make specific fields in a type optional. Granular version of `Partial<T>`
|
|
34
|
-
* @example
|
|
35
|
-
* type PartialProps = PartialBy<Required<DeviceProps>, 'device' | 'canvas'>
|
|
36
|
-
*/
|
|
37
|
-
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
package/src/utils/array-equal.ts
CHANGED
|
@@ -9,12 +9,12 @@ export function arrayEqual(a: unknown, b: unknown, limit: number = 16) {
|
|
|
9
9
|
if (a !== b) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
|
-
const arrayA =
|
|
13
|
-
|
|
12
|
+
const arrayA = a;
|
|
13
|
+
const arrayB = b;
|
|
14
|
+
if (!isNumberArray(arrayA)) {
|
|
14
15
|
return false;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
if (arrayB && arrayA.length === arrayB.length) {
|
|
17
|
+
if (isNumberArray(arrayB) && arrayA.length === arrayB.length) {
|
|
18
18
|
for (let i = 0; i < arrayA.length; ++i) {
|
|
19
19
|
if (arrayB[i] !== arrayA[i]) {
|
|
20
20
|
return false;
|
|
@@ -26,9 +26,8 @@ export function arrayEqual(a: unknown, b: unknown, limit: number = 16) {
|
|
|
26
26
|
|
|
27
27
|
/** Copy a value */
|
|
28
28
|
export function arrayCopy<T>(a: T): T {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return numberArray.slice() as T;
|
|
29
|
+
if (isNumberArray(a)) {
|
|
30
|
+
return a.slice() as T;
|
|
32
31
|
}
|
|
33
32
|
return a;
|
|
34
33
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {TypedArray
|
|
5
|
+
import type {TypedArray} from '../types';
|
|
6
6
|
|
|
7
7
|
let arrayBuffer: ArrayBuffer;
|
|
8
8
|
|
|
@@ -17,33 +17,3 @@ export function getScratchArray(Type: any, length: number): TypedArray {
|
|
|
17
17
|
const scratchArrayBuffer = getScratchArrayBuffer(Type.BYTES_PER_ELEMENT * length);
|
|
18
18
|
return new Type(scratchArrayBuffer, 0, length); // arrayBuffer, byteOffset, length (in elements)
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
// Uses copyWithin to significantly speed up typed array value filling
|
|
22
|
-
export function fillArray(options: {
|
|
23
|
-
target: NumberArray;
|
|
24
|
-
source: NumberArray;
|
|
25
|
-
start?: number;
|
|
26
|
-
count?: number;
|
|
27
|
-
}): NumberArray {
|
|
28
|
-
const {target, source, start = 0, count = 1} = options;
|
|
29
|
-
const length = source.length;
|
|
30
|
-
const total = count * length;
|
|
31
|
-
let copied = 0;
|
|
32
|
-
for (let i = start; copied < length; copied++) {
|
|
33
|
-
target[i++] = source[copied];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
while (copied < total) {
|
|
37
|
-
// If we have copied less than half, copy everything we got
|
|
38
|
-
// else copy remaining in one operation
|
|
39
|
-
if (copied < total - copied) {
|
|
40
|
-
target.copyWithin(start + copied, start, start + copied);
|
|
41
|
-
copied *= 2;
|
|
42
|
-
} else {
|
|
43
|
-
target.copyWithin(start + copied, start, start + total - copied);
|
|
44
|
-
copied = total;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return options.target;
|
|
49
|
-
}
|