@luma.gl/webgl 9.0.0-beta.5 → 9.0.0-beta.7
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.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +128 -71
- package/dist/adapter/converters/sampler-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js +20 -19
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -1
- package/dist/adapter/converters/shader-formats.js +40 -20
- package/dist/adapter/converters/texture-formats.d.ts +16 -11
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +224 -205
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +22 -21
- package/dist/adapter/device-helpers/webgl-device-features.d.ts +19 -5
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +89 -43
- package/dist/adapter/device-helpers/webgl-device-info.d.ts +2 -1
- package/dist/adapter/device-helpers/webgl-device-info.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-info.js +22 -19
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts +33 -48
- package/dist/adapter/device-helpers/webgl-device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-limits.js +42 -87
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -1
- package/dist/adapter/helpers/decode-webgl-types.js +47 -46
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +35 -34
- package/dist/adapter/helpers/parse-shader-compiler-log.d.ts.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +42 -41
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js +40 -39
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js +2 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +2 -2
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +30 -17
- package/dist/adapter/objects/webgl-resource.d.ts +2 -24
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +6 -101
- package/dist/adapter/resources/webgl-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +16 -15
- package/dist/adapter/resources/webgl-command-buffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +32 -31
- package/dist/adapter/resources/webgl-command-encoder.d.ts +8 -3
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +4 -2
- package/dist/adapter/resources/webgl-external-texture.js +6 -5
- package/dist/adapter/resources/webgl-framebuffer.d.ts +6 -10
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +60 -53
- package/dist/adapter/resources/webgl-query-set.d.ts +44 -0
- package/dist/adapter/resources/webgl-query-set.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-query-set.js +136 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts +3 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +20 -12
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +4 -5
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +52 -61
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +5 -4
- package/dist/adapter/resources/webgl-shader.d.ts +3 -2
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +15 -9
- package/dist/adapter/resources/webgl-texture-view.d.ts +14 -0
- package/dist/adapter/resources/webgl-texture-view.d.ts.map +1 -0
- package/dist/adapter/resources/webgl-texture-view.js +18 -0
- package/dist/adapter/resources/webgl-texture.d.ts +6 -4
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +39 -32
- 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 +10 -10
- package/dist/adapter/resources/webgl-vertex-array.d.ts +3 -3
- package/dist/adapter/resources/webgl-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-vertex-array.js +10 -9
- package/dist/adapter/webgl-canvas-context.d.ts +2 -2
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +3 -2
- package/dist/adapter/webgl-device.d.ts +35 -30
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +110 -109
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +8 -7
- package/dist/classic/clear.d.ts.map +1 -1
- package/dist/classic/clear.js +5 -4
- package/dist/classic/copy-and-blit.d.ts +1 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +19 -19
- package/dist/classic/format-utils.d.ts.map +1 -1
- package/dist/classic/format-utils.js +16 -15
- package/dist/classic/typed-array-utils.d.ts.map +1 -1
- package/dist/classic/typed-array-utils.js +20 -19
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +2 -1
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +7 -6
- package/dist/context/{context → helpers}/create-browser-context.d.ts.map +1 -1
- package/dist/context/{context → helpers}/create-browser-context.js +2 -1
- package/dist/context/{context/context-data.d.ts → helpers/webgl-context-data.d.ts} +2 -3
- package/dist/context/helpers/webgl-context-data.d.ts.map +1 -0
- package/dist/context/helpers/webgl-context-data.js +21 -0
- package/dist/context/helpers/webgl-extensions.d.ts +4 -0
- package/dist/context/helpers/webgl-extensions.d.ts.map +1 -0
- package/dist/context/helpers/webgl-extensions.js +10 -0
- package/dist/context/parameters/unified-parameter-api.d.ts +3 -4
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js +7 -11
- package/dist/context/parameters/webgl-parameter-tables.d.ts +12 -13
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +302 -295
- package/dist/context/state-tracker/deep-array-equal.d.ts.map +1 -1
- package/dist/context/state-tracker/deep-array-equal.js +2 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +5 -4
- package/dist/context/state-tracker/with-parameters.d.ts +2 -3
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +6 -8
- package/dist/dist.dev.js +1635 -1387
- package/dist/index.cjs +1766 -1534
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +25 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist.min.js +6 -6
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +114 -27
- package/src/adapter/converters/sampler-parameters.ts +12 -3
- package/src/adapter/converters/shader-formats.ts +47 -22
- package/src/adapter/converters/texture-formats.ts +138 -114
- package/src/adapter/converters/vertex-formats.ts +3 -3
- package/src/adapter/device-helpers/webgl-device-features.ts +102 -50
- package/src/adapter/device-helpers/webgl-device-info.ts +28 -19
- package/src/adapter/device-helpers/webgl-device-limits.ts +46 -150
- package/src/adapter/helpers/decode-webgl-types.ts +13 -7
- package/src/adapter/helpers/get-shader-layout.ts +4 -3
- package/src/adapter/helpers/parse-shader-compiler-log.ts +10 -6
- package/src/adapter/helpers/set-uniform.ts +2 -1
- package/src/adapter/helpers/webgl-topology-utils.ts +10 -3
- package/src/adapter/objects/constants-to-keys.ts +2 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +36 -14
- package/src/adapter/objects/webgl-resource.ts +7 -125
- package/src/adapter/resources/webgl-buffer.ts +4 -3
- package/src/adapter/resources/webgl-command-buffer.ts +5 -5
- package/src/adapter/resources/webgl-command-encoder.ts +14 -11
- package/src/adapter/resources/webgl-external-texture.ts +6 -5
- package/src/adapter/resources/webgl-framebuffer.ts +61 -53
- package/src/adapter/resources/webgl-query-set.ts +171 -0
- package/src/adapter/resources/webgl-render-pass.ts +20 -11
- package/src/adapter/resources/webgl-render-pipeline.ts +54 -54
- package/src/adapter/resources/webgl-sampler.ts +2 -1
- package/src/adapter/resources/webgl-shader.ts +12 -5
- package/src/adapter/resources/webgl-texture-view.ts +28 -0
- package/src/adapter/resources/webgl-texture.ts +14 -3
- package/src/adapter/resources/webgl-transform-feedback.ts +2 -7
- package/src/adapter/resources/webgl-vertex-array.ts +4 -3
- package/src/adapter/webgl-canvas-context.ts +6 -4
- package/src/adapter/webgl-device.ts +116 -107
- package/src/classic/accessor.ts +5 -4
- package/src/classic/clear.ts +14 -8
- package/src/classic/copy-and-blit.ts +11 -4
- package/src/classic/format-utils.ts +2 -1
- package/src/classic/typed-array-utils.ts +3 -7
- package/src/context/debug/spector.ts +9 -6
- package/src/context/debug/webgl-developer-tools.ts +27 -14
- package/src/context/{context → helpers}/create-browser-context.ts +3 -2
- package/src/context/helpers/webgl-context-data.ts +31 -0
- package/src/context/helpers/webgl-extensions.ts +17 -0
- package/src/context/parameters/unified-parameter-api.ts +6 -17
- package/src/context/parameters/webgl-parameter-tables.ts +69 -32
- package/src/context/state-tracker/deep-array-equal.ts +2 -1
- package/src/context/state-tracker/track-context-state.ts +11 -6
- package/src/context/state-tracker/with-parameters.ts +8 -8
- package/src/index.ts +7 -6
- package/src/types.ts +2 -1
- package/dist/adapter/device-helpers/device-features.d.ts +0 -6
- package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-features.js +0 -65
- package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
- package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
- package/dist/adapter/device-helpers/device-limits.js +0 -92
- package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
- package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
- package/dist/adapter/device-helpers/get-device-info.js +0 -87
- package/dist/context/context/context-data.d.ts.map +0 -1
- package/dist/context/context/context-data.js +0 -33
- package/src/context/context/context-data.ts +0 -44
- /package/dist/context/{context → helpers}/create-browser-context.d.ts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,6 @@ __export(dist_exports, {
|
|
|
30
30
|
WEBGLFramebuffer: () => WEBGLFramebuffer,
|
|
31
31
|
WEBGLRenderPass: () => WEBGLRenderPass,
|
|
32
32
|
WEBGLRenderPipeline: () => WEBGLRenderPipeline,
|
|
33
|
-
WEBGLRenderbuffer: () => WEBGLRenderbuffer,
|
|
34
33
|
WEBGLResource: () => WebGLResource,
|
|
35
34
|
WEBGLSampler: () => WEBGLSampler,
|
|
36
35
|
WEBGLShader: () => WEBGLShader,
|
|
@@ -41,6 +40,7 @@ __export(dist_exports, {
|
|
|
41
40
|
WebGLDevice: () => WebGLDevice,
|
|
42
41
|
WebGLResource: () => WebGLResource,
|
|
43
42
|
_TEXTURE_FORMATS: () => TEXTURE_FORMATS,
|
|
43
|
+
_WEBGLRenderbuffer: () => WEBGLRenderbuffer,
|
|
44
44
|
convertGLToTextureFormat: () => convertGLToTextureFormat,
|
|
45
45
|
getGLParameters: () => getGLParameters,
|
|
46
46
|
getShaderLayout: () => getShaderLayout,
|
|
@@ -56,8 +56,7 @@ __export(dist_exports, {
|
|
|
56
56
|
module.exports = __toCommonJS(dist_exports);
|
|
57
57
|
|
|
58
58
|
// dist/adapter/webgl-device.js
|
|
59
|
-
var
|
|
60
|
-
var import_env3 = require("@probe.gl/env");
|
|
59
|
+
var import_core27 = require("@luma.gl/core");
|
|
61
60
|
|
|
62
61
|
// dist/context/state-tracker/track-context-state.js
|
|
63
62
|
var import_core = require("@luma.gl/core");
|
|
@@ -65,102 +64,99 @@ var import_core = require("@luma.gl/core");
|
|
|
65
64
|
// dist/context/parameters/webgl-parameter-tables.js
|
|
66
65
|
var import_constants = require("@luma.gl/constants");
|
|
67
66
|
var GL_PARAMETER_DEFAULTS = {
|
|
68
|
-
[
|
|
69
|
-
[
|
|
70
|
-
[
|
|
71
|
-
[
|
|
72
|
-
[
|
|
73
|
-
[
|
|
74
|
-
[
|
|
75
|
-
[
|
|
76
|
-
[
|
|
67
|
+
[3042]: false,
|
|
68
|
+
[32773]: new Float32Array([0, 0, 0, 0]),
|
|
69
|
+
[32777]: 32774,
|
|
70
|
+
[34877]: 32774,
|
|
71
|
+
[32969]: 1,
|
|
72
|
+
[32968]: 0,
|
|
73
|
+
[32971]: 1,
|
|
74
|
+
[32970]: 0,
|
|
75
|
+
[3106]: new Float32Array([0, 0, 0, 0]),
|
|
77
76
|
// TBD
|
|
78
|
-
[
|
|
79
|
-
[
|
|
80
|
-
[
|
|
81
|
-
[
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
77
|
+
[3107]: [true, true, true, true],
|
|
78
|
+
[2884]: false,
|
|
79
|
+
[2885]: 1029,
|
|
80
|
+
[2929]: false,
|
|
81
|
+
[2931]: 1,
|
|
82
|
+
[2932]: 513,
|
|
83
|
+
[2928]: new Float32Array([0, 1]),
|
|
85
84
|
// TBD
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[
|
|
85
|
+
[2930]: true,
|
|
86
|
+
[3024]: true,
|
|
87
|
+
[35725]: null,
|
|
89
88
|
// FRAMEBUFFER_BINDING and DRAW_FRAMEBUFFER_BINDING(WebGL2) refer same state.
|
|
90
|
-
[
|
|
91
|
-
[
|
|
92
|
-
[
|
|
93
|
-
[
|
|
94
|
-
[
|
|
95
|
-
[
|
|
96
|
-
[
|
|
97
|
-
[
|
|
98
|
-
[
|
|
99
|
-
[
|
|
100
|
-
[
|
|
101
|
-
[
|
|
102
|
-
[
|
|
103
|
-
[
|
|
104
|
-
[
|
|
89
|
+
[36006]: null,
|
|
90
|
+
[36007]: null,
|
|
91
|
+
[34229]: null,
|
|
92
|
+
[34964]: null,
|
|
93
|
+
[2886]: 2305,
|
|
94
|
+
[33170]: 4352,
|
|
95
|
+
[2849]: 1,
|
|
96
|
+
[32823]: false,
|
|
97
|
+
[32824]: 0,
|
|
98
|
+
[10752]: 0,
|
|
99
|
+
[32926]: false,
|
|
100
|
+
[32928]: false,
|
|
101
|
+
[32938]: 1,
|
|
102
|
+
[32939]: false,
|
|
103
|
+
[3089]: false,
|
|
105
104
|
// Note: Dynamic value. If scissor test enabled we expect users to set correct scissor box
|
|
106
|
-
[
|
|
107
|
-
[
|
|
108
|
-
[
|
|
109
|
-
[
|
|
110
|
-
[
|
|
111
|
-
[
|
|
112
|
-
[
|
|
113
|
-
[
|
|
114
|
-
[
|
|
115
|
-
[
|
|
116
|
-
[
|
|
117
|
-
[
|
|
118
|
-
[
|
|
119
|
-
[
|
|
120
|
-
[
|
|
121
|
-
[
|
|
122
|
-
[
|
|
105
|
+
[3088]: new Int32Array([0, 0, 1024, 1024]),
|
|
106
|
+
[2960]: false,
|
|
107
|
+
[2961]: 0,
|
|
108
|
+
[2968]: 4294967295,
|
|
109
|
+
[36005]: 4294967295,
|
|
110
|
+
[2962]: 519,
|
|
111
|
+
[2967]: 0,
|
|
112
|
+
[2963]: 4294967295,
|
|
113
|
+
[34816]: 519,
|
|
114
|
+
[36003]: 0,
|
|
115
|
+
[36004]: 4294967295,
|
|
116
|
+
[2964]: 7680,
|
|
117
|
+
[2965]: 7680,
|
|
118
|
+
[2966]: 7680,
|
|
119
|
+
[34817]: 7680,
|
|
120
|
+
[34818]: 7680,
|
|
121
|
+
[34819]: 7680,
|
|
123
122
|
// Dynamic value: We use [0, 0, 1024, 1024] as default, but usually this is updated in each frame.
|
|
124
|
-
[
|
|
125
|
-
|
|
126
|
-
[
|
|
127
|
-
[
|
|
128
|
-
[
|
|
129
|
-
[
|
|
130
|
-
[
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
[
|
|
134
|
-
[
|
|
135
|
-
[
|
|
136
|
-
[
|
|
137
|
-
[
|
|
138
|
-
[
|
|
139
|
-
[
|
|
140
|
-
[
|
|
141
|
-
[
|
|
142
|
-
[
|
|
143
|
-
[
|
|
144
|
-
[
|
|
145
|
-
[
|
|
146
|
-
[import_constants.GL.UNPACK_SKIP_PIXELS]: 0,
|
|
147
|
-
[import_constants.GL.UNPACK_SKIP_ROWS]: 0,
|
|
148
|
-
[import_constants.GL.UNPACK_SKIP_IMAGES]: 0
|
|
123
|
+
[2978]: [0, 0, 1024, 1024],
|
|
124
|
+
[36389]: null,
|
|
125
|
+
[36662]: null,
|
|
126
|
+
[36663]: null,
|
|
127
|
+
[35053]: null,
|
|
128
|
+
[35055]: null,
|
|
129
|
+
[35723]: 4352,
|
|
130
|
+
[36010]: null,
|
|
131
|
+
[35977]: false,
|
|
132
|
+
[3333]: 4,
|
|
133
|
+
[3317]: 4,
|
|
134
|
+
[37440]: false,
|
|
135
|
+
[37441]: false,
|
|
136
|
+
[37443]: 37444,
|
|
137
|
+
[3330]: 0,
|
|
138
|
+
[3332]: 0,
|
|
139
|
+
[3331]: 0,
|
|
140
|
+
[3314]: 0,
|
|
141
|
+
[32878]: 0,
|
|
142
|
+
[3316]: 0,
|
|
143
|
+
[3315]: 0,
|
|
144
|
+
[32877]: 0
|
|
149
145
|
};
|
|
150
146
|
var enable = (gl, value, key) => value ? gl.enable(key) : gl.disable(key);
|
|
151
147
|
var hint = (gl, value, key) => gl.hint(key, value);
|
|
152
148
|
var pixelStorei = (gl, value, key) => gl.pixelStorei(key, value);
|
|
153
149
|
var bindFramebuffer = (gl, value, key) => {
|
|
154
|
-
const target = key ===
|
|
150
|
+
const target = key === 36006 ? 36009 : 36008;
|
|
155
151
|
return gl.bindFramebuffer(target, value);
|
|
156
152
|
};
|
|
157
153
|
var bindBuffer = (gl, value, key) => {
|
|
158
154
|
const bindingMap = {
|
|
159
|
-
[
|
|
160
|
-
[
|
|
161
|
-
[
|
|
162
|
-
[
|
|
163
|
-
[
|
|
155
|
+
[34964]: 34962,
|
|
156
|
+
[36662]: 36662,
|
|
157
|
+
[36663]: 36663,
|
|
158
|
+
[35053]: 35051,
|
|
159
|
+
[35055]: 35052
|
|
164
160
|
};
|
|
165
161
|
const glTarget = bindingMap[key];
|
|
166
162
|
gl.bindBuffer(glTarget, value);
|
|
@@ -169,93 +165,108 @@ function isArray(array) {
|
|
|
169
165
|
return Array.isArray(array) || ArrayBuffer.isView(array) && !(array instanceof DataView);
|
|
170
166
|
}
|
|
171
167
|
var GL_PARAMETER_SETTERS = {
|
|
172
|
-
[
|
|
173
|
-
[
|
|
174
|
-
[
|
|
175
|
-
[
|
|
176
|
-
[
|
|
177
|
-
[
|
|
178
|
-
[
|
|
179
|
-
[
|
|
180
|
-
[
|
|
181
|
-
[
|
|
182
|
-
[
|
|
183
|
-
[
|
|
184
|
-
[
|
|
185
|
-
[
|
|
186
|
-
[
|
|
187
|
-
[
|
|
188
|
-
[
|
|
189
|
-
[
|
|
190
|
-
[
|
|
191
|
-
[
|
|
192
|
-
[
|
|
193
|
-
[
|
|
168
|
+
[3042]: enable,
|
|
169
|
+
[32773]: (gl, value) => gl.blendColor(...value),
|
|
170
|
+
[32777]: "blendEquation",
|
|
171
|
+
[34877]: "blendEquation",
|
|
172
|
+
[32969]: "blendFunc",
|
|
173
|
+
[32968]: "blendFunc",
|
|
174
|
+
[32971]: "blendFunc",
|
|
175
|
+
[32970]: "blendFunc",
|
|
176
|
+
[3106]: (gl, value) => gl.clearColor(...value),
|
|
177
|
+
[3107]: (gl, value) => gl.colorMask(...value),
|
|
178
|
+
[2884]: enable,
|
|
179
|
+
[2885]: (gl, value) => gl.cullFace(value),
|
|
180
|
+
[2929]: enable,
|
|
181
|
+
[2931]: (gl, value) => gl.clearDepth(value),
|
|
182
|
+
[2932]: (gl, value) => gl.depthFunc(value),
|
|
183
|
+
[2928]: (gl, value) => gl.depthRange(...value),
|
|
184
|
+
[2930]: (gl, value) => gl.depthMask(value),
|
|
185
|
+
[3024]: enable,
|
|
186
|
+
[35723]: hint,
|
|
187
|
+
[35725]: (gl, value) => gl.useProgram(value),
|
|
188
|
+
[36007]: (gl, value) => gl.bindRenderbuffer(36161, value),
|
|
189
|
+
[36389]: (gl, value) => {
|
|
194
190
|
var _a;
|
|
195
|
-
return (_a = gl.bindTransformFeedback) == null ? void 0 : _a.call(gl,
|
|
191
|
+
return (_a = gl.bindTransformFeedback) == null ? void 0 : _a.call(gl, 36386, value);
|
|
196
192
|
},
|
|
197
|
-
[
|
|
193
|
+
[34229]: (gl, value) => gl.bindVertexArray(value),
|
|
198
194
|
// NOTE: FRAMEBUFFER_BINDING and DRAW_FRAMEBUFFER_BINDING(WebGL2) refer same state.
|
|
199
|
-
[
|
|
200
|
-
[
|
|
195
|
+
[36006]: bindFramebuffer,
|
|
196
|
+
[36010]: bindFramebuffer,
|
|
201
197
|
// Buffers
|
|
202
|
-
[
|
|
203
|
-
[
|
|
204
|
-
[
|
|
205
|
-
[
|
|
206
|
-
[
|
|
207
|
-
[
|
|
208
|
-
[
|
|
209
|
-
[
|
|
210
|
-
[
|
|
211
|
-
[
|
|
212
|
-
[
|
|
213
|
-
[
|
|
214
|
-
[
|
|
215
|
-
[
|
|
216
|
-
[
|
|
217
|
-
[
|
|
218
|
-
[
|
|
219
|
-
[
|
|
220
|
-
[
|
|
221
|
-
[
|
|
222
|
-
[
|
|
223
|
-
[
|
|
224
|
-
[
|
|
225
|
-
[
|
|
226
|
-
[
|
|
227
|
-
[
|
|
228
|
-
[
|
|
229
|
-
[
|
|
230
|
-
[
|
|
231
|
-
[
|
|
232
|
-
[
|
|
233
|
-
[
|
|
234
|
-
[
|
|
235
|
-
[
|
|
236
|
-
[
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
-
[
|
|
240
|
-
|
|
241
|
-
[
|
|
242
|
-
|
|
243
|
-
//
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
[
|
|
247
|
-
[
|
|
248
|
-
[
|
|
249
|
-
[
|
|
250
|
-
[
|
|
251
|
-
[
|
|
252
|
-
[
|
|
198
|
+
[34964]: bindBuffer,
|
|
199
|
+
[36662]: bindBuffer,
|
|
200
|
+
[36663]: bindBuffer,
|
|
201
|
+
[35053]: bindBuffer,
|
|
202
|
+
[35055]: bindBuffer,
|
|
203
|
+
[2886]: (gl, value) => gl.frontFace(value),
|
|
204
|
+
[33170]: hint,
|
|
205
|
+
[2849]: (gl, value) => gl.lineWidth(value),
|
|
206
|
+
[32823]: enable,
|
|
207
|
+
[32824]: "polygonOffset",
|
|
208
|
+
[10752]: "polygonOffset",
|
|
209
|
+
[35977]: enable,
|
|
210
|
+
[32926]: enable,
|
|
211
|
+
[32928]: enable,
|
|
212
|
+
[32938]: "sampleCoverage",
|
|
213
|
+
[32939]: "sampleCoverage",
|
|
214
|
+
[3089]: enable,
|
|
215
|
+
[3088]: (gl, value) => gl.scissor(...value),
|
|
216
|
+
[2960]: enable,
|
|
217
|
+
[2961]: (gl, value) => gl.clearStencil(value),
|
|
218
|
+
[2968]: (gl, value) => gl.stencilMaskSeparate(1028, value),
|
|
219
|
+
[36005]: (gl, value) => gl.stencilMaskSeparate(1029, value),
|
|
220
|
+
[2962]: "stencilFuncFront",
|
|
221
|
+
[2967]: "stencilFuncFront",
|
|
222
|
+
[2963]: "stencilFuncFront",
|
|
223
|
+
[34816]: "stencilFuncBack",
|
|
224
|
+
[36003]: "stencilFuncBack",
|
|
225
|
+
[36004]: "stencilFuncBack",
|
|
226
|
+
[2964]: "stencilOpFront",
|
|
227
|
+
[2965]: "stencilOpFront",
|
|
228
|
+
[2966]: "stencilOpFront",
|
|
229
|
+
[34817]: "stencilOpBack",
|
|
230
|
+
[34818]: "stencilOpBack",
|
|
231
|
+
[34819]: "stencilOpBack",
|
|
232
|
+
[2978]: (gl, value) => gl.viewport(...value),
|
|
233
|
+
// WEBGL2 EXTENSIONS
|
|
234
|
+
// EXT_depth_clamp https://registry.khronos.org/webgl/extensions/EXT_depth_clamp/
|
|
235
|
+
[34383]: enable,
|
|
236
|
+
// WEBGL_provoking_vertex https://registry.khronos.org/webgl/extensions/WEBGL_provoking_vertex/
|
|
237
|
+
// [GL.PROVOKING_VERTEX_WEBL]: TODO - extension function needed
|
|
238
|
+
// WEBGL_polygon_mode https://registry.khronos.org/webgl/extensions/WEBGL_polygon_mode/
|
|
239
|
+
// POLYGON_MODE_WEBGL TODO - extension function needed
|
|
240
|
+
[10754]: enable,
|
|
241
|
+
// WEBGL_clip_cull_distance https://registry.khronos.org/webgl/extensions/WEBGL_clip_cull_distance/
|
|
242
|
+
[12288]: enable,
|
|
243
|
+
[12289]: enable,
|
|
244
|
+
[12290]: enable,
|
|
245
|
+
[12291]: enable,
|
|
246
|
+
[12292]: enable,
|
|
247
|
+
[12293]: enable,
|
|
248
|
+
[12294]: enable,
|
|
249
|
+
[12295]: enable,
|
|
250
|
+
// PIXEL PACK/UNPACK MODES
|
|
251
|
+
[3333]: pixelStorei,
|
|
252
|
+
[3317]: pixelStorei,
|
|
253
|
+
[37440]: pixelStorei,
|
|
254
|
+
[37441]: pixelStorei,
|
|
255
|
+
[37443]: pixelStorei,
|
|
256
|
+
[3330]: pixelStorei,
|
|
257
|
+
[3332]: pixelStorei,
|
|
258
|
+
[3331]: pixelStorei,
|
|
259
|
+
[3314]: pixelStorei,
|
|
260
|
+
[32878]: pixelStorei,
|
|
261
|
+
[3316]: pixelStorei,
|
|
262
|
+
[3315]: pixelStorei,
|
|
263
|
+
[32877]: pixelStorei,
|
|
253
264
|
// Function-style setters
|
|
254
265
|
framebuffer: (gl, framebuffer) => {
|
|
255
266
|
const handle = framebuffer && "handle" in framebuffer ? framebuffer.handle : framebuffer;
|
|
256
|
-
return gl.bindFramebuffer(
|
|
267
|
+
return gl.bindFramebuffer(36160, handle);
|
|
257
268
|
},
|
|
258
|
-
blend: (gl, value) => value ? gl.enable(
|
|
269
|
+
blend: (gl, value) => value ? gl.enable(3042) : gl.disable(3042),
|
|
259
270
|
blendColor: (gl, value) => gl.blendColor(...value),
|
|
260
271
|
blendEquation: (gl, args) => {
|
|
261
272
|
const separateModes = typeof args === "number" ? [args, args] : args;
|
|
@@ -269,42 +280,42 @@ var GL_PARAMETER_SETTERS = {
|
|
|
269
280
|
clearDepth: (gl, value) => gl.clearDepth(value),
|
|
270
281
|
clearStencil: (gl, value) => gl.clearStencil(value),
|
|
271
282
|
colorMask: (gl, value) => gl.colorMask(...value),
|
|
272
|
-
cull: (gl, value) => value ? gl.enable(
|
|
283
|
+
cull: (gl, value) => value ? gl.enable(2884) : gl.disable(2884),
|
|
273
284
|
cullFace: (gl, value) => gl.cullFace(value),
|
|
274
|
-
depthTest: (gl, value) => value ? gl.enable(
|
|
285
|
+
depthTest: (gl, value) => value ? gl.enable(2929) : gl.disable(2929),
|
|
275
286
|
depthFunc: (gl, value) => gl.depthFunc(value),
|
|
276
287
|
depthMask: (gl, value) => gl.depthMask(value),
|
|
277
288
|
depthRange: (gl, value) => gl.depthRange(...value),
|
|
278
|
-
dither: (gl, value) => value ? gl.enable(
|
|
289
|
+
dither: (gl, value) => value ? gl.enable(3024) : gl.disable(3024),
|
|
279
290
|
derivativeHint: (gl, value) => {
|
|
280
|
-
gl.hint(
|
|
291
|
+
gl.hint(35723, value);
|
|
281
292
|
},
|
|
282
293
|
frontFace: (gl, value) => gl.frontFace(value),
|
|
283
|
-
mipmapHint: (gl, value) => gl.hint(
|
|
294
|
+
mipmapHint: (gl, value) => gl.hint(33170, value),
|
|
284
295
|
lineWidth: (gl, value) => gl.lineWidth(value),
|
|
285
|
-
polygonOffsetFill: (gl, value) => value ? gl.enable(
|
|
296
|
+
polygonOffsetFill: (gl, value) => value ? gl.enable(32823) : gl.disable(32823),
|
|
286
297
|
polygonOffset: (gl, value) => gl.polygonOffset(...value),
|
|
287
298
|
sampleCoverage: (gl, value) => gl.sampleCoverage(...value),
|
|
288
|
-
scissorTest: (gl, value) => value ? gl.enable(
|
|
299
|
+
scissorTest: (gl, value) => value ? gl.enable(3089) : gl.disable(3089),
|
|
289
300
|
scissor: (gl, value) => gl.scissor(...value),
|
|
290
|
-
stencilTest: (gl, value) => value ? gl.enable(
|
|
301
|
+
stencilTest: (gl, value) => value ? gl.enable(2960) : gl.disable(2960),
|
|
291
302
|
stencilMask: (gl, value) => {
|
|
292
303
|
value = isArray(value) ? value : [value, value];
|
|
293
304
|
const [mask, backMask] = value;
|
|
294
|
-
gl.stencilMaskSeparate(
|
|
295
|
-
gl.stencilMaskSeparate(
|
|
305
|
+
gl.stencilMaskSeparate(1028, mask);
|
|
306
|
+
gl.stencilMaskSeparate(1029, backMask);
|
|
296
307
|
},
|
|
297
308
|
stencilFunc: (gl, args) => {
|
|
298
309
|
args = isArray(args) && args.length === 3 ? [...args, ...args] : args;
|
|
299
310
|
const [func, ref, mask, backFunc, backRef, backMask] = args;
|
|
300
|
-
gl.stencilFuncSeparate(
|
|
301
|
-
gl.stencilFuncSeparate(
|
|
311
|
+
gl.stencilFuncSeparate(1028, func, ref, mask);
|
|
312
|
+
gl.stencilFuncSeparate(1029, backFunc, backRef, backMask);
|
|
302
313
|
},
|
|
303
314
|
stencilOp: (gl, args) => {
|
|
304
315
|
args = isArray(args) && args.length === 3 ? [...args, ...args] : args;
|
|
305
316
|
const [sfail, dpfail, dppass, backSfail, backDpfail, backDppass] = args;
|
|
306
|
-
gl.stencilOpSeparate(
|
|
307
|
-
gl.stencilOpSeparate(
|
|
317
|
+
gl.stencilOpSeparate(1028, sfail, dpfail, dppass);
|
|
318
|
+
gl.stencilOpSeparate(1029, backSfail, backDpfail, backDppass);
|
|
308
319
|
},
|
|
309
320
|
viewport: (gl, value) => gl.viewport(...value)
|
|
310
321
|
};
|
|
@@ -312,14 +323,14 @@ function getValue(glEnum, values, cache) {
|
|
|
312
323
|
return values[glEnum] !== void 0 ? values[glEnum] : cache[glEnum];
|
|
313
324
|
}
|
|
314
325
|
var GL_COMPOSITE_PARAMETER_SETTERS = {
|
|
315
|
-
blendEquation: (gl, values, cache) => gl.blendEquationSeparate(getValue(
|
|
316
|
-
blendFunc: (gl, values, cache) => gl.blendFuncSeparate(getValue(
|
|
317
|
-
polygonOffset: (gl, values, cache) => gl.polygonOffset(getValue(
|
|
318
|
-
sampleCoverage: (gl, values, cache) => gl.sampleCoverage(getValue(
|
|
319
|
-
stencilFuncFront: (gl, values, cache) => gl.stencilFuncSeparate(
|
|
320
|
-
stencilFuncBack: (gl, values, cache) => gl.stencilFuncSeparate(
|
|
321
|
-
stencilOpFront: (gl, values, cache) => gl.stencilOpSeparate(
|
|
322
|
-
stencilOpBack: (gl, values, cache) => gl.stencilOpSeparate(
|
|
326
|
+
blendEquation: (gl, values, cache) => gl.blendEquationSeparate(getValue(32777, values, cache), getValue(34877, values, cache)),
|
|
327
|
+
blendFunc: (gl, values, cache) => gl.blendFuncSeparate(getValue(32969, values, cache), getValue(32968, values, cache), getValue(32971, values, cache), getValue(32970, values, cache)),
|
|
328
|
+
polygonOffset: (gl, values, cache) => gl.polygonOffset(getValue(32824, values, cache), getValue(10752, values, cache)),
|
|
329
|
+
sampleCoverage: (gl, values, cache) => gl.sampleCoverage(getValue(32938, values, cache), getValue(32939, values, cache)),
|
|
330
|
+
stencilFuncFront: (gl, values, cache) => gl.stencilFuncSeparate(1028, getValue(2962, values, cache), getValue(2967, values, cache), getValue(2963, values, cache)),
|
|
331
|
+
stencilFuncBack: (gl, values, cache) => gl.stencilFuncSeparate(1029, getValue(34816, values, cache), getValue(36003, values, cache), getValue(36004, values, cache)),
|
|
332
|
+
stencilOpFront: (gl, values, cache) => gl.stencilOpSeparate(1028, getValue(2964, values, cache), getValue(2965, values, cache), getValue(2966, values, cache)),
|
|
333
|
+
stencilOpBack: (gl, values, cache) => gl.stencilOpSeparate(1029, getValue(34817, values, cache), getValue(34818, values, cache), getValue(34819, values, cache))
|
|
323
334
|
};
|
|
324
335
|
var GL_HOOKED_SETTERS = {
|
|
325
336
|
// GENERIC SETTERS
|
|
@@ -337,39 +348,39 @@ var GL_HOOKED_SETTERS = {
|
|
|
337
348
|
}),
|
|
338
349
|
// SPECIFIC SETTERS
|
|
339
350
|
useProgram: (update, value) => update({
|
|
340
|
-
[
|
|
351
|
+
[35725]: value
|
|
341
352
|
}),
|
|
342
353
|
bindRenderbuffer: (update, target, value) => update({
|
|
343
|
-
[
|
|
354
|
+
[36007]: value
|
|
344
355
|
}),
|
|
345
356
|
bindTransformFeedback: (update, target, value) => update({
|
|
346
|
-
[
|
|
357
|
+
[36389]: value
|
|
347
358
|
}),
|
|
348
359
|
bindVertexArray: (update, value) => update({
|
|
349
|
-
[
|
|
360
|
+
[34229]: value
|
|
350
361
|
}),
|
|
351
362
|
bindFramebuffer: (update, target, framebuffer) => {
|
|
352
363
|
switch (target) {
|
|
353
|
-
case
|
|
364
|
+
case 36160:
|
|
354
365
|
return update({
|
|
355
|
-
[
|
|
356
|
-
[
|
|
366
|
+
[36006]: framebuffer,
|
|
367
|
+
[36010]: framebuffer
|
|
357
368
|
});
|
|
358
|
-
case
|
|
359
|
-
return update({ [
|
|
360
|
-
case
|
|
361
|
-
return update({ [
|
|
369
|
+
case 36009:
|
|
370
|
+
return update({ [36006]: framebuffer });
|
|
371
|
+
case 36008:
|
|
372
|
+
return update({ [36010]: framebuffer });
|
|
362
373
|
default:
|
|
363
374
|
return null;
|
|
364
375
|
}
|
|
365
376
|
},
|
|
366
377
|
bindBuffer: (update, target, buffer) => {
|
|
367
378
|
const pname = {
|
|
368
|
-
[
|
|
369
|
-
[
|
|
370
|
-
[
|
|
371
|
-
[
|
|
372
|
-
[
|
|
379
|
+
[34962]: [34964],
|
|
380
|
+
[36662]: [36662],
|
|
381
|
+
[36663]: [36663],
|
|
382
|
+
[35051]: [35053],
|
|
383
|
+
[35052]: [35055]
|
|
373
384
|
}[target];
|
|
374
385
|
if (pname) {
|
|
375
386
|
return update({ [pname]: buffer });
|
|
@@ -377,162 +388,154 @@ var GL_HOOKED_SETTERS = {
|
|
|
377
388
|
return { valueChanged: true };
|
|
378
389
|
},
|
|
379
390
|
blendColor: (update, r, g, b, a) => update({
|
|
380
|
-
[
|
|
391
|
+
[32773]: new Float32Array([r, g, b, a])
|
|
381
392
|
}),
|
|
382
393
|
blendEquation: (update, mode) => update({
|
|
383
|
-
[
|
|
384
|
-
[
|
|
394
|
+
[32777]: mode,
|
|
395
|
+
[34877]: mode
|
|
385
396
|
}),
|
|
386
397
|
blendEquationSeparate: (update, modeRGB, modeAlpha) => update({
|
|
387
|
-
[
|
|
388
|
-
[
|
|
398
|
+
[32777]: modeRGB,
|
|
399
|
+
[34877]: modeAlpha
|
|
389
400
|
}),
|
|
390
401
|
blendFunc: (update, src, dst) => update({
|
|
391
|
-
[
|
|
392
|
-
[
|
|
393
|
-
[
|
|
394
|
-
[
|
|
402
|
+
[32969]: src,
|
|
403
|
+
[32968]: dst,
|
|
404
|
+
[32971]: src,
|
|
405
|
+
[32970]: dst
|
|
395
406
|
}),
|
|
396
407
|
blendFuncSeparate: (update, srcRGB, dstRGB, srcAlpha, dstAlpha) => update({
|
|
397
|
-
[
|
|
398
|
-
[
|
|
399
|
-
[
|
|
400
|
-
[
|
|
408
|
+
[32969]: srcRGB,
|
|
409
|
+
[32968]: dstRGB,
|
|
410
|
+
[32971]: srcAlpha,
|
|
411
|
+
[32970]: dstAlpha
|
|
401
412
|
}),
|
|
402
413
|
clearColor: (update, r, g, b, a) => update({
|
|
403
|
-
[
|
|
414
|
+
[3106]: new Float32Array([r, g, b, a])
|
|
404
415
|
}),
|
|
405
416
|
clearDepth: (update, depth) => update({
|
|
406
|
-
[
|
|
417
|
+
[2931]: depth
|
|
407
418
|
}),
|
|
408
419
|
clearStencil: (update, s) => update({
|
|
409
|
-
[
|
|
420
|
+
[2961]: s
|
|
410
421
|
}),
|
|
411
422
|
colorMask: (update, r, g, b, a) => update({
|
|
412
|
-
[
|
|
423
|
+
[3107]: [r, g, b, a]
|
|
413
424
|
}),
|
|
414
425
|
cullFace: (update, mode) => update({
|
|
415
|
-
[
|
|
426
|
+
[2885]: mode
|
|
416
427
|
}),
|
|
417
428
|
depthFunc: (update, func) => update({
|
|
418
|
-
[
|
|
429
|
+
[2932]: func
|
|
419
430
|
}),
|
|
420
431
|
depthRange: (update, zNear, zFar) => update({
|
|
421
|
-
[
|
|
432
|
+
[2928]: new Float32Array([zNear, zFar])
|
|
422
433
|
}),
|
|
423
434
|
depthMask: (update, mask) => update({
|
|
424
|
-
[
|
|
435
|
+
[2930]: mask
|
|
425
436
|
}),
|
|
426
437
|
frontFace: (update, face) => update({
|
|
427
|
-
[
|
|
438
|
+
[2886]: face
|
|
428
439
|
}),
|
|
429
440
|
lineWidth: (update, width) => update({
|
|
430
|
-
[
|
|
441
|
+
[2849]: width
|
|
431
442
|
}),
|
|
432
443
|
polygonOffset: (update, factor, units) => update({
|
|
433
|
-
[
|
|
434
|
-
[
|
|
444
|
+
[32824]: factor,
|
|
445
|
+
[10752]: units
|
|
435
446
|
}),
|
|
436
447
|
sampleCoverage: (update, value, invert) => update({
|
|
437
|
-
[
|
|
438
|
-
[
|
|
448
|
+
[32938]: value,
|
|
449
|
+
[32939]: invert
|
|
439
450
|
}),
|
|
440
451
|
scissor: (update, x, y, width, height) => update({
|
|
441
|
-
[
|
|
452
|
+
[3088]: new Int32Array([x, y, width, height])
|
|
442
453
|
}),
|
|
443
454
|
stencilMask: (update, mask) => update({
|
|
444
|
-
[
|
|
445
|
-
[
|
|
455
|
+
[2968]: mask,
|
|
456
|
+
[36005]: mask
|
|
446
457
|
}),
|
|
447
458
|
stencilMaskSeparate: (update, face, mask) => update({
|
|
448
|
-
[face ===
|
|
459
|
+
[face === 1028 ? 2968 : 36005]: mask
|
|
449
460
|
}),
|
|
450
461
|
stencilFunc: (update, func, ref, mask) => update({
|
|
451
|
-
[
|
|
452
|
-
[
|
|
453
|
-
[
|
|
454
|
-
[
|
|
455
|
-
[
|
|
456
|
-
[
|
|
462
|
+
[2962]: func,
|
|
463
|
+
[2967]: ref,
|
|
464
|
+
[2963]: mask,
|
|
465
|
+
[34816]: func,
|
|
466
|
+
[36003]: ref,
|
|
467
|
+
[36004]: mask
|
|
457
468
|
}),
|
|
458
469
|
stencilFuncSeparate: (update, face, func, ref, mask) => update({
|
|
459
|
-
[face ===
|
|
460
|
-
[face ===
|
|
461
|
-
[face ===
|
|
470
|
+
[face === 1028 ? 2962 : 34816]: func,
|
|
471
|
+
[face === 1028 ? 2967 : 36003]: ref,
|
|
472
|
+
[face === 1028 ? 2963 : 36004]: mask
|
|
462
473
|
}),
|
|
463
474
|
stencilOp: (update, fail, zfail, zpass) => update({
|
|
464
|
-
[
|
|
465
|
-
[
|
|
466
|
-
[
|
|
467
|
-
[
|
|
468
|
-
[
|
|
469
|
-
[
|
|
475
|
+
[2964]: fail,
|
|
476
|
+
[2965]: zfail,
|
|
477
|
+
[2966]: zpass,
|
|
478
|
+
[34817]: fail,
|
|
479
|
+
[34818]: zfail,
|
|
480
|
+
[34819]: zpass
|
|
470
481
|
}),
|
|
471
482
|
stencilOpSeparate: (update, face, fail, zfail, zpass) => update({
|
|
472
|
-
[face ===
|
|
473
|
-
[face ===
|
|
474
|
-
[face ===
|
|
483
|
+
[face === 1028 ? 2964 : 34817]: fail,
|
|
484
|
+
[face === 1028 ? 2965 : 34818]: zfail,
|
|
485
|
+
[face === 1028 ? 2966 : 34819]: zpass
|
|
475
486
|
}),
|
|
476
487
|
viewport: (update, x, y, width, height) => update({
|
|
477
|
-
[
|
|
488
|
+
[2978]: [x, y, width, height]
|
|
478
489
|
})
|
|
479
490
|
};
|
|
480
491
|
var isEnabled = (gl, key) => gl.isEnabled(key);
|
|
481
492
|
var GL_PARAMETER_GETTERS = {
|
|
482
|
-
[
|
|
483
|
-
[
|
|
484
|
-
[
|
|
485
|
-
[
|
|
486
|
-
[
|
|
487
|
-
[
|
|
488
|
-
[
|
|
489
|
-
[
|
|
490
|
-
[
|
|
491
|
-
[
|
|
493
|
+
[3042]: isEnabled,
|
|
494
|
+
[2884]: isEnabled,
|
|
495
|
+
[2929]: isEnabled,
|
|
496
|
+
[3024]: isEnabled,
|
|
497
|
+
[32823]: isEnabled,
|
|
498
|
+
[32926]: isEnabled,
|
|
499
|
+
[32928]: isEnabled,
|
|
500
|
+
[3089]: isEnabled,
|
|
501
|
+
[2960]: isEnabled,
|
|
502
|
+
[35977]: isEnabled
|
|
492
503
|
};
|
|
493
504
|
var NON_CACHE_PARAMETERS = /* @__PURE__ */ new Set([
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
// states depending on ACTIVE_TEXTURE
|
|
525
|
-
import_constants.GL.SAMPLER_BINDING,
|
|
526
|
-
import_constants.GL.TEXTURE_BINDING_2D,
|
|
527
|
-
import_constants.GL.TEXTURE_BINDING_2D_ARRAY,
|
|
528
|
-
import_constants.GL.TEXTURE_BINDING_3D,
|
|
529
|
-
import_constants.GL.TEXTURE_BINDING_CUBE_MAP
|
|
505
|
+
34016,
|
|
506
|
+
36388,
|
|
507
|
+
36387,
|
|
508
|
+
35983,
|
|
509
|
+
35368,
|
|
510
|
+
34965,
|
|
511
|
+
35739,
|
|
512
|
+
35738,
|
|
513
|
+
3074,
|
|
514
|
+
34853,
|
|
515
|
+
34854,
|
|
516
|
+
34855,
|
|
517
|
+
34856,
|
|
518
|
+
34857,
|
|
519
|
+
34858,
|
|
520
|
+
34859,
|
|
521
|
+
34860,
|
|
522
|
+
34861,
|
|
523
|
+
34862,
|
|
524
|
+
34863,
|
|
525
|
+
34864,
|
|
526
|
+
34865,
|
|
527
|
+
34866,
|
|
528
|
+
34867,
|
|
529
|
+
34868,
|
|
530
|
+
35097,
|
|
531
|
+
32873,
|
|
532
|
+
35869,
|
|
533
|
+
32874,
|
|
534
|
+
34068
|
|
530
535
|
]);
|
|
531
536
|
|
|
532
537
|
// dist/context/parameters/unified-parameter-api.js
|
|
533
|
-
function setGLParameters(
|
|
534
|
-
const webglDevice = WebGLDevice.attach(device);
|
|
535
|
-
const gl = webglDevice.gl;
|
|
538
|
+
function setGLParameters(gl, parameters) {
|
|
536
539
|
if (isObjectEmpty(parameters)) {
|
|
537
540
|
return;
|
|
538
541
|
}
|
|
@@ -556,9 +559,7 @@ function setGLParameters(device, parameters) {
|
|
|
556
559
|
}
|
|
557
560
|
}
|
|
558
561
|
}
|
|
559
|
-
function getGLParameters(
|
|
560
|
-
const webglDevice = WebGLDevice.attach(device);
|
|
561
|
-
const gl = webglDevice.gl;
|
|
562
|
+
function getGLParameters(gl, parameters = GL_PARAMETER_DEFAULTS) {
|
|
562
563
|
if (typeof parameters === "number") {
|
|
563
564
|
const key = parameters;
|
|
564
565
|
const getter = GL_PARAMETER_GETTERS[key];
|
|
@@ -572,8 +573,8 @@ function getGLParameters(device, parameters = GL_PARAMETER_DEFAULTS) {
|
|
|
572
573
|
}
|
|
573
574
|
return state;
|
|
574
575
|
}
|
|
575
|
-
function resetGLParameters(
|
|
576
|
-
setGLParameters(
|
|
576
|
+
function resetGLParameters(gl) {
|
|
577
|
+
setGLParameters(gl, GL_PARAMETER_DEFAULTS);
|
|
577
578
|
}
|
|
578
579
|
function isObjectEmpty(object) {
|
|
579
580
|
for (const key in object) {
|
|
@@ -741,7 +742,7 @@ function installProgramSpy(gl) {
|
|
|
741
742
|
};
|
|
742
743
|
}
|
|
743
744
|
|
|
744
|
-
// dist/context/
|
|
745
|
+
// dist/context/helpers/create-browser-context.js
|
|
745
746
|
var DEFAULT_CONTEXT_PROPS = {
|
|
746
747
|
powerPreference: "high-performance",
|
|
747
748
|
// After all, most apps are using WebGL for performance reasons
|
|
@@ -774,15 +775,26 @@ function createBrowserContext(canvas, props) {
|
|
|
774
775
|
|
|
775
776
|
// dist/adapter/device-helpers/webgl-device-info.js
|
|
776
777
|
var import_constants2 = require("@luma.gl/constants");
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
778
|
+
|
|
779
|
+
// dist/context/helpers/webgl-extensions.js
|
|
780
|
+
function getWebGLExtension(gl, name, extensions) {
|
|
781
|
+
if (extensions[name] === void 0) {
|
|
782
|
+
extensions[name] = gl.getExtension(name) || null;
|
|
783
|
+
}
|
|
784
|
+
return extensions[name];
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// dist/adapter/device-helpers/webgl-device-info.js
|
|
788
|
+
function getDeviceInfo(gl, extensions) {
|
|
789
|
+
const vendorMasked = gl.getParameter(7936);
|
|
790
|
+
const rendererMasked = gl.getParameter(7937);
|
|
791
|
+
getWebGLExtension(gl, "WEBGL_debug_renderer_info", extensions);
|
|
792
|
+
const ext = extensions.WEBGL_debug_renderer_info;
|
|
793
|
+
const vendorUnmasked = gl.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : 7936);
|
|
794
|
+
const rendererUnmasked = gl.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : 7937);
|
|
783
795
|
const vendor = vendorUnmasked || vendorMasked;
|
|
784
796
|
const renderer = rendererUnmasked || rendererMasked;
|
|
785
|
-
const version = gl.getParameter(
|
|
797
|
+
const version = gl.getParameter(7938);
|
|
786
798
|
const gpu = identifyGPUVendor(vendor, renderer);
|
|
787
799
|
const gpuBackend = identifyGPUBackend(vendor, renderer);
|
|
788
800
|
const gpuType = identifyGPUType(vendor, renderer);
|
|
@@ -844,6 +856,9 @@ function identifyGPUType(vendor, renderer) {
|
|
|
844
856
|
}
|
|
845
857
|
}
|
|
846
858
|
|
|
859
|
+
// dist/adapter/device-helpers/webgl-device-features.js
|
|
860
|
+
var import_core3 = require("@luma.gl/core");
|
|
861
|
+
|
|
847
862
|
// dist/adapter/converters/texture-formats.js
|
|
848
863
|
var import_core2 = require("@luma.gl/core");
|
|
849
864
|
var import_constants4 = require("@luma.gl/constants");
|
|
@@ -853,29 +868,29 @@ var import_constants3 = require("@luma.gl/constants");
|
|
|
853
868
|
function getGLFromVertexType(dataType) {
|
|
854
869
|
switch (dataType) {
|
|
855
870
|
case "uint8":
|
|
856
|
-
return
|
|
871
|
+
return 5121;
|
|
857
872
|
case "sint8":
|
|
858
|
-
return
|
|
873
|
+
return 5120;
|
|
859
874
|
case "unorm8":
|
|
860
|
-
return
|
|
875
|
+
return 5121;
|
|
861
876
|
case "snorm8":
|
|
862
|
-
return
|
|
877
|
+
return 5120;
|
|
863
878
|
case "uint16":
|
|
864
|
-
return
|
|
879
|
+
return 5123;
|
|
865
880
|
case "sint16":
|
|
866
|
-
return
|
|
881
|
+
return 5122;
|
|
867
882
|
case "unorm16":
|
|
868
|
-
return
|
|
883
|
+
return 5123;
|
|
869
884
|
case "snorm16":
|
|
870
|
-
return
|
|
885
|
+
return 5122;
|
|
871
886
|
case "uint32":
|
|
872
|
-
return
|
|
887
|
+
return 5125;
|
|
873
888
|
case "sint32":
|
|
874
|
-
return
|
|
889
|
+
return 5124;
|
|
875
890
|
case "float16":
|
|
876
|
-
return
|
|
891
|
+
return 5131;
|
|
877
892
|
case "float32":
|
|
878
|
-
return
|
|
893
|
+
return 5126;
|
|
879
894
|
}
|
|
880
895
|
throw new Error(String(dataType));
|
|
881
896
|
}
|
|
@@ -887,6 +902,14 @@ var texture_compression_etc2 = "texture-compression-etc2";
|
|
|
887
902
|
var texture_compression_etc1_webgl = "texture-compression-etc1-webgl";
|
|
888
903
|
var texture_compression_pvrtc_webgl = "texture-compression-pvrtc-webgl";
|
|
889
904
|
var texture_compression_atc_webgl = "texture-compression-atc-webgl";
|
|
905
|
+
var float32_renderable = "float32-renderable-webgl";
|
|
906
|
+
var float16_renderable = "float16-renderable-webgl";
|
|
907
|
+
var rgb9e5ufloat_renderable = "rgb9e5ufloat_renderable-webgl";
|
|
908
|
+
var snorm8_renderable = "snorm8-renderable-webgl";
|
|
909
|
+
var norm16_renderable = "norm16-renderable-webgl";
|
|
910
|
+
var snorm16_renderable = "snorm16-renderable-webgl";
|
|
911
|
+
var float32_filterable = "float32-filterable";
|
|
912
|
+
var float16_filterable = "float16-filterable-webgl";
|
|
890
913
|
var X_S3TC = "WEBGL_compressed_texture_s3tc";
|
|
891
914
|
var X_S3TC_SRGB = "WEBGL_compressed_texture_s3tc_srgb";
|
|
892
915
|
var X_RGTC = "EXT_texture_compression_rgtc";
|
|
@@ -896,15 +919,18 @@ var X_ASTC = "WEBGL_compressed_texture_astc";
|
|
|
896
919
|
var X_ETC1 = "WEBGL_compressed_texture_etc1";
|
|
897
920
|
var X_PVRTC = "WEBGL_compressed_texture_pvrtc";
|
|
898
921
|
var X_ATC = "WEBGL_compressed_texture_atc";
|
|
899
|
-
var
|
|
900
|
-
var
|
|
901
|
-
var
|
|
922
|
+
var EXT_texture_norm16 = "EXT_texture_norm16";
|
|
923
|
+
var EXT_render_snorm = "EXT_render_snorm";
|
|
924
|
+
var EXT_color_buffer_float = "EXT_color_buffer_float";
|
|
925
|
+
var TEXTURE_FEATURES = {
|
|
902
926
|
"float32-renderable-webgl": ["EXT_color_buffer_float"],
|
|
903
|
-
// [false, 'EXT_color_buffer_float'],
|
|
904
927
|
"float16-renderable-webgl": ["EXT_color_buffer_half_float"],
|
|
905
|
-
"
|
|
906
|
-
"
|
|
907
|
-
"
|
|
928
|
+
"rgb9e5ufloat_renderable-webgl": ["WEBGL_render_shared_exponent"],
|
|
929
|
+
"snorm8-renderable-webgl": [EXT_render_snorm],
|
|
930
|
+
"norm16-renderable-webgl": [EXT_texture_norm16],
|
|
931
|
+
"snorm16-renderable-webgl": [EXT_texture_norm16, EXT_render_snorm],
|
|
932
|
+
"float32-filterable": ["OES_texture_float_linear"],
|
|
933
|
+
"float16-filterable-webgl": ["OES_texture_half_float_linear"],
|
|
908
934
|
"texture-filterable-anisotropic-webgl": ["EXT_texture_filter_anisotropic"],
|
|
909
935
|
"texture-blend-float-webgl": ["EXT_float_blend"],
|
|
910
936
|
"texture-compression-bc": [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC],
|
|
@@ -918,216 +944,267 @@ var TEXTURE_FEATURE_CHECKS = {
|
|
|
918
944
|
"texture-compression-pvrtc-webgl": [X_PVRTC],
|
|
919
945
|
"texture-compression-atc-webgl": [X_ATC]
|
|
920
946
|
};
|
|
921
|
-
function
|
|
922
|
-
|
|
923
|
-
return extensions.every((extension) => gl.getExtension(extension));
|
|
947
|
+
function isTextureFeature(feature) {
|
|
948
|
+
return feature in TEXTURE_FEATURES;
|
|
924
949
|
}
|
|
925
|
-
function
|
|
926
|
-
const
|
|
927
|
-
return
|
|
950
|
+
function checkTextureFeature(gl, feature, extensions) {
|
|
951
|
+
const textureExtensions = TEXTURE_FEATURES[feature] || [];
|
|
952
|
+
return textureExtensions.every((extension) => getWebGLExtension(gl, extension, extensions));
|
|
928
953
|
}
|
|
929
954
|
var TEXTURE_FORMATS = {
|
|
930
|
-
// Unsized formats that leave the precision up to the driver.
|
|
931
|
-
// TODO - Fix bpp constants
|
|
932
|
-
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
955
|
+
// Unsized formats that leave the precision up to the driver. TODO - Fix bpp constants
|
|
933
956
|
"rgb8unorm-unsized": {
|
|
934
|
-
gl:
|
|
957
|
+
gl: 6407,
|
|
935
958
|
b: 4,
|
|
936
959
|
c: 2,
|
|
937
960
|
bpp: 4,
|
|
938
|
-
dataFormat:
|
|
939
|
-
types: [
|
|
961
|
+
dataFormat: 6407,
|
|
962
|
+
types: [5121, 33635]
|
|
940
963
|
},
|
|
941
964
|
"rgba8unorm-unsized": {
|
|
942
|
-
gl:
|
|
965
|
+
gl: 6408,
|
|
943
966
|
b: 4,
|
|
944
967
|
c: 2,
|
|
945
968
|
bpp: 4,
|
|
946
|
-
dataFormat:
|
|
947
|
-
types: [
|
|
969
|
+
dataFormat: 6408,
|
|
970
|
+
types: [5121, 32819, 32820]
|
|
948
971
|
},
|
|
972
|
+
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
949
973
|
// 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
950
974
|
// 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
951
975
|
// 8-bit formats
|
|
952
|
-
"r8unorm": { gl:
|
|
953
|
-
"r8snorm": { gl:
|
|
954
|
-
"r8uint": { gl:
|
|
955
|
-
"r8sint": { gl:
|
|
976
|
+
"r8unorm": { gl: 33321, b: 1, c: 1, rb: true },
|
|
977
|
+
"r8snorm": { gl: 36756, b: 1, c: 1, render: snorm8_renderable },
|
|
978
|
+
"r8uint": { gl: 33330, b: 1, c: 1, rb: true },
|
|
979
|
+
"r8sint": { gl: 33329, b: 1, c: 1, rb: true },
|
|
956
980
|
// 16-bit formats
|
|
957
|
-
"rg8unorm": { gl:
|
|
958
|
-
"rg8snorm": { gl:
|
|
959
|
-
"rg8uint": { gl:
|
|
960
|
-
"rg8sint": { gl:
|
|
961
|
-
"r16uint": { gl:
|
|
962
|
-
"r16sint": { gl:
|
|
963
|
-
"r16float": { gl:
|
|
964
|
-
"r16unorm-webgl": { gl:
|
|
965
|
-
"r16snorm-webgl": { gl:
|
|
981
|
+
"rg8unorm": { gl: 33323, b: 2, c: 2, rb: true },
|
|
982
|
+
"rg8snorm": { gl: 36757, b: 2, c: 2, render: snorm8_renderable },
|
|
983
|
+
"rg8uint": { gl: 33336, b: 2, c: 2, rb: true },
|
|
984
|
+
"rg8sint": { gl: 33335, b: 2, c: 2, rb: true },
|
|
985
|
+
"r16uint": { gl: 33332, b: 2, c: 1, rb: true },
|
|
986
|
+
"r16sint": { gl: 33331, b: 2, c: 1, rb: true },
|
|
987
|
+
"r16float": { gl: 33325, b: 2, c: 1, render: float16_renderable, filter: "float16-filterable-webgl", rb: true },
|
|
988
|
+
"r16unorm-webgl": { gl: 33322, b: 2, c: 1, f: norm16_renderable, rb: true },
|
|
989
|
+
"r16snorm-webgl": { gl: 36760, b: 2, c: 1, f: snorm16_renderable },
|
|
966
990
|
// Packed 16-bit formats
|
|
967
|
-
"rgba4unorm-webgl": { gl:
|
|
968
|
-
"rgb565unorm-webgl": { gl:
|
|
969
|
-
"rgb5a1unorm-webgl": { gl:
|
|
991
|
+
"rgba4unorm-webgl": { gl: 32854, b: 2, c: 4, wgpu: false, rb: true },
|
|
992
|
+
"rgb565unorm-webgl": { gl: 36194, b: 2, c: 4, wgpu: false, rb: true },
|
|
993
|
+
"rgb5a1unorm-webgl": { gl: 32855, b: 2, c: 4, wgpu: false, rb: true },
|
|
970
994
|
// 24-bit formats
|
|
971
|
-
"rgb8unorm-webgl": { gl:
|
|
972
|
-
"rgb8snorm-webgl": { gl:
|
|
995
|
+
"rgb8unorm-webgl": { gl: 32849, b: 3, c: 3, wgpu: false },
|
|
996
|
+
"rgb8snorm-webgl": { gl: 36758, b: 3, c: 3, wgpu: false },
|
|
973
997
|
// 32-bit formats
|
|
974
|
-
"rgba8unorm": { gl:
|
|
975
|
-
"rgba8unorm-srgb": { gl:
|
|
976
|
-
"rgba8snorm": { gl:
|
|
977
|
-
"rgba8uint": { gl:
|
|
978
|
-
"rgba8sint": { gl:
|
|
998
|
+
"rgba8unorm": { gl: 32856, b: 4, c: 2, bpp: 4 },
|
|
999
|
+
"rgba8unorm-srgb": { gl: 35907, b: 4, c: 4, bpp: 4 },
|
|
1000
|
+
"rgba8snorm": { gl: 36759, b: 4, c: 4, render: snorm8_renderable },
|
|
1001
|
+
"rgba8uint": { gl: 36220, b: 4, c: 4, bpp: 4 },
|
|
1002
|
+
"rgba8sint": { gl: 36238, b: 4, c: 4, bpp: 4 },
|
|
979
1003
|
// reverse colors, webgpu only
|
|
980
1004
|
"bgra8unorm": { b: 4, c: 4 },
|
|
981
1005
|
"bgra8unorm-srgb": { b: 4, c: 4 },
|
|
982
|
-
"rg16uint": { gl:
|
|
983
|
-
"rg16sint": { gl:
|
|
1006
|
+
"rg16uint": { gl: 33338, b: 4, c: 1, bpp: 4 },
|
|
1007
|
+
"rg16sint": { gl: 33337, b: 4, c: 2, bpp: 4 },
|
|
984
1008
|
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
985
|
-
"rg16float": { gl:
|
|
986
|
-
"rg16unorm-webgl": { gl:
|
|
987
|
-
"rg16snorm-webgl": { gl:
|
|
988
|
-
"r32uint": { gl:
|
|
989
|
-
"r32sint": { gl:
|
|
990
|
-
"r32float": { gl:
|
|
1009
|
+
"rg16float": { gl: 33327, bpp: 4, b: 4, c: 2, render: float16_renderable, filter: float16_filterable, rb: true },
|
|
1010
|
+
"rg16unorm-webgl": { gl: 33324, b: 2, c: 2, render: norm16_renderable },
|
|
1011
|
+
"rg16snorm-webgl": { gl: 36761, b: 2, c: 2, render: snorm16_renderable },
|
|
1012
|
+
"r32uint": { gl: 33334, b: 4, c: 1, bpp: 4, rb: true },
|
|
1013
|
+
"r32sint": { gl: 33333, b: 4, c: 1, bpp: 4, rb: true },
|
|
1014
|
+
"r32float": { gl: 33326, bpp: 4, b: 4, c: 1, render: float32_renderable, filter: float32_filterable },
|
|
991
1015
|
// Packed 32-bit formats
|
|
992
|
-
"rgb9e5ufloat": { gl:
|
|
993
|
-
|
|
994
|
-
"
|
|
995
|
-
"rgb10a2unorm
|
|
1016
|
+
"rgb9e5ufloat": { gl: 35901, b: 4, c: 3, p: 1, render: rgb9e5ufloat_renderable },
|
|
1017
|
+
// , filter: true},
|
|
1018
|
+
"rg11b10ufloat": { gl: 35898, b: 4, c: 3, p: 1, render: float32_renderable, rb: true },
|
|
1019
|
+
"rgb10a2unorm": { gl: 32857, b: 4, c: 4, p: 1, rb: true },
|
|
1020
|
+
"rgb10a2uint-webgl": { b: 4, c: 4, gl: 36975, p: 1, wgpu: false, bpp: 4, rb: true },
|
|
996
1021
|
// 48-bit formats
|
|
997
|
-
"rgb16unorm-webgl": { gl:
|
|
998
|
-
|
|
1022
|
+
"rgb16unorm-webgl": { gl: 32852, b: 2, c: 3, f: norm16_renderable },
|
|
1023
|
+
// rgb not renderable
|
|
1024
|
+
"rgb16snorm-webgl": { gl: 36762, b: 2, c: 3, f: norm16_renderable },
|
|
1025
|
+
// rgb not renderable
|
|
999
1026
|
// 64-bit formats
|
|
1000
|
-
"rg32uint": { gl:
|
|
1001
|
-
"rg32sint": { gl:
|
|
1002
|
-
"rg32float": { gl:
|
|
1003
|
-
"rgba16uint": { gl:
|
|
1004
|
-
"rgba16sint": { gl:
|
|
1005
|
-
"rgba16float": { gl:
|
|
1006
|
-
"rgba16unorm-webgl": { gl:
|
|
1007
|
-
"rgba16snorm-webgl": { gl:
|
|
1027
|
+
"rg32uint": { gl: 33340, b: 8, c: 2, rb: true },
|
|
1028
|
+
"rg32sint": { gl: 33339, b: 8, c: 2, rb: true },
|
|
1029
|
+
"rg32float": { gl: 33328, b: 8, c: 2, render: float32_renderable, filter: float32_filterable, rb: true },
|
|
1030
|
+
"rgba16uint": { gl: 36214, b: 8, c: 4, rb: true },
|
|
1031
|
+
"rgba16sint": { gl: 36232, b: 8, c: 4, rb: true },
|
|
1032
|
+
"rgba16float": { gl: 34842, b: 8, c: 4, render: float16_renderable, filter: float16_filterable },
|
|
1033
|
+
"rgba16unorm-webgl": { gl: 32859, b: 2, c: 4, render: norm16_renderable, rb: true },
|
|
1034
|
+
"rgba16snorm-webgl": { gl: 36763, b: 2, c: 4, render: snorm16_renderable },
|
|
1008
1035
|
// 96-bit formats (deprecated!)
|
|
1009
1036
|
"rgb32float-webgl": {
|
|
1010
|
-
gl:
|
|
1011
|
-
render:
|
|
1012
|
-
filter:
|
|
1013
|
-
gl2ext:
|
|
1014
|
-
dataFormat:
|
|
1015
|
-
types: [
|
|
1037
|
+
gl: 34837,
|
|
1038
|
+
render: float32_renderable,
|
|
1039
|
+
filter: float32_filterable,
|
|
1040
|
+
gl2ext: EXT_color_buffer_float,
|
|
1041
|
+
dataFormat: 6407,
|
|
1042
|
+
types: [5126]
|
|
1016
1043
|
},
|
|
1017
1044
|
// 128-bit formats
|
|
1018
|
-
"rgba32uint": { gl:
|
|
1019
|
-
"rgba32sint": { gl:
|
|
1020
|
-
"rgba32float": { gl:
|
|
1045
|
+
"rgba32uint": { gl: 36208, b: 16, c: 4, rb: true },
|
|
1046
|
+
"rgba32sint": { gl: 36226, b: 16, c: 4, rb: true },
|
|
1047
|
+
"rgba32float": { gl: 34836, b: 16, c: 4, render: float32_renderable, filter: float32_filterable, rb: true },
|
|
1021
1048
|
// Depth and stencil formats
|
|
1022
|
-
"stencil8": { gl:
|
|
1049
|
+
"stencil8": { gl: 36168, b: 1, c: 1, attachment: 36128, rb: true },
|
|
1023
1050
|
// 8 stencil bits
|
|
1024
|
-
"depth16unorm": {
|
|
1051
|
+
"depth16unorm": {
|
|
1052
|
+
gl: 33189,
|
|
1053
|
+
b: 2,
|
|
1054
|
+
c: 1,
|
|
1055
|
+
attachment: 36096,
|
|
1056
|
+
dataFormat: 6402,
|
|
1057
|
+
types: [5123],
|
|
1058
|
+
rb: true
|
|
1059
|
+
},
|
|
1025
1060
|
// 16 depth bits
|
|
1026
|
-
"depth24plus": {
|
|
1027
|
-
|
|
1061
|
+
"depth24plus": {
|
|
1062
|
+
gl: 33190,
|
|
1063
|
+
b: 3,
|
|
1064
|
+
c: 1,
|
|
1065
|
+
attachment: 36096,
|
|
1066
|
+
dataFormat: 6402,
|
|
1067
|
+
types: [5125]
|
|
1068
|
+
},
|
|
1069
|
+
"depth32float": {
|
|
1070
|
+
gl: 36012,
|
|
1071
|
+
b: 4,
|
|
1072
|
+
c: 1,
|
|
1073
|
+
attachment: 36096,
|
|
1074
|
+
dataFormat: 6402,
|
|
1075
|
+
types: [5126],
|
|
1076
|
+
rb: true
|
|
1077
|
+
},
|
|
1028
1078
|
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
1029
|
-
"depth24plus-stencil8": {
|
|
1079
|
+
"depth24plus-stencil8": {
|
|
1080
|
+
gl: 35056,
|
|
1081
|
+
b: 4,
|
|
1082
|
+
c: 2,
|
|
1083
|
+
p: 1,
|
|
1084
|
+
attachment: 33306,
|
|
1085
|
+
rb: true,
|
|
1086
|
+
depthTexture: true,
|
|
1087
|
+
dataFormat: 34041,
|
|
1088
|
+
types: [34042]
|
|
1089
|
+
},
|
|
1030
1090
|
// "depth24unorm-stencil8" feature
|
|
1031
|
-
"depth24unorm-stencil8": {
|
|
1032
|
-
|
|
1033
|
-
|
|
1091
|
+
"depth24unorm-stencil8": {
|
|
1092
|
+
gl: 35056,
|
|
1093
|
+
b: 4,
|
|
1094
|
+
c: 2,
|
|
1095
|
+
p: 1,
|
|
1096
|
+
attachment: 33306,
|
|
1097
|
+
dataFormat: 34041,
|
|
1098
|
+
types: [34042],
|
|
1099
|
+
rb: true
|
|
1100
|
+
},
|
|
1101
|
+
// "depth32float-stencil8" feature - TODO below is render buffer only?
|
|
1102
|
+
"depth32float-stencil8": {
|
|
1103
|
+
gl: 36013,
|
|
1104
|
+
b: 5,
|
|
1105
|
+
c: 2,
|
|
1106
|
+
p: 1,
|
|
1107
|
+
attachment: 33306,
|
|
1108
|
+
dataFormat: 34041,
|
|
1109
|
+
types: [36269],
|
|
1110
|
+
rb: true
|
|
1111
|
+
},
|
|
1034
1112
|
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
1035
|
-
"bc1-rgb-unorm-webgl": { gl:
|
|
1036
|
-
"bc1-rgb-unorm-srgb-webgl": { gl:
|
|
1037
|
-
"bc1-rgba-unorm": { gl:
|
|
1038
|
-
"bc1-rgba-unorm-srgb": { gl:
|
|
1039
|
-
"bc2-rgba-unorm": { gl:
|
|
1040
|
-
"bc2-rgba-unorm-srgb": { gl:
|
|
1041
|
-
"bc3-rgba-unorm": { gl:
|
|
1042
|
-
"bc3-rgba-unorm-srgb": { gl:
|
|
1043
|
-
"bc4-r-unorm": { gl:
|
|
1044
|
-
"bc4-r-snorm": { gl:
|
|
1045
|
-
"bc5-rg-unorm": { gl:
|
|
1046
|
-
"bc5-rg-snorm": { gl:
|
|
1047
|
-
"bc6h-rgb-ufloat": { gl:
|
|
1048
|
-
"bc6h-rgb-float": { gl:
|
|
1049
|
-
"bc7-rgba-unorm": { gl:
|
|
1050
|
-
"bc7-rgba-unorm-srgb": { gl:
|
|
1113
|
+
"bc1-rgb-unorm-webgl": { gl: 33776, x: X_S3TC, f: texture_compression_bc },
|
|
1114
|
+
"bc1-rgb-unorm-srgb-webgl": { gl: 35916, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
1115
|
+
"bc1-rgba-unorm": { gl: 33777, x: X_S3TC, f: texture_compression_bc },
|
|
1116
|
+
"bc1-rgba-unorm-srgb": { gl: 35916, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
1117
|
+
"bc2-rgba-unorm": { gl: 33778, x: X_S3TC, f: texture_compression_bc },
|
|
1118
|
+
"bc2-rgba-unorm-srgb": { gl: 35918, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
1119
|
+
"bc3-rgba-unorm": { gl: 33779, x: X_S3TC, f: texture_compression_bc },
|
|
1120
|
+
"bc3-rgba-unorm-srgb": { gl: 35919, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
1121
|
+
"bc4-r-unorm": { gl: 36283, x: X_RGTC, f: texture_compression_bc },
|
|
1122
|
+
"bc4-r-snorm": { gl: 36284, x: X_RGTC, f: texture_compression_bc },
|
|
1123
|
+
"bc5-rg-unorm": { gl: 36285, x: X_RGTC, f: texture_compression_bc },
|
|
1124
|
+
"bc5-rg-snorm": { gl: 36286, x: X_RGTC, f: texture_compression_bc },
|
|
1125
|
+
"bc6h-rgb-ufloat": { gl: 36495, x: X_BPTC, f: texture_compression_bc },
|
|
1126
|
+
"bc6h-rgb-float": { gl: 36494, x: X_BPTC, f: texture_compression_bc },
|
|
1127
|
+
"bc7-rgba-unorm": { gl: 36492, x: X_BPTC, f: texture_compression_bc },
|
|
1128
|
+
"bc7-rgba-unorm-srgb": { gl: 36493, x: X_BPTC, f: texture_compression_bc },
|
|
1051
1129
|
// WEBGL_compressed_texture_etc: device.features.has("texture-compression-etc2")
|
|
1052
1130
|
// Note: Supposedly guaranteed availability compressed formats in WebGL2, but through CPU decompression
|
|
1053
|
-
"etc2-rgb8unorm": { gl:
|
|
1054
|
-
"etc2-rgb8unorm-srgb": { gl:
|
|
1055
|
-
"etc2-rgb8a1unorm": { gl:
|
|
1056
|
-
"etc2-rgb8a1unorm-srgb": { gl:
|
|
1057
|
-
"etc2-rgba8unorm": { gl:
|
|
1058
|
-
"etc2-rgba8unorm-srgb": { gl:
|
|
1059
|
-
"eac-r11unorm": { gl:
|
|
1060
|
-
"eac-r11snorm": { gl:
|
|
1061
|
-
"eac-rg11unorm": { gl:
|
|
1062
|
-
"eac-rg11snorm": { gl:
|
|
1131
|
+
"etc2-rgb8unorm": { gl: 37492, f: texture_compression_etc2 },
|
|
1132
|
+
"etc2-rgb8unorm-srgb": { gl: 37494, f: texture_compression_etc2 },
|
|
1133
|
+
"etc2-rgb8a1unorm": { gl: 37496, f: texture_compression_etc2 },
|
|
1134
|
+
"etc2-rgb8a1unorm-srgb": { gl: 37497, f: texture_compression_etc2 },
|
|
1135
|
+
"etc2-rgba8unorm": { gl: 37493, f: texture_compression_etc2 },
|
|
1136
|
+
"etc2-rgba8unorm-srgb": { gl: 37495, f: texture_compression_etc2 },
|
|
1137
|
+
"eac-r11unorm": { gl: 37488, f: texture_compression_etc2 },
|
|
1138
|
+
"eac-r11snorm": { gl: 37489, f: texture_compression_etc2 },
|
|
1139
|
+
"eac-rg11unorm": { gl: 37490, f: texture_compression_etc2 },
|
|
1140
|
+
"eac-rg11snorm": { gl: 37491, f: texture_compression_etc2 },
|
|
1063
1141
|
// X_ASTC compressed formats: device.features.has("texture-compression-astc")
|
|
1064
|
-
"astc-4x4-unorm": { gl:
|
|
1065
|
-
"astc-4x4-unorm-srgb": { gl:
|
|
1066
|
-
"astc-5x4-unorm": { gl:
|
|
1067
|
-
"astc-5x4-unorm-srgb": { gl:
|
|
1068
|
-
"astc-5x5-unorm": { gl:
|
|
1069
|
-
"astc-5x5-unorm-srgb": { gl:
|
|
1070
|
-
"astc-6x5-unorm": { gl:
|
|
1071
|
-
"astc-6x5-unorm-srgb": { gl:
|
|
1072
|
-
"astc-6x6-unorm": { gl:
|
|
1073
|
-
"astc-6x6-unorm-srgb": { gl:
|
|
1074
|
-
"astc-8x5-unorm": { gl:
|
|
1075
|
-
"astc-8x5-unorm-srgb": { gl:
|
|
1076
|
-
"astc-8x6-unorm": { gl:
|
|
1077
|
-
"astc-8x6-unorm-srgb": { gl:
|
|
1078
|
-
"astc-8x8-unorm": { gl:
|
|
1079
|
-
"astc-8x8-unorm-srgb": { gl:
|
|
1080
|
-
"astc-10x5-unorm": { gl:
|
|
1081
|
-
"astc-10x5-unorm-srgb": { gl:
|
|
1082
|
-
"astc-10x6-unorm": { gl:
|
|
1083
|
-
"astc-10x6-unorm-srgb": { gl:
|
|
1084
|
-
"astc-10x8-unorm": { gl:
|
|
1085
|
-
"astc-10x8-unorm-srgb": { gl:
|
|
1086
|
-
"astc-10x10-unorm": { gl:
|
|
1087
|
-
"astc-10x10-unorm-srgb": { gl:
|
|
1088
|
-
"astc-12x10-unorm": { gl:
|
|
1089
|
-
"astc-12x10-unorm-srgb": { gl:
|
|
1090
|
-
"astc-12x12-unorm": { gl:
|
|
1091
|
-
"astc-12x12-unorm-srgb": { gl:
|
|
1142
|
+
"astc-4x4-unorm": { gl: 37808, f: texture_compression_astc },
|
|
1143
|
+
"astc-4x4-unorm-srgb": { gl: 37840, f: texture_compression_astc },
|
|
1144
|
+
"astc-5x4-unorm": { gl: 37809, f: texture_compression_astc },
|
|
1145
|
+
"astc-5x4-unorm-srgb": { gl: 37841, f: texture_compression_astc },
|
|
1146
|
+
"astc-5x5-unorm": { gl: 37810, f: texture_compression_astc },
|
|
1147
|
+
"astc-5x5-unorm-srgb": { gl: 37842, f: texture_compression_astc },
|
|
1148
|
+
"astc-6x5-unorm": { gl: 37811, f: texture_compression_astc },
|
|
1149
|
+
"astc-6x5-unorm-srgb": { gl: 37843, f: texture_compression_astc },
|
|
1150
|
+
"astc-6x6-unorm": { gl: 37812, f: texture_compression_astc },
|
|
1151
|
+
"astc-6x6-unorm-srgb": { gl: 37844, f: texture_compression_astc },
|
|
1152
|
+
"astc-8x5-unorm": { gl: 37813, f: texture_compression_astc },
|
|
1153
|
+
"astc-8x5-unorm-srgb": { gl: 37845, f: texture_compression_astc },
|
|
1154
|
+
"astc-8x6-unorm": { gl: 37814, f: texture_compression_astc },
|
|
1155
|
+
"astc-8x6-unorm-srgb": { gl: 37846, f: texture_compression_astc },
|
|
1156
|
+
"astc-8x8-unorm": { gl: 37815, f: texture_compression_astc },
|
|
1157
|
+
"astc-8x8-unorm-srgb": { gl: 37847, f: texture_compression_astc },
|
|
1158
|
+
"astc-10x5-unorm": { gl: 37819, f: texture_compression_astc },
|
|
1159
|
+
"astc-10x5-unorm-srgb": { gl: 37851, f: texture_compression_astc },
|
|
1160
|
+
"astc-10x6-unorm": { gl: 37817, f: texture_compression_astc },
|
|
1161
|
+
"astc-10x6-unorm-srgb": { gl: 37849, f: texture_compression_astc },
|
|
1162
|
+
"astc-10x8-unorm": { gl: 37818, f: texture_compression_astc },
|
|
1163
|
+
"astc-10x8-unorm-srgb": { gl: 37850, f: texture_compression_astc },
|
|
1164
|
+
"astc-10x10-unorm": { gl: 37819, f: texture_compression_astc },
|
|
1165
|
+
"astc-10x10-unorm-srgb": { gl: 37851, f: texture_compression_astc },
|
|
1166
|
+
"astc-12x10-unorm": { gl: 37820, f: texture_compression_astc },
|
|
1167
|
+
"astc-12x10-unorm-srgb": { gl: 37852, f: texture_compression_astc },
|
|
1168
|
+
"astc-12x12-unorm": { gl: 37821, f: texture_compression_astc },
|
|
1169
|
+
"astc-12x12-unorm-srgb": { gl: 37853, f: texture_compression_astc },
|
|
1092
1170
|
// WEBGL_compressed_texture_pvrtc
|
|
1093
|
-
"pvrtc-rgb4unorm-webgl": { gl:
|
|
1094
|
-
"pvrtc-rgba4unorm-webgl": { gl:
|
|
1095
|
-
"pvrtc-rbg2unorm-webgl": { gl:
|
|
1096
|
-
"pvrtc-rgba2unorm-webgl": { gl:
|
|
1171
|
+
"pvrtc-rgb4unorm-webgl": { gl: 35840, f: texture_compression_pvrtc_webgl },
|
|
1172
|
+
"pvrtc-rgba4unorm-webgl": { gl: 35842, f: texture_compression_pvrtc_webgl },
|
|
1173
|
+
"pvrtc-rbg2unorm-webgl": { gl: 35841, f: texture_compression_pvrtc_webgl },
|
|
1174
|
+
"pvrtc-rgba2unorm-webgl": { gl: 35843, f: texture_compression_pvrtc_webgl },
|
|
1097
1175
|
// WEBGL_compressed_texture_etc1
|
|
1098
|
-
"etc1-rbg-unorm-webgl": { gl:
|
|
1176
|
+
"etc1-rbg-unorm-webgl": { gl: 36196, f: texture_compression_etc1_webgl },
|
|
1099
1177
|
// WEBGL_compressed_texture_atc
|
|
1100
|
-
"atc-rgb-unorm-webgl": { gl:
|
|
1101
|
-
"atc-rgba-unorm-webgl": { gl:
|
|
1102
|
-
"atc-rgbai-unorm-webgl": { gl:
|
|
1178
|
+
"atc-rgb-unorm-webgl": { gl: 35986, f: texture_compression_atc_webgl },
|
|
1179
|
+
"atc-rgba-unorm-webgl": { gl: 35986, f: texture_compression_atc_webgl },
|
|
1180
|
+
"atc-rgbai-unorm-webgl": { gl: 34798, f: texture_compression_atc_webgl }
|
|
1103
1181
|
};
|
|
1104
1182
|
var DATA_FORMAT_CHANNELS = {
|
|
1105
|
-
[
|
|
1106
|
-
[
|
|
1107
|
-
[
|
|
1108
|
-
[
|
|
1109
|
-
[
|
|
1110
|
-
[
|
|
1111
|
-
[
|
|
1112
|
-
[
|
|
1113
|
-
[
|
|
1114
|
-
[
|
|
1115
|
-
[
|
|
1116
|
-
[
|
|
1117
|
-
[
|
|
1183
|
+
[6403]: 1,
|
|
1184
|
+
[36244]: 1,
|
|
1185
|
+
[33319]: 2,
|
|
1186
|
+
[33320]: 2,
|
|
1187
|
+
[6407]: 3,
|
|
1188
|
+
[36248]: 3,
|
|
1189
|
+
[6408]: 4,
|
|
1190
|
+
[36249]: 4,
|
|
1191
|
+
[6402]: 1,
|
|
1192
|
+
[34041]: 1,
|
|
1193
|
+
[6406]: 1,
|
|
1194
|
+
[6409]: 1,
|
|
1195
|
+
[6410]: 2
|
|
1118
1196
|
};
|
|
1119
1197
|
var TYPE_SIZES = {
|
|
1120
|
-
[
|
|
1121
|
-
[
|
|
1122
|
-
[
|
|
1123
|
-
[
|
|
1124
|
-
[
|
|
1125
|
-
[
|
|
1126
|
-
[
|
|
1127
|
-
[
|
|
1198
|
+
[5126]: 4,
|
|
1199
|
+
[5125]: 4,
|
|
1200
|
+
[5124]: 4,
|
|
1201
|
+
[5123]: 2,
|
|
1202
|
+
[5122]: 2,
|
|
1203
|
+
[5131]: 2,
|
|
1204
|
+
[5120]: 1,
|
|
1205
|
+
[5121]: 1
|
|
1128
1206
|
};
|
|
1129
|
-
function isTextureFormatSupported(gl,
|
|
1130
|
-
const format = convertGLToTextureFormat(formatOrGL);
|
|
1207
|
+
function isTextureFormatSupported(gl, format, extensions) {
|
|
1131
1208
|
const info = TEXTURE_FORMATS[format];
|
|
1132
1209
|
if (!info) {
|
|
1133
1210
|
return false;
|
|
@@ -1137,13 +1214,13 @@ function isTextureFormatSupported(gl, formatOrGL) {
|
|
|
1137
1214
|
}
|
|
1138
1215
|
const extension = info.x || info.gl2ext;
|
|
1139
1216
|
if (extension) {
|
|
1140
|
-
return Boolean(gl
|
|
1217
|
+
return Boolean(getWebGLExtension(gl, extension, extensions));
|
|
1141
1218
|
}
|
|
1142
1219
|
return true;
|
|
1143
1220
|
}
|
|
1144
|
-
function isRenderbufferFormatSupported(gl, format) {
|
|
1221
|
+
function isRenderbufferFormatSupported(gl, format, extensions) {
|
|
1145
1222
|
var _a;
|
|
1146
|
-
return isTextureFormatSupported(gl, format) && ((_a = TEXTURE_FORMATS[format]) == null ? void 0 : _a.
|
|
1223
|
+
return isTextureFormatSupported(gl, format, extensions) && ((_a = TEXTURE_FORMATS[format]) == null ? void 0 : _a.rb);
|
|
1147
1224
|
}
|
|
1148
1225
|
function convertGLToTextureFormat(format) {
|
|
1149
1226
|
if (typeof format === "string") {
|
|
@@ -1163,9 +1240,11 @@ function convertTextureFormatToGL(format) {
|
|
|
1163
1240
|
}
|
|
1164
1241
|
return webglFormat;
|
|
1165
1242
|
}
|
|
1166
|
-
function isTextureFormatFilterable(gl,
|
|
1167
|
-
|
|
1168
|
-
|
|
1243
|
+
function isTextureFormatFilterable(gl, format, extensions) {
|
|
1244
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
1245
|
+
return false;
|
|
1246
|
+
}
|
|
1247
|
+
if (format.startsWith("depth") || format.startsWith("stencil")) {
|
|
1169
1248
|
return false;
|
|
1170
1249
|
}
|
|
1171
1250
|
try {
|
|
@@ -1177,16 +1256,15 @@ function isTextureFormatFilterable(gl, formatOrGL) {
|
|
|
1177
1256
|
return false;
|
|
1178
1257
|
}
|
|
1179
1258
|
if (format.endsWith("32float")) {
|
|
1180
|
-
return Boolean(gl
|
|
1259
|
+
return Boolean(getWebGLExtension(gl, "OES_texture_float_linear, extensions", extensions));
|
|
1181
1260
|
}
|
|
1182
1261
|
if (format.endsWith("16float")) {
|
|
1183
|
-
return Boolean(gl
|
|
1262
|
+
return Boolean(getWebGLExtension(gl, "OES_texture_half_float_linear, extensions", extensions));
|
|
1184
1263
|
}
|
|
1185
1264
|
return true;
|
|
1186
1265
|
}
|
|
1187
|
-
function isTextureFormatRenderable(gl,
|
|
1188
|
-
|
|
1189
|
-
if (!isTextureFormatSupported(gl, format)) {
|
|
1266
|
+
function isTextureFormatRenderable(gl, format, extensions) {
|
|
1267
|
+
if (!isTextureFormatSupported(gl, format, extensions)) {
|
|
1190
1268
|
return false;
|
|
1191
1269
|
}
|
|
1192
1270
|
if (typeof format === "number") {
|
|
@@ -1194,15 +1272,16 @@ function isTextureFormatRenderable(gl, formatOrGL) {
|
|
|
1194
1272
|
}
|
|
1195
1273
|
return true;
|
|
1196
1274
|
}
|
|
1197
|
-
function getWebGLTextureParameters(
|
|
1198
|
-
|
|
1275
|
+
function getWebGLTextureParameters(format) {
|
|
1276
|
+
var _a;
|
|
1277
|
+
const formatData = TEXTURE_FORMATS[format];
|
|
1199
1278
|
const webglFormat = convertTextureFormatToGL(format);
|
|
1200
1279
|
const decoded = (0, import_core2.decodeTextureFormat)(format);
|
|
1201
1280
|
return {
|
|
1202
1281
|
format: webglFormat,
|
|
1203
|
-
dataFormat: getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
|
|
1282
|
+
dataFormat: (formatData == null ? void 0 : formatData.dataFormat) || getWebGLPixelDataFormat(decoded.format, decoded.integer, decoded.normalized, webglFormat),
|
|
1204
1283
|
// depth formats don't have a type
|
|
1205
|
-
type: decoded.dataType ? getGLFromVertexType(decoded.dataType) :
|
|
1284
|
+
type: decoded.dataType ? getGLFromVertexType(decoded.dataType) : ((_a = formatData == null ? void 0 : formatData.types) == null ? void 0 : _a[0]) || 5121,
|
|
1206
1285
|
// @ts-expect-error
|
|
1207
1286
|
compressed: decoded.compressed
|
|
1208
1287
|
};
|
|
@@ -1214,221 +1293,228 @@ function getDepthStencilAttachmentWebGL(format) {
|
|
|
1214
1293
|
}
|
|
1215
1294
|
return info.attachment;
|
|
1216
1295
|
}
|
|
1217
|
-
function getTextureFormatBytesPerPixel(
|
|
1218
|
-
const format = convertGLToTextureFormat(formatOrGL);
|
|
1296
|
+
function getTextureFormatBytesPerPixel(format) {
|
|
1219
1297
|
const params = getWebGLTextureParameters(format);
|
|
1220
1298
|
const channels = DATA_FORMAT_CHANNELS[params.dataFormat] || 4;
|
|
1221
1299
|
const channelSize = TYPE_SIZES[params.type] || 1;
|
|
1222
1300
|
return channels * channelSize;
|
|
1223
1301
|
}
|
|
1224
1302
|
function getWebGLPixelDataFormat(dataFormat, integer, normalized, format) {
|
|
1225
|
-
if (format ===
|
|
1303
|
+
if (format === 6408 || format === 6407) {
|
|
1226
1304
|
return format;
|
|
1227
1305
|
}
|
|
1228
1306
|
switch (dataFormat) {
|
|
1229
1307
|
case "r":
|
|
1230
|
-
return integer && !normalized ?
|
|
1308
|
+
return integer && !normalized ? 36244 : 6403;
|
|
1231
1309
|
case "rg":
|
|
1232
|
-
return integer && !normalized ?
|
|
1310
|
+
return integer && !normalized ? 33320 : 33319;
|
|
1233
1311
|
case "rgb":
|
|
1234
|
-
return integer && !normalized ?
|
|
1312
|
+
return integer && !normalized ? 36248 : 6407;
|
|
1235
1313
|
case "rgba":
|
|
1236
|
-
return integer && !normalized ?
|
|
1314
|
+
return integer && !normalized ? 36249 : 6408;
|
|
1237
1315
|
default:
|
|
1238
|
-
return
|
|
1316
|
+
return 6408;
|
|
1239
1317
|
}
|
|
1240
1318
|
}
|
|
1241
1319
|
|
|
1242
1320
|
// dist/adapter/device-helpers/webgl-device-features.js
|
|
1243
|
-
function getDeviceFeatures(gl) {
|
|
1244
|
-
const features = getWebGLFeatures(gl);
|
|
1245
|
-
for (const textureFeature of getTextureFeatures(gl)) {
|
|
1246
|
-
features.add(textureFeature);
|
|
1247
|
-
}
|
|
1248
|
-
return features;
|
|
1249
|
-
}
|
|
1250
|
-
function getWebGLFeatures(gl) {
|
|
1251
|
-
gl.getExtension("EXT_color_buffer_float");
|
|
1252
|
-
const features = /* @__PURE__ */ new Set();
|
|
1253
|
-
for (const feature of Object.keys(WEBGL_FEATURES)) {
|
|
1254
|
-
if (isFeatureSupported(gl, feature)) {
|
|
1255
|
-
features.add(feature);
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
return features;
|
|
1259
|
-
}
|
|
1260
|
-
function isFeatureSupported(gl, feature) {
|
|
1261
|
-
const featureInfo = WEBGL_FEATURES[feature];
|
|
1262
|
-
return typeof featureInfo === "string" ? Boolean(gl.getExtension(featureInfo)) : Boolean(featureInfo);
|
|
1263
|
-
}
|
|
1264
1321
|
var WEBGL_FEATURES = {
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
"
|
|
1269
|
-
"
|
|
1322
|
+
// optional WebGPU features
|
|
1323
|
+
"depth-clip-control": "EXT_depth_clamp",
|
|
1324
|
+
// TODO these seem subtly different
|
|
1325
|
+
// 'timestamp-query' // GPUQueryType "timestamp-query"
|
|
1326
|
+
// "indirect-first-instance"
|
|
1327
|
+
// Textures are handled by getTextureFeatures()
|
|
1328
|
+
// 'depth24unorm-stencil8' // GPUTextureFormat 'depth24unorm-stencil8'
|
|
1329
|
+
// 'depth32float-stencil8' // GPUTextureFormat 'depth32float-stencil8'
|
|
1330
|
+
// optional WebGL features
|
|
1270
1331
|
"timer-query-webgl": "EXT_disjoint_timer_query_webgl2",
|
|
1271
|
-
"
|
|
1332
|
+
"compilation-status-async-webgl": "KHR_parallel_shader_compile",
|
|
1333
|
+
"polygon-mode-webgl": "WEBGL_polygon_mode",
|
|
1334
|
+
"provoking-vertex-webgl": "WEBGL_provoking_vertex",
|
|
1335
|
+
"shader-clip-cull-distance-webgl": "WEBGL_clip_cull_distance",
|
|
1336
|
+
"shader-noperspective-interpolation-webgl": "NV_shader_noperspective_interpolation",
|
|
1337
|
+
"shader-conservative-depth-webgl": "EXT_conservative_depth"
|
|
1272
1338
|
// Textures are handled by getTextureFeatures()
|
|
1273
1339
|
};
|
|
1340
|
+
var WebGLDeviceFeatures = class extends import_core3.DeviceFeatures {
|
|
1341
|
+
gl;
|
|
1342
|
+
extensions;
|
|
1343
|
+
testedFeatures = /* @__PURE__ */ new Set();
|
|
1344
|
+
constructor(gl, extensions, disabledFeatures) {
|
|
1345
|
+
super([], disabledFeatures);
|
|
1346
|
+
this.gl = gl;
|
|
1347
|
+
this.extensions = extensions;
|
|
1348
|
+
getWebGLExtension(gl, "EXT_color_buffer_float", extensions);
|
|
1349
|
+
}
|
|
1350
|
+
*[Symbol.iterator]() {
|
|
1351
|
+
for (const feature of Object.keys(WEBGL_FEATURES)) {
|
|
1352
|
+
if (this.has(feature)) {
|
|
1353
|
+
yield feature;
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
for (const feature of Object.keys(TEXTURE_FEATURES)) {
|
|
1357
|
+
if (this.has(feature)) {
|
|
1358
|
+
yield feature;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
return [];
|
|
1362
|
+
}
|
|
1363
|
+
has(feature) {
|
|
1364
|
+
if (this.disabledFeatures[feature]) {
|
|
1365
|
+
return false;
|
|
1366
|
+
}
|
|
1367
|
+
if (!this.testedFeatures.has(feature)) {
|
|
1368
|
+
this.testedFeatures.add(feature);
|
|
1369
|
+
if (isTextureFeature(feature) && checkTextureFeature(this.gl, feature, this.extensions)) {
|
|
1370
|
+
this.features.add(feature);
|
|
1371
|
+
}
|
|
1372
|
+
if (this.getWebGLFeature(feature)) {
|
|
1373
|
+
this.features.add(feature);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
return this.features.has(feature);
|
|
1377
|
+
}
|
|
1378
|
+
// FOR DEVICE
|
|
1379
|
+
initializeFeatures() {
|
|
1380
|
+
for (const feature of this) {
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
// IMPLEMENTATION
|
|
1384
|
+
/** Extract all WebGL features */
|
|
1385
|
+
getWebGLFeature(feature) {
|
|
1386
|
+
const featureInfo = WEBGL_FEATURES[feature];
|
|
1387
|
+
const isSupported = typeof featureInfo === "string" ? Boolean(getWebGLExtension(this.gl, featureInfo, this.extensions)) : Boolean(featureInfo);
|
|
1388
|
+
return isSupported;
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1274
1391
|
|
|
1275
1392
|
// dist/adapter/device-helpers/webgl-device-limits.js
|
|
1393
|
+
var import_core4 = require("@luma.gl/core");
|
|
1276
1394
|
var import_constants5 = require("@luma.gl/constants");
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
// WebGL does not support 1D textures
|
|
1281
|
-
maxTextureDimension2D: gl.getParameter(import_constants5.GL.MAX_TEXTURE_SIZE),
|
|
1282
|
-
maxTextureDimension3D: gl.getParameter(import_constants5.GL.MAX_3D_TEXTURE_SIZE),
|
|
1283
|
-
maxTextureArrayLayers: gl.getParameter(import_constants5.GL.MAX_ARRAY_TEXTURE_LAYERS),
|
|
1284
|
-
maxBindGroups: 1,
|
|
1285
|
-
// TBD - if we emulate bind groups we could support any number...
|
|
1286
|
-
maxDynamicUniformBuffersPerPipelineLayout: 0,
|
|
1287
|
-
// TBD
|
|
1288
|
-
maxDynamicStorageBuffersPerPipelineLayout: 0,
|
|
1289
|
-
// TBD
|
|
1290
|
-
maxSampledTexturesPerShaderStage: gl.getParameter(import_constants5.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
|
|
1291
|
-
// TBD
|
|
1292
|
-
maxSamplersPerShaderStage: gl.getParameter(import_constants5.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
|
|
1293
|
-
maxStorageBuffersPerShaderStage: 0,
|
|
1294
|
-
// TBD
|
|
1295
|
-
maxStorageTexturesPerShaderStage: 0,
|
|
1296
|
-
// TBD
|
|
1297
|
-
maxUniformBuffersPerShaderStage: gl.getParameter(import_constants5.GL.MAX_UNIFORM_BUFFER_BINDINGS),
|
|
1298
|
-
maxUniformBufferBindingSize: gl.getParameter(import_constants5.GL.MAX_UNIFORM_BLOCK_SIZE),
|
|
1299
|
-
maxStorageBufferBindingSize: 0,
|
|
1300
|
-
minUniformBufferOffsetAlignment: gl.getParameter(import_constants5.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT),
|
|
1301
|
-
minStorageBufferOffsetAlignment: 0,
|
|
1302
|
-
// TBD
|
|
1303
|
-
maxVertexBuffers: 0,
|
|
1304
|
-
maxVertexAttributes: gl.getParameter(import_constants5.GL.MAX_VERTEX_ATTRIBS),
|
|
1305
|
-
maxVertexBufferArrayStride: 2048,
|
|
1306
|
-
// TBD, this is just the default value from WebGPU
|
|
1307
|
-
maxInterStageShaderComponents: gl.getParameter(import_constants5.GL.MAX_VARYING_COMPONENTS),
|
|
1308
|
-
maxComputeWorkgroupStorageSize: 0,
|
|
1309
|
-
// WebGL does not support compute shaders
|
|
1310
|
-
maxComputeInvocationsPerWorkgroup: 0,
|
|
1311
|
-
// WebGL does not support compute shaders
|
|
1312
|
-
maxComputeWorkgroupSizeX: 0,
|
|
1313
|
-
// WebGL does not support compute shaders
|
|
1314
|
-
maxComputeWorkgroupSizeY: 0,
|
|
1315
|
-
// WebGL does not support compute shaders
|
|
1316
|
-
maxComputeWorkgroupSizeZ: 0,
|
|
1317
|
-
// WebGL does not support compute shaders
|
|
1318
|
-
maxComputeWorkgroupsPerDimension: 0
|
|
1319
|
-
// WebGL does not support compute shaders
|
|
1320
|
-
};
|
|
1321
|
-
}
|
|
1322
|
-
function getWebGLLimits(gl) {
|
|
1323
|
-
function get(pname) {
|
|
1324
|
-
return gl.getParameter(pname);
|
|
1395
|
+
var WebGLDeviceLimits = class extends import_core4.DeviceLimits {
|
|
1396
|
+
get maxTextureDimension1D() {
|
|
1397
|
+
return 0;
|
|
1325
1398
|
}
|
|
1326
|
-
|
|
1327
|
-
|
|
1399
|
+
// WebGL does not support 1D textures
|
|
1400
|
+
get maxTextureDimension2D() {
|
|
1401
|
+
return this.getParameter(3379);
|
|
1328
1402
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1403
|
+
get maxTextureDimension3D() {
|
|
1404
|
+
return this.getParameter(32883);
|
|
1405
|
+
}
|
|
1406
|
+
get maxTextureArrayLayers() {
|
|
1407
|
+
return this.getParameter(35071);
|
|
1408
|
+
}
|
|
1409
|
+
get maxBindGroups() {
|
|
1410
|
+
return 0;
|
|
1411
|
+
}
|
|
1412
|
+
get maxDynamicUniformBuffersPerPipelineLayout() {
|
|
1413
|
+
return 0;
|
|
1414
|
+
}
|
|
1415
|
+
// TBD
|
|
1416
|
+
get maxDynamicStorageBuffersPerPipelineLayout() {
|
|
1417
|
+
return 0;
|
|
1418
|
+
}
|
|
1419
|
+
// TBD
|
|
1420
|
+
get maxSampledTexturesPerShaderStage() {
|
|
1421
|
+
return this.getParameter(35660);
|
|
1422
|
+
}
|
|
1423
|
+
// ) TBD
|
|
1424
|
+
get maxSamplersPerShaderStage() {
|
|
1425
|
+
return this.getParameter(35661);
|
|
1426
|
+
}
|
|
1427
|
+
get maxStorageBuffersPerShaderStage() {
|
|
1428
|
+
return 0;
|
|
1429
|
+
}
|
|
1430
|
+
// TBD
|
|
1431
|
+
get maxStorageTexturesPerShaderStage() {
|
|
1432
|
+
return 0;
|
|
1433
|
+
}
|
|
1434
|
+
// TBD
|
|
1435
|
+
get maxUniformBuffersPerShaderStage() {
|
|
1436
|
+
return this.getParameter(35375);
|
|
1437
|
+
}
|
|
1438
|
+
get maxUniformBufferBindingSize() {
|
|
1439
|
+
return this.getParameter(35376);
|
|
1440
|
+
}
|
|
1441
|
+
get maxStorageBufferBindingSize() {
|
|
1442
|
+
return 0;
|
|
1443
|
+
}
|
|
1444
|
+
get minUniformBufferOffsetAlignment() {
|
|
1445
|
+
return this.getParameter(35380);
|
|
1446
|
+
}
|
|
1447
|
+
get minStorageBufferOffsetAlignment() {
|
|
1448
|
+
return 0;
|
|
1449
|
+
}
|
|
1450
|
+
get maxVertexBuffers() {
|
|
1451
|
+
return 16;
|
|
1452
|
+
}
|
|
1453
|
+
// WebGL 2 supports 16 buffers, see https://github.com/gpuweb/gpuweb/issues/4284
|
|
1454
|
+
get maxVertexAttributes() {
|
|
1455
|
+
return this.getParameter(34921);
|
|
1456
|
+
}
|
|
1457
|
+
get maxVertexBufferArrayStride() {
|
|
1458
|
+
return 2048;
|
|
1459
|
+
}
|
|
1460
|
+
// TBD, this is just the default value from WebGPU
|
|
1461
|
+
get maxInterStageShaderComponents() {
|
|
1462
|
+
return this.getParameter(35659);
|
|
1463
|
+
}
|
|
1464
|
+
get maxComputeWorkgroupStorageSize() {
|
|
1465
|
+
return 0;
|
|
1466
|
+
}
|
|
1467
|
+
// WebGL does not support compute shaders
|
|
1468
|
+
get maxComputeInvocationsPerWorkgroup() {
|
|
1469
|
+
return 0;
|
|
1470
|
+
}
|
|
1471
|
+
// WebGL does not support compute shaders
|
|
1472
|
+
get maxComputeWorkgroupSizeX() {
|
|
1473
|
+
return 0;
|
|
1474
|
+
}
|
|
1475
|
+
// WebGL does not support compute shaders
|
|
1476
|
+
get maxComputeWorkgroupSizeY() {
|
|
1477
|
+
return 0;
|
|
1478
|
+
}
|
|
1479
|
+
// WebGL does not support compute shaders
|
|
1480
|
+
get maxComputeWorkgroupSizeZ() {
|
|
1481
|
+
return 0;
|
|
1482
|
+
}
|
|
1483
|
+
// WebGL does not support compute shaders
|
|
1484
|
+
get maxComputeWorkgroupsPerDimension() {
|
|
1485
|
+
return 0;
|
|
1486
|
+
}
|
|
1487
|
+
// WebGL does not support compute shaders
|
|
1488
|
+
// PRIVATE
|
|
1489
|
+
gl;
|
|
1490
|
+
limits = {};
|
|
1491
|
+
constructor(gl) {
|
|
1492
|
+
super();
|
|
1493
|
+
this.gl = gl;
|
|
1494
|
+
}
|
|
1495
|
+
getParameter(parameter) {
|
|
1496
|
+
if (this.limits[parameter] === void 0) {
|
|
1497
|
+
this.limits[parameter] = this.gl.getParameter(parameter);
|
|
1498
|
+
}
|
|
1499
|
+
return this.limits[parameter];
|
|
1500
|
+
}
|
|
1501
|
+
};
|
|
1414
1502
|
|
|
1415
1503
|
// dist/adapter/webgl-canvas-context.js
|
|
1416
1504
|
var import_core11 = require("@luma.gl/core");
|
|
1417
1505
|
|
|
1418
1506
|
// dist/adapter/resources/webgl-framebuffer.js
|
|
1419
1507
|
var import_core10 = require("@luma.gl/core");
|
|
1420
|
-
var
|
|
1508
|
+
var import_constants11 = require("@luma.gl/constants");
|
|
1421
1509
|
|
|
1422
1510
|
// dist/adapter/resources/webgl-texture.js
|
|
1423
|
-
var
|
|
1511
|
+
var import_core9 = require("@luma.gl/core");
|
|
1424
1512
|
var import_constants10 = require("@luma.gl/constants");
|
|
1425
1513
|
|
|
1426
1514
|
// dist/context/state-tracker/with-parameters.js
|
|
1427
|
-
function withGLParameters(
|
|
1428
|
-
const webglDevice = WebGLDevice.attach(device);
|
|
1429
|
-
const gl = webglDevice.gl;
|
|
1515
|
+
function withGLParameters(gl, parameters, func) {
|
|
1430
1516
|
if (isObjectEmpty2(parameters)) {
|
|
1431
|
-
return func(
|
|
1517
|
+
return func(gl);
|
|
1432
1518
|
}
|
|
1433
1519
|
const { nocatch = true } = parameters;
|
|
1434
1520
|
pushContextState(gl);
|
|
@@ -1457,23 +1543,24 @@ function isObjectEmpty2(object) {
|
|
|
1457
1543
|
var import_constants7 = require("@luma.gl/constants");
|
|
1458
1544
|
|
|
1459
1545
|
// dist/adapter/converters/device-parameters.js
|
|
1460
|
-
var
|
|
1546
|
+
var import_core5 = require("@luma.gl/core");
|
|
1461
1547
|
var import_constants6 = require("@luma.gl/constants");
|
|
1462
1548
|
function withDeviceAndGLParameters(device, parameters, glParameters, func) {
|
|
1463
|
-
if ((0,
|
|
1549
|
+
if ((0, import_core5.isObjectEmpty)(parameters)) {
|
|
1464
1550
|
return func(device);
|
|
1465
1551
|
}
|
|
1466
|
-
|
|
1552
|
+
const webglDevice = device;
|
|
1553
|
+
pushContextState(webglDevice.gl);
|
|
1467
1554
|
try {
|
|
1468
1555
|
setDeviceParameters(device, parameters);
|
|
1469
|
-
setGLParameters(
|
|
1556
|
+
setGLParameters(webglDevice.gl, glParameters);
|
|
1470
1557
|
return func(device);
|
|
1471
1558
|
} finally {
|
|
1472
|
-
popContextState(
|
|
1559
|
+
popContextState(webglDevice.gl);
|
|
1473
1560
|
}
|
|
1474
1561
|
}
|
|
1475
1562
|
function withDeviceParameters(device, parameters, func) {
|
|
1476
|
-
if ((0,
|
|
1563
|
+
if ((0, import_core5.isObjectEmpty)(parameters)) {
|
|
1477
1564
|
return func(device);
|
|
1478
1565
|
}
|
|
1479
1566
|
pushContextState(device.gl);
|
|
@@ -1485,63 +1572,120 @@ function withDeviceParameters(device, parameters, func) {
|
|
|
1485
1572
|
}
|
|
1486
1573
|
}
|
|
1487
1574
|
function setDeviceParameters(device, parameters) {
|
|
1488
|
-
const webglDevice =
|
|
1575
|
+
const webglDevice = device;
|
|
1489
1576
|
const { gl } = webglDevice;
|
|
1490
1577
|
if (parameters.cullMode) {
|
|
1491
1578
|
switch (parameters.cullMode) {
|
|
1492
1579
|
case "none":
|
|
1493
|
-
gl.disable(
|
|
1580
|
+
gl.disable(2884);
|
|
1494
1581
|
break;
|
|
1495
1582
|
case "front":
|
|
1496
|
-
gl.enable(
|
|
1497
|
-
gl.cullFace(
|
|
1583
|
+
gl.enable(2884);
|
|
1584
|
+
gl.cullFace(1028);
|
|
1498
1585
|
break;
|
|
1499
1586
|
case "back":
|
|
1500
|
-
gl.enable(
|
|
1501
|
-
gl.cullFace(
|
|
1587
|
+
gl.enable(2884);
|
|
1588
|
+
gl.cullFace(1029);
|
|
1502
1589
|
break;
|
|
1503
1590
|
}
|
|
1504
1591
|
}
|
|
1505
1592
|
if (parameters.frontFace) {
|
|
1506
1593
|
gl.frontFace(map("frontFace", parameters.frontFace, {
|
|
1507
|
-
ccw:
|
|
1508
|
-
cw:
|
|
1594
|
+
ccw: 2305,
|
|
1595
|
+
cw: 2304
|
|
1509
1596
|
}));
|
|
1510
1597
|
}
|
|
1598
|
+
if (parameters.unclippedDepth) {
|
|
1599
|
+
if (device.features.has("depth-clip-control")) {
|
|
1600
|
+
gl.enable(34383);
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1511
1603
|
if (parameters.depthBias !== void 0) {
|
|
1512
1604
|
gl.polygonOffset(parameters.depthBias, parameters.depthBiasSlopeScale || 0);
|
|
1513
1605
|
}
|
|
1606
|
+
if (device.features.has("provoking-vertex-webgl")) {
|
|
1607
|
+
const extensions = webglDevice.getExtension("WEBGL_provoking_vertex");
|
|
1608
|
+
const ext = extensions.WEBGL_provoking_vertex;
|
|
1609
|
+
if (parameters.provokingVertex) {
|
|
1610
|
+
const vertex = map("provokingVertex", parameters.provokingVertex, {
|
|
1611
|
+
first: 36429,
|
|
1612
|
+
last: 36430
|
|
1613
|
+
});
|
|
1614
|
+
ext == null ? void 0 : ext.provokingVertexWEBGL(vertex);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
if (device.features.has("polygon-mode-webgl")) {
|
|
1618
|
+
const extensions = webglDevice.getExtension("WEBGL_polygon_mode");
|
|
1619
|
+
const ext = extensions.WEBGL_polygon_mode;
|
|
1620
|
+
if (parameters.polygonMode) {
|
|
1621
|
+
const mode = map("polygonMode", parameters.provokingVertex, {
|
|
1622
|
+
fill: 6914,
|
|
1623
|
+
lint: 6913
|
|
1624
|
+
});
|
|
1625
|
+
ext == null ? void 0 : ext.polygonModeWEBGL(1028, mode);
|
|
1626
|
+
ext == null ? void 0 : ext.polygonModeWEBGL(1029, mode);
|
|
1627
|
+
}
|
|
1628
|
+
if (parameters.polygonOffsetLine) {
|
|
1629
|
+
gl.enable(10754);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
if (device.features.has("shader-clip-cull-distance-webgl")) {
|
|
1633
|
+
if (parameters.clipDistance0) {
|
|
1634
|
+
gl.enable(12288);
|
|
1635
|
+
}
|
|
1636
|
+
if (parameters.clipDistance1) {
|
|
1637
|
+
gl.enable(12289);
|
|
1638
|
+
}
|
|
1639
|
+
if (parameters.clipDistance2) {
|
|
1640
|
+
gl.enable(12290);
|
|
1641
|
+
}
|
|
1642
|
+
if (parameters.clipDistance3) {
|
|
1643
|
+
gl.enable(12291);
|
|
1644
|
+
}
|
|
1645
|
+
if (parameters.clipDistance4) {
|
|
1646
|
+
gl.enable(12292);
|
|
1647
|
+
}
|
|
1648
|
+
if (parameters.clipDistance5) {
|
|
1649
|
+
gl.enable(12293);
|
|
1650
|
+
}
|
|
1651
|
+
if (parameters.clipDistance6) {
|
|
1652
|
+
gl.enable(12294);
|
|
1653
|
+
}
|
|
1654
|
+
if (parameters.clipDistance7) {
|
|
1655
|
+
gl.enable(12295);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1514
1658
|
if (parameters.depthWriteEnabled !== void 0) {
|
|
1515
1659
|
gl.depthMask(mapBoolean("depthWriteEnabled", parameters.depthWriteEnabled));
|
|
1516
1660
|
}
|
|
1517
1661
|
if (parameters.depthCompare) {
|
|
1518
|
-
parameters.depthCompare !== "always" ? gl.enable(
|
|
1662
|
+
parameters.depthCompare !== "always" ? gl.enable(2929) : gl.disable(2929);
|
|
1519
1663
|
gl.depthFunc(convertCompareFunction("depthCompare", parameters.depthCompare));
|
|
1520
1664
|
}
|
|
1521
1665
|
if (parameters.stencilWriteMask) {
|
|
1522
1666
|
const mask = parameters.stencilWriteMask;
|
|
1523
|
-
gl.stencilMaskSeparate(
|
|
1524
|
-
gl.stencilMaskSeparate(
|
|
1667
|
+
gl.stencilMaskSeparate(1028, mask);
|
|
1668
|
+
gl.stencilMaskSeparate(1029, mask);
|
|
1525
1669
|
}
|
|
1526
1670
|
if (parameters.stencilReadMask) {
|
|
1527
|
-
|
|
1671
|
+
import_core5.log.warn("stencilReadMask not supported under WebGL");
|
|
1528
1672
|
}
|
|
1529
1673
|
if (parameters.stencilCompare) {
|
|
1530
1674
|
const mask = parameters.stencilReadMask || 4294967295;
|
|
1531
1675
|
const glValue = convertCompareFunction("depthCompare", parameters.stencilCompare);
|
|
1532
|
-
parameters.stencilCompare !== "always" ? gl.enable(
|
|
1533
|
-
gl.stencilFuncSeparate(
|
|
1534
|
-
gl.stencilFuncSeparate(
|
|
1676
|
+
parameters.stencilCompare !== "always" ? gl.enable(2960) : gl.disable(2960);
|
|
1677
|
+
gl.stencilFuncSeparate(1028, glValue, 0, mask);
|
|
1678
|
+
gl.stencilFuncSeparate(1029, glValue, 0, mask);
|
|
1535
1679
|
}
|
|
1536
1680
|
if (parameters.stencilPassOperation && parameters.stencilFailOperation && parameters.stencilDepthFailOperation) {
|
|
1537
1681
|
const dppass = convertStencilOperation("stencilPassOperation", parameters.stencilPassOperation);
|
|
1538
1682
|
const sfail = convertStencilOperation("stencilFailOperation", parameters.stencilFailOperation);
|
|
1539
1683
|
const dpfail = convertStencilOperation("stencilDepthFailOperation", parameters.stencilDepthFailOperation);
|
|
1540
|
-
gl.stencilOpSeparate(
|
|
1541
|
-
gl.stencilOpSeparate(
|
|
1684
|
+
gl.stencilOpSeparate(1028, sfail, dpfail, dppass);
|
|
1685
|
+
gl.stencilOpSeparate(1029, sfail, dpfail, dppass);
|
|
1542
1686
|
}
|
|
1543
1687
|
if (parameters.blendColorOperation || parameters.blendAlphaOperation) {
|
|
1544
|
-
gl.enable(
|
|
1688
|
+
gl.enable(3042);
|
|
1545
1689
|
const colorEquation = convertBlendOperationToEquation("blendColorOperation", parameters.blendColorOperation || "add");
|
|
1546
1690
|
const alphaEquation = convertBlendOperationToEquation("blendAlphaOperation", parameters.blendAlphaOperation || "add");
|
|
1547
1691
|
gl.blendEquationSeparate(colorEquation, alphaEquation);
|
|
@@ -1554,49 +1698,49 @@ function setDeviceParameters(device, parameters) {
|
|
|
1554
1698
|
}
|
|
1555
1699
|
function convertCompareFunction(parameter, value) {
|
|
1556
1700
|
return map(parameter, value, {
|
|
1557
|
-
never:
|
|
1558
|
-
less:
|
|
1559
|
-
equal:
|
|
1560
|
-
"less-equal":
|
|
1561
|
-
greater:
|
|
1562
|
-
"not-equal":
|
|
1563
|
-
"greater-equal":
|
|
1564
|
-
always:
|
|
1701
|
+
never: 512,
|
|
1702
|
+
less: 513,
|
|
1703
|
+
equal: 514,
|
|
1704
|
+
"less-equal": 515,
|
|
1705
|
+
greater: 516,
|
|
1706
|
+
"not-equal": 517,
|
|
1707
|
+
"greater-equal": 518,
|
|
1708
|
+
always: 519
|
|
1565
1709
|
});
|
|
1566
1710
|
}
|
|
1567
1711
|
function convertStencilOperation(parameter, value) {
|
|
1568
1712
|
return map(parameter, value, {
|
|
1569
|
-
keep:
|
|
1570
|
-
zero:
|
|
1571
|
-
replace:
|
|
1572
|
-
invert:
|
|
1573
|
-
"increment-clamp":
|
|
1574
|
-
"decrement-clamp":
|
|
1575
|
-
"increment-wrap":
|
|
1576
|
-
"decrement-wrap":
|
|
1713
|
+
keep: 7680,
|
|
1714
|
+
zero: 0,
|
|
1715
|
+
replace: 7681,
|
|
1716
|
+
invert: 5386,
|
|
1717
|
+
"increment-clamp": 7682,
|
|
1718
|
+
"decrement-clamp": 7683,
|
|
1719
|
+
"increment-wrap": 34055,
|
|
1720
|
+
"decrement-wrap": 34056
|
|
1577
1721
|
});
|
|
1578
1722
|
}
|
|
1579
1723
|
function convertBlendOperationToEquation(parameter, value) {
|
|
1580
1724
|
return map(parameter, value, {
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
"reverse-subtract":
|
|
1584
|
-
|
|
1585
|
-
|
|
1725
|
+
add: 32774,
|
|
1726
|
+
subtract: 32778,
|
|
1727
|
+
"reverse-subtract": 32779,
|
|
1728
|
+
min: 32775,
|
|
1729
|
+
max: 32776
|
|
1586
1730
|
});
|
|
1587
1731
|
}
|
|
1588
1732
|
function convertBlendFactorToFunction(parameter, value) {
|
|
1589
1733
|
return map(parameter, value, {
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
"src-color":
|
|
1593
|
-
"one-minus-src-color":
|
|
1594
|
-
"dst-color":
|
|
1595
|
-
"one-minus-dst-color":
|
|
1596
|
-
"src-alpha":
|
|
1597
|
-
"one-minus-src-alpha":
|
|
1598
|
-
"dst-alpha":
|
|
1599
|
-
"one-minus-dst-alpha":
|
|
1734
|
+
one: 1,
|
|
1735
|
+
zero: 0,
|
|
1736
|
+
"src-color": 768,
|
|
1737
|
+
"one-minus-src-color": 769,
|
|
1738
|
+
"dst-color": 774,
|
|
1739
|
+
"one-minus-dst-color": 775,
|
|
1740
|
+
"src-alpha": 770,
|
|
1741
|
+
"one-minus-src-alpha": 771,
|
|
1742
|
+
"dst-alpha": 772,
|
|
1743
|
+
"one-minus-dst-alpha": 773
|
|
1600
1744
|
});
|
|
1601
1745
|
}
|
|
1602
1746
|
function message(parameter, value) {
|
|
@@ -1616,53 +1760,53 @@ function mapBoolean(parameter, value) {
|
|
|
1616
1760
|
function convertSamplerParametersToWebGL(props) {
|
|
1617
1761
|
const params = {};
|
|
1618
1762
|
if (props.addressModeU) {
|
|
1619
|
-
params[
|
|
1763
|
+
params[10242] = convertAddressMode(props.addressModeU);
|
|
1620
1764
|
}
|
|
1621
1765
|
if (props.addressModeV) {
|
|
1622
|
-
params[
|
|
1766
|
+
params[10243] = convertAddressMode(props.addressModeV);
|
|
1623
1767
|
}
|
|
1624
1768
|
if (props.addressModeW) {
|
|
1625
|
-
params[
|
|
1769
|
+
params[32882] = convertAddressMode(props.addressModeW);
|
|
1626
1770
|
}
|
|
1627
1771
|
if (props.magFilter) {
|
|
1628
|
-
params[
|
|
1772
|
+
params[10240] = convertMaxFilterMode(props.magFilter);
|
|
1629
1773
|
}
|
|
1630
1774
|
if (props.minFilter || props.mipmapFilter) {
|
|
1631
|
-
params[
|
|
1775
|
+
params[10241] = convertMinFilterMode(props.minFilter || "linear", props.mipmapFilter);
|
|
1632
1776
|
}
|
|
1633
1777
|
if (props.lodMinClamp !== void 0) {
|
|
1634
|
-
params[
|
|
1778
|
+
params[33082] = props.lodMinClamp;
|
|
1635
1779
|
}
|
|
1636
1780
|
if (props.lodMaxClamp !== void 0) {
|
|
1637
|
-
params[
|
|
1781
|
+
params[33083] = props.lodMaxClamp;
|
|
1638
1782
|
}
|
|
1639
1783
|
if (props.type === "comparison-sampler") {
|
|
1640
|
-
params[
|
|
1784
|
+
params[34892] = 34894;
|
|
1641
1785
|
}
|
|
1642
1786
|
if (props.compare) {
|
|
1643
|
-
params[
|
|
1787
|
+
params[34893] = convertCompareFunction("compare", props.compare);
|
|
1644
1788
|
}
|
|
1645
1789
|
if (props.maxAnisotropy) {
|
|
1646
|
-
params[
|
|
1790
|
+
params[34046] = props.maxAnisotropy;
|
|
1647
1791
|
}
|
|
1648
1792
|
return params;
|
|
1649
1793
|
}
|
|
1650
1794
|
function convertAddressMode(addressMode) {
|
|
1651
1795
|
switch (addressMode) {
|
|
1652
1796
|
case "clamp-to-edge":
|
|
1653
|
-
return
|
|
1797
|
+
return 33071;
|
|
1654
1798
|
case "repeat":
|
|
1655
|
-
return
|
|
1799
|
+
return 10497;
|
|
1656
1800
|
case "mirror-repeat":
|
|
1657
|
-
return
|
|
1801
|
+
return 33648;
|
|
1658
1802
|
}
|
|
1659
1803
|
}
|
|
1660
1804
|
function convertMaxFilterMode(maxFilter) {
|
|
1661
1805
|
switch (maxFilter) {
|
|
1662
1806
|
case "nearest":
|
|
1663
|
-
return
|
|
1807
|
+
return 9728;
|
|
1664
1808
|
case "linear":
|
|
1665
|
-
return
|
|
1809
|
+
return 9729;
|
|
1666
1810
|
}
|
|
1667
1811
|
}
|
|
1668
1812
|
function convertMinFilterMode(minFilter, mipmapFilter) {
|
|
@@ -1671,16 +1815,16 @@ function convertMinFilterMode(minFilter, mipmapFilter) {
|
|
|
1671
1815
|
}
|
|
1672
1816
|
switch (minFilter) {
|
|
1673
1817
|
case "nearest":
|
|
1674
|
-
return mipmapFilter === "nearest" ?
|
|
1818
|
+
return mipmapFilter === "nearest" ? 9984 : 9986;
|
|
1675
1819
|
case "linear":
|
|
1676
|
-
return mipmapFilter === "nearest" ?
|
|
1820
|
+
return mipmapFilter === "nearest" ? 9985 : 9987;
|
|
1677
1821
|
}
|
|
1678
1822
|
}
|
|
1679
1823
|
|
|
1680
1824
|
// dist/adapter/resources/webgl-buffer.js
|
|
1681
|
-
var
|
|
1825
|
+
var import_core6 = require("@luma.gl/core");
|
|
1682
1826
|
var import_constants8 = require("@luma.gl/constants");
|
|
1683
|
-
var WEBGLBuffer = class extends
|
|
1827
|
+
var WEBGLBuffer = class extends import_core6.Buffer {
|
|
1684
1828
|
device;
|
|
1685
1829
|
gl;
|
|
1686
1830
|
handle;
|
|
@@ -1689,7 +1833,7 @@ var WEBGLBuffer = class extends import_core4.Buffer {
|
|
|
1689
1833
|
/** Usage is a hint on how frequently the buffer will be updates */
|
|
1690
1834
|
glUsage;
|
|
1691
1835
|
/** Index type is needed when issuing draw calls, so we pre-compute it */
|
|
1692
|
-
glIndexType =
|
|
1836
|
+
glIndexType = 5123;
|
|
1693
1837
|
/** Number of bytes allocated on the GPU for this buffer */
|
|
1694
1838
|
byteLength;
|
|
1695
1839
|
/** Number of bytes used */
|
|
@@ -1703,7 +1847,7 @@ var WEBGLBuffer = class extends import_core4.Buffer {
|
|
|
1703
1847
|
device.setSpectorMetadata(this.handle, { ...this.props, data: typeof this.props.data });
|
|
1704
1848
|
this.glTarget = getWebGLTarget(this.props.usage);
|
|
1705
1849
|
this.glUsage = getWebGLUsage(this.props.usage);
|
|
1706
|
-
this.glIndexType = this.props.indexType === "uint32" ?
|
|
1850
|
+
this.glIndexType = this.props.indexType === "uint32" ? 5125 : 5123;
|
|
1707
1851
|
if (props.data) {
|
|
1708
1852
|
this._initWithData(props.data, props.byteOffset, props.byteLength);
|
|
1709
1853
|
} else {
|
|
@@ -1725,7 +1869,7 @@ var WEBGLBuffer = class extends import_core4.Buffer {
|
|
|
1725
1869
|
}
|
|
1726
1870
|
// Allocate a GPU buffer of specified size.
|
|
1727
1871
|
_initWithByteLength(byteLength) {
|
|
1728
|
-
(0,
|
|
1872
|
+
(0, import_core6.assert)(byteLength >= 0);
|
|
1729
1873
|
let data = byteLength;
|
|
1730
1874
|
if (byteLength === 0) {
|
|
1731
1875
|
data = new Float32Array(0);
|
|
@@ -1752,7 +1896,7 @@ var WEBGLBuffer = class extends import_core4.Buffer {
|
|
|
1752
1896
|
write(data, byteOffset = 0) {
|
|
1753
1897
|
const srcOffset = 0;
|
|
1754
1898
|
const byteLength = void 0;
|
|
1755
|
-
const glTarget =
|
|
1899
|
+
const glTarget = 36663;
|
|
1756
1900
|
this.gl.bindBuffer(glTarget, this.handle);
|
|
1757
1901
|
if (srcOffset !== 0 || byteLength !== void 0) {
|
|
1758
1902
|
this.gl.bufferSubData(glTarget, byteOffset, data, srcOffset, byteLength);
|
|
@@ -1771,42 +1915,42 @@ var WEBGLBuffer = class extends import_core4.Buffer {
|
|
|
1771
1915
|
byteLength = byteLength ?? this.byteLength - byteOffset;
|
|
1772
1916
|
const data = new Uint8Array(byteLength);
|
|
1773
1917
|
const dstOffset = 0;
|
|
1774
|
-
this.gl.bindBuffer(
|
|
1775
|
-
this.gl.getBufferSubData(
|
|
1776
|
-
this.gl.bindBuffer(
|
|
1918
|
+
this.gl.bindBuffer(36662, this.handle);
|
|
1919
|
+
this.gl.getBufferSubData(36662, byteOffset, data, dstOffset, byteLength);
|
|
1920
|
+
this.gl.bindBuffer(36662, null);
|
|
1777
1921
|
this._setDebugData(data, byteOffset, byteLength);
|
|
1778
1922
|
return data;
|
|
1779
1923
|
}
|
|
1780
1924
|
};
|
|
1781
1925
|
function getWebGLTarget(usage) {
|
|
1782
|
-
if (usage &
|
|
1783
|
-
return
|
|
1926
|
+
if (usage & import_core6.Buffer.INDEX) {
|
|
1927
|
+
return 34963;
|
|
1784
1928
|
}
|
|
1785
|
-
if (usage &
|
|
1786
|
-
return
|
|
1929
|
+
if (usage & import_core6.Buffer.VERTEX) {
|
|
1930
|
+
return 34962;
|
|
1787
1931
|
}
|
|
1788
|
-
if (usage &
|
|
1789
|
-
return
|
|
1932
|
+
if (usage & import_core6.Buffer.UNIFORM) {
|
|
1933
|
+
return 35345;
|
|
1790
1934
|
}
|
|
1791
|
-
return
|
|
1935
|
+
return 34962;
|
|
1792
1936
|
}
|
|
1793
1937
|
function getWebGLUsage(usage) {
|
|
1794
|
-
if (usage &
|
|
1795
|
-
return
|
|
1938
|
+
if (usage & import_core6.Buffer.INDEX) {
|
|
1939
|
+
return 35044;
|
|
1796
1940
|
}
|
|
1797
|
-
if (usage &
|
|
1798
|
-
return
|
|
1941
|
+
if (usage & import_core6.Buffer.VERTEX) {
|
|
1942
|
+
return 35044;
|
|
1799
1943
|
}
|
|
1800
|
-
if (usage &
|
|
1801
|
-
return
|
|
1944
|
+
if (usage & import_core6.Buffer.UNIFORM) {
|
|
1945
|
+
return 35048;
|
|
1802
1946
|
}
|
|
1803
|
-
return
|
|
1947
|
+
return 35044;
|
|
1804
1948
|
}
|
|
1805
1949
|
|
|
1806
1950
|
// dist/adapter/resources/webgl-sampler.js
|
|
1807
|
-
var
|
|
1951
|
+
var import_core7 = require("@luma.gl/core");
|
|
1808
1952
|
var import_constants9 = require("@luma.gl/constants");
|
|
1809
|
-
var WEBGLSampler = class extends
|
|
1953
|
+
var WEBGLSampler = class extends import_core7.Sampler {
|
|
1810
1954
|
device;
|
|
1811
1955
|
handle;
|
|
1812
1956
|
parameters;
|
|
@@ -1831,8 +1975,8 @@ var WEBGLSampler = class extends import_core5.Sampler {
|
|
|
1831
1975
|
for (const [pname, value] of Object.entries(parameters)) {
|
|
1832
1976
|
const param = Number(pname);
|
|
1833
1977
|
switch (param) {
|
|
1834
|
-
case
|
|
1835
|
-
case
|
|
1978
|
+
case 33082:
|
|
1979
|
+
case 33083:
|
|
1836
1980
|
this.device.gl.samplerParameterf(this.handle, param, value);
|
|
1837
1981
|
break;
|
|
1838
1982
|
default:
|
|
@@ -1843,6 +1987,22 @@ var WEBGLSampler = class extends import_core5.Sampler {
|
|
|
1843
1987
|
}
|
|
1844
1988
|
};
|
|
1845
1989
|
|
|
1990
|
+
// dist/adapter/resources/webgl-texture-view.js
|
|
1991
|
+
var import_core8 = require("@luma.gl/core");
|
|
1992
|
+
var WEBGLTextureView = class extends import_core8.TextureView {
|
|
1993
|
+
device;
|
|
1994
|
+
gl;
|
|
1995
|
+
handle;
|
|
1996
|
+
texture;
|
|
1997
|
+
constructor(device, props) {
|
|
1998
|
+
super(device, { ...import_core8.Texture.defaultProps, ...props });
|
|
1999
|
+
this.device = device;
|
|
2000
|
+
this.gl = this.device.gl;
|
|
2001
|
+
this.handle = null;
|
|
2002
|
+
this.texture = props.texture;
|
|
2003
|
+
}
|
|
2004
|
+
};
|
|
2005
|
+
|
|
1846
2006
|
// dist/adapter/resources/webgl-texture.js
|
|
1847
2007
|
var DEFAULT_WEBGL_TEXTURE_PROPS = {
|
|
1848
2008
|
// deprecated
|
|
@@ -1854,13 +2014,14 @@ var DEFAULT_WEBGL_TEXTURE_PROPS = {
|
|
|
1854
2014
|
textureUnit: void 0,
|
|
1855
2015
|
target: void 0
|
|
1856
2016
|
};
|
|
1857
|
-
var _WEBGLTexture = class extends
|
|
2017
|
+
var _WEBGLTexture = class extends import_core9.Texture {
|
|
1858
2018
|
MAX_ATTRIBUTES;
|
|
1859
2019
|
device;
|
|
1860
2020
|
gl;
|
|
1861
2021
|
handle;
|
|
1862
|
-
|
|
2022
|
+
// (TODO - currently unused in WebGL, but WebGL 2 does support sampler objects) */
|
|
1863
2023
|
sampler = void 0;
|
|
2024
|
+
view = void 0;
|
|
1864
2025
|
// data;
|
|
1865
2026
|
glFormat = void 0;
|
|
1866
2027
|
type = void 0;
|
|
@@ -1891,11 +2052,11 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
1891
2052
|
this.gl = this.device.gl;
|
|
1892
2053
|
this.handle = this.props.handle || this.gl.createTexture();
|
|
1893
2054
|
this.device.setSpectorMetadata(this.handle, { ...this.props, data: typeof this.props.data });
|
|
1894
|
-
this.glFormat =
|
|
2055
|
+
this.glFormat = 6408;
|
|
1895
2056
|
this.target = getWebGLTextureTarget(this.props);
|
|
1896
2057
|
this.loaded = false;
|
|
1897
2058
|
if (typeof ((_a = this.props) == null ? void 0 : _a.data) === "string") {
|
|
1898
|
-
Object.assign(this.props, { data: (0,
|
|
2059
|
+
Object.assign(this.props, { data: (0, import_core9.loadImage)(this.props.data) });
|
|
1899
2060
|
}
|
|
1900
2061
|
this.initialize(this.props);
|
|
1901
2062
|
Object.seal(this);
|
|
@@ -1911,6 +2072,9 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
1911
2072
|
toString() {
|
|
1912
2073
|
return `Texture(${this.id},${this.width}x${this.height})`;
|
|
1913
2074
|
}
|
|
2075
|
+
createView(props) {
|
|
2076
|
+
return new WEBGLTextureView(this.device, { ...props, texture: this });
|
|
2077
|
+
}
|
|
1914
2078
|
// eslint-disable-next-line max-statements
|
|
1915
2079
|
initialize(props = {}) {
|
|
1916
2080
|
if (this.props.dimension === "cube") {
|
|
@@ -1954,7 +2118,7 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
1954
2118
|
this.dataFormat = dataFormat;
|
|
1955
2119
|
this.textureUnit = textureUnit;
|
|
1956
2120
|
if (Number.isFinite(this.textureUnit)) {
|
|
1957
|
-
this.gl.activeTexture(
|
|
2121
|
+
this.gl.activeTexture(33984 + this.textureUnit);
|
|
1958
2122
|
this.gl.bindTexture(this.target, this.handle);
|
|
1959
2123
|
}
|
|
1960
2124
|
this.mipmaps = mipmaps;
|
|
@@ -1972,7 +2136,8 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
1972
2136
|
});
|
|
1973
2137
|
this.setSampler(props.sampler);
|
|
1974
2138
|
this._setSamplerParameters(parameters);
|
|
1975
|
-
|
|
2139
|
+
this.view = this.createView({ ...this.props, mipLevelCount: 1, arrayLayerCount: 1 });
|
|
2140
|
+
if (mipmaps && this.device.isTextureFormatFilterable(props.format)) {
|
|
1976
2141
|
this.generateMipmap();
|
|
1977
2142
|
}
|
|
1978
2143
|
if (isVideo) {
|
|
@@ -2120,9 +2285,9 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2120
2285
|
);
|
|
2121
2286
|
break;
|
|
2122
2287
|
case "buffer":
|
|
2123
|
-
this.device.gl.bindBuffer(
|
|
2288
|
+
this.device.gl.bindBuffer(35052, data.handle || data);
|
|
2124
2289
|
this.device.gl.texImage2D(target, level, glFormat, width, height, 0, dataFormat, type, offset);
|
|
2125
|
-
this.device.gl.bindBuffer(
|
|
2290
|
+
this.device.gl.bindBuffer(35052, null);
|
|
2126
2291
|
break;
|
|
2127
2292
|
case "browser-object":
|
|
2128
2293
|
gl.texImage2D(target, level, glFormat, width, height, 0, dataFormat, type, data);
|
|
@@ -2133,7 +2298,7 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2133
2298
|
}
|
|
2134
2299
|
break;
|
|
2135
2300
|
default:
|
|
2136
|
-
(0,
|
|
2301
|
+
(0, import_core9.assert)(false, "Unknown image data type");
|
|
2137
2302
|
}
|
|
2138
2303
|
});
|
|
2139
2304
|
if (data && data.byteLength) {
|
|
@@ -2160,7 +2325,7 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2160
2325
|
width,
|
|
2161
2326
|
height
|
|
2162
2327
|
}));
|
|
2163
|
-
(0,
|
|
2328
|
+
(0, import_core9.assert)(this.depth === 1, "texSubImage not supported for 3D textures");
|
|
2164
2329
|
if (!data) {
|
|
2165
2330
|
data = pixels;
|
|
2166
2331
|
}
|
|
@@ -2182,9 +2347,9 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2182
2347
|
} else if (ArrayBuffer.isView(data)) {
|
|
2183
2348
|
this.gl.texSubImage2D(target, level, x, y, width, height, dataFormat, type, data, offset);
|
|
2184
2349
|
} else if (typeof WebGLBuffer !== "undefined" && data instanceof WebGLBuffer) {
|
|
2185
|
-
this.device.gl.bindBuffer(
|
|
2350
|
+
this.device.gl.bindBuffer(35052, data);
|
|
2186
2351
|
this.device.gl.texSubImage2D(target, level, x, y, width, height, dataFormat, type, offset);
|
|
2187
|
-
this.device.gl.bindBuffer(
|
|
2352
|
+
this.device.gl.bindBuffer(35052, null);
|
|
2188
2353
|
} else {
|
|
2189
2354
|
this.device.gl.texSubImage2D(target, level, x, y, width, height, dataFormat, type, data);
|
|
2190
2355
|
}
|
|
@@ -2200,17 +2365,17 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2200
2365
|
* rendering can be faster.
|
|
2201
2366
|
*/
|
|
2202
2367
|
copyFramebuffer(opts = {}) {
|
|
2203
|
-
|
|
2368
|
+
import_core9.log.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")();
|
|
2204
2369
|
return null;
|
|
2205
2370
|
}
|
|
2206
2371
|
getActiveUnit() {
|
|
2207
|
-
return this.gl.getParameter(
|
|
2372
|
+
return this.gl.getParameter(34016) - 33984;
|
|
2208
2373
|
}
|
|
2209
2374
|
bind(textureUnit = this.textureUnit) {
|
|
2210
2375
|
const { gl } = this;
|
|
2211
2376
|
if (textureUnit !== void 0) {
|
|
2212
2377
|
this.textureUnit = textureUnit;
|
|
2213
|
-
gl.activeTexture(
|
|
2378
|
+
gl.activeTexture(33984 + textureUnit);
|
|
2214
2379
|
}
|
|
2215
2380
|
gl.bindTexture(this.target, this.handle);
|
|
2216
2381
|
return textureUnit;
|
|
@@ -2219,7 +2384,7 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2219
2384
|
const { gl } = this;
|
|
2220
2385
|
if (textureUnit !== void 0) {
|
|
2221
2386
|
this.textureUnit = textureUnit;
|
|
2222
|
-
gl.activeTexture(
|
|
2387
|
+
gl.activeTexture(33984 + textureUnit);
|
|
2223
2388
|
}
|
|
2224
2389
|
gl.bindTexture(this.target, null);
|
|
2225
2390
|
return textureUnit;
|
|
@@ -2272,16 +2437,16 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2272
2437
|
} else {
|
|
2273
2438
|
size = { width, height };
|
|
2274
2439
|
}
|
|
2275
|
-
(0,
|
|
2276
|
-
(0,
|
|
2277
|
-
(0,
|
|
2440
|
+
(0, import_core9.assert)(size, "Could not deduced texture size");
|
|
2441
|
+
(0, import_core9.assert)(width === void 0 || size.width === width, "Deduced texture width does not match supplied width");
|
|
2442
|
+
(0, import_core9.assert)(height === void 0 || size.height === height, "Deduced texture height does not match supplied height");
|
|
2278
2443
|
return size;
|
|
2279
2444
|
}
|
|
2280
2445
|
// CUBE MAP METHODS
|
|
2281
2446
|
/* eslint-disable max-statements, max-len */
|
|
2282
2447
|
async setCubeMapImageData(options) {
|
|
2283
2448
|
const { gl } = this;
|
|
2284
|
-
const { width, height, pixels, data, format =
|
|
2449
|
+
const { width, height, pixels, data, format = 6408, type = 5121 } = options;
|
|
2285
2450
|
const imageDataMap = pixels || data;
|
|
2286
2451
|
const resolvedFaces = await Promise.all(_WEBGLTexture.FACES.map((face) => {
|
|
2287
2452
|
const facePixels = imageDataMap[face];
|
|
@@ -2290,7 +2455,7 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2290
2455
|
this.bind();
|
|
2291
2456
|
_WEBGLTexture.FACES.forEach((face, index) => {
|
|
2292
2457
|
if (resolvedFaces[index].length > 1 && this.props.mipmaps !== false) {
|
|
2293
|
-
|
|
2458
|
+
import_core9.log.warn(`${this.id} has mipmap and multiple LODs.`)();
|
|
2294
2459
|
}
|
|
2295
2460
|
resolvedFaces[index].forEach((image, lodLevel) => {
|
|
2296
2461
|
if (width && height) {
|
|
@@ -2310,8 +2475,8 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2310
2475
|
height,
|
|
2311
2476
|
pixels,
|
|
2312
2477
|
data,
|
|
2313
|
-
format =
|
|
2314
|
-
type =
|
|
2478
|
+
format = 6408,
|
|
2479
|
+
type = 5121
|
|
2315
2480
|
// generateMipmap = false // TODO
|
|
2316
2481
|
} = options;
|
|
2317
2482
|
const { gl } = this;
|
|
@@ -2365,7 +2530,7 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2365
2530
|
);
|
|
2366
2531
|
}
|
|
2367
2532
|
if (data instanceof WEBGLBuffer) {
|
|
2368
|
-
this.gl.bindBuffer(
|
|
2533
|
+
this.gl.bindBuffer(35052, data.handle);
|
|
2369
2534
|
this.gl.texImage3D(this.target, level, dataFormat, width, height, depth, 0, format, type, offset);
|
|
2370
2535
|
}
|
|
2371
2536
|
});
|
|
@@ -2383,7 +2548,7 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2383
2548
|
* Sets sampler parameters on texture
|
|
2384
2549
|
*/
|
|
2385
2550
|
_setSamplerParameters(parameters) {
|
|
2386
|
-
if ((0,
|
|
2551
|
+
if ((0, import_core9.isObjectEmpty)(parameters)) {
|
|
2387
2552
|
return;
|
|
2388
2553
|
}
|
|
2389
2554
|
logParameters(parameters);
|
|
@@ -2392,8 +2557,8 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2392
2557
|
const param = Number(pname);
|
|
2393
2558
|
const value = pvalue;
|
|
2394
2559
|
switch (param) {
|
|
2395
|
-
case
|
|
2396
|
-
case
|
|
2560
|
+
case 33082:
|
|
2561
|
+
case 33083:
|
|
2397
2562
|
this.gl.texParameterf(this.target, param, value);
|
|
2398
2563
|
break;
|
|
2399
2564
|
default:
|
|
@@ -2408,23 +2573,23 @@ var _WEBGLTexture = class extends import_core6.Texture {
|
|
|
2408
2573
|
var WEBGLTexture = _WEBGLTexture;
|
|
2409
2574
|
// TODO - remove?
|
|
2410
2575
|
__publicField(WEBGLTexture, "FACES", [
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2576
|
+
34069,
|
|
2577
|
+
34070,
|
|
2578
|
+
34071,
|
|
2579
|
+
34072,
|
|
2580
|
+
34073,
|
|
2581
|
+
34074
|
|
2417
2582
|
]);
|
|
2418
2583
|
function getWebGLTextureTarget(props) {
|
|
2419
2584
|
switch (props.dimension) {
|
|
2420
2585
|
case "2d":
|
|
2421
|
-
return
|
|
2586
|
+
return 3553;
|
|
2422
2587
|
case "cube":
|
|
2423
|
-
return
|
|
2588
|
+
return 34067;
|
|
2424
2589
|
case "2d-array":
|
|
2425
|
-
return
|
|
2590
|
+
return 35866;
|
|
2426
2591
|
case "3d":
|
|
2427
|
-
return
|
|
2592
|
+
return 32879;
|
|
2428
2593
|
case "1d":
|
|
2429
2594
|
case "cube-array":
|
|
2430
2595
|
default:
|
|
@@ -2432,380 +2597,114 @@ function getWebGLTextureTarget(props) {
|
|
|
2432
2597
|
}
|
|
2433
2598
|
}
|
|
2434
2599
|
function logParameters(parameters) {
|
|
2435
|
-
|
|
2436
|
-
}
|
|
2437
|
-
|
|
2438
|
-
// dist/adapter/objects/webgl-renderbuffer.js
|
|
2439
|
-
var import_core9 = require("@luma.gl/core");
|
|
2440
|
-
var import_constants11 = require("@luma.gl/constants");
|
|
2441
|
-
|
|
2442
|
-
// dist/adapter/objects/webgl-resource.js
|
|
2443
|
-
var import_core8 = require("@luma.gl/core");
|
|
2444
|
-
|
|
2445
|
-
// dist/adapter/objects/constants-to-keys.js
|
|
2446
|
-
var import_core7 = require("@luma.gl/core");
|
|
2447
|
-
function getKeyValue(gl, name) {
|
|
2448
|
-
if (typeof name !== "string") {
|
|
2449
|
-
return name;
|
|
2450
|
-
}
|
|
2451
|
-
const number = Number(name);
|
|
2452
|
-
if (!isNaN(number)) {
|
|
2453
|
-
return number;
|
|
2454
|
-
}
|
|
2455
|
-
name = name.replace(/^.*\./, "");
|
|
2456
|
-
const value = gl[name];
|
|
2457
|
-
(0, import_core7.assert)(value !== void 0, `Accessing undefined constant GL.${name}`);
|
|
2458
|
-
return value;
|
|
2600
|
+
import_core9.log.log(1, "texture sampler parameters", parameters)();
|
|
2459
2601
|
}
|
|
2460
2602
|
|
|
2461
|
-
// dist/adapter/
|
|
2462
|
-
var
|
|
2463
|
-
var WebGLResource = class extends import_core8.Resource {
|
|
2603
|
+
// dist/adapter/resources/webgl-framebuffer.js
|
|
2604
|
+
var WEBGLFramebuffer = class extends import_core10.Framebuffer {
|
|
2464
2605
|
device;
|
|
2465
2606
|
gl;
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
// Only meaningful for resources that allocate GPU memory
|
|
2470
|
-
byteLength = 0;
|
|
2471
|
-
constructor(device, props, defaultProps) {
|
|
2472
|
-
super(device, props, defaultProps);
|
|
2473
|
-
this.device = WebGLDevice.attach(device);
|
|
2474
|
-
const gl = this.device.gl;
|
|
2475
|
-
const { id } = props || {};
|
|
2476
|
-
this.gl = gl;
|
|
2477
|
-
this.gl2 = gl;
|
|
2478
|
-
this.id = id || (0, import_core8.uid)(this.constructor.name);
|
|
2479
|
-
this._handle = props == null ? void 0 : props.handle;
|
|
2480
|
-
if (this._handle === void 0) {
|
|
2481
|
-
this._handle = this._createHandle();
|
|
2482
|
-
}
|
|
2483
|
-
this.byteLength = 0;
|
|
2484
|
-
}
|
|
2485
|
-
toString() {
|
|
2486
|
-
return `${this.constructor.name}(${this.id})`;
|
|
2487
|
-
}
|
|
2488
|
-
get handle() {
|
|
2489
|
-
return this._handle;
|
|
2607
|
+
handle;
|
|
2608
|
+
get texture() {
|
|
2609
|
+
return this.colorAttachments[0];
|
|
2490
2610
|
}
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
this.
|
|
2497
|
-
if (
|
|
2498
|
-
|
|
2611
|
+
constructor(device, props) {
|
|
2612
|
+
super(device, props);
|
|
2613
|
+
const isDefaultFramebuffer = props.handle === null;
|
|
2614
|
+
this.device = device;
|
|
2615
|
+
this.gl = device.gl;
|
|
2616
|
+
this.handle = this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();
|
|
2617
|
+
if (!isDefaultFramebuffer) {
|
|
2618
|
+
device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
|
|
2619
|
+
this.autoCreateAttachmentTextures();
|
|
2620
|
+
this.gl.bindFramebuffer(36160, this.handle);
|
|
2621
|
+
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
2622
|
+
const attachment = this.colorAttachments[i];
|
|
2623
|
+
const attachmentPoint = 36064 + i;
|
|
2624
|
+
if (attachment) {
|
|
2625
|
+
this._attachOne(attachmentPoint, attachment);
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
if (this.depthStencilAttachment) {
|
|
2629
|
+
this._attachOne(getDepthStencilAttachmentWebGL(this.depthStencilAttachment.props.format), this.depthStencilAttachment);
|
|
2630
|
+
}
|
|
2631
|
+
if (props.check !== false) {
|
|
2632
|
+
const status = this.gl.checkFramebufferStatus(36160);
|
|
2633
|
+
if (status !== 36053) {
|
|
2634
|
+
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
this.gl.bindFramebuffer(36160, null);
|
|
2499
2638
|
}
|
|
2500
|
-
return this;
|
|
2501
2639
|
}
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
let value;
|
|
2508
|
-
if (!this._bound) {
|
|
2509
|
-
this._bindHandle(this.handle);
|
|
2510
|
-
this._bound = true;
|
|
2511
|
-
value = funcOrHandle();
|
|
2512
|
-
this._bound = false;
|
|
2513
|
-
this._bindHandle(null);
|
|
2514
|
-
} else {
|
|
2515
|
-
value = funcOrHandle();
|
|
2640
|
+
/** destroys any auto created resources etc. */
|
|
2641
|
+
destroy() {
|
|
2642
|
+
super.destroy();
|
|
2643
|
+
if (!this.destroyed && this.handle !== null) {
|
|
2644
|
+
this.gl.deleteFramebuffer(this.handle);
|
|
2516
2645
|
}
|
|
2517
|
-
return value;
|
|
2518
2646
|
}
|
|
2519
|
-
|
|
2520
|
-
|
|
2647
|
+
// PRIVATE
|
|
2648
|
+
/** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
|
|
2649
|
+
createDepthStencilTexture(format) {
|
|
2650
|
+
return new WEBGLTexture(this.device, {
|
|
2651
|
+
id: `${this.id}-depth-stencil`,
|
|
2652
|
+
format,
|
|
2653
|
+
width: this.width,
|
|
2654
|
+
height: this.height,
|
|
2655
|
+
mipmaps: false
|
|
2656
|
+
});
|
|
2521
2657
|
}
|
|
2522
2658
|
/**
|
|
2523
|
-
*
|
|
2524
|
-
*
|
|
2525
|
-
* @param name
|
|
2526
|
-
* @return param
|
|
2659
|
+
* Attachment resize is expected to be a noop if size is same
|
|
2527
2660
|
*/
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
if (parameter) {
|
|
2534
|
-
const parameterAvailable = !("extension" in parameter) || this.gl.getExtension(parameter.extension);
|
|
2535
|
-
if (!parameterAvailable) {
|
|
2536
|
-
return parameter.webgl2;
|
|
2537
|
-
}
|
|
2661
|
+
resizeAttachments(width, height) {
|
|
2662
|
+
if (this.handle === null) {
|
|
2663
|
+
this.width = this.gl.drawingBufferWidth;
|
|
2664
|
+
this.height = this.gl.drawingBufferHeight;
|
|
2665
|
+
return this;
|
|
2538
2666
|
}
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
// Many resources support a getParameter call -
|
|
2542
|
-
// getParameters will get all parameters - slow but useful for debugging
|
|
2543
|
-
// eslint-disable-next-line complexity
|
|
2544
|
-
getParameters(options = {}) {
|
|
2545
|
-
const { parameters, keys } = options;
|
|
2546
|
-
const PARAMETERS = this.constructor.PARAMETERS || {};
|
|
2547
|
-
const values = {};
|
|
2548
|
-
const parameterKeys = parameters || Object.keys(PARAMETERS);
|
|
2549
|
-
for (const pname of parameterKeys) {
|
|
2550
|
-
const parameter = PARAMETERS[pname];
|
|
2551
|
-
const parameterAvailable = parameter && (!("extension" in parameter) || this.gl.getExtension(parameter.extension));
|
|
2552
|
-
if (parameterAvailable) {
|
|
2553
|
-
const key = keys ? this.device.getGLKey(pname) : pname;
|
|
2554
|
-
values[key] = this.getParameter(pname, options);
|
|
2555
|
-
if (keys && parameter.type === "GLenum") {
|
|
2556
|
-
values[key] = this.device.getGLKey(values[key]);
|
|
2557
|
-
}
|
|
2558
|
-
}
|
|
2667
|
+
if (width === void 0) {
|
|
2668
|
+
width = this.gl.drawingBufferWidth;
|
|
2559
2669
|
}
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
*/
|
|
2571
|
-
setParameter(pname, value) {
|
|
2572
|
-
pname = getKeyValue(this.gl, pname);
|
|
2573
|
-
(0, import_core8.assert)(pname);
|
|
2574
|
-
const parameters = this.constructor.PARAMETERS || {};
|
|
2575
|
-
const parameter = parameters[pname];
|
|
2576
|
-
if (parameter) {
|
|
2577
|
-
const parameterAvailable = !("extension" in parameter) || this.gl.getExtension(parameter.extension);
|
|
2578
|
-
if (!parameterAvailable) {
|
|
2579
|
-
throw new Error("Parameter not available on this platform");
|
|
2580
|
-
}
|
|
2581
|
-
if (parameter.type === "GLenum") {
|
|
2582
|
-
value = getKeyValue(value);
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
|
-
this._setParameter(pname, value);
|
|
2586
|
-
return this;
|
|
2587
|
-
}
|
|
2588
|
-
/*
|
|
2589
|
-
* Batch update resource parameters
|
|
2590
|
-
* Assumes the subclass supports a setParameter call
|
|
2591
|
-
*/
|
|
2592
|
-
setParameters(parameters) {
|
|
2593
|
-
for (const pname in parameters) {
|
|
2594
|
-
this.setParameter(pname, parameters[pname]);
|
|
2595
|
-
}
|
|
2596
|
-
return this;
|
|
2597
|
-
}
|
|
2598
|
-
// Install stubs for removed methods
|
|
2599
|
-
stubRemovedMethods(className, version, methodNames) {
|
|
2600
|
-
return (0, import_core8.stubRemovedMethods)(this, className, version, methodNames);
|
|
2601
|
-
}
|
|
2602
|
-
// PUBLIC VIRTUAL METHODS
|
|
2603
|
-
initialize(props) {
|
|
2604
|
-
}
|
|
2605
|
-
// PROTECTED METHODS - These must be overridden by subclass
|
|
2606
|
-
_createHandle() {
|
|
2607
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
2608
|
-
}
|
|
2609
|
-
_deleteHandle() {
|
|
2610
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
2611
|
-
}
|
|
2612
|
-
_bindHandle(handle) {
|
|
2613
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
2614
|
-
}
|
|
2615
|
-
_getOptsFromHandle() {
|
|
2616
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
2617
|
-
}
|
|
2618
|
-
_getParameter(pname, props) {
|
|
2619
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
2620
|
-
}
|
|
2621
|
-
_setParameter(pname, value) {
|
|
2622
|
-
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
2623
|
-
}
|
|
2624
|
-
};
|
|
2625
|
-
|
|
2626
|
-
// dist/adapter/objects/webgl-renderbuffer.js
|
|
2627
|
-
var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
2628
|
-
get [Symbol.toStringTag]() {
|
|
2629
|
-
return "Renderbuffer";
|
|
2630
|
-
}
|
|
2631
|
-
get width() {
|
|
2632
|
-
return this.props.width;
|
|
2633
|
-
}
|
|
2634
|
-
get height() {
|
|
2635
|
-
return this.props.height;
|
|
2636
|
-
}
|
|
2637
|
-
get format() {
|
|
2638
|
-
return this.props.format;
|
|
2639
|
-
}
|
|
2640
|
-
get samples() {
|
|
2641
|
-
return this.props.samples;
|
|
2642
|
-
}
|
|
2643
|
-
get attachment() {
|
|
2644
|
-
return;
|
|
2645
|
-
}
|
|
2646
|
-
/** WebGL format constant */
|
|
2647
|
-
glFormat;
|
|
2648
|
-
static isTextureFormatSupported(device, format) {
|
|
2649
|
-
return isRenderbufferFormatSupported(device.gl, format);
|
|
2650
|
-
}
|
|
2651
|
-
constructor(device, props) {
|
|
2652
|
-
if (typeof props.format === "number") {
|
|
2653
|
-
throw new Error("Renderbuffer");
|
|
2654
|
-
}
|
|
2655
|
-
super(device, props, _WEBGLRenderbuffer.defaultProps);
|
|
2656
|
-
this.glFormat = convertTextureFormatToGL(this.props.format);
|
|
2657
|
-
this._initialize(this.props);
|
|
2658
|
-
}
|
|
2659
|
-
resize(size) {
|
|
2660
|
-
if (size.width !== this.width || size.height !== this.height) {
|
|
2661
|
-
Object.assign(this.props, { ...size, format: this.format, samples: this.samples });
|
|
2662
|
-
this._initialize(this.props);
|
|
2663
|
-
}
|
|
2664
|
-
}
|
|
2665
|
-
// PRIVATE METHODS
|
|
2666
|
-
/** Creates and initializes a renderbuffer object's data store */
|
|
2667
|
-
_initialize(props) {
|
|
2668
|
-
const { format, width, height, samples } = props;
|
|
2669
|
-
(0, import_core9.assert)(format, "Needs format");
|
|
2670
|
-
this.trackDeallocatedMemory();
|
|
2671
|
-
this.gl.bindRenderbuffer(import_constants11.GL.RENDERBUFFER, this.handle);
|
|
2672
|
-
if (samples !== 0) {
|
|
2673
|
-
this.gl.renderbufferStorageMultisample(import_constants11.GL.RENDERBUFFER, samples, this.glFormat, width, height);
|
|
2674
|
-
} else {
|
|
2675
|
-
this.gl.renderbufferStorage(import_constants11.GL.RENDERBUFFER, this.glFormat, width, height);
|
|
2676
|
-
}
|
|
2677
|
-
this.gl.bindRenderbuffer(import_constants11.GL.RENDERBUFFER, null);
|
|
2678
|
-
this.trackAllocatedMemory(width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat));
|
|
2679
|
-
}
|
|
2680
|
-
// RESOURCE IMPLEMENTATION
|
|
2681
|
-
_createHandle() {
|
|
2682
|
-
return this.gl.createRenderbuffer();
|
|
2683
|
-
}
|
|
2684
|
-
_deleteHandle() {
|
|
2685
|
-
this.gl.deleteRenderbuffer(this.handle);
|
|
2686
|
-
this.trackDeallocatedMemory();
|
|
2687
|
-
}
|
|
2688
|
-
_bindHandle(handle) {
|
|
2689
|
-
this.gl.bindRenderbuffer(import_constants11.GL.RENDERBUFFER, handle);
|
|
2690
|
-
}
|
|
2691
|
-
};
|
|
2692
|
-
var WEBGLRenderbuffer = _WEBGLRenderbuffer;
|
|
2693
|
-
__publicField(WEBGLRenderbuffer, "defaultProps", {
|
|
2694
|
-
id: void 0,
|
|
2695
|
-
handle: void 0,
|
|
2696
|
-
userData: void 0,
|
|
2697
|
-
format: void 0,
|
|
2698
|
-
// 'depth16unorm'
|
|
2699
|
-
width: 1,
|
|
2700
|
-
height: 1,
|
|
2701
|
-
samples: 0
|
|
2702
|
-
});
|
|
2703
|
-
|
|
2704
|
-
// dist/adapter/resources/webgl-framebuffer.js
|
|
2705
|
-
var WEBGLFramebuffer = class extends import_core10.Framebuffer {
|
|
2706
|
-
device;
|
|
2707
|
-
gl;
|
|
2708
|
-
handle;
|
|
2709
|
-
get texture() {
|
|
2710
|
-
return this.colorAttachments[0];
|
|
2711
|
-
}
|
|
2712
|
-
constructor(device, props) {
|
|
2713
|
-
super(device, props);
|
|
2714
|
-
const isDefaultFramebuffer = props.handle === null;
|
|
2715
|
-
this.device = device;
|
|
2716
|
-
this.gl = device.gl;
|
|
2717
|
-
this.handle = this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();
|
|
2718
|
-
if (!isDefaultFramebuffer) {
|
|
2719
|
-
device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
|
|
2720
|
-
this.autoCreateAttachmentTextures();
|
|
2721
|
-
this.gl.bindFramebuffer(import_constants12.GL.FRAMEBUFFER, this.handle);
|
|
2722
|
-
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
2723
|
-
const attachment = this.colorAttachments[i];
|
|
2724
|
-
const attachmentPoint = import_constants12.GL.COLOR_ATTACHMENT0 + i;
|
|
2725
|
-
if (attachment) {
|
|
2726
|
-
this._attachOne(attachmentPoint, attachment);
|
|
2727
|
-
}
|
|
2728
|
-
}
|
|
2729
|
-
if (this.depthStencilAttachment) {
|
|
2730
|
-
this._attachOne(getDepthStencilAttachmentWebGL(this.depthStencilAttachment.format), this.depthStencilAttachment);
|
|
2731
|
-
}
|
|
2732
|
-
this.gl.bindFramebuffer(import_constants12.GL.FRAMEBUFFER, null);
|
|
2733
|
-
}
|
|
2734
|
-
if (props.check !== false) {
|
|
2735
|
-
this._checkStatus();
|
|
2736
|
-
}
|
|
2737
|
-
}
|
|
2738
|
-
/** destroys any auto created resources etc. */
|
|
2739
|
-
destroy() {
|
|
2740
|
-
super.destroy();
|
|
2741
|
-
if (!this.destroyed && this.handle !== null) {
|
|
2742
|
-
this.gl.deleteFramebuffer(this.handle);
|
|
2743
|
-
}
|
|
2744
|
-
}
|
|
2745
|
-
// PRIVATE
|
|
2746
|
-
/** Check the status */
|
|
2747
|
-
_checkStatus() {
|
|
2748
|
-
const { gl } = this;
|
|
2749
|
-
const prevHandle = gl.bindFramebuffer(import_constants12.GL.FRAMEBUFFER, this.handle);
|
|
2750
|
-
const status = gl.checkFramebufferStatus(import_constants12.GL.FRAMEBUFFER);
|
|
2751
|
-
gl.bindFramebuffer(import_constants12.GL.FRAMEBUFFER, prevHandle || null);
|
|
2752
|
-
if (status !== gl.FRAMEBUFFER_COMPLETE) {
|
|
2753
|
-
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
2754
|
-
}
|
|
2755
|
-
}
|
|
2756
|
-
/** In WebGL we must use renderbuffers for depth/stencil attachments (unless we have extensions) */
|
|
2757
|
-
createDepthStencilTexture(format) {
|
|
2758
|
-
return new WEBGLRenderbuffer(this.device, {
|
|
2759
|
-
id: `${this.id}-depth-stencil`,
|
|
2760
|
-
// TODO misleading if not depth and stencil?
|
|
2761
|
-
format,
|
|
2762
|
-
// dataFormat: GL.DEPTH_STENCIL,
|
|
2763
|
-
// type: GL.UNSIGNED_INT_24_8,
|
|
2764
|
-
width: this.width,
|
|
2765
|
-
height: this.height
|
|
2766
|
-
});
|
|
2767
|
-
}
|
|
2768
|
-
/**
|
|
2769
|
-
* Attachment resize is expected to be a noop if size is same
|
|
2770
|
-
*/
|
|
2771
|
-
resizeAttachments(width, height) {
|
|
2772
|
-
if (this.handle === null) {
|
|
2773
|
-
this.width = this.gl.drawingBufferWidth;
|
|
2774
|
-
this.height = this.gl.drawingBufferHeight;
|
|
2775
|
-
return this;
|
|
2776
|
-
}
|
|
2777
|
-
if (width === void 0) {
|
|
2778
|
-
width = this.gl.drawingBufferWidth;
|
|
2779
|
-
}
|
|
2780
|
-
if (height === void 0) {
|
|
2781
|
-
height = this.gl.drawingBufferHeight;
|
|
2782
|
-
}
|
|
2783
|
-
for (const colorAttachment of this.colorAttachments) {
|
|
2784
|
-
colorAttachment.resize({ width, height });
|
|
2785
|
-
}
|
|
2786
|
-
if (this.depthStencilAttachment) {
|
|
2787
|
-
this.depthStencilAttachment.resize({ width, height });
|
|
2788
|
-
}
|
|
2789
|
-
return this;
|
|
2670
|
+
if (height === void 0) {
|
|
2671
|
+
height = this.gl.drawingBufferHeight;
|
|
2672
|
+
}
|
|
2673
|
+
for (const colorAttachment of this.colorAttachments) {
|
|
2674
|
+
colorAttachment.texture.resize({ width, height });
|
|
2675
|
+
}
|
|
2676
|
+
if (this.depthStencilAttachment) {
|
|
2677
|
+
this.depthStencilAttachment.texture.resize({ width, height });
|
|
2678
|
+
}
|
|
2679
|
+
return this;
|
|
2790
2680
|
}
|
|
2791
2681
|
/** Attach one attachment */
|
|
2792
2682
|
_attachOne(attachmentPoint, attachment) {
|
|
2793
|
-
if (attachment
|
|
2794
|
-
this._attachWEBGLRenderbuffer(attachmentPoint, attachment);
|
|
2795
|
-
return attachment;
|
|
2796
|
-
} else if (Array.isArray(attachment)) {
|
|
2683
|
+
if (Array.isArray(attachment)) {
|
|
2797
2684
|
const [texture, layer = 0, level = 0] = attachment;
|
|
2798
2685
|
this._attachTexture(attachmentPoint, texture, layer, level);
|
|
2799
2686
|
return texture;
|
|
2800
|
-
}
|
|
2687
|
+
}
|
|
2688
|
+
if (attachment instanceof WEBGLTexture) {
|
|
2801
2689
|
this._attachTexture(attachmentPoint, attachment, 0, 0);
|
|
2802
2690
|
return attachment;
|
|
2803
2691
|
}
|
|
2692
|
+
if (attachment instanceof WEBGLTextureView) {
|
|
2693
|
+
const textureView = attachment;
|
|
2694
|
+
this._attachTexture(attachmentPoint, textureView.texture, textureView.props.baseMipLevel, textureView.props.baseArrayLayer);
|
|
2695
|
+
return attachment.texture;
|
|
2696
|
+
}
|
|
2804
2697
|
throw new Error("attach");
|
|
2805
2698
|
}
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2699
|
+
// TODO - we do not seem to need render buffers in WebGL 2
|
|
2700
|
+
// protected _attachWEBGLRenderbuffer(attachment: GL, renderbuffer: WEBGLRenderbuffer): void {
|
|
2701
|
+
// this.gl.framebufferRenderbuffer(
|
|
2702
|
+
// GL.FRAMEBUFFER,
|
|
2703
|
+
// attachment,
|
|
2704
|
+
// GL.RENDERBUFFER,
|
|
2705
|
+
// renderbuffer.handle
|
|
2706
|
+
// );
|
|
2707
|
+
// }
|
|
2809
2708
|
/**
|
|
2810
2709
|
* @param attachment
|
|
2811
2710
|
* @param texture
|
|
@@ -2816,16 +2715,16 @@ var WEBGLFramebuffer = class extends import_core10.Framebuffer {
|
|
|
2816
2715
|
const { gl } = this.device;
|
|
2817
2716
|
gl.bindTexture(texture.target, texture.handle);
|
|
2818
2717
|
switch (texture.target) {
|
|
2819
|
-
case
|
|
2820
|
-
case
|
|
2821
|
-
gl.framebufferTextureLayer(
|
|
2718
|
+
case 35866:
|
|
2719
|
+
case 32879:
|
|
2720
|
+
gl.framebufferTextureLayer(36160, attachment, texture.target, level, layer);
|
|
2822
2721
|
break;
|
|
2823
|
-
case
|
|
2722
|
+
case 34067:
|
|
2824
2723
|
const face = mapIndexToCubeMapFace(layer);
|
|
2825
|
-
gl.framebufferTexture2D(
|
|
2724
|
+
gl.framebufferTexture2D(36160, attachment, face, texture.handle, level);
|
|
2826
2725
|
break;
|
|
2827
|
-
case
|
|
2828
|
-
gl.framebufferTexture2D(
|
|
2726
|
+
case 3553:
|
|
2727
|
+
gl.framebufferTexture2D(36160, attachment, 3553, texture.handle, level);
|
|
2829
2728
|
break;
|
|
2830
2729
|
default:
|
|
2831
2730
|
(0, import_core10.assert)(false, "Illegal texture type");
|
|
@@ -2834,21 +2733,21 @@ var WEBGLFramebuffer = class extends import_core10.Framebuffer {
|
|
|
2834
2733
|
}
|
|
2835
2734
|
};
|
|
2836
2735
|
function mapIndexToCubeMapFace(layer) {
|
|
2837
|
-
return layer <
|
|
2736
|
+
return layer < 34069 ? layer + 34069 : layer;
|
|
2838
2737
|
}
|
|
2839
2738
|
function _getFrameBufferStatus(status) {
|
|
2840
2739
|
switch (status) {
|
|
2841
|
-
case
|
|
2740
|
+
case 36053:
|
|
2842
2741
|
return "success";
|
|
2843
|
-
case
|
|
2742
|
+
case 36054:
|
|
2844
2743
|
return "Mismatched attachments";
|
|
2845
|
-
case
|
|
2744
|
+
case 36055:
|
|
2846
2745
|
return "No attachments";
|
|
2847
|
-
case
|
|
2746
|
+
case 36057:
|
|
2848
2747
|
return "Height/width mismatch";
|
|
2849
|
-
case
|
|
2748
|
+
case 36061:
|
|
2850
2749
|
return "Unsupported or split attachments";
|
|
2851
|
-
case
|
|
2750
|
+
case 36182:
|
|
2852
2751
|
return "Samples mismatch";
|
|
2853
2752
|
default:
|
|
2854
2753
|
return `${status}`;
|
|
@@ -2965,10 +2864,10 @@ function initializeSpectorJS(props) {
|
|
|
2965
2864
|
|
|
2966
2865
|
// dist/context/debug/webgl-developer-tools.js
|
|
2967
2866
|
var import_core13 = require("@luma.gl/core");
|
|
2968
|
-
var
|
|
2867
|
+
var import_constants12 = require("@luma.gl/constants");
|
|
2969
2868
|
var import_env = require("@probe.gl/env");
|
|
2970
2869
|
var WEBGL_DEBUG_CDN_URL = "https://unpkg.com/webgl-debug@2.0.1/index.js";
|
|
2971
|
-
function
|
|
2870
|
+
function getWebGLContextData(gl) {
|
|
2972
2871
|
gl.luma = gl.luma || {};
|
|
2973
2872
|
return gl.luma;
|
|
2974
2873
|
}
|
|
@@ -2986,7 +2885,7 @@ function makeDebugContext(gl, props = {}) {
|
|
|
2986
2885
|
return props.debug ? getDebugContext(gl, props) : getRealContext(gl);
|
|
2987
2886
|
}
|
|
2988
2887
|
function getRealContext(gl) {
|
|
2989
|
-
const data =
|
|
2888
|
+
const data = getWebGLContextData(gl);
|
|
2990
2889
|
return data.realContext ? data.realContext : gl;
|
|
2991
2890
|
}
|
|
2992
2891
|
function getDebugContext(gl, props) {
|
|
@@ -2994,15 +2893,15 @@ function getDebugContext(gl, props) {
|
|
|
2994
2893
|
import_core13.log.warn("webgl-debug not loaded")();
|
|
2995
2894
|
return gl;
|
|
2996
2895
|
}
|
|
2997
|
-
const data =
|
|
2896
|
+
const data = getWebGLContextData(gl);
|
|
2998
2897
|
if (data.debugContext) {
|
|
2999
2898
|
return data.debugContext;
|
|
3000
2899
|
}
|
|
3001
|
-
globalThis.WebGLDebugUtils.init({ ...
|
|
2900
|
+
globalThis.WebGLDebugUtils.init({ ...import_constants12.GL, ...gl });
|
|
3002
2901
|
const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(gl, onGLError.bind(null, props), onValidateGLFunc.bind(null, props));
|
|
3003
|
-
for (const key in
|
|
3004
|
-
if (!(key in glDebug) && typeof
|
|
3005
|
-
glDebug[key] =
|
|
2902
|
+
for (const key in import_constants12.GL) {
|
|
2903
|
+
if (!(key in glDebug) && typeof import_constants12.GL[key] === "number") {
|
|
2904
|
+
glDebug[key] = import_constants12.GL[key];
|
|
3006
2905
|
}
|
|
3007
2906
|
}
|
|
3008
2907
|
class WebGLDebugContext {
|
|
@@ -3060,7 +2959,7 @@ function onValidateGLFunc(props, functionName, functionArgs) {
|
|
|
3060
2959
|
|
|
3061
2960
|
// dist/adapter/resources/webgl-shader.js
|
|
3062
2961
|
var import_core14 = require("@luma.gl/core");
|
|
3063
|
-
var
|
|
2962
|
+
var import_constants13 = require("@luma.gl/constants");
|
|
3064
2963
|
|
|
3065
2964
|
// dist/adapter/helpers/parse-shader-compiler-log.js
|
|
3066
2965
|
function parseShaderCompilerLog(errLog) {
|
|
@@ -3115,10 +3014,10 @@ var WEBGLShader = class extends import_core14.Shader {
|
|
|
3115
3014
|
this.device = device;
|
|
3116
3015
|
switch (this.props.stage) {
|
|
3117
3016
|
case "vertex":
|
|
3118
|
-
this.handle = this.props.handle || this.device.gl.createShader(
|
|
3017
|
+
this.handle = this.props.handle || this.device.gl.createShader(35633);
|
|
3119
3018
|
break;
|
|
3120
3019
|
case "fragment":
|
|
3121
|
-
this.handle = this.props.handle || this.device.gl.createShader(
|
|
3020
|
+
this.handle = this.props.handle || this.device.gl.createShader(35632);
|
|
3122
3021
|
break;
|
|
3123
3022
|
default:
|
|
3124
3023
|
throw new Error(this.props.stage);
|
|
@@ -3140,6 +3039,11 @@ var WEBGLShader = class extends import_core14.Shader {
|
|
|
3140
3039
|
const log9 = this.device.gl.getShaderInfoLog(this.handle);
|
|
3141
3040
|
return parseShaderCompilerLog(log9);
|
|
3142
3041
|
}
|
|
3042
|
+
getTranslatedSource() {
|
|
3043
|
+
const extensions = this.device.getExtension("WEBGL_debug_shaders");
|
|
3044
|
+
const ext = extensions.WEBGL_debug_shaders;
|
|
3045
|
+
return ext == null ? void 0 : ext.getTranslatedShaderSource(this.handle);
|
|
3046
|
+
}
|
|
3143
3047
|
// PRIVATE METHODS
|
|
3144
3048
|
/** Compile a shader and get compilation status */
|
|
3145
3049
|
async _compile(source) {
|
|
@@ -3153,7 +3057,7 @@ ${source2}`;
|
|
|
3153
3057
|
this.compilationStatus = "pending";
|
|
3154
3058
|
return;
|
|
3155
3059
|
}
|
|
3156
|
-
if (!this.device.features.has("
|
|
3060
|
+
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
3157
3061
|
this._getCompilationStatus();
|
|
3158
3062
|
if (this.compilationStatus === "error") {
|
|
3159
3063
|
throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);
|
|
@@ -3171,13 +3075,13 @@ ${source2}`;
|
|
|
3171
3075
|
async _waitForCompilationComplete() {
|
|
3172
3076
|
const waitMs = async (ms) => await new Promise((resolve) => setTimeout(resolve, ms));
|
|
3173
3077
|
const DELAY_MS = 10;
|
|
3174
|
-
if (!this.device.features.has("
|
|
3078
|
+
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
3175
3079
|
await waitMs(DELAY_MS);
|
|
3176
3080
|
return;
|
|
3177
3081
|
}
|
|
3178
3082
|
const { gl } = this.device;
|
|
3179
3083
|
for (; ; ) {
|
|
3180
|
-
const complete = gl.getShaderParameter(this.handle,
|
|
3084
|
+
const complete = gl.getShaderParameter(this.handle, 37297);
|
|
3181
3085
|
if (complete) {
|
|
3182
3086
|
return;
|
|
3183
3087
|
}
|
|
@@ -3188,15 +3092,15 @@ ${source2}`;
|
|
|
3188
3092
|
* Get the shader compilation status
|
|
3189
3093
|
* TODO - Load log even when no error reported, to catch warnings?
|
|
3190
3094
|
* https://gamedev.stackexchange.com/questions/30429/how-to-detect-glsl-warnings
|
|
3191
|
-
|
|
3095
|
+
*/
|
|
3192
3096
|
_getCompilationStatus() {
|
|
3193
|
-
this.compilationStatus = this.device.gl.getShaderParameter(this.handle,
|
|
3097
|
+
this.compilationStatus = this.device.gl.getShaderParameter(this.handle, 35713) ? "success" : "error";
|
|
3194
3098
|
}
|
|
3195
3099
|
};
|
|
3196
3100
|
|
|
3197
3101
|
// dist/adapter/resources/webgl-render-pass.js
|
|
3198
3102
|
var import_core15 = require("@luma.gl/core");
|
|
3199
|
-
var
|
|
3103
|
+
var import_constants14 = require("@luma.gl/constants");
|
|
3200
3104
|
var GL_DEPTH_BUFFER_BIT = 256;
|
|
3201
3105
|
var GL_STENCIL_BUFFER_BIT = 1024;
|
|
3202
3106
|
var GL_COLOR_BUFFER_BIT = 16384;
|
|
@@ -3215,7 +3119,7 @@ var WEBGLRenderPass = class extends import_core15.RenderPass {
|
|
|
3215
3119
|
end() {
|
|
3216
3120
|
popContextState(this.device.gl);
|
|
3217
3121
|
if (this.props.framebuffer) {
|
|
3218
|
-
setGLParameters(this.device, { framebuffer: null });
|
|
3122
|
+
setGLParameters(this.device.gl, { framebuffer: null });
|
|
3219
3123
|
}
|
|
3220
3124
|
}
|
|
3221
3125
|
pushDebugGroup(groupLabel) {
|
|
@@ -3224,7 +3128,6 @@ var WEBGLRenderPass = class extends import_core15.RenderPass {
|
|
|
3224
3128
|
}
|
|
3225
3129
|
insertDebugMarker(markerLabel) {
|
|
3226
3130
|
}
|
|
3227
|
-
// writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
|
|
3228
3131
|
// beginOcclusionQuery(queryIndex: number): void;
|
|
3229
3132
|
// endOcclusionQuery(): void;
|
|
3230
3133
|
// executeBundles(bundles: Iterable<GPURenderBundle>): void;
|
|
@@ -3240,7 +3143,7 @@ var WEBGLRenderPass = class extends import_core15.RenderPass {
|
|
|
3240
3143
|
glParameters.depthMask = !this.props.depthReadOnly;
|
|
3241
3144
|
}
|
|
3242
3145
|
glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;
|
|
3243
|
-
glParameters[
|
|
3146
|
+
glParameters[35977] = this.props.discard;
|
|
3244
3147
|
if (parameters.viewport) {
|
|
3245
3148
|
if (parameters.viewport.length >= 6) {
|
|
3246
3149
|
glParameters.viewport = parameters.viewport.slice(0, 4);
|
|
@@ -3258,12 +3161,20 @@ var WEBGLRenderPass = class extends import_core15.RenderPass {
|
|
|
3258
3161
|
}
|
|
3259
3162
|
if (parameters.stencilReference) {
|
|
3260
3163
|
console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL");
|
|
3261
|
-
parameters[
|
|
3164
|
+
parameters[2967] = parameters.stencilReference;
|
|
3262
3165
|
}
|
|
3263
3166
|
this.glParameters = glParameters;
|
|
3264
|
-
setGLParameters(this.device, glParameters);
|
|
3167
|
+
setGLParameters(this.device.gl, glParameters);
|
|
3168
|
+
}
|
|
3169
|
+
beginOcclusionQuery(queryIndex) {
|
|
3170
|
+
const webglQuerySet = this.props.occlusionQuerySet;
|
|
3171
|
+
webglQuerySet == null ? void 0 : webglQuerySet.beginOcclusionQuery();
|
|
3265
3172
|
}
|
|
3266
|
-
|
|
3173
|
+
endOcclusionQuery() {
|
|
3174
|
+
const webglQuerySet = this.props.occlusionQuerySet;
|
|
3175
|
+
webglQuerySet == null ? void 0 : webglQuerySet.endOcclusionQuery();
|
|
3176
|
+
}
|
|
3177
|
+
// PRIVATE
|
|
3267
3178
|
/**
|
|
3268
3179
|
* Optionally clears depth, color and stencil buffers based on parameters
|
|
3269
3180
|
*/
|
|
@@ -3283,7 +3194,7 @@ var WEBGLRenderPass = class extends import_core15.RenderPass {
|
|
|
3283
3194
|
glParameters.clearStencil = this.props.clearStencil;
|
|
3284
3195
|
}
|
|
3285
3196
|
if (clearMask !== 0) {
|
|
3286
|
-
withGLParameters(this.device, glParameters, () => {
|
|
3197
|
+
withGLParameters(this.device.gl, glParameters, () => {
|
|
3287
3198
|
this.device.gl.clear(clearMask);
|
|
3288
3199
|
});
|
|
3289
3200
|
}
|
|
@@ -3312,37 +3223,37 @@ var WEBGLRenderPass = class extends import_core15.RenderPass {
|
|
|
3312
3223
|
// dist/adapter/resources/webgl-render-pipeline.js
|
|
3313
3224
|
var import_core17 = require("@luma.gl/core");
|
|
3314
3225
|
var import_core18 = require("@luma.gl/core");
|
|
3315
|
-
var
|
|
3226
|
+
var import_constants21 = require("@luma.gl/constants");
|
|
3316
3227
|
|
|
3317
3228
|
// dist/adapter/helpers/get-shader-layout.js
|
|
3318
|
-
var
|
|
3229
|
+
var import_constants18 = require("@luma.gl/constants");
|
|
3319
3230
|
|
|
3320
3231
|
// dist/classic/accessor.js
|
|
3321
3232
|
var import_core16 = require("@luma.gl/core");
|
|
3322
|
-
var
|
|
3233
|
+
var import_constants16 = require("@luma.gl/constants");
|
|
3323
3234
|
|
|
3324
3235
|
// dist/classic/typed-array-utils.js
|
|
3325
|
-
var
|
|
3236
|
+
var import_constants15 = require("@luma.gl/constants");
|
|
3326
3237
|
var ERR_TYPE_DEDUCTION = "Failed to deduce GL constant from typed array";
|
|
3327
3238
|
function getGLTypeFromTypedArray(arrayOrType) {
|
|
3328
3239
|
const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
3329
3240
|
switch (type) {
|
|
3330
3241
|
case Float32Array:
|
|
3331
|
-
return
|
|
3242
|
+
return 5126;
|
|
3332
3243
|
case Uint16Array:
|
|
3333
|
-
return
|
|
3244
|
+
return 5123;
|
|
3334
3245
|
case Uint32Array:
|
|
3335
|
-
return
|
|
3246
|
+
return 5125;
|
|
3336
3247
|
case Uint8Array:
|
|
3337
|
-
return
|
|
3248
|
+
return 5121;
|
|
3338
3249
|
case Uint8ClampedArray:
|
|
3339
|
-
return
|
|
3250
|
+
return 5121;
|
|
3340
3251
|
case Int8Array:
|
|
3341
|
-
return
|
|
3252
|
+
return 5120;
|
|
3342
3253
|
case Int16Array:
|
|
3343
|
-
return
|
|
3254
|
+
return 5122;
|
|
3344
3255
|
case Int32Array:
|
|
3345
|
-
return
|
|
3256
|
+
return 5124;
|
|
3346
3257
|
default:
|
|
3347
3258
|
throw new Error(ERR_TYPE_DEDUCTION);
|
|
3348
3259
|
}
|
|
@@ -3350,22 +3261,22 @@ function getGLTypeFromTypedArray(arrayOrType) {
|
|
|
3350
3261
|
function getTypedArrayFromGLType(glType, options) {
|
|
3351
3262
|
const { clamped = true } = options || {};
|
|
3352
3263
|
switch (glType) {
|
|
3353
|
-
case
|
|
3264
|
+
case 5126:
|
|
3354
3265
|
return Float32Array;
|
|
3355
|
-
case
|
|
3356
|
-
case
|
|
3357
|
-
case
|
|
3358
|
-
case
|
|
3266
|
+
case 5123:
|
|
3267
|
+
case 33635:
|
|
3268
|
+
case 32819:
|
|
3269
|
+
case 32820:
|
|
3359
3270
|
return Uint16Array;
|
|
3360
|
-
case
|
|
3271
|
+
case 5125:
|
|
3361
3272
|
return Uint32Array;
|
|
3362
|
-
case
|
|
3273
|
+
case 5121:
|
|
3363
3274
|
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
3364
|
-
case
|
|
3275
|
+
case 5120:
|
|
3365
3276
|
return Int8Array;
|
|
3366
|
-
case
|
|
3277
|
+
case 5122:
|
|
3367
3278
|
return Int16Array;
|
|
3368
|
-
case
|
|
3279
|
+
case 5124:
|
|
3369
3280
|
return Int32Array;
|
|
3370
3281
|
default:
|
|
3371
3282
|
throw new Error("Failed to deduce typed array type from GL constant");
|
|
@@ -3376,7 +3287,7 @@ function getTypedArrayFromGLType(glType, options) {
|
|
|
3376
3287
|
var DEFAULT_ACCESSOR_VALUES = {
|
|
3377
3288
|
offset: 0,
|
|
3378
3289
|
stride: 0,
|
|
3379
|
-
type:
|
|
3290
|
+
type: 5126,
|
|
3380
3291
|
size: 1,
|
|
3381
3292
|
divisor: 0,
|
|
3382
3293
|
normalized: false,
|
|
@@ -3399,12 +3310,12 @@ var Accessor = class {
|
|
|
3399
3310
|
buffer;
|
|
3400
3311
|
index;
|
|
3401
3312
|
static getBytesPerElement(accessor) {
|
|
3402
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type ||
|
|
3313
|
+
const ArrayType = getTypedArrayFromGLType(accessor.type || 5126);
|
|
3403
3314
|
return ArrayType.BYTES_PER_ELEMENT;
|
|
3404
3315
|
}
|
|
3405
3316
|
static getBytesPerVertex(accessor) {
|
|
3406
3317
|
(0, import_core16.assert)(accessor.size);
|
|
3407
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type ||
|
|
3318
|
+
const ArrayType = getTypedArrayFromGLType(accessor.type || 5126);
|
|
3408
3319
|
return ArrayType.BYTES_PER_ELEMENT * accessor.size;
|
|
3409
3320
|
}
|
|
3410
3321
|
// Combines (merges) a list of accessors. On top of default values
|
|
@@ -3435,7 +3346,7 @@ var Accessor = class {
|
|
|
3435
3346
|
props = (0, import_core16.checkProps)("Accessor", props, PROP_CHECKS);
|
|
3436
3347
|
if (props.type !== void 0) {
|
|
3437
3348
|
this.type = props.type;
|
|
3438
|
-
if (props.type ===
|
|
3349
|
+
if (props.type === 5124 || props.type === 5125) {
|
|
3439
3350
|
this.integer = true;
|
|
3440
3351
|
}
|
|
3441
3352
|
}
|
|
@@ -3499,62 +3410,62 @@ var Accessor = class {
|
|
|
3499
3410
|
};
|
|
3500
3411
|
|
|
3501
3412
|
// dist/adapter/helpers/decode-webgl-types.js
|
|
3502
|
-
var
|
|
3413
|
+
var import_constants17 = require("@luma.gl/constants");
|
|
3503
3414
|
function isSamplerUniform(type) {
|
|
3504
3415
|
return SAMPLER_TYPES.includes(type);
|
|
3505
3416
|
}
|
|
3506
3417
|
var SAMPLER_TYPES = [
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3418
|
+
35678,
|
|
3419
|
+
35680,
|
|
3420
|
+
35679,
|
|
3421
|
+
35682,
|
|
3422
|
+
36289,
|
|
3423
|
+
36292,
|
|
3424
|
+
36293,
|
|
3425
|
+
36298,
|
|
3426
|
+
36299,
|
|
3427
|
+
36300,
|
|
3428
|
+
36303,
|
|
3429
|
+
36306,
|
|
3430
|
+
36307,
|
|
3431
|
+
36308,
|
|
3432
|
+
36311
|
|
3522
3433
|
];
|
|
3523
3434
|
var COMPOSITE_GL_TYPES = {
|
|
3524
|
-
[
|
|
3525
|
-
[
|
|
3526
|
-
[
|
|
3527
|
-
[
|
|
3528
|
-
[
|
|
3529
|
-
[
|
|
3530
|
-
[
|
|
3531
|
-
[
|
|
3532
|
-
[
|
|
3533
|
-
[
|
|
3534
|
-
[
|
|
3535
|
-
[
|
|
3536
|
-
[
|
|
3537
|
-
[
|
|
3538
|
-
[
|
|
3539
|
-
[
|
|
3435
|
+
[5126]: [5126, 1, "float", "f32", "float32"],
|
|
3436
|
+
[35664]: [5126, 2, "vec2", "vec2<f32>", "float32x2"],
|
|
3437
|
+
[35665]: [5126, 3, "vec3", "vec3<f32>", "float32x3"],
|
|
3438
|
+
[35666]: [5126, 4, "vec4", "vec4<f32>", "float32x4"],
|
|
3439
|
+
[5124]: [5124, 1, "int", "i32", "sint32"],
|
|
3440
|
+
[35667]: [5124, 2, "ivec2", "vec2<i32>", "sint32x2"],
|
|
3441
|
+
[35668]: [5124, 3, "ivec3", "vec3<i32>", "sint32x3"],
|
|
3442
|
+
[35669]: [5124, 4, "ivec4", "vec4<i32>", "sint32x4"],
|
|
3443
|
+
[5125]: [5125, 1, "uint", "u32", "uint32"],
|
|
3444
|
+
[36294]: [5125, 2, "uvec2", "vec2<u32>", "uint32x2"],
|
|
3445
|
+
[36295]: [5125, 3, "uvec3", "vec3<u32>", "uint32x3"],
|
|
3446
|
+
[36296]: [5125, 4, "uvec4", "vec4<u32>", "uint32x4"],
|
|
3447
|
+
[35670]: [5126, 1, "bool", "f32", "float32"],
|
|
3448
|
+
[35671]: [5126, 2, "bvec2", "vec2<f32>", "float32x2"],
|
|
3449
|
+
[35672]: [5126, 3, "bvec3", "vec3<f32>", "float32x3"],
|
|
3450
|
+
[35673]: [5126, 4, "bvec4", "vec4<f32>", "float32x4"],
|
|
3540
3451
|
// TODO - are sizes/components below correct?
|
|
3541
|
-
[
|
|
3452
|
+
[35674]: [5126, 8, "mat2", "mat2x2<f32>"],
|
|
3542
3453
|
// 4
|
|
3543
|
-
[
|
|
3454
|
+
[35685]: [5126, 8, "mat2x3", "mat2x3<f32>"],
|
|
3544
3455
|
// 6
|
|
3545
|
-
[
|
|
3456
|
+
[35686]: [5126, 8, "mat2x4", "mat2x4<f32>"],
|
|
3546
3457
|
// 8
|
|
3547
|
-
[
|
|
3458
|
+
[35687]: [5126, 12, "mat3x2", "mat3x2<f32>"],
|
|
3548
3459
|
// 6
|
|
3549
|
-
[
|
|
3460
|
+
[35675]: [5126, 12, "mat3", "mat3x3<f32>"],
|
|
3550
3461
|
// 9
|
|
3551
|
-
[
|
|
3462
|
+
[35688]: [5126, 12, "mat3x4", "mat3x4<f32>"],
|
|
3552
3463
|
// 12
|
|
3553
|
-
[
|
|
3464
|
+
[35689]: [5126, 16, "mat4x2", "mat4x2<f32>"],
|
|
3554
3465
|
// 8
|
|
3555
|
-
[
|
|
3466
|
+
[35690]: [5126, 16, "mat4x3", "mat4x3<f32>"],
|
|
3556
3467
|
// 12
|
|
3557
|
-
[
|
|
3468
|
+
[35676]: [5126, 16, "mat4", "mat4x4<f32>"]
|
|
3558
3469
|
// 16
|
|
3559
3470
|
};
|
|
3560
3471
|
function decodeGLUniformType(glUniformType) {
|
|
@@ -3627,7 +3538,7 @@ function getShaderLayout(gl, program) {
|
|
|
3627
3538
|
}
|
|
3628
3539
|
function readAttributeDeclarations(gl, program) {
|
|
3629
3540
|
const attributes = [];
|
|
3630
|
-
const count = gl.getProgramParameter(program,
|
|
3541
|
+
const count = gl.getProgramParameter(program, 35721);
|
|
3631
3542
|
for (let index = 0; index < count; index++) {
|
|
3632
3543
|
const activeInfo = gl.getActiveAttrib(program, index);
|
|
3633
3544
|
if (!activeInfo) {
|
|
@@ -3656,7 +3567,7 @@ function readAttributeDeclarations(gl, program) {
|
|
|
3656
3567
|
}
|
|
3657
3568
|
function readVaryings(gl, program) {
|
|
3658
3569
|
const varyings = [];
|
|
3659
|
-
const count = gl.getProgramParameter(program,
|
|
3570
|
+
const count = gl.getProgramParameter(program, 35971);
|
|
3660
3571
|
for (let location = 0; location < count; location++) {
|
|
3661
3572
|
const activeInfo = gl.getTransformFeedbackVarying(program, location);
|
|
3662
3573
|
if (!activeInfo) {
|
|
@@ -3673,7 +3584,7 @@ function readVaryings(gl, program) {
|
|
|
3673
3584
|
}
|
|
3674
3585
|
function readUniformBindings(gl, program) {
|
|
3675
3586
|
const uniforms = [];
|
|
3676
|
-
const uniformCount = gl.getProgramParameter(program,
|
|
3587
|
+
const uniformCount = gl.getProgramParameter(program, 35718);
|
|
3677
3588
|
for (let i = 0; i < uniformCount; i++) {
|
|
3678
3589
|
const activeInfo = gl.getActiveUniform(program, i);
|
|
3679
3590
|
if (!activeInfo) {
|
|
@@ -3709,22 +3620,22 @@ function readUniformBindings(gl, program) {
|
|
|
3709
3620
|
function readUniformBlocks(gl, program) {
|
|
3710
3621
|
const getBlockParameter = (blockIndex, pname) => gl.getActiveUniformBlockParameter(program, blockIndex, pname);
|
|
3711
3622
|
const uniformBlocks = [];
|
|
3712
|
-
const blockCount = gl.getProgramParameter(program,
|
|
3623
|
+
const blockCount = gl.getProgramParameter(program, 35382);
|
|
3713
3624
|
for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {
|
|
3714
3625
|
const blockInfo = {
|
|
3715
3626
|
name: gl.getActiveUniformBlockName(program, blockIndex) || "",
|
|
3716
|
-
location: getBlockParameter(blockIndex,
|
|
3717
|
-
byteLength: getBlockParameter(blockIndex,
|
|
3718
|
-
vertex: getBlockParameter(blockIndex,
|
|
3719
|
-
fragment: getBlockParameter(blockIndex,
|
|
3720
|
-
uniformCount: getBlockParameter(blockIndex,
|
|
3627
|
+
location: getBlockParameter(blockIndex, 35391),
|
|
3628
|
+
byteLength: getBlockParameter(blockIndex, 35392),
|
|
3629
|
+
vertex: getBlockParameter(blockIndex, 35396),
|
|
3630
|
+
fragment: getBlockParameter(blockIndex, 35398),
|
|
3631
|
+
uniformCount: getBlockParameter(blockIndex, 35394),
|
|
3721
3632
|
uniforms: []
|
|
3722
3633
|
};
|
|
3723
|
-
const uniformIndices = getBlockParameter(blockIndex,
|
|
3724
|
-
const uniformType = gl.getActiveUniforms(program, uniformIndices,
|
|
3725
|
-
const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices,
|
|
3726
|
-
const uniformOffset = gl.getActiveUniforms(program, uniformIndices,
|
|
3727
|
-
const uniformStride = gl.getActiveUniforms(program, uniformIndices,
|
|
3634
|
+
const uniformIndices = getBlockParameter(blockIndex, 35395) || [];
|
|
3635
|
+
const uniformType = gl.getActiveUniforms(program, uniformIndices, 35383);
|
|
3636
|
+
const uniformArrayLength = gl.getActiveUniforms(program, uniformIndices, 35384);
|
|
3637
|
+
const uniformOffset = gl.getActiveUniforms(program, uniformIndices, 35387);
|
|
3638
|
+
const uniformStride = gl.getActiveUniforms(program, uniformIndices, 35388);
|
|
3728
3639
|
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
3729
3640
|
const activeInfo = gl.getActiveUniform(program, uniformIndices[i]);
|
|
3730
3641
|
if (!activeInfo) {
|
|
@@ -3747,21 +3658,21 @@ function readUniformBlocks(gl, program) {
|
|
|
3747
3658
|
return uniformBlocks;
|
|
3748
3659
|
}
|
|
3749
3660
|
var SAMPLER_UNIFORMS_GL_TO_GPU = {
|
|
3750
|
-
[
|
|
3751
|
-
[
|
|
3752
|
-
[
|
|
3753
|
-
[
|
|
3754
|
-
[
|
|
3755
|
-
[
|
|
3756
|
-
[
|
|
3757
|
-
[
|
|
3758
|
-
[
|
|
3759
|
-
[
|
|
3760
|
-
[
|
|
3761
|
-
[
|
|
3762
|
-
[
|
|
3763
|
-
[
|
|
3764
|
-
[
|
|
3661
|
+
[35678]: ["2d", "float"],
|
|
3662
|
+
[35680]: ["cube", "float"],
|
|
3663
|
+
[35679]: ["3d", "float"],
|
|
3664
|
+
[35682]: ["3d", "depth"],
|
|
3665
|
+
[36289]: ["2d-array", "float"],
|
|
3666
|
+
[36292]: ["2d-array", "depth"],
|
|
3667
|
+
[36293]: ["cube", "float"],
|
|
3668
|
+
[36298]: ["2d", "sint"],
|
|
3669
|
+
[36299]: ["3d", "sint"],
|
|
3670
|
+
[36300]: ["cube", "sint"],
|
|
3671
|
+
[36303]: ["2d-array", "uint"],
|
|
3672
|
+
[36306]: ["2d", "uint"],
|
|
3673
|
+
[36307]: ["3d", "uint"],
|
|
3674
|
+
[36308]: ["cube", "uint"],
|
|
3675
|
+
[36311]: ["2d-array", "uint"]
|
|
3765
3676
|
};
|
|
3766
3677
|
function getSamplerInfo(type) {
|
|
3767
3678
|
const sampler = SAMPLER_UNIFORMS_GL_TO_GPU[type];
|
|
@@ -3792,7 +3703,7 @@ function parseUniformName(name) {
|
|
|
3792
3703
|
}
|
|
3793
3704
|
|
|
3794
3705
|
// dist/adapter/helpers/set-uniform.js
|
|
3795
|
-
var
|
|
3706
|
+
var import_constants19 = require("@luma.gl/constants");
|
|
3796
3707
|
function setUniform(gl, location, type, value) {
|
|
3797
3708
|
const gl2 = gl;
|
|
3798
3709
|
let uniformValue = value;
|
|
@@ -3804,97 +3715,97 @@ function setUniform(gl, location, type, value) {
|
|
|
3804
3715
|
}
|
|
3805
3716
|
const arrayValue = typeof uniformValue === "number" ? [uniformValue] : uniformValue;
|
|
3806
3717
|
switch (type) {
|
|
3807
|
-
case
|
|
3808
|
-
case
|
|
3809
|
-
case
|
|
3810
|
-
case
|
|
3811
|
-
case
|
|
3812
|
-
case
|
|
3813
|
-
case
|
|
3814
|
-
case
|
|
3815
|
-
case
|
|
3816
|
-
case
|
|
3817
|
-
case
|
|
3818
|
-
case
|
|
3819
|
-
case
|
|
3820
|
-
case
|
|
3821
|
-
case
|
|
3718
|
+
case 35678:
|
|
3719
|
+
case 35680:
|
|
3720
|
+
case 35679:
|
|
3721
|
+
case 35682:
|
|
3722
|
+
case 36289:
|
|
3723
|
+
case 36292:
|
|
3724
|
+
case 36293:
|
|
3725
|
+
case 36298:
|
|
3726
|
+
case 36299:
|
|
3727
|
+
case 36300:
|
|
3728
|
+
case 36303:
|
|
3729
|
+
case 36306:
|
|
3730
|
+
case 36307:
|
|
3731
|
+
case 36308:
|
|
3732
|
+
case 36311:
|
|
3822
3733
|
if (typeof value !== "number") {
|
|
3823
3734
|
throw new Error("samplers must be set to integers");
|
|
3824
3735
|
}
|
|
3825
3736
|
return gl.uniform1i(location, value);
|
|
3826
|
-
case
|
|
3737
|
+
case 5126:
|
|
3827
3738
|
return gl.uniform1fv(location, arrayValue);
|
|
3828
|
-
case
|
|
3739
|
+
case 35664:
|
|
3829
3740
|
return gl.uniform2fv(location, arrayValue);
|
|
3830
|
-
case
|
|
3741
|
+
case 35665:
|
|
3831
3742
|
return gl.uniform3fv(location, arrayValue);
|
|
3832
|
-
case
|
|
3743
|
+
case 35666:
|
|
3833
3744
|
return gl.uniform4fv(location, arrayValue);
|
|
3834
|
-
case
|
|
3745
|
+
case 5124:
|
|
3835
3746
|
return gl.uniform1iv(location, arrayValue);
|
|
3836
|
-
case
|
|
3747
|
+
case 35667:
|
|
3837
3748
|
return gl.uniform2iv(location, arrayValue);
|
|
3838
|
-
case
|
|
3749
|
+
case 35668:
|
|
3839
3750
|
return gl.uniform3iv(location, arrayValue);
|
|
3840
|
-
case
|
|
3751
|
+
case 35669:
|
|
3841
3752
|
return gl.uniform4iv(location, arrayValue);
|
|
3842
|
-
case
|
|
3753
|
+
case 35670:
|
|
3843
3754
|
return gl.uniform1iv(location, arrayValue);
|
|
3844
|
-
case
|
|
3755
|
+
case 35671:
|
|
3845
3756
|
return gl.uniform2iv(location, arrayValue);
|
|
3846
|
-
case
|
|
3757
|
+
case 35672:
|
|
3847
3758
|
return gl.uniform3iv(location, arrayValue);
|
|
3848
|
-
case
|
|
3759
|
+
case 35673:
|
|
3849
3760
|
return gl.uniform4iv(location, arrayValue);
|
|
3850
|
-
case
|
|
3761
|
+
case 5125:
|
|
3851
3762
|
return gl2.uniform1uiv(location, arrayValue, 1);
|
|
3852
|
-
case
|
|
3763
|
+
case 36294:
|
|
3853
3764
|
return gl2.uniform2uiv(location, arrayValue, 2);
|
|
3854
|
-
case
|
|
3765
|
+
case 36295:
|
|
3855
3766
|
return gl2.uniform3uiv(location, arrayValue, 3);
|
|
3856
|
-
case
|
|
3767
|
+
case 36296:
|
|
3857
3768
|
return gl2.uniform4uiv(location, arrayValue, 4);
|
|
3858
|
-
case
|
|
3769
|
+
case 35674:
|
|
3859
3770
|
return gl.uniformMatrix2fv(location, false, arrayValue);
|
|
3860
|
-
case
|
|
3771
|
+
case 35675:
|
|
3861
3772
|
return gl.uniformMatrix3fv(location, false, arrayValue);
|
|
3862
|
-
case
|
|
3773
|
+
case 35676:
|
|
3863
3774
|
return gl.uniformMatrix4fv(location, false, arrayValue);
|
|
3864
|
-
case
|
|
3775
|
+
case 35685:
|
|
3865
3776
|
return gl2.uniformMatrix2x3fv(location, false, arrayValue);
|
|
3866
|
-
case
|
|
3777
|
+
case 35686:
|
|
3867
3778
|
return gl2.uniformMatrix2x4fv(location, false, arrayValue);
|
|
3868
|
-
case
|
|
3779
|
+
case 35687:
|
|
3869
3780
|
return gl2.uniformMatrix3x2fv(location, false, arrayValue);
|
|
3870
|
-
case
|
|
3781
|
+
case 35688:
|
|
3871
3782
|
return gl2.uniformMatrix3x4fv(location, false, arrayValue);
|
|
3872
|
-
case
|
|
3783
|
+
case 35689:
|
|
3873
3784
|
return gl2.uniformMatrix4x2fv(location, false, arrayValue);
|
|
3874
|
-
case
|
|
3785
|
+
case 35690:
|
|
3875
3786
|
return gl2.uniformMatrix4x3fv(location, false, arrayValue);
|
|
3876
3787
|
}
|
|
3877
3788
|
throw new Error("Illegal uniform");
|
|
3878
3789
|
}
|
|
3879
3790
|
|
|
3880
3791
|
// dist/adapter/helpers/webgl-topology-utils.js
|
|
3881
|
-
var
|
|
3792
|
+
var import_constants20 = require("@luma.gl/constants");
|
|
3882
3793
|
function getGLDrawMode(topology) {
|
|
3883
3794
|
switch (topology) {
|
|
3884
3795
|
case "point-list":
|
|
3885
|
-
return
|
|
3796
|
+
return 0;
|
|
3886
3797
|
case "line-list":
|
|
3887
|
-
return
|
|
3798
|
+
return 1;
|
|
3888
3799
|
case "line-strip":
|
|
3889
|
-
return
|
|
3800
|
+
return 3;
|
|
3890
3801
|
case "line-loop-webgl":
|
|
3891
|
-
return
|
|
3802
|
+
return 2;
|
|
3892
3803
|
case "triangle-list":
|
|
3893
|
-
return
|
|
3804
|
+
return 4;
|
|
3894
3805
|
case "triangle-strip":
|
|
3895
|
-
return
|
|
3806
|
+
return 5;
|
|
3896
3807
|
case "triangle-fan-webgl":
|
|
3897
|
-
return
|
|
3808
|
+
return 6;
|
|
3898
3809
|
default:
|
|
3899
3810
|
throw new Error(topology);
|
|
3900
3811
|
}
|
|
@@ -3902,19 +3813,19 @@ function getGLDrawMode(topology) {
|
|
|
3902
3813
|
function getGLPrimitive(topology) {
|
|
3903
3814
|
switch (topology) {
|
|
3904
3815
|
case "point-list":
|
|
3905
|
-
return
|
|
3816
|
+
return 0;
|
|
3906
3817
|
case "line-list":
|
|
3907
|
-
return
|
|
3818
|
+
return 1;
|
|
3908
3819
|
case "line-strip":
|
|
3909
|
-
return
|
|
3820
|
+
return 1;
|
|
3910
3821
|
case "line-loop-webgl":
|
|
3911
|
-
return
|
|
3822
|
+
return 1;
|
|
3912
3823
|
case "triangle-list":
|
|
3913
|
-
return
|
|
3824
|
+
return 4;
|
|
3914
3825
|
case "triangle-strip":
|
|
3915
|
-
return
|
|
3826
|
+
return 4;
|
|
3916
3827
|
case "triangle-fan-webgl":
|
|
3917
|
-
return
|
|
3828
|
+
return 4;
|
|
3918
3829
|
default:
|
|
3919
3830
|
throw new Error(topology);
|
|
3920
3831
|
}
|
|
@@ -3949,13 +3860,15 @@ var WEBGLRenderPipeline = class extends import_core17.RenderPipeline {
|
|
|
3949
3860
|
this.device.setSpectorMetadata(this.handle, { id: this.props.id });
|
|
3950
3861
|
this.vs = (0, import_core17.cast)(props.vs);
|
|
3951
3862
|
this.fs = (0, import_core17.cast)(props.fs);
|
|
3952
|
-
const { varyings, bufferMode =
|
|
3863
|
+
const { varyings, bufferMode = 35981 } = props;
|
|
3953
3864
|
if (varyings && varyings.length > 0) {
|
|
3954
3865
|
this.varyings = varyings;
|
|
3955
3866
|
this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
3956
3867
|
}
|
|
3957
3868
|
this._linkShaders();
|
|
3869
|
+
import_core17.log.time(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
3958
3870
|
this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
|
|
3871
|
+
import_core17.log.timeEnd(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
3959
3872
|
this.shaderLayout = (0, import_core18.mergeShaderLayout)(this.introspectedLayout, props.shaderLayout);
|
|
3960
3873
|
switch (this.props.topology) {
|
|
3961
3874
|
case "triangle-fan-webgl":
|
|
@@ -3993,7 +3906,7 @@ var WEBGLRenderPipeline = class extends import_core17.RenderPipeline {
|
|
|
3993
3906
|
}
|
|
3994
3907
|
break;
|
|
3995
3908
|
case "texture":
|
|
3996
|
-
if (!(value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
3909
|
+
if (!(value instanceof WEBGLTextureView || value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
3997
3910
|
throw new Error("texture value");
|
|
3998
3911
|
}
|
|
3999
3912
|
break;
|
|
@@ -4006,23 +3919,12 @@ var WEBGLRenderPipeline = class extends import_core17.RenderPipeline {
|
|
|
4006
3919
|
this.bindings[name] = value;
|
|
4007
3920
|
}
|
|
4008
3921
|
}
|
|
4009
|
-
/** This function is @deprecated, use uniform buffers */
|
|
4010
|
-
setUniforms(uniforms) {
|
|
4011
|
-
const { bindings } = (0, import_core17.splitUniformsAndBindings)(uniforms);
|
|
4012
|
-
Object.keys(bindings).forEach((name) => {
|
|
4013
|
-
import_core17.log.warn(`Unsupported value "${JSON.stringify(bindings[name])}" used in setUniforms() for key ${name}. Use setBindings() instead?`)();
|
|
4014
|
-
});
|
|
4015
|
-
Object.assign(this.uniforms, uniforms);
|
|
4016
|
-
}
|
|
4017
3922
|
/** @todo needed for portable model
|
|
4018
3923
|
* @note The WebGL API is offers many ways to draw things
|
|
4019
3924
|
* This function unifies those ways into a single call using common parameters with sane defaults
|
|
4020
3925
|
*/
|
|
4021
3926
|
draw(options) {
|
|
4022
3927
|
var _a;
|
|
4023
|
-
if (this.linkStatus !== "success") {
|
|
4024
|
-
return false;
|
|
4025
|
-
}
|
|
4026
3928
|
const {
|
|
4027
3929
|
renderPass,
|
|
4028
3930
|
vertexArray,
|
|
@@ -4039,9 +3941,18 @@ var WEBGLRenderPipeline = class extends import_core17.RenderPipeline {
|
|
|
4039
3941
|
const isIndexed = Boolean(vertexArray.indexBuffer);
|
|
4040
3942
|
const glIndexType = (_a = vertexArray.indexBuffer) == null ? void 0 : _a.glIndexType;
|
|
4041
3943
|
const isInstanced = Number(instanceCount) > 0;
|
|
3944
|
+
if (this.linkStatus !== "success") {
|
|
3945
|
+
import_core17.log.info(2, `RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)();
|
|
3946
|
+
return false;
|
|
3947
|
+
}
|
|
4042
3948
|
if (!this._areTexturesRenderable() || vertexCount === 0) {
|
|
3949
|
+
import_core17.log.info(2, `RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)();
|
|
4043
3950
|
return false;
|
|
4044
3951
|
}
|
|
3952
|
+
if (vertexCount === 0) {
|
|
3953
|
+
import_core17.log.info(2, `RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)();
|
|
3954
|
+
return true;
|
|
3955
|
+
}
|
|
4045
3956
|
this.device.gl.useProgram(this.handle);
|
|
4046
3957
|
vertexArray.bindBeforeRender(renderPass);
|
|
4047
3958
|
if (transformFeedback) {
|
|
@@ -4074,6 +3985,14 @@ var WEBGLRenderPipeline = class extends import_core17.RenderPipeline {
|
|
|
4074
3985
|
vertexArray.unbindAfterRender(renderPass);
|
|
4075
3986
|
return true;
|
|
4076
3987
|
}
|
|
3988
|
+
// DEPRECATED METHODS
|
|
3989
|
+
setUniformsWebGL(uniforms) {
|
|
3990
|
+
const { bindings } = (0, import_core17.splitUniformsAndBindings)(uniforms);
|
|
3991
|
+
Object.keys(bindings).forEach((name) => {
|
|
3992
|
+
import_core17.log.warn(`Unsupported value "${JSON.stringify(bindings[name])}" used in setUniforms() for key ${name}. Use setBindings() instead?`)();
|
|
3993
|
+
});
|
|
3994
|
+
Object.assign(this.uniforms, uniforms);
|
|
3995
|
+
}
|
|
4077
3996
|
// PRIVATE METHODS
|
|
4078
3997
|
// setAttributes(attributes: Record<string, Buffer>): void {}
|
|
4079
3998
|
// setBindings(bindings: Record<string, Binding>): void {}
|
|
@@ -4086,7 +4005,7 @@ var WEBGLRenderPipeline = class extends import_core17.RenderPipeline {
|
|
|
4086
4005
|
import_core17.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
4087
4006
|
if (import_core17.log.level === 0) {
|
|
4088
4007
|
}
|
|
4089
|
-
if (!this.device.features.has("
|
|
4008
|
+
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
4090
4009
|
const status2 = this._getLinkStatus();
|
|
4091
4010
|
this._reportLinkStatus(status2);
|
|
4092
4011
|
return;
|
|
@@ -4122,13 +4041,13 @@ var WEBGLRenderPipeline = class extends import_core17.RenderPipeline {
|
|
|
4122
4041
|
*/
|
|
4123
4042
|
_getLinkStatus() {
|
|
4124
4043
|
const { gl } = this.device;
|
|
4125
|
-
const linked = gl.getProgramParameter(this.handle,
|
|
4044
|
+
const linked = gl.getProgramParameter(this.handle, 35714);
|
|
4126
4045
|
if (!linked) {
|
|
4127
4046
|
this.linkStatus = "error";
|
|
4128
4047
|
return "linking";
|
|
4129
4048
|
}
|
|
4130
4049
|
gl.validateProgram(this.handle);
|
|
4131
|
-
const validated = gl.getProgramParameter(this.handle,
|
|
4050
|
+
const validated = gl.getProgramParameter(this.handle, 35715);
|
|
4132
4051
|
if (!validated) {
|
|
4133
4052
|
this.linkStatus = "error";
|
|
4134
4053
|
return "validation";
|
|
@@ -4140,13 +4059,13 @@ var WEBGLRenderPipeline = class extends import_core17.RenderPipeline {
|
|
|
4140
4059
|
async _waitForLinkComplete() {
|
|
4141
4060
|
const waitMs = async (ms) => await new Promise((resolve) => setTimeout(resolve, ms));
|
|
4142
4061
|
const DELAY_MS = 10;
|
|
4143
|
-
if (!this.device.features.has("
|
|
4062
|
+
if (!this.device.features.has("compilation-status-async-webgl")) {
|
|
4144
4063
|
await waitMs(DELAY_MS);
|
|
4145
4064
|
return;
|
|
4146
4065
|
}
|
|
4147
4066
|
const { gl } = this.device;
|
|
4148
4067
|
for (; ; ) {
|
|
4149
|
-
const complete = gl.getProgramParameter(this.handle,
|
|
4068
|
+
const complete = gl.getProgramParameter(this.handle, 37297);
|
|
4150
4069
|
if (complete) {
|
|
4151
4070
|
return;
|
|
4152
4071
|
}
|
|
@@ -4186,15 +4105,15 @@ var WEBGLRenderPipeline = class extends import_core17.RenderPipeline {
|
|
|
4186
4105
|
case "uniform":
|
|
4187
4106
|
const { name } = binding;
|
|
4188
4107
|
const location = gl.getUniformBlockIndex(this.handle, name);
|
|
4189
|
-
if (location ===
|
|
4108
|
+
if (location === 4294967295) {
|
|
4190
4109
|
throw new Error(`Invalid uniform block name ${name}`);
|
|
4191
4110
|
}
|
|
4192
4111
|
gl.uniformBlockBinding(this.handle, uniformBufferIndex, location);
|
|
4193
4112
|
if (value instanceof WEBGLBuffer) {
|
|
4194
|
-
gl.bindBufferBase(
|
|
4113
|
+
gl.bindBufferBase(35345, uniformBufferIndex, value.handle);
|
|
4195
4114
|
} else {
|
|
4196
4115
|
gl.bindBufferRange(
|
|
4197
|
-
|
|
4116
|
+
35345,
|
|
4198
4117
|
uniformBufferIndex,
|
|
4199
4118
|
// @ts-expect-error
|
|
4200
4119
|
value.buffer.handle,
|
|
@@ -4207,11 +4126,13 @@ var WEBGLRenderPipeline = class extends import_core17.RenderPipeline {
|
|
|
4207
4126
|
uniformBufferIndex += 1;
|
|
4208
4127
|
break;
|
|
4209
4128
|
case "texture":
|
|
4210
|
-
if (!(value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
4129
|
+
if (!(value instanceof WEBGLTextureView || value instanceof WEBGLTexture || value instanceof WEBGLFramebuffer)) {
|
|
4211
4130
|
throw new Error("texture");
|
|
4212
4131
|
}
|
|
4213
4132
|
let texture;
|
|
4214
|
-
if (value instanceof
|
|
4133
|
+
if (value instanceof WEBGLTextureView) {
|
|
4134
|
+
texture = value.texture;
|
|
4135
|
+
} else if (value instanceof WEBGLTexture) {
|
|
4215
4136
|
texture = value;
|
|
4216
4137
|
} else if (value instanceof WEBGLFramebuffer && value.colorAttachments[0] instanceof WEBGLTexture) {
|
|
4217
4138
|
import_core17.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")();
|
|
@@ -4219,7 +4140,7 @@ var WEBGLRenderPipeline = class extends import_core17.RenderPipeline {
|
|
|
4219
4140
|
} else {
|
|
4220
4141
|
throw new Error("No texture");
|
|
4221
4142
|
}
|
|
4222
|
-
gl.activeTexture(
|
|
4143
|
+
gl.activeTexture(33984 + textureUnit);
|
|
4223
4144
|
gl.bindTexture(texture.target, texture.handle);
|
|
4224
4145
|
textureUnit += 1;
|
|
4225
4146
|
break;
|
|
@@ -4251,7 +4172,7 @@ var import_core20 = require("@luma.gl/core");
|
|
|
4251
4172
|
|
|
4252
4173
|
// dist/adapter/resources/webgl-command-buffer.js
|
|
4253
4174
|
var import_core19 = require("@luma.gl/core");
|
|
4254
|
-
var
|
|
4175
|
+
var import_constants22 = require("@luma.gl/constants");
|
|
4255
4176
|
function cast2(value) {
|
|
4256
4177
|
return value;
|
|
4257
4178
|
}
|
|
@@ -4284,11 +4205,11 @@ var WEBGLCommandBuffer = class extends import_core19.CommandBuffer {
|
|
|
4284
4205
|
function _copyBufferToBuffer(device, options) {
|
|
4285
4206
|
const source = cast2(options.source);
|
|
4286
4207
|
const destination = cast2(options.destination);
|
|
4287
|
-
device.gl.bindBuffer(
|
|
4288
|
-
device.gl.bindBuffer(
|
|
4289
|
-
device.gl.copyBufferSubData(
|
|
4290
|
-
device.gl.bindBuffer(
|
|
4291
|
-
device.gl.bindBuffer(
|
|
4208
|
+
device.gl.bindBuffer(36662, source.handle);
|
|
4209
|
+
device.gl.bindBuffer(36663, destination.handle);
|
|
4210
|
+
device.gl.copyBufferSubData(36662, 36663, options.sourceOffset ?? 0, options.destinationOffset ?? 0, options.size);
|
|
4211
|
+
device.gl.bindBuffer(36662, null);
|
|
4212
|
+
device.gl.bindBuffer(36663, null);
|
|
4292
4213
|
}
|
|
4293
4214
|
function _copyBufferToTexture(device, options) {
|
|
4294
4215
|
throw new Error("Not implemented");
|
|
@@ -4335,15 +4256,15 @@ function _copyTextureToBuffer(device, options) {
|
|
|
4335
4256
|
const webglBuffer = destination;
|
|
4336
4257
|
const sourceWidth = width || framebuffer.width;
|
|
4337
4258
|
const sourceHeight = height || framebuffer.height;
|
|
4338
|
-
const sourceParams = getWebGLTextureParameters(framebuffer.texture.format);
|
|
4259
|
+
const sourceParams = getWebGLTextureParameters(framebuffer.texture.props.format);
|
|
4339
4260
|
const sourceFormat = sourceParams.dataFormat;
|
|
4340
4261
|
const sourceType = sourceParams.type;
|
|
4341
|
-
device.gl.bindBuffer(
|
|
4342
|
-
device.gl.bindFramebuffer(
|
|
4262
|
+
device.gl.bindBuffer(35051, webglBuffer.handle);
|
|
4263
|
+
device.gl.bindFramebuffer(36160, framebuffer.handle);
|
|
4343
4264
|
device.gl.readPixels(origin[0], origin[1], sourceWidth, sourceHeight, sourceFormat, sourceType, byteOffset);
|
|
4344
4265
|
} finally {
|
|
4345
|
-
device.gl.bindBuffer(
|
|
4346
|
-
device.gl.bindFramebuffer(
|
|
4266
|
+
device.gl.bindBuffer(35051, null);
|
|
4267
|
+
device.gl.bindFramebuffer(36160, null);
|
|
4347
4268
|
if (destroyFramebuffer) {
|
|
4348
4269
|
framebuffer.destroy();
|
|
4349
4270
|
}
|
|
@@ -4374,11 +4295,11 @@ function _copyTextureToTexture(device, options) {
|
|
|
4374
4295
|
// depthOrArrayLayers = 0
|
|
4375
4296
|
} = options;
|
|
4376
4297
|
const destinationMipmaplevel = 0;
|
|
4377
|
-
const destinationInternalFormat =
|
|
4298
|
+
const destinationInternalFormat = 6408;
|
|
4378
4299
|
const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
|
|
4379
4300
|
const [sourceX, sourceY] = origin;
|
|
4380
4301
|
const isSubCopy = false;
|
|
4381
|
-
device.gl.bindFramebuffer(
|
|
4302
|
+
device.gl.bindFramebuffer(36160, framebuffer.handle);
|
|
4382
4303
|
let texture = null;
|
|
4383
4304
|
let textureTarget;
|
|
4384
4305
|
if (destination instanceof WEBGLTexture) {
|
|
@@ -4461,11 +4382,13 @@ var WEBGLCommandEncoder = class extends import_core20.CommandEncoder {
|
|
|
4461
4382
|
}
|
|
4462
4383
|
insertDebugMarker(markerLabel) {
|
|
4463
4384
|
}
|
|
4385
|
+
resolveQuerySet(querySet, destination, options) {
|
|
4386
|
+
}
|
|
4464
4387
|
};
|
|
4465
4388
|
|
|
4466
4389
|
// dist/adapter/resources/webgl-vertex-array.js
|
|
4467
4390
|
var import_core21 = require("@luma.gl/core");
|
|
4468
|
-
var
|
|
4391
|
+
var import_constants23 = require("@luma.gl/constants");
|
|
4469
4392
|
var import_env2 = require("@probe.gl/env");
|
|
4470
4393
|
var WEBGLVertexArray = class extends import_core21.VertexArray {
|
|
4471
4394
|
get [Symbol.toStringTag]() {
|
|
@@ -4505,22 +4428,22 @@ var WEBGLVertexArray = class extends import_core21.VertexArray {
|
|
|
4505
4428
|
*/
|
|
4506
4429
|
setIndexBuffer(indexBuffer) {
|
|
4507
4430
|
const buffer = indexBuffer;
|
|
4508
|
-
if (buffer && buffer.glTarget !==
|
|
4431
|
+
if (buffer && buffer.glTarget !== 34963) {
|
|
4509
4432
|
throw new Error("Use .setBuffer()");
|
|
4510
4433
|
}
|
|
4511
4434
|
this.device.gl.bindVertexArray(this.handle);
|
|
4512
|
-
this.device.gl.bindBuffer(
|
|
4435
|
+
this.device.gl.bindBuffer(34963, buffer ? buffer.handle : null);
|
|
4513
4436
|
this.indexBuffer = buffer;
|
|
4514
4437
|
}
|
|
4515
4438
|
/** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
|
|
4516
4439
|
setBuffer(location, attributeBuffer) {
|
|
4517
4440
|
const buffer = attributeBuffer;
|
|
4518
|
-
if (buffer.glTarget ===
|
|
4441
|
+
if (buffer.glTarget === 34963) {
|
|
4519
4442
|
throw new Error("Use .setIndexBuffer()");
|
|
4520
4443
|
}
|
|
4521
4444
|
const { size, type, stride, offset, normalized, integer, divisor } = this._getAccessor(location);
|
|
4522
4445
|
this.device.gl.bindVertexArray(this.handle);
|
|
4523
|
-
this.device.gl.bindBuffer(
|
|
4446
|
+
this.device.gl.bindBuffer(34962, buffer.handle);
|
|
4524
4447
|
if (integer) {
|
|
4525
4448
|
this.device.gl.vertexAttribIPointer(location, size, type, stride, offset);
|
|
4526
4449
|
} else {
|
|
@@ -4531,7 +4454,7 @@ var WEBGLVertexArray = class extends import_core21.VertexArray {
|
|
|
4531
4454
|
this.attributes[location] = buffer;
|
|
4532
4455
|
}
|
|
4533
4456
|
/** Set a location in vertex attributes array to a constant value, disables the location */
|
|
4534
|
-
|
|
4457
|
+
setConstantWebGL(location, value) {
|
|
4535
4458
|
this._enable(location, false);
|
|
4536
4459
|
this.attributes[location] = value;
|
|
4537
4460
|
}
|
|
@@ -4540,7 +4463,7 @@ var WEBGLVertexArray = class extends import_core21.VertexArray {
|
|
|
4540
4463
|
this.device.gl.bindVertexArray(this.handle);
|
|
4541
4464
|
if (!this.init) {
|
|
4542
4465
|
const webglBuffer = this.indexBuffer;
|
|
4543
|
-
this.device.gl.bindBuffer(
|
|
4466
|
+
this.device.gl.bindBuffer(34963, (webglBuffer == null ? void 0 : webglBuffer.handle) || null);
|
|
4544
4467
|
this.init = true;
|
|
4545
4468
|
}
|
|
4546
4469
|
this._applyConstantAttributes();
|
|
@@ -4559,7 +4482,7 @@ var WEBGLVertexArray = class extends import_core21.VertexArray {
|
|
|
4559
4482
|
for (let location = 0; location < this.maxVertexAttributes; ++location) {
|
|
4560
4483
|
const constant = this.attributes[location];
|
|
4561
4484
|
if (ArrayBuffer.isView(constant)) {
|
|
4562
|
-
this.device.
|
|
4485
|
+
this.device.setConstantAttributeWebGL(location, constant);
|
|
4563
4486
|
}
|
|
4564
4487
|
}
|
|
4565
4488
|
}
|
|
@@ -4665,7 +4588,7 @@ function compareConstantArrayValues(v1, v2) {
|
|
|
4665
4588
|
|
|
4666
4589
|
// dist/adapter/resources/webgl-transform-feedback.js
|
|
4667
4590
|
var import_core22 = require("@luma.gl/core");
|
|
4668
|
-
var
|
|
4591
|
+
var import_constants24 = require("@luma.gl/constants");
|
|
4669
4592
|
var WEBGLTransformFeedback = class extends import_core22.TransformFeedback {
|
|
4670
4593
|
device;
|
|
4671
4594
|
gl;
|
|
@@ -4701,7 +4624,7 @@ var WEBGLTransformFeedback = class extends import_core22.TransformFeedback {
|
|
|
4701
4624
|
super.destroy();
|
|
4702
4625
|
}
|
|
4703
4626
|
begin(topology = "point-list") {
|
|
4704
|
-
this.gl.bindTransformFeedback(
|
|
4627
|
+
this.gl.bindTransformFeedback(36386, this.handle);
|
|
4705
4628
|
if (this.bindOnUse) {
|
|
4706
4629
|
this._bindBuffers();
|
|
4707
4630
|
}
|
|
@@ -4712,7 +4635,7 @@ var WEBGLTransformFeedback = class extends import_core22.TransformFeedback {
|
|
|
4712
4635
|
if (!this.bindOnUse) {
|
|
4713
4636
|
this._unbindBuffers();
|
|
4714
4637
|
}
|
|
4715
|
-
this.gl.bindTransformFeedback(
|
|
4638
|
+
this.gl.bindTransformFeedback(36386, null);
|
|
4716
4639
|
}
|
|
4717
4640
|
// SUBCLASS
|
|
4718
4641
|
setBuffers(buffers) {
|
|
@@ -4746,16 +4669,16 @@ var WEBGLTransformFeedback = class extends import_core22.TransformFeedback {
|
|
|
4746
4669
|
}
|
|
4747
4670
|
bind(funcOrHandle = this.handle) {
|
|
4748
4671
|
if (typeof funcOrHandle !== "function") {
|
|
4749
|
-
this.gl.bindTransformFeedback(
|
|
4672
|
+
this.gl.bindTransformFeedback(36386, funcOrHandle);
|
|
4750
4673
|
return this;
|
|
4751
4674
|
}
|
|
4752
4675
|
let value;
|
|
4753
4676
|
if (!this._bound) {
|
|
4754
|
-
this.gl.bindTransformFeedback(
|
|
4677
|
+
this.gl.bindTransformFeedback(36386, this.handle);
|
|
4755
4678
|
this._bound = true;
|
|
4756
4679
|
value = funcOrHandle();
|
|
4757
4680
|
this._bound = false;
|
|
4758
|
-
this.gl.bindTransformFeedback(
|
|
4681
|
+
this.gl.bindTransformFeedback(36386, null);
|
|
4759
4682
|
} else {
|
|
4760
4683
|
value = funcOrHandle();
|
|
4761
4684
|
}
|
|
@@ -4796,15 +4719,15 @@ var WEBGLTransformFeedback = class extends import_core22.TransformFeedback {
|
|
|
4796
4719
|
}
|
|
4797
4720
|
_unbindBuffers() {
|
|
4798
4721
|
for (const bufferIndex in this.buffers) {
|
|
4799
|
-
this.gl.bindBufferBase(
|
|
4722
|
+
this.gl.bindBufferBase(35982, Number(bufferIndex), null);
|
|
4800
4723
|
}
|
|
4801
4724
|
}
|
|
4802
4725
|
_bindBuffer(index, buffer, byteOffset = 0, byteLength) {
|
|
4803
4726
|
const handle = buffer && buffer.handle;
|
|
4804
4727
|
if (!handle || byteLength === void 0) {
|
|
4805
|
-
this.gl.bindBufferBase(
|
|
4728
|
+
this.gl.bindBufferBase(35982, index, handle);
|
|
4806
4729
|
} else {
|
|
4807
|
-
this.gl.bindBufferRange(
|
|
4730
|
+
this.gl.bindBufferRange(35982, index, handle, byteOffset, byteLength);
|
|
4808
4731
|
}
|
|
4809
4732
|
}
|
|
4810
4733
|
};
|
|
@@ -4815,57 +4738,187 @@ function isIndex(value) {
|
|
|
4815
4738
|
return /^\d+$/.test(value);
|
|
4816
4739
|
}
|
|
4817
4740
|
|
|
4741
|
+
// dist/adapter/resources/webgl-query-set.js
|
|
4742
|
+
var import_core23 = require("@luma.gl/core");
|
|
4743
|
+
var import_constants25 = require("@luma.gl/constants");
|
|
4744
|
+
var WEBGLQuerySet = class extends import_core23.QuerySet {
|
|
4745
|
+
device;
|
|
4746
|
+
handle;
|
|
4747
|
+
target = null;
|
|
4748
|
+
_queryPending = false;
|
|
4749
|
+
_pollingPromise = null;
|
|
4750
|
+
get [Symbol.toStringTag]() {
|
|
4751
|
+
return "Query";
|
|
4752
|
+
}
|
|
4753
|
+
// Create a query class
|
|
4754
|
+
constructor(device, props) {
|
|
4755
|
+
super(device, props);
|
|
4756
|
+
this.device = device;
|
|
4757
|
+
if (props.count > 1) {
|
|
4758
|
+
throw new Error("WebGL QuerySet can only have one value");
|
|
4759
|
+
}
|
|
4760
|
+
this.handle = this.device.gl.createQuery();
|
|
4761
|
+
Object.seal(this);
|
|
4762
|
+
}
|
|
4763
|
+
destroy() {
|
|
4764
|
+
this.device.gl.deleteQuery(this.handle);
|
|
4765
|
+
}
|
|
4766
|
+
// FOR RENDER PASS AND COMMAND ENCODER
|
|
4767
|
+
/**
|
|
4768
|
+
* Shortcut for timer query (dependent on extension in both WebGL1 and 2)
|
|
4769
|
+
* Measures GPU time delta between this call and a matching `end` call in the
|
|
4770
|
+
* GPU instruction stream.
|
|
4771
|
+
*/
|
|
4772
|
+
beginTimestampQuery() {
|
|
4773
|
+
return this._begin(35007);
|
|
4774
|
+
}
|
|
4775
|
+
endTimestampQuery() {
|
|
4776
|
+
this._end();
|
|
4777
|
+
}
|
|
4778
|
+
// Shortcut for occlusion queries
|
|
4779
|
+
beginOcclusionQuery(options) {
|
|
4780
|
+
return this._begin((options == null ? void 0 : options.conservative) ? 36202 : 35887);
|
|
4781
|
+
}
|
|
4782
|
+
endOcclusionQuery() {
|
|
4783
|
+
this._end();
|
|
4784
|
+
}
|
|
4785
|
+
// Shortcut for transformFeedbackQuery
|
|
4786
|
+
beginTransformFeedbackQuery() {
|
|
4787
|
+
return this._begin(35976);
|
|
4788
|
+
}
|
|
4789
|
+
endTransformFeedbackQuery() {
|
|
4790
|
+
this._end();
|
|
4791
|
+
}
|
|
4792
|
+
async resolveQuery() {
|
|
4793
|
+
const value = await this.pollQuery();
|
|
4794
|
+
return [value];
|
|
4795
|
+
}
|
|
4796
|
+
// PRIVATE METHODS
|
|
4797
|
+
/**
|
|
4798
|
+
* Due to OpenGL API limitations, after calling `begin()` on one Query
|
|
4799
|
+
* instance, `end()` must be called on that same instance before
|
|
4800
|
+
* calling `begin()` on another query. While there can be multiple
|
|
4801
|
+
* outstanding queries representing disjoint `begin()`/`end()` intervals.
|
|
4802
|
+
* It is not possible to interleave or overlap `begin` and `end` calls.
|
|
4803
|
+
*/
|
|
4804
|
+
_begin(target) {
|
|
4805
|
+
if (this._queryPending) {
|
|
4806
|
+
return;
|
|
4807
|
+
}
|
|
4808
|
+
this.target = target;
|
|
4809
|
+
this.device.gl.beginQuery(this.target, this.handle);
|
|
4810
|
+
return;
|
|
4811
|
+
}
|
|
4812
|
+
// ends the current query
|
|
4813
|
+
_end() {
|
|
4814
|
+
if (this._queryPending) {
|
|
4815
|
+
return;
|
|
4816
|
+
}
|
|
4817
|
+
if (this.target) {
|
|
4818
|
+
this.device.gl.endQuery(this.target);
|
|
4819
|
+
this.target = null;
|
|
4820
|
+
this._queryPending = true;
|
|
4821
|
+
}
|
|
4822
|
+
return;
|
|
4823
|
+
}
|
|
4824
|
+
// Returns true if the query result is available
|
|
4825
|
+
isResultAvailable() {
|
|
4826
|
+
if (!this._queryPending) {
|
|
4827
|
+
return false;
|
|
4828
|
+
}
|
|
4829
|
+
const resultAvailable = this.device.gl.getQueryParameter(this.handle, 34919);
|
|
4830
|
+
if (resultAvailable) {
|
|
4831
|
+
this._queryPending = false;
|
|
4832
|
+
}
|
|
4833
|
+
return resultAvailable;
|
|
4834
|
+
}
|
|
4835
|
+
// Timing query is disjoint, i.e. results are invalid
|
|
4836
|
+
isTimerDisjoint() {
|
|
4837
|
+
return this.device.gl.getParameter(36795);
|
|
4838
|
+
}
|
|
4839
|
+
// Returns query result.
|
|
4840
|
+
getResult() {
|
|
4841
|
+
return this.device.gl.getQueryParameter(this.handle, 34918);
|
|
4842
|
+
}
|
|
4843
|
+
// Returns the query result, converted to milliseconds to match JavaScript conventions.
|
|
4844
|
+
getTimerMilliseconds() {
|
|
4845
|
+
return this.getResult() / 1e6;
|
|
4846
|
+
}
|
|
4847
|
+
// Polls the query
|
|
4848
|
+
pollQuery(limit = Number.POSITIVE_INFINITY) {
|
|
4849
|
+
if (this._pollingPromise) {
|
|
4850
|
+
return this._pollingPromise;
|
|
4851
|
+
}
|
|
4852
|
+
let counter = 0;
|
|
4853
|
+
this._pollingPromise = new Promise((resolve, reject) => {
|
|
4854
|
+
const poll = () => {
|
|
4855
|
+
if (this.isResultAvailable()) {
|
|
4856
|
+
resolve(this.getResult());
|
|
4857
|
+
this._pollingPromise = null;
|
|
4858
|
+
} else if (counter++ > limit) {
|
|
4859
|
+
reject("Timed out");
|
|
4860
|
+
this._pollingPromise = null;
|
|
4861
|
+
} else {
|
|
4862
|
+
requestAnimationFrame(poll);
|
|
4863
|
+
}
|
|
4864
|
+
};
|
|
4865
|
+
requestAnimationFrame(poll);
|
|
4866
|
+
});
|
|
4867
|
+
return this._pollingPromise;
|
|
4868
|
+
}
|
|
4869
|
+
};
|
|
4870
|
+
|
|
4818
4871
|
// dist/classic/copy-and-blit.js
|
|
4819
|
-
var
|
|
4872
|
+
var import_core25 = require("@luma.gl/core");
|
|
4820
4873
|
var import_constants27 = require("@luma.gl/constants");
|
|
4821
4874
|
|
|
4822
4875
|
// dist/classic/format-utils.js
|
|
4823
|
-
var
|
|
4876
|
+
var import_core24 = require("@luma.gl/core");
|
|
4824
4877
|
var import_constants26 = require("@luma.gl/constants");
|
|
4825
4878
|
function glFormatToComponents(format) {
|
|
4826
4879
|
switch (format) {
|
|
4827
|
-
case
|
|
4828
|
-
case
|
|
4829
|
-
case
|
|
4880
|
+
case 6406:
|
|
4881
|
+
case 33326:
|
|
4882
|
+
case 6403:
|
|
4830
4883
|
return 1;
|
|
4831
|
-
case
|
|
4832
|
-
case
|
|
4884
|
+
case 33328:
|
|
4885
|
+
case 33319:
|
|
4833
4886
|
return 2;
|
|
4834
|
-
case
|
|
4835
|
-
case
|
|
4887
|
+
case 6407:
|
|
4888
|
+
case 34837:
|
|
4836
4889
|
return 3;
|
|
4837
|
-
case
|
|
4838
|
-
case
|
|
4890
|
+
case 6408:
|
|
4891
|
+
case 34836:
|
|
4839
4892
|
return 4;
|
|
4840
4893
|
default:
|
|
4841
|
-
(0,
|
|
4894
|
+
(0, import_core24.assert)(false);
|
|
4842
4895
|
return 0;
|
|
4843
4896
|
}
|
|
4844
4897
|
}
|
|
4845
4898
|
function glTypeToBytes(type) {
|
|
4846
4899
|
switch (type) {
|
|
4847
|
-
case
|
|
4900
|
+
case 5121:
|
|
4848
4901
|
return 1;
|
|
4849
|
-
case
|
|
4850
|
-
case
|
|
4851
|
-
case
|
|
4902
|
+
case 33635:
|
|
4903
|
+
case 32819:
|
|
4904
|
+
case 32820:
|
|
4852
4905
|
return 2;
|
|
4853
|
-
case
|
|
4906
|
+
case 5126:
|
|
4854
4907
|
return 4;
|
|
4855
4908
|
default:
|
|
4856
|
-
(0,
|
|
4909
|
+
(0, import_core24.assert)(false);
|
|
4857
4910
|
return 0;
|
|
4858
4911
|
}
|
|
4859
4912
|
}
|
|
4860
4913
|
|
|
4861
4914
|
// dist/classic/copy-and-blit.js
|
|
4862
4915
|
function readPixelsToArray(source, options) {
|
|
4863
|
-
var _a;
|
|
4916
|
+
var _a, _b;
|
|
4864
4917
|
const {
|
|
4865
4918
|
sourceX = 0,
|
|
4866
4919
|
sourceY = 0,
|
|
4867
|
-
sourceFormat =
|
|
4868
|
-
sourceAttachment =
|
|
4920
|
+
sourceFormat = 6408,
|
|
4921
|
+
sourceAttachment = 36064
|
|
4869
4922
|
// TODO - support gl.readBuffer
|
|
4870
4923
|
} = options || {};
|
|
4871
4924
|
let {
|
|
@@ -4876,31 +4929,31 @@ function readPixelsToArray(source, options) {
|
|
|
4876
4929
|
sourceType
|
|
4877
4930
|
} = options || {};
|
|
4878
4931
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
4879
|
-
(0,
|
|
4932
|
+
(0, import_core25.assert)(framebuffer);
|
|
4880
4933
|
const { gl, handle } = framebuffer;
|
|
4881
4934
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
4882
4935
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
4883
|
-
const attachment = sourceAttachment -
|
|
4884
|
-
sourceType = sourceType || ((_a = framebuffer.colorAttachments[attachment]) == null ? void 0 : _a.type) ||
|
|
4936
|
+
const attachment = sourceAttachment - 36064;
|
|
4937
|
+
sourceType = sourceType || ((_b = (_a = framebuffer.colorAttachments[attachment]) == null ? void 0 : _a.texture) == null ? void 0 : _b.type) || 5121;
|
|
4885
4938
|
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);
|
|
4886
4939
|
sourceType = sourceType || getGLTypeFromTypedArray(target);
|
|
4887
|
-
const prevHandle = gl.bindFramebuffer(
|
|
4940
|
+
const prevHandle = gl.bindFramebuffer(36160, handle);
|
|
4888
4941
|
gl.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
|
|
4889
|
-
gl.bindFramebuffer(
|
|
4942
|
+
gl.bindFramebuffer(36160, prevHandle || null);
|
|
4890
4943
|
if (deleteFramebuffer) {
|
|
4891
4944
|
framebuffer.destroy();
|
|
4892
4945
|
}
|
|
4893
4946
|
return target;
|
|
4894
4947
|
}
|
|
4895
4948
|
function readPixelsToBuffer(source, options) {
|
|
4896
|
-
const { target, sourceX = 0, sourceY = 0, sourceFormat =
|
|
4949
|
+
const { target, sourceX = 0, sourceY = 0, sourceFormat = 6408, targetByteOffset = 0 } = options || {};
|
|
4897
4950
|
let { sourceWidth, sourceHeight, sourceType } = options || {};
|
|
4898
4951
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
4899
|
-
(0,
|
|
4952
|
+
(0, import_core25.assert)(framebuffer);
|
|
4900
4953
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
4901
4954
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
4902
4955
|
const webglFramebuffer = framebuffer;
|
|
4903
|
-
sourceType = sourceType ||
|
|
4956
|
+
sourceType = sourceType || 5121;
|
|
4904
4957
|
let webglBufferTarget = target;
|
|
4905
4958
|
if (!webglBufferTarget) {
|
|
4906
4959
|
const components = glFormatToComponents(sourceFormat);
|
|
@@ -4924,7 +4977,7 @@ function readPixelsToBuffer(source, options) {
|
|
|
4924
4977
|
return webglBufferTarget;
|
|
4925
4978
|
}
|
|
4926
4979
|
function getFramebuffer2(source) {
|
|
4927
|
-
if (!(source instanceof
|
|
4980
|
+
if (!(source instanceof import_core25.Framebuffer)) {
|
|
4928
4981
|
return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
|
|
4929
4982
|
}
|
|
4930
4983
|
return { framebuffer: source, deleteFramebuffer: false };
|
|
@@ -4944,14 +4997,14 @@ function getPixelArray(pixelArray, type, format, width, height) {
|
|
|
4944
4997
|
if (pixelArray) {
|
|
4945
4998
|
return pixelArray;
|
|
4946
4999
|
}
|
|
4947
|
-
type = type ||
|
|
5000
|
+
type = type || 5121;
|
|
4948
5001
|
const ArrayType = getTypedArrayFromGLType(type, { clamped: false });
|
|
4949
5002
|
const components = glFormatToComponents(format);
|
|
4950
5003
|
return new ArrayType(width * height * components);
|
|
4951
5004
|
}
|
|
4952
5005
|
|
|
4953
5006
|
// dist/classic/clear.js
|
|
4954
|
-
var
|
|
5007
|
+
var import_core26 = require("@luma.gl/core");
|
|
4955
5008
|
var GL_DEPTH_BUFFER_BIT2 = 256;
|
|
4956
5009
|
var GL_STENCIL_BUFFER_BIT2 = 1024;
|
|
4957
5010
|
var GL_COLOR_BUFFER_BIT2 = 16384;
|
|
@@ -4981,37 +5034,33 @@ function clear(device, options) {
|
|
|
4981
5034
|
parameters.clearStencil = depth;
|
|
4982
5035
|
}
|
|
4983
5036
|
}
|
|
4984
|
-
(0,
|
|
4985
|
-
|
|
4986
|
-
|
|
5037
|
+
(0, import_core26.assert)(clearFlags !== 0, ERR_ARGUMENTS);
|
|
5038
|
+
const gl = device.gl;
|
|
5039
|
+
withGLParameters(gl, parameters, () => {
|
|
4987
5040
|
gl.clear(clearFlags);
|
|
4988
5041
|
});
|
|
4989
5042
|
}
|
|
4990
5043
|
|
|
4991
5044
|
// dist/adapter/webgl-device.js
|
|
4992
5045
|
var LOG_LEVEL2 = 1;
|
|
4993
|
-
var _WebGLDevice = class extends
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
5046
|
+
var _WebGLDevice = class extends import_core27.Device {
|
|
5047
|
+
/** type of this device */
|
|
5048
|
+
type = "webgl";
|
|
5049
|
+
/** The underlying WebGL context */
|
|
5050
|
+
handle;
|
|
5051
|
+
features;
|
|
5052
|
+
limits;
|
|
4997
5053
|
info;
|
|
4998
5054
|
canvasContext;
|
|
4999
|
-
handle;
|
|
5000
|
-
get features() {
|
|
5001
|
-
this._features = this._features || getDeviceFeatures(this.gl);
|
|
5002
|
-
return this._features;
|
|
5003
|
-
}
|
|
5004
|
-
get limits() {
|
|
5005
|
-
this._limits = this._limits || getDeviceLimits(this.gl);
|
|
5006
|
-
return this._limits;
|
|
5007
|
-
}
|
|
5008
5055
|
lost;
|
|
5009
5056
|
_resolveContextLost;
|
|
5010
|
-
_features;
|
|
5011
|
-
_limits;
|
|
5012
5057
|
//
|
|
5013
5058
|
// Static methods, expected to be present by `luma.createDevice()`
|
|
5014
5059
|
//
|
|
5060
|
+
/** Check if WebGL 2 is available */
|
|
5061
|
+
static isSupported() {
|
|
5062
|
+
return typeof WebGL2RenderingContext !== "undefined";
|
|
5063
|
+
}
|
|
5015
5064
|
/**
|
|
5016
5065
|
* Get a device instance from a GL context
|
|
5017
5066
|
* Creates and instruments the device if not already created
|
|
@@ -5022,7 +5071,7 @@ var _WebGLDevice = class extends import_core26.Device {
|
|
|
5022
5071
|
if (gl instanceof _WebGLDevice) {
|
|
5023
5072
|
return gl;
|
|
5024
5073
|
}
|
|
5025
|
-
if ((gl == null ? void 0 : gl.device) instanceof
|
|
5074
|
+
if ((gl == null ? void 0 : gl.device) instanceof import_core27.Device) {
|
|
5026
5075
|
return gl.device;
|
|
5027
5076
|
}
|
|
5028
5077
|
if (!isWebGL(gl)) {
|
|
@@ -5031,26 +5080,34 @@ var _WebGLDevice = class extends import_core26.Device {
|
|
|
5031
5080
|
return new _WebGLDevice({ gl });
|
|
5032
5081
|
}
|
|
5033
5082
|
static async create(props = {}) {
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5083
|
+
var _a;
|
|
5084
|
+
import_core27.log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
|
|
5085
|
+
const promises = [];
|
|
5086
|
+
if (props.debug) {
|
|
5087
|
+
promises.push(loadWebGLDeveloperTools());
|
|
5088
|
+
}
|
|
5089
|
+
if (props.spector) {
|
|
5090
|
+
promises.push(loadSpectorJS());
|
|
5037
5091
|
}
|
|
5038
|
-
if (
|
|
5039
|
-
|
|
5092
|
+
if (typeof props.canvas === "string") {
|
|
5093
|
+
promises.push(import_core27.CanvasContext.pageLoaded);
|
|
5040
5094
|
}
|
|
5041
|
-
const
|
|
5042
|
-
|
|
5043
|
-
|
|
5095
|
+
const results = await Promise.allSettled(promises);
|
|
5096
|
+
for (const result of results) {
|
|
5097
|
+
if (result.status === "rejected") {
|
|
5098
|
+
import_core27.log.error(`Failed to initialize debug libraries ${result.reason}`)();
|
|
5099
|
+
}
|
|
5044
5100
|
}
|
|
5045
|
-
|
|
5046
|
-
if (props.gl
|
|
5101
|
+
import_core27.log.probe(LOG_LEVEL2 + 1, "DOM is loaded")();
|
|
5102
|
+
if ((_a = props.gl) == null ? void 0 : _a.device) {
|
|
5103
|
+
import_core27.log.warn("reattaching existing device")();
|
|
5047
5104
|
return _WebGLDevice.attach(props.gl);
|
|
5048
5105
|
}
|
|
5049
5106
|
const device = new _WebGLDevice(props);
|
|
5050
|
-
const message2 = `Created ${device.
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5107
|
+
const message2 = `Created ${device.type}${device.debug ? " debug" : ""} context: ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContext.id}`;
|
|
5108
|
+
import_core27.log.probe(LOG_LEVEL2, message2)();
|
|
5109
|
+
import_core27.log.table(LOG_LEVEL2, device.info)();
|
|
5110
|
+
import_core27.log.groupEnd(LOG_LEVEL2)();
|
|
5054
5111
|
return device;
|
|
5055
5112
|
}
|
|
5056
5113
|
//
|
|
@@ -5058,54 +5115,60 @@ var _WebGLDevice = class extends import_core26.Device {
|
|
|
5058
5115
|
//
|
|
5059
5116
|
constructor(props) {
|
|
5060
5117
|
var _a, _b;
|
|
5061
|
-
super({ ...props, id: props.id || (0,
|
|
5118
|
+
super({ ...props, id: props.id || (0, import_core27.uid)("webgl-device") });
|
|
5062
5119
|
const device = (_a = props.gl) == null ? void 0 : _a.device;
|
|
5063
5120
|
if (device) {
|
|
5064
5121
|
throw new Error(`WebGL context already attached to device ${device.id}`);
|
|
5065
5122
|
}
|
|
5066
|
-
const canvas =
|
|
5123
|
+
const canvas = ((_b = props.gl) == null ? void 0 : _b.canvas) || props.canvas;
|
|
5067
5124
|
this.canvasContext = new WebGLCanvasContext(this, { ...props, canvas });
|
|
5068
5125
|
this.lost = new Promise((resolve) => {
|
|
5069
5126
|
this._resolveContextLost = resolve;
|
|
5070
5127
|
});
|
|
5071
|
-
const onContextLost = (event) => {
|
|
5072
|
-
var _a2;
|
|
5073
|
-
return (_a2 = this._resolveContextLost) == null ? void 0 : _a2.call(this, {
|
|
5074
|
-
reason: "destroyed",
|
|
5075
|
-
message: "Computer entered sleep mode, or too many apps or browser tabs are using the GPU."
|
|
5076
|
-
});
|
|
5077
|
-
};
|
|
5078
5128
|
let gl = props.gl || null;
|
|
5079
|
-
gl
|
|
5129
|
+
gl ||= createBrowserContext(this.canvasContext.canvas, {
|
|
5130
|
+
...props,
|
|
5131
|
+
onContextLost: (event) => {
|
|
5132
|
+
var _a2;
|
|
5133
|
+
return (_a2 = this._resolveContextLost) == null ? void 0 : _a2.call(this, {
|
|
5134
|
+
reason: "destroyed",
|
|
5135
|
+
message: "Entered sleep mode, or too many apps or browser tabs are using the GPU."
|
|
5136
|
+
});
|
|
5137
|
+
}
|
|
5138
|
+
});
|
|
5080
5139
|
if (!gl) {
|
|
5081
5140
|
throw new Error("WebGL context creation failed");
|
|
5082
5141
|
}
|
|
5083
5142
|
this.handle = gl;
|
|
5084
|
-
this.gl =
|
|
5085
|
-
this.canvasContext.resize();
|
|
5086
|
-
this.info = getDeviceInfo(this.gl);
|
|
5143
|
+
this.gl = gl;
|
|
5087
5144
|
this.gl.device = this;
|
|
5088
|
-
this.gl._version =
|
|
5145
|
+
this.gl._version = 2;
|
|
5146
|
+
this.info = getDeviceInfo(this.gl, this._extensions);
|
|
5147
|
+
this.limits = new WebGLDeviceLimits(this.gl);
|
|
5148
|
+
this.features = new WebGLDeviceFeatures(this.gl, this._extensions, this.props.disabledFeatures);
|
|
5149
|
+
if (this.props.initalizeFeatures) {
|
|
5150
|
+
this.features.initializeFeatures();
|
|
5151
|
+
}
|
|
5152
|
+
this.canvasContext.resize();
|
|
5089
5153
|
const { enable: enable2 = true, copyState = false } = props;
|
|
5090
5154
|
trackContextState(this.gl, {
|
|
5091
5155
|
enable: enable2,
|
|
5092
5156
|
copyState,
|
|
5093
|
-
log: (...args) =>
|
|
5157
|
+
log: (...args) => import_core27.log.log(1, ...args)()
|
|
5094
5158
|
});
|
|
5095
|
-
if (
|
|
5159
|
+
if (props.debug) {
|
|
5096
5160
|
this.gl = makeDebugContext(this.gl, { ...props, throwOnError: true });
|
|
5097
5161
|
this.debug = true;
|
|
5098
|
-
|
|
5099
|
-
|
|
5162
|
+
import_core27.log.level = Math.max(import_core27.log.level, 1);
|
|
5163
|
+
import_core27.log.warn("WebGL debug mode activated. Performance reduced.")();
|
|
5100
5164
|
}
|
|
5101
|
-
if (
|
|
5102
|
-
|
|
5103
|
-
this.spector = initializeSpectorJS({ ...this.props, canvas: canvas2 });
|
|
5165
|
+
if (props.spector) {
|
|
5166
|
+
this.spectorJS = initializeSpectorJS({ ...this.props, canvas: this.handle.canvas });
|
|
5104
5167
|
}
|
|
5105
5168
|
}
|
|
5106
5169
|
/**
|
|
5107
5170
|
* Destroys the context
|
|
5108
|
-
* @note Has no effect for browser contexts, there is no browser API for destroying contexts
|
|
5171
|
+
* @note Has no effect for WebGL browser contexts, there is no browser API for destroying contexts
|
|
5109
5172
|
*/
|
|
5110
5173
|
destroy() {
|
|
5111
5174
|
}
|
|
@@ -5116,13 +5179,13 @@ var _WebGLDevice = class extends import_core26.Device {
|
|
|
5116
5179
|
return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];
|
|
5117
5180
|
}
|
|
5118
5181
|
isTextureFormatSupported(format) {
|
|
5119
|
-
return isTextureFormatSupported(this.gl, format);
|
|
5182
|
+
return isTextureFormatSupported(this.gl, format, this._extensions);
|
|
5120
5183
|
}
|
|
5121
5184
|
isTextureFormatFilterable(format) {
|
|
5122
|
-
return isTextureFormatFilterable(this.gl, format);
|
|
5185
|
+
return isTextureFormatFilterable(this.gl, format, this._extensions);
|
|
5123
5186
|
}
|
|
5124
5187
|
isTextureFormatRenderable(format) {
|
|
5125
|
-
return isTextureFormatRenderable(this.gl, format);
|
|
5188
|
+
return isTextureFormatRenderable(this.gl, format, this._extensions);
|
|
5126
5189
|
}
|
|
5127
5190
|
// IMPLEMENTATION OF ABSTRACT DEVICE
|
|
5128
5191
|
createCanvasContext(props) {
|
|
@@ -5147,12 +5210,18 @@ var _WebGLDevice = class extends import_core26.Device {
|
|
|
5147
5210
|
createFramebuffer(props) {
|
|
5148
5211
|
return new WEBGLFramebuffer(this, props);
|
|
5149
5212
|
}
|
|
5150
|
-
createRenderPipeline(props) {
|
|
5151
|
-
return new WEBGLRenderPipeline(this, props);
|
|
5152
|
-
}
|
|
5153
5213
|
createVertexArray(props) {
|
|
5154
5214
|
return new WEBGLVertexArray(this, props);
|
|
5155
5215
|
}
|
|
5216
|
+
createTransformFeedback(props) {
|
|
5217
|
+
return new WEBGLTransformFeedback(this, props);
|
|
5218
|
+
}
|
|
5219
|
+
createQuerySet(props) {
|
|
5220
|
+
return new WEBGLQuerySet(this, props);
|
|
5221
|
+
}
|
|
5222
|
+
createRenderPipeline(props) {
|
|
5223
|
+
return new WEBGLRenderPipeline(this, props);
|
|
5224
|
+
}
|
|
5156
5225
|
beginRenderPass(props) {
|
|
5157
5226
|
return new WEBGLRenderPass(this, props);
|
|
5158
5227
|
}
|
|
@@ -5162,16 +5231,7 @@ var _WebGLDevice = class extends import_core26.Device {
|
|
|
5162
5231
|
beginComputePass(props) {
|
|
5163
5232
|
throw new Error("ComputePass not supported in WebGL");
|
|
5164
5233
|
}
|
|
5165
|
-
createTransformFeedback(props) {
|
|
5166
|
-
return new WEBGLTransformFeedback(this, props);
|
|
5167
|
-
}
|
|
5168
5234
|
renderPass = null;
|
|
5169
|
-
getDefaultRenderPass() {
|
|
5170
|
-
this.renderPass = this.renderPass || this.beginRenderPass({
|
|
5171
|
-
framebuffer: this.canvasContext.getCurrentFramebuffer()
|
|
5172
|
-
});
|
|
5173
|
-
return this.renderPass;
|
|
5174
|
-
}
|
|
5175
5235
|
createCommandEncoder(props) {
|
|
5176
5236
|
return new WEBGLCommandEncoder(this, props);
|
|
5177
5237
|
}
|
|
@@ -5187,7 +5247,7 @@ var _WebGLDevice = class extends import_core26.Device {
|
|
|
5187
5247
|
}
|
|
5188
5248
|
//
|
|
5189
5249
|
// TEMPORARY HACKS - will be removed in v9.1
|
|
5190
|
-
//
|
|
5250
|
+
//
|
|
5191
5251
|
/** @deprecated - should use command encoder */
|
|
5192
5252
|
readPixelsToArrayWebGL(source, options) {
|
|
5193
5253
|
return readPixelsToArray(source, options);
|
|
@@ -5197,13 +5257,13 @@ var _WebGLDevice = class extends import_core26.Device {
|
|
|
5197
5257
|
return readPixelsToBuffer(source, options);
|
|
5198
5258
|
}
|
|
5199
5259
|
setParametersWebGL(parameters) {
|
|
5200
|
-
setGLParameters(this, parameters);
|
|
5260
|
+
setGLParameters(this.gl, parameters);
|
|
5201
5261
|
}
|
|
5202
5262
|
getParametersWebGL(parameters) {
|
|
5203
|
-
return getGLParameters(this, parameters);
|
|
5263
|
+
return getGLParameters(this.gl, parameters);
|
|
5204
5264
|
}
|
|
5205
5265
|
withParametersWebGL(parameters, func) {
|
|
5206
|
-
withGLParameters(this, parameters, func);
|
|
5266
|
+
withGLParameters(this.gl, parameters, func);
|
|
5207
5267
|
}
|
|
5208
5268
|
clearWebGL(options) {
|
|
5209
5269
|
clear(this, options);
|
|
@@ -5220,13 +5280,7 @@ var _WebGLDevice = class extends import_core26.Device {
|
|
|
5220
5280
|
_extensions = {};
|
|
5221
5281
|
_polyfilled = false;
|
|
5222
5282
|
/** Instance of Spector.js (if initialized) */
|
|
5223
|
-
|
|
5224
|
-
_webglLimits;
|
|
5225
|
-
/** Return WebGL specific limits */
|
|
5226
|
-
get webglLimits() {
|
|
5227
|
-
this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);
|
|
5228
|
-
return this._webglLimits;
|
|
5229
|
-
}
|
|
5283
|
+
spectorJS;
|
|
5230
5284
|
/**
|
|
5231
5285
|
* Triggers device (or WebGL context) loss.
|
|
5232
5286
|
* @note primarily intended for testing how application reacts to device loss
|
|
@@ -5234,7 +5288,8 @@ var _WebGLDevice = class extends import_core26.Device {
|
|
|
5234
5288
|
loseDevice() {
|
|
5235
5289
|
var _a;
|
|
5236
5290
|
let deviceLossTriggered = false;
|
|
5237
|
-
const
|
|
5291
|
+
const extensions = this.getExtension("WEBGL_lose_context");
|
|
5292
|
+
const ext = extensions.WEBGL_lose_context;
|
|
5238
5293
|
if (ext) {
|
|
5239
5294
|
deviceLossTriggered = true;
|
|
5240
5295
|
ext.loseContext();
|
|
@@ -5283,11 +5338,12 @@ var _WebGLDevice = class extends import_core26.Device {
|
|
|
5283
5338
|
* so they need to be updated before every render
|
|
5284
5339
|
* @todo - remember/cache values to avoid setting them unnecessarily?
|
|
5285
5340
|
*/
|
|
5286
|
-
|
|
5287
|
-
|
|
5341
|
+
setConstantAttributeWebGL(location, constant) {
|
|
5342
|
+
const maxVertexAttributes = this.limits.maxVertexAttributes;
|
|
5343
|
+
this._constants = this._constants || new Array(maxVertexAttributes).fill(null);
|
|
5288
5344
|
const currentConstant = this._constants[location];
|
|
5289
5345
|
if (currentConstant && compareConstantArrayValues2(currentConstant, constant)) {
|
|
5290
|
-
|
|
5346
|
+
import_core27.log.info(1, `setConstantAttributeWebGL(${location}) could have been skipped, value unchanged`)();
|
|
5291
5347
|
}
|
|
5292
5348
|
this._constants[location] = constant;
|
|
5293
5349
|
switch (constant.constructor) {
|
|
@@ -5301,14 +5357,20 @@ var _WebGLDevice = class extends import_core26.Device {
|
|
|
5301
5357
|
setConstantUintArray(this, location, constant);
|
|
5302
5358
|
break;
|
|
5303
5359
|
default:
|
|
5304
|
-
(0,
|
|
5360
|
+
(0, import_core27.assert)(false);
|
|
5305
5361
|
}
|
|
5306
5362
|
}
|
|
5363
|
+
/** Ensure extensions are only requested once */
|
|
5364
|
+
getExtension(name) {
|
|
5365
|
+
getWebGLExtension(this.gl, name, this._extensions);
|
|
5366
|
+
return this._extensions;
|
|
5367
|
+
}
|
|
5307
5368
|
};
|
|
5308
5369
|
var WebGLDevice = _WebGLDevice;
|
|
5309
5370
|
//
|
|
5310
5371
|
// Public `Device` API
|
|
5311
5372
|
//
|
|
5373
|
+
/** type of this device */
|
|
5312
5374
|
__publicField(WebGLDevice, "type", "webgl");
|
|
5313
5375
|
function isWebGL(gl) {
|
|
5314
5376
|
if (typeof WebGL2RenderingContext !== "undefined" && gl instanceof WebGL2RenderingContext) {
|
|
@@ -5331,7 +5393,7 @@ function setConstantFloatArray(device, location, array) {
|
|
|
5331
5393
|
device.gl.vertexAttrib4fv(location, array);
|
|
5332
5394
|
break;
|
|
5333
5395
|
default:
|
|
5334
|
-
(0,
|
|
5396
|
+
(0, import_core27.assert)(false);
|
|
5335
5397
|
}
|
|
5336
5398
|
}
|
|
5337
5399
|
function setConstantIntArray(device, location, array) {
|
|
@@ -5351,4 +5413,174 @@ function compareConstantArrayValues2(v1, v2) {
|
|
|
5351
5413
|
}
|
|
5352
5414
|
return true;
|
|
5353
5415
|
}
|
|
5416
|
+
|
|
5417
|
+
// dist/adapter/objects/webgl-resource.js
|
|
5418
|
+
var import_core28 = require("@luma.gl/core");
|
|
5419
|
+
var ERR_RESOURCE_METHOD_UNDEFINED = "Resource subclass must define virtual methods";
|
|
5420
|
+
var WebGLResource = class extends import_core28.Resource {
|
|
5421
|
+
device;
|
|
5422
|
+
gl;
|
|
5423
|
+
gl2;
|
|
5424
|
+
_handle;
|
|
5425
|
+
_bound = false;
|
|
5426
|
+
// Only meaningful for resources that allocate GPU memory
|
|
5427
|
+
byteLength = 0;
|
|
5428
|
+
constructor(device, props, defaultProps) {
|
|
5429
|
+
super(device, props, defaultProps);
|
|
5430
|
+
this.device = device;
|
|
5431
|
+
const gl = this.device.gl;
|
|
5432
|
+
const { id } = props || {};
|
|
5433
|
+
this.gl = gl;
|
|
5434
|
+
this.gl2 = gl;
|
|
5435
|
+
this.id = id || (0, import_core28.uid)(this.constructor.name);
|
|
5436
|
+
this._handle = props == null ? void 0 : props.handle;
|
|
5437
|
+
if (this._handle === void 0) {
|
|
5438
|
+
this._handle = this._createHandle();
|
|
5439
|
+
}
|
|
5440
|
+
this.byteLength = 0;
|
|
5441
|
+
}
|
|
5442
|
+
toString() {
|
|
5443
|
+
return `${this.constructor.name}(${this.id})`;
|
|
5444
|
+
}
|
|
5445
|
+
get handle() {
|
|
5446
|
+
return this._handle;
|
|
5447
|
+
}
|
|
5448
|
+
delete({ deleteChildren = false } = {}) {
|
|
5449
|
+
const children = this._handle && this._deleteHandle(this._handle);
|
|
5450
|
+
if (this._handle) {
|
|
5451
|
+
this.removeStats();
|
|
5452
|
+
}
|
|
5453
|
+
this._handle = null;
|
|
5454
|
+
if (children && deleteChildren) {
|
|
5455
|
+
children.filter(Boolean).forEach((child) => child.destroy());
|
|
5456
|
+
}
|
|
5457
|
+
return this;
|
|
5458
|
+
}
|
|
5459
|
+
bind(funcOrHandle = this.handle) {
|
|
5460
|
+
if (typeof funcOrHandle !== "function") {
|
|
5461
|
+
this._bindHandle(funcOrHandle);
|
|
5462
|
+
return this;
|
|
5463
|
+
}
|
|
5464
|
+
let value;
|
|
5465
|
+
if (!this._bound) {
|
|
5466
|
+
this._bindHandle(this.handle);
|
|
5467
|
+
this._bound = true;
|
|
5468
|
+
value = funcOrHandle();
|
|
5469
|
+
this._bound = false;
|
|
5470
|
+
this._bindHandle(null);
|
|
5471
|
+
} else {
|
|
5472
|
+
value = funcOrHandle();
|
|
5473
|
+
}
|
|
5474
|
+
return value;
|
|
5475
|
+
}
|
|
5476
|
+
unbind() {
|
|
5477
|
+
this.bind(null);
|
|
5478
|
+
}
|
|
5479
|
+
// Install stubs for removed methods
|
|
5480
|
+
stubRemovedMethods(className, version, methodNames) {
|
|
5481
|
+
return (0, import_core28.stubRemovedMethods)(this, className, version, methodNames);
|
|
5482
|
+
}
|
|
5483
|
+
// PUBLIC VIRTUAL METHODS
|
|
5484
|
+
initialize(props) {
|
|
5485
|
+
}
|
|
5486
|
+
// PROTECTED METHODS - These must be overridden by subclass
|
|
5487
|
+
_createHandle() {
|
|
5488
|
+
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5489
|
+
}
|
|
5490
|
+
_deleteHandle() {
|
|
5491
|
+
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5492
|
+
}
|
|
5493
|
+
_bindHandle(handle) {
|
|
5494
|
+
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5495
|
+
}
|
|
5496
|
+
_getOptsFromHandle() {
|
|
5497
|
+
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5498
|
+
}
|
|
5499
|
+
_getParameter(pname, props) {
|
|
5500
|
+
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5501
|
+
}
|
|
5502
|
+
_setParameter(pname, value) {
|
|
5503
|
+
throw new Error(ERR_RESOURCE_METHOD_UNDEFINED);
|
|
5504
|
+
}
|
|
5505
|
+
};
|
|
5506
|
+
|
|
5507
|
+
// dist/adapter/objects/webgl-renderbuffer.js
|
|
5508
|
+
var import_core29 = require("@luma.gl/core");
|
|
5509
|
+
var import_constants28 = require("@luma.gl/constants");
|
|
5510
|
+
var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
5511
|
+
get [Symbol.toStringTag]() {
|
|
5512
|
+
return "Renderbuffer";
|
|
5513
|
+
}
|
|
5514
|
+
get width() {
|
|
5515
|
+
return this.props.width;
|
|
5516
|
+
}
|
|
5517
|
+
get height() {
|
|
5518
|
+
return this.props.height;
|
|
5519
|
+
}
|
|
5520
|
+
get format() {
|
|
5521
|
+
return this.props.format;
|
|
5522
|
+
}
|
|
5523
|
+
get samples() {
|
|
5524
|
+
return this.props.samples;
|
|
5525
|
+
}
|
|
5526
|
+
get attachment() {
|
|
5527
|
+
return;
|
|
5528
|
+
}
|
|
5529
|
+
/** WebGL format constant */
|
|
5530
|
+
glFormat;
|
|
5531
|
+
static isTextureFormatSupported(device, format) {
|
|
5532
|
+
return isRenderbufferFormatSupported(device.gl, format, device._extensions);
|
|
5533
|
+
}
|
|
5534
|
+
constructor(device, props) {
|
|
5535
|
+
if (typeof props.format === "number") {
|
|
5536
|
+
throw new Error("Renderbuffer");
|
|
5537
|
+
}
|
|
5538
|
+
super(device, props, _WEBGLRenderbuffer.defaultProps);
|
|
5539
|
+
this.glFormat = convertTextureFormatToGL(this.props.format);
|
|
5540
|
+
this._initialize(this.props);
|
|
5541
|
+
}
|
|
5542
|
+
resize(size) {
|
|
5543
|
+
if (size.width !== this.width || size.height !== this.height) {
|
|
5544
|
+
Object.assign(this.props, { ...size, format: this.format, samples: this.samples });
|
|
5545
|
+
this._initialize(this.props);
|
|
5546
|
+
}
|
|
5547
|
+
}
|
|
5548
|
+
// PRIVATE METHODS
|
|
5549
|
+
/** Creates and initializes a renderbuffer object's data store */
|
|
5550
|
+
_initialize(props) {
|
|
5551
|
+
const { format, width, height, samples } = props;
|
|
5552
|
+
(0, import_core29.assert)(format, "Needs format");
|
|
5553
|
+
this.trackDeallocatedMemory();
|
|
5554
|
+
this.gl.bindRenderbuffer(36161, this.handle);
|
|
5555
|
+
if (samples !== 0) {
|
|
5556
|
+
this.gl.renderbufferStorageMultisample(36161, samples, this.glFormat, width, height);
|
|
5557
|
+
} else {
|
|
5558
|
+
this.gl.renderbufferStorage(36161, this.glFormat, width, height);
|
|
5559
|
+
}
|
|
5560
|
+
this.gl.bindRenderbuffer(36161, null);
|
|
5561
|
+
this.trackAllocatedMemory(width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.format));
|
|
5562
|
+
}
|
|
5563
|
+
// RESOURCE IMPLEMENTATION
|
|
5564
|
+
_createHandle() {
|
|
5565
|
+
return this.gl.createRenderbuffer();
|
|
5566
|
+
}
|
|
5567
|
+
_deleteHandle() {
|
|
5568
|
+
this.gl.deleteRenderbuffer(this.handle);
|
|
5569
|
+
this.trackDeallocatedMemory();
|
|
5570
|
+
}
|
|
5571
|
+
_bindHandle(handle) {
|
|
5572
|
+
this.gl.bindRenderbuffer(36161, handle);
|
|
5573
|
+
}
|
|
5574
|
+
};
|
|
5575
|
+
var WEBGLRenderbuffer = _WEBGLRenderbuffer;
|
|
5576
|
+
__publicField(WEBGLRenderbuffer, "defaultProps", {
|
|
5577
|
+
id: void 0,
|
|
5578
|
+
handle: void 0,
|
|
5579
|
+
userData: void 0,
|
|
5580
|
+
format: void 0,
|
|
5581
|
+
// 'depth16unorm'
|
|
5582
|
+
width: 1,
|
|
5583
|
+
height: 1,
|
|
5584
|
+
samples: 0
|
|
5585
|
+
});
|
|
5354
5586
|
//# sourceMappingURL=index.cjs.map
|