@luma.gl/core 9.0.0-alpha.9 → 9.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -1
- package/README.md +4 -4
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.d.ts +52 -0
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.d.ts.map +1 -0
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.js +130 -0
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.js.map +1 -0
- package/dist/adapter/canvas-context.d.ts +109 -0
- package/dist/adapter/canvas-context.d.ts.map +1 -0
- package/dist/adapter/canvas-context.js +254 -0
- package/dist/adapter/canvas-context.js.map +1 -0
- package/dist/adapter/device.d.ts +219 -0
- package/dist/adapter/device.d.ts.map +1 -0
- package/dist/adapter/device.js +99 -0
- package/dist/adapter/device.js.map +1 -0
- package/dist/adapter/resources/buffer.d.ts +56 -0
- package/dist/adapter/resources/buffer.d.ts.map +1 -0
- package/dist/adapter/resources/buffer.js +62 -0
- package/dist/adapter/resources/buffer.js.map +1 -0
- package/dist/adapter/resources/command-buffer.d.ts +12 -0
- package/dist/adapter/resources/command-buffer.d.ts.map +1 -0
- package/dist/adapter/resources/command-buffer.js +15 -0
- package/dist/adapter/resources/command-buffer.js.map +1 -0
- package/dist/adapter/resources/command-encoder.d.ts +113 -0
- package/dist/adapter/resources/command-encoder.d.ts.map +1 -0
- package/dist/adapter/resources/command-encoder.js +19 -0
- package/dist/adapter/resources/command-encoder.js.map +1 -0
- package/dist/adapter/resources/compute-pass.d.ts +31 -0
- package/dist/adapter/resources/compute-pass.d.ts.map +1 -0
- package/dist/adapter/resources/compute-pass.js +15 -0
- package/dist/adapter/resources/compute-pass.js.map +1 -0
- package/dist/adapter/resources/compute-pipeline.d.ts +24 -0
- package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/compute-pipeline.js +20 -0
- package/dist/adapter/resources/compute-pipeline.js.map +1 -0
- package/dist/adapter/resources/external-texture.d.ts +12 -0
- package/dist/adapter/resources/external-texture.d.ts.map +1 -0
- package/dist/adapter/resources/external-texture.js +17 -0
- package/dist/adapter/resources/external-texture.js.map +1 -0
- package/dist/adapter/resources/framebuffer.d.ts +50 -0
- package/dist/adapter/resources/framebuffer.d.ts.map +1 -0
- package/dist/adapter/resources/framebuffer.js +102 -0
- package/dist/adapter/resources/framebuffer.js.map +1 -0
- package/dist/adapter/resources/render-pass.d.ts +51 -0
- package/dist/adapter/resources/render-pass.d.ts.map +1 -0
- package/dist/adapter/resources/render-pass.js +23 -0
- package/dist/adapter/resources/render-pass.js.map +1 -0
- package/dist/adapter/resources/render-pipeline.d.ts +89 -0
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -0
- package/dist/adapter/resources/render-pipeline.js +36 -0
- package/dist/adapter/resources/render-pipeline.js.map +1 -0
- package/dist/adapter/resources/resource.d.ts +73 -0
- package/dist/adapter/resources/resource.d.ts.map +1 -0
- package/dist/adapter/resources/resource.js +101 -0
- package/dist/adapter/resources/resource.js.map +1 -0
- package/dist/adapter/resources/sampler.d.ts +42 -0
- package/dist/adapter/resources/sampler.d.ts.map +1 -0
- package/dist/adapter/resources/sampler.js +26 -0
- package/dist/adapter/resources/sampler.js.map +1 -0
- package/dist/adapter/resources/shader.d.ts +45 -0
- package/dist/adapter/resources/shader.d.ts.map +1 -0
- package/dist/adapter/resources/shader.js +90 -0
- package/dist/adapter/resources/shader.js.map +1 -0
- package/dist/adapter/resources/texture.d.ts +90 -0
- package/dist/adapter/resources/texture.d.ts.map +1 -0
- package/dist/adapter/resources/texture.js +45 -0
- package/dist/adapter/resources/texture.js.map +1 -0
- package/dist/adapter/resources/transform-feedback.d.ts +30 -0
- package/dist/adapter/resources/transform-feedback.d.ts.map +1 -0
- package/dist/adapter/resources/transform-feedback.js +17 -0
- package/dist/adapter/resources/transform-feedback.js.map +1 -0
- package/dist/adapter/resources/vertex-array.d.ts +40 -0
- package/dist/adapter/resources/vertex-array.d.ts.map +1 -0
- package/dist/adapter/resources/vertex-array.js +24 -0
- package/dist/adapter/resources/vertex-array.js.map +1 -0
- package/dist/adapter/type-utils/decode-attribute-type.d.ts +20 -0
- package/dist/adapter/type-utils/decode-attribute-type.d.ts.map +1 -0
- package/dist/adapter/type-utils/decode-attribute-type.js +60 -0
- package/dist/adapter/type-utils/decode-attribute-type.js.map +1 -0
- package/dist/adapter/type-utils/decode-data-type.d.ts +16 -0
- package/dist/adapter/type-utils/decode-data-type.d.ts.map +1 -0
- package/dist/adapter/type-utils/decode-data-type.js +43 -0
- package/dist/adapter/type-utils/decode-data-type.js.map +1 -0
- package/dist/adapter/type-utils/decode-shader-types.d.ts +9 -0
- package/dist/adapter/type-utils/decode-shader-types.d.ts.map +1 -0
- package/dist/adapter/type-utils/decode-shader-types.js +103 -0
- package/dist/adapter/type-utils/decode-shader-types.js.map +1 -0
- package/dist/adapter/type-utils/decode-texture-format.d.ts +19 -0
- package/dist/adapter/type-utils/decode-texture-format.d.ts.map +1 -0
- package/dist/adapter/type-utils/decode-texture-format.js +101 -0
- package/dist/adapter/type-utils/decode-texture-format.js.map +1 -0
- package/dist/adapter/type-utils/decode-vertex-format.d.ts +22 -0
- package/dist/adapter/type-utils/decode-vertex-format.d.ts.map +1 -0
- package/dist/adapter/type-utils/decode-vertex-format.js +25 -0
- package/dist/adapter/type-utils/decode-vertex-format.js.map +1 -0
- package/dist/adapter/type-utils/vertex-format-from-attribute.d.ts +10 -0
- package/dist/adapter/type-utils/vertex-format-from-attribute.d.ts.map +1 -0
- package/dist/adapter/type-utils/vertex-format-from-attribute.js +76 -0
- package/dist/adapter/type-utils/vertex-format-from-attribute.js.map +1 -0
- package/dist/adapter/type-utils/wgsl-utils.d.ts +4 -0
- package/dist/adapter/type-utils/wgsl-utils.d.ts.map +1 -0
- package/dist/adapter/type-utils/wgsl-utils.js +15 -0
- package/dist/adapter/type-utils/wgsl-utils.js.map +1 -0
- package/dist/adapter/types/accessor.d.ts +23 -0
- package/dist/adapter/types/accessor.d.ts.map +1 -0
- package/dist/adapter/types/accessor.js +2 -0
- package/dist/adapter/types/accessor.js.map +1 -0
- package/dist/adapter/types/buffer-layout.d.ts +59 -0
- package/dist/adapter/types/buffer-layout.d.ts.map +1 -0
- package/dist/adapter/types/buffer-layout.js +2 -0
- package/dist/adapter/types/buffer-layout.js.map +1 -0
- package/dist/adapter/types/parameters.d.ts +97 -0
- package/dist/adapter/types/parameters.d.ts.map +1 -0
- package/dist/adapter/types/parameters.js +28 -0
- package/dist/adapter/types/parameters.js.map +1 -0
- package/dist/adapter/types/shader-layout.d.ts +145 -0
- package/dist/adapter/types/shader-layout.d.ts.map +1 -0
- package/dist/adapter/types/shader-layout.js +2 -0
- package/dist/adapter/types/shader-layout.js.map +1 -0
- package/dist/adapter/types/shader-types.d.ts +21 -0
- package/dist/adapter/types/shader-types.d.ts.map +1 -0
- package/dist/adapter/types/shader-types.js +2 -0
- package/dist/adapter/types/shader-types.js.map +1 -0
- package/dist/adapter/types/texture-formats.d.ts +12 -0
- package/dist/adapter/types/texture-formats.d.ts.map +1 -0
- package/dist/adapter/types/texture-formats.js +2 -0
- package/dist/adapter/types/texture-formats.js.map +1 -0
- package/dist/adapter/types/types.d.ts +90 -0
- package/dist/adapter/types/types.d.ts.map +1 -0
- package/dist/adapter/types/types.js +2 -0
- package/dist/adapter/types/types.js.map +1 -0
- package/dist/adapter/types/vertex-formats.d.ts +14 -0
- package/dist/adapter/types/vertex-formats.d.ts.map +1 -0
- package/dist/adapter/types/vertex-formats.js +2 -0
- package/dist/adapter/types/vertex-formats.js.map +1 -0
- package/dist/dist.dev.js +2976 -0
- package/dist/index.cjs +2445 -0
- package/dist/index.d.ts +81 -128
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -18
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +5 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +24 -0
- package/dist/init.js.map +1 -0
- package/dist/lib/compiler-log/compiler-message.d.ts +8 -0
- package/dist/lib/compiler-log/compiler-message.d.ts.map +1 -0
- package/dist/lib/compiler-log/compiler-message.js +2 -0
- package/dist/lib/compiler-log/compiler-message.js.map +1 -0
- package/dist/lib/compiler-log/format-compiler-log.d.ts +8 -0
- package/dist/lib/compiler-log/format-compiler-log.d.ts.map +1 -0
- package/dist/lib/compiler-log/format-compiler-log.js +64 -0
- package/dist/lib/compiler-log/format-compiler-log.js.map +1 -0
- package/dist/lib/compiler-log/get-shader-info.d.ts +9 -0
- package/dist/lib/compiler-log/get-shader-info.d.ts.map +1 -0
- package/dist/lib/compiler-log/get-shader-info.js +25 -0
- package/dist/lib/compiler-log/get-shader-info.js.map +1 -0
- package/dist/lib/luma.d.ts +22 -0
- package/dist/lib/luma.d.ts.map +1 -0
- package/dist/lib/luma.js +63 -0
- package/dist/lib/luma.js.map +1 -0
- package/dist/lib/uniforms/uniform-block.d.ts +29 -0
- package/dist/lib/uniforms/uniform-block.d.ts.map +1 -0
- package/dist/lib/uniforms/uniform-block.js +48 -0
- package/dist/lib/uniforms/uniform-block.js.map +1 -0
- package/dist/lib/uniforms/uniform-buffer-layout.d.ts +27 -0
- package/dist/lib/uniforms/uniform-buffer-layout.d.ts.map +1 -0
- package/dist/lib/uniforms/uniform-buffer-layout.js +76 -0
- package/dist/lib/uniforms/uniform-buffer-layout.js.map +1 -0
- package/dist/lib/uniforms/uniform-store.d.ts +62 -0
- package/dist/lib/uniforms/uniform-store.d.ts.map +1 -0
- package/dist/lib/uniforms/uniform-store.js +89 -0
- package/dist/lib/uniforms/uniform-store.js.map +1 -0
- package/dist/lib/uniforms/uniform.d.ts +10 -0
- package/dist/lib/uniforms/uniform.d.ts.map +1 -0
- package/dist/lib/uniforms/uniform.js +20 -0
- package/dist/lib/uniforms/uniform.js.map +1 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/array-equal.d.ts +5 -0
- package/dist/utils/array-equal.d.ts.map +1 -0
- package/dist/utils/array-equal.js +28 -0
- package/dist/utils/array-equal.js.map +1 -0
- package/dist/utils/array-utils-flat.d.ts +10 -0
- package/dist/utils/array-utils-flat.d.ts.map +1 -0
- package/dist/utils/array-utils-flat.js +36 -0
- package/dist/utils/array-utils-flat.js.map +1 -0
- package/dist/utils/assert.d.ts +2 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/assert.js +6 -0
- package/dist/utils/assert.js.map +1 -0
- package/dist/utils/cast.d.ts +3 -0
- package/dist/utils/cast.d.ts.map +1 -0
- package/dist/utils/cast.js +4 -0
- package/dist/utils/cast.js.map +1 -0
- package/dist/utils/check-props.d.ts +7 -0
- package/dist/utils/check-props.d.ts.map +1 -0
- package/dist/utils/check-props.js +32 -0
- package/dist/utils/check-props.js.map +1 -0
- package/dist/utils/deep-equal.d.ts +9 -0
- package/dist/utils/deep-equal.d.ts.map +1 -0
- package/dist/utils/deep-equal.js +40 -0
- package/dist/utils/deep-equal.js.map +1 -0
- package/dist/utils/format-value.d.ts +7 -0
- package/dist/utils/format-value.d.ts.map +1 -0
- package/dist/utils/format-value.js +42 -0
- package/dist/utils/format-value.js.map +1 -0
- package/dist/utils/is-array.d.ts +16 -0
- package/dist/utils/is-array.d.ts.map +1 -0
- package/dist/utils/is-array.js +10 -0
- package/dist/utils/is-array.js.map +1 -0
- package/dist/utils/load-file.d.ts +35 -0
- package/dist/utils/load-file.d.ts.map +1 -0
- package/dist/utils/load-file.js +48 -0
- package/dist/utils/load-file.js.map +1 -0
- package/dist/utils/log.d.ts +4 -0
- package/dist/utils/log.d.ts.map +1 -0
- package/dist/utils/log.js +5 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/random.d.ts +5 -0
- package/dist/utils/random.d.ts.map +1 -0
- package/dist/utils/random.js +14 -0
- package/dist/utils/random.js.map +1 -0
- package/dist/utils/request-animation-frame.d.ts +3 -0
- package/dist/utils/request-animation-frame.d.ts.map +1 -0
- package/dist/utils/request-animation-frame.js +7 -0
- package/dist/utils/request-animation-frame.js.map +1 -0
- package/dist/utils/stats-manager.d.ts +12 -0
- package/dist/utils/stats-manager.d.ts.map +1 -0
- package/dist/utils/stats-manager.js +19 -0
- package/dist/utils/stats-manager.js.map +1 -0
- package/dist/utils/stub-methods.d.ts +2 -0
- package/dist/utils/stub-methods.d.ts.map +1 -0
- package/dist/utils/stub-methods.js +16 -0
- package/dist/utils/stub-methods.js.map +1 -0
- package/dist/utils/utils.d.ts +15 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +19 -0
- package/dist/utils/utils.js.map +1 -0
- package/dist.min.js +33 -0
- package/package.json +17 -12
- package/src/adapter/attribute-utils/get-attribute-from-layouts.ts +259 -0
- package/src/adapter/canvas-context.ts +433 -0
- package/src/adapter/device.ts +435 -0
- package/src/adapter/resources/buffer.ts +106 -0
- package/src/adapter/resources/command-buffer.ts +38 -0
- package/src/adapter/resources/command-encoder.ts +172 -0
- package/src/adapter/resources/compute-pass.ts +52 -0
- package/src/adapter/resources/compute-pipeline.ts +39 -0
- package/src/adapter/resources/external-texture.ts +20 -0
- package/src/adapter/resources/framebuffer.ts +230 -0
- package/src/adapter/resources/render-pass.ts +117 -0
- package/src/adapter/resources/render-pipeline.ts +133 -0
- package/src/adapter/resources/resource.ts +176 -0
- package/src/adapter/resources/sampler.ts +69 -0
- package/src/adapter/resources/shader.ts +143 -0
- package/src/adapter/resources/texture.ts +140 -0
- package/src/adapter/resources/transform-feedback.ts +45 -0
- package/src/adapter/resources/vertex-array.ts +65 -0
- package/src/adapter/type-utils/decode-attribute-type.ts +82 -0
- package/src/adapter/type-utils/decode-data-type.ts +62 -0
- package/src/adapter/type-utils/decode-shader-types.ts +48 -0
- package/src/adapter/type-utils/decode-texture-format.ts +190 -0
- package/src/adapter/type-utils/decode-vertex-format.ts +49 -0
- package/src/adapter/type-utils/vertex-format-from-attribute.ts +103 -0
- package/src/adapter/type-utils/wgsl-utils.ts +18 -0
- package/src/adapter/types/accessor.ts +34 -0
- package/src/adapter/types/buffer-layout.ts +62 -0
- package/src/adapter/types/parameters.ts +250 -0
- package/src/adapter/types/shader-layout.ts +193 -0
- package/src/adapter/types/shader-types.ts +77 -0
- package/src/adapter/types/texture-formats.ts +168 -0
- package/src/adapter/types/types.ts +109 -0
- package/src/adapter/types/vertex-formats.ts +91 -0
- package/src/index.ts +160 -92
- package/src/init.ts +47 -0
- package/src/lib/compiler-log/compiler-message.ts +10 -0
- package/src/lib/compiler-log/format-compiler-log.ts +113 -0
- package/src/lib/compiler-log/get-shader-info.ts +41 -0
- package/src/lib/luma.ts +84 -0
- package/src/lib/uniforms/uniform-block.ts +80 -0
- package/src/lib/uniforms/uniform-buffer-layout.ts +109 -0
- package/src/lib/uniforms/uniform-store.ts +173 -0
- package/src/lib/uniforms/uniform.ts +25 -0
- package/src/types.ts +33 -0
- package/src/utils/array-equal.ts +33 -0
- package/src/utils/array-utils-flat.ts +43 -0
- package/src/utils/assert.ts +7 -0
- package/src/utils/cast.ts +4 -0
- package/src/utils/check-props.ts +74 -0
- package/src/utils/deep-equal.ts +47 -0
- package/src/utils/format-value.ts +40 -0
- package/src/utils/is-array.ts +24 -0
- package/src/utils/load-file.ts +89 -0
- package/src/utils/log.ts +4 -0
- package/src/utils/random.ts +17 -0
- package/src/utils/request-animation-frame.ts +15 -0
- package/src/utils/stats-manager.ts +23 -0
- package/src/utils/stub-methods.ts +20 -0
- package/src/utils/utils.ts +36 -0
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/bundle.js.map +0 -1
- package/src/bundle.ts +0 -4
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { decodeVertexType } from "./decode-data-type.js";
|
|
2
|
+
const REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;
|
|
3
|
+
export function decodeTextureFormat(format) {
|
|
4
|
+
const matches = REGEX.exec(format);
|
|
5
|
+
if (matches) {
|
|
6
|
+
const [, format, length, type, srgb, suffix] = matches;
|
|
7
|
+
if (format) {
|
|
8
|
+
const dataType = `${type}${length}`;
|
|
9
|
+
const decodedType = decodeVertexType(dataType);
|
|
10
|
+
return {
|
|
11
|
+
format: format,
|
|
12
|
+
components: format.length,
|
|
13
|
+
srgb: srgb === '-srgb',
|
|
14
|
+
unsized: suffix === '-unsized',
|
|
15
|
+
webgl: suffix === '-webgl',
|
|
16
|
+
...decodedType
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return decodeNonStandardFormat(format);
|
|
21
|
+
}
|
|
22
|
+
const EXCEPTIONS = {
|
|
23
|
+
'rgba4unorm-webgl': {
|
|
24
|
+
format: 'rgba',
|
|
25
|
+
bpp: 2
|
|
26
|
+
},
|
|
27
|
+
'rgb565unorm-webgl': {
|
|
28
|
+
format: 'rgb',
|
|
29
|
+
bpp: 2
|
|
30
|
+
},
|
|
31
|
+
'rgb5a1unorm-webgl': {
|
|
32
|
+
format: 'rgba',
|
|
33
|
+
bbp: 2
|
|
34
|
+
},
|
|
35
|
+
'rgb9e5ufloat': {
|
|
36
|
+
format: 'rgb',
|
|
37
|
+
bbp: 4
|
|
38
|
+
},
|
|
39
|
+
'rg11b10ufloat': {
|
|
40
|
+
format: 'rgb',
|
|
41
|
+
bbp: 4
|
|
42
|
+
},
|
|
43
|
+
'rgb10a2unorm': {
|
|
44
|
+
format: 'rgba',
|
|
45
|
+
bbp: 4
|
|
46
|
+
},
|
|
47
|
+
'rgb10a2unorm-webgl': {
|
|
48
|
+
format: 'rgba',
|
|
49
|
+
bbp: 4
|
|
50
|
+
},
|
|
51
|
+
'stencil8': {
|
|
52
|
+
components: 1,
|
|
53
|
+
bpp: 1,
|
|
54
|
+
a: 'stencil'
|
|
55
|
+
},
|
|
56
|
+
'depth16unorm': {
|
|
57
|
+
components: 1,
|
|
58
|
+
bpp: 2,
|
|
59
|
+
a: 'depth'
|
|
60
|
+
},
|
|
61
|
+
'depth24plus': {
|
|
62
|
+
components: 1,
|
|
63
|
+
bpp: 3,
|
|
64
|
+
a: 'depth'
|
|
65
|
+
},
|
|
66
|
+
'depth32float': {
|
|
67
|
+
components: 1,
|
|
68
|
+
bpp: 4,
|
|
69
|
+
a: 'depth'
|
|
70
|
+
},
|
|
71
|
+
'depth24plus-stencil8': {
|
|
72
|
+
components: 2,
|
|
73
|
+
bpp: 4,
|
|
74
|
+
a: 'depth-stencil'
|
|
75
|
+
},
|
|
76
|
+
'depth24unorm-stencil8': {
|
|
77
|
+
components: 2,
|
|
78
|
+
bpp: 4,
|
|
79
|
+
a: 'depth-stencil'
|
|
80
|
+
},
|
|
81
|
+
'depth32float-stencil8': {
|
|
82
|
+
components: 2,
|
|
83
|
+
bpp: 4,
|
|
84
|
+
a: 'depth-stencil'
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
function decodeNonStandardFormat(format) {
|
|
88
|
+
var _data$format;
|
|
89
|
+
const data = EXCEPTIONS[format];
|
|
90
|
+
if (!data) {
|
|
91
|
+
throw new Error(`Unknown format ${format}`);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
format: data.format || '',
|
|
95
|
+
components: data.components || ((_data$format = data.format) === null || _data$format === void 0 ? void 0 : _data$format.length) || 1,
|
|
96
|
+
byteLength: data.bpp || 1,
|
|
97
|
+
srgb: false,
|
|
98
|
+
unsized: false
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=decode-texture-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-texture-format.js","names":["decodeVertexType","REGEX","decodeTextureFormat","format","matches","exec","length","type","srgb","suffix","dataType","decodedType","components","unsized","webgl","decodeNonStandardFormat","EXCEPTIONS","bpp","bbp","a","_data$format","data","Error","byteLength"],"sources":["../../../src/adapter/type-utils/decode-texture-format.ts"],"sourcesContent":["import {TextureFormat} from '../types/texture-formats';\nimport {VertexType} from '../types/vertex-formats';\nimport {decodeVertexType} from './decode-data-type';\n\nconst REGEX = /^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;\n\nexport type DecodedTextureFormat = {\n format: 'r' | 'rg' | 'rgb' | 'rgba';\n components: 1 | 2 | 3 | 4;\n dataType?: VertexType;\n srgb: boolean;\n webgl: boolean;\n unsized: boolean;\n byteLength: number;\n integer: boolean;\n signed: boolean;\n normalized: boolean;\n}\n\n/**\n * Decodes a vertex format, returning type, components, byte length and flags (integer, signed, normalized)\n */\nexport function decodeTextureFormat(format: TextureFormat): DecodedTextureFormat {\n const matches = REGEX.exec((format as string));\n if (matches) {\n const [, format, length, type, srgb, suffix] = matches;\n if (format) {\n const dataType = `${type}${length}` as VertexType;\n const decodedType = decodeVertexType(dataType);\n return {\n format: format as 'r' | 'rg' | 'rgb' | 'rgba',\n components: format.length as 1 | 2 | 3 | 4,\n // dataType - overwritten by decodedType\n srgb: srgb === '-srgb',\n unsized: suffix === '-unsized',\n webgl: suffix === '-webgl',\n ...decodedType\n };\n }\n }\n\n return decodeNonStandardFormat(format);\n}\n\n// https://www.w3.org/TR/webgpu/#texture-format-caps\n\nconst EXCEPTIONS: Partial<Record<TextureFormat, any>> = {\n // Packed 16 bit formats\n 'rgba4unorm-webgl': {format: 'rgba', bpp: 2}, \n 'rgb565unorm-webgl': {format: 'rgb', bpp: 2},\n 'rgb5a1unorm-webgl': {format: 'rgba', bbp: 2}, \n // Packed 32 bit formats\n 'rgb9e5ufloat': {format: 'rgb', bbp: 4},\n 'rg11b10ufloat': {format: 'rgb', bbp: 4},\n 'rgb10a2unorm': {format: 'rgba', bbp: 4},\n 'rgb10a2unorm-webgl': {format: 'rgba', bbp: 4},\n // Depth/stencil\n 'stencil8': {components: 1, bpp: 1, a: 'stencil'},\n 'depth16unorm': {components: 1, bpp: 2, a: 'depth'},\n 'depth24plus': {components: 1, bpp: 3, a: 'depth'},\n 'depth32float': {components: 1, bpp: 4, a: 'depth'},\n 'depth24plus-stencil8': {components: 2, bpp: 4, a: 'depth-stencil'},\n // \"depth24unorm-stencil8\" feature\n 'depth24unorm-stencil8': {components: 2, bpp: 4, a: 'depth-stencil'},\n // \"depth32float-stencil8\" feature\n 'depth32float-stencil8': {components: 2, bpp: 4, a: 'depth-stencil'}\n};\n\nfunction decodeNonStandardFormat(format: TextureFormat): DecodedTextureFormat {\n const data = EXCEPTIONS[format];\n if (!data) {\n throw new Error(`Unknown format ${format}`);\n }\n return {\n format: data.format || '',\n components: data.components || data.format?.length || 1,\n byteLength: data.bpp || 1,\n srgb: false,\n unsized: false \n } as DecodedTextureFormat;\n}\n\n/*\n'r8unorm':\t{s: \"float\"}, // \t✓\t✓\t✓\t},\n'r8snorm':\t{s: \"float\"}, // \t\t✓\t\t},\n'r8uint':\t{s: \"uint\"}, // \t✓\t✓\t\t},\n'r8sint':\t{s: \"sint\"}, // \t✓\t✓\t\t},\n'rg8unorm':\t{s: \"float\"}, // \t✓\t✓\t✓\t},\n'rg8snorm':\t{s: \"float\"}, // \t\t✓\t\t},\n'rg8uint':\t{s: \"uint\"}, // \t✓\t✓\t\t},\n'rg8sint':\t{s: \"sint\"}, // \t✓\t✓\t\t},\n'rgba8unorm':\t{s: \"float\"}, // \t✓\t✓\t✓\t✓},\n'rgba8unorm-srgb': {s: \"float\"}, // \t✓\t✓\t✓\t},\n'rgba8snorm':\t{s: \"float\"}, // \t\t✓\t\t✓},\n'rgba8uint':\t{s: \"uint\"}, // \t✓\t✓\t\t✓},\n'rgba8sint':\t{s: \"sint\"}, // \t✓\t✓\t\t✓},\n'bgra8unorm':\t{s: \"float\"}, // \t✓\t✓\t✓\t},\n'bgra8unorm-srgb': {s: \"float\"}, // \t✓\t✓\t✓\t},\n// 16-bit per component\t\t\t\t\t\n'r16uint': {s: \"uint\"}, // \t✓\t✓\t\t},\n'r16sint': {s: \"sint\"}, // \t✓\t✓\t\t},\n'r16float': {s: \"float\"}, // \t✓\t✓\t✓\t},\n'rg16uint': {s: \"uint\"}, // \t✓\t✓\t\t},\n'rg16sint': {s: \"sint\"}, // \t✓\t✓\t\t},\n'rg16float': {s: \"float\"}, // \t✓\t✓\t✓\t},\n'rgba16uint': {s: \"uint\"}, // \t✓\t✓\t\t✓},\n'rgba16sint': {s: \"sint\"}, // \t✓\t✓\t\t✓},\n'rgba16float': {s: \"float\"}, // \t✓\t✓\t✓\t✓},\n// 32-bit per component\t\t\t\t\t\n'r32uint': {s: \"uint\"}, // \t✓\t\t\t✓},\n'r32sint': {s: \"sint\"}, // \t✓\t\t\t✓},\n'r32float': {\"unfilterable-float\"\t✓\t✓\t\t✓},\n'rg32uint': {s: \"uint\"}, // \t✓\t\t\t✓},\n'rg32sint': {s: \"sint\"}, // \t✓\t\t\t✓},\n'rg32float': {\"unfilterable-float\"\t✓\t\t\t✓},\n'rgba32uint': {s: \"uint\"}, // \t✓\t\t\t✓},\n'rgba32sint': {s: \"sint\"}, // \t✓\t\t\t✓},\n'rgba32float': {\"unfilterable-float\"\t✓\t\t\t✓},\n// mixed component width\t\t\t\t\t\n'rgb10a2unorm': {s: \"float\"}, // \t✓\t✓\t✓\t}\n'rg11b10ufloat': {s: \"float\"}, // \t\t✓\t\t}\n// Format\tBytes per texel\tAspect\tGPUTextureSampleType\tValid image copy source\tValid image copy destination\n'stencil8': {1 − 4\tstencil\t\"uint\"\t✓}\n'depth16unorm': {2\tdepth\t\"depth\"\t✓}\n'depth24plus': {4\tdepth\t\"depth\"\t✗}\n'depth24plus': {stencil8\t4 − 8\tdepth\t\"depth\"\t✗}\n'stencil': {s: \"uint\"}, // \t✓}\n'depth32float': {4\tdepth\t\"depth\"\t✓\t✗}\n'depth24unorm': {stencil8\t4\tdepth\t\"depth\"\t✗}\n'stencil': {s: \"uint\"}, // \t✓}\n'depth32float': {stencil8}\n\n// Format\tBytes per block\tGPUTextureSampleType\tBlock Size\tFeature\n'rgb9e5ufloat': {c: 4, s: \"float\",\tbpp: 4/(1*1)},\n\n'bc1-rgba-unorm': {c: 4. s: \"float\", bpp: 8/(4 * 4) f: 'texture-compression-bc'},\n'bc1-rgba-unorm-srgb': {c: 4. s: \"float\", bpp: 8/(4 * 4) f: 'texture-compression-bc'},\n'bc2-rgba-unorm': {c: 4. s: \"float\", bpp: 16/(4 * 4) f: 'texture-compression-bc'},\n'bc2-rgba-unorm-srgb': {c: 4. s: \"float\", bpp: 16/(4 * 4) f: 'texture-compression-bc'},\n'bc3-rgba-unorm': {c: 4. s: \"float\", bpp: 16/(4 * 4) f: 'texture-compression-bc'},\n'bc3-rgba-unorm-srgb': {c: 4. s: \"float\", bpp: 16/(4 * 4) f: 'texture-compression-bc'},\n'bc4-r-unorm': {c: 1. s: \"float\", bpp: 8/(4 * 4) f: 'texture-compression-bc'},\n'bc4-r-snorm': {c: 1. s: \"float\", bpp: 8/(4 * 4) f: 'texture-compression-bc'},\n'bc5-rg-unorm': {c: 2. s: \"float\", bpp: 16/(4 * 4) f: 'texture-compression-bc'},\n'bc5-rg-snorm': { },\n'bc6h-rgb-ufloat': {\t16 },\n'bc6h-rgb-float': { },\n'bc7-rgba-unorm': {\t16 },\n'bc7-rgba-unorm-srgb': { },\n\n'etc2-rgb8unorm': {\t8\t\"float\"\t4 × 4\ttexture-compression-etc2 },\n'etc2-rgb8unorm-srgb': { },\n'etc2-rgb8a1unorm': {\t8 },\n'etc2-rgb8a1unorm-srgb': { },\n'etc2-rgba8unorm': {\t16 },\n'etc2-rgba8unorm-srgb': { },\n\n'eac-r11unorm': {\t8 },\n'eac-r11snorm': { },\n'eac-rg11unorm': {\t16 },\n'eac-rg11snorm': { },\n\n'astc-4x4-unorm': {\t16\t\"float\"\t4 × 4\ttexture-compression-astc },\n'astc-4x4-unorm-srgb': { },\n'astc-5x4-unorm': {\t16\t5 × 4 },\n'astc-5x4-unorm-srgb': { },\n'astc-5x5-unorm': {\t16\t5 × 5 },\n'astc-5x5-unorm-srgb': { },\n'astc-6x5-unorm': {\t16\t6 × 5 },\n'astc-6x5-unorm-srgb': { },\n'astc-6x6-unorm': {\t16\t6 × 6 },\n'astc-6x6-unorm-srgb': { },\n'astc-8x5-unorm': {\t16\t8 × 5 },\n'astc-8x5-unorm-srgb': { },\n'astc-8x6-unorm': {\t16\t8 × 6 },\n'astc-8x6-unorm-srgb': { },\n'astc-8x8-unorm': {\t16\t8 × 8 },\n'astc-8x8-unorm-srgb': { },\n'astc-10x5-unorm': {\t16\t10 × 5 },\n'astc-10x5-unorm-srgb': { },\n'astc-10x6-unorm': {\t16\t10 × 6 },\n'astc-10x6-unorm-srgb': { },\n'astc-10x8-unorm': {\t16\t10 × 8 },\n'astc-10x8-unorm-srgb': { },\n'astc-10x10-unorm': {\t16\t10 × 10 },\n'astc-10x10-unorm-srgb': { },\n'astc-12x10-unorm': {\t16\t12 × 10 },\n'astc-12x10-unorm-srgb': { },\n'astc-12x12-unorm': {\t16 },\n*/\n"],"mappings":"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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { VertexFormat, VertexType } from '../types/vertex-formats';
|
|
2
|
+
export type VertexFormatInfo = {
|
|
3
|
+
/** Length in bytes */
|
|
4
|
+
byteLength: number;
|
|
5
|
+
/** Type of each component */
|
|
6
|
+
type: VertexType;
|
|
7
|
+
/** Number of components per vertex / row */
|
|
8
|
+
components: 1 | 2 | 3 | 4;
|
|
9
|
+
/** Is this an integer format (normalized integer formats are not integer) */
|
|
10
|
+
integer: boolean;
|
|
11
|
+
/** Is this a signed format? */
|
|
12
|
+
signed: boolean;
|
|
13
|
+
/** Is this a normalized format? */
|
|
14
|
+
normalized: boolean;
|
|
15
|
+
/** Is this a webgl only format? */
|
|
16
|
+
webglOnly?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Decodes a vertex format, returning type, components, byte length and flags (integer, signed, normalized)
|
|
20
|
+
*/
|
|
21
|
+
export declare function decodeVertexFormat(format: VertexFormat): VertexFormatInfo;
|
|
22
|
+
//# sourceMappingURL=decode-vertex-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-vertex-format.d.ts","sourceRoot":"","sources":["../../../src/adapter/type-utils/decode-vertex-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,yBAAyB,CAAC;AAGjE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,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,mCAAmC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,CAyBzE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { decodeVertexType } from "./decode-data-type.js";
|
|
2
|
+
export function decodeVertexFormat(format) {
|
|
3
|
+
let webglOnly;
|
|
4
|
+
if (format.endsWith('-webgl')) {
|
|
5
|
+
format.replace('-webgl', '');
|
|
6
|
+
webglOnly = true;
|
|
7
|
+
}
|
|
8
|
+
const [type_, count] = format.split('x');
|
|
9
|
+
const type = type_;
|
|
10
|
+
const components = count ? parseInt(count) : 1;
|
|
11
|
+
const decodedType = decodeVertexType(type);
|
|
12
|
+
const result = {
|
|
13
|
+
type,
|
|
14
|
+
components,
|
|
15
|
+
byteLength: decodedType.byteLength * components,
|
|
16
|
+
integer: decodedType.integer,
|
|
17
|
+
signed: decodedType.signed,
|
|
18
|
+
normalized: decodedType.normalized
|
|
19
|
+
};
|
|
20
|
+
if (webglOnly) {
|
|
21
|
+
result.webglOnly = true;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=decode-vertex-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-vertex-format.js","names":["decodeVertexType","decodeVertexFormat","format","webglOnly","endsWith","replace","type_","count","split","type","components","parseInt","decodedType","result","byteLength","integer","signed","normalized"],"sources":["../../../src/adapter/type-utils/decode-vertex-format.ts"],"sourcesContent":["import {VertexFormat, VertexType} from '../types/vertex-formats';\nimport {decodeVertexType} from './decode-data-type';\n\nexport type VertexFormatInfo = {\n /** Length in bytes */\n byteLength: number;\n /** Type of each component */\n type: VertexType;\n /** Number of components per vertex / row */\n components: 1 | 2 | 3 | 4;\n /** Is this an integer format (normalized integer formats are not integer) */\n integer: boolean;\n /** Is this a signed format? */\n signed: boolean;\n /** Is this a normalized format? */\n normalized: boolean;\n /** Is this a webgl only format? */\n webglOnly?: boolean;\n};\n\n/**\n * Decodes a vertex format, returning type, components, byte length and flags (integer, signed, normalized)\n */\nexport function decodeVertexFormat(format: VertexFormat): VertexFormatInfo {\n // Strip the -webgl ending if present\n let webglOnly: boolean | undefined;\n if (format.endsWith('-webgl')) {\n format.replace('-webgl', '');\n webglOnly = true;\n }\n // split components from type\n const [type_, count] = format.split('x');\n const type = type_ as VertexType;\n const components = (count ? parseInt(count) : 1) as 1 | 2 | 3 | 4;\n // decode the type\n const decodedType = decodeVertexType(type);\n const result: VertexFormatInfo = {\n type,\n components,\n byteLength: decodedType.byteLength * components,\n integer: decodedType.integer,\n signed: decodedType.signed,\n normalized: decodedType.normalized\n };\n if (webglOnly) {\n result.webglOnly = true;\n }\n return result;\n}\n"],"mappings":"SACQA,gBAAgB;AAsBxB,OAAO,SAASC,kBAAkBA,CAACC,MAAoB,EAAoB;EAEzE,IAAIC,SAA8B;EAClC,IAAID,MAAM,CAACE,QAAQ,CAAC,QAAQ,CAAC,EAAE;IAC7BF,MAAM,CAACG,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC5BF,SAAS,GAAG,IAAI;EAClB;EAEA,MAAM,CAACG,KAAK,EAAEC,KAAK,CAAC,GAAGL,MAAM,CAACM,KAAK,CAAC,GAAG,CAAC;EACxC,MAAMC,IAAI,GAAGH,KAAmB;EAChC,MAAMI,UAAU,GAAIH,KAAK,GAAGI,QAAQ,CAACJ,KAAK,CAAC,GAAG,CAAmB;EAEjE,MAAMK,WAAW,GAAGZ,gBAAgB,CAACS,IAAI,CAAC;EAC1C,MAAMI,MAAwB,GAAG;IAC/BJ,IAAI;IACJC,UAAU;IACVI,UAAU,EAAEF,WAAW,CAACE,UAAU,GAAGJ,UAAU;IAC/CK,OAAO,EAAEH,WAAW,CAACG,OAAO;IAC5BC,MAAM,EAAEJ,WAAW,CAACI,MAAM;IAC1BC,UAAU,EAAEL,WAAW,CAACK;EAC1B,CAAC;EACD,IAAId,SAAS,EAAE;IACbU,MAAM,CAACV,SAAS,GAAG,IAAI;EACzB;EACA,OAAOU,MAAM;AACf"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TypedArray, TypedArrayConstructor } from '../..';
|
|
2
|
+
import { VertexFormat } from '../types/vertex-formats';
|
|
3
|
+
type DataType = 'uint8' | 'sint8' | 'uint16' | 'sint16' | 'uint32' | 'sint32' | 'float32';
|
|
4
|
+
type DataTypeNorm = 'unorm8' | 'snorm8' | 'unorm16' | 'snorm16';
|
|
5
|
+
export declare function getDataTypeFromTypedArray(arrayOrType: TypedArray | TypedArrayConstructor): DataType;
|
|
6
|
+
export declare function getTypedArrayFromDataType(dataType: DataType | DataTypeNorm): TypedArrayConstructor;
|
|
7
|
+
/** Get the vertex format for an attribute with TypedArray and size */
|
|
8
|
+
export declare function getVertexFormatFromAttribute(typedArray: TypedArray, size: number, normalized?: boolean): VertexFormat;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=vertex-format-from-attribute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vertex-format-from-attribute.d.ts","sourceRoot":"","sources":["../../../src/adapter/type-utils/vertex-format-from-attribute.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,qBAAqB,EAAC,MAAM,OAAO,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAIrD,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAC1F,KAAK,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAEhE,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,UAAU,GAAG,qBAAqB,GAC9C,QAAQ,CAsBV;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,QAAQ,GAAG,YAAY,GAChC,qBAAqB,CAwBvB;AAED,sEAAsE;AACtE,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,OAAO,GACnB,YAAY,CAkCd"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export function getDataTypeFromTypedArray(arrayOrType) {
|
|
2
|
+
const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
3
|
+
switch (type) {
|
|
4
|
+
case Float32Array:
|
|
5
|
+
return 'float32';
|
|
6
|
+
case Uint16Array:
|
|
7
|
+
return 'uint16';
|
|
8
|
+
case Uint32Array:
|
|
9
|
+
return 'uint32';
|
|
10
|
+
case Uint8Array:
|
|
11
|
+
case Uint8ClampedArray:
|
|
12
|
+
return 'uint8';
|
|
13
|
+
case Int8Array:
|
|
14
|
+
return 'sint8';
|
|
15
|
+
case Int16Array:
|
|
16
|
+
return 'sint16';
|
|
17
|
+
case Int32Array:
|
|
18
|
+
return 'sint32';
|
|
19
|
+
default:
|
|
20
|
+
throw new Error(type.constructor.name);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function getTypedArrayFromDataType(dataType) {
|
|
24
|
+
switch (dataType) {
|
|
25
|
+
case 'float32':
|
|
26
|
+
return Float32Array;
|
|
27
|
+
case 'uint32':
|
|
28
|
+
return Uint32Array;
|
|
29
|
+
case 'sint32':
|
|
30
|
+
return Int32Array;
|
|
31
|
+
case 'uint16':
|
|
32
|
+
case 'unorm16':
|
|
33
|
+
return Uint16Array;
|
|
34
|
+
case 'sint16':
|
|
35
|
+
case 'snorm16':
|
|
36
|
+
return Int16Array;
|
|
37
|
+
case 'uint8':
|
|
38
|
+
case 'unorm8':
|
|
39
|
+
return Uint8Array;
|
|
40
|
+
case 'sint8':
|
|
41
|
+
case 'snorm8':
|
|
42
|
+
return Int8Array;
|
|
43
|
+
default:
|
|
44
|
+
throw new Error(dataType);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function getVertexFormatFromAttribute(typedArray, size, normalized) {
|
|
48
|
+
if (!size || size > 4) {
|
|
49
|
+
throw new Error(`size ${size}`);
|
|
50
|
+
}
|
|
51
|
+
const components = size;
|
|
52
|
+
let dataType = getDataTypeFromTypedArray(typedArray);
|
|
53
|
+
if (dataType === 'uint8' || dataType === 'sint8') {
|
|
54
|
+
if (components === 1 || components === 3) {
|
|
55
|
+
throw new Error(`size: ${size}`);
|
|
56
|
+
}
|
|
57
|
+
if (normalized) {
|
|
58
|
+
dataType = dataType.replace('int', 'norm');
|
|
59
|
+
}
|
|
60
|
+
return `${dataType}x${components}`;
|
|
61
|
+
}
|
|
62
|
+
if (dataType === 'uint16' || dataType === 'sint16') {
|
|
63
|
+
if (components === 1 || components === 3) {
|
|
64
|
+
throw new Error(`size: ${size}`);
|
|
65
|
+
}
|
|
66
|
+
if (normalized) {
|
|
67
|
+
dataType = dataType.replace('int', 'norm');
|
|
68
|
+
}
|
|
69
|
+
return `${dataType}x${components}`;
|
|
70
|
+
}
|
|
71
|
+
if (components === 1) {
|
|
72
|
+
return dataType;
|
|
73
|
+
}
|
|
74
|
+
return `${dataType}x${components}`;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=vertex-format-from-attribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vertex-format-from-attribute.js","names":["getDataTypeFromTypedArray","arrayOrType","type","ArrayBuffer","isView","constructor","Float32Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray","Int8Array","Int16Array","Int32Array","Error","name","getTypedArrayFromDataType","dataType","getVertexFormatFromAttribute","typedArray","size","normalized","components","replace"],"sources":["../../../src/adapter/type-utils/vertex-format-from-attribute.ts"],"sourcesContent":["// luma.gl, MIT licese\nimport {TypedArray, TypedArrayConstructor} from '../..';\nimport {VertexFormat} from '../types/vertex-formats';\n\n// import {DataType} from '../types/vertex-formats';\n// type Omit<DataType, 'float16'> unfortunately breaks Typescript inferance\ntype DataType = 'uint8' | 'sint8' | 'uint16' | 'sint16' | 'uint32' | 'sint32' | 'float32';\ntype DataTypeNorm = 'unorm8' | 'snorm8' | 'unorm16' | 'snorm16';\n\nexport function getDataTypeFromTypedArray(\n arrayOrType: TypedArray | TypedArrayConstructor\n): DataType {\n const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;\n switch (type) {\n case Float32Array:\n return 'float32';\n case Uint16Array:\n return 'uint16';\n case Uint32Array:\n return 'uint32';\n case Uint8Array:\n case Uint8ClampedArray:\n return 'uint8';\n case Int8Array:\n return 'sint8';\n case Int16Array:\n return 'sint16';\n case Int32Array:\n return 'sint32';\n default:\n // Failed to deduce data type from typed array\n throw new Error(type.constructor.name);\n }\n}\n\nexport function getTypedArrayFromDataType(\n dataType: DataType | DataTypeNorm\n): TypedArrayConstructor {\n switch (dataType) {\n case 'float32':\n return Float32Array;\n case 'uint32':\n return Uint32Array;\n case 'sint32':\n return Int32Array;\n case 'uint16':\n case 'unorm16':\n return Uint16Array;\n case 'sint16':\n case 'snorm16':\n return Int16Array;\n case 'uint8':\n case 'unorm8':\n return Uint8Array;\n case 'sint8':\n case 'snorm8':\n return Int8Array;\n default:\n // Failed to deduce typed array from data type\n throw new Error(dataType);\n }\n}\n\n/** Get the vertex format for an attribute with TypedArray and size */\nexport function getVertexFormatFromAttribute(\n typedArray: TypedArray,\n size: number,\n normalized?: boolean\n): VertexFormat {\n if (!size || size > 4) {\n throw new Error(`size ${size}`);\n }\n\n const components = size as 1 | 2 | 3 | 4;\n let dataType: DataType | DataTypeNorm = getDataTypeFromTypedArray(typedArray);\n\n if (dataType === 'uint8' || dataType === 'sint8') {\n if (components === 1 || components === 3) {\n // WebGPU 8 bit formats must be aligned to 16 bit boundaries');\n throw new Error(`size: ${size}`);\n }\n if (normalized) {\n dataType = dataType.replace('int', 'norm') as 'unorm8' | 'snorm8';\n }\n return `${dataType}x${components}`;\n }\n if (dataType === 'uint16' || dataType === 'sint16') {\n if (components === 1 || components === 3) {\n // WebGPU 16 bit formats must be aligned to 32 bit boundaries\n throw new Error(`size: ${size}`);\n }\n if (normalized) {\n dataType = dataType.replace('int', 'norm') as 'unorm16' | 'snorm16';\n }\n return `${dataType}x${components}`;\n }\n\n if (components === 1) {\n return dataType;\n }\n\n return `${dataType}x${components}`;\n}\n"],"mappings":"AASA,OAAO,SAASA,yBAAyBA,CACvCC,WAA+C,EACrC;EACV,MAAMC,IAAI,GAAGC,WAAW,CAACC,MAAM,CAACH,WAAW,CAAC,GAAGA,WAAW,CAACI,WAAW,GAAGJ,WAAW;EACpF,QAAQC,IAAI;IACV,KAAKI,YAAY;MACf,OAAO,SAAS;IAClB,KAAKC,WAAW;MACd,OAAO,QAAQ;IACjB,KAAKC,WAAW;MACd,OAAO,QAAQ;IACjB,KAAKC,UAAU;IACf,KAAKC,iBAAiB;MACpB,OAAO,OAAO;IAChB,KAAKC,SAAS;MACZ,OAAO,OAAO;IAChB,KAAKC,UAAU;MACb,OAAO,QAAQ;IACjB,KAAKC,UAAU;MACb,OAAO,QAAQ;IACjB;MAEE,MAAM,IAAIC,KAAK,CAACZ,IAAI,CAACG,WAAW,CAACU,IAAI,CAAC;EAC1C;AACF;AAEA,OAAO,SAASC,yBAAyBA,CACvCC,QAAiC,EACV;EACvB,QAAQA,QAAQ;IACd,KAAK,SAAS;MACZ,OAAOX,YAAY;IACrB,KAAK,QAAQ;MACX,OAAOE,WAAW;IACpB,KAAK,QAAQ;MACX,OAAOK,UAAU;IACnB,KAAK,QAAQ;IACb,KAAK,SAAS;MACZ,OAAON,WAAW;IACpB,KAAK,QAAQ;IACb,KAAK,SAAS;MACZ,OAAOK,UAAU;IACnB,KAAK,OAAO;IACZ,KAAK,QAAQ;MACX,OAAOH,UAAU;IACnB,KAAK,OAAO;IACZ,KAAK,QAAQ;MACX,OAAOE,SAAS;IAClB;MAEE,MAAM,IAAIG,KAAK,CAACG,QAAQ,CAAC;EAC7B;AACF;AAGA,OAAO,SAASC,4BAA4BA,CAC1CC,UAAsB,EACtBC,IAAY,EACZC,UAAoB,EACN;EACd,IAAI,CAACD,IAAI,IAAIA,IAAI,GAAG,CAAC,EAAE;IACrB,MAAM,IAAIN,KAAK,CAAE,QAAOM,IAAK,EAAC,CAAC;EACjC;EAEA,MAAME,UAAU,GAAGF,IAAqB;EACxC,IAAIH,QAAiC,GAAGjB,yBAAyB,CAACmB,UAAU,CAAC;EAE7E,IAAIF,QAAQ,KAAK,OAAO,IAAIA,QAAQ,KAAK,OAAO,EAAE;IAChD,IAAIK,UAAU,KAAK,CAAC,IAAIA,UAAU,KAAK,CAAC,EAAE;MAExC,MAAM,IAAIR,KAAK,CAAE,SAAQM,IAAK,EAAC,CAAC;IAClC;IACA,IAAIC,UAAU,EAAE;MACdJ,QAAQ,GAAGA,QAAQ,CAACM,OAAO,CAAC,KAAK,EAAE,MAAM,CAAwB;IACnE;IACA,OAAQ,GAAEN,QAAS,IAAGK,UAAW,EAAC;EACpC;EACA,IAAIL,QAAQ,KAAK,QAAQ,IAAIA,QAAQ,KAAK,QAAQ,EAAE;IAClD,IAAIK,UAAU,KAAK,CAAC,IAAIA,UAAU,KAAK,CAAC,EAAE;MAExC,MAAM,IAAIR,KAAK,CAAE,SAAQM,IAAK,EAAC,CAAC;IAClC;IACA,IAAIC,UAAU,EAAE;MACdJ,QAAQ,GAAGA,QAAQ,CAACM,OAAO,CAAC,KAAK,EAAE,MAAM,CAA0B;IACrE;IACA,OAAQ,GAAEN,QAAS,IAAGK,UAAW,EAAC;EACpC;EAEA,IAAIA,UAAU,KAAK,CAAC,EAAE;IACpB,OAAOL,QAAQ;EACjB;EAEA,OAAQ,GAAEA,QAAS,IAAGK,UAAW,EAAC;AACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgsl-utils.d.ts","sourceRoot":"","sources":["../../../src/adapter/type-utils/wgsl-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAcnE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const WGSL_TYPE_ALIAS_MAP = {
|
|
2
|
+
vec2i: 'vec2<i32>',
|
|
3
|
+
vec3i: 'vec3<i32>',
|
|
4
|
+
vec4i: 'vec4<i32>',
|
|
5
|
+
vec2u: 'vec2<u32>',
|
|
6
|
+
vec3u: 'vec3<u32>',
|
|
7
|
+
vec4u: 'vec4<u32>',
|
|
8
|
+
vec2f: 'vec2<f32>',
|
|
9
|
+
vec3f: 'vec3<f32>',
|
|
10
|
+
vec4f: 'vec4<f32>',
|
|
11
|
+
vec2h: 'vec2<f16>',
|
|
12
|
+
vec3h: 'vec3<f16>',
|
|
13
|
+
vec4h: 'vec4<f16>'
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=wgsl-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgsl-utils.js","names":["WGSL_TYPE_ALIAS_MAP","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","vec2f","vec3f","vec4f","vec2h","vec3h","vec4h"],"sources":["../../../src/adapter/type-utils/wgsl-utils.ts"],"sourcesContent":["import { ShaderAttributeType } from '../types/shader-types';\n\n/** Predeclared aliases @see https://www.w3.org/TR/WGSL/#vector-types */\nexport const WGSL_TYPE_ALIAS_MAP: Record<string, ShaderAttributeType> = {\n vec2i: 'vec2<i32>',\n vec3i: 'vec3<i32>',\n vec4i: 'vec4<i32>',\n vec2u: 'vec2<u32>',\n vec3u: 'vec3<u32>',\n vec4u: 'vec4<u32>',\n vec2f: 'vec2<f32>',\n vec3f: 'vec3<f32>',\n vec4f: 'vec4<f32>',\n // Requires the f16 extension.\n vec2h: 'vec2<f16>',\n vec3h: 'vec3<f16>',\n vec4h: 'vec4<f16>',\n};\n"],"mappings":"AAGA,OAAO,MAAMA,mBAAwD,GAAG;EACtEC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE,WAAW;EAElBC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE;AACT,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Buffer } from '../resources/buffer';
|
|
2
|
+
/**
|
|
3
|
+
* Attribute descriptor object
|
|
4
|
+
* @deprecated Use ShaderLayout
|
|
5
|
+
*/
|
|
6
|
+
export interface AccessorObject {
|
|
7
|
+
buffer?: Buffer;
|
|
8
|
+
offset?: number;
|
|
9
|
+
stride?: number;
|
|
10
|
+
/** @deprecated - Use accessor.stepMode */
|
|
11
|
+
divisor?: number;
|
|
12
|
+
/** @deprecated - Infer from format */
|
|
13
|
+
type?: number;
|
|
14
|
+
/** @deprecated - Infer from format */
|
|
15
|
+
size?: number;
|
|
16
|
+
/** @deprecated - Infer from format */
|
|
17
|
+
normalized?: boolean;
|
|
18
|
+
/** @deprecated - Infer from format */
|
|
19
|
+
integer?: boolean;
|
|
20
|
+
/** @deprecated */
|
|
21
|
+
index?: number;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=accessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessor.d.ts","sourceRoot":"","sources":["../../../src/adapter/types/accessor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAKhD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,MAAM,CAAC,EAAE,MAAM,CAAC;IAIhB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sCAAsC;IACtC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,kBAAkB;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessor.js","names":[],"sources":["../../../src/adapter/types/accessor.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {Buffer} from '../resources/buffer';\n// import type {VertexFormat} from './data-formats';\n\n// ACCESSORS\n\n/**\n * Attribute descriptor object\n * @deprecated Use ShaderLayout\n */\nexport interface AccessorObject {\n buffer?: Buffer;\n // format: VertexFormat;\n offset?: number;\n // can now be described with single WebGPU-style `format` string\n\n // \n stride?: number;\n\n /** @deprecated - Use accessor.stepMode */\n divisor?: number;\n\n /** @deprecated - Infer from format */\n type?: number;\n /** @deprecated - Infer from format */\n size?: number;\n /** @deprecated - Infer from format */\n normalized?: boolean;\n /** @deprecated - Infer from format */\n integer?: boolean;\n\n /** @deprecated */\n index?: number;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { VertexFormat } from './vertex-formats';
|
|
2
|
+
/**
|
|
3
|
+
* Provides specific details about the memory layout of the actual buffers
|
|
4
|
+
* that will be provided to a `RenderPipeline`.
|
|
5
|
+
*
|
|
6
|
+
* BufferLayout lets the application describe whether
|
|
7
|
+
* - A single buffer can be used for multiple attributes (using interleaving or offsets),
|
|
8
|
+
* - The data format of the memory being supplied to a specific shader attribute.
|
|
9
|
+
*
|
|
10
|
+
* `BufferLayout` complements the "static" attribute declarations in a ShaderLayout
|
|
11
|
+
* with information about the "dynamic" memory layout of each buffer that will be bound
|
|
12
|
+
* to the render pipeline.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Specify memory layout for one buffer, describing how it is used by one or more attribute
|
|
16
|
+
* @note Specifies format, stride, offset and step mode
|
|
17
|
+
* @note The buffer can be set using the buffer name:`.setAttributes({[bufferName]: buffer})`.
|
|
18
|
+
* @note Needs to match type/components of the ShaderLayout ('f32', 'i32', 's32')
|
|
19
|
+
*
|
|
20
|
+
* A buffer layout is used to specify "non-standard" buffer layouts (buffers with offsets, interleaved buffers etc)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```
|
|
24
|
+
device.createRenderPipeline({
|
|
25
|
+
...
|
|
26
|
+
shaderLayout,
|
|
27
|
+
bufferLayout: [
|
|
28
|
+
{name: 'positions', stepMode: 'vertex', format: 'float32x3'},
|
|
29
|
+
// interleaved bindings, auto offset
|
|
30
|
+
{name: 'particles', stepMode: 'instance', byteStride: 32, attributes: [
|
|
31
|
+
{name: 'instancePositions', format: 'float32x4', byteOffset: 0},
|
|
32
|
+
{name: 'instanceVelocities', format: 'float32x4', byteOffset: 16}
|
|
33
|
+
]},
|
|
34
|
+
]
|
|
35
|
+
];
|
|
36
|
+
```
|
|
37
|
+
*/
|
|
38
|
+
export type BufferLayout = {
|
|
39
|
+
/** Name of buffer */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Is the attribute is instanced. Default: auto-deduced from shader name. */
|
|
42
|
+
stepMode?: 'vertex' | 'instance';
|
|
43
|
+
/** bytes between successive elements. If omitted, stride is set to reflect a "packed" buffer */
|
|
44
|
+
byteStride?: number;
|
|
45
|
+
/** Option 1: interleaved attributes that read from this buffer */
|
|
46
|
+
attributes?: BufferAttributeLayout[];
|
|
47
|
+
/** Option 2: Single attribute with same name as buffer. */
|
|
48
|
+
format?: VertexFormat;
|
|
49
|
+
};
|
|
50
|
+
/** Specifies how the GPU should read one specific attribute from a buffer. */
|
|
51
|
+
export type BufferAttributeLayout = {
|
|
52
|
+
/** Name of attribute that maps to a "view" of this buffer */
|
|
53
|
+
attribute: string;
|
|
54
|
+
/** Data format of the memory in the buffer that is mapped to this attribute */
|
|
55
|
+
format: VertexFormat;
|
|
56
|
+
/** Sum up any the "global" offset (or 0) and the offset each stride (for interleaved data). */
|
|
57
|
+
byteOffset: number;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=buffer-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/types/buffer-layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;;;;;;;;;IAuBI;AACJ,MAAM,MAAM,YAAY,GAAG;IACzB,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IACjC,gGAAgG;IAChG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,UAAU,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACrC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,qBAAqB,GAAG;IAClC,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,MAAM,EAAE,YAAY,CAAC;IACrB,+FAA+F;IAC/F,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-layout.js","names":[],"sources":["../../../src/adapter/types/buffer-layout.ts"],"sourcesContent":["import type {VertexFormat} from './vertex-formats';\n\n/** \n * Provides specific details about the memory layout of the actual buffers \n * that will be provided to a `RenderPipeline`.\n * \n * BufferLayout lets the application describe whether\n * - A single buffer can be used for multiple attributes (using interleaving or offsets), \n * - The data format of the memory being supplied to a specific shader attribute.\n * \n * `BufferLayout` complements the \"static\" attribute declarations in a ShaderLayout \n * with information about the \"dynamic\" memory layout of each buffer that will be bound \n * to the render pipeline.\n */\n\n/** \n * Specify memory layout for one buffer, describing how it is used by one or more attribute\n * @note Specifies format, stride, offset and step mode\n * @note The buffer can be set using the buffer name:`.setAttributes({[bufferName]: buffer})`.\n * @note Needs to match type/components of the ShaderLayout ('f32', 'i32', 's32')\n *\n * A buffer layout is used to specify \"non-standard\" buffer layouts (buffers with offsets, interleaved buffers etc)\n *\n * @example\n * ```\n device.createRenderPipeline({\n ...\n shaderLayout,\n bufferLayout: [\n {name: 'positions', stepMode: 'vertex', format: 'float32x3'},\n // interleaved bindings, auto offset\n {name: 'particles', stepMode: 'instance', byteStride: 32, attributes: [\n {name: 'instancePositions', format: 'float32x4', byteOffset: 0},\n {name: 'instanceVelocities', format: 'float32x4', byteOffset: 16}\n ]},\n ]\n ];\n ```\n */\nexport type BufferLayout = {\n /** Name of buffer */\n name: string;\n /** Is the attribute is instanced. Default: auto-deduced from shader name. */\n stepMode?: 'vertex' | 'instance';\n /** bytes between successive elements. If omitted, stride is set to reflect a \"packed\" buffer */\n byteStride?: number;\n /** Option 1: interleaved attributes that read from this buffer */\n attributes?: BufferAttributeLayout[];\n /** Option 2: Single attribute with same name as buffer. */\n format?: VertexFormat;\n};\n\n/** Specifies how the GPU should read one specific attribute from a buffer. */\nexport type BufferAttributeLayout = {\n /** Name of attribute that maps to a \"view\" of this buffer */\n attribute: string;\n /** Data format of the memory in the buffer that is mapped to this attribute */\n format: VertexFormat;\n /** Sum up any the \"global\" offset (or 0) and the offset each stride (for interleaved data). */\n byteOffset: number;\n};\n\n"],"mappings":""}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { DepthStencilTextureFormat } from './texture-formats';
|
|
2
|
+
export type CompareFunction = 'never' | 'less' | 'equal' | 'less-equal' | 'greater' | 'not-equal' | 'greater-equal' | 'always';
|
|
3
|
+
export type PrimitiveTopology = 'point-list' | 'line-list' | 'line-strip' |
|
|
4
|
+
/** @deprecated */
|
|
5
|
+
'line-loop-webgl' | 'triangle-list' | 'triangle-strip' |
|
|
6
|
+
/** @deprecated */
|
|
7
|
+
'triangle-fan-webgl';
|
|
8
|
+
export type IndexFormat = 'uint16' | 'uint32';
|
|
9
|
+
export type CullMode = 'none' | 'front' | 'back';
|
|
10
|
+
export type FrontFace = 'ccw' | 'cw';
|
|
11
|
+
type _RenderParameters = {
|
|
12
|
+
/** Defines which polygon orientation will be culled, if any. Only applies to triangle topologies/ */
|
|
13
|
+
cullMode?: CullMode;
|
|
14
|
+
/** Defines which polygons are considered front-facing. Only applies to triangle topologies. Default to "ccw" */
|
|
15
|
+
frontFace?: FrontFace;
|
|
16
|
+
/** TBD */
|
|
17
|
+
depthClamp?: boolean;
|
|
18
|
+
/** Constant depth bias (polygon offset) added to each fragment. */
|
|
19
|
+
depthBias?: number;
|
|
20
|
+
/** Depth bias (polygon offset) that scales with the fragment’s slope. */
|
|
21
|
+
depthBiasSlopeScale?: number;
|
|
22
|
+
/** Maximum depth bias of a fragment. */
|
|
23
|
+
depthBiasClamp?: number;
|
|
24
|
+
};
|
|
25
|
+
export type RasterizationParameters = _RenderParameters & {
|
|
26
|
+
/** The type of primitive to be constructed from the vertex inputs. Defaults to "triangle-list". */
|
|
27
|
+
topology?: PrimitiveTopology;
|
|
28
|
+
/** For pipelines with strip topologies ("line-strip" or "triangle-strip"), this determines the index buffer format and primitive restart value ("uint16"/0xFFFF or "uint32"/0xFFFFFFFF). It is not allowed on pipelines with non-strip topologies. */
|
|
29
|
+
stripIndexFormat?: IndexFormat;
|
|
30
|
+
};
|
|
31
|
+
/** Types of operations that can be performed on stencil buffers when various tests pass */
|
|
32
|
+
export type StencilOperation = 'keep' | 'zero' | 'replace' | 'invert' | 'increment-clamp' | 'decrement-clamp' | 'increment-wrap' | 'decrement-wrap';
|
|
33
|
+
export type DepthStencilParameters = {
|
|
34
|
+
/** Whether this GPURenderPipeline can modify depthStencilAttachment depth values. */
|
|
35
|
+
depthWriteEnabled?: boolean;
|
|
36
|
+
/** The comparison operation used to test fragment depths against existing depthStencilAttachment depth values. */
|
|
37
|
+
depthCompare?: CompareFunction;
|
|
38
|
+
/** The format of depthStencilAttachment this GPURenderPipeline will be compatible with. */
|
|
39
|
+
depthFormat?: DepthStencilTextureFormat;
|
|
40
|
+
/** Bitmask controlling which depthStencilAttachment stencil value bits are read when performing stencil comparison tests. */
|
|
41
|
+
stencilReadMask?: number;
|
|
42
|
+
/** Bitmask controlling which depthStencilAttachment stencil value bits are written to when performing stencil operations. */
|
|
43
|
+
stencilWriteMask?: number;
|
|
44
|
+
/** The CompareFunction used when testing fragments against depthStencilAttachment stencil values. */
|
|
45
|
+
stencilCompare?: CompareFunction;
|
|
46
|
+
/** The StencilOperation performed if the fragment stencil comparison test described by compare fails. */
|
|
47
|
+
stencilPassOperation?: StencilOperation;
|
|
48
|
+
/** The GPUStencilOperation performed if the fragment depth comparison described by depthCompare fails. */
|
|
49
|
+
stencilFailOperation?: StencilOperation;
|
|
50
|
+
/** The GPUStencilOperation performed if the fragment stencil comparison test described by compare passes. */
|
|
51
|
+
stencilDepthFailOperation?: StencilOperation;
|
|
52
|
+
};
|
|
53
|
+
/** BlendFactor defines how either a source or destination blend factors is calculated */
|
|
54
|
+
export type BlendFactor = 'zero' | 'one' | 'src-color' | 'one-minus-src-color' | 'src-alpha' | 'one-minus-src-alpha' | 'dst-color' | 'one-minus-dst-color' | 'dst-alpha' | 'one-minus-dst-alpha' | 'src-alpha-saturated' | 'blend-color' | 'one-minus-blend-color';
|
|
55
|
+
/** BlendOperation defines the algorithm used to combine source and destination blend factors: */
|
|
56
|
+
export type BlendOperation = 'add' | 'subtract' | 'reverse-subtract' | 'min' | 'max';
|
|
57
|
+
export type ColorParameters = {
|
|
58
|
+
/** Defines the operation used to calculate the values written to the target attachment components. */
|
|
59
|
+
blendColorOperation?: BlendOperation;
|
|
60
|
+
/** Defines the operation to be performed on values from the fragment shader. */
|
|
61
|
+
blendColorSrcFactor?: BlendFactor;
|
|
62
|
+
/** Defines the operation to be performed on values from the target attachment. */
|
|
63
|
+
blendColorDstFactor?: BlendFactor;
|
|
64
|
+
/** Defines the operation used to calculate the values written to the target attachment components. */
|
|
65
|
+
blendAlphaOperation?: BlendOperation;
|
|
66
|
+
/** Defines the operation to be performed on values from the fragment shader. */
|
|
67
|
+
blendAlphaSrcFactor?: BlendFactor;
|
|
68
|
+
/** Defines the operation to be performed on values from the target attachment. */
|
|
69
|
+
blendAlphaDstFactor?: BlendFactor;
|
|
70
|
+
/** Bitmask controlling which channels are are written to when drawing to this color target. defaulting to 0xF */
|
|
71
|
+
colorMask?: number;
|
|
72
|
+
};
|
|
73
|
+
/** Multisample */
|
|
74
|
+
export type MultisampleParameters = {
|
|
75
|
+
/** Number of samples per pixel. RenderPipeline will be compatible only with attachment textures with matching sampleCounts. */
|
|
76
|
+
sampleCount?: number;
|
|
77
|
+
/** Mask determining which samples are written to. defaulting to 0xFFFFFFFF */
|
|
78
|
+
sampleMask?: number;
|
|
79
|
+
/** When true indicates that a fragment’s alpha channel should be used to generate a sample coverage mask. */
|
|
80
|
+
sampleAlphaToCoverageEnabled?: boolean;
|
|
81
|
+
};
|
|
82
|
+
/** These parameters are set on the render pass and are thus easy to change frequently */
|
|
83
|
+
export type RenderPassParameters = {
|
|
84
|
+
/** Linear map from normalized device coordinates to viewport coordinates [x, y, width, height, minDepth, maxDepth] */
|
|
85
|
+
viewport?: number[];
|
|
86
|
+
/** Sets scissor rectangle used during rasterization. Discards fragments outside viewport coords [x, y, width, height]. */
|
|
87
|
+
scissorRect?: number[];
|
|
88
|
+
/** Sets constant blend color and alpha values used with "constant" and "one-minus-constant" blend factors. */
|
|
89
|
+
blendConstant?: number[];
|
|
90
|
+
/** Stencil operation "replace" sets the value to stencilReference */
|
|
91
|
+
stencilReference?: number;
|
|
92
|
+
};
|
|
93
|
+
export type RenderPipelineParameters = RasterizationParameters & DepthStencilParameters & ColorParameters & MultisampleParameters;
|
|
94
|
+
export type Parameters = _RenderParameters & DepthStencilParameters & ColorParameters & MultisampleParameters;
|
|
95
|
+
export declare const DEFAULT_PARAMETERS: Required<Parameters>;
|
|
96
|
+
export {};
|
|
97
|
+
//# sourceMappingURL=parameters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/types/parameters.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const DEFAULT_PARAMETERS = {
|
|
2
|
+
cullMode: 'none',
|
|
3
|
+
frontFace: 'ccw',
|
|
4
|
+
depthWriteEnabled: false,
|
|
5
|
+
depthCompare: 'always',
|
|
6
|
+
depthFormat: 'depth24plus',
|
|
7
|
+
depthClamp: false,
|
|
8
|
+
depthBias: 0,
|
|
9
|
+
depthBiasSlopeScale: 0,
|
|
10
|
+
depthBiasClamp: 0,
|
|
11
|
+
stencilReadMask: 0xFFFFFFFF,
|
|
12
|
+
stencilWriteMask: 0xFFFFFFFF,
|
|
13
|
+
stencilCompare: 'always',
|
|
14
|
+
stencilPassOperation: 'keep',
|
|
15
|
+
stencilFailOperation: 'keep',
|
|
16
|
+
stencilDepthFailOperation: 'keep',
|
|
17
|
+
sampleCount: 0,
|
|
18
|
+
sampleMask: 0xFFFFFFFF,
|
|
19
|
+
sampleAlphaToCoverageEnabled: false,
|
|
20
|
+
blendColorOperation: 'add',
|
|
21
|
+
blendColorSrcFactor: 'one',
|
|
22
|
+
blendColorDstFactor: 'zero',
|
|
23
|
+
blendAlphaOperation: 'add',
|
|
24
|
+
blendAlphaSrcFactor: 'one',
|
|
25
|
+
blendAlphaDstFactor: 'zero',
|
|
26
|
+
colorMask: 0xF
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters.js","names":["DEFAULT_PARAMETERS","cullMode","frontFace","depthWriteEnabled","depthCompare","depthFormat","depthClamp","depthBias","depthBiasSlopeScale","depthBiasClamp","stencilReadMask","stencilWriteMask","stencilCompare","stencilPassOperation","stencilFailOperation","stencilDepthFailOperation","sampleCount","sampleMask","sampleAlphaToCoverageEnabled","blendColorOperation","blendColorSrcFactor","blendColorDstFactor","blendAlphaOperation","blendAlphaSrcFactor","blendAlphaDstFactor","colorMask"],"sources":["../../../src/adapter/types/parameters.ts"],"sourcesContent":["import {DepthStencilTextureFormat} from './texture-formats';\n\nexport type CompareFunction =\n 'never' |\n 'less' |\n 'equal' |\n 'less-equal' |\n 'greater' |\n 'not-equal' |\n 'greater-equal' |\n 'always';\n\n// Primitive state\n\nexport type PrimitiveTopology =\n 'point-list' |\n 'line-list' |\n 'line-strip' |\n /** @deprecated */\n 'line-loop-webgl' |\n 'triangle-list' |\n 'triangle-strip' |\n /** @deprecated */\n 'triangle-fan-webgl';\n\nexport type IndexFormat = 'uint16' | 'uint32';\n\nexport type CullMode = 'none' | 'front' | 'back';\nexport type FrontFace = 'ccw' | 'cw';\n\n// Rasterization Parameters\n\ntype _RenderParameters = {\n /** Defines which polygon orientation will be culled, if any. Only applies to triangle topologies/ */\n cullMode?: CullMode;\n /** Defines which polygons are considered front-facing. Only applies to triangle topologies. Default to \"ccw\" */\n frontFace?: FrontFace;\n /** TBD */\n depthClamp?: boolean;\n /** Constant depth bias (polygon offset) added to each fragment. */\n depthBias?: number;\n /** Depth bias (polygon offset) that scales with the fragment’s slope. */\n depthBiasSlopeScale?: number;\n /** Maximum depth bias of a fragment. */\n depthBiasClamp?: number;\n}\n\nexport type RasterizationParameters = _RenderParameters & {\n /** The type of primitive to be constructed from the vertex inputs. Defaults to \"triangle-list\". */\n topology?: PrimitiveTopology;\n /** For pipelines with strip topologies (\"line-strip\" or \"triangle-strip\"), this determines the index buffer format and primitive restart value (\"uint16\"/0xFFFF or \"uint32\"/0xFFFFFFFF). It is not allowed on pipelines with non-strip topologies. */\n stripIndexFormat?: IndexFormat; // WebGPU only\n}\n\n// Depth Stencil Parameters\n\n/** Types of operations that can be performed on stencil buffers when various tests pass */\nexport type StencilOperation =\n 'keep' |\n 'zero' |\n 'replace' |\n 'invert' |\n 'increment-clamp' |\n 'decrement-clamp' |\n 'increment-wrap' |\n 'decrement-wrap';\n\nexport type DepthStencilParameters = {\n /** Whether this GPURenderPipeline can modify depthStencilAttachment depth values. */\n depthWriteEnabled?: boolean;\n /** The comparison operation used to test fragment depths against existing depthStencilAttachment depth values. */\n depthCompare?: CompareFunction;\n /** The format of depthStencilAttachment this GPURenderPipeline will be compatible with. */\n depthFormat?: DepthStencilTextureFormat;\n\n /** Bitmask controlling which depthStencilAttachment stencil value bits are read when performing stencil comparison tests. */\n stencilReadMask?: number;\n /** Bitmask controlling which depthStencilAttachment stencil value bits are written to when performing stencil operations. */\n stencilWriteMask?: number;\n\n /** The CompareFunction used when testing fragments against depthStencilAttachment stencil values. */\n stencilCompare?: CompareFunction;\n /** The StencilOperation performed if the fragment stencil comparison test described by compare fails. */\n stencilPassOperation?: StencilOperation;\n /** The GPUStencilOperation performed if the fragment depth comparison described by depthCompare fails. */\n stencilFailOperation?: StencilOperation;\n /** The GPUStencilOperation performed if the fragment stencil comparison test described by compare passes. */\n stencilDepthFailOperation?: StencilOperation;\n}\n\n// Color Parameters\n\n/** BlendFactor defines how either a source or destination blend factors is calculated */\nexport type BlendFactor =\n 'zero' |\n 'one' |\n 'src-color' |\n 'one-minus-src-color' |\n 'src-alpha' |\n 'one-minus-src-alpha' |\n 'dst-color' |\n 'one-minus-dst-color' |\n 'dst-alpha' |\n 'one-minus-dst-alpha' |\n 'src-alpha-saturated' |\n 'blend-color' |\n 'one-minus-blend-color';\n\n/** BlendOperation defines the algorithm used to combine source and destination blend factors: */\nexport type BlendOperation =\n 'add' |\n 'subtract' |\n 'reverse-subtract' |\n 'min' |\n 'max';\n\n/*\nexport const ColorWrite = {\n RED: 0x1,\n GREEN: 0x2,\n BLUE: 0x4,\n ALPHA: 0x8,\n ALL: 0xF\n};\n\nblend: {\n color: {operation, srcFactor, dstFactor}\n alpha: {operation, srcFactor, dstFactor}\n}\ncolorWriteMask\n\nrgba\nrgb\nrga\nrba\ngba\nrg\nrb\nra\ngb\nga\nba\nr\ng\nb\na\nnone\n*/\n\n/* Color parameters are set on the RenderPipeline */\nexport type ColorParameters = {\n /** Defines the operation used to calculate the values written to the target attachment components. */\n blendColorOperation?: BlendOperation;\n /** Defines the operation to be performed on values from the fragment shader. */\n blendColorSrcFactor?: BlendFactor;\n /** Defines the operation to be performed on values from the target attachment. */\n blendColorDstFactor?: BlendFactor;\n\n /** Defines the operation used to calculate the values written to the target attachment components. */\n blendAlphaOperation?: BlendOperation;\n /** Defines the operation to be performed on values from the fragment shader. */\n blendAlphaSrcFactor?: BlendFactor;\n /** Defines the operation to be performed on values from the target attachment. */\n blendAlphaDstFactor?: BlendFactor;\n\n /** Bitmask controlling which channels are are written to when drawing to this color target. defaulting to 0xF */\n colorMask?: number;\n}\n\n/** Multisample */\nexport type MultisampleParameters = {\n /** Number of samples per pixel. RenderPipeline will be compatible only with attachment textures with matching sampleCounts. */\n sampleCount?: number; // = 1;\n /** Mask determining which samples are written to. defaulting to 0xFFFFFFFF */\n sampleMask?: number; \n /** When true indicates that a fragment’s alpha channel should be used to generate a sample coverage mask. */\n sampleAlphaToCoverageEnabled?: boolean; // = false;\n};\n\n/** These parameters are set on the render pass and are thus easy to change frequently */\nexport type RenderPassParameters = {\n /** Linear map from normalized device coordinates to viewport coordinates [x, y, width, height, minDepth, maxDepth] */\n viewport?: number[]; \n /** Sets scissor rectangle used during rasterization. Discards fragments outside viewport coords [x, y, width, height]. */\n scissorRect?: number[]; // ;\n /** Sets constant blend color and alpha values used with \"constant\" and \"one-minus-constant\" blend factors. */\n blendConstant?: number[]; // GPUColor\n /** Stencil operation \"replace\" sets the value to stencilReference */\n stencilReference?: number; // GPUStencilValue\n};\n\nexport type RenderPipelineParameters =\n RasterizationParameters &\n DepthStencilParameters &\n ColorParameters &\n MultisampleParameters;\n\nexport type Parameters =\n _RenderParameters &\n DepthStencilParameters &\n ColorParameters &\n MultisampleParameters;\n\n// export const DEFAULT_PARAMETERS: Parameters;\n\nexport const DEFAULT_PARAMETERS: Required<Parameters> = {\n\n // Rasterization Parameters\n\n cullMode: 'none',\n frontFace: 'ccw',\n\n // Depth Parameters\n\n depthWriteEnabled: false,\n depthCompare: 'always',\n depthFormat: 'depth24plus',\n\n depthClamp: false,\n depthBias: 0,\n depthBiasSlopeScale: 0,\n depthBiasClamp: 0,\n\n // Stencil parameters\n\n stencilReadMask: 0xFFFFFFFF,\n stencilWriteMask: 0xFFFFFFFF,\n\n stencilCompare: 'always',\n stencilPassOperation: 'keep',\n stencilFailOperation: 'keep',\n stencilDepthFailOperation: 'keep',\n\n // Multisample parameters\n sampleCount: 0,\n sampleMask: 0xFFFFFFFF,\n sampleAlphaToCoverageEnabled: false,\n\n // Color and blend parameters\n\n blendColorOperation: 'add',\n blendColorSrcFactor: 'one',\n blendColorDstFactor: 'zero',\n\n blendAlphaOperation: 'add',\n blendAlphaSrcFactor: 'one',\n blendAlphaDstFactor: 'zero',\n\n colorMask: 0xF\n};\n"],"mappings":"AA6MA,OAAO,MAAMA,kBAAwC,GAAG;EAItDC,QAAQ,EAAE,MAAM;EAChBC,SAAS,EAAE,KAAK;EAIhBC,iBAAiB,EAAE,KAAK;EACxBC,YAAY,EAAE,QAAQ;EACtBC,WAAW,EAAE,aAAa;EAE1BC,UAAU,EAAE,KAAK;EACjBC,SAAS,EAAE,CAAC;EACZC,mBAAmB,EAAE,CAAC;EACtBC,cAAc,EAAE,CAAC;EAIjBC,eAAe,EAAE,UAAU;EAC3BC,gBAAgB,EAAE,UAAU;EAE5BC,cAAc,EAAE,QAAQ;EACxBC,oBAAoB,EAAE,MAAM;EAC5BC,oBAAoB,EAAE,MAAM;EAC5BC,yBAAyB,EAAE,MAAM;EAGjCC,WAAW,EAAE,CAAC;EACdC,UAAU,EAAE,UAAU;EACtBC,4BAA4B,EAAE,KAAK;EAInCC,mBAAmB,EAAE,KAAK;EAC1BC,mBAAmB,EAAE,KAAK;EAC1BC,mBAAmB,EAAE,MAAM;EAE3BC,mBAAmB,EAAE,KAAK;EAC1BC,mBAAmB,EAAE,KAAK;EAC1BC,mBAAmB,EAAE,MAAM;EAE3BC,SAAS,EAAE;AACb,CAAC"}
|