@luma.gl/core 9.0.0-beta.4 → 9.0.0-beta.5
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/attribute-utils/get-attribute-from-layouts.js +140 -109
- package/dist/adapter/canvas-context.js +305 -233
- package/dist/adapter/device.d.ts +9 -11
- package/dist/adapter/device.d.ts.map +1 -1
- package/dist/adapter/device.js +114 -95
- package/dist/adapter/resources/buffer.d.ts +1 -1
- package/dist/adapter/resources/buffer.d.ts.map +1 -1
- package/dist/adapter/resources/buffer.js +65 -57
- package/dist/adapter/resources/command-buffer.js +13 -13
- package/dist/adapter/resources/command-encoder.js +17 -17
- package/dist/adapter/resources/compute-pass.js +10 -13
- package/dist/adapter/resources/compute-pipeline.js +19 -18
- package/dist/adapter/resources/external-texture.js +10 -15
- package/dist/adapter/resources/framebuffer.js +155 -94
- package/dist/adapter/resources/render-pass.js +28 -21
- package/dist/adapter/resources/render-pipeline.d.ts +3 -1
- package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/render-pipeline.js +37 -34
- package/dist/adapter/resources/resource.js +131 -93
- package/dist/adapter/resources/sampler.js +24 -24
- package/dist/adapter/resources/shader.d.ts +2 -2
- package/dist/adapter/resources/shader.d.ts.map +1 -1
- package/dist/adapter/resources/shader.js +90 -78
- package/dist/adapter/resources/texture.js +49 -43
- package/dist/adapter/resources/transform-feedback.d.ts +2 -2
- package/dist/adapter/resources/transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/transform-feedback.js +13 -15
- package/dist/adapter/resources/vertex-array.js +30 -22
- package/dist/adapter/type-utils/decode-attribute-type.js +56 -52
- package/dist/adapter/type-utils/decode-data-type.js +36 -35
- package/dist/adapter/type-utils/decode-shader-types.js +36 -97
- package/dist/adapter/type-utils/decode-texture-format.js +160 -93
- package/dist/adapter/type-utils/decode-vertex-format.js +28 -23
- package/dist/adapter/type-utils/vertex-format-from-attribute.js +69 -65
- package/dist/adapter/type-utils/wgsl-utils.js +14 -13
- package/dist/adapter/types/accessor.js +0 -1
- package/dist/adapter/types/buffer-layout.js +0 -1
- package/dist/adapter/types/parameters.js +31 -26
- package/dist/adapter/types/shader-layout.js +0 -1
- package/dist/adapter/types/shader-types.js +2 -1
- package/dist/adapter/types/texture-formats.d.ts +1 -1
- package/dist/adapter/types/texture-formats.d.ts.map +1 -1
- package/dist/adapter/types/texture-formats.js +2 -1
- package/dist/adapter/types/types.js +0 -1
- package/dist/adapter/types/vertex-formats.js +2 -1
- package/dist/dist.dev.js +453 -270
- package/dist/index.cjs +66 -168
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -46
- package/dist/init.js +29 -19
- package/dist/lib/compiler-log/compiler-message.js +2 -1
- package/dist/lib/compiler-log/format-compiler-log.js +66 -48
- package/dist/lib/compiler-log/get-shader-info.js +22 -19
- package/dist/lib/luma.d.ts.map +1 -1
- package/dist/lib/luma.js +60 -55
- package/dist/lib/uniforms/uniform-block.d.ts +0 -1
- package/dist/lib/uniforms/uniform-block.d.ts.map +1 -1
- package/dist/lib/uniforms/uniform-block.js +50 -43
- package/dist/lib/uniforms/uniform-buffer-layout.js +87 -70
- package/dist/lib/uniforms/uniform-store.js +112 -79
- package/dist/lib/uniforms/uniform.js +13 -16
- package/dist/types.js +1 -3
- package/dist/utils/array-equal.js +25 -23
- package/dist/utils/array-utils-flat.js +28 -28
- package/dist/utils/assert.js +5 -4
- package/dist/utils/cast.js +2 -2
- package/dist/utils/check-props.js +28 -27
- package/dist/utils/deep-equal.js +39 -32
- package/dist/utils/format-value.js +33 -39
- package/dist/utils/is-array.js +17 -6
- package/dist/utils/load-file.js +62 -37
- package/dist/utils/log.js +2 -4
- package/dist/utils/random.js +10 -9
- package/dist/utils/request-animation-frame.js +9 -3
- package/dist/utils/stats-manager.js +13 -14
- package/dist/utils/stub-methods.js +13 -13
- package/dist/utils/utils.d.ts +0 -6
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +20 -15
- package/dist.min.js +8 -23
- package/package.json +6 -6
- package/src/adapter/device.ts +38 -59
- package/src/adapter/resources/buffer.ts +1 -1
- package/src/adapter/resources/render-pipeline.ts +3 -1
- package/src/adapter/resources/shader.ts +2 -2
- package/src/adapter/resources/transform-feedback.ts +2 -2
- package/src/adapter/types/texture-formats.ts +1 -1
- package/src/index.ts +1 -1
- package/src/lib/luma.ts +0 -2
- package/src/lib/uniforms/uniform-block.ts +0 -1
- package/src/utils/utils.ts +0 -9
- package/dist/adapter/attribute-utils/get-attribute-from-layouts.js.map +0 -1
- package/dist/adapter/canvas-context.js.map +0 -1
- package/dist/adapter/device.js.map +0 -1
- package/dist/adapter/resources/buffer.js.map +0 -1
- package/dist/adapter/resources/command-buffer.js.map +0 -1
- package/dist/adapter/resources/command-encoder.js.map +0 -1
- package/dist/adapter/resources/compute-pass.js.map +0 -1
- package/dist/adapter/resources/compute-pipeline.js.map +0 -1
- package/dist/adapter/resources/external-texture.js.map +0 -1
- package/dist/adapter/resources/framebuffer.js.map +0 -1
- package/dist/adapter/resources/render-pass.js.map +0 -1
- package/dist/adapter/resources/render-pipeline.js.map +0 -1
- package/dist/adapter/resources/resource.js.map +0 -1
- package/dist/adapter/resources/sampler.js.map +0 -1
- package/dist/adapter/resources/shader.js.map +0 -1
- package/dist/adapter/resources/texture.js.map +0 -1
- package/dist/adapter/resources/transform-feedback.js.map +0 -1
- package/dist/adapter/resources/vertex-array.js.map +0 -1
- package/dist/adapter/type-utils/decode-attribute-type.js.map +0 -1
- package/dist/adapter/type-utils/decode-data-type.js.map +0 -1
- package/dist/adapter/type-utils/decode-shader-types.js.map +0 -1
- package/dist/adapter/type-utils/decode-texture-format.js.map +0 -1
- package/dist/adapter/type-utils/decode-vertex-format.js.map +0 -1
- package/dist/adapter/type-utils/vertex-format-from-attribute.js.map +0 -1
- package/dist/adapter/type-utils/wgsl-utils.js.map +0 -1
- package/dist/adapter/types/accessor.js.map +0 -1
- package/dist/adapter/types/buffer-layout.js.map +0 -1
- package/dist/adapter/types/parameters.js.map +0 -1
- package/dist/adapter/types/shader-layout.js.map +0 -1
- package/dist/adapter/types/shader-types.js.map +0 -1
- package/dist/adapter/types/texture-formats.js.map +0 -1
- package/dist/adapter/types/types.js.map +0 -1
- package/dist/adapter/types/vertex-formats.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/init.js.map +0 -1
- package/dist/lib/compiler-log/compiler-message.js.map +0 -1
- package/dist/lib/compiler-log/format-compiler-log.js.map +0 -1
- package/dist/lib/compiler-log/get-shader-info.js.map +0 -1
- package/dist/lib/luma.js.map +0 -1
- package/dist/lib/uniforms/uniform-block.js.map +0 -1
- package/dist/lib/uniforms/uniform-buffer-layout.js.map +0 -1
- package/dist/lib/uniforms/uniform-store.js.map +0 -1
- package/dist/lib/uniforms/uniform.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/array-equal.js.map +0 -1
- package/dist/utils/array-utils-flat.js.map +0 -1
- package/dist/utils/assert.js.map +0 -1
- package/dist/utils/cast.js.map +0 -1
- package/dist/utils/check-props.js.map +0 -1
- package/dist/utils/deep-equal.js.map +0 -1
- package/dist/utils/format-value.js.map +0 -1
- package/dist/utils/is-array.js.map +0 -1
- package/dist/utils/load-file.js.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/random.js.map +0 -1
- package/dist/utils/request-animation-frame.js.map +0 -1
- package/dist/utils/stats-manager.js.map +0 -1
- package/dist/utils/stub-methods.js.map +0 -1
- package/dist/utils/utils.js.map +0 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
import { Resource } from './resource';
|
|
4
|
+
/** Immutable Sampler object */
|
|
4
5
|
export class Sampler extends Resource {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
static defaultProps = {
|
|
7
|
+
...Resource.defaultProps,
|
|
8
|
+
type: 'color-sampler',
|
|
9
|
+
addressModeU: 'clamp-to-edge',
|
|
10
|
+
addressModeV: 'clamp-to-edge',
|
|
11
|
+
addressModeW: 'clamp-to-edge',
|
|
12
|
+
magFilter: 'nearest',
|
|
13
|
+
minFilter: 'nearest',
|
|
14
|
+
mipmapFilter: 'nearest',
|
|
15
|
+
lodMinClamp: 0,
|
|
16
|
+
lodMaxClamp: 32, // Per WebGPU spec
|
|
17
|
+
compare: 'less-equal',
|
|
18
|
+
maxAnisotropy: 1
|
|
19
|
+
};
|
|
20
|
+
get [Symbol.toStringTag]() {
|
|
21
|
+
return 'Sampler';
|
|
22
|
+
}
|
|
23
|
+
constructor(device, props) {
|
|
24
|
+
super(device, props, Sampler.defaultProps);
|
|
25
|
+
}
|
|
11
26
|
}
|
|
12
|
-
Sampler.defaultProps = {
|
|
13
|
-
...Resource.defaultProps,
|
|
14
|
-
type: 'color-sampler',
|
|
15
|
-
addressModeU: 'clamp-to-edge',
|
|
16
|
-
addressModeV: 'clamp-to-edge',
|
|
17
|
-
addressModeW: 'clamp-to-edge',
|
|
18
|
-
magFilter: 'nearest',
|
|
19
|
-
minFilter: 'nearest',
|
|
20
|
-
mipmapFilter: 'nearest',
|
|
21
|
-
lodMinClamp: 0,
|
|
22
|
-
lodMaxClamp: 32,
|
|
23
|
-
compare: 'less-equal',
|
|
24
|
-
maxAnisotropy: 1
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=sampler.js.map
|
|
@@ -29,8 +29,8 @@ export declare abstract class Shader extends Resource<ShaderProps> {
|
|
|
29
29
|
readonly stage: 'vertex' | 'fragment' | 'compute';
|
|
30
30
|
/** The source code of this shader */
|
|
31
31
|
readonly source: string;
|
|
32
|
-
/** The compilation status of
|
|
33
|
-
compilationStatus: '
|
|
32
|
+
/** The compilation status of the shader. 'pending' if compilation is asynchronous, and on production */
|
|
33
|
+
compilationStatus: 'pending' | 'success' | 'error';
|
|
34
34
|
/** Create a new Shader instance */
|
|
35
35
|
constructor(device: Device, props: ShaderProps);
|
|
36
36
|
/** Get compiler log asynchronously */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/shader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAC,eAAe,EAAC,MAAM,yCAAyC,CAAC;AAIxE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG;IACxC,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACpC,0EAA0E;IAC1E,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IACzC,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;CACpD,CAAC;AAEF;;;GAGG;AACH,8BAAsB,MAAO,SAAQ,QAAQ,CAAC,WAAW,CAAC;IACxD,OAAgB,YAAY,EAAE,QAAQ,CAAC,WAAW,CAAC,CAQjD;IAEF,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;IAED,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IAClD,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,
|
|
1
|
+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eAAe,EAAE,CAAC;IAElE,kDAAkD;IAClD,sBAAsB,IAAI,SAAS,eAAe,EAAE,GAAG,IAAI;IAM3D,mCAAmC;IAC7B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBlC,sCAAsC;IACtC,SAAS,CAAC,iBAAiB,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,GAAG,IAAI;CAuCxE"}
|
|
@@ -1,90 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { uid } from
|
|
4
|
-
import { formatCompilerLog } from
|
|
5
|
-
import { getShaderInfo } from
|
|
6
|
-
|
|
1
|
+
import { Resource } from './resource';
|
|
2
|
+
// import { log } from '../../utils/log';
|
|
3
|
+
import { uid } from '../../utils/utils';
|
|
4
|
+
import { formatCompilerLog } from '../../lib/compiler-log/format-compiler-log';
|
|
5
|
+
import { getShaderInfo } from '../../lib/compiler-log/get-shader-info';
|
|
6
|
+
/**
|
|
7
|
+
* Immutable Shader object
|
|
8
|
+
* In WebGPU the handle can be copied between threads
|
|
9
|
+
*/
|
|
7
10
|
export class Shader extends Resource {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.stage = this.props.stage;
|
|
20
|
-
this.source = this.props.source;
|
|
21
|
-
}
|
|
22
|
-
getCompilationInfoSync() {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
async debugShader() {
|
|
26
|
-
switch (this.props.debug) {
|
|
27
|
-
case 'never':
|
|
28
|
-
return;
|
|
29
|
-
case 'errors':
|
|
30
|
-
if (this.compilationStatus === 'success') {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
break;
|
|
34
|
-
case 'warnings':
|
|
35
|
-
case 'always':
|
|
36
|
-
break;
|
|
11
|
+
static defaultProps = {
|
|
12
|
+
...Resource.defaultProps,
|
|
13
|
+
language: 'auto',
|
|
14
|
+
stage: 'vertex',
|
|
15
|
+
source: '',
|
|
16
|
+
sourceMap: null,
|
|
17
|
+
entryPoint: 'main',
|
|
18
|
+
debug: 'errors'
|
|
19
|
+
};
|
|
20
|
+
get [Symbol.toStringTag]() {
|
|
21
|
+
return 'Shader';
|
|
37
22
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
/** The stage of this shader */
|
|
24
|
+
stage;
|
|
25
|
+
/** The source code of this shader */
|
|
26
|
+
source;
|
|
27
|
+
/** The compilation status of the shader. 'pending' if compilation is asynchronous, and on production */
|
|
28
|
+
compilationStatus = 'pending';
|
|
29
|
+
/** Create a new Shader instance */
|
|
30
|
+
constructor(device, props) {
|
|
31
|
+
super(device, { id: getShaderIdFromProps(props), ...props }, Shader.defaultProps);
|
|
32
|
+
this.stage = this.props.stage;
|
|
33
|
+
this.source = this.props.source;
|
|
41
34
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
/** Get compiler log synchronously (WebGL only) */
|
|
36
|
+
getCompilationInfoSync() {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
// PORTABLE HELPERS
|
|
40
|
+
/** In browser logging of errors */
|
|
41
|
+
async debugShader() {
|
|
42
|
+
switch (this.props.debug) {
|
|
43
|
+
case 'never':
|
|
44
|
+
return;
|
|
45
|
+
case 'errors':
|
|
46
|
+
// On WebGL - Don't extract the log unless errors
|
|
47
|
+
if (this.compilationStatus === 'success') {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
case 'warnings':
|
|
52
|
+
case 'always':
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
const messages = await this.getCompilationInfo();
|
|
56
|
+
if (this.props.debug === 'warnings' && messages?.length === 0) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this._displayShaderLog(messages);
|
|
48
60
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
// PRIVATE
|
|
62
|
+
/** In-browser UI logging of errors */
|
|
63
|
+
_displayShaderLog(messages) {
|
|
64
|
+
// Return if under Node.js / incomplete `document` polyfills
|
|
65
|
+
if (typeof document === 'undefined' || !document?.createElement) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const shaderName = getShaderInfo(this.source).name;
|
|
69
|
+
const shaderTitle = `${this.stage} ${shaderName}`;
|
|
70
|
+
const htmlLog = formatCompilerLog(messages, this.source, { showSourceCode: 'all', html: true });
|
|
71
|
+
// Make it clickable so we can copy to clipboard
|
|
72
|
+
const button = document.createElement('Button');
|
|
73
|
+
button.innerHTML = `
|
|
57
74
|
<h1>Shader Compilation Error in ${shaderTitle}</h1><br /><br />
|
|
58
75
|
<code style="user-select:text;"><pre>
|
|
59
76
|
${htmlLog}
|
|
60
77
|
</pre></code>`;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
button.style.top = '10px';
|
|
79
|
+
button.style.left = '10px';
|
|
80
|
+
button.style.position = 'absolute';
|
|
81
|
+
button.style.zIndex = '9999';
|
|
82
|
+
button.style.width = '100%';
|
|
83
|
+
button.style.textAlign = 'left';
|
|
84
|
+
document.body.appendChild(button);
|
|
85
|
+
const errors = document.getElementsByClassName('luma-compiler-log-error');
|
|
86
|
+
if (errors[0]?.scrollIntoView) {
|
|
87
|
+
errors[0].scrollIntoView();
|
|
88
|
+
}
|
|
89
|
+
// TODO - add a small embedded copy button (instead of main button)
|
|
90
|
+
button.onclick = () => {
|
|
91
|
+
// const source = this.source.replaceAll('\n', '<br />');
|
|
92
|
+
const dataURI = `data:text/plain,${encodeURIComponent(this.source)}`;
|
|
93
|
+
navigator.clipboard.writeText(dataURI);
|
|
94
|
+
};
|
|
95
|
+
// TODO - add a small embedded close button
|
|
71
96
|
}
|
|
72
|
-
button.onclick = () => {
|
|
73
|
-
const dataURI = `data:text/plain,${encodeURIComponent(this.source)}`;
|
|
74
|
-
navigator.clipboard.writeText(dataURI);
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
97
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
language: 'auto',
|
|
81
|
-
stage: 'vertex',
|
|
82
|
-
source: '',
|
|
83
|
-
sourceMap: null,
|
|
84
|
-
entryPoint: 'main',
|
|
85
|
-
debug: 'errors'
|
|
86
|
-
};
|
|
98
|
+
// HELPERS
|
|
99
|
+
/** Deduce an id, from shader source, or supplied id, or shader type */
|
|
87
100
|
function getShaderIdFromProps(props) {
|
|
88
|
-
|
|
101
|
+
return getShaderInfo(props.source).name || props.id || uid(`unnamed ${props.stage}-shader`);
|
|
89
102
|
}
|
|
90
|
-
//# sourceMappingURL=shader.js.map
|
|
@@ -1,45 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Resource } from './resource';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract Texture interface
|
|
4
|
+
* Texture Object
|
|
5
|
+
* https://gpuweb.github.io/gpuweb/#gputexture
|
|
6
|
+
*/
|
|
4
7
|
export class Texture extends Resource {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
static defaultProps = {
|
|
9
|
+
...Resource.defaultProps,
|
|
10
|
+
data: null,
|
|
11
|
+
dimension: '2d',
|
|
12
|
+
format: 'rgba8unorm',
|
|
13
|
+
width: undefined,
|
|
14
|
+
height: undefined,
|
|
15
|
+
depth: 1,
|
|
16
|
+
mipmaps: true,
|
|
17
|
+
sampler: {},
|
|
18
|
+
// type: undefined,
|
|
19
|
+
compressed: false,
|
|
20
|
+
// mipLevels: 1,
|
|
21
|
+
usage: 0,
|
|
22
|
+
// usage: GPUTextureUsage.COPY_DST
|
|
23
|
+
mipLevels: undefined,
|
|
24
|
+
samples: undefined,
|
|
25
|
+
type: undefined
|
|
26
|
+
};
|
|
27
|
+
static COPY_SRC = 0x01;
|
|
28
|
+
static COPY_DST = 0x02;
|
|
29
|
+
static TEXTURE_BINDING = 0x04;
|
|
30
|
+
static STORAGE_BINDING = 0x08;
|
|
31
|
+
static RENDER_ATTACHMENT = 0x10;
|
|
32
|
+
get [Symbol.toStringTag]() { return 'Texture'; }
|
|
33
|
+
/** dimension of this texture */
|
|
34
|
+
dimension;
|
|
35
|
+
/** format of this texture */
|
|
36
|
+
format;
|
|
37
|
+
/** width in pixels of this texture */
|
|
38
|
+
width;
|
|
39
|
+
/** height in pixels of this texture */
|
|
40
|
+
height;
|
|
41
|
+
/** depth of this texture */
|
|
42
|
+
depth;
|
|
43
|
+
constructor(device, props, defaultProps = Texture.defaultProps) {
|
|
44
|
+
super(device, props, defaultProps);
|
|
45
|
+
this.dimension = this.props.dimension;
|
|
46
|
+
this.format = this.props.format;
|
|
47
|
+
this.width = this.props.width;
|
|
48
|
+
this.height = this.props.height;
|
|
49
|
+
this.depth = this.props.depth;
|
|
50
|
+
}
|
|
23
51
|
}
|
|
24
|
-
Texture.defaultProps = {
|
|
25
|
-
...Resource.defaultProps,
|
|
26
|
-
data: null,
|
|
27
|
-
dimension: '2d',
|
|
28
|
-
format: 'rgba8unorm',
|
|
29
|
-
width: undefined,
|
|
30
|
-
height: undefined,
|
|
31
|
-
depth: 1,
|
|
32
|
-
mipmaps: true,
|
|
33
|
-
sampler: {},
|
|
34
|
-
compressed: false,
|
|
35
|
-
usage: 0,
|
|
36
|
-
mipLevels: undefined,
|
|
37
|
-
samples: undefined,
|
|
38
|
-
type: undefined
|
|
39
|
-
};
|
|
40
|
-
Texture.COPY_SRC = 0x01;
|
|
41
|
-
Texture.COPY_DST = 0x02;
|
|
42
|
-
Texture.TEXTURE_BINDING = 0x04;
|
|
43
|
-
Texture.STORAGE_BINDING = 0x08;
|
|
44
|
-
Texture.RENDER_ATTACHMENT = 0x10;
|
|
45
|
-
//# sourceMappingURL=texture.js.map
|
|
@@ -9,14 +9,14 @@ export type BufferRange = {
|
|
|
9
9
|
byteOffset?: number;
|
|
10
10
|
byteLength?: number;
|
|
11
11
|
};
|
|
12
|
-
/** Configures a set of output buffers for pipeline (WebGL
|
|
12
|
+
/** Configures a set of output buffers for pipeline (WebGL only) */
|
|
13
13
|
export type TransformFeedbackProps = ResourceProps & {
|
|
14
14
|
/** Layout of shader (for varyings) */
|
|
15
15
|
layout: ShaderLayout;
|
|
16
16
|
/** Buffer bindings (for varyings) */
|
|
17
17
|
buffers: Record<string, Buffer | BufferRange>;
|
|
18
18
|
};
|
|
19
|
-
/** Holds a set of output buffers for pipeline (WebGL
|
|
19
|
+
/** Holds a set of output buffers for pipeline (WebGL only) */
|
|
20
20
|
export declare abstract class TransformFeedback extends Resource<TransformFeedbackProps> {
|
|
21
21
|
static defaultProps: Required<TransformFeedbackProps>;
|
|
22
22
|
get [Symbol.toStringTag](): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-feedback.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/transform-feedback.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AACrC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,C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QAAQ,CAAC,GAAG,IAAI,IAAI;IAEpB,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC,GAAG,IAAI;IACxE,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAC9F,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,IAAI;CACjF"}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
_Symbol$toStringTag = Symbol.toStringTag;
|
|
1
|
+
import { Resource } from './resource';
|
|
2
|
+
/** Holds a set of output buffers for pipeline (WebGL only) */
|
|
4
3
|
export class TransformFeedback extends Resource {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
static defaultProps = {
|
|
5
|
+
...Resource.defaultProps,
|
|
6
|
+
layout: undefined,
|
|
7
|
+
buffers: {}
|
|
8
|
+
};
|
|
9
|
+
get [Symbol.toStringTag]() {
|
|
10
|
+
return 'TransformFeedback';
|
|
11
|
+
}
|
|
12
|
+
constructor(device, props) {
|
|
13
|
+
super(device, props, TransformFeedback.defaultProps);
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
|
-
TransformFeedback.defaultProps = {
|
|
13
|
-
...Resource.defaultProps,
|
|
14
|
-
layout: undefined,
|
|
15
|
-
buffers: {}
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=transform-feedback.js.map
|
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { getAttributeInfosByLocation } from '../attribute-utils/get-attribute-from-layouts';
|
|
2
|
+
import { Resource } from './resource';
|
|
3
|
+
/**
|
|
4
|
+
* Stores attribute bindings.
|
|
5
|
+
* Makes it easy to share a render pipeline and use separate vertex arrays.
|
|
6
|
+
* @note On WebGL, VertexArray allows non-constant bindings to be performed in advance
|
|
7
|
+
* reducing the number of WebGL calls per draw call.
|
|
8
|
+
* @note On WebGPU this is just a convenience class that collects the bindings.
|
|
9
|
+
*/
|
|
5
10
|
export class VertexArray extends Resource {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
static defaultProps = {
|
|
12
|
+
...Resource.defaultProps,
|
|
13
|
+
renderPipeline: null
|
|
14
|
+
};
|
|
15
|
+
get [Symbol.toStringTag]() {
|
|
16
|
+
return 'VertexArray';
|
|
17
|
+
}
|
|
18
|
+
/** Max number of vertex attributes */
|
|
19
|
+
maxVertexAttributes;
|
|
20
|
+
/** Attribute infos indexed by location - TODO only needed by webgl module? */
|
|
21
|
+
attributeInfos;
|
|
22
|
+
/** Index buffer */
|
|
23
|
+
indexBuffer = null;
|
|
24
|
+
/** Attributes indexed by buffer slot */
|
|
25
|
+
attributes;
|
|
26
|
+
constructor(device, props) {
|
|
27
|
+
super(device, props, VertexArray.defaultProps);
|
|
28
|
+
this.maxVertexAttributes = device.limits.maxVertexAttributes;
|
|
29
|
+
this.attributes = new Array(this.maxVertexAttributes).fill(null);
|
|
30
|
+
this.attributeInfos = getAttributeInfosByLocation(props.renderPipeline.shaderLayout, props.renderPipeline.bufferLayout, this.maxVertexAttributes);
|
|
31
|
+
}
|
|
19
32
|
}
|
|
20
|
-
VertexArray.defaultProps = {
|
|
21
|
-
...Resource.defaultProps,
|
|
22
|
-
renderPipeline: null
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=vertex-array.js.map
|
|
@@ -1,60 +1,64 @@
|
|
|
1
|
+
/** Decodes a vertex type, returning byte length and flags (integer, signed, normalized) */
|
|
1
2
|
export function decodeShaderAttributeType(attributeType) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
const [dataType, components] = TYPE_INFO[attributeType];
|
|
4
|
+
const integer = dataType === 'i32' || dataType === 'u32';
|
|
5
|
+
const signed = dataType !== 'u32';
|
|
6
|
+
const byteLength = TYPE_SIZES[dataType] * components;
|
|
7
|
+
const defaultVertexFormat = getCompatibleVertexFormat(dataType, components);
|
|
8
|
+
return {
|
|
9
|
+
dataType,
|
|
10
|
+
components,
|
|
11
|
+
defaultVertexFormat,
|
|
12
|
+
byteLength,
|
|
13
|
+
integer,
|
|
14
|
+
signed
|
|
15
|
+
};
|
|
15
16
|
}
|
|
17
|
+
/** Get the "default" vertex format for a certain shader data type */
|
|
16
18
|
function getCompatibleVertexFormat(dataType, components) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
let vertexType;
|
|
20
|
+
switch (dataType) {
|
|
21
|
+
case 'f32':
|
|
22
|
+
vertexType = 'float32';
|
|
23
|
+
break;
|
|
24
|
+
case 'i32':
|
|
25
|
+
vertexType = 'sint32';
|
|
26
|
+
break;
|
|
27
|
+
case 'u32':
|
|
28
|
+
vertexType = 'uint32';
|
|
29
|
+
break;
|
|
30
|
+
case 'f16':
|
|
31
|
+
return components <= 2 ? 'float16x2' : 'float16x4';
|
|
32
|
+
}
|
|
33
|
+
// TODO logic does not work for float16
|
|
34
|
+
if (components === 1) {
|
|
35
|
+
return vertexType;
|
|
36
|
+
}
|
|
37
|
+
return `${vertexType}x${components}`;
|
|
35
38
|
}
|
|
39
|
+
/** All valid shader attribute types. A table guarantees exhaustive list and fast execution */
|
|
36
40
|
const TYPE_INFO = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
f32: ['f32', 1],
|
|
42
|
+
'vec2<f32>': ['f32', 2],
|
|
43
|
+
'vec3<f32>': ['f32', 3],
|
|
44
|
+
'vec4<f32>': ['f32', 4],
|
|
45
|
+
f16: ['f16', 1],
|
|
46
|
+
'vec2<f16>': ['f16', 2],
|
|
47
|
+
'vec3<f16>': ['f16', 3],
|
|
48
|
+
'vec4<f16>': ['f16', 4],
|
|
49
|
+
i32: ['i32', 1],
|
|
50
|
+
'vec2<i32>': ['i32', 2],
|
|
51
|
+
'vec3<i32>': ['i32', 3],
|
|
52
|
+
'vec4<i32>': ['i32', 4],
|
|
53
|
+
u32: ['u32', 1],
|
|
54
|
+
'vec2<u32>': ['u32', 2],
|
|
55
|
+
'vec3<u32>': ['u32', 3],
|
|
56
|
+
'vec4<u32>': ['u32', 4]
|
|
53
57
|
};
|
|
54
58
|
const TYPE_SIZES = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
f32: 4,
|
|
60
|
+
f16: 2,
|
|
61
|
+
i32: 4,
|
|
62
|
+
u32: 4,
|
|
63
|
+
// 'bool-webgl': 4,
|
|
59
64
|
};
|
|
60
|
-
//# sourceMappingURL=decode-attribute-type.js.map
|