@luma.gl/webgl 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/converters/device-parameters.js +240 -158
- package/dist/adapter/converters/sampler-parameters.d.ts +0 -4
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +73 -68
- package/dist/adapter/converters/shader-formats.js +33 -46
- package/dist/adapter/converters/texture-formats.d.ts +9 -18
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +454 -871
- package/dist/adapter/converters/vertex-formats.js +52 -61
- package/dist/adapter/device-helpers/device-features.d.ts +2 -5
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js +56 -87
- package/dist/adapter/device-helpers/device-limits.d.ts +2 -4
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +88 -83
- package/dist/adapter/device-helpers/get-device-info.d.ts +1 -1
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +79 -63
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +6 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.js +52 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +4 -0
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js +87 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +50 -0
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js +92 -0
- package/dist/adapter/helpers/decode-webgl-types.js +87 -76
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +261 -226
- package/dist/adapter/helpers/parse-shader-compiler-log.js +46 -37
- package/dist/adapter/helpers/set-uniform.d.ts +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +67 -82
- package/dist/adapter/helpers/webgl-topology-utils.js +77 -93
- package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +18 -12
- package/dist/adapter/objects/webgl-renderbuffer.js +76 -80
- package/dist/adapter/objects/webgl-resource.d.ts +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +204 -154
- package/dist/adapter/resources/webgl-buffer.d.ts +2 -3
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +160 -119
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +268 -171
- package/dist/adapter/resources/webgl-command-encoder.js +32 -40
- package/dist/adapter/resources/webgl-external-texture.js +92 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -2
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +167 -139
- package/dist/adapter/resources/webgl-render-pass.js +121 -95
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +11 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +378 -228
- package/dist/adapter/resources/webgl-sampler.d.ts +0 -2
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +43 -34
- package/dist/adapter/resources/webgl-shader.d.ts +10 -1
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +106 -45
- package/dist/adapter/resources/webgl-texture.d.ts +2 -6
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +614 -699
- package/dist/adapter/resources/webgl-transform-feedback.d.ts +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-transform-feedback.js +143 -145
- package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +229 -158
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +58 -37
- package/dist/adapter/webgl-device.d.ts +7 -15
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +440 -381
- package/dist/classic/accessor.js +132 -102
- package/dist/classic/clear.d.ts +2 -2
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +73 -73
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +176 -177
- package/dist/classic/format-utils.d.ts +2 -2
- package/dist/classic/format-utils.js +38 -32
- package/dist/classic/typed-array-utils.js +95 -81
- package/dist/context/{polyfill → context}/context-data.d.ts +2 -1
- package/dist/context/context/context-data.d.ts.map +1 -0
- package/dist/context/context/context-data.js +33 -0
- package/dist/context/context/create-browser-context.d.ts +1 -6
- package/dist/context/context/create-browser-context.d.ts.map +1 -1
- package/dist/context/context/create-browser-context.js +62 -49
- package/dist/context/debug/spector.js +54 -50
- package/dist/context/debug/webgl-developer-tools.d.ts +1 -2
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +102 -76
- package/dist/context/parameters/unified-parameter-api.d.ts +3 -3
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +95 -46
- package/dist/context/parameters/webgl-parameter-tables.d.ts +110 -99
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +456 -404
- package/dist/context/state-tracker/deep-array-equal.js +18 -14
- package/dist/context/state-tracker/track-context-state.d.ts +4 -4
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +190 -126
- package/dist/context/state-tracker/with-parameters.d.ts +1 -1
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +45 -29
- package/dist/dist.dev.js +2568 -3786
- package/dist/index.cjs +1346 -2464
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -26
- package/dist/types.js +2 -1
- package/dist.min.js +9 -42
- package/package.json +11 -15
- package/src/adapter/converters/device-parameters.ts +0 -1
- package/src/adapter/converters/sampler-parameters.ts +0 -17
- package/src/adapter/converters/texture-formats.ts +86 -154
- package/src/adapter/device-helpers/webgl-device-features.ts +69 -0
- package/src/adapter/device-helpers/{get-device-info.ts → webgl-device-info.ts} +3 -4
- package/src/adapter/device-helpers/{device-limits.ts → webgl-device-limits.ts} +25 -23
- package/src/adapter/helpers/get-shader-layout.ts +17 -28
- package/src/adapter/helpers/set-uniform.ts +1 -3
- package/src/adapter/objects/constants-to-keys.ts +1 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +4 -4
- package/src/adapter/objects/webgl-resource.ts +3 -18
- package/src/adapter/resources/webgl-buffer.ts +6 -11
- package/src/adapter/resources/webgl-command-buffer.ts +20 -30
- package/src/adapter/resources/webgl-external-texture.ts +2 -3
- package/src/adapter/resources/webgl-framebuffer.ts +4 -5
- package/src/adapter/resources/webgl-render-pass.ts +7 -7
- package/src/adapter/resources/webgl-render-pipeline.ts +106 -31
- package/src/adapter/resources/webgl-sampler.ts +5 -9
- package/src/adapter/resources/webgl-shader.ts +57 -10
- package/src/adapter/resources/webgl-texture.ts +29 -103
- package/src/adapter/resources/webgl-transform-feedback.ts +14 -15
- package/src/adapter/resources/webgl-vertex-array.ts +16 -18
- package/src/adapter/webgl-canvas-context.ts +1 -7
- package/src/adapter/webgl-device.ts +18 -67
- package/src/classic/clear.ts +13 -14
- package/src/classic/copy-and-blit.ts +1 -2
- package/src/context/context/context-data.ts +44 -0
- package/src/context/context/create-browser-context.ts +7 -32
- package/src/context/debug/webgl-developer-tools.ts +6 -8
- package/src/context/parameters/unified-parameter-api.ts +3 -3
- package/src/context/parameters/webgl-parameter-tables.ts +66 -75
- package/src/context/state-tracker/track-context-state.ts +18 -17
- package/src/context/state-tracker/with-parameters.ts +1 -1
- package/src/index.ts +2 -17
- package/dist/adapter/converters/device-parameters.js.map +0 -1
- package/dist/adapter/converters/sampler-parameters.js.map +0 -1
- package/dist/adapter/converters/shader-formats.js.map +0 -1
- package/dist/adapter/converters/texture-formats.js.map +0 -1
- package/dist/adapter/converters/vertex-formats.js.map +0 -1
- package/dist/adapter/device-helpers/device-features.js.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js.map +0 -1
- package/dist/adapter/device-helpers/is-old-ie.d.ts +0 -2
- package/dist/adapter/device-helpers/is-old-ie.d.ts.map +0 -1
- package/dist/adapter/device-helpers/is-old-ie.js +0 -9
- package/dist/adapter/device-helpers/is-old-ie.js.map +0 -1
- package/dist/adapter/helpers/decode-webgl-types.js.map +0 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +0 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +0 -1
- package/dist/adapter/helpers/set-uniform.js.map +0 -1
- package/dist/adapter/helpers/webgl-topology-utils.js.map +0 -1
- package/dist/adapter/objects/constants-to-keys.js.map +0 -1
- package/dist/adapter/objects/webgl-renderbuffer.js.map +0 -1
- package/dist/adapter/objects/webgl-resource.js.map +0 -1
- package/dist/adapter/resources/webgl-buffer.js.map +0 -1
- package/dist/adapter/resources/webgl-command-buffer.js.map +0 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +0 -1
- package/dist/adapter/resources/webgl-external-texture.js.map +0 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +0 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +0 -1
- package/dist/adapter/resources/webgl-render-pipeline.js.map +0 -1
- package/dist/adapter/resources/webgl-sampler.js.map +0 -1
- package/dist/adapter/resources/webgl-shader.js.map +0 -1
- package/dist/adapter/resources/webgl-texture.js.map +0 -1
- package/dist/adapter/resources/webgl-transform-feedback.js.map +0 -1
- package/dist/adapter/resources/webgl-vertex-array.js.map +0 -1
- package/dist/adapter/webgl-canvas-context.js.map +0 -1
- package/dist/adapter/webgl-device.js.map +0 -1
- package/dist/classic/accessor.js.map +0 -1
- package/dist/classic/clear.js.map +0 -1
- package/dist/classic/copy-and-blit.js.map +0 -1
- package/dist/classic/format-utils.js.map +0 -1
- package/dist/classic/typed-array-utils.js.map +0 -1
- package/dist/context/context/create-browser-context.js.map +0 -1
- package/dist/context/context/create-headless-context.d.ts +0 -9
- package/dist/context/context/create-headless-context.d.ts.map +0 -1
- package/dist/context/context/create-headless-context.js +0 -42
- package/dist/context/context/create-headless-context.js.map +0 -1
- package/dist/context/context/webgl-checks.d.ts +0 -13
- package/dist/context/context/webgl-checks.d.ts.map +0 -1
- package/dist/context/context/webgl-checks.js +0 -31
- package/dist/context/context/webgl-checks.js.map +0 -1
- package/dist/context/debug/spector.js.map +0 -1
- package/dist/context/debug/webgl-developer-tools.js.map +0 -1
- package/dist/context/parameters/unified-parameter-api.js.map +0 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +0 -1
- package/dist/context/polyfill/context-data.d.ts.map +0 -1
- package/dist/context/polyfill/context-data.js +0 -12
- package/dist/context/polyfill/context-data.js.map +0 -1
- package/dist/context/polyfill/get-parameter-polyfill.d.ts +0 -2
- package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +0 -1
- package/dist/context/polyfill/get-parameter-polyfill.js +0 -85
- package/dist/context/polyfill/get-parameter-polyfill.js.map +0 -1
- package/dist/context/polyfill/polyfill-context.d.ts +0 -5
- package/dist/context/polyfill/polyfill-context.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-context.js +0 -87
- package/dist/context/polyfill/polyfill-context.js.map +0 -1
- package/dist/context/polyfill/polyfill-table.d.ts +0 -48
- package/dist/context/polyfill/polyfill-table.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-table.js +0 -137
- package/dist/context/polyfill/polyfill-table.js.map +0 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts +0 -2
- package/dist/context/polyfill/polyfill-vertex-array-object.d.ts.map +0 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js +0 -265
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +0 -1
- package/dist/context/state-tracker/deep-array-equal.js.map +0 -1
- package/dist/context/state-tracker/track-context-state.js.map +0 -1
- package/dist/context/state-tracker/with-parameters.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/src/adapter/device-helpers/device-features.ts +0 -161
- package/src/adapter/device-helpers/is-old-ie.ts +0 -14
- package/src/context/context/create-headless-context.ts +0 -51
- package/src/context/context/webgl-checks.ts +0 -51
- package/src/context/polyfill/context-data.ts +0 -30
- package/src/context/polyfill/get-parameter-polyfill.ts +0 -122
- package/src/context/polyfill/polyfill-context.ts +0 -104
- package/src/context/polyfill/polyfill-table.ts +0 -167
- package/src/context/polyfill/polyfill-vertex-array-object.ts +0 -365
|
@@ -1,40 +1,49 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
1
3
|
import { Sampler } from '@luma.gl/core';
|
|
2
|
-
import {
|
|
4
|
+
import { GL } from '@luma.gl/constants';
|
|
5
|
+
import { convertSamplerParametersToWebGL } from '../converters/sampler-parameters';
|
|
6
|
+
/**
|
|
7
|
+
* Sampler object -
|
|
8
|
+
* so that they can be set directly on the texture
|
|
9
|
+
* https://github.com/WebGLSamples/WebGL2Samples/blob/master/samples/sampler_object.html
|
|
10
|
+
*/
|
|
3
11
|
export class WEBGLSampler extends Sampler {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this._setSamplerParameters(this.parameters);
|
|
12
|
+
device;
|
|
13
|
+
handle;
|
|
14
|
+
parameters;
|
|
15
|
+
constructor(device, props) {
|
|
16
|
+
super(device, props);
|
|
17
|
+
this.device = device;
|
|
18
|
+
this.parameters = convertSamplerParametersToWebGL(props);
|
|
19
|
+
this.handle = this.handle || this.device.gl.createSampler();
|
|
20
|
+
this._setSamplerParameters(this.parameters);
|
|
14
21
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
destroy() {
|
|
23
|
+
if (this.handle) {
|
|
24
|
+
this.device.gl.deleteSampler(this.handle);
|
|
25
|
+
// @ts-expect-error read-only/undefined
|
|
26
|
+
this.handle = undefined;
|
|
27
|
+
}
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
toString() {
|
|
30
|
+
return `Sampler(${this.id},${JSON.stringify(this.props)})`;
|
|
31
|
+
}
|
|
32
|
+
/** Set sampler parameters on the sampler */
|
|
33
|
+
_setSamplerParameters(parameters) {
|
|
34
|
+
for (const [pname, value] of Object.entries(parameters)) {
|
|
35
|
+
// Apparently there are integer/float conversion issues requires two parameter setting functions in JavaScript.
|
|
36
|
+
// For now, pick the float version for parameters specified as GLfloat.
|
|
37
|
+
const param = Number(pname);
|
|
38
|
+
switch (param) {
|
|
39
|
+
case GL.TEXTURE_MIN_LOD:
|
|
40
|
+
case GL.TEXTURE_MAX_LOD:
|
|
41
|
+
this.device.gl.samplerParameterf(this.handle, param, value);
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
this.device.gl.samplerParameteri(this.handle, param, value);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
37
48
|
}
|
|
38
|
-
}
|
|
39
49
|
}
|
|
40
|
-
//# sourceMappingURL=webgl-sampler.js.map
|
|
@@ -10,6 +10,15 @@ export declare class WEBGLShader extends Shader {
|
|
|
10
10
|
destroy(): void;
|
|
11
11
|
getCompilationInfo(): Promise<readonly CompilerMessage[]>;
|
|
12
12
|
getCompilationInfoSync(): readonly CompilerMessage[];
|
|
13
|
-
|
|
13
|
+
/** Compile a shader and get compilation status */
|
|
14
|
+
protected _compile(source: string): Promise<void>;
|
|
15
|
+
/** Use KHR_parallel_shader_compile extension if available */
|
|
16
|
+
protected _waitForCompilationComplete(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Get the shader compilation status
|
|
19
|
+
* TODO - Load log even when no error reported, to catch warnings?
|
|
20
|
+
* https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings
|
|
21
|
+
*/
|
|
22
|
+
protected _getCompilationStatus(): void;
|
|
14
23
|
}
|
|
15
24
|
//# sourceMappingURL=webgl-shader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-shader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"webgl-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-shader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,eAAe,EAAM,MAAM,eAAe,CAAC;AAGxE,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAE5C;;GAEG;AACH,qBAAa,WAAY,SAAQ,MAAM;IACrC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;gBAEjB,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW;IAgB1C,OAAO,IAAI,IAAI;IAST,kBAAkB,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;IAK/D,sBAAsB;IAO/B,kDAAkD;cAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCvD,6DAA6D;cAC7C,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB5D;;;;MAIE;IACF,SAAS,CAAC,qBAAqB;CAKhC"}
|
|
@@ -1,50 +1,111 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
import { Shader, log } from '@luma.gl/core';
|
|
4
|
+
import { GL } from '@luma.gl/constants';
|
|
5
|
+
import { parseShaderCompilerLog } from '../helpers/parse-shader-compiler-log';
|
|
6
|
+
/**
|
|
7
|
+
* An immutable compiled shader program that execute portions of the GPU Pipeline
|
|
8
|
+
*/
|
|
3
9
|
export class WEBGLShader extends Shader {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
device;
|
|
11
|
+
handle;
|
|
12
|
+
constructor(device, props) {
|
|
13
|
+
super(device, props);
|
|
14
|
+
this.device = device;
|
|
15
|
+
switch (this.props.stage) {
|
|
16
|
+
case 'vertex':
|
|
17
|
+
this.handle = this.props.handle || this.device.gl.createShader(GL.VERTEX_SHADER);
|
|
18
|
+
break;
|
|
19
|
+
case 'fragment':
|
|
20
|
+
this.handle = this.props.handle || this.device.gl.createShader(GL.FRAGMENT_SHADER);
|
|
21
|
+
break;
|
|
22
|
+
default:
|
|
23
|
+
throw new Error(this.props.stage);
|
|
24
|
+
}
|
|
25
|
+
this._compile(this.source);
|
|
18
26
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
destroy() {
|
|
28
|
+
if (this.handle) {
|
|
29
|
+
this.removeStats();
|
|
30
|
+
this.device.gl.deleteShader(this.handle);
|
|
31
|
+
// this.handle = null;
|
|
32
|
+
this.destroyed = true;
|
|
33
|
+
}
|
|
26
34
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
async getCompilationInfo() {
|
|
36
|
+
await this._waitForCompilationComplete();
|
|
37
|
+
return this.getCompilationInfoSync();
|
|
38
|
+
}
|
|
39
|
+
getCompilationInfoSync() {
|
|
40
|
+
const log = this.device.gl.getShaderInfoLog(this.handle);
|
|
41
|
+
return parseShaderCompilerLog(log);
|
|
42
|
+
}
|
|
43
|
+
// PRIVATE METHODS
|
|
44
|
+
/** Compile a shader and get compilation status */
|
|
45
|
+
async _compile(source) {
|
|
46
|
+
const addGLSLVersion = (source) => source.startsWith('#version ') ? source : `#version 100\n${source}`;
|
|
47
|
+
source = addGLSLVersion(source);
|
|
48
|
+
const { gl } = this.device;
|
|
49
|
+
gl.shaderSource(this.handle, source);
|
|
50
|
+
gl.compileShader(this.handle);
|
|
51
|
+
// For performance reasons, avoid checking shader compilation errors on production
|
|
52
|
+
if (log.level === 0) {
|
|
53
|
+
this.compilationStatus = 'pending';
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// Sync case - slower, but advantage is that it throws in the constructor, making break on error more useful
|
|
57
|
+
if (!this.device.features.has('shader-status-async-webgl')) {
|
|
58
|
+
this._getCompilationStatus();
|
|
59
|
+
if (this.compilationStatus === 'error') {
|
|
60
|
+
throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);
|
|
61
|
+
}
|
|
62
|
+
// The `Shader` base class will determine if debug window should be opened based on this.compilationStatus
|
|
63
|
+
this.debugShader();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// async case
|
|
67
|
+
log.once(1, 'Shader compilation is asynchronous')();
|
|
68
|
+
await this._waitForCompilationComplete();
|
|
69
|
+
log.info(2, `Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)();
|
|
70
|
+
this._getCompilationStatus();
|
|
71
|
+
// The `Shader` base class will determine if debug window should be opened based on this.compilationStatus
|
|
72
|
+
this.debugShader();
|
|
73
|
+
}
|
|
74
|
+
/** Use KHR_parallel_shader_compile extension if available */
|
|
75
|
+
async _waitForCompilationComplete() {
|
|
76
|
+
const waitMs = async (ms) => await new Promise(resolve => setTimeout(resolve, ms));
|
|
77
|
+
const DELAY_MS = 10; // Shader compilation is typically quite fast (with some exceptions)
|
|
78
|
+
// If status polling is not available, we can't wait for completion. Just wait a little to minimize blocking
|
|
79
|
+
if (!this.device.features.has('shader-status-async-webgl')) {
|
|
80
|
+
await waitMs(DELAY_MS);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const { gl } = this.device;
|
|
84
|
+
for (;;) {
|
|
85
|
+
const complete = gl.getShaderParameter(this.handle, GL.COMPLETION_STATUS);
|
|
86
|
+
if (complete) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
await waitMs(DELAY_MS);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get the shader compilation status
|
|
94
|
+
* TODO - Load log even when no error reported, to catch warnings?
|
|
95
|
+
* https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings
|
|
96
|
+
*/
|
|
97
|
+
_getCompilationStatus() {
|
|
98
|
+
this.compilationStatus = this.device.gl.getShaderParameter(this.handle, GL.COMPILE_STATUS)
|
|
99
|
+
? 'success'
|
|
100
|
+
: 'error';
|
|
47
101
|
}
|
|
48
|
-
}
|
|
49
102
|
}
|
|
50
|
-
|
|
103
|
+
// TODO - Original code from luma.gl v8 - keep until new debug functionality has matured
|
|
104
|
+
// if (!compilationSuccess) {
|
|
105
|
+
// const parsedLog = shaderLog ? parseShaderCompilerLog(shaderLog) : [];
|
|
106
|
+
// const messages = parsedLog.filter(message => message.type === 'error');
|
|
107
|
+
// const formattedLog = formatCompilerLog(messages, source, {showSourceCode: 'all', html: true});
|
|
108
|
+
// const shaderDescription = `${this.stage} shader ${shaderName}`;
|
|
109
|
+
// log.error(`GLSL compilation errors in ${shaderDescription}\n${formattedLog}`)();
|
|
110
|
+
// displayShaderLog(parsedLog, source, shaderName);
|
|
111
|
+
// }
|
|
@@ -101,8 +101,7 @@ export declare class WEBGLTexture extends Texture<WEBGLTextureProps> {
|
|
|
101
101
|
static FACES: number[];
|
|
102
102
|
readonly MAX_ATTRIBUTES: number;
|
|
103
103
|
readonly device: WebGLDevice;
|
|
104
|
-
readonly gl:
|
|
105
|
-
readonly gl2: WebGL2RenderingContext | null;
|
|
104
|
+
readonly gl: WebGL2RenderingContext;
|
|
106
105
|
readonly handle: WebGLTexture;
|
|
107
106
|
/** Sampler object (currently unused) */
|
|
108
107
|
sampler: WEBGLSampler;
|
|
@@ -183,7 +182,7 @@ export declare class WEBGLTexture extends Texture<WEBGLTextureProps> {
|
|
|
183
182
|
width: number;
|
|
184
183
|
height: number;
|
|
185
184
|
format: import("@luma.gl/core").TextureFormat;
|
|
186
|
-
data: string |
|
|
185
|
+
data: string | import("@luma.gl/core").TextureData | Promise<import("@luma.gl/core").TextureData> | import("modules/core/dist/adapter/resources/texture").CubeTextureData | HTMLVideoElement;
|
|
187
186
|
};
|
|
188
187
|
_deduceImageSize(data: any, width: any, height: any): {
|
|
189
188
|
width: number;
|
|
@@ -203,11 +202,8 @@ export declare class WEBGLTexture extends Texture<WEBGLTextureProps> {
|
|
|
203
202
|
setImageData3D(options: SetImageData3DOptions): this;
|
|
204
203
|
/**
|
|
205
204
|
* Sets sampler parameters on texture
|
|
206
|
-
* @note: Applies NPOT workaround if appropriate
|
|
207
205
|
*/
|
|
208
206
|
_setSamplerParameters(parameters: GLSamplerParameters): void;
|
|
209
|
-
/** @deprecated For LegacyTexture subclass */
|
|
210
|
-
protected _getWebGL1NPOTParameterOverride(pname: GL.TEXTURE_MIN_FILTER | GL.TEXTURE_WRAP_S | GL.TEXTURE_WRAP_T, value: GL.LINEAR | GL.NEAREST): number;
|
|
211
207
|
}
|
|
212
208
|
export {};
|
|
213
209
|
//# sourceMappingURL=webgl-texture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,OAAO,EACP,YAAY,EAEZ,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"webgl-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgl-texture.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,OAAO,EACP,YAAY,EAEZ,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,OAAO,EAAwC,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAC,EAAE,EAAE,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAQ3D,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAC,YAAY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