@luma.gl/core 9.1.9 → 9.2.0-alpha.3
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 +14 -1
- package/dist/adapter/adapter.d.ts.map +1 -1
- package/dist/adapter/adapter.js +27 -0
- package/dist/adapter/adapter.js.map +1 -1
- package/dist/adapter/canvas-context.d.ts +101 -48
- package/dist/adapter/canvas-context.d.ts.map +1 -1
- package/dist/adapter/canvas-context.js +255 -153
- package/dist/adapter/canvas-context.js.map +1 -1
- package/dist/adapter/device.d.ts +112 -42
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +153 -56
- package/dist/adapter/device.js.map +1 -1
- package/dist/adapter/luma.d.ts +24 -22
- package/dist/adapter/luma.d.ts.map +1 -1
- package/dist/adapter/luma.js +76 -92
- package/dist/adapter/luma.js.map +1 -1
- package/dist/adapter/resources/buffer.d.ts +18 -12
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js +14 -18
- package/dist/adapter/resources/buffer.js.map +1 -1
- package/dist/adapter/resources/command-buffer.d.ts +1 -1
- package/dist/adapter/resources/command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/command-buffer.js +3 -3
- package/dist/adapter/resources/command-buffer.js.map +1 -1
- package/dist/adapter/resources/command-encoder.d.ts +9 -2
- package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/command-encoder.js +7 -4
- package/dist/adapter/resources/command-encoder.js.map +1 -1
- package/dist/adapter/resources/compute-pass.d.ts +2 -2
- package/dist/adapter/resources/compute-pass.d.ts.map +1 -1
- package/dist/adapter/resources/compute-pass.js +3 -3
- package/dist/adapter/resources/compute-pass.js.map +1 -1
- package/dist/adapter/resources/compute-pipeline.d.ts +1 -1
- package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/compute-pipeline.js +7 -7
- package/dist/adapter/resources/compute-pipeline.js.map +1 -1
- 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 +5 -5
- package/dist/adapter/resources/external-texture.js.map +1 -1
- package/dist/adapter/resources/framebuffer.d.ts +4 -4
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/framebuffer.js +8 -9
- package/dist/adapter/resources/framebuffer.js.map +1 -1
- package/dist/adapter/resources/pipeline-layout.d.ts.map +1 -1
- package/dist/adapter/resources/pipeline-layout.js +3 -0
- package/dist/adapter/resources/pipeline-layout.js.map +1 -1
- package/dist/adapter/resources/query-set.d.ts +1 -1
- package/dist/adapter/resources/query-set.d.ts.map +1 -1
- package/dist/adapter/resources/query-set.js +5 -5
- package/dist/adapter/resources/query-set.js.map +1 -1
- 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-pass.js +10 -13
- package/dist/adapter/resources/render-pass.js.map +1 -1
- package/dist/adapter/resources/render-pipeline.d.ts +7 -9
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.js +17 -29
- package/dist/adapter/resources/render-pipeline.js.map +1 -1
- package/dist/adapter/resources/resource.d.ts +1 -0
- package/dist/adapter/resources/resource.d.ts.map +1 -1
- package/dist/adapter/resources/resource.js.map +1 -1
- package/dist/adapter/resources/sampler.d.ts.map +1 -1
- package/dist/adapter/resources/sampler.js +1 -3
- package/dist/adapter/resources/sampler.js.map +1 -1
- package/dist/adapter/resources/shader.d.ts +2 -2
- package/dist/adapter/resources/shader.d.ts.map +1 -1
- package/dist/adapter/resources/shader.js +14 -14
- package/dist/adapter/resources/shader.js.map +1 -1
- package/dist/adapter/resources/texture-view.d.ts +2 -2
- package/dist/adapter/resources/texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/texture-view.js +7 -7
- package/dist/adapter/resources/texture-view.js.map +1 -1
- package/dist/adapter/resources/texture.d.ts +84 -135
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/texture.js +136 -152
- package/dist/adapter/resources/texture.js.map +1 -1
- package/dist/adapter/resources/vertex-array.d.ts +4 -2
- package/dist/adapter/resources/vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/vertex-array.js +4 -7
- package/dist/adapter/resources/vertex-array.js.map +1 -1
- package/dist/adapter/types/attachments.d.ts +3 -3
- 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 +7 -3
- package/dist/adapter/types/parameters.d.ts.map +1 -1
- package/dist/adapter/types/parameters.js.map +1 -1
- package/dist/adapter/types/shader-layout.d.ts +5 -5
- package/dist/adapter/types/shader-layout.d.ts.map +1 -1
- package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -1
- package/dist/adapter-utils/format-compiler-log.js +8 -0
- package/dist/adapter-utils/format-compiler-log.js.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts +6 -5
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.js +8 -7
- package/dist/adapter-utils/get-attribute-from-layouts.js.map +1 -1
- package/dist/dist.dev.js +1162 -851
- package/dist/dist.min.js +7 -6
- package/dist/image-utils/image-types.d.ts +19 -0
- package/dist/image-utils/image-types.d.ts.map +1 -0
- package/dist/image-utils/image-types.js +34 -0
- package/dist/image-utils/image-types.js.map +1 -0
- package/dist/index.cjs +1129 -819
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +17 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -12
- package/dist/index.js.map +1 -1
- package/dist/portable/uniform-block.d.ts +2 -2
- package/dist/portable/uniform-block.d.ts.map +1 -1
- package/dist/portable/uniform-buffer-layout.d.ts +4 -3
- package/dist/portable/uniform-buffer-layout.d.ts.map +1 -1
- package/dist/portable/uniform-buffer-layout.js +3 -2
- package/dist/portable/uniform-buffer-layout.js.map +1 -1
- package/dist/portable/uniform-store.d.ts +2 -2
- package/dist/portable/uniform-store.d.ts.map +1 -1
- package/dist/shadertypes/data-types/data-types.d.ts +32 -0
- package/dist/shadertypes/data-types/data-types.d.ts.map +1 -0
- package/dist/{gpu-type-utils/texture-formats.js → shadertypes/data-types/data-types.js} +1 -1
- package/dist/shadertypes/data-types/data-types.js.map +1 -0
- package/dist/shadertypes/data-types/decode-data-types.d.ts +16 -0
- package/dist/shadertypes/data-types/decode-data-types.d.ts.map +1 -0
- package/dist/shadertypes/data-types/decode-data-types.js +74 -0
- package/dist/shadertypes/data-types/decode-data-types.js.map +1 -0
- package/dist/shadertypes/data-types/decode-shader-types.d.ts +17 -0
- package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +1 -0
- package/dist/shadertypes/data-types/decode-shader-types.js +171 -0
- package/dist/shadertypes/data-types/decode-shader-types.js.map +1 -0
- package/dist/shadertypes/data-types/shader-types.d.ts +45 -0
- package/dist/shadertypes/data-types/shader-types.d.ts.map +1 -0
- package/dist/shadertypes/data-types/shader-types.js.map +1 -0
- package/dist/shadertypes/textures/pixel-utils.d.ts +112 -0
- package/dist/shadertypes/textures/pixel-utils.d.ts.map +1 -0
- package/dist/shadertypes/textures/pixel-utils.js +193 -0
- package/dist/shadertypes/textures/pixel-utils.js.map +1 -0
- package/dist/shadertypes/textures/texture-format-decoder.d.ts +18 -0
- package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +1 -0
- package/dist/{gpu-type-utils/decode-texture-format.js → shadertypes/textures/texture-format-decoder.js} +52 -13
- package/dist/shadertypes/textures/texture-format-decoder.js.map +1 -0
- package/dist/shadertypes/textures/texture-format-generics.d.ts +33 -0
- package/dist/shadertypes/textures/texture-format-generics.d.ts.map +1 -0
- package/dist/{gpu-type-utils/texture-features.js → shadertypes/textures/texture-format-generics.js} +1 -1
- package/dist/shadertypes/textures/texture-format-generics.js.map +1 -0
- package/dist/{gpu-type-utils → shadertypes/textures}/texture-format-table.d.ts +2 -3
- package/dist/shadertypes/textures/texture-format-table.d.ts.map +1 -0
- package/dist/{gpu-type-utils → shadertypes/textures}/texture-format-table.js +42 -43
- package/dist/shadertypes/textures/texture-format-table.js.map +1 -0
- package/dist/shadertypes/textures/texture-formats.d.ts +90 -0
- package/dist/shadertypes/textures/texture-formats.d.ts.map +1 -0
- package/dist/shadertypes/textures/texture-formats.js +58 -0
- package/dist/shadertypes/textures/texture-formats.js.map +1 -0
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts +18 -0
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts.map +1 -0
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js +100 -0
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js.map +1 -0
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts +27 -0
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts.map +1 -0
- package/dist/shadertypes/vertex-arrays/vertex-formats.js.map +1 -0
- package/dist/types.d.ts +4 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/promise-utils.d.ts +6 -0
- package/dist/utils/promise-utils.d.ts.map +1 -0
- package/dist/utils/promise-utils.js +15 -0
- package/dist/utils/promise-utils.js.map +1 -0
- package/package.json +2 -2
- package/src/adapter/adapter.ts +36 -1
- package/src/adapter/canvas-context.ts +321 -198
- package/src/adapter/device.ts +261 -110
- package/src/adapter/luma.ts +97 -113
- package/src/adapter/resources/buffer.ts +45 -28
- package/src/adapter/resources/command-buffer.ts +4 -4
- package/src/adapter/resources/command-encoder.ts +15 -6
- package/src/adapter/resources/compute-pass.ts +11 -11
- package/src/adapter/resources/compute-pipeline.ts +8 -8
- package/src/adapter/resources/external-texture.ts +6 -6
- package/src/adapter/resources/framebuffer.ts +14 -15
- package/src/adapter/resources/pipeline-layout.ts +4 -0
- package/src/adapter/resources/query-set.ts +6 -6
- package/src/adapter/resources/render-pass.ts +20 -23
- package/src/adapter/resources/render-pipeline.ts +36 -42
- package/src/adapter/resources/resource.ts +1 -0
- package/src/adapter/resources/sampler.ts +1 -4
- package/src/adapter/resources/shader.ts +15 -15
- package/src/adapter/resources/texture-view.ts +12 -12
- package/src/adapter/resources/texture.ts +206 -300
- package/src/adapter/resources/vertex-array.ts +9 -10
- package/src/adapter/types/attachments.ts +5 -5
- package/src/adapter/types/buffer-layout.ts +1 -1
- package/src/adapter/types/parameters.ts +16 -11
- package/src/adapter/types/shader-layout.ts +8 -5
- package/src/adapter-utils/format-compiler-log.ts +8 -0
- package/src/adapter-utils/get-attribute-from-layouts.ts +17 -12
- package/src/image-utils/image-types.ts +59 -0
- package/src/index.ts +67 -47
- package/src/portable/uniform-block.ts +2 -2
- package/src/portable/uniform-buffer-layout.ts +7 -5
- package/src/portable/uniform-store.ts +2 -2
- package/src/shadertypes/data-types/data-types.ts +96 -0
- package/src/shadertypes/data-types/decode-data-types.ts +91 -0
- package/src/shadertypes/data-types/decode-shader-types.ts +211 -0
- package/src/shadertypes/data-types/shader-types.ts +87 -0
- package/src/shadertypes/textures/pixel-utils.ts +239 -0
- package/src/{gpu-type-utils/decode-texture-format.ts → shadertypes/textures/texture-format-decoder.ts} +71 -20
- package/src/shadertypes/textures/texture-format-generics.ts +190 -0
- package/src/{gpu-type-utils → shadertypes/textures}/texture-format-table.ts +63 -56
- package/src/shadertypes/textures/texture-formats.ts +334 -0
- package/src/shadertypes/vertex-arrays/decode-vertex-format.ts +124 -0
- package/src/shadertypes/vertex-arrays/vertex-formats.ts +91 -0
- package/src/types.ts +12 -5
- package/src/utils/promise-utils.ts +19 -0
- package/dist/adapter-utils/buffer-layout-helper.d.ts +0 -12
- package/dist/adapter-utils/buffer-layout-helper.d.ts.map +0 -1
- package/dist/adapter-utils/buffer-layout-helper.js +0 -41
- package/dist/adapter-utils/buffer-layout-helper.js.map +0 -1
- package/dist/adapter-utils/buffer-layout-order.d.ts +0 -4
- package/dist/adapter-utils/buffer-layout-order.d.ts.map +0 -1
- package/dist/adapter-utils/buffer-layout-order.js +0 -16
- package/dist/adapter-utils/buffer-layout-order.js.map +0 -1
- package/dist/gpu-type-utils/decode-attribute-type.d.ts +0 -20
- package/dist/gpu-type-utils/decode-attribute-type.d.ts.map +0 -1
- package/dist/gpu-type-utils/decode-attribute-type.js +0 -68
- package/dist/gpu-type-utils/decode-attribute-type.js.map +0 -1
- package/dist/gpu-type-utils/decode-data-type.d.ts +0 -16
- package/dist/gpu-type-utils/decode-data-type.d.ts.map +0 -1
- package/dist/gpu-type-utils/decode-data-type.js +0 -48
- package/dist/gpu-type-utils/decode-data-type.js.map +0 -1
- package/dist/gpu-type-utils/decode-shader-types.d.ts +0 -9
- package/dist/gpu-type-utils/decode-shader-types.d.ts.map +0 -1
- package/dist/gpu-type-utils/decode-shader-types.js +0 -42
- package/dist/gpu-type-utils/decode-shader-types.js.map +0 -1
- package/dist/gpu-type-utils/decode-texture-format.d.ts +0 -11
- package/dist/gpu-type-utils/decode-texture-format.d.ts.map +0 -1
- package/dist/gpu-type-utils/decode-texture-format.js.map +0 -1
- package/dist/gpu-type-utils/decode-vertex-format.d.ts +0 -22
- package/dist/gpu-type-utils/decode-vertex-format.d.ts.map +0 -1
- package/dist/gpu-type-utils/decode-vertex-format.js +0 -34
- package/dist/gpu-type-utils/decode-vertex-format.js.map +0 -1
- package/dist/gpu-type-utils/shader-types.d.ts +0 -21
- package/dist/gpu-type-utils/shader-types.d.ts.map +0 -1
- package/dist/gpu-type-utils/shader-types.js.map +0 -1
- package/dist/gpu-type-utils/texture-features.d.ts +0 -6
- package/dist/gpu-type-utils/texture-features.d.ts.map +0 -1
- package/dist/gpu-type-utils/texture-features.js.map +0 -1
- package/dist/gpu-type-utils/texture-format-capabilities.d.ts +0 -21
- package/dist/gpu-type-utils/texture-format-capabilities.d.ts.map +0 -1
- package/dist/gpu-type-utils/texture-format-capabilities.js +0 -27
- package/dist/gpu-type-utils/texture-format-capabilities.js.map +0 -1
- package/dist/gpu-type-utils/texture-format-info.d.ts +0 -38
- package/dist/gpu-type-utils/texture-format-info.d.ts.map +0 -1
- package/dist/gpu-type-utils/texture-format-info.js +0 -5
- package/dist/gpu-type-utils/texture-format-info.js.map +0 -1
- package/dist/gpu-type-utils/texture-format-table.d.ts.map +0 -1
- package/dist/gpu-type-utils/texture-format-table.js.map +0 -1
- package/dist/gpu-type-utils/texture-formats.d.ts +0 -11
- package/dist/gpu-type-utils/texture-formats.d.ts.map +0 -1
- package/dist/gpu-type-utils/texture-formats.js.map +0 -1
- package/dist/gpu-type-utils/vertex-format-from-attribute.d.ts +0 -10
- package/dist/gpu-type-utils/vertex-format-from-attribute.d.ts.map +0 -1
- package/dist/gpu-type-utils/vertex-format-from-attribute.js +0 -91
- package/dist/gpu-type-utils/vertex-format-from-attribute.js.map +0 -1
- package/dist/gpu-type-utils/vertex-formats.d.ts +0 -14
- package/dist/gpu-type-utils/vertex-formats.d.ts.map +0 -1
- package/dist/gpu-type-utils/vertex-formats.js.map +0 -1
- package/dist/gpu-type-utils/wgsl-utils.d.ts +0 -4
- package/dist/gpu-type-utils/wgsl-utils.d.ts.map +0 -1
- package/dist/gpu-type-utils/wgsl-utils.js +0 -20
- package/dist/gpu-type-utils/wgsl-utils.js.map +0 -1
- package/src/adapter-utils/buffer-layout-helper.ts +0 -52
- package/src/adapter-utils/buffer-layout-order.ts +0 -27
- package/src/gpu-type-utils/decode-attribute-type.ts +0 -96
- package/src/gpu-type-utils/decode-data-type.ts +0 -66
- package/src/gpu-type-utils/decode-shader-types.ts +0 -49
- package/src/gpu-type-utils/decode-vertex-format.ts +0 -53
- package/src/gpu-type-utils/shader-types.ts +0 -78
- package/src/gpu-type-utils/texture-features.ts +0 -23
- package/src/gpu-type-utils/texture-format-capabilities.ts +0 -53
- package/src/gpu-type-utils/texture-format-info.ts +0 -42
- package/src/gpu-type-utils/texture-formats.ts +0 -161
- package/src/gpu-type-utils/vertex-format-from-attribute.ts +0 -114
- package/src/gpu-type-utils/vertex-formats.ts +0 -90
- package/src/gpu-type-utils/wgsl-utils.ts +0 -22
- /package/dist/{gpu-type-utils → shadertypes/data-types}/shader-types.js +0 -0
- /package/dist/{gpu-type-utils → shadertypes/vertex-arrays}/vertex-formats.js +0 -0
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
export function getDataTypeFromTypedArray(arrayOrType) {
|
|
5
|
-
const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
6
|
-
switch (type) {
|
|
7
|
-
case Float32Array:
|
|
8
|
-
return 'float32';
|
|
9
|
-
case Uint16Array:
|
|
10
|
-
return 'uint16';
|
|
11
|
-
case Uint32Array:
|
|
12
|
-
return 'uint32';
|
|
13
|
-
case Uint8Array:
|
|
14
|
-
case Uint8ClampedArray:
|
|
15
|
-
return 'uint8';
|
|
16
|
-
case Int8Array:
|
|
17
|
-
return 'sint8';
|
|
18
|
-
case Int16Array:
|
|
19
|
-
return 'sint16';
|
|
20
|
-
case Int32Array:
|
|
21
|
-
return 'sint32';
|
|
22
|
-
default:
|
|
23
|
-
// Failed to deduce data type from typed array
|
|
24
|
-
throw new Error(type.constructor.name);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export function getTypedArrayFromDataType(dataType) {
|
|
28
|
-
switch (dataType) {
|
|
29
|
-
case 'float32':
|
|
30
|
-
return Float32Array;
|
|
31
|
-
case 'uint32':
|
|
32
|
-
return Uint32Array;
|
|
33
|
-
case 'sint32':
|
|
34
|
-
return Int32Array;
|
|
35
|
-
case 'uint16':
|
|
36
|
-
case 'unorm16':
|
|
37
|
-
return Uint16Array;
|
|
38
|
-
case 'sint16':
|
|
39
|
-
case 'snorm16':
|
|
40
|
-
return Int16Array;
|
|
41
|
-
case 'uint8':
|
|
42
|
-
case 'unorm8':
|
|
43
|
-
return Uint8Array;
|
|
44
|
-
case 'sint8':
|
|
45
|
-
case 'snorm8':
|
|
46
|
-
return Int8Array;
|
|
47
|
-
default:
|
|
48
|
-
// Failed to deduce typed array from data type
|
|
49
|
-
throw new Error(dataType);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/** Get the vertex format for an attribute with TypedArray and size */
|
|
53
|
-
export function getVertexFormatFromAttribute(typedArray, size, normalized) {
|
|
54
|
-
if (!size || size > 4) {
|
|
55
|
-
throw new Error(`size ${size}`);
|
|
56
|
-
}
|
|
57
|
-
const components = size;
|
|
58
|
-
let dataType = getDataTypeFromTypedArray(typedArray);
|
|
59
|
-
// TODO - Special cases for WebGL (not supported on WebGPU), overrides the check below
|
|
60
|
-
if (dataType === 'uint8' && normalized && components === 1) {
|
|
61
|
-
return 'unorm8-webgl';
|
|
62
|
-
}
|
|
63
|
-
if (dataType === 'uint8' && normalized && components === 3) {
|
|
64
|
-
return 'unorm8x3-webgl';
|
|
65
|
-
}
|
|
66
|
-
if (dataType === 'uint8' || dataType === 'sint8') {
|
|
67
|
-
if (components === 1 || components === 3) {
|
|
68
|
-
// WebGPU 8 bit formats must be aligned to 16 bit boundaries');
|
|
69
|
-
throw new Error(`size: ${size}`);
|
|
70
|
-
}
|
|
71
|
-
if (normalized) {
|
|
72
|
-
dataType = dataType.replace('int', 'norm');
|
|
73
|
-
}
|
|
74
|
-
return `${dataType}x${components}`;
|
|
75
|
-
}
|
|
76
|
-
if (dataType === 'uint16' || dataType === 'sint16') {
|
|
77
|
-
if (components === 1 || components === 3) {
|
|
78
|
-
// WebGPU 16 bit formats must be aligned to 32 bit boundaries
|
|
79
|
-
throw new Error(`size: ${size}`);
|
|
80
|
-
}
|
|
81
|
-
if (normalized) {
|
|
82
|
-
dataType = dataType.replace('int', 'norm');
|
|
83
|
-
}
|
|
84
|
-
return `${dataType}x${components}`;
|
|
85
|
-
}
|
|
86
|
-
if (components === 1) {
|
|
87
|
-
return dataType;
|
|
88
|
-
}
|
|
89
|
-
return `${dataType}x${components}`;
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=vertex-format-from-attribute.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vertex-format-from-attribute.js","sourceRoot":"","sources":["../../src/gpu-type-utils/vertex-format-from-attribute.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** Basic data types signed and unsigned integers, and floats, of varying sizes */
|
|
2
|
-
export type DataType = 'uint8' | 'sint8' | 'uint16' | 'sint16' | 'uint32' | 'sint32' | 'float16' | 'float32';
|
|
3
|
-
/** Vertex and Pixel data types. Include normalized integers */
|
|
4
|
-
export type NormalizedDataType = 'uint8' | 'sint8' | 'unorm8' | 'snorm8' | 'uint16' | 'sint16' | 'unorm16' | 'snorm16' | 'uint32' | 'sint32' | 'float32' | 'float16';
|
|
5
|
-
/** Describes the type (without number of components) of a vertex format */
|
|
6
|
-
export type VertexType = NormalizedDataType;
|
|
7
|
-
/**
|
|
8
|
-
* Describes the memory format of a buffer that will be supplied to vertex attributes
|
|
9
|
-
* @note Must be compatible with the ShaderAttributeType of the shaders, see documentation.
|
|
10
|
-
* @note This is a superset of WebGPU vertex formats to allow foe some flexibility for WebGL only applications
|
|
11
|
-
* @todo Add device.isTextureFormatSupported() method?
|
|
12
|
-
*/
|
|
13
|
-
export type VertexFormat = 'uint8x2' | 'uint8x4' | 'sint8x2' | 'sint8x4' | 'unorm8-webgl' | 'unorm8x2' | 'unorm8x3-webgl' | 'unorm8x4' | 'snorm8-webgl' | 'snorm8x2' | 'snorm8x3-webgl' | 'snorm8x4' | 'uint16x2' | 'uint16x4' | 'sint16x2' | 'sint16x4' | 'unorm16x2' | 'unorm16x4' | 'snorm16x2' | 'snorm16x4' | 'uint32' | 'uint32x2' | 'uint32x3' | 'uint32x4' | 'sint32' | 'sint32x2' | 'sint32x3' | 'sint32x4' | 'float16x2' | 'float16x4' | 'float32' | 'float32x2' | 'float32x3' | 'float32x4';
|
|
14
|
-
//# sourceMappingURL=vertex-formats.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vertex-formats.d.ts","sourceRoot":"","sources":["../../src/gpu-type-utils/vertex-formats.ts"],"names":[],"mappings":"AAIA,kFAAkF;AAClF,MAAM,MAAM,QAAQ,GAChB,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,CAAC;AAEd,+DAA+D;AAC/D,MAAM,MAAM,kBAAkB,GAC1B,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,QAAQ,GACR,QAAQ,GAIR,SAAS,GACT,SAAS,CAAC;AAEd,2EAA2E;AAC3E,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAEpB,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,cAAc,GACd,UAAU,GACV,gBAAgB,GAChB,UAAU,GACV,cAAc,GACd,UAAU,GACV,gBAAgB,GAChB,UAAU,GAEV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GAEX,QAAQ,GACR,UAAU,GACV,UAAU,GACV,UAAU,GACV,QAAQ,GACR,UAAU,GACV,UAAU,GACV,UAAU,GAWV,WAAW,GACX,WAAW,GACX,SAAS,GACT,WAAW,GACX,WAAW,GACX,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vertex-formats.js","sourceRoot":"","sources":["../../src/gpu-type-utils/vertex-formats.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wgsl-utils.d.ts","sourceRoot":"","sources":["../../src/gpu-type-utils/wgsl-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,mBAAmB,EAAC,0BAAuB;AAEnD,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAcnE,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
/** Predeclared aliases @see https://www.w3.org/TR/WGSL/#vector-types */
|
|
5
|
-
export const WGSL_TYPE_ALIAS_MAP = {
|
|
6
|
-
vec2i: 'vec2<i32>',
|
|
7
|
-
vec3i: 'vec3<i32>',
|
|
8
|
-
vec4i: 'vec4<i32>',
|
|
9
|
-
vec2u: 'vec2<u32>',
|
|
10
|
-
vec3u: 'vec3<u32>',
|
|
11
|
-
vec4u: 'vec4<u32>',
|
|
12
|
-
vec2f: 'vec2<f32>',
|
|
13
|
-
vec3f: 'vec3<f32>',
|
|
14
|
-
vec4f: 'vec4<f32>',
|
|
15
|
-
// Requires the f16 extension.
|
|
16
|
-
vec2h: 'vec2<f16>',
|
|
17
|
-
vec3h: 'vec3<f16>',
|
|
18
|
-
vec4h: 'vec4<f16>'
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=wgsl-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wgsl-utils.js","sourceRoot":"","sources":["../../src/gpu-type-utils/wgsl-utils.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,yEAAyE;AACzE,MAAM,CAAC,MAAM,mBAAmB,GAAwC;IACtE,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;IAClB,8BAA8B;IAC9B,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;CACnB,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {BufferLayout} from '../adapter/types/buffer-layout';
|
|
6
|
-
import {log} from '../utils/log';
|
|
7
|
-
|
|
8
|
-
/** BufferLayoutHelper is a helper class that should not be used directly by applications */
|
|
9
|
-
export class BufferLayoutHelper {
|
|
10
|
-
bufferLayouts: BufferLayout[];
|
|
11
|
-
|
|
12
|
-
constructor(bufferLayouts: BufferLayout[]) {
|
|
13
|
-
this.bufferLayouts = bufferLayouts;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
getBufferLayout(name: string): BufferLayout | null {
|
|
17
|
-
return this.bufferLayouts.find(layout => layout.name === name) || null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** Get attribute names from a BufferLayout */
|
|
21
|
-
getAttributeNamesForBuffer(bufferLayout: BufferLayout): string[] {
|
|
22
|
-
return bufferLayout.attributes
|
|
23
|
-
? bufferLayout.attributes?.map(layout => layout.attribute)
|
|
24
|
-
: [bufferLayout.name];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
mergeBufferLayouts(
|
|
28
|
-
bufferLayouts1: BufferLayout[],
|
|
29
|
-
bufferLayouts2: BufferLayout[]
|
|
30
|
-
): BufferLayout[] {
|
|
31
|
-
const mergedLayouts = [...bufferLayouts1];
|
|
32
|
-
for (const attribute of bufferLayouts2) {
|
|
33
|
-
const index = mergedLayouts.findIndex(attribute2 => attribute2.name === attribute.name);
|
|
34
|
-
if (index < 0) {
|
|
35
|
-
mergedLayouts.push(attribute);
|
|
36
|
-
} else {
|
|
37
|
-
mergedLayouts[index] = attribute;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return mergedLayouts;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
getBufferIndex(bufferName: string): number {
|
|
44
|
-
const bufferIndex = this.bufferLayouts.findIndex(layout => layout.name === bufferName);
|
|
45
|
-
|
|
46
|
-
if (bufferIndex === -1) {
|
|
47
|
-
log.warn(`BufferLayout: Missing buffer for "${bufferName}".`)();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return bufferIndex;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {BufferLayout} from '../adapter/types/buffer-layout';
|
|
6
|
-
import {ShaderLayout} from '../adapter/types/shader-layout';
|
|
7
|
-
|
|
8
|
-
export function sortedBufferLayoutByShaderSourceLocations(
|
|
9
|
-
shaderLayout: ShaderLayout,
|
|
10
|
-
bufferLayout: BufferLayout[]
|
|
11
|
-
): BufferLayout[] {
|
|
12
|
-
const shaderLayoutMap = Object.fromEntries(
|
|
13
|
-
shaderLayout.attributes.map(attr => [attr.name, attr.location])
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
const sortedLayout = bufferLayout.slice();
|
|
17
|
-
sortedLayout.sort((a, b) => {
|
|
18
|
-
const attributeNamesA = a.attributes ? a.attributes.map(attr => attr.attribute) : [a.name];
|
|
19
|
-
const attributeNamesB = b.attributes ? b.attributes.map(attr => attr.attribute) : [b.name];
|
|
20
|
-
const minLocationA = Math.min(...attributeNamesA.map(name => shaderLayoutMap[name]));
|
|
21
|
-
const minLocationB = Math.min(...attributeNamesB.map(name => shaderLayoutMap[name]));
|
|
22
|
-
|
|
23
|
-
return minLocationA - minLocationB;
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
return sortedLayout;
|
|
27
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {ShaderDataType, ShaderAttributeType} from './shader-types';
|
|
6
|
-
import {VertexFormat, VertexType} from './vertex-formats';
|
|
7
|
-
|
|
8
|
-
/** Information extracted from a ShaderAttributeInfo constant */
|
|
9
|
-
export type ShaderAttributeTypeInfo = {
|
|
10
|
-
/** WGSL-style primitive data type, f32, i32, u32 */
|
|
11
|
-
dataType: ShaderDataType;
|
|
12
|
-
/** Whether this is a normalized integer (that must be used as float) */
|
|
13
|
-
components: 1 | 2 | 3 | 4;
|
|
14
|
-
/** Length in bytes of the data for one vertex */
|
|
15
|
-
byteLength?: number;
|
|
16
|
-
/** Whether this is for integer or float vert */
|
|
17
|
-
integer: boolean;
|
|
18
|
-
/** Whether this data type is signed */
|
|
19
|
-
signed: boolean;
|
|
20
|
-
/** The simplest vertex format that matches the shader attribute's data type */
|
|
21
|
-
defaultVertexFormat: VertexFormat;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/** Decodes a vertex type, returning byte length and flags (integer, signed, normalized) */
|
|
25
|
-
export function decodeShaderAttributeType(
|
|
26
|
-
attributeType: ShaderAttributeType
|
|
27
|
-
): ShaderAttributeTypeInfo {
|
|
28
|
-
const [dataType, components] = TYPE_INFO[attributeType];
|
|
29
|
-
const integer: boolean = dataType === 'i32' || dataType === 'u32';
|
|
30
|
-
const signed: boolean = dataType !== 'u32';
|
|
31
|
-
|
|
32
|
-
const byteLength = TYPE_SIZES[dataType] * components;
|
|
33
|
-
const defaultVertexFormat = getCompatibleVertexFormat(dataType, components);
|
|
34
|
-
return {
|
|
35
|
-
dataType,
|
|
36
|
-
components,
|
|
37
|
-
defaultVertexFormat,
|
|
38
|
-
byteLength,
|
|
39
|
-
integer,
|
|
40
|
-
signed
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** Get the "default" vertex format for a certain shader data type */
|
|
45
|
-
function getCompatibleVertexFormat(
|
|
46
|
-
dataType: ShaderDataType,
|
|
47
|
-
components: 1 | 2 | 3 | 4
|
|
48
|
-
): VertexFormat {
|
|
49
|
-
let vertexType: VertexType;
|
|
50
|
-
switch (dataType) {
|
|
51
|
-
case 'f32':
|
|
52
|
-
vertexType = 'float32';
|
|
53
|
-
break;
|
|
54
|
-
case 'i32':
|
|
55
|
-
vertexType = 'sint32';
|
|
56
|
-
break;
|
|
57
|
-
case 'u32':
|
|
58
|
-
vertexType = 'uint32';
|
|
59
|
-
break;
|
|
60
|
-
case 'f16':
|
|
61
|
-
return components <= 2 ? 'float16x2' : 'float16x4';
|
|
62
|
-
}
|
|
63
|
-
// TODO logic does not work for float16
|
|
64
|
-
if (components === 1) {
|
|
65
|
-
return vertexType;
|
|
66
|
-
}
|
|
67
|
-
return `${vertexType}x${components}`;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** All valid shader attribute types. A table guarantees exhaustive list and fast execution */
|
|
71
|
-
const TYPE_INFO: Record<ShaderAttributeType, [ShaderDataType, 1 | 2 | 3 | 4]> = {
|
|
72
|
-
f32: ['f32', 1],
|
|
73
|
-
'vec2<f32>': ['f32', 2],
|
|
74
|
-
'vec3<f32>': ['f32', 3],
|
|
75
|
-
'vec4<f32>': ['f32', 4],
|
|
76
|
-
f16: ['f16', 1],
|
|
77
|
-
'vec2<f16>': ['f16', 2],
|
|
78
|
-
'vec3<f16>': ['f16', 3],
|
|
79
|
-
'vec4<f16>': ['f16', 4],
|
|
80
|
-
i32: ['i32', 1],
|
|
81
|
-
'vec2<i32>': ['i32', 2],
|
|
82
|
-
'vec3<i32>': ['i32', 3],
|
|
83
|
-
'vec4<i32>': ['i32', 4],
|
|
84
|
-
u32: ['u32', 1],
|
|
85
|
-
'vec2<u32>': ['u32', 2],
|
|
86
|
-
'vec3<u32>': ['u32', 3],
|
|
87
|
-
'vec4<u32>': ['u32', 4]
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const TYPE_SIZES: Record<ShaderDataType, number> = {
|
|
91
|
-
f32: 4,
|
|
92
|
-
f16: 2,
|
|
93
|
-
i32: 4,
|
|
94
|
-
u32: 4
|
|
95
|
-
// 'bool-webgl': 4,
|
|
96
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {DataType, NormalizedDataType} from './vertex-formats';
|
|
6
|
-
|
|
7
|
-
export type DecodedVertexType = {
|
|
8
|
-
/** WebGPU data type */
|
|
9
|
-
dataType: DataType;
|
|
10
|
-
/** Length in bytes of the data for one vertex */
|
|
11
|
-
byteLength: number;
|
|
12
|
-
/** Whether this is for integer or float vert */
|
|
13
|
-
integer: boolean;
|
|
14
|
-
/** Whether this data type is signed */
|
|
15
|
-
signed: boolean;
|
|
16
|
-
/** Whether this is a normalized integer (that must be used as float) */
|
|
17
|
-
normalized: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/** Decodes a vertex type, returning byte length and flags (integer, signed, normalized) */
|
|
21
|
-
export function decodeVertexType(type: NormalizedDataType): DecodedVertexType {
|
|
22
|
-
const dataType = TYPE_MAP[type];
|
|
23
|
-
const bytes = getDataTypeBytes(dataType);
|
|
24
|
-
const normalized: boolean = type.includes('norm');
|
|
25
|
-
const integer: boolean = !normalized && !type.startsWith('float');
|
|
26
|
-
const signed: boolean = type.startsWith('s');
|
|
27
|
-
return {
|
|
28
|
-
dataType: TYPE_MAP[type],
|
|
29
|
-
byteLength: bytes,
|
|
30
|
-
integer,
|
|
31
|
-
signed,
|
|
32
|
-
normalized
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function getDataTypeBytes(type: DataType): number {
|
|
37
|
-
const bytes = TYPE_SIZES[type];
|
|
38
|
-
// assert(bytes);
|
|
39
|
-
return bytes;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const TYPE_MAP: Record<NormalizedDataType, DataType> = {
|
|
43
|
-
uint8: 'uint8',
|
|
44
|
-
sint8: 'sint8',
|
|
45
|
-
unorm8: 'uint8',
|
|
46
|
-
snorm8: 'sint8',
|
|
47
|
-
uint16: 'uint16',
|
|
48
|
-
sint16: 'sint16',
|
|
49
|
-
unorm16: 'uint16',
|
|
50
|
-
snorm16: 'sint16',
|
|
51
|
-
float16: 'float16',
|
|
52
|
-
float32: 'float32',
|
|
53
|
-
uint32: 'uint32',
|
|
54
|
-
sint32: 'sint32'
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const TYPE_SIZES: Record<DataType, number> = {
|
|
58
|
-
uint8: 1,
|
|
59
|
-
sint8: 1,
|
|
60
|
-
uint16: 2,
|
|
61
|
-
sint16: 2,
|
|
62
|
-
float16: 2,
|
|
63
|
-
float32: 4,
|
|
64
|
-
uint32: 4,
|
|
65
|
-
sint32: 4
|
|
66
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {ShaderUniformType, ShaderDataType} from './shader-types';
|
|
6
|
-
|
|
7
|
-
const UNIFORM_FORMATS: Record<ShaderUniformType, {type: ShaderDataType; components: number}> = {
|
|
8
|
-
f32: {type: 'f32', components: 1},
|
|
9
|
-
i32: {type: 'i32', components: 1},
|
|
10
|
-
u32: {type: 'u32', components: 1},
|
|
11
|
-
// 'bool-webgl': {type: 'bool-webgl', components: 1},
|
|
12
|
-
'vec2<f32>': {type: 'f32', components: 2},
|
|
13
|
-
'vec3<f32>': {type: 'f32', components: 3},
|
|
14
|
-
'vec4<f32>': {type: 'f32', components: 4},
|
|
15
|
-
'vec2<i32>': {type: 'i32', components: 2},
|
|
16
|
-
'vec3<i32>': {type: 'i32', components: 3},
|
|
17
|
-
'vec4<i32>': {type: 'i32', components: 4},
|
|
18
|
-
'vec2<u32>': {type: 'u32', components: 2},
|
|
19
|
-
'vec3<u32>': {type: 'u32', components: 3},
|
|
20
|
-
'vec4<u32>': {type: 'u32', components: 4},
|
|
21
|
-
'mat2x2<f32>': {type: 'f32', components: 4},
|
|
22
|
-
'mat2x3<f32>': {type: 'f32', components: 6},
|
|
23
|
-
'mat2x4<f32>': {type: 'f32', components: 8},
|
|
24
|
-
'mat3x2<f32>': {type: 'f32', components: 6},
|
|
25
|
-
'mat3x3<f32>': {type: 'f32', components: 9},
|
|
26
|
-
'mat3x4<f32>': {type: 'f32', components: 12},
|
|
27
|
-
'mat4x2<f32>': {type: 'f32', components: 8},
|
|
28
|
-
'mat4x3<f32>': {type: 'f32', components: 12},
|
|
29
|
-
'mat4x4<f32>': {type: 'f32', components: 16}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/** Split a uniform type string into type and components */
|
|
33
|
-
export function decodeShaderUniformType(format: ShaderUniformType): {
|
|
34
|
-
type: ShaderDataType;
|
|
35
|
-
components: number;
|
|
36
|
-
} {
|
|
37
|
-
const decoded = UNIFORM_FORMATS[format];
|
|
38
|
-
return decoded;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Align offset to 1, 2 or 4 elements (4, 8 or 16 bytes) */
|
|
42
|
-
export function alignTo(size: number, count: number): number {
|
|
43
|
-
// prettier-ignore
|
|
44
|
-
switch (count) {
|
|
45
|
-
case 1: return size; // Pad upwards to even multiple of 2
|
|
46
|
-
case 2: return size + (size % 2); // Pad upwards to even multiple of 2
|
|
47
|
-
default: return size + ((4 - (size % 4)) % 4); // Pad upwards to even multiple of 4
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {VertexFormat, VertexType} from './vertex-formats';
|
|
6
|
-
import {decodeVertexType} from './decode-data-type';
|
|
7
|
-
|
|
8
|
-
export type VertexFormatInfo = {
|
|
9
|
-
/** Length in bytes */
|
|
10
|
-
byteLength: number;
|
|
11
|
-
/** Type of each component */
|
|
12
|
-
type: VertexType;
|
|
13
|
-
/** Number of components per vertex / row */
|
|
14
|
-
components: 1 | 2 | 3 | 4;
|
|
15
|
-
/** Is this an integer format (normalized integer formats are not integer) */
|
|
16
|
-
integer: boolean;
|
|
17
|
-
/** Is this a signed format? */
|
|
18
|
-
signed: boolean;
|
|
19
|
-
/** Is this a normalized format? */
|
|
20
|
-
normalized: boolean;
|
|
21
|
-
/** Is this a webgl only format? */
|
|
22
|
-
webglOnly?: boolean;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Decodes a vertex format, returning type, components, byte length and flags (integer, signed, normalized)
|
|
27
|
-
*/
|
|
28
|
-
export function decodeVertexFormat(format: VertexFormat): VertexFormatInfo {
|
|
29
|
-
// Strip the -webgl ending if present
|
|
30
|
-
let webglOnly: boolean | undefined;
|
|
31
|
-
if (format.endsWith('-webgl')) {
|
|
32
|
-
format.replace('-webgl', '');
|
|
33
|
-
webglOnly = true;
|
|
34
|
-
}
|
|
35
|
-
// split components from type
|
|
36
|
-
const [type_, count] = format.split('x');
|
|
37
|
-
const type = type_ as VertexType;
|
|
38
|
-
const components = (count ? parseInt(count) : 1) as 1 | 2 | 3 | 4;
|
|
39
|
-
// decode the type
|
|
40
|
-
const decodedType = decodeVertexType(type);
|
|
41
|
-
const result: VertexFormatInfo = {
|
|
42
|
-
type,
|
|
43
|
-
components,
|
|
44
|
-
byteLength: decodedType.byteLength * components,
|
|
45
|
-
integer: decodedType.integer,
|
|
46
|
-
signed: decodedType.signed,
|
|
47
|
-
normalized: decodedType.normalized
|
|
48
|
-
};
|
|
49
|
-
if (webglOnly) {
|
|
50
|
-
result.webglOnly = true;
|
|
51
|
-
}
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Primitive data types understood by shaders
|
|
7
|
-
* @note These types describe the type used in shader calculations, but for attribute inputs these can be populated from a different in-memory type.
|
|
8
|
-
* @note bindings (like textures, samplers, and uniform buffers) are considered "bindings", not types
|
|
9
|
-
* @note `f16` requires the `f16` extension
|
|
10
|
-
*/
|
|
11
|
-
export type ShaderDataType = 'u32' | 'i32' | 'f32' | 'f16';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Describes the type of an attribute as defined in the shader source code.
|
|
15
|
-
* @note Buffers with various `VertexFormat`s can be supplied for each type, and the GPU will convert them at runtime,
|
|
16
|
-
* but there are limitations, see documentation for details.
|
|
17
|
-
*/
|
|
18
|
-
export type ShaderAttributeType =
|
|
19
|
-
| 'f32'
|
|
20
|
-
| 'vec2<f32>'
|
|
21
|
-
| 'vec3<f32>'
|
|
22
|
-
| 'vec4<f32>'
|
|
23
|
-
| 'i32'
|
|
24
|
-
| 'vec2<i32>'
|
|
25
|
-
| 'vec3<i32>'
|
|
26
|
-
| 'vec4<i32>'
|
|
27
|
-
| 'u32'
|
|
28
|
-
| 'vec2<u32>'
|
|
29
|
-
| 'vec3<u32>'
|
|
30
|
-
| 'vec4<u32>'
|
|
31
|
-
// requires `f16` extension
|
|
32
|
-
| 'f16'
|
|
33
|
-
| 'vec2<f16>'
|
|
34
|
-
| 'vec3<f16>'
|
|
35
|
-
| 'vec4<f16>';
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Describes the type of a uniform as described in the shader source code.
|
|
39
|
-
* Uniforms can be of a wider range of types than attributes.
|
|
40
|
-
*/
|
|
41
|
-
export type ShaderUniformType =
|
|
42
|
-
| 'f32'
|
|
43
|
-
| 'i32'
|
|
44
|
-
| 'u32'
|
|
45
|
-
| 'vec2<f32>'
|
|
46
|
-
| 'vec3<f32>'
|
|
47
|
-
| 'vec4<f32>'
|
|
48
|
-
| 'vec2<i32>'
|
|
49
|
-
| 'vec3<i32>'
|
|
50
|
-
| 'vec4<i32>'
|
|
51
|
-
| 'vec2<u32>'
|
|
52
|
-
| 'vec3<u32>'
|
|
53
|
-
| 'vec4<u32>'
|
|
54
|
-
| 'mat2x2<f32>'
|
|
55
|
-
| 'mat2x3<f32>'
|
|
56
|
-
| 'mat2x4<f32>'
|
|
57
|
-
| 'mat3x2<f32>'
|
|
58
|
-
| 'mat3x3<f32>'
|
|
59
|
-
| 'mat3x4<f32>'
|
|
60
|
-
| 'mat4x2<f32>'
|
|
61
|
-
| 'mat4x3<f32>'
|
|
62
|
-
| 'mat4x4<f32>';
|
|
63
|
-
|
|
64
|
-
/** Shorthand type aliases recognized by WGSL */
|
|
65
|
-
export type ShaderTypeAlias =
|
|
66
|
-
| 'vec2i'
|
|
67
|
-
| 'vec3i'
|
|
68
|
-
| 'vec4i'
|
|
69
|
-
| 'vec2u'
|
|
70
|
-
| 'vec3u'
|
|
71
|
-
| 'vec4u'
|
|
72
|
-
| 'vec2f'
|
|
73
|
-
| 'vec3f'
|
|
74
|
-
| 'vec4f'
|
|
75
|
-
// Requires the f16 extension.
|
|
76
|
-
| 'vec2h'
|
|
77
|
-
| 'vec3h'
|
|
78
|
-
| 'vec4h';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Texture feature checks
|
|
7
|
-
* @note these must be a subset of DeviceFeatures.
|
|
8
|
-
*/
|
|
9
|
-
export type TextureFeature =
|
|
10
|
-
| 'texture-compression-bc'
|
|
11
|
-
| 'texture-compression-astc'
|
|
12
|
-
| 'texture-compression-etc2'
|
|
13
|
-
| 'texture-compression-etc1-webgl'
|
|
14
|
-
| 'texture-compression-pvrtc-webgl'
|
|
15
|
-
| 'texture-compression-atc-webgl'
|
|
16
|
-
| 'float32-renderable-webgl'
|
|
17
|
-
| 'float16-renderable-webgl'
|
|
18
|
-
| 'rgb9e5ufloat-renderable-webgl'
|
|
19
|
-
| 'snorm8-renderable-webgl'
|
|
20
|
-
| 'norm16-renderable-webgl'
|
|
21
|
-
| 'snorm16-renderable-webgl'
|
|
22
|
-
| 'float32-filterable'
|
|
23
|
-
| 'float16-filterable-webgl';
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {TextureFormat} from './texture-formats';
|
|
6
|
-
import type {TextureFeature} from './texture-features';
|
|
7
|
-
import {decodeTextureFormat} from './decode-texture-format';
|
|
8
|
-
|
|
9
|
-
import {getTextureFormatDefinition} from './texture-format-table';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Texture format capabilities.
|
|
13
|
-
* @note Not directly usable. Can contain TextureFeature strings that need to be checked against a specific device.
|
|
14
|
-
*/
|
|
15
|
-
export type TextureFormatCapabilities = {
|
|
16
|
-
format: TextureFormat;
|
|
17
|
-
/** Can the format be created */
|
|
18
|
-
create: TextureFeature | boolean;
|
|
19
|
-
/** If a feature string, the specified device feature determines if format is renderable. */
|
|
20
|
-
render: TextureFeature | boolean;
|
|
21
|
-
/** If a feature string, the specified device feature determines if format is filterable. */
|
|
22
|
-
filter: TextureFeature | boolean;
|
|
23
|
-
/** If a feature string, the specified device feature determines if format is blendable. */
|
|
24
|
-
blend: TextureFeature | boolean;
|
|
25
|
-
/** If a feature string, the specified device feature determines if format is storeable. */
|
|
26
|
-
store: TextureFeature | boolean;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export function getTextureFormatCapabilities(format: TextureFormat): TextureFormatCapabilities {
|
|
30
|
-
const info = getTextureFormatDefinition(format);
|
|
31
|
-
|
|
32
|
-
const formatCapabilities: Required<TextureFormatCapabilities> = {
|
|
33
|
-
format,
|
|
34
|
-
create: info.f ?? true,
|
|
35
|
-
render: info.render ?? true,
|
|
36
|
-
filter: info.filter ?? true,
|
|
37
|
-
blend: info.blend ?? true,
|
|
38
|
-
store: info.store ?? true
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const formatInfo = decodeTextureFormat(format);
|
|
42
|
-
const isDepthStencil = format.startsWith('depth') || format.startsWith('stencil');
|
|
43
|
-
const isSigned = formatInfo?.signed;
|
|
44
|
-
const isInteger = formatInfo?.integer;
|
|
45
|
-
const isWebGLSpecific = formatInfo?.webgl;
|
|
46
|
-
|
|
47
|
-
// signed formats are not renderable
|
|
48
|
-
formatCapabilities.render &&= !isSigned;
|
|
49
|
-
// signed and integer formats are not filterable
|
|
50
|
-
formatCapabilities.filter &&= !isDepthStencil && !isSigned && !isInteger && !isWebGLSpecific;
|
|
51
|
-
|
|
52
|
-
return formatCapabilities;
|
|
53
|
-
}
|