@luma.gl/core 9.2.5 → 9.3.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/canvas-context.d.ts +6 -162
- package/dist/adapter/canvas-context.d.ts.map +1 -1
- package/dist/adapter/canvas-context.js +5 -419
- package/dist/adapter/canvas-context.js.map +1 -1
- package/dist/adapter/canvas-observer.d.ts +32 -0
- package/dist/adapter/canvas-observer.d.ts.map +1 -0
- package/dist/adapter/canvas-observer.js +90 -0
- package/dist/adapter/canvas-observer.js.map +1 -0
- package/dist/adapter/canvas-surface.d.ts +150 -0
- package/dist/adapter/canvas-surface.d.ts.map +1 -0
- package/dist/adapter/canvas-surface.js +392 -0
- package/dist/adapter/canvas-surface.js.map +1 -0
- package/dist/adapter/device.d.ts +81 -16
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +196 -10
- package/dist/adapter/device.js.map +1 -1
- package/dist/adapter/luma.js +1 -1
- package/dist/adapter/luma.js.map +1 -1
- package/dist/adapter/presentation-context.d.ts +11 -0
- package/dist/adapter/presentation-context.d.ts.map +1 -0
- package/dist/adapter/presentation-context.js +12 -0
- package/dist/adapter/presentation-context.js.map +1 -0
- package/dist/adapter/resources/buffer.d.ts +5 -5
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js +18 -7
- package/dist/adapter/resources/buffer.js.map +1 -1
- package/dist/adapter/resources/command-buffer.d.ts +3 -1
- package/dist/adapter/resources/command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/command-buffer.js +3 -1
- package/dist/adapter/resources/command-buffer.js.map +1 -1
- package/dist/adapter/resources/command-encoder.d.ts +30 -7
- package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/command-encoder.js +68 -2
- package/dist/adapter/resources/command-encoder.js.map +1 -1
- package/dist/adapter/resources/compute-pipeline.d.ts +2 -2
- package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/fence.d.ts +16 -0
- package/dist/adapter/resources/fence.d.ts.map +1 -0
- package/dist/adapter/resources/fence.js +17 -0
- package/dist/adapter/resources/fence.js.map +1 -0
- package/dist/adapter/resources/framebuffer.d.ts +1 -1
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/framebuffer.js +15 -12
- package/dist/adapter/resources/framebuffer.js.map +1 -1
- package/dist/adapter/resources/query-set.d.ts +17 -1
- package/dist/adapter/resources/query-set.d.ts.map +1 -1
- package/dist/adapter/resources/query-set.js.map +1 -1
- package/dist/adapter/resources/render-pipeline.d.ts +28 -10
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.js +21 -2
- package/dist/adapter/resources/render-pipeline.js.map +1 -1
- package/dist/adapter/resources/resource.d.ts +13 -0
- package/dist/adapter/resources/resource.d.ts.map +1 -1
- package/dist/adapter/resources/resource.js +243 -14
- package/dist/adapter/resources/resource.js.map +1 -1
- package/dist/adapter/resources/shader.js +27 -25
- package/dist/adapter/resources/shader.js.map +1 -1
- package/dist/adapter/resources/shared-render-pipeline.d.ts +22 -0
- package/dist/adapter/resources/shared-render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/shared-render-pipeline.js +25 -0
- package/dist/adapter/resources/shared-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/texture-view.d.ts +1 -1
- package/dist/adapter/resources/texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/texture.d.ts +168 -28
- package/dist/adapter/resources/texture.d.ts.map +1 -1
- package/dist/adapter/resources/texture.js +284 -25
- package/dist/adapter/resources/texture.js.map +1 -1
- package/dist/adapter/types/attachments.d.ts +1 -1
- package/dist/adapter/types/attachments.d.ts.map +1 -1
- package/dist/adapter/types/buffer-layout.d.ts +1 -1
- package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
- package/dist/adapter/types/parameters.d.ts +3 -1
- package/dist/adapter/types/parameters.d.ts.map +1 -1
- package/dist/adapter/types/parameters.js +1 -0
- package/dist/adapter/types/parameters.js.map +1 -1
- package/dist/adapter/types/shader-layout.d.ts +10 -6
- package/dist/adapter/types/shader-layout.d.ts.map +1 -1
- package/dist/adapter/types/uniforms.d.ts +6 -0
- package/dist/adapter/types/uniforms.d.ts.map +1 -1
- package/dist/adapter-utils/bind-groups.d.ts +9 -0
- package/dist/adapter-utils/bind-groups.d.ts.map +1 -0
- package/dist/adapter-utils/bind-groups.js +41 -0
- package/dist/adapter-utils/bind-groups.js.map +1 -0
- package/dist/adapter-utils/format-compiler-log.d.ts.map +1 -1
- package/dist/adapter-utils/format-compiler-log.js +23 -15
- package/dist/adapter-utils/format-compiler-log.js.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts +2 -2
- package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -1
- package/dist/adapter-utils/get-attribute-from-layouts.js +6 -6
- package/dist/adapter-utils/get-attribute-from-layouts.js.map +1 -1
- package/dist/dist.dev.js +2692 -645
- package/dist/dist.min.js +10 -9
- package/dist/factories/bind-group-factory.d.ts +20 -0
- package/dist/factories/bind-group-factory.d.ts.map +1 -0
- package/dist/factories/bind-group-factory.js +79 -0
- package/dist/factories/bind-group-factory.js.map +1 -0
- package/dist/factories/core-module-state.d.ts +7 -0
- package/dist/factories/core-module-state.d.ts.map +1 -0
- package/dist/{shadertypes/data-types/shader-types.js → factories/core-module-state.js} +1 -1
- package/dist/factories/core-module-state.js.map +1 -0
- package/dist/factories/pipeline-factory.d.ts +54 -0
- package/dist/factories/pipeline-factory.d.ts.map +1 -0
- package/dist/factories/pipeline-factory.js +270 -0
- package/dist/factories/pipeline-factory.js.map +1 -0
- package/dist/factories/shader-factory.d.ts +20 -0
- package/dist/factories/shader-factory.d.ts.map +1 -0
- package/dist/factories/shader-factory.js +84 -0
- package/dist/factories/shader-factory.js.map +1 -0
- package/dist/index.cjs +2427 -554
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +30 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/portable/shader-block-writer.d.ts +51 -0
- package/dist/portable/shader-block-writer.d.ts.map +1 -0
- package/dist/portable/shader-block-writer.js +185 -0
- package/dist/portable/shader-block-writer.js.map +1 -0
- package/dist/portable/uniform-block.d.ts +1 -1
- package/dist/portable/uniform-block.d.ts.map +1 -1
- package/dist/portable/uniform-store.d.ts +55 -24
- package/dist/portable/uniform-store.d.ts.map +1 -1
- package/dist/portable/uniform-store.js +73 -25
- package/dist/portable/uniform-store.js.map +1 -1
- package/dist/shadertypes/data-types/data-type-decoder.d.ts +20 -0
- package/dist/shadertypes/data-types/data-type-decoder.d.ts.map +1 -0
- package/dist/shadertypes/data-types/data-type-decoder.js +79 -0
- package/dist/shadertypes/data-types/data-type-decoder.js.map +1 -0
- package/dist/shadertypes/data-types/data-types.d.ts +31 -12
- package/dist/shadertypes/data-types/data-types.d.ts.map +1 -1
- package/dist/shadertypes/data-types/decode-data-types.d.ts.map +1 -1
- package/dist/shadertypes/data-types/decode-data-types.js +2 -1
- package/dist/shadertypes/data-types/decode-data-types.js.map +1 -1
- package/dist/{image-utils → shadertypes/image-types}/image-types.d.ts +0 -6
- package/dist/shadertypes/image-types/image-types.d.ts.map +1 -0
- package/dist/shadertypes/image-types/image-types.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-block-layout.d.ts +72 -0
- package/dist/shadertypes/shader-types/shader-block-layout.d.ts.map +1 -0
- package/dist/shadertypes/shader-types/shader-block-layout.js +209 -0
- package/dist/shadertypes/shader-types/shader-block-layout.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-type-decoder.d.ts +41 -0
- package/dist/shadertypes/shader-types/shader-type-decoder.d.ts.map +1 -0
- package/dist/shadertypes/{data-types/decode-shader-types.js → shader-types/shader-type-decoder.js} +43 -4
- package/dist/shadertypes/shader-types/shader-type-decoder.js.map +1 -0
- package/dist/shadertypes/shader-types/shader-types.d.ts +101 -0
- package/dist/shadertypes/shader-types/shader-types.d.ts.map +1 -0
- package/dist/shadertypes/shader-types/shader-types.js +30 -0
- package/dist/shadertypes/shader-types/shader-types.js.map +1 -0
- package/dist/shadertypes/texture-types/pixel-utils.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/pixel-utils.js +4 -4
- package/dist/shadertypes/texture-types/pixel-utils.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-decoder.d.ts +36 -0
- package/dist/shadertypes/texture-types/texture-format-decoder.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-format-decoder.js +109 -37
- package/dist/shadertypes/texture-types/texture-format-decoder.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-generics.d.ts +34 -0
- package/dist/shadertypes/texture-types/texture-format-generics.d.ts.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-generics.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-format-table.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-format-table.js +10 -9
- package/dist/shadertypes/texture-types/texture-format-table.js.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-formats.d.ts +51 -17
- package/dist/shadertypes/texture-types/texture-formats.d.ts.map +1 -0
- package/dist/shadertypes/{textures → texture-types}/texture-formats.js +1 -0
- package/dist/shadertypes/texture-types/texture-formats.js.map +1 -0
- package/dist/shadertypes/texture-types/texture-layout.d.ts +5 -0
- package/dist/shadertypes/texture-types/texture-layout.d.ts.map +1 -0
- package/dist/shadertypes/texture-types/texture-layout.js +41 -0
- package/dist/shadertypes/texture-types/texture-layout.js.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts +24 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.js +106 -0
- package/dist/shadertypes/vertex-types/vertex-format-decoder.js.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-formats.d.ts +50 -0
- package/dist/shadertypes/vertex-types/vertex-formats.d.ts.map +1 -0
- package/dist/shadertypes/vertex-types/vertex-formats.js.map +1 -0
- package/dist/utils/array-equal.d.ts +1 -1
- package/dist/utils/array-equal.d.ts.map +1 -1
- package/dist/utils/array-equal.js +15 -9
- package/dist/utils/array-equal.js.map +1 -1
- package/dist/utils/assert.d.ts +5 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/assert.js +17 -0
- package/dist/utils/assert.js.map +1 -0
- package/dist/utils/stats-manager.d.ts.map +1 -1
- package/dist/utils/stats-manager.js +61 -1
- package/dist/utils/stats-manager.js.map +1 -1
- package/package.json +6 -6
- package/src/adapter/canvas-context.ts +7 -556
- package/src/adapter/canvas-observer.ts +130 -0
- package/src/adapter/canvas-surface.ts +521 -0
- package/src/adapter/device.ts +312 -24
- package/src/adapter/presentation-context.ts +16 -0
- package/src/adapter/resources/buffer.ts +19 -9
- package/src/adapter/resources/command-buffer.ts +4 -2
- package/src/adapter/resources/command-encoder.ts +101 -10
- package/src/adapter/resources/compute-pipeline.ts +2 -2
- package/src/adapter/resources/fence.ts +32 -0
- package/src/adapter/resources/framebuffer.ts +16 -13
- package/src/adapter/resources/query-set.ts +17 -1
- package/src/adapter/resources/render-pipeline.ts +52 -16
- package/src/adapter/resources/resource.ts +289 -14
- package/src/adapter/resources/shader.ts +28 -28
- package/src/adapter/resources/shared-render-pipeline.ts +40 -0
- package/src/adapter/resources/texture-view.ts +1 -1
- package/src/adapter/resources/texture.ts +427 -49
- package/src/adapter/types/attachments.ts +1 -1
- package/src/adapter/types/buffer-layout.ts +1 -1
- package/src/adapter/types/parameters.ts +4 -1
- package/src/adapter/types/shader-layout.ts +15 -9
- package/src/adapter/types/uniforms.ts +12 -0
- package/src/adapter-utils/bind-groups.ts +71 -0
- package/src/adapter-utils/format-compiler-log.ts +23 -15
- package/src/adapter-utils/get-attribute-from-layouts.ts +8 -11
- package/src/factories/bind-group-factory.ts +139 -0
- package/src/factories/core-module-state.ts +11 -0
- package/src/factories/pipeline-factory.ts +328 -0
- package/src/factories/shader-factory.ts +103 -0
- package/src/index.ts +70 -26
- package/src/portable/shader-block-writer.ts +254 -0
- package/src/portable/uniform-block.ts +1 -1
- package/src/portable/uniform-store.ts +98 -40
- package/src/shadertypes/data-types/data-type-decoder.ts +105 -0
- package/src/shadertypes/data-types/data-types.ts +100 -48
- package/src/shadertypes/data-types/decode-data-types.ts +2 -1
- package/src/{image-utils → shadertypes/image-types}/image-types.ts +0 -7
- package/src/shadertypes/shader-types/shader-block-layout.ts +340 -0
- package/src/shadertypes/{data-types/decode-shader-types.ts → shader-types/shader-type-decoder.ts} +88 -14
- package/src/shadertypes/shader-types/shader-types.ts +207 -0
- package/src/shadertypes/{textures → texture-types}/pixel-utils.ts +4 -4
- package/src/shadertypes/{textures → texture-types}/texture-format-decoder.ts +166 -45
- package/src/shadertypes/{textures → texture-types}/texture-format-generics.ts +42 -48
- package/src/shadertypes/{textures → texture-types}/texture-format-table.ts +10 -9
- package/src/shadertypes/{textures → texture-types}/texture-formats.ts +73 -17
- package/src/shadertypes/texture-types/texture-layout.ts +60 -0
- package/src/shadertypes/vertex-types/vertex-format-decoder.ts +131 -0
- package/src/shadertypes/vertex-types/vertex-formats.ts +183 -0
- package/src/utils/array-equal.ts +21 -9
- package/src/utils/assert.ts +18 -0
- package/src/utils/stats-manager.ts +76 -2
- package/dist/image-utils/image-types.d.ts.map +0 -1
- package/dist/image-utils/image-types.js.map +0 -1
- package/dist/portable/uniform-buffer-layout.d.ts +0 -28
- package/dist/portable/uniform-buffer-layout.d.ts.map +0 -1
- package/dist/portable/uniform-buffer-layout.js +0 -96
- package/dist/portable/uniform-buffer-layout.js.map +0 -1
- package/dist/shadertypes/data-types/decode-shader-types.d.ts +0 -17
- package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +0 -1
- package/dist/shadertypes/data-types/decode-shader-types.js.map +0 -1
- package/dist/shadertypes/data-types/shader-types.d.ts +0 -45
- package/dist/shadertypes/data-types/shader-types.d.ts.map +0 -1
- package/dist/shadertypes/data-types/shader-types.js.map +0 -1
- package/dist/shadertypes/textures/pixel-utils.d.ts.map +0 -1
- package/dist/shadertypes/textures/pixel-utils.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-decoder.d.ts +0 -18
- package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-decoder.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-generics.d.ts +0 -33
- package/dist/shadertypes/textures/texture-format-generics.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-generics.js.map +0 -1
- package/dist/shadertypes/textures/texture-format-table.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-format-table.js.map +0 -1
- package/dist/shadertypes/textures/texture-formats.d.ts.map +0 -1
- package/dist/shadertypes/textures/texture-formats.js.map +0 -1
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts +0 -18
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts.map +0 -1
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js +0 -100
- package/dist/shadertypes/vertex-arrays/decode-vertex-format.js.map +0 -1
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts +0 -27
- package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts.map +0 -1
- package/dist/shadertypes/vertex-arrays/vertex-formats.js.map +0 -1
- package/src/portable/uniform-buffer-layout.ts +0 -118
- package/src/shadertypes/data-types/shader-types.ts +0 -87
- package/src/shadertypes/vertex-arrays/decode-vertex-format.ts +0 -124
- package/src/shadertypes/vertex-arrays/vertex-formats.ts +0 -91
- /package/dist/{image-utils → shadertypes/image-types}/image-types.js +0 -0
- /package/dist/shadertypes/{textures → texture-types}/pixel-utils.d.ts +0 -0
- /package/dist/shadertypes/{textures → texture-types}/texture-format-generics.js +0 -0
- /package/dist/shadertypes/{textures → texture-types}/texture-format-table.d.ts +0 -0
- /package/dist/shadertypes/{vertex-arrays → vertex-types}/vertex-formats.js +0 -0
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { NormalizedDataType } from "../data-types/data-types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Describes the **memory format** and interpretation (normalization) of a buffer that will be supplied to vertex attributes
|
|
4
|
-
* @note Must be compatible with the AttributeShaderType of the shaders, see documentation.
|
|
5
|
-
* @note This is a superset of WebGPU vertex formats to allow for some flexibility for WebGL only applications
|
|
6
|
-
* @todo Add device.isTextureFormatSupported() method?
|
|
7
|
-
*/
|
|
8
|
-
export type VertexFormat = 'uint8' | 'uint8x2' | 'uint8x4' | 'sint8' | 'sint8x2' | 'sint8x4' | 'unorm8' | 'unorm8x2' | 'unorm8x3-webgl' | 'unorm8x4' | 'unorm8x4-bgra' | 'unorm10-10-10-2' | 'snorm8' | 'snorm8x2' | 'snorm8x3-webgl' | 'snorm8x4' | 'uint16' | 'sint16' | 'unorm16' | 'snorm16' | 'uint16x2' | 'uint16x4' | 'sint16x2' | 'sint16x4' | 'unorm16x2' | 'unorm16x4' | 'snorm16x2' | 'snorm16x4' | 'uint32' | 'uint32x2' | 'uint32x3' | 'uint32x4' | 'sint32' | 'sint32x2' | 'sint32x3' | 'sint32x4' | 'float16' | 'float16x2' | 'float16x4' | 'float32' | 'float32x2' | 'float32x3' | 'float32x4';
|
|
9
|
-
export type VertexFormatInfo = {
|
|
10
|
-
/** Type of each component */
|
|
11
|
-
type: NormalizedDataType;
|
|
12
|
-
/** Length in bytes */
|
|
13
|
-
byteLength: number;
|
|
14
|
-
/** Number of components per vertex / row */
|
|
15
|
-
components: 1 | 2 | 3 | 4;
|
|
16
|
-
/** Is this an integer format (normalized integer formats are not integer) */
|
|
17
|
-
integer: boolean;
|
|
18
|
-
/** Is this a signed format? */
|
|
19
|
-
signed: boolean;
|
|
20
|
-
/** Is this a normalized format? */
|
|
21
|
-
normalized: boolean;
|
|
22
|
-
/** Is this a bgra format? */
|
|
23
|
-
bgra?: boolean;
|
|
24
|
-
/** Is this a webgl only format? */
|
|
25
|
-
webglOnly?: boolean;
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=vertex-formats.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vertex-formats.d.ts","sourceRoot":"","sources":["../../../src/shadertypes/vertex-arrays/vertex-formats.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,kBAAkB,EAAC,oCAAiC;AAI5D;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAEpB,OAAO,GACP,SAAS,GACT,SAAS,GACT,OAAO,GACP,SAAS,GACT,SAAS,GACT,QAAQ,GACR,UAAU,GACV,gBAAgB,GAChB,UAAU,GACV,eAAe,GACf,iBAAiB,GAEjB,QAAQ,GACR,UAAU,GACV,gBAAgB,GAChB,UAAU,GAEV,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,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,SAAS,GACT,WAAW,GACX,WAAW,GACX,SAAS,GACT,WAAW,GACX,WAAW,GACX,WAAW,CAAC;AAEhB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,6BAA6B;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAC;IACjB,+BAA+B;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,mCAAmC;IACnC,UAAU,EAAE,OAAO,CAAC;IACpB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,mCAAmC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vertex-formats.js","sourceRoot":"","sources":["../../../src/shadertypes/vertex-arrays/vertex-formats.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC"}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {PrimitiveDataType} from '../shadertypes/data-types/data-types';
|
|
6
|
-
import type {VariableShaderType} from '../shadertypes/data-types/shader-types';
|
|
7
|
-
import {alignTo} from '../shadertypes/data-types/decode-data-types';
|
|
8
|
-
import {getVariableShaderTypeInfo} from '../shadertypes/data-types/decode-shader-types';
|
|
9
|
-
|
|
10
|
-
import type {UniformValue} from '../adapter/types/uniforms';
|
|
11
|
-
import {getScratchArrayBuffer} from '../utils/array-utils-flat';
|
|
12
|
-
import {isNumberArray} from '../utils/is-array';
|
|
13
|
-
import {log} from '../utils/log';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Smallest buffer size that can be used for uniform buffers.
|
|
17
|
-
* TODO - does this depend on device?
|
|
18
|
-
*/
|
|
19
|
-
const minBufferSize: number = 1024;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Std140 layout for uniform buffers
|
|
23
|
-
* Supports manual listing of uniforms
|
|
24
|
-
*/
|
|
25
|
-
export class UniformBufferLayout {
|
|
26
|
-
readonly layout: Record<string, {offset: number; size: number; type: PrimitiveDataType}> = {};
|
|
27
|
-
|
|
28
|
-
/** number of bytes needed for buffer allocation */
|
|
29
|
-
readonly byteLength: number;
|
|
30
|
-
|
|
31
|
-
/** Create a new UniformBufferLayout given a map of attributes. */
|
|
32
|
-
constructor(
|
|
33
|
-
uniformTypes: Record<string, VariableShaderType>,
|
|
34
|
-
uniformSizes: Record<string, number> = {}
|
|
35
|
-
) {
|
|
36
|
-
/** number of 4 byte slots taken */
|
|
37
|
-
let size: number = 0;
|
|
38
|
-
|
|
39
|
-
// Add layout (type, size and offset) definitions for each uniform in the layout
|
|
40
|
-
for (const [key, uniformType] of Object.entries(uniformTypes)) {
|
|
41
|
-
const typeAndComponents = getVariableShaderTypeInfo(uniformType);
|
|
42
|
-
const {type, components} = typeAndComponents;
|
|
43
|
-
// Calculate total count for uniform arrays.
|
|
44
|
-
const count = components * (uniformSizes?.[key] ?? 1);
|
|
45
|
-
// First, align (bump) current offset to an even multiple of current object (1, 2, 4)
|
|
46
|
-
size = alignTo(size, count);
|
|
47
|
-
// Use the aligned size as the offset of the current uniform.
|
|
48
|
-
const offset = size;
|
|
49
|
-
// Then, add our object's padded size ((1, 2, multiple of 4) to the current offset
|
|
50
|
-
size += count;
|
|
51
|
-
this.layout[key] = {type, size: count, offset};
|
|
52
|
-
}
|
|
53
|
-
size += (4 - (size % 4)) % 4;
|
|
54
|
-
|
|
55
|
-
const actualByteLength = size * 4;
|
|
56
|
-
this.byteLength = Math.max(actualByteLength, minBufferSize);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** Get the data for the complete buffer */
|
|
60
|
-
getData(uniformValues: Record<string, UniformValue>): Uint8Array {
|
|
61
|
-
// Allocate three typed arrays pointing at same memory
|
|
62
|
-
const arrayBuffer = getScratchArrayBuffer(this.byteLength);
|
|
63
|
-
const typedArrays = {
|
|
64
|
-
i32: new Int32Array(arrayBuffer),
|
|
65
|
-
u32: new Uint32Array(arrayBuffer),
|
|
66
|
-
f32: new Float32Array(arrayBuffer),
|
|
67
|
-
// TODO not implemented
|
|
68
|
-
f16: new Uint16Array(arrayBuffer)
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
for (const [name, value] of Object.entries(uniformValues)) {
|
|
72
|
-
const uniformLayout = this.layout[name];
|
|
73
|
-
if (!uniformLayout) {
|
|
74
|
-
log.warn(`Supplied uniform value ${name} not present in uniform block layout`)();
|
|
75
|
-
// eslint-disable-next-line no-continue
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const {type, size, offset} = uniformLayout;
|
|
80
|
-
const typedArray = typedArrays[type];
|
|
81
|
-
if (size === 1) {
|
|
82
|
-
if (typeof value !== 'number' && typeof value !== 'boolean') {
|
|
83
|
-
log.warn(
|
|
84
|
-
`Supplied value for single component uniform ${name} is not a number: ${value}`
|
|
85
|
-
)();
|
|
86
|
-
// eslint-disable-next-line no-continue
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
// single value -> just set it
|
|
90
|
-
typedArray[offset] = Number(value);
|
|
91
|
-
} else {
|
|
92
|
-
if (!isNumberArray(value)) {
|
|
93
|
-
log.warn(
|
|
94
|
-
`Supplied value for multi component / array uniform ${name} is not a numeric array: ${value}`
|
|
95
|
-
)();
|
|
96
|
-
// eslint-disable-next-line no-continue
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
// vector/matrix -> copy the supplied (typed) array, starting from offset
|
|
100
|
-
// TODO: we should limit or check size in case the supplied data overflows
|
|
101
|
-
typedArray.set(value, offset);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return new Uint8Array(arrayBuffer, 0, this.byteLength);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** Does this layout have a field with specified name */
|
|
109
|
-
has(name: string) {
|
|
110
|
-
return Boolean(this.layout[name]);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** Get offset and size for a field with specified name */
|
|
114
|
-
get(name: string): {offset: number; size: number} | undefined {
|
|
115
|
-
const layout = this.layout[name];
|
|
116
|
-
return layout;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {PrimitiveDataType} from './data-types';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Describes the type of an attribute as defined in the shader source code.
|
|
9
|
-
* @note This is a subset of shader variable types
|
|
10
|
-
* @note Buffers with various `VertexFormat`s can be supplied for each type, GPU will convert them at runtime/
|
|
11
|
-
*/
|
|
12
|
-
export type AttributeShaderType =
|
|
13
|
-
| PrimitiveDataType
|
|
14
|
-
| `vec2<${PrimitiveDataType}>`
|
|
15
|
-
| `vec3<${PrimitiveDataType}>`
|
|
16
|
-
| `vec4<${PrimitiveDataType}>`;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Describes the type of a variable that can declared in shader source code.
|
|
20
|
-
* @note Uniforms can be declared using these types
|
|
21
|
-
* @note Uniforms can be of a wider range of types than attributes.
|
|
22
|
-
* @note to WebGL users: "bindings" (textures, samplers, and uniform buffers) are considered "bindings", not shader variables/uniforms
|
|
23
|
-
*/
|
|
24
|
-
export type VariableShaderType =
|
|
25
|
-
| PrimitiveDataType
|
|
26
|
-
| `vec2<${PrimitiveDataType}>`
|
|
27
|
-
| `vec3<${PrimitiveDataType}>`
|
|
28
|
-
| `vec4<${PrimitiveDataType}>`
|
|
29
|
-
| `mat2x2<${PrimitiveDataType}>`
|
|
30
|
-
| `mat2x3<${PrimitiveDataType}>`
|
|
31
|
-
| `mat2x4<${PrimitiveDataType}>`
|
|
32
|
-
| `mat3x2<${PrimitiveDataType}>`
|
|
33
|
-
| `mat3x3<${PrimitiveDataType}>`
|
|
34
|
-
| `mat3x4<${PrimitiveDataType}>`
|
|
35
|
-
| `mat4x2<${PrimitiveDataType}>`
|
|
36
|
-
| `mat4x3<${PrimitiveDataType}>`
|
|
37
|
-
| `mat4x4<${PrimitiveDataType}>`;
|
|
38
|
-
|
|
39
|
-
/* Suffixes used by WGSL alias types */
|
|
40
|
-
type ShaderTypeAliasSuffix = 'f' | 'i' | 'u' | 'h';
|
|
41
|
-
|
|
42
|
-
/** Shorthand type aliases recognized by WGSL */
|
|
43
|
-
export type AttributeShaderTypeAlias =
|
|
44
|
-
| `vec2${ShaderTypeAliasSuffix}`
|
|
45
|
-
| `vec3${ShaderTypeAliasSuffix}`
|
|
46
|
-
| `vec4${ShaderTypeAliasSuffix}`;
|
|
47
|
-
|
|
48
|
-
/** Shorthand type aliases recognized by WGSL */
|
|
49
|
-
export type VariableShaderTypeAlias =
|
|
50
|
-
| AttributeShaderTypeAlias
|
|
51
|
-
| `mat2x2${ShaderTypeAliasSuffix}`
|
|
52
|
-
| `mat2x3${ShaderTypeAliasSuffix}`
|
|
53
|
-
| `mat2x4${ShaderTypeAliasSuffix}`
|
|
54
|
-
| `mat3x2${ShaderTypeAliasSuffix}`
|
|
55
|
-
| `mat3x3${ShaderTypeAliasSuffix}`
|
|
56
|
-
| `mat3x4${ShaderTypeAliasSuffix}`
|
|
57
|
-
| `mat4x2${ShaderTypeAliasSuffix}`
|
|
58
|
-
| `mat4x3${ShaderTypeAliasSuffix}`
|
|
59
|
-
| `mat4x4${ShaderTypeAliasSuffix}`;
|
|
60
|
-
|
|
61
|
-
/** A composite shader type can include structs and arrays, recursively */
|
|
62
|
-
export type CompositeShaderType = VariableShaderType | StructShaderType | ArrayShaderType;
|
|
63
|
-
|
|
64
|
-
/** Represents a struct in WGSL */
|
|
65
|
-
export type StructShaderType = {
|
|
66
|
-
members: Record<string, CompositeShaderType>;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/** Represents an array in WGSL */
|
|
70
|
-
export type ArrayShaderType = {
|
|
71
|
-
type: CompositeShaderType;
|
|
72
|
-
length: number;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
/** Information extracted from a AttributeShaderType constant */
|
|
76
|
-
export type AttributeShaderTypeInfo = {
|
|
77
|
-
/** WGSL-style primitive data type, f32, i32, u32 */
|
|
78
|
-
primitiveType: PrimitiveDataType;
|
|
79
|
-
/** Whether this is a normalized integer (that must be used as float) */
|
|
80
|
-
components: 1 | 2 | 3 | 4;
|
|
81
|
-
/** Length in bytes of the data for one vertex */
|
|
82
|
-
byteLength?: number;
|
|
83
|
-
/** Whether this is for integer or float vert */
|
|
84
|
-
integer: boolean;
|
|
85
|
-
/** Whether this data type is signed */
|
|
86
|
-
signed: boolean;
|
|
87
|
-
};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {TypedArray} from '../../types';
|
|
6
|
-
import type {NormalizedDataType, PrimitiveDataType, SignedDataType} from '../data-types/data-types';
|
|
7
|
-
import type {VertexFormat, VertexFormatInfo} from './vertex-formats';
|
|
8
|
-
import {getDataTypeInfo, getDataType, getNormalizedDataType} from '../data-types/decode-data-types';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Decodes a vertex format, returning type, components, byte length and flags (integer, signed, normalized)
|
|
12
|
-
*/
|
|
13
|
-
export function getVertexFormatInfo(format: VertexFormat): VertexFormatInfo {
|
|
14
|
-
// Strip the -webgl ending if present
|
|
15
|
-
let webglOnly: boolean | undefined;
|
|
16
|
-
if (format.endsWith('-webgl')) {
|
|
17
|
-
format.replace('-webgl', '');
|
|
18
|
-
webglOnly = true;
|
|
19
|
-
}
|
|
20
|
-
// split components from type
|
|
21
|
-
const [type_, count] = format.split('x');
|
|
22
|
-
const type = type_ as NormalizedDataType;
|
|
23
|
-
const components = (count ? parseInt(count) : 1) as 1 | 2 | 3 | 4;
|
|
24
|
-
// decode the type
|
|
25
|
-
const decodedType = getDataTypeInfo(type);
|
|
26
|
-
const result: VertexFormatInfo = {
|
|
27
|
-
type,
|
|
28
|
-
components,
|
|
29
|
-
byteLength: decodedType.byteLength * components,
|
|
30
|
-
integer: decodedType.integer,
|
|
31
|
-
signed: decodedType.signed,
|
|
32
|
-
normalized: decodedType.normalized
|
|
33
|
-
};
|
|
34
|
-
if (webglOnly) {
|
|
35
|
-
result.webglOnly = true;
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Build a vertex format from a signed data type and a component */
|
|
41
|
-
export function makeVertexFormat(
|
|
42
|
-
signedDataType: SignedDataType,
|
|
43
|
-
components: 1 | 2 | 3 | 4,
|
|
44
|
-
normalized?: boolean
|
|
45
|
-
): VertexFormat {
|
|
46
|
-
const dataType: NormalizedDataType = normalized
|
|
47
|
-
? getNormalizedDataType(signedDataType)
|
|
48
|
-
: signedDataType;
|
|
49
|
-
|
|
50
|
-
switch (dataType) {
|
|
51
|
-
// TODO - Special cases for WebGL (not supported on WebGPU), overrides the check below
|
|
52
|
-
case 'unorm8':
|
|
53
|
-
if (components === 1) {
|
|
54
|
-
return 'unorm8';
|
|
55
|
-
}
|
|
56
|
-
if (components === 3) {
|
|
57
|
-
return 'unorm8x3-webgl';
|
|
58
|
-
}
|
|
59
|
-
return `${dataType}x${components}`;
|
|
60
|
-
|
|
61
|
-
case 'snorm8':
|
|
62
|
-
case 'uint8':
|
|
63
|
-
case 'sint8':
|
|
64
|
-
// WebGPU 8 bit formats must be aligned to 16 bit boundaries');
|
|
65
|
-
// fall through
|
|
66
|
-
case 'uint16':
|
|
67
|
-
case 'sint16':
|
|
68
|
-
case 'unorm16':
|
|
69
|
-
case 'snorm16':
|
|
70
|
-
case 'float16':
|
|
71
|
-
// WebGPU 16 bit formats must be aligned to 32 bit boundaries
|
|
72
|
-
if (components === 1 || components === 3) {
|
|
73
|
-
throw new Error(`size: ${components}`);
|
|
74
|
-
}
|
|
75
|
-
return `${dataType}x${components}`;
|
|
76
|
-
|
|
77
|
-
default:
|
|
78
|
-
return components === 1 ? dataType : `${dataType}x${components}`;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** Get the vertex format for an attribute with TypedArray and size */
|
|
83
|
-
export function getVertexFormatFromAttribute(
|
|
84
|
-
typedArray: TypedArray,
|
|
85
|
-
size: number,
|
|
86
|
-
normalized?: boolean
|
|
87
|
-
): VertexFormat {
|
|
88
|
-
if (!size || size > 4) {
|
|
89
|
-
throw new Error(`size ${size}`);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const components = size as 1 | 2 | 3 | 4;
|
|
93
|
-
const signedDataType = getDataType(typedArray);
|
|
94
|
-
return makeVertexFormat(signedDataType, components, normalized);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** Return a "default" vertex format for a certain shader data type
|
|
98
|
-
The simplest vertex format that matches the shader attribute's data type */
|
|
99
|
-
|
|
100
|
-
export function getCompatibleVertexFormat(opts: {
|
|
101
|
-
primitiveType: PrimitiveDataType;
|
|
102
|
-
components: 1 | 2 | 3 | 4;
|
|
103
|
-
}): VertexFormat {
|
|
104
|
-
let vertexType: NormalizedDataType;
|
|
105
|
-
switch (opts.primitiveType) {
|
|
106
|
-
case 'f32':
|
|
107
|
-
vertexType = 'float32';
|
|
108
|
-
break;
|
|
109
|
-
case 'i32':
|
|
110
|
-
vertexType = 'sint32';
|
|
111
|
-
break;
|
|
112
|
-
case 'u32':
|
|
113
|
-
vertexType = 'uint32';
|
|
114
|
-
break;
|
|
115
|
-
case 'f16':
|
|
116
|
-
return opts.components <= 2 ? 'float16x2' : 'float16x4';
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// TODO logic does not work for float16
|
|
120
|
-
if (opts.components === 1) {
|
|
121
|
-
return vertexType;
|
|
122
|
-
}
|
|
123
|
-
return `${vertexType}x${opts.components}`;
|
|
124
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {NormalizedDataType} from '../data-types/data-types';
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Describes the **memory format** and interpretation (normalization) of a buffer that will be supplied to vertex attributes
|
|
11
|
-
* @note Must be compatible with the AttributeShaderType of the shaders, see documentation.
|
|
12
|
-
* @note This is a superset of WebGPU vertex formats to allow for some flexibility for WebGL only applications
|
|
13
|
-
* @todo Add device.isTextureFormatSupported() method?
|
|
14
|
-
*/
|
|
15
|
-
export type VertexFormat =
|
|
16
|
-
// 8 bit integers, note that only 16 bit aligned formats are supported in WebGPU (x2 and x4)
|
|
17
|
-
| 'uint8' // Chrome 133+
|
|
18
|
-
| 'uint8x2'
|
|
19
|
-
| 'uint8x4'
|
|
20
|
-
| 'sint8' // Chrome 133+
|
|
21
|
-
| 'sint8x2'
|
|
22
|
-
| 'sint8x4'
|
|
23
|
-
| 'unorm8' // Chrome 133+
|
|
24
|
-
| 'unorm8x2'
|
|
25
|
-
| 'unorm8x3-webgl' // Not in WebGPU
|
|
26
|
-
| 'unorm8x4'
|
|
27
|
-
| 'unorm8x4-bgra' // Chrome 133+
|
|
28
|
-
| 'unorm10-10-10-2' // Chrome 119+
|
|
29
|
-
// | 'snorm-10-10-10-2' // Not in WebGPU, DXD12 doesn't support
|
|
30
|
-
| 'snorm8' // Chrome 133+
|
|
31
|
-
| 'snorm8x2'
|
|
32
|
-
| 'snorm8x3-webgl'
|
|
33
|
-
| 'snorm8x4'
|
|
34
|
-
// 16 bit integers, that only 32 bit aligned formats are supported in WebGPU (x2 and x4)
|
|
35
|
-
| 'uint16' // Chrome 133+
|
|
36
|
-
| 'sint16' // Chrome 133+
|
|
37
|
-
| 'unorm16' // Chrome 133+
|
|
38
|
-
| 'snorm16' // Chrome 133+
|
|
39
|
-
| 'uint16x2'
|
|
40
|
-
| 'uint16x4'
|
|
41
|
-
| 'sint16x2'
|
|
42
|
-
| 'sint16x4'
|
|
43
|
-
| 'unorm16x2'
|
|
44
|
-
| 'unorm16x4'
|
|
45
|
-
| 'snorm16x2'
|
|
46
|
-
| 'snorm16x4'
|
|
47
|
-
// 32 bit integers
|
|
48
|
-
| 'uint32'
|
|
49
|
-
| 'uint32x2'
|
|
50
|
-
| 'uint32x3'
|
|
51
|
-
| 'uint32x4'
|
|
52
|
-
| 'sint32'
|
|
53
|
-
| 'sint32x2'
|
|
54
|
-
| 'sint32x3'
|
|
55
|
-
| 'sint32x4'
|
|
56
|
-
// No normalized 32 bit integers in WebGPU...
|
|
57
|
-
// | 'unorm32'
|
|
58
|
-
// | 'unorm32x2'
|
|
59
|
-
// | 'unorm32x3'
|
|
60
|
-
// | 'unorm32x4'
|
|
61
|
-
// | 'snorm32'
|
|
62
|
-
// | 'snorm32x2'
|
|
63
|
-
// | 'snorm32x3'
|
|
64
|
-
// | 'snorm32x4'
|
|
65
|
-
// floats
|
|
66
|
-
| 'float16' // Chrome 133+
|
|
67
|
-
| 'float16x2'
|
|
68
|
-
| 'float16x4'
|
|
69
|
-
| 'float32'
|
|
70
|
-
| 'float32x2'
|
|
71
|
-
| 'float32x3'
|
|
72
|
-
| 'float32x4';
|
|
73
|
-
|
|
74
|
-
export type VertexFormatInfo = {
|
|
75
|
-
/** Type of each component */
|
|
76
|
-
type: NormalizedDataType;
|
|
77
|
-
/** Length in bytes */
|
|
78
|
-
byteLength: number;
|
|
79
|
-
/** Number of components per vertex / row */
|
|
80
|
-
components: 1 | 2 | 3 | 4;
|
|
81
|
-
/** Is this an integer format (normalized integer formats are not integer) */
|
|
82
|
-
integer: boolean;
|
|
83
|
-
/** Is this a signed format? */
|
|
84
|
-
signed: boolean;
|
|
85
|
-
/** Is this a normalized format? */
|
|
86
|
-
normalized: boolean;
|
|
87
|
-
/** Is this a bgra format? */
|
|
88
|
-
bgra?: boolean;
|
|
89
|
-
/** Is this a webgl only format? */
|
|
90
|
-
webglOnly?: boolean;
|
|
91
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|