@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
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import type {
|
|
5
|
+
import {NumberArray} from '../../types';
|
|
6
|
+
import type {
|
|
7
|
+
ColorTextureFormat,
|
|
8
|
+
DepthStencilTextureFormat,
|
|
9
|
+
TextureFormat
|
|
10
|
+
} from '../../gpu-type-utils/texture-formats';
|
|
7
11
|
import type {Texture} from '../resources/texture'; // TextureView...
|
|
12
|
+
import type {TextureView} from '../resources/texture-view'; // TextureView...
|
|
8
13
|
|
|
9
14
|
// UNIFORMS
|
|
10
15
|
|
|
11
16
|
/** Valid values for uniforms. @note boolean values get converted to 0 or 1 before setting */
|
|
12
|
-
export type UniformValue = number | boolean | Readonly<number[]>;
|
|
13
|
-
|
|
14
|
-
// BINDINGS
|
|
15
|
-
|
|
16
|
-
/** Buffer bindings */
|
|
17
|
-
export type Binding = Texture | Buffer | {buffer: Buffer; offset?: number; size?: number};
|
|
17
|
+
export type UniformValue = number | boolean | Readonly<NumberArray>; // Float32Array> | Readonly<Int32Array> | Readonly<Uint32Array> | Readonly<number[]>;
|
|
18
18
|
|
|
19
19
|
// BINDING LAYOUTS
|
|
20
20
|
|
|
@@ -54,14 +54,6 @@ export type BindingDeclaration =
|
|
|
54
54
|
| TextureBindingLayout
|
|
55
55
|
| StorageTextureBindingLayout;
|
|
56
56
|
|
|
57
|
-
// TEXTURE VIEWS
|
|
58
|
-
|
|
59
|
-
export type TextureView = {
|
|
60
|
-
texture: WebGLTexture;
|
|
61
|
-
layer?: number; // = 0
|
|
62
|
-
level?: number; // = 0
|
|
63
|
-
};
|
|
64
|
-
|
|
65
57
|
// ATTACHMENTS (See Framebuffer)
|
|
66
58
|
|
|
67
59
|
/**
|
|
@@ -70,7 +62,7 @@ export type TextureView = {
|
|
|
70
62
|
*/
|
|
71
63
|
export type ColorAttachment = {
|
|
72
64
|
/** Describes the texture subresource that will be output to for this color attachment. */
|
|
73
|
-
texture?: Texture;
|
|
65
|
+
texture?: TextureView | Texture;
|
|
74
66
|
/** Format of the texture resource. Used to auto create texture if not supplied */
|
|
75
67
|
format?: ColorTextureFormat;
|
|
76
68
|
/* Describes the texture subresource that will receive resolved output for this color attachment if multisampled. */
|
|
@@ -90,7 +82,7 @@ export type ColorAttachment = {
|
|
|
90
82
|
*/
|
|
91
83
|
export type DepthStencilAttachment = {
|
|
92
84
|
/** Describes the texture subresource that will be output to and read from for this depth/stencil attachment. */
|
|
93
|
-
texture?: Texture;
|
|
85
|
+
texture?: TextureView | Texture;
|
|
94
86
|
/** Format of the texture resource. Used to auto create texture if not supplied */
|
|
95
87
|
format?: DepthStencilTextureFormat;
|
|
96
88
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {VertexFormat} from '
|
|
5
|
+
import type {VertexFormat} from '../../gpu-type-utils/vertex-formats';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Provides specific details about the memory layout of the actual buffers
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {DepthStencilTextureFormat} from '
|
|
5
|
+
import {DepthStencilTextureFormat} from '../../gpu-type-utils/texture-formats';
|
|
6
6
|
|
|
7
7
|
export type CompareFunction =
|
|
8
8
|
| 'never'
|
|
@@ -20,12 +20,8 @@ export type PrimitiveTopology =
|
|
|
20
20
|
| 'point-list'
|
|
21
21
|
| 'line-list'
|
|
22
22
|
| 'line-strip'
|
|
23
|
-
/** @deprecated */
|
|
24
|
-
| 'line-loop-webgl'
|
|
25
23
|
| 'triangle-list'
|
|
26
|
-
| 'triangle-strip'
|
|
27
|
-
/** @deprecated */
|
|
28
|
-
| 'triangle-fan-webgl';
|
|
24
|
+
| 'triangle-strip';
|
|
29
25
|
|
|
30
26
|
export type IndexFormat = 'uint16' | 'uint32';
|
|
31
27
|
|
|
@@ -146,6 +142,9 @@ export type BlendOperation = 'add' | 'subtract' | 'reverse-subtract' | 'min' | '
|
|
|
146
142
|
|
|
147
143
|
/* Color parameters are set on the RenderPipeline */
|
|
148
144
|
export type ColorParameters = {
|
|
145
|
+
/** Enable blending */
|
|
146
|
+
blend?: boolean;
|
|
147
|
+
|
|
149
148
|
/** Defines the operation used to calculate the values written to the target attachment components. */
|
|
150
149
|
blendColorOperation?: BlendOperation;
|
|
151
150
|
/** Defines the operation to be performed on values from the fragment shader. */
|
|
@@ -233,6 +232,7 @@ export const DEFAULT_PARAMETERS: Required<Parameters> = {
|
|
|
233
232
|
sampleAlphaToCoverageEnabled: false,
|
|
234
233
|
|
|
235
234
|
// Color and blend parameters
|
|
235
|
+
blend: false,
|
|
236
236
|
|
|
237
237
|
blendColorOperation: 'add',
|
|
238
238
|
blendColorSrcFactor: 'one',
|
|
@@ -251,12 +251,12 @@ export const DEFAULT_PARAMETERS: Required<Parameters> = {
|
|
|
251
251
|
polygonMode: 'fill',
|
|
252
252
|
polygonOffsetLine: false,
|
|
253
253
|
|
|
254
|
-
clipDistance0: undefined
|
|
255
|
-
clipDistance1: undefined
|
|
256
|
-
clipDistance2: undefined
|
|
257
|
-
clipDistance3: undefined
|
|
258
|
-
clipDistance4: undefined
|
|
259
|
-
clipDistance5: undefined
|
|
260
|
-
clipDistance6: undefined
|
|
261
|
-
clipDistance7: undefined
|
|
254
|
+
clipDistance0: undefined!,
|
|
255
|
+
clipDistance1: undefined!,
|
|
256
|
+
clipDistance2: undefined!,
|
|
257
|
+
clipDistance3: undefined!,
|
|
258
|
+
clipDistance4: undefined!,
|
|
259
|
+
clipDistance5: undefined!,
|
|
260
|
+
clipDistance6: undefined!,
|
|
261
|
+
clipDistance7: undefined!
|
|
262
262
|
};
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {TextureFormat} from '
|
|
6
|
-
import type {ShaderUniformType, ShaderAttributeType} from '
|
|
7
|
-
import {AccessorObject} from '../types/accessor';
|
|
5
|
+
import type {TextureFormat} from '../../gpu-type-utils/texture-formats';
|
|
6
|
+
import type {ShaderUniformType, ShaderAttributeType} from '../../gpu-type-utils/shader-types';
|
|
8
7
|
import type {Buffer} from '../resources/buffer';
|
|
9
8
|
import type {Sampler} from '../resources/sampler';
|
|
10
9
|
import type {Texture} from '../resources/texture';
|
|
@@ -64,32 +63,6 @@ export type AttributeDeclaration = {
|
|
|
64
63
|
|
|
65
64
|
// BINDING LAYOUTS
|
|
66
65
|
|
|
67
|
-
/*
|
|
68
|
-
type Binding = {
|
|
69
|
-
binding: number;
|
|
70
|
-
visibility: number;
|
|
71
|
-
|
|
72
|
-
buffer?: {
|
|
73
|
-
type?: 'uniform' | 'storage' | 'read-only-storage';
|
|
74
|
-
hasDynamicOffset?: false;
|
|
75
|
-
minBindingSize?: number;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// type = sampler
|
|
79
|
-
samplerType?: 'filtering' | 'non-filtering' | 'comparison';
|
|
80
|
-
|
|
81
|
-
// type = texture
|
|
82
|
-
viewDimension?: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
|
|
83
|
-
sampleType?: 'float' | 'unfilterable-float' | 'depth' | 'sint' | 'uint';
|
|
84
|
-
multisampled?: boolean;
|
|
85
|
-
|
|
86
|
-
// type = storage
|
|
87
|
-
viewDimension?: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
|
|
88
|
-
access: 'read-only' | 'write-only';
|
|
89
|
-
format: string;
|
|
90
|
-
};
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
66
|
/** ShaderLayout for bindings */
|
|
94
67
|
export type BindingDeclaration =
|
|
95
68
|
| UniformBufferBindingLayout
|
|
@@ -205,3 +178,32 @@ export type AttributeBinding = {
|
|
|
205
178
|
location: number;
|
|
206
179
|
accessor: AccessorObject;
|
|
207
180
|
};
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Attribute descriptor object
|
|
184
|
+
* @deprecated Use ShaderLayout
|
|
185
|
+
*/
|
|
186
|
+
export interface AccessorObject {
|
|
187
|
+
buffer?: Buffer;
|
|
188
|
+
// format: VertexFormat;
|
|
189
|
+
offset?: number;
|
|
190
|
+
// can now be described with single WebGPU-style `format` string
|
|
191
|
+
|
|
192
|
+
//
|
|
193
|
+
stride?: number;
|
|
194
|
+
|
|
195
|
+
/** @deprecated - Use accessor.stepMode */
|
|
196
|
+
divisor?: number;
|
|
197
|
+
|
|
198
|
+
/** @deprecated - Infer from format */
|
|
199
|
+
type?: number;
|
|
200
|
+
/** @deprecated - Infer from format */
|
|
201
|
+
size?: number;
|
|
202
|
+
/** @deprecated - Infer from format */
|
|
203
|
+
normalized?: boolean;
|
|
204
|
+
/** @deprecated - Infer from format */
|
|
205
|
+
integer?: boolean;
|
|
206
|
+
|
|
207
|
+
/** @deprecated */
|
|
208
|
+
index?: number;
|
|
209
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {NumberArray} from '../../types';
|
|
6
|
+
|
|
7
|
+
// UNIFORMS
|
|
8
|
+
|
|
9
|
+
/** Valid values for uniforms. @note boolean values get converted to 0 or 1 before setting */
|
|
10
|
+
export type UniformValue = number | boolean | Readonly<NumberArray>; // Float32Array> | Readonly<Int32Array> | Readonly<Uint32Array> | Readonly<number[]>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {CompilerMessage} from '
|
|
5
|
+
import type {CompilerMessage} from '../adapter/types/compiler-message';
|
|
6
6
|
|
|
7
7
|
/** @returns annotated errors or warnings */
|
|
8
8
|
export function formatCompilerLog(
|
|
@@ -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
|
|
@@ -11,19 +11,40 @@ const COMPRESSED_TEXTURE_FORMAT_PREFIXES = [
|
|
|
11
11
|
'bc1', 'bc2', 'bc3', 'bc4', 'bc5', 'bc6', 'bc7', 'etc1', 'etc2', 'eac', 'atc', 'astc', 'pvrtc'
|
|
12
12
|
];
|
|
13
13
|
|
|
14
|
-
const REGEX = /^(rg
|
|
14
|
+
const REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;
|
|
15
15
|
|
|
16
16
|
export type DecodedTextureFormat = {
|
|
17
|
-
|
|
17
|
+
/** String describing which channels this texture has */
|
|
18
|
+
channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra';
|
|
19
|
+
/** Number of components (corresponds to channels string) */
|
|
18
20
|
components: 1 | 2 | 3 | 4;
|
|
21
|
+
/** What is the data type of each component */
|
|
19
22
|
dataType?: VertexType;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
/** If this is a packed data type */
|
|
24
|
+
packed?: boolean;
|
|
25
|
+
/** Number of bytes per pixel */
|
|
26
|
+
bytesPerPixel?: number;
|
|
27
|
+
/** Number of bits per channel (may be unreliable for packed formats) */
|
|
28
|
+
bitsPerChannel: number;
|
|
29
|
+
/** Depth stencil formats */
|
|
30
|
+
a?: 'depth' | 'stencil' | 'depth-stencil';
|
|
31
|
+
/** SRGB texture format? */
|
|
32
|
+
srgb?: boolean;
|
|
33
|
+
/** WebGL specific texture format? */
|
|
34
|
+
webgl?: boolean;
|
|
35
|
+
/** Is this an integer or floating point format? */
|
|
24
36
|
integer: boolean;
|
|
37
|
+
/** Is this a signed or unsigned format? */
|
|
25
38
|
signed: boolean;
|
|
39
|
+
/** Is this a normalized integer format? */
|
|
26
40
|
normalized: boolean;
|
|
41
|
+
/** Is this a compressed texture format */
|
|
42
|
+
compressed?: boolean;
|
|
43
|
+
/** Block size for ASTC formats (texture must be a multiple) */
|
|
44
|
+
blockWidth?: number;
|
|
45
|
+
/** Block size for ASTC formats (texture must be a multiple) */
|
|
46
|
+
blockHeight?: number;
|
|
47
|
+
/** */
|
|
27
48
|
};
|
|
28
49
|
|
|
29
50
|
/**
|
|
@@ -39,19 +60,28 @@ export function isTextureFormatCompressed(textureFormat: TextureFormat): boolean
|
|
|
39
60
|
export function decodeTextureFormat(format: TextureFormat): DecodedTextureFormat {
|
|
40
61
|
const matches = REGEX.exec(format as string);
|
|
41
62
|
if (matches) {
|
|
42
|
-
const [,
|
|
63
|
+
const [, channels, length, type, srgb, suffix] = matches;
|
|
43
64
|
if (format) {
|
|
44
65
|
const dataType = `${type}${length}` as VertexType;
|
|
45
66
|
const decodedType = decodeVertexType(dataType);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
components:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
const info: DecodedTextureFormat = {
|
|
68
|
+
channels: channels as 'r' | 'rg' | 'rgb' | 'rgba',
|
|
69
|
+
components: channels.length as 1 | 2 | 3 | 4,
|
|
70
|
+
bitsPerChannel: decodedType.byteLength * 8,
|
|
71
|
+
bytesPerPixel: decodedType.byteLength * channels.length,
|
|
72
|
+
dataType: decodedType.dataType,
|
|
73
|
+
integer: decodedType.integer,
|
|
74
|
+
signed: decodedType.signed,
|
|
75
|
+
normalized: decodedType.normalized
|
|
54
76
|
};
|
|
77
|
+
if (suffix === '-webgl') {
|
|
78
|
+
info.webgl = true;
|
|
79
|
+
}
|
|
80
|
+
// dataType - overwritten by decodedType
|
|
81
|
+
if (srgb === '-srgb') {
|
|
82
|
+
info.srgb = true;
|
|
83
|
+
}
|
|
84
|
+
return info;
|
|
55
85
|
}
|
|
56
86
|
}
|
|
57
87
|
|
|
@@ -60,40 +90,70 @@ export function decodeTextureFormat(format: TextureFormat): DecodedTextureFormat
|
|
|
60
90
|
|
|
61
91
|
// https://www.w3.org/TR/webgpu/#texture-format-caps
|
|
62
92
|
|
|
63
|
-
const EXCEPTIONS: Partial<Record<TextureFormat,
|
|
93
|
+
const EXCEPTIONS: Partial<Record<TextureFormat, Partial<DecodedTextureFormat>>> = {
|
|
64
94
|
// Packed 16 bit formats
|
|
65
|
-
'rgba4unorm-webgl': {
|
|
66
|
-
'rgb565unorm-webgl': {
|
|
67
|
-
'rgb5a1unorm-webgl': {
|
|
95
|
+
'rgba4unorm-webgl': {channels: 'rgba', bytesPerPixel: 2, packed: true},
|
|
96
|
+
'rgb565unorm-webgl': {channels: 'rgb', bytesPerPixel: 2, packed: true},
|
|
97
|
+
'rgb5a1unorm-webgl': {channels: 'rgba', bytesPerPixel: 2, packed: true},
|
|
68
98
|
// Packed 32 bit formats
|
|
69
|
-
rgb9e5ufloat: {
|
|
70
|
-
rg11b10ufloat: {
|
|
71
|
-
rgb10a2unorm: {
|
|
72
|
-
'rgb10a2uint-webgl': {
|
|
99
|
+
rgb9e5ufloat: {channels: 'rgb', bytesPerPixel: 4, packed: true},
|
|
100
|
+
rg11b10ufloat: {channels: 'rgb', bytesPerPixel: 4, packed: true},
|
|
101
|
+
rgb10a2unorm: {channels: 'rgba', bytesPerPixel: 4, packed: true},
|
|
102
|
+
'rgb10a2uint-webgl': {channels: 'rgba', bytesPerPixel: 4, packed: true},
|
|
73
103
|
// Depth/stencil
|
|
74
|
-
stencil8: {components: 1,
|
|
75
|
-
depth16unorm: {components: 1,
|
|
76
|
-
depth24plus: {components: 1,
|
|
77
|
-
depth32float: {components: 1,
|
|
78
|
-
'depth24plus-stencil8': {components: 2,
|
|
79
|
-
// "depth24unorm-stencil8" feature
|
|
80
|
-
'depth24unorm-stencil8': {components: 2, bpp: 4, a: 'depth-stencil'},
|
|
104
|
+
stencil8: {components: 1, bytesPerPixel: 1, a: 'stencil', dataType: 'uint8'},
|
|
105
|
+
depth16unorm: {components: 1, bytesPerPixel: 2, a: 'depth', dataType: 'uint16'},
|
|
106
|
+
depth24plus: {components: 1, bytesPerPixel: 3, a: 'depth', dataType: 'uint32'},
|
|
107
|
+
depth32float: {components: 1, bytesPerPixel: 4, a: 'depth', dataType: 'float32'},
|
|
108
|
+
'depth24plus-stencil8': {components: 2, bytesPerPixel: 4, a: 'depth-stencil', packed: true},
|
|
81
109
|
// "depth32float-stencil8" feature
|
|
82
|
-
'depth32float-stencil8': {components: 2,
|
|
110
|
+
'depth32float-stencil8': {components: 2, bytesPerPixel: 4, a: 'depth-stencil', packed: true}
|
|
83
111
|
};
|
|
84
112
|
|
|
85
113
|
function decodeNonStandardFormat(format: TextureFormat): DecodedTextureFormat {
|
|
114
|
+
if (isTextureFormatCompressed(format)) {
|
|
115
|
+
const info: DecodedTextureFormat = {
|
|
116
|
+
channels: 'rgb',
|
|
117
|
+
components: 3,
|
|
118
|
+
bytesPerPixel: 1,
|
|
119
|
+
srgb: false,
|
|
120
|
+
compressed: true
|
|
121
|
+
} as DecodedTextureFormat;
|
|
122
|
+
const blockSize = getCompressedTextureBlockSize(format);
|
|
123
|
+
if (blockSize) {
|
|
124
|
+
info.blockWidth = blockSize.blockWidth;
|
|
125
|
+
info.blockHeight = blockSize.blockHeight;
|
|
126
|
+
}
|
|
127
|
+
return info;
|
|
128
|
+
}
|
|
86
129
|
const data = EXCEPTIONS[format];
|
|
87
130
|
if (!data) {
|
|
88
131
|
throw new Error(`Unknown format ${format}`);
|
|
89
132
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
133
|
+
const info: DecodedTextureFormat = {
|
|
134
|
+
...data,
|
|
135
|
+
channels: data.channels || '',
|
|
136
|
+
components: data.components || data.channels?.length || 1,
|
|
137
|
+
bytesPerPixel: data.bytesPerPixel || 1,
|
|
138
|
+
srgb: false
|
|
96
139
|
} as DecodedTextureFormat;
|
|
140
|
+
if (data.packed) {
|
|
141
|
+
info.packed = data.packed;
|
|
142
|
+
}
|
|
143
|
+
return info;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Parses ASTC block widths from format string */
|
|
147
|
+
function getCompressedTextureBlockSize(
|
|
148
|
+
format: string
|
|
149
|
+
): {blockWidth: number; blockHeight: number} | null {
|
|
150
|
+
const REGEX = /.*-(\d+)x(\d+)-.*/;
|
|
151
|
+
const matches = REGEX.exec(format);
|
|
152
|
+
if (matches) {
|
|
153
|
+
const [, blockWidth, blockHeight] = matches;
|
|
154
|
+
return {blockWidth: Number(blockWidth), blockHeight: Number(blockHeight)};
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
97
157
|
}
|
|
98
158
|
|
|
99
159
|
/*
|
|
@@ -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 = {
|
|
@@ -12,16 +12,11 @@ export type DepthStencilTextureFormat =
|
|
|
12
12
|
| 'depth24plus'
|
|
13
13
|
| 'depth24plus-stencil8'
|
|
14
14
|
| 'depth32float'
|
|
15
|
-
// device.features.has('depth24unorm-stencil8')
|
|
16
|
-
| 'depth24unorm-stencil8'
|
|
17
15
|
// device.features.has('depth32float-stencil8')
|
|
18
16
|
| 'depth32float-stencil8';
|
|
19
17
|
|
|
20
18
|
/** Texture formats for color attachments */
|
|
21
|
-
export type ColorTextureFormat =
|
|
22
|
-
| WebGPUColorTextureFormat
|
|
23
|
-
| WebGL2ColorTextureFormat
|
|
24
|
-
| UnsizedColorTextureFormat;
|
|
19
|
+
export type ColorTextureFormat = WebGPUColorTextureFormat | WebGL2ColorTextureFormat;
|
|
25
20
|
|
|
26
21
|
export type WebGPUColorTextureFormat =
|
|
27
22
|
// 8-bit formats
|
|
@@ -103,6 +98,7 @@ export type WebGPUColorTextureFormat =
|
|
|
103
98
|
|
|
104
99
|
// ASTC compressed formats usable if "texture-compression-astc" is both
|
|
105
100
|
// supported by the device/user agent and enabled in requestDevice.
|
|
101
|
+
// Textures must be multiple of block size (encoded in format string).
|
|
106
102
|
| 'astc-4x4-unorm'
|
|
107
103
|
| 'astc-4x4-unorm-srgb'
|
|
108
104
|
| 'astc-5x4-unorm'
|
|
@@ -132,14 +128,7 @@ export type WebGPUColorTextureFormat =
|
|
|
132
128
|
| 'astc-12x12-unorm'
|
|
133
129
|
| 'astc-12x12-unorm-srgb';
|
|
134
130
|
|
|
135
|
-
/**
|
|
136
|
-
export type UnsizedColorTextureFormat = 'rgb8unorm-unsized' | 'rgba8unorm-unsized';
|
|
137
|
-
// 'r8unorm-unsized' |
|
|
138
|
-
// 'ra8unorm-unsized' |
|
|
139
|
-
// 'rgb8unorm-srgb-unsized' |
|
|
140
|
-
// 'rgba8unorm-srgb-unsized'
|
|
141
|
-
|
|
142
|
-
/** Sized formats unique to WebGL 2. Some will perhaps be added to WebGPU standard? */
|
|
131
|
+
/** Sized formats in WebGL 2 that are not (yet?) supported by WebGPU */
|
|
143
132
|
export type WebGL2ColorTextureFormat =
|
|
144
133
|
| 'r16unorm-webgl'
|
|
145
134
|
| '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> = {
|