@luma.gl/webgl 9.0.0-beta.3 → 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,84 +1,69 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
|
+
/** Set a raw uniform (without type conversion and caching) */
|
|
5
|
+
/* eslint-disable max-len */
|
|
1
6
|
export function setUniform(gl, location, type, value) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
uniformValue
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
uniformValue
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return gl.uniformMatrix2fv(location, false, arrayValue);
|
|
65
|
-
case 35675:
|
|
66
|
-
return gl.uniformMatrix3fv(location, false, arrayValue);
|
|
67
|
-
case 35676:
|
|
68
|
-
return gl.uniformMatrix4fv(location, false, arrayValue);
|
|
69
|
-
case 35685:
|
|
70
|
-
return gl2.uniformMatrix2x3fv(location, false, arrayValue);
|
|
71
|
-
case 35686:
|
|
72
|
-
return gl2.uniformMatrix2x4fv(location, false, arrayValue);
|
|
73
|
-
case 35687:
|
|
74
|
-
return gl2.uniformMatrix3x2fv(location, false, arrayValue);
|
|
75
|
-
case 35688:
|
|
76
|
-
return gl2.uniformMatrix3x4fv(location, false, arrayValue);
|
|
77
|
-
case 35689:
|
|
78
|
-
return gl2.uniformMatrix4x2fv(location, false, arrayValue);
|
|
79
|
-
case 35690:
|
|
80
|
-
return gl2.uniformMatrix4x3fv(location, false, arrayValue);
|
|
81
|
-
}
|
|
82
|
-
throw new Error('Illegal uniform');
|
|
7
|
+
const gl2 = gl;
|
|
8
|
+
// Prepare the value for WebGL setters
|
|
9
|
+
let uniformValue = value;
|
|
10
|
+
if (uniformValue === true) {
|
|
11
|
+
uniformValue = 1;
|
|
12
|
+
}
|
|
13
|
+
if (uniformValue === false) {
|
|
14
|
+
uniformValue = 0;
|
|
15
|
+
}
|
|
16
|
+
const arrayValue = typeof uniformValue === 'number' ? [uniformValue] : uniformValue;
|
|
17
|
+
// prettier-ignore
|
|
18
|
+
switch (type) {
|
|
19
|
+
case GL.SAMPLER_2D:
|
|
20
|
+
case GL.SAMPLER_CUBE:
|
|
21
|
+
case GL.SAMPLER_3D:
|
|
22
|
+
case GL.SAMPLER_2D_SHADOW:
|
|
23
|
+
case GL.SAMPLER_2D_ARRAY:
|
|
24
|
+
case GL.SAMPLER_2D_ARRAY_SHADOW:
|
|
25
|
+
case GL.SAMPLER_CUBE_SHADOW:
|
|
26
|
+
case GL.INT_SAMPLER_2D:
|
|
27
|
+
case GL.INT_SAMPLER_3D:
|
|
28
|
+
case GL.INT_SAMPLER_CUBE:
|
|
29
|
+
case GL.INT_SAMPLER_2D_ARRAY:
|
|
30
|
+
case GL.UNSIGNED_INT_SAMPLER_2D:
|
|
31
|
+
case GL.UNSIGNED_INT_SAMPLER_3D:
|
|
32
|
+
case GL.UNSIGNED_INT_SAMPLER_CUBE:
|
|
33
|
+
case GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
|
34
|
+
if (typeof value !== 'number') {
|
|
35
|
+
throw new Error('samplers must be set to integers');
|
|
36
|
+
}
|
|
37
|
+
return gl.uniform1i(location, value);
|
|
38
|
+
case GL.FLOAT: return gl.uniform1fv(location, arrayValue);
|
|
39
|
+
case GL.FLOAT_VEC2: return gl.uniform2fv(location, arrayValue);
|
|
40
|
+
case GL.FLOAT_VEC3: return gl.uniform3fv(location, arrayValue);
|
|
41
|
+
case GL.FLOAT_VEC4: return gl.uniform4fv(location, arrayValue);
|
|
42
|
+
case GL.INT: return gl.uniform1iv(location, arrayValue);
|
|
43
|
+
case GL.INT_VEC2: return gl.uniform2iv(location, arrayValue);
|
|
44
|
+
case GL.INT_VEC3: return gl.uniform3iv(location, arrayValue);
|
|
45
|
+
case GL.INT_VEC4: return gl.uniform4iv(location, arrayValue);
|
|
46
|
+
case GL.BOOL: return gl.uniform1iv(location, arrayValue);
|
|
47
|
+
case GL.BOOL_VEC2: return gl.uniform2iv(location, arrayValue);
|
|
48
|
+
case GL.BOOL_VEC3: return gl.uniform3iv(location, arrayValue);
|
|
49
|
+
case GL.BOOL_VEC4: return gl.uniform4iv(location, arrayValue);
|
|
50
|
+
// WEBGL2 - unsigned integers
|
|
51
|
+
case GL.UNSIGNED_INT: return gl2.uniform1uiv(location, arrayValue, 1);
|
|
52
|
+
case GL.UNSIGNED_INT_VEC2: return gl2.uniform2uiv(location, arrayValue, 2);
|
|
53
|
+
case GL.UNSIGNED_INT_VEC3: return gl2.uniform3uiv(location, arrayValue, 3);
|
|
54
|
+
case GL.UNSIGNED_INT_VEC4: return gl2.uniform4uiv(location, arrayValue, 4);
|
|
55
|
+
// WebGL2 - quadratic matrices
|
|
56
|
+
// false: don't transpose the matrix
|
|
57
|
+
case GL.FLOAT_MAT2: return gl.uniformMatrix2fv(location, false, arrayValue);
|
|
58
|
+
case GL.FLOAT_MAT3: return gl.uniformMatrix3fv(location, false, arrayValue);
|
|
59
|
+
case GL.FLOAT_MAT4: return gl.uniformMatrix4fv(location, false, arrayValue);
|
|
60
|
+
// WebGL2 - rectangular matrices
|
|
61
|
+
case GL.FLOAT_MAT2x3: return gl2.uniformMatrix2x3fv(location, false, arrayValue);
|
|
62
|
+
case GL.FLOAT_MAT2x4: return gl2.uniformMatrix2x4fv(location, false, arrayValue);
|
|
63
|
+
case GL.FLOAT_MAT3x2: return gl2.uniformMatrix3x2fv(location, false, arrayValue);
|
|
64
|
+
case GL.FLOAT_MAT3x4: return gl2.uniformMatrix3x4fv(location, false, arrayValue);
|
|
65
|
+
case GL.FLOAT_MAT4x2: return gl2.uniformMatrix4x2fv(location, false, arrayValue);
|
|
66
|
+
case GL.FLOAT_MAT4x3: return gl2.uniformMatrix4x3fv(location, false, arrayValue);
|
|
67
|
+
}
|
|
68
|
+
throw new Error('Illegal uniform');
|
|
83
69
|
}
|
|
84
|
-
//# sourceMappingURL=set-uniform.js.map
|
|
@@ -1,103 +1,87 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
import { GL } from '@luma.gl/constants';
|
|
4
|
+
// Counts the number of complete primitives given a number of vertices and a drawMode
|
|
1
5
|
export function getPrimitiveDrawMode(drawMode) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
switch (drawMode) {
|
|
7
|
+
case GL.POINTS:
|
|
8
|
+
return GL.POINTS;
|
|
9
|
+
case GL.LINES:
|
|
10
|
+
return GL.LINES;
|
|
11
|
+
case GL.LINE_STRIP:
|
|
12
|
+
return GL.LINES;
|
|
13
|
+
case GL.LINE_LOOP:
|
|
14
|
+
return GL.LINES;
|
|
15
|
+
case GL.TRIANGLES:
|
|
16
|
+
return GL.TRIANGLES;
|
|
17
|
+
case GL.TRIANGLE_STRIP:
|
|
18
|
+
return GL.TRIANGLES;
|
|
19
|
+
case GL.TRIANGLE_FAN:
|
|
20
|
+
return GL.TRIANGLES;
|
|
21
|
+
default:
|
|
22
|
+
throw new Error('drawMode');
|
|
23
|
+
}
|
|
20
24
|
}
|
|
25
|
+
// Counts the number of complete "primitives" given a number of vertices and a drawMode
|
|
21
26
|
export function getPrimitiveCount(options) {
|
|
22
|
-
|
|
23
|
-
drawMode
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
default:
|
|
40
|
-
throw new Error('drawMode');
|
|
41
|
-
}
|
|
27
|
+
const { drawMode, vertexCount } = options;
|
|
28
|
+
switch (drawMode) {
|
|
29
|
+
case GL.POINTS:
|
|
30
|
+
case GL.LINE_LOOP:
|
|
31
|
+
return vertexCount;
|
|
32
|
+
case GL.LINES:
|
|
33
|
+
return vertexCount / 2;
|
|
34
|
+
case GL.LINE_STRIP:
|
|
35
|
+
return vertexCount - 1;
|
|
36
|
+
case GL.TRIANGLES:
|
|
37
|
+
return vertexCount / 3;
|
|
38
|
+
case GL.TRIANGLE_STRIP:
|
|
39
|
+
case GL.TRIANGLE_FAN:
|
|
40
|
+
return vertexCount - 2;
|
|
41
|
+
default:
|
|
42
|
+
throw new Error('drawMode');
|
|
43
|
+
}
|
|
42
44
|
}
|
|
45
|
+
// Counts the number of vertices after splitting the vertex stream into separate "primitives"
|
|
43
46
|
export function getVertexCount(options) {
|
|
44
|
-
|
|
45
|
-
drawMode,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return primitiveCount * 2;
|
|
57
|
-
case 4:
|
|
58
|
-
return primitiveCount * 3;
|
|
59
|
-
default:
|
|
60
|
-
throw new Error('drawMode');
|
|
61
|
-
}
|
|
47
|
+
const { drawMode, vertexCount } = options;
|
|
48
|
+
const primitiveCount = getPrimitiveCount({ drawMode, vertexCount });
|
|
49
|
+
switch (getPrimitiveDrawMode(drawMode)) {
|
|
50
|
+
case GL.POINTS:
|
|
51
|
+
return primitiveCount;
|
|
52
|
+
case GL.LINES:
|
|
53
|
+
return primitiveCount * 2;
|
|
54
|
+
case GL.TRIANGLES:
|
|
55
|
+
return primitiveCount * 3;
|
|
56
|
+
default:
|
|
57
|
+
throw new Error('drawMode');
|
|
58
|
+
}
|
|
62
59
|
}
|
|
60
|
+
/** Get the primitive type for draw */
|
|
63
61
|
export function getGLDrawMode(topology) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
case 'triangle-strip':
|
|
76
|
-
return 5;
|
|
77
|
-
case 'triangle-fan-webgl':
|
|
78
|
-
return 6;
|
|
79
|
-
default:
|
|
80
|
-
throw new Error(topology);
|
|
81
|
-
}
|
|
62
|
+
// prettier-ignore
|
|
63
|
+
switch (topology) {
|
|
64
|
+
case 'point-list': return GL.POINTS;
|
|
65
|
+
case 'line-list': return GL.LINES;
|
|
66
|
+
case 'line-strip': return GL.LINE_STRIP;
|
|
67
|
+
case 'line-loop-webgl': return GL.LINE_LOOP;
|
|
68
|
+
case 'triangle-list': return GL.TRIANGLES;
|
|
69
|
+
case 'triangle-strip': return GL.TRIANGLE_STRIP;
|
|
70
|
+
case 'triangle-fan-webgl': return GL.TRIANGLE_FAN;
|
|
71
|
+
default: throw new Error(topology);
|
|
72
|
+
}
|
|
82
73
|
}
|
|
74
|
+
/** Get the primitive type for transform feedback */
|
|
83
75
|
export function getGLPrimitive(topology) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
case 'triangle-strip':
|
|
96
|
-
return 4;
|
|
97
|
-
case 'triangle-fan-webgl':
|
|
98
|
-
return 4;
|
|
99
|
-
default:
|
|
100
|
-
throw new Error(topology);
|
|
101
|
-
}
|
|
76
|
+
// prettier-ignore
|
|
77
|
+
switch (topology) {
|
|
78
|
+
case 'point-list': return GL.POINTS;
|
|
79
|
+
case 'line-list': return GL.LINES;
|
|
80
|
+
case 'line-strip': return GL.LINES;
|
|
81
|
+
case 'line-loop-webgl': return GL.LINES;
|
|
82
|
+
case 'triangle-list': return GL.TRIANGLES;
|
|
83
|
+
case 'triangle-strip': return GL.TRIANGLES;
|
|
84
|
+
case 'triangle-fan-webgl': return GL.TRIANGLES;
|
|
85
|
+
default: throw new Error(topology);
|
|
86
|
+
}
|
|
102
87
|
}
|
|
103
|
-
//# sourceMappingURL=webgl-topology-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants-to-keys.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/constants-to-keys.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,wBAAgB,WAAW,CAAC,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"constants-to-keys.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/constants-to-keys.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,wBAAgB,WAAW,CAAC,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,GAAG,EAAE,CAkB7E"}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
1
3
|
import { assert } from '@luma.gl/core';
|
|
4
|
+
// Resolve a WebGL enumeration name (returns itself if already a number)
|
|
2
5
|
export function getKeyValue(gl, name) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
// If not a string, return (assume number)
|
|
7
|
+
if (typeof name !== 'string') {
|
|
8
|
+
return name;
|
|
9
|
+
}
|
|
10
|
+
// If string converts to number, return number
|
|
11
|
+
const number = Number(name);
|
|
12
|
+
if (!isNaN(number)) {
|
|
13
|
+
return number;
|
|
14
|
+
}
|
|
15
|
+
// Look up string, after removing any 'GL.' or 'gl.' prefix
|
|
16
|
+
name = name.replace(/^.*\./, '');
|
|
17
|
+
// @ts-ignore expect-error depends on settings
|
|
18
|
+
const value = gl[name];
|
|
19
|
+
assert(value !== undefined, `Accessing undefined constant GL.${name}`);
|
|
20
|
+
return value;
|
|
14
21
|
}
|
|
15
|
-
//# sourceMappingURL=constants-to-keys.js.map
|
|
@@ -1,86 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
2
3
|
import { assert } from '@luma.gl/core';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
4
|
+
import { GL } from '@luma.gl/constants';
|
|
5
|
+
import { WebGLResource } from './webgl-resource';
|
|
6
|
+
import { isRenderbufferFormatSupported } from '../converters/texture-formats';
|
|
7
|
+
import { convertTextureFormatToGL, getTextureFormatBytesPerPixel } from '../converters/texture-formats';
|
|
8
|
+
/**
|
|
9
|
+
* Renderbuffers are GPU objects that contain images.
|
|
10
|
+
* In contrast to Textures they are optimized for use as render targets, with Framebuffers.
|
|
11
|
+
* while Textures may not be, and are the logical choice when
|
|
12
|
+
* you do not need to sample (i.e. in a post-pass shader)
|
|
13
|
+
* from the produced image. If you need to resample
|
|
14
|
+
* (such as when reading depth back in a second shader pass),
|
|
15
|
+
* use Textures instead.
|
|
16
|
+
* Renderbuffer objects also natively accommodate Multisampling (MSAA).
|
|
17
|
+
*/
|
|
7
18
|
export class WEBGLRenderbuffer extends WebGLResource {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return this.props.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return this.props.samples;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return isRenderbufferFormatSupported(device.gl, format);
|
|
28
|
-
}
|
|
29
|
-
constructor(device, props) {
|
|
30
|
-
if (typeof props.format === 'number') {
|
|
31
|
-
throw new Error('Renderbuffer');
|
|
19
|
+
static defaultProps = {
|
|
20
|
+
id: undefined,
|
|
21
|
+
handle: undefined,
|
|
22
|
+
userData: undefined,
|
|
23
|
+
format: undefined, // 'depth16unorm'
|
|
24
|
+
width: 1,
|
|
25
|
+
height: 1,
|
|
26
|
+
samples: 0
|
|
27
|
+
};
|
|
28
|
+
get [Symbol.toStringTag]() { return 'Renderbuffer'; }
|
|
29
|
+
get width() { return this.props.width; }
|
|
30
|
+
get height() { return this.props.height; }
|
|
31
|
+
get format() { return this.props.format; }
|
|
32
|
+
get samples() { return this.props.samples; }
|
|
33
|
+
get attachment() { return; }
|
|
34
|
+
/** WebGL format constant */
|
|
35
|
+
glFormat;
|
|
36
|
+
static isTextureFormatSupported(device, format) {
|
|
37
|
+
return isRenderbufferFormatSupported(device.gl, format);
|
|
32
38
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
...size,
|
|
42
|
-
format: this.format,
|
|
43
|
-
samples: this.samples
|
|
44
|
-
});
|
|
45
|
-
this._initialize(this.props);
|
|
39
|
+
constructor(device, props) {
|
|
40
|
+
// TODO - remove temporary sanity check
|
|
41
|
+
if (typeof props.format === 'number') {
|
|
42
|
+
throw new Error('Renderbuffer');
|
|
43
|
+
}
|
|
44
|
+
super(device, props, WEBGLRenderbuffer.defaultProps);
|
|
45
|
+
this.glFormat = convertTextureFormatToGL(this.props.format);
|
|
46
|
+
this._initialize(this.props);
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
resize(size) {
|
|
49
|
+
// Don't resize if width/height haven't changed
|
|
50
|
+
if (size.width !== this.width || size.height !== this.height) {
|
|
51
|
+
Object.assign(this.props, { ...size, format: this.format, samples: this.samples });
|
|
52
|
+
this._initialize(this.props);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// PRIVATE METHODS
|
|
56
|
+
/** Creates and initializes a renderbuffer object's data store */
|
|
57
|
+
_initialize(props) {
|
|
58
|
+
const { format, width, height, samples } = props;
|
|
59
|
+
assert(format, 'Needs format');
|
|
60
|
+
this.trackDeallocatedMemory();
|
|
61
|
+
this.gl.bindRenderbuffer(GL.RENDERBUFFER, this.handle);
|
|
62
|
+
if (samples !== 0) {
|
|
63
|
+
this.gl.renderbufferStorageMultisample(GL.RENDERBUFFER, samples, this.glFormat, width, height);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.gl.renderbufferStorage(GL.RENDERBUFFER, this.glFormat, width, height);
|
|
67
|
+
}
|
|
68
|
+
this.gl.bindRenderbuffer(GL.RENDERBUFFER, null);
|
|
69
|
+
this.trackAllocatedMemory(width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat));
|
|
70
|
+
}
|
|
71
|
+
// RESOURCE IMPLEMENTATION
|
|
72
|
+
_createHandle() {
|
|
73
|
+
return this.gl.createRenderbuffer();
|
|
74
|
+
}
|
|
75
|
+
_deleteHandle() {
|
|
76
|
+
this.gl.deleteRenderbuffer(this.handle);
|
|
77
|
+
this.trackDeallocatedMemory();
|
|
78
|
+
}
|
|
79
|
+
_bindHandle(handle) {
|
|
80
|
+
this.gl.bindRenderbuffer(GL.RENDERBUFFER, handle);
|
|
62
81
|
}
|
|
63
|
-
this.gl.bindRenderbuffer(36161, null);
|
|
64
|
-
this.trackAllocatedMemory(width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2));
|
|
65
|
-
}
|
|
66
|
-
_createHandle() {
|
|
67
|
-
return this.gl.createRenderbuffer();
|
|
68
|
-
}
|
|
69
|
-
_deleteHandle() {
|
|
70
|
-
this.gl.deleteRenderbuffer(this.handle);
|
|
71
|
-
this.trackDeallocatedMemory();
|
|
72
|
-
}
|
|
73
|
-
_bindHandle(handle) {
|
|
74
|
-
this.gl.bindRenderbuffer(36161, handle);
|
|
75
|
-
}
|
|
76
82
|
}
|
|
77
|
-
WEBGLRenderbuffer.defaultProps = {
|
|
78
|
-
id: undefined,
|
|
79
|
-
handle: undefined,
|
|
80
|
-
userData: undefined,
|
|
81
|
-
format: undefined,
|
|
82
|
-
width: 1,
|
|
83
|
-
height: 1,
|
|
84
|
-
samples: 0
|
|
85
|
-
};
|
|
86
|
-
//# sourceMappingURL=webgl-renderbuffer.js.map
|
|
@@ -7,7 +7,7 @@ import { WebGLDevice } from '../webgl-device';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare abstract class WebGLResource<Props extends ResourceProps> extends Resource<Props> {
|
|
9
9
|
readonly device: WebGLDevice;
|
|
10
|
-
readonly gl:
|
|
10
|
+
readonly gl: WebGL2RenderingContext;
|
|
11
11
|
readonly gl2: WebGL2RenderingContext;
|
|
12
12
|
private _handle;
|
|
13
13
|
private _bound;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl-resource.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-resource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAkC,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AACzD,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"webgl-resource.d.ts","sourceRoot":"","sources":["../../../src/adapter/objects/webgl-resource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAkC,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AACzD,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AACtC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAO5C;;GAEG;AACH,8BAAsB,aAAa,CAAC,KAAK,SAAS,aAAa,CAAE,SAAQ,QAAQ,CAAC,KAAK,CAAC;IACtF,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,EAAE,EAAE,sBAAsB,CAAC;IACpC,QAAQ,CAAC,GAAG,EAAE,sBAAsB,CAAC;IACrC,OAAO,CAAC,OAAO,CAAM;IAErB,OAAO,CAAC,MAAM,CAAS;IAEvB,UAAU,SAAK;gBAEH,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC;IA2B9D,QAAQ,IAAI,MAAM;IAI3B,IAAI,MAAM,QAWT;IAEQ,MAAM,CAAC,EAAC,cAAsB,EAAC;;KAAK;IAmB7C,IAAI,CAAC,YAAY,MAAc;IAuB/B,MAAM;IAIN;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,GAAQ,GAAG,GAAG;IA2BjD,aAAa,CAAC,OAAO,GAAE;QAAC,UAAU,CAAC,EAAE,GAAG,CAAC;QAAC,IAAI,CAAC,EAAE,GAAG,CAAA;KAAM;IAiC1D;;;;;;;;OAQG;IACH,YAAY,CAAC,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAkClD,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC;IAQzC,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE;IAK5E,UAAU,CAAC,KAAK,EAAE,aAAa;IAG/B,aAAa;IAIb,aAAa;IAIb,WAAW,CAAC,MAAM,EAAE,GAAG;IAIvB,kBAAkB;IAIlB,aAAa,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM;IAI5D,aAAa,CAAC,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG;CAuC7C"}
|