@luma.gl/webgl 9.0.0-alpha.24 → 9.0.0-alpha.26
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 +1 -1
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +1 -1
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/sampler-parameters.js.map +1 -1
- package/dist/adapter/converters/texture-formats.d.ts +1 -1
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +1 -1
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +1 -1
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/device-limits.d.ts +1 -1
- package/dist/adapter/device-helpers/device-limits.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-limits.js +1 -1
- package/dist/adapter/device-helpers/device-limits.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +1 -1
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/helpers/attribute-utils.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +1 -1
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +1 -1
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/uniforms.js.map +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +1 -1
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- 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 +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +1 -1
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +1 -0
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.js +2 -2
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/accessor.d.ts +1 -1
- package/dist/classic/accessor.d.ts.map +1 -1
- package/dist/classic/accessor.js +1 -1
- package/dist/classic/accessor.js.map +1 -1
- package/dist/classic/{buffer.d.ts → buffer-with-accessor.d.ts} +8 -8
- package/dist/classic/buffer-with-accessor.d.ts.map +1 -0
- package/dist/classic/{buffer.js → buffer-with-accessor.js} +3 -3
- package/dist/classic/buffer-with-accessor.js.map +1 -0
- package/dist/classic/clear.js.map +1 -1
- package/dist/classic/copy-and-blit.d.ts +18 -1
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +69 -3
- package/dist/classic/copy-and-blit.js.map +1 -1
- package/dist/classic/format-utils.js +1 -1
- package/dist/classic/format-utils.js.map +1 -1
- package/dist/classic/typed-array-utils.js.map +1 -1
- package/dist/context/context/create-browser-context.js.map +1 -1
- package/dist/context/debug/spector.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +1 -1
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.js +3 -3
- package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.js +1 -1
- package/dist/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/context/polyfill/polyfill-vertex-array-object.js.map +1 -1
- package/dist/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/dist.dev.js +687 -649
- package/dist/index.cjs +1120 -1037
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist.min.js +22 -22
- package/package.json +5 -5
- package/src/adapter/converters/device-parameters.ts +1 -1
- package/src/adapter/converters/texture-formats.ts +1 -1
- package/src/adapter/converters/vertex-formats.ts +1 -1
- package/src/adapter/device-helpers/device-limits.ts +1 -1
- package/src/adapter/device-helpers/get-device-info.ts +1 -1
- package/src/adapter/helpers/get-shader-layout.ts +1 -1
- package/src/adapter/helpers/set-uniform.ts +1 -1
- package/src/adapter/objects/constants-to-keys.ts +1 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +1 -1
- package/src/adapter/objects/webgl-resource.ts +1 -1
- package/src/adapter/objects/webgl-vertex-array-object.ts +1 -1
- package/src/adapter/resources/webgl-buffer.ts +1 -1
- package/src/adapter/resources/webgl-command-buffer.ts +1 -1
- package/src/adapter/resources/webgl-framebuffer.ts +1 -1
- package/src/adapter/resources/webgl-render-pipeline.ts +1 -1
- package/src/adapter/resources/webgl-shader.ts +1 -1
- package/src/adapter/webgl-canvas-context.ts +2 -1
- package/src/adapter/webgl-device.ts +2 -2
- package/src/classic/accessor.ts +1 -1
- package/src/classic/{buffer.ts → buffer-with-accessor.ts} +9 -9
- package/src/classic/copy-and-blit.ts +122 -2
- package/src/classic/format-utils.ts +1 -1
- package/src/context/debug/webgl-developer-tools.ts +1 -1
- package/src/context/polyfill/get-parameter-polyfill.ts +1 -1
- package/src/context/polyfill/polyfill-table.ts +1 -1
- package/src/index.ts +3 -3
- package/dist/classic/buffer.d.ts.map +0 -1
- package/dist/classic/buffer.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
6
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
8
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
9
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -33,14 +31,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
33
31
|
}
|
|
34
32
|
return to;
|
|
35
33
|
};
|
|
36
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
41
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
42
|
-
mod
|
|
43
|
-
));
|
|
44
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
35
|
var __async = (__this, __arguments, generator) => {
|
|
46
36
|
return new Promise((resolve, reject) => {
|
|
@@ -67,8 +57,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
67
57
|
var src_exports = {};
|
|
68
58
|
__export(src_exports, {
|
|
69
59
|
Accessor: () => Accessor,
|
|
70
|
-
|
|
71
|
-
ClassicBuffer: () => ClassicBuffer,
|
|
60
|
+
BufferWithAccessor: () => BufferWithAccessor,
|
|
72
61
|
WEBGLBuffer: () => WEBGLBuffer,
|
|
73
62
|
WEBGLCommandEncoder: () => WEBGLCommandEncoder,
|
|
74
63
|
WEBGLFramebuffer: () => WEBGLFramebuffer,
|
|
@@ -89,6 +78,7 @@ __export(src_exports, {
|
|
|
89
78
|
assertWebGLContext: () => assertWebGLContext,
|
|
90
79
|
clear: () => clear,
|
|
91
80
|
convertGLToTextureFormat: () => convertGLToTextureFormat,
|
|
81
|
+
copyToTexture: () => copyToTexture,
|
|
92
82
|
getParameters: () => getParameters,
|
|
93
83
|
getProgramBindings: () => getProgramBindings,
|
|
94
84
|
getShaderLayout: () => getShaderLayout,
|
|
@@ -135,11 +125,11 @@ function createHeadlessContext(options) {
|
|
|
135
125
|
if (!headlessGL) {
|
|
136
126
|
throw new Error(ERR_HEADLESSGL_LOAD);
|
|
137
127
|
}
|
|
138
|
-
const
|
|
139
|
-
if (!
|
|
128
|
+
const gl2 = headlessGL(width, height, options);
|
|
129
|
+
if (!gl2) {
|
|
140
130
|
throw new Error(ERR_HEADLESSGL_FAILED);
|
|
141
131
|
}
|
|
142
|
-
return
|
|
132
|
+
return gl2;
|
|
143
133
|
}
|
|
144
134
|
|
|
145
135
|
// src/adapter/webgl-device.ts
|
|
@@ -167,43 +157,43 @@ function synthesizeGLError(err, opt_msg) {
|
|
|
167
157
|
error(opt_msg);
|
|
168
158
|
}
|
|
169
159
|
}
|
|
170
|
-
function wrapGLError(
|
|
171
|
-
const f =
|
|
172
|
-
|
|
160
|
+
function wrapGLError(gl2) {
|
|
161
|
+
const f = gl2.getError;
|
|
162
|
+
gl2.getError = function getError() {
|
|
173
163
|
let err;
|
|
174
164
|
do {
|
|
175
|
-
err = f.apply(
|
|
176
|
-
if (err !==
|
|
165
|
+
err = f.apply(gl2);
|
|
166
|
+
if (err !== gl2.NO_ERROR) {
|
|
177
167
|
glErrorShadow[err] = true;
|
|
178
168
|
}
|
|
179
|
-
} while (err !==
|
|
169
|
+
} while (err !== gl2.NO_ERROR);
|
|
180
170
|
for (err in glErrorShadow) {
|
|
181
171
|
if (glErrorShadow[err]) {
|
|
182
172
|
delete glErrorShadow[err];
|
|
183
173
|
return parseInt(err, 10);
|
|
184
174
|
}
|
|
185
175
|
}
|
|
186
|
-
return
|
|
176
|
+
return gl2.NO_ERROR;
|
|
187
177
|
};
|
|
188
178
|
}
|
|
189
179
|
var WebGLVertexArrayObjectOES = function WebGLVertexArrayObjectOES2(ext) {
|
|
190
|
-
const
|
|
180
|
+
const gl2 = ext.gl;
|
|
191
181
|
this.ext = ext;
|
|
192
182
|
this.isAlive = true;
|
|
193
183
|
this.hasBeenBound = false;
|
|
194
184
|
this.elementArrayBuffer = null;
|
|
195
185
|
this.attribs = new Array(ext.maxVertexAttribs);
|
|
196
186
|
for (let n = 0; n < this.attribs.length; n++) {
|
|
197
|
-
const attrib = new WebGLVertexArrayObjectOES2.VertexAttrib(
|
|
187
|
+
const attrib = new WebGLVertexArrayObjectOES2.VertexAttrib(gl2);
|
|
198
188
|
this.attribs[n] = attrib;
|
|
199
189
|
}
|
|
200
190
|
this.maxAttrib = 0;
|
|
201
191
|
};
|
|
202
|
-
WebGLVertexArrayObjectOES.VertexAttrib = function VertexAttrib(
|
|
192
|
+
WebGLVertexArrayObjectOES.VertexAttrib = function VertexAttrib(gl2) {
|
|
203
193
|
this.enabled = false;
|
|
204
194
|
this.buffer = null;
|
|
205
195
|
this.size = 4;
|
|
206
|
-
this.type =
|
|
196
|
+
this.type = gl2.FLOAT;
|
|
207
197
|
this.normalized = false;
|
|
208
198
|
this.stride = 16;
|
|
209
199
|
this.offset = 0;
|
|
@@ -213,19 +203,19 @@ WebGLVertexArrayObjectOES.VertexAttrib = function VertexAttrib(gl) {
|
|
|
213
203
|
WebGLVertexArrayObjectOES.VertexAttrib.prototype.recache = function recache() {
|
|
214
204
|
this.cached = [this.size, this.type, this.normalized, this.stride, this.offset].join(":");
|
|
215
205
|
};
|
|
216
|
-
var OESVertexArrayObject = function OESVertexArrayObject2(
|
|
206
|
+
var OESVertexArrayObject = function OESVertexArrayObject2(gl2) {
|
|
217
207
|
const self = this;
|
|
218
|
-
this.gl =
|
|
219
|
-
wrapGLError(
|
|
208
|
+
this.gl = gl2;
|
|
209
|
+
wrapGLError(gl2);
|
|
220
210
|
const original = this.original = {
|
|
221
|
-
getParameter:
|
|
222
|
-
enableVertexAttribArray:
|
|
223
|
-
disableVertexAttribArray:
|
|
224
|
-
bindBuffer:
|
|
225
|
-
getVertexAttrib:
|
|
226
|
-
vertexAttribPointer:
|
|
211
|
+
getParameter: gl2.getParameter,
|
|
212
|
+
enableVertexAttribArray: gl2.enableVertexAttribArray,
|
|
213
|
+
disableVertexAttribArray: gl2.disableVertexAttribArray,
|
|
214
|
+
bindBuffer: gl2.bindBuffer,
|
|
215
|
+
getVertexAttrib: gl2.getVertexAttrib,
|
|
216
|
+
vertexAttribPointer: gl2.vertexAttribPointer
|
|
227
217
|
};
|
|
228
|
-
|
|
218
|
+
gl2.getParameter = function getParameter(pname) {
|
|
229
219
|
if (pname === self.VERTEX_ARRAY_BINDING_OES) {
|
|
230
220
|
if (self.currentVertexArrayObject === self.defaultVertexArrayObject) {
|
|
231
221
|
return null;
|
|
@@ -234,53 +224,53 @@ var OESVertexArrayObject = function OESVertexArrayObject2(gl) {
|
|
|
234
224
|
}
|
|
235
225
|
return original.getParameter.apply(this, arguments);
|
|
236
226
|
};
|
|
237
|
-
|
|
227
|
+
gl2.enableVertexAttribArray = function enableVertexAttribArray(index) {
|
|
238
228
|
const vao = self.currentVertexArrayObject;
|
|
239
229
|
vao.maxAttrib = Math.max(vao.maxAttrib, index);
|
|
240
230
|
const attrib = vao.attribs[index];
|
|
241
231
|
attrib.enabled = true;
|
|
242
232
|
return original.enableVertexAttribArray.apply(this, arguments);
|
|
243
233
|
};
|
|
244
|
-
|
|
234
|
+
gl2.disableVertexAttribArray = function disableVertexAttribArray(index) {
|
|
245
235
|
const vao = self.currentVertexArrayObject;
|
|
246
236
|
vao.maxAttrib = Math.max(vao.maxAttrib, index);
|
|
247
237
|
const attrib = vao.attribs[index];
|
|
248
238
|
attrib.enabled = false;
|
|
249
239
|
return original.disableVertexAttribArray.apply(this, arguments);
|
|
250
240
|
};
|
|
251
|
-
|
|
241
|
+
gl2.bindBuffer = function bindBuffer2(target, buffer) {
|
|
252
242
|
switch (target) {
|
|
253
|
-
case
|
|
243
|
+
case gl2.ARRAY_BUFFER:
|
|
254
244
|
self.currentArrayBuffer = buffer;
|
|
255
245
|
break;
|
|
256
|
-
case
|
|
246
|
+
case gl2.ELEMENT_ARRAY_BUFFER:
|
|
257
247
|
self.currentVertexArrayObject.elementArrayBuffer = buffer;
|
|
258
248
|
break;
|
|
259
249
|
default:
|
|
260
250
|
}
|
|
261
251
|
return original.bindBuffer.apply(this, arguments);
|
|
262
252
|
};
|
|
263
|
-
|
|
253
|
+
gl2.getVertexAttrib = function getVertexAttrib(index, pname) {
|
|
264
254
|
const vao = self.currentVertexArrayObject;
|
|
265
255
|
const attrib = vao.attribs[index];
|
|
266
256
|
switch (pname) {
|
|
267
|
-
case
|
|
257
|
+
case gl2.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
|
|
268
258
|
return attrib.buffer;
|
|
269
|
-
case
|
|
259
|
+
case gl2.VERTEX_ATTRIB_ARRAY_ENABLED:
|
|
270
260
|
return attrib.enabled;
|
|
271
|
-
case
|
|
261
|
+
case gl2.VERTEX_ATTRIB_ARRAY_SIZE:
|
|
272
262
|
return attrib.size;
|
|
273
|
-
case
|
|
263
|
+
case gl2.VERTEX_ATTRIB_ARRAY_STRIDE:
|
|
274
264
|
return attrib.stride;
|
|
275
|
-
case
|
|
265
|
+
case gl2.VERTEX_ATTRIB_ARRAY_TYPE:
|
|
276
266
|
return attrib.type;
|
|
277
|
-
case
|
|
267
|
+
case gl2.VERTEX_ATTRIB_ARRAY_NORMALIZED:
|
|
278
268
|
return attrib.normalized;
|
|
279
269
|
default:
|
|
280
270
|
return original.getVertexAttrib.apply(this, arguments);
|
|
281
271
|
}
|
|
282
272
|
};
|
|
283
|
-
|
|
273
|
+
gl2.vertexAttribPointer = function vertexAttribPointer(indx, size, type, normalized, stride, offset) {
|
|
284
274
|
const vao = self.currentVertexArrayObject;
|
|
285
275
|
vao.maxAttrib = Math.max(vao.maxAttrib, indx);
|
|
286
276
|
const attrib = vao.attribs[indx];
|
|
@@ -293,11 +283,11 @@ var OESVertexArrayObject = function OESVertexArrayObject2(gl) {
|
|
|
293
283
|
attrib.recache();
|
|
294
284
|
return original.vertexAttribPointer.apply(this, arguments);
|
|
295
285
|
};
|
|
296
|
-
if (
|
|
297
|
-
|
|
286
|
+
if (gl2.instrumentExtension) {
|
|
287
|
+
gl2.instrumentExtension(this, "OES_vertex_array_object");
|
|
298
288
|
}
|
|
299
|
-
if (
|
|
300
|
-
|
|
289
|
+
if (gl2.canvas) {
|
|
290
|
+
gl2.canvas.addEventListener(
|
|
301
291
|
"webglcontextrestored",
|
|
302
292
|
() => {
|
|
303
293
|
log("OESVertexArrayObject emulation library context restored");
|
|
@@ -316,8 +306,8 @@ OESVertexArrayObject.prototype.reset_ = function reset_() {
|
|
|
316
306
|
this.vertexArrayObjects.isAlive = false;
|
|
317
307
|
}
|
|
318
308
|
}
|
|
319
|
-
const
|
|
320
|
-
this.maxVertexAttribs =
|
|
309
|
+
const gl2 = this.gl;
|
|
310
|
+
this.maxVertexAttribs = gl2.getParameter(gl2.MAX_VERTEX_ATTRIBS);
|
|
321
311
|
this.defaultVertexArrayObject = new WebGLVertexArrayObjectOES(this);
|
|
322
312
|
this.currentVertexArrayObject = null;
|
|
323
313
|
this.currentArrayBuffer = null;
|
|
@@ -345,10 +335,10 @@ OESVertexArrayObject.prototype.isVertexArrayOES = function isVertexArrayOES(arra
|
|
|
345
335
|
return false;
|
|
346
336
|
};
|
|
347
337
|
OESVertexArrayObject.prototype.bindVertexArrayOES = function bindVertexArrayOES(arrayObject) {
|
|
348
|
-
const
|
|
338
|
+
const gl2 = this.gl;
|
|
349
339
|
if (arrayObject && !arrayObject.isAlive) {
|
|
350
340
|
synthesizeGLError(
|
|
351
|
-
|
|
341
|
+
gl2.INVALID_OPERATION,
|
|
352
342
|
"bindVertexArrayOES: attempt to bind deleted arrayObject"
|
|
353
343
|
);
|
|
354
344
|
return;
|
|
@@ -362,7 +352,7 @@ OESVertexArrayObject.prototype.bindVertexArrayOES = function bindVertexArrayOES(
|
|
|
362
352
|
return;
|
|
363
353
|
}
|
|
364
354
|
if (!oldVAO || newVAO.elementArrayBuffer !== oldVAO.elementArrayBuffer) {
|
|
365
|
-
original.bindBuffer.call(
|
|
355
|
+
original.bindBuffer.call(gl2, gl2.ELEMENT_ARRAY_BUFFER, newVAO.elementArrayBuffer);
|
|
366
356
|
}
|
|
367
357
|
let currentBinding = this.currentArrayBuffer;
|
|
368
358
|
const maxAttrib = Math.max(oldVAO ? oldVAO.maxAttrib : 0, newVAO.maxAttrib);
|
|
@@ -371,23 +361,23 @@ OESVertexArrayObject.prototype.bindVertexArrayOES = function bindVertexArrayOES(
|
|
|
371
361
|
const oldAttrib = oldVAO ? oldVAO.attribs[n] : null;
|
|
372
362
|
if (!oldVAO || attrib.enabled !== oldAttrib.enabled) {
|
|
373
363
|
if (attrib.enabled) {
|
|
374
|
-
original.enableVertexAttribArray.call(
|
|
364
|
+
original.enableVertexAttribArray.call(gl2, n);
|
|
375
365
|
} else {
|
|
376
|
-
original.disableVertexAttribArray.call(
|
|
366
|
+
original.disableVertexAttribArray.call(gl2, n);
|
|
377
367
|
}
|
|
378
368
|
}
|
|
379
369
|
if (attrib.enabled) {
|
|
380
370
|
let bufferChanged = false;
|
|
381
371
|
if (!oldVAO || attrib.buffer !== oldAttrib.buffer) {
|
|
382
372
|
if (currentBinding !== attrib.buffer) {
|
|
383
|
-
original.bindBuffer.call(
|
|
373
|
+
original.bindBuffer.call(gl2, gl2.ARRAY_BUFFER, attrib.buffer);
|
|
384
374
|
currentBinding = attrib.buffer;
|
|
385
375
|
}
|
|
386
376
|
bufferChanged = true;
|
|
387
377
|
}
|
|
388
378
|
if (bufferChanged || attrib.cached !== oldAttrib.cached) {
|
|
389
379
|
original.vertexAttribPointer.call(
|
|
390
|
-
|
|
380
|
+
gl2,
|
|
391
381
|
n,
|
|
392
382
|
attrib.size,
|
|
393
383
|
attrib.type,
|
|
@@ -399,23 +389,23 @@ OESVertexArrayObject.prototype.bindVertexArrayOES = function bindVertexArrayOES(
|
|
|
399
389
|
}
|
|
400
390
|
}
|
|
401
391
|
if (this.currentArrayBuffer !== currentBinding) {
|
|
402
|
-
original.bindBuffer.call(
|
|
392
|
+
original.bindBuffer.call(gl2, gl2.ARRAY_BUFFER, this.currentArrayBuffer);
|
|
403
393
|
}
|
|
404
394
|
};
|
|
405
|
-
function polyfillVertexArrayObject(
|
|
406
|
-
if (typeof
|
|
395
|
+
function polyfillVertexArrayObject(gl2) {
|
|
396
|
+
if (typeof gl2.createVertexArray === "function") {
|
|
407
397
|
return;
|
|
408
398
|
}
|
|
409
|
-
const original_getSupportedExtensions =
|
|
410
|
-
|
|
399
|
+
const original_getSupportedExtensions = gl2.getSupportedExtensions;
|
|
400
|
+
gl2.getSupportedExtensions = function getSupportedExtensions() {
|
|
411
401
|
const list = original_getSupportedExtensions.call(this) || [];
|
|
412
402
|
if (list.indexOf("OES_vertex_array_object") < 0) {
|
|
413
403
|
list.push("OES_vertex_array_object");
|
|
414
404
|
}
|
|
415
405
|
return list;
|
|
416
406
|
};
|
|
417
|
-
const original_getExtension =
|
|
418
|
-
|
|
407
|
+
const original_getExtension = gl2.getExtension;
|
|
408
|
+
gl2.getExtension = function getExtension(name) {
|
|
419
409
|
const ext = original_getExtension.call(this, name);
|
|
420
410
|
if (ext) {
|
|
421
411
|
return ext;
|
|
@@ -423,7 +413,7 @@ function polyfillVertexArrayObject(gl) {
|
|
|
423
413
|
if (name !== "OES_vertex_array_object") {
|
|
424
414
|
return null;
|
|
425
415
|
}
|
|
426
|
-
if (!
|
|
416
|
+
if (!gl2.__OESVertexArrayObject) {
|
|
427
417
|
this.__OESVertexArrayObject = new OESVertexArrayObject(this);
|
|
428
418
|
}
|
|
429
419
|
return this.__OESVertexArrayObject;
|
|
@@ -432,41 +422,41 @@ function polyfillVertexArrayObject(gl) {
|
|
|
432
422
|
|
|
433
423
|
// src/context/polyfill/polyfill-table.ts
|
|
434
424
|
var import_api2 = require("@luma.gl/api");
|
|
435
|
-
var import_constants2 =
|
|
425
|
+
var import_constants2 = require("@luma.gl/constants");
|
|
436
426
|
|
|
437
427
|
// src/context/context/webgl-checks.ts
|
|
438
428
|
var import_api = require("@luma.gl/api");
|
|
439
429
|
var ERR_CONTEXT = "Invalid WebGLRenderingContext";
|
|
440
430
|
var ERR_WEBGL2 = "Requires WebGL2";
|
|
441
|
-
function isWebGL(
|
|
442
|
-
if (typeof WebGLRenderingContext !== "undefined" &&
|
|
431
|
+
function isWebGL(gl2) {
|
|
432
|
+
if (typeof WebGLRenderingContext !== "undefined" && gl2 instanceof WebGLRenderingContext) {
|
|
443
433
|
return true;
|
|
444
434
|
}
|
|
445
|
-
if (typeof WebGL2RenderingContext !== "undefined" &&
|
|
435
|
+
if (typeof WebGL2RenderingContext !== "undefined" && gl2 instanceof WebGL2RenderingContext) {
|
|
446
436
|
return true;
|
|
447
437
|
}
|
|
448
|
-
return Boolean(
|
|
438
|
+
return Boolean(gl2 && Number.isFinite(gl2._version));
|
|
449
439
|
}
|
|
450
|
-
function isWebGL2(
|
|
451
|
-
if (typeof WebGL2RenderingContext !== "undefined" &&
|
|
440
|
+
function isWebGL2(gl2) {
|
|
441
|
+
if (typeof WebGL2RenderingContext !== "undefined" && gl2 instanceof WebGL2RenderingContext) {
|
|
452
442
|
return true;
|
|
453
443
|
}
|
|
454
|
-
return Boolean(
|
|
444
|
+
return Boolean(gl2 && gl2._version === 2);
|
|
455
445
|
}
|
|
456
|
-
function getWebGL2Context(
|
|
457
|
-
return isWebGL2(
|
|
446
|
+
function getWebGL2Context(gl2) {
|
|
447
|
+
return isWebGL2(gl2) ? gl2 : null;
|
|
458
448
|
}
|
|
459
|
-
function assertWebGLContext(
|
|
460
|
-
(0, import_api.assert)(isWebGL(
|
|
461
|
-
return
|
|
449
|
+
function assertWebGLContext(gl2) {
|
|
450
|
+
(0, import_api.assert)(isWebGL(gl2), ERR_CONTEXT);
|
|
451
|
+
return gl2;
|
|
462
452
|
}
|
|
463
|
-
function assertWebGL2Context(
|
|
464
|
-
(0, import_api.assert)(isWebGL2(
|
|
465
|
-
return
|
|
453
|
+
function assertWebGL2Context(gl2) {
|
|
454
|
+
(0, import_api.assert)(isWebGL2(gl2), ERR_WEBGL2);
|
|
455
|
+
return gl2;
|
|
466
456
|
}
|
|
467
457
|
|
|
468
458
|
// src/context/polyfill/get-parameter-polyfill.ts
|
|
469
|
-
var import_constants =
|
|
459
|
+
var import_constants = require("@luma.gl/constants");
|
|
470
460
|
var OES_element_index = "OES_element_index";
|
|
471
461
|
var WEBGL_draw_buffers = "WEBGL_draw_buffers";
|
|
472
462
|
var EXT_disjoint_timer_query = "EXT_disjoint_timer_query";
|
|
@@ -479,103 +469,103 @@ var GL_GPU_DISJOINT_EXT = 36795;
|
|
|
479
469
|
var GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 34047;
|
|
480
470
|
var GL_UNMASKED_VENDOR_WEBGL = 37445;
|
|
481
471
|
var GL_UNMASKED_RENDERER_WEBGL = 37446;
|
|
482
|
-
var getWebGL2ValueOrZero = (
|
|
472
|
+
var getWebGL2ValueOrZero = (gl2) => !isWebGL2(gl2) ? 0 : void 0;
|
|
483
473
|
var WEBGL_PARAMETERS = {
|
|
484
|
-
[import_constants.
|
|
474
|
+
[import_constants.GL.READ_BUFFER]: (gl2) => !isWebGL2(gl2) ? import_constants.GL.COLOR_ATTACHMENT0 : void 0,
|
|
485
475
|
// WebGL2 context parameters
|
|
486
|
-
[GL_FRAGMENT_SHADER_DERIVATIVE_HINT]: (
|
|
487
|
-
[import_constants.
|
|
488
|
-
[import_constants.
|
|
476
|
+
[GL_FRAGMENT_SHADER_DERIVATIVE_HINT]: (gl2) => !isWebGL2(gl2) ? GL_DONT_CARE : void 0,
|
|
477
|
+
[import_constants.GL.RASTERIZER_DISCARD]: getWebGL2ValueOrZero,
|
|
478
|
+
[import_constants.GL.SAMPLES]: getWebGL2ValueOrZero,
|
|
489
479
|
// WebGL2 extension context parameters
|
|
490
|
-
[GL_GPU_DISJOINT_EXT]: (
|
|
491
|
-
const ext = isWebGL2(
|
|
480
|
+
[GL_GPU_DISJOINT_EXT]: (gl2, getParameter) => {
|
|
481
|
+
const ext = isWebGL2(gl2) ? gl2.getExtension(EXT_disjoint_timer_query_webgl2) : gl2.getExtension(EXT_disjoint_timer_query);
|
|
492
482
|
return ext && ext.GPU_DISJOINT_EXT ? getParameter(ext.GPU_DISJOINT_EXT) : 0;
|
|
493
483
|
},
|
|
494
484
|
// Extension fixed values
|
|
495
|
-
[GL_UNMASKED_VENDOR_WEBGL]: (
|
|
496
|
-
const ext =
|
|
497
|
-
return getParameter(ext && ext.UNMASKED_VENDOR_WEBGL || import_constants.
|
|
485
|
+
[GL_UNMASKED_VENDOR_WEBGL]: (gl2, getParameter) => {
|
|
486
|
+
const ext = gl2.getExtension(WEBGL_debug_renderer_info);
|
|
487
|
+
return getParameter(ext && ext.UNMASKED_VENDOR_WEBGL || import_constants.GL.VENDOR);
|
|
498
488
|
},
|
|
499
|
-
[GL_UNMASKED_RENDERER_WEBGL]: (
|
|
500
|
-
const ext =
|
|
501
|
-
return getParameter(ext && ext.UNMASKED_RENDERER_WEBGL || import_constants.
|
|
489
|
+
[GL_UNMASKED_RENDERER_WEBGL]: (gl2, getParameter) => {
|
|
490
|
+
const ext = gl2.getExtension(WEBGL_debug_renderer_info);
|
|
491
|
+
return getParameter(ext && ext.UNMASKED_RENDERER_WEBGL || import_constants.GL.RENDERER);
|
|
502
492
|
},
|
|
503
493
|
// Extension LIMITS
|
|
504
|
-
[GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT]: (
|
|
494
|
+
[GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT]: (gl2, getParameter) => {
|
|
505
495
|
var _a, _b;
|
|
506
|
-
const ext = ((_b = (_a =
|
|
496
|
+
const ext = ((_b = (_a = gl2.luma) == null ? void 0 : _a.extensions) == null ? void 0 : _b[EXT_texture_filter_anisotropic]) || gl2.getExtension("EXT_texture_filter_anisotropic");
|
|
507
497
|
return ext ? getParameter(ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 1;
|
|
508
498
|
},
|
|
509
499
|
// WebGL2 Limits
|
|
510
|
-
[import_constants.
|
|
511
|
-
[import_constants.
|
|
512
|
-
[import_constants.
|
|
513
|
-
[import_constants.
|
|
514
|
-
if (!isWebGL2(
|
|
515
|
-
const ext =
|
|
500
|
+
[import_constants.GL.MAX_3D_TEXTURE_SIZE]: getWebGL2ValueOrZero,
|
|
501
|
+
[import_constants.GL.MAX_ARRAY_TEXTURE_LAYERS]: getWebGL2ValueOrZero,
|
|
502
|
+
[import_constants.GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: getWebGL2ValueOrZero,
|
|
503
|
+
[import_constants.GL.MAX_COLOR_ATTACHMENTS]: (gl2, getParameter) => {
|
|
504
|
+
if (!isWebGL2(gl2)) {
|
|
505
|
+
const ext = gl2.getExtension(WEBGL_draw_buffers);
|
|
516
506
|
return ext ? getParameter(ext.MAX_COLOR_ATTACHMENTS_WEBGL) : 0;
|
|
517
507
|
}
|
|
518
508
|
return void 0;
|
|
519
509
|
},
|
|
520
|
-
[import_constants.
|
|
521
|
-
[import_constants.
|
|
522
|
-
[import_constants.
|
|
523
|
-
[import_constants.
|
|
524
|
-
if (!isWebGL2(
|
|
525
|
-
const ext =
|
|
510
|
+
[import_constants.GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: getWebGL2ValueOrZero,
|
|
511
|
+
[import_constants.GL.MAX_COMBINED_UNIFORM_BLOCKS]: getWebGL2ValueOrZero,
|
|
512
|
+
[import_constants.GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]: getWebGL2ValueOrZero,
|
|
513
|
+
[import_constants.GL.MAX_DRAW_BUFFERS]: (gl2) => {
|
|
514
|
+
if (!isWebGL2(gl2)) {
|
|
515
|
+
const ext = gl2.getExtension(WEBGL_draw_buffers);
|
|
526
516
|
return ext ? ext.MAX_DRAW_BUFFERS_WEBGL : 0;
|
|
527
517
|
}
|
|
528
518
|
return void 0;
|
|
529
519
|
},
|
|
530
|
-
[import_constants.
|
|
520
|
+
[import_constants.GL.MAX_ELEMENT_INDEX]: (
|
|
531
521
|
// Guess: per webglstats.com 99.6% of webgl2 supports 2147483647
|
|
532
|
-
(
|
|
522
|
+
(gl2) => gl2.getExtension(OES_element_index) ? 2147483647 : 65535
|
|
533
523
|
),
|
|
534
|
-
[import_constants.
|
|
524
|
+
[import_constants.GL.MAX_ELEMENTS_INDICES]: (
|
|
535
525
|
// Guess: "Reasonably safe" per webglstats.com - could be higher/lower (on some mobile devices)
|
|
536
|
-
(
|
|
526
|
+
(gl2) => gl2.getExtension(OES_element_index) ? 16777216 : 65535
|
|
537
527
|
),
|
|
538
|
-
[import_constants.
|
|
528
|
+
[import_constants.GL.MAX_ELEMENTS_VERTICES]: (
|
|
539
529
|
// Guess: "Reasonably safe" per webglstats.com - could be higher/lower (on some mobile devices)
|
|
540
|
-
(
|
|
530
|
+
(gl2) => 16777216
|
|
541
531
|
),
|
|
542
|
-
[import_constants.
|
|
543
|
-
[import_constants.
|
|
544
|
-
[import_constants.
|
|
545
|
-
[import_constants.
|
|
546
|
-
[import_constants.
|
|
547
|
-
[import_constants.
|
|
548
|
-
[import_constants.
|
|
549
|
-
[import_constants.
|
|
550
|
-
[import_constants.
|
|
551
|
-
[import_constants.
|
|
552
|
-
[import_constants.
|
|
553
|
-
[import_constants.
|
|
554
|
-
[import_constants.
|
|
555
|
-
[import_constants.
|
|
556
|
-
[import_constants.
|
|
557
|
-
[import_constants.
|
|
558
|
-
[import_constants.
|
|
559
|
-
[import_constants.
|
|
532
|
+
[import_constants.GL.MAX_FRAGMENT_INPUT_COMPONENTS]: getWebGL2ValueOrZero,
|
|
533
|
+
[import_constants.GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: getWebGL2ValueOrZero,
|
|
534
|
+
[import_constants.GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]: getWebGL2ValueOrZero,
|
|
535
|
+
[import_constants.GL.MAX_SAMPLES]: getWebGL2ValueOrZero,
|
|
536
|
+
[import_constants.GL.MAX_SERVER_WAIT_TIMEOUT]: getWebGL2ValueOrZero,
|
|
537
|
+
[import_constants.GL.MAX_TEXTURE_LOD_BIAS]: getWebGL2ValueOrZero,
|
|
538
|
+
[import_constants.GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: getWebGL2ValueOrZero,
|
|
539
|
+
[import_constants.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]: getWebGL2ValueOrZero,
|
|
540
|
+
[import_constants.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]: getWebGL2ValueOrZero,
|
|
541
|
+
[import_constants.GL.MAX_UNIFORM_BLOCK_SIZE]: getWebGL2ValueOrZero,
|
|
542
|
+
[import_constants.GL.MAX_UNIFORM_BUFFER_BINDINGS]: getWebGL2ValueOrZero,
|
|
543
|
+
[import_constants.GL.MAX_VARYING_COMPONENTS]: getWebGL2ValueOrZero,
|
|
544
|
+
[import_constants.GL.MAX_VERTEX_OUTPUT_COMPONENTS]: getWebGL2ValueOrZero,
|
|
545
|
+
[import_constants.GL.MAX_VERTEX_UNIFORM_BLOCKS]: getWebGL2ValueOrZero,
|
|
546
|
+
[import_constants.GL.MAX_VERTEX_UNIFORM_COMPONENTS]: getWebGL2ValueOrZero,
|
|
547
|
+
[import_constants.GL.MIN_PROGRAM_TEXEL_OFFSET]: getWebGL2ValueOrZero,
|
|
548
|
+
[import_constants.GL.MAX_PROGRAM_TEXEL_OFFSET]: getWebGL2ValueOrZero,
|
|
549
|
+
[import_constants.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]: getWebGL2ValueOrZero
|
|
560
550
|
};
|
|
561
|
-
function getParameterPolyfill(
|
|
551
|
+
function getParameterPolyfill(gl2, originalGetParameter, pname) {
|
|
562
552
|
const limit = WEBGL_PARAMETERS[pname];
|
|
563
|
-
const value = typeof limit === "function" ? limit(
|
|
553
|
+
const value = typeof limit === "function" ? limit(gl2, originalGetParameter, pname) : limit;
|
|
564
554
|
const result = value !== void 0 ? value : originalGetParameter(pname);
|
|
565
555
|
return result;
|
|
566
556
|
}
|
|
567
557
|
|
|
568
558
|
// src/context/polyfill/context-data.ts
|
|
569
|
-
function getContextData(
|
|
570
|
-
const luma =
|
|
559
|
+
function getContextData(gl2) {
|
|
560
|
+
const luma = gl2.luma;
|
|
571
561
|
if (!luma) {
|
|
572
562
|
const contextState = {
|
|
573
563
|
_polyfilled: false,
|
|
574
564
|
_extensions: {}
|
|
575
565
|
};
|
|
576
|
-
|
|
566
|
+
gl2.luma = contextState;
|
|
577
567
|
}
|
|
578
|
-
return
|
|
568
|
+
return gl2.luma;
|
|
579
569
|
}
|
|
580
570
|
|
|
581
571
|
// src/context/polyfill/polyfill-table.ts
|
|
@@ -585,10 +575,10 @@ var WEBGL_draw_buffers2 = "WEBGL_draw_buffers";
|
|
|
585
575
|
var EXT_disjoint_timer_query2 = "EXT_disjoint_timer_query";
|
|
586
576
|
var EXT_texture_filter_anisotropic2 = "EXT_texture_filter_anisotropic";
|
|
587
577
|
var ERR_VAO_NOT_SUPPORTED = "VertexArray requires WebGL2 or OES_vertex_array_object extension";
|
|
588
|
-
function getExtensionData(
|
|
578
|
+
function getExtensionData(gl2, extension) {
|
|
589
579
|
return {
|
|
590
|
-
webgl2: isWebGL2(
|
|
591
|
-
ext:
|
|
580
|
+
webgl2: isWebGL2(gl2),
|
|
581
|
+
ext: gl2.getExtension(extension)
|
|
592
582
|
};
|
|
593
583
|
}
|
|
594
584
|
var WEBGL2_CONTEXT_POLYFILLS = {
|
|
@@ -655,21 +645,21 @@ var WEBGL2_CONTEXT_POLYFILLS = {
|
|
|
655
645
|
};
|
|
656
646
|
var WEBGL2_CONTEXT_OVERRIDES = {
|
|
657
647
|
// Ensure readBuffer is a no-op
|
|
658
|
-
readBuffer: (
|
|
659
|
-
if (isWebGL2(
|
|
648
|
+
readBuffer: (gl2, originalFunc, attachment) => {
|
|
649
|
+
if (isWebGL2(gl2)) {
|
|
660
650
|
originalFunc(attachment);
|
|
661
651
|
} else {
|
|
662
652
|
}
|
|
663
653
|
},
|
|
664
654
|
// Override for getVertexAttrib that returns sane values for non-WebGL1 constants
|
|
665
|
-
getVertexAttrib: (
|
|
666
|
-
const { webgl2, ext } = getExtensionData(
|
|
655
|
+
getVertexAttrib: (gl2, originalFunc, location, pname) => {
|
|
656
|
+
const { webgl2, ext } = getExtensionData(gl2, ANGLE_instanced_arrays);
|
|
667
657
|
let result;
|
|
668
658
|
switch (pname) {
|
|
669
|
-
case import_constants2.
|
|
659
|
+
case import_constants2.GL.VERTEX_ATTRIB_ARRAY_INTEGER:
|
|
670
660
|
result = !webgl2 ? false : void 0;
|
|
671
661
|
break;
|
|
672
|
-
case import_constants2.
|
|
662
|
+
case import_constants2.GL.VERTEX_ATTRIB_ARRAY_DIVISOR:
|
|
673
663
|
result = !webgl2 && !ext ? 0 : void 0;
|
|
674
664
|
break;
|
|
675
665
|
default:
|
|
@@ -677,88 +667,88 @@ var WEBGL2_CONTEXT_OVERRIDES = {
|
|
|
677
667
|
return result !== void 0 ? result : originalFunc(location, pname);
|
|
678
668
|
},
|
|
679
669
|
// Handle transform feedback and uniform block queries in WebGL1
|
|
680
|
-
getProgramParameter: (
|
|
681
|
-
if (!isWebGL2(
|
|
670
|
+
getProgramParameter: (gl2, originalFunc, program, pname) => {
|
|
671
|
+
if (!isWebGL2(gl2)) {
|
|
682
672
|
switch (pname) {
|
|
683
|
-
case import_constants2.
|
|
684
|
-
return import_constants2.
|
|
685
|
-
case import_constants2.
|
|
673
|
+
case import_constants2.GL.TRANSFORM_FEEDBACK_BUFFER_MODE:
|
|
674
|
+
return import_constants2.GL.SEPARATE_ATTRIBS;
|
|
675
|
+
case import_constants2.GL.TRANSFORM_FEEDBACK_VARYINGS:
|
|
686
676
|
return 0;
|
|
687
|
-
case import_constants2.
|
|
677
|
+
case import_constants2.GL.ACTIVE_UNIFORM_BLOCKS:
|
|
688
678
|
return 0;
|
|
689
679
|
default:
|
|
690
680
|
}
|
|
691
681
|
}
|
|
692
682
|
return originalFunc(program, pname);
|
|
693
683
|
},
|
|
694
|
-
getInternalformatParameter: (
|
|
695
|
-
if (!isWebGL2(
|
|
684
|
+
getInternalformatParameter: (gl2, originalFunc, target, format, pname) => {
|
|
685
|
+
if (!isWebGL2(gl2)) {
|
|
696
686
|
switch (pname) {
|
|
697
|
-
case import_constants2.
|
|
687
|
+
case import_constants2.GL.SAMPLES:
|
|
698
688
|
return new Int32Array([0]);
|
|
699
689
|
default:
|
|
700
690
|
}
|
|
701
691
|
}
|
|
702
|
-
const
|
|
703
|
-
return
|
|
692
|
+
const gl22 = gl2;
|
|
693
|
+
return gl22.getInternalformatParameter(target, format, pname);
|
|
704
694
|
},
|
|
705
|
-
getTexParameter(
|
|
695
|
+
getTexParameter(gl2, originalFunc, target, pname) {
|
|
706
696
|
switch (pname) {
|
|
707
|
-
case import_constants2.
|
|
708
|
-
const contextData = getContextData(
|
|
697
|
+
case import_constants2.GL.TEXTURE_MAX_ANISOTROPY_EXT:
|
|
698
|
+
const contextData = getContextData(gl2);
|
|
709
699
|
const { _extensions } = contextData;
|
|
710
700
|
const ext = _extensions[EXT_texture_filter_anisotropic2];
|
|
711
|
-
pname = ext && ext.TEXTURE_MAX_ANISOTROPY_EXT || import_constants2.
|
|
701
|
+
pname = ext && ext.TEXTURE_MAX_ANISOTROPY_EXT || import_constants2.GL.TEXTURE_MAX_ANISOTROPY_EXT;
|
|
712
702
|
break;
|
|
713
703
|
default:
|
|
714
704
|
}
|
|
715
705
|
return originalFunc(target, pname);
|
|
716
706
|
},
|
|
717
707
|
getParameter: getParameterPolyfill,
|
|
718
|
-
hint(
|
|
708
|
+
hint(gl2, originalFunc, pname, value) {
|
|
719
709
|
return originalFunc(pname, value);
|
|
720
710
|
}
|
|
721
711
|
};
|
|
722
712
|
|
|
723
713
|
// src/context/polyfill/polyfill-context.ts
|
|
724
|
-
function polyfillContext(
|
|
725
|
-
const contextState = getContextData(
|
|
714
|
+
function polyfillContext(gl2) {
|
|
715
|
+
const contextState = getContextData(gl2);
|
|
726
716
|
if (!contextState._polyfilled) {
|
|
727
|
-
polyfillVertexArrayObject(
|
|
728
|
-
initializeExtensions(
|
|
729
|
-
installPolyfills(
|
|
730
|
-
installOverrides(
|
|
717
|
+
polyfillVertexArrayObject(gl2);
|
|
718
|
+
initializeExtensions(gl2);
|
|
719
|
+
installPolyfills(gl2, WEBGL2_CONTEXT_POLYFILLS);
|
|
720
|
+
installOverrides(gl2, { target: contextState, target2: gl2 });
|
|
731
721
|
contextState._polyfilled = true;
|
|
732
722
|
}
|
|
733
|
-
return
|
|
723
|
+
return gl2;
|
|
734
724
|
}
|
|
735
|
-
function initializeExtensions(
|
|
736
|
-
const contextState = getContextData(
|
|
737
|
-
const EXTENSIONS =
|
|
725
|
+
function initializeExtensions(gl2) {
|
|
726
|
+
const contextState = getContextData(gl2);
|
|
727
|
+
const EXTENSIONS = gl2.getSupportedExtensions() || [];
|
|
738
728
|
for (const extensionName of EXTENSIONS) {
|
|
739
|
-
const extension =
|
|
729
|
+
const extension = gl2.getExtension(extensionName);
|
|
740
730
|
contextState._extensions[extensionName] = extension;
|
|
741
731
|
}
|
|
742
732
|
}
|
|
743
|
-
function installPolyfills(
|
|
744
|
-
const contextState = getContextData(
|
|
733
|
+
function installPolyfills(gl2, polyfills) {
|
|
734
|
+
const contextState = getContextData(gl2);
|
|
745
735
|
for (const extension of Object.getOwnPropertyNames(polyfills)) {
|
|
746
736
|
if (extension !== "overrides") {
|
|
747
|
-
polyfillExtension(
|
|
737
|
+
polyfillExtension(gl2, { extension, target: contextState, target2: gl2 });
|
|
748
738
|
}
|
|
749
739
|
}
|
|
750
740
|
}
|
|
751
|
-
function polyfillExtension(
|
|
741
|
+
function polyfillExtension(gl2, { extension, target, target2 }) {
|
|
752
742
|
const defaults = WEBGL2_CONTEXT_POLYFILLS[extension];
|
|
753
743
|
(0, import_api3.assert)(defaults);
|
|
754
744
|
const { meta = {} } = defaults;
|
|
755
745
|
const { suffix = "" } = meta;
|
|
756
|
-
const ext =
|
|
746
|
+
const ext = gl2.getExtension(extension);
|
|
757
747
|
for (const key of Object.keys(defaults)) {
|
|
758
748
|
const extKey = `${key}${suffix}`;
|
|
759
749
|
let polyfill = null;
|
|
760
750
|
if (key === "meta") {
|
|
761
|
-
} else if (typeof
|
|
751
|
+
} else if (typeof gl2[key] === "function") {
|
|
762
752
|
} else if (ext && typeof ext[extKey] === "function") {
|
|
763
753
|
polyfill = (...args) => ext[extKey](...args);
|
|
764
754
|
} else if (typeof defaults[key] === "function") {
|
|
@@ -770,12 +760,12 @@ function polyfillExtension(gl, { extension, target, target2 }) {
|
|
|
770
760
|
}
|
|
771
761
|
}
|
|
772
762
|
}
|
|
773
|
-
function installOverrides(
|
|
763
|
+
function installOverrides(gl2, { target, target2 }) {
|
|
774
764
|
Object.keys(WEBGL2_CONTEXT_OVERRIDES).forEach((key) => {
|
|
775
765
|
if (typeof WEBGL2_CONTEXT_OVERRIDES[key] === "function") {
|
|
776
|
-
const originalFunc =
|
|
766
|
+
const originalFunc = gl2[key] ? gl2[key].bind(gl2) : () => {
|
|
777
767
|
};
|
|
778
|
-
const polyfill = WEBGL2_CONTEXT_OVERRIDES[key].bind(null,
|
|
768
|
+
const polyfill = WEBGL2_CONTEXT_OVERRIDES[key].bind(null, gl2, originalFunc);
|
|
779
769
|
target[key] = polyfill;
|
|
780
770
|
target2[key] = polyfill;
|
|
781
771
|
}
|
|
@@ -870,19 +860,19 @@ var GL_PARAMETER_DEFAULTS = {
|
|
|
870
860
|
[import_constants3.GL.UNPACK_SKIP_ROWS]: 0,
|
|
871
861
|
[import_constants3.GL.UNPACK_SKIP_IMAGES]: 0
|
|
872
862
|
};
|
|
873
|
-
var enable = (
|
|
874
|
-
var hint = (
|
|
875
|
-
var pixelStorei = (
|
|
876
|
-
var bindFramebuffer = (
|
|
863
|
+
var enable = (gl2, value, key) => value ? gl2.enable(key) : gl2.disable(key);
|
|
864
|
+
var hint = (gl2, value, key) => gl2.hint(key, value);
|
|
865
|
+
var pixelStorei = (gl2, value, key) => gl2.pixelStorei(key, value);
|
|
866
|
+
var bindFramebuffer = (gl2, value, key) => {
|
|
877
867
|
let target;
|
|
878
868
|
if (key === import_constants3.GL.FRAMEBUFFER_BINDING) {
|
|
879
|
-
target = isWebGL2(
|
|
869
|
+
target = isWebGL2(gl2) ? import_constants3.GL.DRAW_FRAMEBUFFER : import_constants3.GL.FRAMEBUFFER;
|
|
880
870
|
} else {
|
|
881
871
|
target = import_constants3.GL.READ_FRAMEBUFFER;
|
|
882
872
|
}
|
|
883
|
-
return
|
|
873
|
+
return gl2.bindFramebuffer(target, value);
|
|
884
874
|
};
|
|
885
|
-
var bindBuffer = (
|
|
875
|
+
var bindBuffer = (gl2, value, key) => {
|
|
886
876
|
const bindingMap = {
|
|
887
877
|
[import_constants3.GL.ARRAY_BUFFER_BINDING]: import_constants3.GL.ARRAY_BUFFER,
|
|
888
878
|
[import_constants3.GL.COPY_READ_BUFFER_BINDING]: import_constants3.GL.COPY_READ_BUFFER,
|
|
@@ -891,38 +881,38 @@ var bindBuffer = (gl, value, key) => {
|
|
|
891
881
|
[import_constants3.GL.PIXEL_UNPACK_BUFFER_BINDING]: import_constants3.GL.PIXEL_UNPACK_BUFFER
|
|
892
882
|
};
|
|
893
883
|
const target = bindingMap[key];
|
|
894
|
-
|
|
884
|
+
gl2.bindBuffer(target, value);
|
|
895
885
|
};
|
|
896
886
|
function isArray(array) {
|
|
897
887
|
return Array.isArray(array) || ArrayBuffer.isView(array) && !(array instanceof DataView);
|
|
898
888
|
}
|
|
899
889
|
var GL_PARAMETER_SETTERS = {
|
|
900
890
|
[import_constants3.GL.BLEND]: enable,
|
|
901
|
-
[import_constants3.GL.BLEND_COLOR]: (
|
|
891
|
+
[import_constants3.GL.BLEND_COLOR]: (gl2, value) => gl2.blendColor(...value),
|
|
902
892
|
[import_constants3.GL.BLEND_EQUATION_RGB]: "blendEquation",
|
|
903
893
|
[import_constants3.GL.BLEND_EQUATION_ALPHA]: "blendEquation",
|
|
904
894
|
[import_constants3.GL.BLEND_SRC_RGB]: "blendFunc",
|
|
905
895
|
[import_constants3.GL.BLEND_DST_RGB]: "blendFunc",
|
|
906
896
|
[import_constants3.GL.BLEND_SRC_ALPHA]: "blendFunc",
|
|
907
897
|
[import_constants3.GL.BLEND_DST_ALPHA]: "blendFunc",
|
|
908
|
-
[import_constants3.GL.COLOR_CLEAR_VALUE]: (
|
|
909
|
-
[import_constants3.GL.COLOR_WRITEMASK]: (
|
|
898
|
+
[import_constants3.GL.COLOR_CLEAR_VALUE]: (gl2, value) => gl2.clearColor(...value),
|
|
899
|
+
[import_constants3.GL.COLOR_WRITEMASK]: (gl2, value) => gl2.colorMask(...value),
|
|
910
900
|
[import_constants3.GL.CULL_FACE]: enable,
|
|
911
|
-
[import_constants3.GL.CULL_FACE_MODE]: (
|
|
901
|
+
[import_constants3.GL.CULL_FACE_MODE]: (gl2, value) => gl2.cullFace(value),
|
|
912
902
|
[import_constants3.GL.DEPTH_TEST]: enable,
|
|
913
|
-
[import_constants3.GL.DEPTH_CLEAR_VALUE]: (
|
|
914
|
-
[import_constants3.GL.DEPTH_FUNC]: (
|
|
915
|
-
[import_constants3.GL.DEPTH_RANGE]: (
|
|
916
|
-
[import_constants3.GL.DEPTH_WRITEMASK]: (
|
|
903
|
+
[import_constants3.GL.DEPTH_CLEAR_VALUE]: (gl2, value) => gl2.clearDepth(value),
|
|
904
|
+
[import_constants3.GL.DEPTH_FUNC]: (gl2, value) => gl2.depthFunc(value),
|
|
905
|
+
[import_constants3.GL.DEPTH_RANGE]: (gl2, value) => gl2.depthRange(...value),
|
|
906
|
+
[import_constants3.GL.DEPTH_WRITEMASK]: (gl2, value) => gl2.depthMask(value),
|
|
917
907
|
[import_constants3.GL.DITHER]: enable,
|
|
918
908
|
[import_constants3.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]: hint,
|
|
919
|
-
[import_constants3.GL.CURRENT_PROGRAM]: (
|
|
920
|
-
[import_constants3.GL.RENDERBUFFER_BINDING]: (
|
|
921
|
-
[import_constants3.GL.TRANSFORM_FEEDBACK_BINDING]: (
|
|
909
|
+
[import_constants3.GL.CURRENT_PROGRAM]: (gl2, value) => gl2.useProgram(value),
|
|
910
|
+
[import_constants3.GL.RENDERBUFFER_BINDING]: (gl2, value) => gl2.bindRenderbuffer(import_constants3.GL.RENDERBUFFER, value),
|
|
911
|
+
[import_constants3.GL.TRANSFORM_FEEDBACK_BINDING]: (gl2, value) => {
|
|
922
912
|
var _a;
|
|
923
|
-
return (_a =
|
|
913
|
+
return (_a = gl2.bindTransformFeedback) == null ? void 0 : _a.call(gl2, import_constants3.GL.TRANSFORM_FEEDBACK, value);
|
|
924
914
|
},
|
|
925
|
-
[import_constants3.GL.VERTEX_ARRAY_BINDING]: (
|
|
915
|
+
[import_constants3.GL.VERTEX_ARRAY_BINDING]: (gl2, value) => gl2.bindVertexArray(value),
|
|
926
916
|
// NOTE: FRAMEBUFFER_BINDING and DRAW_FRAMEBUFFER_BINDING(WebGL2) refer same state.
|
|
927
917
|
[import_constants3.GL.FRAMEBUFFER_BINDING]: bindFramebuffer,
|
|
928
918
|
[import_constants3.GL.READ_FRAMEBUFFER_BINDING]: bindFramebuffer,
|
|
@@ -932,9 +922,9 @@ var GL_PARAMETER_SETTERS = {
|
|
|
932
922
|
[import_constants3.GL.COPY_WRITE_BUFFER_BINDING]: bindBuffer,
|
|
933
923
|
[import_constants3.GL.PIXEL_PACK_BUFFER_BINDING]: bindBuffer,
|
|
934
924
|
[import_constants3.GL.PIXEL_UNPACK_BUFFER_BINDING]: bindBuffer,
|
|
935
|
-
[import_constants3.GL.FRONT_FACE]: (
|
|
925
|
+
[import_constants3.GL.FRONT_FACE]: (gl2, value) => gl2.frontFace(value),
|
|
936
926
|
[import_constants3.GL.GENERATE_MIPMAP_HINT]: hint,
|
|
937
|
-
[import_constants3.GL.LINE_WIDTH]: (
|
|
927
|
+
[import_constants3.GL.LINE_WIDTH]: (gl2, value) => gl2.lineWidth(value),
|
|
938
928
|
[import_constants3.GL.POLYGON_OFFSET_FILL]: enable,
|
|
939
929
|
[import_constants3.GL.POLYGON_OFFSET_FACTOR]: "polygonOffset",
|
|
940
930
|
[import_constants3.GL.POLYGON_OFFSET_UNITS]: "polygonOffset",
|
|
@@ -944,11 +934,11 @@ var GL_PARAMETER_SETTERS = {
|
|
|
944
934
|
[import_constants3.GL.SAMPLE_COVERAGE_VALUE]: "sampleCoverage",
|
|
945
935
|
[import_constants3.GL.SAMPLE_COVERAGE_INVERT]: "sampleCoverage",
|
|
946
936
|
[import_constants3.GL.SCISSOR_TEST]: enable,
|
|
947
|
-
[import_constants3.GL.SCISSOR_BOX]: (
|
|
937
|
+
[import_constants3.GL.SCISSOR_BOX]: (gl2, value) => gl2.scissor(...value),
|
|
948
938
|
[import_constants3.GL.STENCIL_TEST]: enable,
|
|
949
|
-
[import_constants3.GL.STENCIL_CLEAR_VALUE]: (
|
|
950
|
-
[import_constants3.GL.STENCIL_WRITEMASK]: (
|
|
951
|
-
[import_constants3.GL.STENCIL_BACK_WRITEMASK]: (
|
|
939
|
+
[import_constants3.GL.STENCIL_CLEAR_VALUE]: (gl2, value) => gl2.clearStencil(value),
|
|
940
|
+
[import_constants3.GL.STENCIL_WRITEMASK]: (gl2, value) => gl2.stencilMaskSeparate(import_constants3.GL.FRONT, value),
|
|
941
|
+
[import_constants3.GL.STENCIL_BACK_WRITEMASK]: (gl2, value) => gl2.stencilMaskSeparate(import_constants3.GL.BACK, value),
|
|
952
942
|
[import_constants3.GL.STENCIL_FUNC]: "stencilFuncFront",
|
|
953
943
|
[import_constants3.GL.STENCIL_REF]: "stencilFuncFront",
|
|
954
944
|
[import_constants3.GL.STENCIL_VALUE_MASK]: "stencilFuncFront",
|
|
@@ -961,7 +951,7 @@ var GL_PARAMETER_SETTERS = {
|
|
|
961
951
|
[import_constants3.GL.STENCIL_BACK_FAIL]: "stencilOpBack",
|
|
962
952
|
[import_constants3.GL.STENCIL_BACK_PASS_DEPTH_FAIL]: "stencilOpBack",
|
|
963
953
|
[import_constants3.GL.STENCIL_BACK_PASS_DEPTH_PASS]: "stencilOpBack",
|
|
964
|
-
[import_constants3.GL.VIEWPORT]: (
|
|
954
|
+
[import_constants3.GL.VIEWPORT]: (gl2, value) => gl2.viewport(...value),
|
|
965
955
|
// WEBGL1 PIXEL PACK/UNPACK MODES
|
|
966
956
|
[import_constants3.GL.PACK_ALIGNMENT]: pixelStorei,
|
|
967
957
|
[import_constants3.GL.UNPACK_ALIGNMENT]: pixelStorei,
|
|
@@ -979,104 +969,104 @@ var GL_PARAMETER_SETTERS = {
|
|
|
979
969
|
[import_constants3.GL.UNPACK_SKIP_ROWS]: pixelStorei,
|
|
980
970
|
[import_constants3.GL.UNPACK_SKIP_IMAGES]: pixelStorei,
|
|
981
971
|
// Function-style setters
|
|
982
|
-
framebuffer: (
|
|
972
|
+
framebuffer: (gl2, framebuffer) => {
|
|
983
973
|
const handle = framebuffer && "handle" in framebuffer ? framebuffer.handle : framebuffer;
|
|
984
|
-
return
|
|
974
|
+
return gl2.bindFramebuffer(import_constants3.GL.FRAMEBUFFER, handle);
|
|
985
975
|
},
|
|
986
|
-
blend: (
|
|
987
|
-
blendColor: (
|
|
988
|
-
blendEquation: (
|
|
976
|
+
blend: (gl2, value) => value ? gl2.enable(import_constants3.GL.BLEND) : gl2.disable(import_constants3.GL.BLEND),
|
|
977
|
+
blendColor: (gl2, value) => gl2.blendColor(...value),
|
|
978
|
+
blendEquation: (gl2, args) => {
|
|
989
979
|
const separateModes = typeof args === "number" ? [args, args] : args;
|
|
990
|
-
|
|
980
|
+
gl2.blendEquationSeparate(...separateModes);
|
|
991
981
|
},
|
|
992
|
-
blendFunc: (
|
|
982
|
+
blendFunc: (gl2, args) => {
|
|
993
983
|
const separateFuncs = (args == null ? void 0 : args.length) === 2 ? [...args, ...args] : args;
|
|
994
|
-
|
|
984
|
+
gl2.blendFuncSeparate(...separateFuncs);
|
|
995
985
|
},
|
|
996
|
-
clearColor: (
|
|
997
|
-
clearDepth: (
|
|
998
|
-
clearStencil: (
|
|
999
|
-
colorMask: (
|
|
1000
|
-
cull: (
|
|
1001
|
-
cullFace: (
|
|
1002
|
-
depthTest: (
|
|
1003
|
-
depthFunc: (
|
|
1004
|
-
depthMask: (
|
|
1005
|
-
depthRange: (
|
|
1006
|
-
dither: (
|
|
1007
|
-
derivativeHint: (
|
|
1008
|
-
|
|
986
|
+
clearColor: (gl2, value) => gl2.clearColor(...value),
|
|
987
|
+
clearDepth: (gl2, value) => gl2.clearDepth(value),
|
|
988
|
+
clearStencil: (gl2, value) => gl2.clearStencil(value),
|
|
989
|
+
colorMask: (gl2, value) => gl2.colorMask(...value),
|
|
990
|
+
cull: (gl2, value) => value ? gl2.enable(import_constants3.GL.CULL_FACE) : gl2.disable(import_constants3.GL.CULL_FACE),
|
|
991
|
+
cullFace: (gl2, value) => gl2.cullFace(value),
|
|
992
|
+
depthTest: (gl2, value) => value ? gl2.enable(import_constants3.GL.DEPTH_TEST) : gl2.disable(import_constants3.GL.DEPTH_TEST),
|
|
993
|
+
depthFunc: (gl2, value) => gl2.depthFunc(value),
|
|
994
|
+
depthMask: (gl2, value) => gl2.depthMask(value),
|
|
995
|
+
depthRange: (gl2, value) => gl2.depthRange(...value),
|
|
996
|
+
dither: (gl2, value) => value ? gl2.enable(import_constants3.GL.DITHER) : gl2.disable(import_constants3.GL.DITHER),
|
|
997
|
+
derivativeHint: (gl2, value) => {
|
|
998
|
+
gl2.hint(import_constants3.GL.FRAGMENT_SHADER_DERIVATIVE_HINT, value);
|
|
1009
999
|
},
|
|
1010
|
-
frontFace: (
|
|
1011
|
-
mipmapHint: (
|
|
1012
|
-
lineWidth: (
|
|
1013
|
-
polygonOffsetFill: (
|
|
1014
|
-
polygonOffset: (
|
|
1015
|
-
sampleCoverage: (
|
|
1016
|
-
scissorTest: (
|
|
1017
|
-
scissor: (
|
|
1018
|
-
stencilTest: (
|
|
1019
|
-
stencilMask: (
|
|
1000
|
+
frontFace: (gl2, value) => gl2.frontFace(value),
|
|
1001
|
+
mipmapHint: (gl2, value) => gl2.hint(import_constants3.GL.GENERATE_MIPMAP_HINT, value),
|
|
1002
|
+
lineWidth: (gl2, value) => gl2.lineWidth(value),
|
|
1003
|
+
polygonOffsetFill: (gl2, value) => value ? gl2.enable(import_constants3.GL.POLYGON_OFFSET_FILL) : gl2.disable(import_constants3.GL.POLYGON_OFFSET_FILL),
|
|
1004
|
+
polygonOffset: (gl2, value) => gl2.polygonOffset(...value),
|
|
1005
|
+
sampleCoverage: (gl2, value) => gl2.sampleCoverage(...value),
|
|
1006
|
+
scissorTest: (gl2, value) => value ? gl2.enable(import_constants3.GL.SCISSOR_TEST) : gl2.disable(import_constants3.GL.SCISSOR_TEST),
|
|
1007
|
+
scissor: (gl2, value) => gl2.scissor(...value),
|
|
1008
|
+
stencilTest: (gl2, value) => value ? gl2.enable(import_constants3.GL.STENCIL_TEST) : gl2.disable(import_constants3.GL.STENCIL_TEST),
|
|
1009
|
+
stencilMask: (gl2, value) => {
|
|
1020
1010
|
value = isArray(value) ? value : [value, value];
|
|
1021
1011
|
const [mask, backMask] = value;
|
|
1022
|
-
|
|
1023
|
-
|
|
1012
|
+
gl2.stencilMaskSeparate(import_constants3.GL.FRONT, mask);
|
|
1013
|
+
gl2.stencilMaskSeparate(import_constants3.GL.BACK, backMask);
|
|
1024
1014
|
},
|
|
1025
|
-
stencilFunc: (
|
|
1015
|
+
stencilFunc: (gl2, args) => {
|
|
1026
1016
|
args = isArray(args) && args.length === 3 ? [...args, ...args] : args;
|
|
1027
1017
|
const [func, ref, mask, backFunc, backRef, backMask] = args;
|
|
1028
|
-
|
|
1029
|
-
|
|
1018
|
+
gl2.stencilFuncSeparate(import_constants3.GL.FRONT, func, ref, mask);
|
|
1019
|
+
gl2.stencilFuncSeparate(import_constants3.GL.BACK, backFunc, backRef, backMask);
|
|
1030
1020
|
},
|
|
1031
|
-
stencilOp: (
|
|
1021
|
+
stencilOp: (gl2, args) => {
|
|
1032
1022
|
args = isArray(args) && args.length === 3 ? [...args, ...args] : args;
|
|
1033
1023
|
const [sfail, dpfail, dppass, backSfail, backDpfail, backDppass] = args;
|
|
1034
|
-
|
|
1035
|
-
|
|
1024
|
+
gl2.stencilOpSeparate(import_constants3.GL.FRONT, sfail, dpfail, dppass);
|
|
1025
|
+
gl2.stencilOpSeparate(import_constants3.GL.BACK, backSfail, backDpfail, backDppass);
|
|
1036
1026
|
},
|
|
1037
|
-
viewport: (
|
|
1027
|
+
viewport: (gl2, value) => gl2.viewport(...value)
|
|
1038
1028
|
};
|
|
1039
1029
|
function getValue(glEnum, values, cache) {
|
|
1040
1030
|
return values[glEnum] !== void 0 ? values[glEnum] : cache[glEnum];
|
|
1041
1031
|
}
|
|
1042
1032
|
var GL_COMPOSITE_PARAMETER_SETTERS = {
|
|
1043
|
-
blendEquation: (
|
|
1033
|
+
blendEquation: (gl2, values, cache) => gl2.blendEquationSeparate(
|
|
1044
1034
|
getValue(import_constants3.GL.BLEND_EQUATION_RGB, values, cache),
|
|
1045
1035
|
getValue(import_constants3.GL.BLEND_EQUATION_ALPHA, values, cache)
|
|
1046
1036
|
),
|
|
1047
|
-
blendFunc: (
|
|
1037
|
+
blendFunc: (gl2, values, cache) => gl2.blendFuncSeparate(
|
|
1048
1038
|
getValue(import_constants3.GL.BLEND_SRC_RGB, values, cache),
|
|
1049
1039
|
getValue(import_constants3.GL.BLEND_DST_RGB, values, cache),
|
|
1050
1040
|
getValue(import_constants3.GL.BLEND_SRC_ALPHA, values, cache),
|
|
1051
1041
|
getValue(import_constants3.GL.BLEND_DST_ALPHA, values, cache)
|
|
1052
1042
|
),
|
|
1053
|
-
polygonOffset: (
|
|
1043
|
+
polygonOffset: (gl2, values, cache) => gl2.polygonOffset(
|
|
1054
1044
|
getValue(import_constants3.GL.POLYGON_OFFSET_FACTOR, values, cache),
|
|
1055
1045
|
getValue(import_constants3.GL.POLYGON_OFFSET_UNITS, values, cache)
|
|
1056
1046
|
),
|
|
1057
|
-
sampleCoverage: (
|
|
1047
|
+
sampleCoverage: (gl2, values, cache) => gl2.sampleCoverage(
|
|
1058
1048
|
getValue(import_constants3.GL.SAMPLE_COVERAGE_VALUE, values, cache),
|
|
1059
1049
|
getValue(import_constants3.GL.SAMPLE_COVERAGE_INVERT, values, cache)
|
|
1060
1050
|
),
|
|
1061
|
-
stencilFuncFront: (
|
|
1051
|
+
stencilFuncFront: (gl2, values, cache) => gl2.stencilFuncSeparate(
|
|
1062
1052
|
import_constants3.GL.FRONT,
|
|
1063
1053
|
getValue(import_constants3.GL.STENCIL_FUNC, values, cache),
|
|
1064
1054
|
getValue(import_constants3.GL.STENCIL_REF, values, cache),
|
|
1065
1055
|
getValue(import_constants3.GL.STENCIL_VALUE_MASK, values, cache)
|
|
1066
1056
|
),
|
|
1067
|
-
stencilFuncBack: (
|
|
1057
|
+
stencilFuncBack: (gl2, values, cache) => gl2.stencilFuncSeparate(
|
|
1068
1058
|
import_constants3.GL.BACK,
|
|
1069
1059
|
getValue(import_constants3.GL.STENCIL_BACK_FUNC, values, cache),
|
|
1070
1060
|
getValue(import_constants3.GL.STENCIL_BACK_REF, values, cache),
|
|
1071
1061
|
getValue(import_constants3.GL.STENCIL_BACK_VALUE_MASK, values, cache)
|
|
1072
1062
|
),
|
|
1073
|
-
stencilOpFront: (
|
|
1063
|
+
stencilOpFront: (gl2, values, cache) => gl2.stencilOpSeparate(
|
|
1074
1064
|
import_constants3.GL.FRONT,
|
|
1075
1065
|
getValue(import_constants3.GL.STENCIL_FAIL, values, cache),
|
|
1076
1066
|
getValue(import_constants3.GL.STENCIL_PASS_DEPTH_FAIL, values, cache),
|
|
1077
1067
|
getValue(import_constants3.GL.STENCIL_PASS_DEPTH_PASS, values, cache)
|
|
1078
1068
|
),
|
|
1079
|
-
stencilOpBack: (
|
|
1069
|
+
stencilOpBack: (gl2, values, cache) => gl2.stencilOpSeparate(
|
|
1080
1070
|
import_constants3.GL.BACK,
|
|
1081
1071
|
getValue(import_constants3.GL.STENCIL_BACK_FAIL, values, cache),
|
|
1082
1072
|
getValue(import_constants3.GL.STENCIL_BACK_PASS_DEPTH_FAIL, values, cache),
|
|
@@ -1239,7 +1229,7 @@ var GL_HOOKED_SETTERS = {
|
|
|
1239
1229
|
[import_constants3.GL.VIEWPORT]: [x, y, width, height]
|
|
1240
1230
|
})
|
|
1241
1231
|
};
|
|
1242
|
-
var isEnabled = (
|
|
1232
|
+
var isEnabled = (gl2, key) => gl2.isEnabled(key);
|
|
1243
1233
|
var GL_PARAMETER_GETTERS = {
|
|
1244
1234
|
[import_constants3.GL.BLEND]: isEnabled,
|
|
1245
1235
|
[import_constants3.GL.CULL_FACE]: isEnabled,
|
|
@@ -1295,7 +1285,7 @@ var NON_CACHE_PARAMETERS = /* @__PURE__ */ new Set([
|
|
|
1295
1285
|
// src/context/parameters/unified-parameter-api.ts
|
|
1296
1286
|
function setParameters(device, parameters) {
|
|
1297
1287
|
const webglDevice = WebGLDevice.attach(device);
|
|
1298
|
-
const
|
|
1288
|
+
const gl2 = webglDevice.gl;
|
|
1299
1289
|
if (isObjectEmpty(parameters)) {
|
|
1300
1290
|
return;
|
|
1301
1291
|
}
|
|
@@ -1307,31 +1297,31 @@ function setParameters(device, parameters) {
|
|
|
1307
1297
|
if (typeof setter === "string") {
|
|
1308
1298
|
compositeSetters[setter] = true;
|
|
1309
1299
|
} else {
|
|
1310
|
-
setter(
|
|
1300
|
+
setter(gl2, parameters[key], glConstant);
|
|
1311
1301
|
}
|
|
1312
1302
|
}
|
|
1313
1303
|
}
|
|
1314
|
-
const cache =
|
|
1304
|
+
const cache = gl2.state && gl2.state.cache;
|
|
1315
1305
|
if (cache) {
|
|
1316
1306
|
for (const key in compositeSetters) {
|
|
1317
1307
|
const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];
|
|
1318
|
-
compositeSetter(
|
|
1308
|
+
compositeSetter(gl2, parameters, cache);
|
|
1319
1309
|
}
|
|
1320
1310
|
}
|
|
1321
1311
|
}
|
|
1322
1312
|
function getParameters(device, parameters = GL_PARAMETER_DEFAULTS) {
|
|
1323
1313
|
const webglDevice = WebGLDevice.attach(device);
|
|
1324
|
-
const
|
|
1314
|
+
const gl2 = webglDevice.gl;
|
|
1325
1315
|
if (typeof parameters === "number") {
|
|
1326
1316
|
const key = parameters;
|
|
1327
1317
|
const getter = GL_PARAMETER_GETTERS[key];
|
|
1328
|
-
return getter ? getter(
|
|
1318
|
+
return getter ? getter(gl2, key) : gl2.getParameter(key);
|
|
1329
1319
|
}
|
|
1330
1320
|
const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);
|
|
1331
1321
|
const state = {};
|
|
1332
1322
|
for (const key of parameterKeys) {
|
|
1333
1323
|
const getter = GL_PARAMETER_GETTERS[key];
|
|
1334
|
-
state[key] = getter ? getter(
|
|
1324
|
+
state[key] = getter ? getter(gl2, Number(key)) : gl2.getParameter(Number(key));
|
|
1335
1325
|
}
|
|
1336
1326
|
return state;
|
|
1337
1327
|
}
|
|
@@ -1365,7 +1355,7 @@ function deepArrayEqual(x, y) {
|
|
|
1365
1355
|
|
|
1366
1356
|
// src/context/state-tracker/track-context-state.ts
|
|
1367
1357
|
var GLState = class {
|
|
1368
|
-
constructor(
|
|
1358
|
+
constructor(gl2, {
|
|
1369
1359
|
copyState = false,
|
|
1370
1360
|
// Copy cache from params (slow) or initialize from WebGL defaults (fast)
|
|
1371
1361
|
log: log9 = () => {
|
|
@@ -1375,8 +1365,8 @@ var GLState = class {
|
|
|
1375
1365
|
this.program = null;
|
|
1376
1366
|
this.stateStack = [];
|
|
1377
1367
|
this.enable = true;
|
|
1378
|
-
this.gl =
|
|
1379
|
-
this.cache = copyState ? getParameters(
|
|
1368
|
+
this.gl = gl2;
|
|
1369
|
+
this.cache = copyState ? getParameters(gl2) : Object.assign({}, GL_PARAMETER_DEFAULTS);
|
|
1380
1370
|
this.log = log9;
|
|
1381
1371
|
this._updateCache = this._updateCache.bind(this);
|
|
1382
1372
|
Object.seal(this);
|
|
@@ -1416,46 +1406,46 @@ var GLState = class {
|
|
|
1416
1406
|
return { valueChanged, oldValue };
|
|
1417
1407
|
}
|
|
1418
1408
|
};
|
|
1419
|
-
function getContextState(
|
|
1420
|
-
return
|
|
1409
|
+
function getContextState(gl2) {
|
|
1410
|
+
return gl2.state;
|
|
1421
1411
|
}
|
|
1422
|
-
function trackContextState(
|
|
1412
|
+
function trackContextState(gl2, options) {
|
|
1423
1413
|
const { enable: enable2 = true, copyState } = options;
|
|
1424
1414
|
(0, import_api4.assert)(copyState !== void 0);
|
|
1425
|
-
if (!
|
|
1426
|
-
|
|
1427
|
-
installProgramSpy(
|
|
1415
|
+
if (!gl2.state) {
|
|
1416
|
+
gl2.state = new GLState(gl2, { copyState });
|
|
1417
|
+
installProgramSpy(gl2);
|
|
1428
1418
|
for (const key in GL_HOOKED_SETTERS) {
|
|
1429
1419
|
const setter = GL_HOOKED_SETTERS[key];
|
|
1430
|
-
installSetterSpy(
|
|
1420
|
+
installSetterSpy(gl2, key, setter);
|
|
1431
1421
|
}
|
|
1432
|
-
installGetterOverride(
|
|
1433
|
-
installGetterOverride(
|
|
1422
|
+
installGetterOverride(gl2, "getParameter");
|
|
1423
|
+
installGetterOverride(gl2, "isEnabled");
|
|
1434
1424
|
}
|
|
1435
|
-
const glState = getContextState(
|
|
1425
|
+
const glState = getContextState(gl2);
|
|
1436
1426
|
glState.enable = enable2;
|
|
1437
|
-
return
|
|
1427
|
+
return gl2;
|
|
1438
1428
|
}
|
|
1439
|
-
function pushContextState(
|
|
1440
|
-
let glState = getContextState(
|
|
1429
|
+
function pushContextState(gl2) {
|
|
1430
|
+
let glState = getContextState(gl2);
|
|
1441
1431
|
if (!glState) {
|
|
1442
|
-
trackContextState(
|
|
1443
|
-
glState = getContextState(
|
|
1432
|
+
trackContextState(gl2, { copyState: false });
|
|
1433
|
+
glState = getContextState(gl2);
|
|
1444
1434
|
}
|
|
1445
1435
|
glState.push();
|
|
1446
1436
|
}
|
|
1447
|
-
function popContextState(
|
|
1448
|
-
const glState = getContextState(
|
|
1437
|
+
function popContextState(gl2) {
|
|
1438
|
+
const glState = getContextState(gl2);
|
|
1449
1439
|
(0, import_api4.assert)(glState);
|
|
1450
1440
|
glState.pop();
|
|
1451
1441
|
}
|
|
1452
|
-
function installGetterOverride(
|
|
1453
|
-
const originalGetterFunc =
|
|
1454
|
-
|
|
1442
|
+
function installGetterOverride(gl2, functionName) {
|
|
1443
|
+
const originalGetterFunc = gl2[functionName].bind(gl2);
|
|
1444
|
+
gl2[functionName] = function get(pname) {
|
|
1455
1445
|
if (pname === void 0 || NON_CACHE_PARAMETERS.has(pname)) {
|
|
1456
1446
|
return originalGetterFunc(pname);
|
|
1457
1447
|
}
|
|
1458
|
-
const glState = getContextState(
|
|
1448
|
+
const glState = getContextState(gl2);
|
|
1459
1449
|
if (!(pname in glState.cache)) {
|
|
1460
1450
|
glState.cache[pname] = originalGetterFunc(pname);
|
|
1461
1451
|
}
|
|
@@ -1467,33 +1457,33 @@ function installGetterOverride(gl, functionName) {
|
|
|
1467
1457
|
originalGetterFunc(pname)
|
|
1468
1458
|
);
|
|
1469
1459
|
};
|
|
1470
|
-
Object.defineProperty(
|
|
1460
|
+
Object.defineProperty(gl2[functionName], "name", {
|
|
1471
1461
|
value: `${functionName}-from-cache`,
|
|
1472
1462
|
configurable: false
|
|
1473
1463
|
});
|
|
1474
1464
|
}
|
|
1475
|
-
function installSetterSpy(
|
|
1476
|
-
if (!
|
|
1465
|
+
function installSetterSpy(gl2, functionName, setter) {
|
|
1466
|
+
if (!gl2[functionName]) {
|
|
1477
1467
|
return;
|
|
1478
1468
|
}
|
|
1479
|
-
const originalSetterFunc =
|
|
1480
|
-
|
|
1481
|
-
const glState = getContextState(
|
|
1469
|
+
const originalSetterFunc = gl2[functionName].bind(gl2);
|
|
1470
|
+
gl2[functionName] = function set(...params) {
|
|
1471
|
+
const glState = getContextState(gl2);
|
|
1482
1472
|
const { valueChanged, oldValue } = setter(glState._updateCache, ...params);
|
|
1483
1473
|
if (valueChanged) {
|
|
1484
1474
|
originalSetterFunc(...params);
|
|
1485
1475
|
}
|
|
1486
1476
|
return oldValue;
|
|
1487
1477
|
};
|
|
1488
|
-
Object.defineProperty(
|
|
1478
|
+
Object.defineProperty(gl2[functionName], "name", {
|
|
1489
1479
|
value: `${functionName}-to-cache`,
|
|
1490
1480
|
configurable: false
|
|
1491
1481
|
});
|
|
1492
1482
|
}
|
|
1493
|
-
function installProgramSpy(
|
|
1494
|
-
const originalUseProgram =
|
|
1495
|
-
|
|
1496
|
-
const glState = getContextState(
|
|
1483
|
+
function installProgramSpy(gl2) {
|
|
1484
|
+
const originalUseProgram = gl2.useProgram.bind(gl2);
|
|
1485
|
+
gl2.useProgram = function useProgramLuma(handle) {
|
|
1486
|
+
const glState = getContextState(gl2);
|
|
1497
1487
|
if (glState.program !== handle) {
|
|
1498
1488
|
originalUseProgram(handle);
|
|
1499
1489
|
glState.program = handle;
|
|
@@ -1519,21 +1509,21 @@ function createBrowserContext(canvas, props) {
|
|
|
1519
1509
|
let errorMessage = null;
|
|
1520
1510
|
const onCreateError = (error2) => errorMessage = error2.statusMessage || errorMessage;
|
|
1521
1511
|
canvas.addEventListener("webglcontextcreationerror", onCreateError, false);
|
|
1522
|
-
let
|
|
1512
|
+
let gl2 = null;
|
|
1523
1513
|
if (props.type === "webgl2") {
|
|
1524
1514
|
props = __spreadProps(__spreadValues({}, props), { webgl1: false });
|
|
1525
1515
|
}
|
|
1526
1516
|
if (props.type === "webgl1") {
|
|
1527
1517
|
props = __spreadProps(__spreadValues({}, props), { webgl2: false });
|
|
1528
1518
|
}
|
|
1529
|
-
if (!
|
|
1530
|
-
|
|
1519
|
+
if (!gl2 && props.webgl2) {
|
|
1520
|
+
gl2 = canvas.getContext("webgl2", props);
|
|
1531
1521
|
}
|
|
1532
|
-
if (!
|
|
1533
|
-
|
|
1522
|
+
if (!gl2 && props.webgl1) {
|
|
1523
|
+
gl2 = canvas.getContext("webgl", props);
|
|
1534
1524
|
}
|
|
1535
1525
|
canvas.removeEventListener("webglcontextcreationerror", onCreateError, false);
|
|
1536
|
-
if (!
|
|
1526
|
+
if (!gl2) {
|
|
1537
1527
|
throw new Error(
|
|
1538
1528
|
`Failed to create ${props.webgl2 && !props.webgl1 ? "WebGL2" : "WebGL"} context: ${errorMessage || "Unknown error"}`
|
|
1539
1529
|
);
|
|
@@ -1550,29 +1540,29 @@ function createBrowserContext(canvas, props) {
|
|
|
1550
1540
|
false
|
|
1551
1541
|
);
|
|
1552
1542
|
}
|
|
1553
|
-
return
|
|
1543
|
+
return gl2;
|
|
1554
1544
|
}
|
|
1555
1545
|
|
|
1556
1546
|
// src/adapter/device-helpers/get-device-info.ts
|
|
1557
|
-
var import_constants4 =
|
|
1558
|
-
function getDeviceInfo(
|
|
1559
|
-
const vendorMasked =
|
|
1560
|
-
const rendererMasked =
|
|
1561
|
-
const ext =
|
|
1562
|
-
const vendorUnmasked =
|
|
1563
|
-
const rendererUnmasked =
|
|
1547
|
+
var import_constants4 = require("@luma.gl/constants");
|
|
1548
|
+
function getDeviceInfo(gl2) {
|
|
1549
|
+
const vendorMasked = gl2.getParameter(import_constants4.GL.VENDOR);
|
|
1550
|
+
const rendererMasked = gl2.getParameter(import_constants4.GL.RENDERER);
|
|
1551
|
+
const ext = gl2.getExtension("WEBGL_debug_renderer_info");
|
|
1552
|
+
const vendorUnmasked = gl2.getParameter(ext ? ext.UNMASKED_VENDOR_WEBGL : import_constants4.GL.VENDOR);
|
|
1553
|
+
const rendererUnmasked = gl2.getParameter(ext ? ext.UNMASKED_RENDERER_WEBGL : import_constants4.GL.RENDERER);
|
|
1564
1554
|
const vendor = vendorUnmasked || vendorMasked;
|
|
1565
1555
|
const renderer = rendererUnmasked || rendererMasked;
|
|
1566
1556
|
const gpu = identifyGPUVendor(vendor, renderer);
|
|
1567
1557
|
return {
|
|
1568
|
-
type: isWebGL2(
|
|
1558
|
+
type: isWebGL2(gl2) ? "webgl2" : "webgl",
|
|
1569
1559
|
gpu,
|
|
1570
1560
|
vendor: vendorUnmasked || vendorMasked,
|
|
1571
1561
|
renderer: rendererUnmasked || rendererMasked,
|
|
1572
|
-
version:
|
|
1562
|
+
version: gl2.getParameter(import_constants4.GL.VERSION),
|
|
1573
1563
|
shadingLanguages: ["glsl"],
|
|
1574
1564
|
shadingLanguageVersions: {
|
|
1575
|
-
"glsl":
|
|
1565
|
+
"glsl": gl2.getParameter(import_constants4.GL.SHADING_LANGUAGE_VERSION)
|
|
1576
1566
|
}
|
|
1577
1567
|
};
|
|
1578
1568
|
}
|
|
@@ -1606,7 +1596,7 @@ function isOldIE(opts = {}) {
|
|
|
1606
1596
|
|
|
1607
1597
|
// src/adapter/converters/texture-formats.ts
|
|
1608
1598
|
var import_api5 = require("@luma.gl/api");
|
|
1609
|
-
var import_constants5 =
|
|
1599
|
+
var import_constants5 = require("@luma.gl/constants");
|
|
1610
1600
|
var texture_compression_bc = "texture-compression-bc";
|
|
1611
1601
|
var texture_compression_astc = "texture-compression-astc";
|
|
1612
1602
|
var texture_compression_etc2 = "texture-compression-etc2";
|
|
@@ -1626,264 +1616,264 @@ var EXT_SRGB = "EXT_sRGB";
|
|
|
1626
1616
|
var EXT_TEXTURE_NORM16 = "EXT_texture_norm16";
|
|
1627
1617
|
var EXT_FLOAT_WEBGL1 = "WEBGL_color_buffer_float";
|
|
1628
1618
|
var EXT_FLOAT_RENDER_WEBGL2 = "EXT_color_buffer_float";
|
|
1629
|
-
var checkExtension = (
|
|
1630
|
-
var checkExtensions = (
|
|
1619
|
+
var checkExtension = (gl2, extension) => gl2.getExtension(extension);
|
|
1620
|
+
var checkExtensions = (gl2, extensions) => extensions.every((extension) => gl2.getExtension(extension));
|
|
1631
1621
|
var TEXTURE_FEATURE_CHECKS = {
|
|
1632
|
-
"texture-blend-float-webgl1": (
|
|
1633
|
-
"texture-formats-srgb-webgl1": (
|
|
1634
|
-
"texture-formats-depth-webgl1": (
|
|
1635
|
-
"texture-formats-float32-webgl1": (
|
|
1636
|
-
"texture-formats-float16-webgl1": (
|
|
1637
|
-
"texture-formats-norm16-webgl": (
|
|
1638
|
-
"texture-filter-linear-float32-webgl": (
|
|
1639
|
-
"texture-filter-linear-float16-webgl": (
|
|
1640
|
-
"texture-filter-anisotropic-webgl": (
|
|
1641
|
-
"texture-renderable-float32-webgl": (
|
|
1622
|
+
"texture-blend-float-webgl1": (gl2) => isWebGL2(gl2) ? true : checkExtension(gl2, "EXT_float_blend"),
|
|
1623
|
+
"texture-formats-srgb-webgl1": (gl2) => isWebGL2(gl2) ? true : checkExtension(gl2, EXT_SRGB),
|
|
1624
|
+
"texture-formats-depth-webgl1": (gl2) => isWebGL2(gl2) ? true : checkExtension(gl2, "WEBGL_depth_texture"),
|
|
1625
|
+
"texture-formats-float32-webgl1": (gl2) => isWebGL2(gl2) ? true : checkExtension(gl2, "OES_texture_float"),
|
|
1626
|
+
"texture-formats-float16-webgl1": (gl2) => isWebGL2(gl2) ? true : checkExtension(gl2, "OES_texture_half_float"),
|
|
1627
|
+
"texture-formats-norm16-webgl": (gl2) => isWebGL2(gl2) ? checkExtension(gl2, EXT_TEXTURE_NORM16) : false,
|
|
1628
|
+
"texture-filter-linear-float32-webgl": (gl2) => checkExtension(gl2, "OES_texture_float_linear"),
|
|
1629
|
+
"texture-filter-linear-float16-webgl": (gl2) => checkExtension(gl2, "OES_texture_half_float_linear"),
|
|
1630
|
+
"texture-filter-anisotropic-webgl": (gl2) => checkExtension(gl2, "EXT_texture_filter_anisotropic"),
|
|
1631
|
+
"texture-renderable-float32-webgl": (gl2) => checkExtension(gl2, "EXT_color_buffer_float"),
|
|
1642
1632
|
// [false, 'EXT_color_buffer_float'],
|
|
1643
|
-
"texture-renderable-float16-webgl": (
|
|
1644
|
-
"texture-compression-bc": (
|
|
1645
|
-
"texture-compression-bc5-webgl": (
|
|
1633
|
+
"texture-renderable-float16-webgl": (gl2) => checkExtension(gl2, "EXT_color_buffer_half_float"),
|
|
1634
|
+
"texture-compression-bc": (gl2) => checkExtensions(gl2, [X_S3TC, X_S3TC_SRGB, X_RGTC, X_BPTC]),
|
|
1635
|
+
"texture-compression-bc5-webgl": (gl2) => checkExtensions(gl2, [X_RGTC]),
|
|
1646
1636
|
// 'texture-compression-bc7-webgl': gl => checkExtensions(gl, [X_BPTC]),
|
|
1647
1637
|
// 'texture-compression-bc3-srgb-webgl': gl => checkExtensions(gl, [X_S3TC_SRGB]),
|
|
1648
1638
|
// 'texture-compression-bc3-webgl': gl => checkExtensions(gl, [X_S3TC]),
|
|
1649
|
-
"texture-compression-etc2": (
|
|
1650
|
-
"texture-compression-astc": (
|
|
1651
|
-
"texture-compression-etc1-webgl": (
|
|
1652
|
-
"texture-compression-pvrtc-webgl": (
|
|
1653
|
-
"texture-compression-atc-webgl": (
|
|
1639
|
+
"texture-compression-etc2": (gl2) => checkExtensions(gl2, [X_ETC2]),
|
|
1640
|
+
"texture-compression-astc": (gl2) => checkExtensions(gl2, [X_ASTC]),
|
|
1641
|
+
"texture-compression-etc1-webgl": (gl2) => checkExtensions(gl2, [X_ETC1]),
|
|
1642
|
+
"texture-compression-pvrtc-webgl": (gl2) => checkExtensions(gl2, [X_PVRTC]),
|
|
1643
|
+
"texture-compression-atc-webgl": (gl2) => checkExtensions(gl2, [X_ATC])
|
|
1654
1644
|
};
|
|
1655
|
-
function checkTextureFeature(
|
|
1645
|
+
function checkTextureFeature(gl2, feature) {
|
|
1656
1646
|
var _a;
|
|
1657
|
-
return ((_a = TEXTURE_FEATURE_CHECKS[feature]) == null ? void 0 : _a.call(TEXTURE_FEATURE_CHECKS,
|
|
1647
|
+
return ((_a = TEXTURE_FEATURE_CHECKS[feature]) == null ? void 0 : _a.call(TEXTURE_FEATURE_CHECKS, gl2)) || false;
|
|
1658
1648
|
}
|
|
1659
|
-
function getTextureFeatures(
|
|
1649
|
+
function getTextureFeatures(gl2) {
|
|
1660
1650
|
const textureFeatures = Object.keys(TEXTURE_FEATURE_CHECKS);
|
|
1661
|
-
return textureFeatures.filter((feature) => checkTextureFeature(
|
|
1651
|
+
return textureFeatures.filter((feature) => checkTextureFeature(gl2, feature));
|
|
1662
1652
|
}
|
|
1663
1653
|
var TEXTURE_FORMATS = {
|
|
1664
1654
|
// Unsized formats that leave the precision up to the driver.
|
|
1665
1655
|
// TODO - Fix bpp constants
|
|
1666
1656
|
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
1667
1657
|
"rgb8unorm-unsized": {
|
|
1668
|
-
gl: import_constants5.
|
|
1669
|
-
gl1: import_constants5.
|
|
1658
|
+
gl: import_constants5.GL.RGB,
|
|
1659
|
+
gl1: import_constants5.GL.RGB,
|
|
1670
1660
|
b: 4,
|
|
1671
1661
|
c: 2,
|
|
1672
1662
|
bpp: 4,
|
|
1673
|
-
dataFormat: import_constants5.
|
|
1674
|
-
types: [import_constants5.
|
|
1663
|
+
dataFormat: import_constants5.GL.RGB,
|
|
1664
|
+
types: [import_constants5.GL.UNSIGNED_BYTE, import_constants5.GL.UNSIGNED_SHORT_5_6_5]
|
|
1675
1665
|
},
|
|
1676
1666
|
"rgba8unorm-unsized": {
|
|
1677
|
-
gl: import_constants5.
|
|
1678
|
-
gl1: import_constants5.
|
|
1667
|
+
gl: import_constants5.GL.RGBA,
|
|
1668
|
+
gl1: import_constants5.GL.RGBA,
|
|
1679
1669
|
b: 4,
|
|
1680
1670
|
c: 2,
|
|
1681
1671
|
bpp: 4,
|
|
1682
|
-
dataFormat: import_constants5.
|
|
1683
|
-
types: [import_constants5.
|
|
1672
|
+
dataFormat: import_constants5.GL.RGBA,
|
|
1673
|
+
types: [import_constants5.GL.UNSIGNED_BYTE, import_constants5.GL.UNSIGNED_SHORT_4_4_4_4, import_constants5.GL.UNSIGNED_SHORT_5_5_5_1]
|
|
1684
1674
|
},
|
|
1685
1675
|
// 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
1686
1676
|
// 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
1687
1677
|
// 8-bit formats
|
|
1688
|
-
"r8unorm": { gl: import_constants5.
|
|
1689
|
-
"r8snorm": { gl: import_constants5.
|
|
1690
|
-
"r8uint": { gl: import_constants5.
|
|
1691
|
-
"r8sint": { gl: import_constants5.
|
|
1678
|
+
"r8unorm": { gl: import_constants5.GL.R8, b: 1, c: 1, renderbuffer: true },
|
|
1679
|
+
"r8snorm": { gl: import_constants5.GL.R8_SNORM, b: 1, c: 1 },
|
|
1680
|
+
"r8uint": { gl: import_constants5.GL.R8UI, b: 1, c: 1, renderbuffer: true },
|
|
1681
|
+
"r8sint": { gl: import_constants5.GL.R8I, b: 1, c: 1, renderbuffer: true },
|
|
1692
1682
|
// 16-bit formats
|
|
1693
|
-
"rg8unorm": { gl: import_constants5.
|
|
1694
|
-
"rg8snorm": { gl: import_constants5.
|
|
1695
|
-
"rg8uint": { gl: import_constants5.
|
|
1696
|
-
"rg8sint": { gl: import_constants5.
|
|
1697
|
-
"r16uint": { gl: import_constants5.
|
|
1698
|
-
"r16sint": { gl: import_constants5.
|
|
1699
|
-
"r16float": { gl: import_constants5.
|
|
1700
|
-
"r16unorm-webgl": { gl: import_constants5.
|
|
1701
|
-
"r16snorm-webgl": { gl: import_constants5.
|
|
1683
|
+
"rg8unorm": { gl: import_constants5.GL.RG8, b: 2, c: 2, renderbuffer: true },
|
|
1684
|
+
"rg8snorm": { gl: import_constants5.GL.RG8_SNORM, b: 2, c: 2 },
|
|
1685
|
+
"rg8uint": { gl: import_constants5.GL.RG8UI, b: 2, c: 2, renderbuffer: true },
|
|
1686
|
+
"rg8sint": { gl: import_constants5.GL.RG8I, b: 2, c: 2, renderbuffer: true },
|
|
1687
|
+
"r16uint": { gl: import_constants5.GL.R16UI, b: 2, c: 1, renderbuffer: true },
|
|
1688
|
+
"r16sint": { gl: import_constants5.GL.R16I, b: 2, c: 1, renderbuffer: true },
|
|
1689
|
+
"r16float": { gl: import_constants5.GL.R16F, b: 2, c: 1, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl", renderbuffer: true },
|
|
1690
|
+
"r16unorm-webgl": { gl: import_constants5.GL.R16_EXT, b: 2, c: 1, f: "texture-formats-norm16-webgl", renderbuffer: true, x: EXT_TEXTURE_NORM16 },
|
|
1691
|
+
"r16snorm-webgl": { gl: import_constants5.GL.R16_SNORM_EXT, b: 2, c: 1, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
|
|
1702
1692
|
// Packed 16-bit formats
|
|
1703
|
-
"rgba4unorm-webgl": { gl: import_constants5.
|
|
1704
|
-
"rgb565unorm-webgl": { gl: import_constants5.
|
|
1705
|
-
"rgb5a1unorm-webgl": { gl: import_constants5.
|
|
1693
|
+
"rgba4unorm-webgl": { gl: import_constants5.GL.RGBA4, b: 2, c: 4, wgpu: false, renderbuffer: true },
|
|
1694
|
+
"rgb565unorm-webgl": { gl: import_constants5.GL.RGB565, b: 2, c: 4, wgpu: false, renderbuffer: true },
|
|
1695
|
+
"rgb5a1unorm-webgl": { gl: import_constants5.GL.RGB5_A1, b: 2, c: 4, wgpu: false, renderbuffer: true },
|
|
1706
1696
|
// 24-bit formats
|
|
1707
|
-
"rgb8unorm-webgl": { gl: import_constants5.
|
|
1708
|
-
"rgb8snorm-webgl": { gl: import_constants5.
|
|
1697
|
+
"rgb8unorm-webgl": { gl: import_constants5.GL.RGB8, b: 3, c: 3, wgpu: false },
|
|
1698
|
+
"rgb8snorm-webgl": { gl: import_constants5.GL.RGB8_SNORM, b: 3, c: 3, wgpu: false },
|
|
1709
1699
|
// 32-bit formats
|
|
1710
|
-
"rgba8unorm": { gl: import_constants5.
|
|
1711
|
-
"rgba8unorm-srgb": { gl: import_constants5.
|
|
1712
|
-
"rgba8snorm": { gl: import_constants5.
|
|
1713
|
-
"rgba8uint": { gl: import_constants5.
|
|
1714
|
-
"rgba8sint": { gl: import_constants5.
|
|
1700
|
+
"rgba8unorm": { gl: import_constants5.GL.RGBA8, gl1: import_constants5.GL.RGBA, b: 4, c: 2, bpp: 4 },
|
|
1701
|
+
"rgba8unorm-srgb": { gl: import_constants5.GL.SRGB8_ALPHA8, gl1: import_constants5.GL.SRGB_ALPHA_EXT, b: 4, c: 4, gl1ext: EXT_SRGB, bpp: 4 },
|
|
1702
|
+
"rgba8snorm": { gl: import_constants5.GL.RGBA8_SNORM, b: 4, c: 4 },
|
|
1703
|
+
"rgba8uint": { gl: import_constants5.GL.RGBA8UI, b: 4, c: 4, bpp: 4 },
|
|
1704
|
+
"rgba8sint": { gl: import_constants5.GL.RGBA8I, b: 4, c: 4, bpp: 4 },
|
|
1715
1705
|
// reverse colors, webgpu only
|
|
1716
1706
|
"bgra8unorm": { b: 4, c: 4 },
|
|
1717
1707
|
"bgra8unorm-srgb": { b: 4, c: 4 },
|
|
1718
|
-
"rg16uint": { gl: import_constants5.
|
|
1719
|
-
"rg16sint": { gl: import_constants5.
|
|
1708
|
+
"rg16uint": { gl: import_constants5.GL.RG16UI, b: 4, c: 1, bpp: 4 },
|
|
1709
|
+
"rg16sint": { gl: import_constants5.GL.RG16I, b: 4, c: 2, bpp: 4 },
|
|
1720
1710
|
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
1721
|
-
"rg16float": { gl: import_constants5.
|
|
1722
|
-
"rg16unorm-webgl": { gl: import_constants5.
|
|
1723
|
-
"rg16snorm-webgl": { gl: import_constants5.
|
|
1724
|
-
"r32uint": { gl: import_constants5.
|
|
1725
|
-
"r32sint": { gl: import_constants5.
|
|
1726
|
-
"r32float": { gl: import_constants5.
|
|
1711
|
+
"rg16float": { gl: import_constants5.GL.RG16F, bpp: 4, b: 4, c: 2, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl", renderbuffer: true },
|
|
1712
|
+
"rg16unorm-webgl": { gl: import_constants5.GL.RG16_EXT, b: 2, c: 2, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
|
|
1713
|
+
"rg16snorm-webgl": { gl: import_constants5.GL.RG16_SNORM_EXT, b: 2, c: 2, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
|
|
1714
|
+
"r32uint": { gl: import_constants5.GL.R32UI, b: 4, c: 1, bpp: 4, renderbuffer: true },
|
|
1715
|
+
"r32sint": { gl: import_constants5.GL.R32I, b: 4, c: 1, bpp: 4, renderbuffer: true },
|
|
1716
|
+
"r32float": { gl: import_constants5.GL.R32F, bpp: 4, b: 4, c: 1, render: "texture-renderable-float32-webgl", filter: "texture-filter-linear-float32-webgl" },
|
|
1727
1717
|
// Packed 32-bit formats
|
|
1728
|
-
"rgb9e5ufloat": { gl: import_constants5.
|
|
1729
|
-
"rg11b10ufloat": { gl: import_constants5.
|
|
1730
|
-
"rgb10a2unorm": { gl: import_constants5.
|
|
1718
|
+
"rgb9e5ufloat": { gl: import_constants5.GL.RGB9_E5, b: 4, c: 3, p: 1, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl" },
|
|
1719
|
+
"rg11b10ufloat": { gl: import_constants5.GL.R11F_G11F_B10F, b: 4, c: 3, p: 1, render: "texture-renderable-float32-webgl", renderbuffer: true },
|
|
1720
|
+
"rgb10a2unorm": { gl: import_constants5.GL.RGB10_A2, b: 4, c: 4, p: 1, renderbuffer: true },
|
|
1731
1721
|
// webgl2 only
|
|
1732
|
-
"rgb10a2unorm-webgl": { b: 4, c: 4, gl: import_constants5.
|
|
1722
|
+
"rgb10a2unorm-webgl": { b: 4, c: 4, gl: import_constants5.GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, renderbuffer: true },
|
|
1733
1723
|
// 48-bit formats
|
|
1734
|
-
"rgb16unorm-webgl": { gl: import_constants5.
|
|
1735
|
-
"rgb16snorm-webgl": { gl: import_constants5.
|
|
1724
|
+
"rgb16unorm-webgl": { gl: import_constants5.GL.RGB16_EXT, b: 2, c: 3, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
|
|
1725
|
+
"rgb16snorm-webgl": { gl: import_constants5.GL.RGB16_SNORM_EXT, b: 2, c: 3, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
|
|
1736
1726
|
// 64-bit formats
|
|
1737
|
-
"rg32uint": { gl: import_constants5.
|
|
1738
|
-
"rg32sint": { gl: import_constants5.
|
|
1739
|
-
"rg32float": { gl: import_constants5.
|
|
1740
|
-
"rgba16uint": { gl: import_constants5.
|
|
1741
|
-
"rgba16sint": { gl: import_constants5.
|
|
1742
|
-
"rgba16float": { gl: import_constants5.
|
|
1743
|
-
"rgba16unorm-webgl": { gl: import_constants5.
|
|
1744
|
-
"rgba16snorm-webgl": { gl: import_constants5.
|
|
1727
|
+
"rg32uint": { gl: import_constants5.GL.RG32UI, b: 8, c: 2, renderbuffer: true },
|
|
1728
|
+
"rg32sint": { gl: import_constants5.GL.RG32I, b: 8, c: 2, renderbuffer: true },
|
|
1729
|
+
"rg32float": { gl: import_constants5.GL.RG32F, b: 8, c: 2, render: "texture-renderable-float32-webgl", filter: "texture-filter-linear-float32-webgl", renderbuffer: true },
|
|
1730
|
+
"rgba16uint": { gl: import_constants5.GL.RGBA16UI, b: 8, c: 4, renderbuffer: true },
|
|
1731
|
+
"rgba16sint": { gl: import_constants5.GL.RGBA16I, b: 8, c: 4, renderbuffer: true },
|
|
1732
|
+
"rgba16float": { gl: import_constants5.GL.RGBA16F, gl1: import_constants5.GL.RGBA, b: 8, c: 4, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl" },
|
|
1733
|
+
"rgba16unorm-webgl": { gl: import_constants5.GL.RGBA16_EXT, b: 2, c: 4, f: "texture-formats-norm16-webgl", renderbuffer: true, x: EXT_TEXTURE_NORM16 },
|
|
1734
|
+
"rgba16snorm-webgl": { gl: import_constants5.GL.RGBA16_SNORM_EXT, b: 2, c: 4, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
|
|
1745
1735
|
// 96-bit formats (deprecated!)
|
|
1746
1736
|
"rgb32float-webgl": {
|
|
1747
|
-
gl: import_constants5.
|
|
1748
|
-
gl1: import_constants5.
|
|
1737
|
+
gl: import_constants5.GL.RGB32F,
|
|
1738
|
+
gl1: import_constants5.GL.RGB,
|
|
1749
1739
|
render: "texture-renderable-float32-webgl",
|
|
1750
1740
|
filter: "texture-filter-linear-float32-webgl",
|
|
1751
1741
|
gl2ext: EXT_FLOAT_RENDER_WEBGL2,
|
|
1752
1742
|
gl1ext: EXT_FLOAT_WEBGL1,
|
|
1753
1743
|
// WebGL1 render buffers are supported with GL.RGB32F
|
|
1754
|
-
dataFormat: import_constants5.
|
|
1755
|
-
types: [import_constants5.
|
|
1744
|
+
dataFormat: import_constants5.GL.RGB,
|
|
1745
|
+
types: [import_constants5.GL.FLOAT]
|
|
1756
1746
|
},
|
|
1757
1747
|
// 128-bit formats
|
|
1758
|
-
"rgba32uint": { gl: import_constants5.
|
|
1759
|
-
"rgba32sint": { gl: import_constants5.
|
|
1760
|
-
"rgba32float": { gl: import_constants5.
|
|
1748
|
+
"rgba32uint": { gl: import_constants5.GL.RGBA32UI, b: 16, c: 4, renderbuffer: true },
|
|
1749
|
+
"rgba32sint": { gl: import_constants5.GL.RGBA32I, b: 16, c: 4, renderbuffer: true },
|
|
1750
|
+
"rgba32float": { gl: import_constants5.GL.RGBA32F, b: 16, c: 4, render: "texture-renderable-float32-webgl", filter: "texture-filter-linear-float32-webgl", renderbuffer: true },
|
|
1761
1751
|
// Depth and stencil formats
|
|
1762
|
-
"stencil8": { gl: import_constants5.
|
|
1752
|
+
"stencil8": { gl: import_constants5.GL.STENCIL_INDEX8, gl1: import_constants5.GL.STENCIL_INDEX8, b: 1, c: 1, attachment: import_constants5.GL.STENCIL_ATTACHMENT, renderbuffer: true },
|
|
1763
1753
|
// 8 stencil bits
|
|
1764
|
-
"depth16unorm": { gl: import_constants5.
|
|
1754
|
+
"depth16unorm": { gl: import_constants5.GL.DEPTH_COMPONENT16, gl1: import_constants5.GL.DEPTH_COMPONENT16, b: 2, c: 1, attachment: import_constants5.GL.DEPTH_ATTACHMENT, renderbuffer: true },
|
|
1765
1755
|
// 16 depth bits
|
|
1766
|
-
"depth24plus": { gl: import_constants5.
|
|
1767
|
-
"depth32float": { gl: import_constants5.
|
|
1756
|
+
"depth24plus": { gl: import_constants5.GL.DEPTH_COMPONENT24, b: 3, c: 1, attachment: import_constants5.GL.DEPTH_ATTACHMENT },
|
|
1757
|
+
"depth32float": { gl: import_constants5.GL.DEPTH_COMPONENT32F, b: 4, c: 1, attachment: import_constants5.GL.DEPTH_ATTACHMENT, renderbuffer: true },
|
|
1768
1758
|
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
1769
|
-
"depth24plus-stencil8": { gl: import_constants5.
|
|
1759
|
+
"depth24plus-stencil8": { gl: import_constants5.GL.DEPTH_STENCIL, gl1: import_constants5.GL.DEPTH_STENCIL, b: 4, c: 2, p: 1, attachment: import_constants5.GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true, depthTexture: true },
|
|
1770
1760
|
// "depth24unorm-stencil8" feature
|
|
1771
|
-
"depth24unorm-stencil8": { gl: import_constants5.
|
|
1761
|
+
"depth24unorm-stencil8": { gl: import_constants5.GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: import_constants5.GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true },
|
|
1772
1762
|
// "depth32float-stencil8" feature
|
|
1773
|
-
"depth32float-stencil8": { gl: import_constants5.
|
|
1763
|
+
"depth32float-stencil8": { gl: import_constants5.GL.DEPTH32F_STENCIL8, b: 5, c: 2, p: 1, attachment: import_constants5.GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true },
|
|
1774
1764
|
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
1775
|
-
"bc1-rgb-unorm-webgl": { gl: import_constants5.
|
|
1776
|
-
"bc1-rgb-unorm-srgb-webgl": { gl: import_constants5.
|
|
1777
|
-
"bc1-rgba-unorm": { gl: import_constants5.
|
|
1778
|
-
"bc1-rgba-unorm-srgb": { gl: import_constants5.
|
|
1779
|
-
"bc2-rgba-unorm": { gl: import_constants5.
|
|
1780
|
-
"bc2-rgba-unorm-srgb": { gl: import_constants5.
|
|
1781
|
-
"bc3-rgba-unorm": { gl: import_constants5.
|
|
1782
|
-
"bc3-rgba-unorm-srgb": { gl: import_constants5.
|
|
1783
|
-
"bc4-r-unorm": { gl: import_constants5.
|
|
1784
|
-
"bc4-r-snorm": { gl: import_constants5.
|
|
1785
|
-
"bc5-rg-unorm": { gl: import_constants5.
|
|
1786
|
-
"bc5-rg-snorm": { gl: import_constants5.
|
|
1787
|
-
"bc6h-rgb-ufloat": { gl: import_constants5.
|
|
1788
|
-
"bc6h-rgb-float": { gl: import_constants5.
|
|
1789
|
-
"bc7-rgba-unorm": { gl: import_constants5.
|
|
1790
|
-
"bc7-rgba-unorm-srgb": { gl: import_constants5.
|
|
1765
|
+
"bc1-rgb-unorm-webgl": { gl: import_constants5.GL.COMPRESSED_RGB_S3TC_DXT1_EXT, x: X_S3TC, f: texture_compression_bc },
|
|
1766
|
+
"bc1-rgb-unorm-srgb-webgl": { gl: import_constants5.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
1767
|
+
"bc1-rgba-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_S3TC_DXT1_EXT, x: X_S3TC, f: texture_compression_bc },
|
|
1768
|
+
"bc1-rgba-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
1769
|
+
"bc2-rgba-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_S3TC_DXT3_EXT, x: X_S3TC, f: texture_compression_bc },
|
|
1770
|
+
"bc2-rgba-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
1771
|
+
"bc3-rgba-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_S3TC_DXT5_EXT, x: X_S3TC, f: texture_compression_bc },
|
|
1772
|
+
"bc3-rgba-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
1773
|
+
"bc4-r-unorm": { gl: import_constants5.GL.COMPRESSED_RED_RGTC1_EXT, x: X_RGTC, f: texture_compression_bc },
|
|
1774
|
+
"bc4-r-snorm": { gl: import_constants5.GL.COMPRESSED_SIGNED_RED_RGTC1_EXT, x: X_RGTC, f: texture_compression_bc },
|
|
1775
|
+
"bc5-rg-unorm": { gl: import_constants5.GL.COMPRESSED_RED_GREEN_RGTC2_EXT, x: X_RGTC, f: texture_compression_bc },
|
|
1776
|
+
"bc5-rg-snorm": { gl: import_constants5.GL.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, x: X_RGTC, f: texture_compression_bc },
|
|
1777
|
+
"bc6h-rgb-ufloat": { gl: import_constants5.GL.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, x: X_BPTC, f: texture_compression_bc },
|
|
1778
|
+
"bc6h-rgb-float": { gl: import_constants5.GL.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, x: X_BPTC, f: texture_compression_bc },
|
|
1779
|
+
"bc7-rgba-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_BPTC_UNORM_EXT, x: X_BPTC, f: texture_compression_bc },
|
|
1780
|
+
"bc7-rgba-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, x: X_BPTC, f: texture_compression_bc },
|
|
1791
1781
|
// WEBGL_compressed_texture_etc: device.features.has("texture-compression-etc2")
|
|
1792
1782
|
// Note: Supposedly guaranteed availability compressed formats in WebGL2, but through CPU decompression
|
|
1793
|
-
"etc2-rgb8unorm": { gl: import_constants5.
|
|
1794
|
-
"etc2-rgb8unorm-srgb": { gl: import_constants5.
|
|
1795
|
-
"etc2-rgb8a1unorm": { gl: import_constants5.
|
|
1796
|
-
"etc2-rgb8a1unorm-srgb": { gl: import_constants5.
|
|
1797
|
-
"etc2-rgba8unorm": { gl: import_constants5.
|
|
1798
|
-
"etc2-rgba8unorm-srgb": { gl: import_constants5.
|
|
1799
|
-
"eac-r11unorm": { gl: import_constants5.
|
|
1800
|
-
"eac-r11snorm": { gl: import_constants5.
|
|
1801
|
-
"eac-rg11unorm": { gl: import_constants5.
|
|
1802
|
-
"eac-rg11snorm": { gl: import_constants5.
|
|
1783
|
+
"etc2-rgb8unorm": { gl: import_constants5.GL.COMPRESSED_RGB8_ETC2, f: texture_compression_etc2 },
|
|
1784
|
+
"etc2-rgb8unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ETC2, f: texture_compression_etc2 },
|
|
1785
|
+
"etc2-rgb8a1unorm": { gl: import_constants5.GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, f: texture_compression_etc2 },
|
|
1786
|
+
"etc2-rgb8a1unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, f: texture_compression_etc2 },
|
|
1787
|
+
"etc2-rgba8unorm": { gl: import_constants5.GL.COMPRESSED_RGBA8_ETC2_EAC, f: texture_compression_etc2 },
|
|
1788
|
+
"etc2-rgba8unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, f: texture_compression_etc2 },
|
|
1789
|
+
"eac-r11unorm": { gl: import_constants5.GL.COMPRESSED_R11_EAC, f: texture_compression_etc2 },
|
|
1790
|
+
"eac-r11snorm": { gl: import_constants5.GL.COMPRESSED_SIGNED_R11_EAC, f: texture_compression_etc2 },
|
|
1791
|
+
"eac-rg11unorm": { gl: import_constants5.GL.COMPRESSED_RG11_EAC, f: texture_compression_etc2 },
|
|
1792
|
+
"eac-rg11snorm": { gl: import_constants5.GL.COMPRESSED_SIGNED_RG11_EAC, f: texture_compression_etc2 },
|
|
1803
1793
|
// X_ASTC compressed formats: device.features.has("texture-compression-astc")
|
|
1804
|
-
"astc-4x4-unorm": { gl: import_constants5.
|
|
1805
|
-
"astc-4x4-unorm-srgb": { gl: import_constants5.
|
|
1806
|
-
"astc-5x4-unorm": { gl: import_constants5.
|
|
1807
|
-
"astc-5x4-unorm-srgb": { gl: import_constants5.
|
|
1808
|
-
"astc-5x5-unorm": { gl: import_constants5.
|
|
1809
|
-
"astc-5x5-unorm-srgb": { gl: import_constants5.
|
|
1810
|
-
"astc-6x5-unorm": { gl: import_constants5.
|
|
1811
|
-
"astc-6x5-unorm-srgb": { gl: import_constants5.
|
|
1812
|
-
"astc-6x6-unorm": { gl: import_constants5.
|
|
1813
|
-
"astc-6x6-unorm-srgb": { gl: import_constants5.
|
|
1814
|
-
"astc-8x5-unorm": { gl: import_constants5.
|
|
1815
|
-
"astc-8x5-unorm-srgb": { gl: import_constants5.
|
|
1816
|
-
"astc-8x6-unorm": { gl: import_constants5.
|
|
1817
|
-
"astc-8x6-unorm-srgb": { gl: import_constants5.
|
|
1818
|
-
"astc-8x8-unorm": { gl: import_constants5.
|
|
1819
|
-
"astc-8x8-unorm-srgb": { gl: import_constants5.
|
|
1820
|
-
"astc-10x5-unorm": { gl: import_constants5.
|
|
1821
|
-
"astc-10x5-unorm-srgb": { gl: import_constants5.
|
|
1822
|
-
"astc-10x6-unorm": { gl: import_constants5.
|
|
1823
|
-
"astc-10x6-unorm-srgb": { gl: import_constants5.
|
|
1824
|
-
"astc-10x8-unorm": { gl: import_constants5.
|
|
1825
|
-
"astc-10x8-unorm-srgb": { gl: import_constants5.
|
|
1826
|
-
"astc-10x10-unorm": { gl: import_constants5.
|
|
1827
|
-
"astc-10x10-unorm-srgb": { gl: import_constants5.
|
|
1828
|
-
"astc-12x10-unorm": { gl: import_constants5.
|
|
1829
|
-
"astc-12x10-unorm-srgb": { gl: import_constants5.
|
|
1830
|
-
"astc-12x12-unorm": { gl: import_constants5.
|
|
1831
|
-
"astc-12x12-unorm-srgb": { gl: import_constants5.
|
|
1794
|
+
"astc-4x4-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_4x4_KHR, f: texture_compression_astc },
|
|
1795
|
+
"astc-4x4-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, f: texture_compression_astc },
|
|
1796
|
+
"astc-5x4-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_5x4_KHR, f: texture_compression_astc },
|
|
1797
|
+
"astc-5x4-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, f: texture_compression_astc },
|
|
1798
|
+
"astc-5x5-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_5x5_KHR, f: texture_compression_astc },
|
|
1799
|
+
"astc-5x5-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, f: texture_compression_astc },
|
|
1800
|
+
"astc-6x5-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_6x5_KHR, f: texture_compression_astc },
|
|
1801
|
+
"astc-6x5-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, f: texture_compression_astc },
|
|
1802
|
+
"astc-6x6-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_6x6_KHR, f: texture_compression_astc },
|
|
1803
|
+
"astc-6x6-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, f: texture_compression_astc },
|
|
1804
|
+
"astc-8x5-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_8x5_KHR, f: texture_compression_astc },
|
|
1805
|
+
"astc-8x5-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, f: texture_compression_astc },
|
|
1806
|
+
"astc-8x6-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_8x6_KHR, f: texture_compression_astc },
|
|
1807
|
+
"astc-8x6-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, f: texture_compression_astc },
|
|
1808
|
+
"astc-8x8-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_8x8_KHR, f: texture_compression_astc },
|
|
1809
|
+
"astc-8x8-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, f: texture_compression_astc },
|
|
1810
|
+
"astc-10x5-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_10x10_KHR, f: texture_compression_astc },
|
|
1811
|
+
"astc-10x5-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, f: texture_compression_astc },
|
|
1812
|
+
"astc-10x6-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_10x6_KHR, f: texture_compression_astc },
|
|
1813
|
+
"astc-10x6-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, f: texture_compression_astc },
|
|
1814
|
+
"astc-10x8-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_10x8_KHR, f: texture_compression_astc },
|
|
1815
|
+
"astc-10x8-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, f: texture_compression_astc },
|
|
1816
|
+
"astc-10x10-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_10x10_KHR, f: texture_compression_astc },
|
|
1817
|
+
"astc-10x10-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, f: texture_compression_astc },
|
|
1818
|
+
"astc-12x10-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_12x10_KHR, f: texture_compression_astc },
|
|
1819
|
+
"astc-12x10-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, f: texture_compression_astc },
|
|
1820
|
+
"astc-12x12-unorm": { gl: import_constants5.GL.COMPRESSED_RGBA_ASTC_12x12_KHR, f: texture_compression_astc },
|
|
1821
|
+
"astc-12x12-unorm-srgb": { gl: import_constants5.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, f: texture_compression_astc },
|
|
1832
1822
|
// WEBGL_compressed_texture_pvrtc
|
|
1833
|
-
"pvrtc-rgb4unorm-webgl": { gl: import_constants5.
|
|
1834
|
-
"pvrtc-rgba4unorm-webgl": { gl: import_constants5.
|
|
1835
|
-
"pvrtc-rbg2unorm-webgl": { gl: import_constants5.
|
|
1836
|
-
"pvrtc-rgba2unorm-webgl": { gl: import_constants5.
|
|
1823
|
+
"pvrtc-rgb4unorm-webgl": { gl: import_constants5.GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG, f: texture_compression_pvrtc_webgl },
|
|
1824
|
+
"pvrtc-rgba4unorm-webgl": { gl: import_constants5.GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, f: texture_compression_pvrtc_webgl },
|
|
1825
|
+
"pvrtc-rbg2unorm-webgl": { gl: import_constants5.GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG, f: texture_compression_pvrtc_webgl },
|
|
1826
|
+
"pvrtc-rgba2unorm-webgl": { gl: import_constants5.GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, f: texture_compression_pvrtc_webgl },
|
|
1837
1827
|
// WEBGL_compressed_texture_etc1
|
|
1838
|
-
"etc1-rbg-unorm-webgl": { gl: import_constants5.
|
|
1828
|
+
"etc1-rbg-unorm-webgl": { gl: import_constants5.GL.COMPRESSED_RGB_ETC1_WEBGL, f: texture_compression_etc1_webgl },
|
|
1839
1829
|
// WEBGL_compressed_texture_atc
|
|
1840
|
-
"atc-rgb-unorm-webgl": { gl: import_constants5.
|
|
1841
|
-
"atc-rgba-unorm-webgl": { gl: import_constants5.
|
|
1842
|
-
"atc-rgbai-unorm-webgl": { gl: import_constants5.
|
|
1830
|
+
"atc-rgb-unorm-webgl": { gl: import_constants5.GL.COMPRESSED_RGB_ATC_WEBGL, f: texture_compression_atc_webgl },
|
|
1831
|
+
"atc-rgba-unorm-webgl": { gl: import_constants5.GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, f: texture_compression_atc_webgl },
|
|
1832
|
+
"atc-rgbai-unorm-webgl": { gl: import_constants5.GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, f: texture_compression_atc_webgl }
|
|
1843
1833
|
};
|
|
1844
1834
|
var DATA_FORMAT_CHANNELS = {
|
|
1845
|
-
[import_constants5.
|
|
1846
|
-
[import_constants5.
|
|
1847
|
-
[import_constants5.
|
|
1848
|
-
[import_constants5.
|
|
1849
|
-
[import_constants5.
|
|
1850
|
-
[import_constants5.
|
|
1851
|
-
[import_constants5.
|
|
1852
|
-
[import_constants5.
|
|
1853
|
-
[import_constants5.
|
|
1854
|
-
[import_constants5.
|
|
1855
|
-
[import_constants5.
|
|
1856
|
-
[import_constants5.
|
|
1857
|
-
[import_constants5.
|
|
1835
|
+
[import_constants5.GL.RED]: 1,
|
|
1836
|
+
[import_constants5.GL.RED_INTEGER]: 1,
|
|
1837
|
+
[import_constants5.GL.RG]: 2,
|
|
1838
|
+
[import_constants5.GL.RG_INTEGER]: 2,
|
|
1839
|
+
[import_constants5.GL.RGB]: 3,
|
|
1840
|
+
[import_constants5.GL.RGB_INTEGER]: 3,
|
|
1841
|
+
[import_constants5.GL.RGBA]: 4,
|
|
1842
|
+
[import_constants5.GL.RGBA_INTEGER]: 4,
|
|
1843
|
+
[import_constants5.GL.DEPTH_COMPONENT]: 1,
|
|
1844
|
+
[import_constants5.GL.DEPTH_STENCIL]: 1,
|
|
1845
|
+
[import_constants5.GL.ALPHA]: 1,
|
|
1846
|
+
[import_constants5.GL.LUMINANCE]: 1,
|
|
1847
|
+
[import_constants5.GL.LUMINANCE_ALPHA]: 2
|
|
1858
1848
|
};
|
|
1859
1849
|
var TYPE_SIZES = {
|
|
1860
|
-
[import_constants5.
|
|
1861
|
-
[import_constants5.
|
|
1862
|
-
[import_constants5.
|
|
1863
|
-
[import_constants5.
|
|
1864
|
-
[import_constants5.
|
|
1865
|
-
[import_constants5.
|
|
1866
|
-
[import_constants5.
|
|
1867
|
-
[import_constants5.
|
|
1850
|
+
[import_constants5.GL.FLOAT]: 4,
|
|
1851
|
+
[import_constants5.GL.UNSIGNED_INT]: 4,
|
|
1852
|
+
[import_constants5.GL.INT]: 4,
|
|
1853
|
+
[import_constants5.GL.UNSIGNED_SHORT]: 2,
|
|
1854
|
+
[import_constants5.GL.SHORT]: 2,
|
|
1855
|
+
[import_constants5.GL.HALF_FLOAT]: 2,
|
|
1856
|
+
[import_constants5.GL.BYTE]: 1,
|
|
1857
|
+
[import_constants5.GL.UNSIGNED_BYTE]: 1
|
|
1868
1858
|
};
|
|
1869
|
-
function isTextureFormatSupported(
|
|
1859
|
+
function isTextureFormatSupported(gl2, formatOrGL) {
|
|
1870
1860
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
1871
1861
|
const info = TEXTURE_FORMATS[format];
|
|
1872
1862
|
if (!info) {
|
|
1873
1863
|
return false;
|
|
1874
1864
|
}
|
|
1875
|
-
if (isWebGL2(
|
|
1865
|
+
if (isWebGL2(gl2) ? info.gl === void 0 : info.gl1 === void 0) {
|
|
1876
1866
|
return false;
|
|
1877
1867
|
}
|
|
1878
|
-
const extension = info.x || (isWebGL2(
|
|
1868
|
+
const extension = info.x || (isWebGL2(gl2) ? info.gl2ext || info.gl1ext : info.gl1ext);
|
|
1879
1869
|
if (extension) {
|
|
1880
|
-
return Boolean(
|
|
1870
|
+
return Boolean(gl2.getExtension(extension));
|
|
1881
1871
|
}
|
|
1882
1872
|
return true;
|
|
1883
1873
|
}
|
|
1884
|
-
function isRenderbufferFormatSupported(
|
|
1874
|
+
function isRenderbufferFormatSupported(gl2, format) {
|
|
1885
1875
|
var _a;
|
|
1886
|
-
return isTextureFormatSupported(
|
|
1876
|
+
return isTextureFormatSupported(gl2, format) && ((_a = TEXTURE_FORMATS[format]) == null ? void 0 : _a.renderbuffer);
|
|
1887
1877
|
}
|
|
1888
1878
|
function convertGLToTextureFormat(format) {
|
|
1889
1879
|
if (typeof format === "string") {
|
|
@@ -1905,9 +1895,9 @@ function convertTextureFormatToGL(format, isWebGL23) {
|
|
|
1905
1895
|
}
|
|
1906
1896
|
return webglFormat;
|
|
1907
1897
|
}
|
|
1908
|
-
function isTextureFormatFilterable(
|
|
1898
|
+
function isTextureFormatFilterable(gl2, formatOrGL) {
|
|
1909
1899
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
1910
|
-
if (!isTextureFormatSupported(
|
|
1900
|
+
if (!isTextureFormatSupported(gl2, format)) {
|
|
1911
1901
|
return false;
|
|
1912
1902
|
}
|
|
1913
1903
|
try {
|
|
@@ -1919,16 +1909,16 @@ function isTextureFormatFilterable(gl, formatOrGL) {
|
|
|
1919
1909
|
return false;
|
|
1920
1910
|
}
|
|
1921
1911
|
if (format.endsWith("32float")) {
|
|
1922
|
-
return Boolean(
|
|
1912
|
+
return Boolean(gl2.getExtension("OES_texture_float_linear"));
|
|
1923
1913
|
}
|
|
1924
1914
|
if (format.endsWith("16float")) {
|
|
1925
|
-
return Boolean(
|
|
1915
|
+
return Boolean(gl2.getExtension("OES_texture_half_float_linear"));
|
|
1926
1916
|
}
|
|
1927
1917
|
return true;
|
|
1928
1918
|
}
|
|
1929
|
-
function isTextureFormatRenderable(
|
|
1919
|
+
function isTextureFormatRenderable(gl2, formatOrGL) {
|
|
1930
1920
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
1931
|
-
if (!isTextureFormatSupported(
|
|
1921
|
+
if (!isTextureFormatSupported(gl2, format)) {
|
|
1932
1922
|
return false;
|
|
1933
1923
|
}
|
|
1934
1924
|
if (typeof format === "number") {
|
|
@@ -1960,19 +1950,19 @@ function getDepthStencilAttachmentWebGL(format) {
|
|
|
1960
1950
|
}
|
|
1961
1951
|
return info.attachment;
|
|
1962
1952
|
}
|
|
1963
|
-
function _checkFloat32ColorAttachment(
|
|
1953
|
+
function _checkFloat32ColorAttachment(gl2, internalFormat = gl2.RGBA, srcFormat = import_constants5.GL.RGBA, srcType = import_constants5.GL.UNSIGNED_BYTE) {
|
|
1964
1954
|
let texture = null;
|
|
1965
1955
|
let framebuffer = null;
|
|
1966
1956
|
try {
|
|
1967
|
-
texture =
|
|
1968
|
-
|
|
1957
|
+
texture = gl2.createTexture();
|
|
1958
|
+
gl2.bindTexture(import_constants5.GL.TEXTURE_2D, texture);
|
|
1969
1959
|
const level = 0;
|
|
1970
1960
|
const width = 1;
|
|
1971
1961
|
const height = 1;
|
|
1972
1962
|
const border = 0;
|
|
1973
1963
|
const pixel = new Uint8Array([0, 0, 255, 255]);
|
|
1974
|
-
|
|
1975
|
-
|
|
1964
|
+
gl2.texImage2D(
|
|
1965
|
+
gl2.TEXTURE_2D,
|
|
1976
1966
|
level,
|
|
1977
1967
|
internalFormat,
|
|
1978
1968
|
width,
|
|
@@ -1982,15 +1972,15 @@ function _checkFloat32ColorAttachment(gl, internalFormat = gl.RGBA, srcFormat =
|
|
|
1982
1972
|
srcType,
|
|
1983
1973
|
pixel
|
|
1984
1974
|
);
|
|
1985
|
-
framebuffer =
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
const status =
|
|
1989
|
-
|
|
1975
|
+
framebuffer = gl2.createFramebuffer();
|
|
1976
|
+
gl2.bindFramebuffer(import_constants5.GL.FRAMEBUFFER, framebuffer);
|
|
1977
|
+
gl2.framebufferTexture2D(import_constants5.GL.FRAMEBUFFER, import_constants5.GL.COLOR_ATTACHMENT0, import_constants5.GL.TEXTURE_2D, texture, 0);
|
|
1978
|
+
const status = gl2.checkFramebufferStatus(import_constants5.GL.FRAMEBUFFER) === import_constants5.GL.FRAMEBUFFER_COMPLETE;
|
|
1979
|
+
gl2.bindTexture(import_constants5.GL.TEXTURE_2D, null);
|
|
1990
1980
|
return status;
|
|
1991
1981
|
} finally {
|
|
1992
|
-
|
|
1993
|
-
|
|
1982
|
+
gl2.deleteTexture(texture);
|
|
1983
|
+
gl2.deleteFramebuffer(framebuffer);
|
|
1994
1984
|
}
|
|
1995
1985
|
}
|
|
1996
1986
|
function getTextureFormatBytesPerPixel(formatOrGL, isWebGL23) {
|
|
@@ -2001,90 +1991,90 @@ function getTextureFormatBytesPerPixel(formatOrGL, isWebGL23) {
|
|
|
2001
1991
|
return channels * channelSize;
|
|
2002
1992
|
}
|
|
2003
1993
|
function getWebGLPixelDataFormat(dataFormat, integer, normalized, format) {
|
|
2004
|
-
if (format === import_constants5.
|
|
1994
|
+
if (format === import_constants5.GL.RGBA || format === import_constants5.GL.RGB) {
|
|
2005
1995
|
return format;
|
|
2006
1996
|
}
|
|
2007
1997
|
switch (dataFormat) {
|
|
2008
1998
|
case "r":
|
|
2009
|
-
return integer && !normalized ? import_constants5.
|
|
1999
|
+
return integer && !normalized ? import_constants5.GL.RED_INTEGER : import_constants5.GL.RED;
|
|
2010
2000
|
case "rg":
|
|
2011
|
-
return integer && !normalized ? import_constants5.
|
|
2001
|
+
return integer && !normalized ? import_constants5.GL.RG_INTEGER : import_constants5.GL.RG;
|
|
2012
2002
|
case "rgb":
|
|
2013
|
-
return integer && !normalized ? import_constants5.
|
|
2003
|
+
return integer && !normalized ? import_constants5.GL.RGB_INTEGER : import_constants5.GL.RGB;
|
|
2014
2004
|
case "rgba":
|
|
2015
|
-
return integer && !normalized ? import_constants5.
|
|
2005
|
+
return integer && !normalized ? import_constants5.GL.RGBA_INTEGER : import_constants5.GL.RGBA;
|
|
2016
2006
|
default:
|
|
2017
|
-
return import_constants5.
|
|
2007
|
+
return import_constants5.GL.RGBA;
|
|
2018
2008
|
}
|
|
2019
2009
|
}
|
|
2020
2010
|
function getWebGLDataType(dataType) {
|
|
2021
2011
|
switch (dataType) {
|
|
2022
2012
|
case "uint8":
|
|
2023
|
-
return import_constants5.
|
|
2013
|
+
return import_constants5.GL.UNSIGNED_BYTE;
|
|
2024
2014
|
case "sint8":
|
|
2025
|
-
return import_constants5.
|
|
2015
|
+
return import_constants5.GL.BYTE;
|
|
2026
2016
|
case "uint16":
|
|
2027
|
-
return import_constants5.
|
|
2017
|
+
return import_constants5.GL.UNSIGNED_SHORT;
|
|
2028
2018
|
case "sint16":
|
|
2029
|
-
return import_constants5.
|
|
2019
|
+
return import_constants5.GL.SHORT;
|
|
2030
2020
|
case "uint32":
|
|
2031
|
-
return import_constants5.
|
|
2021
|
+
return import_constants5.GL.UNSIGNED_INT;
|
|
2032
2022
|
case "sint32":
|
|
2033
|
-
return import_constants5.
|
|
2023
|
+
return import_constants5.GL.INT;
|
|
2034
2024
|
case "float16":
|
|
2035
|
-
return import_constants5.
|
|
2025
|
+
return import_constants5.GL.HALF_FLOAT;
|
|
2036
2026
|
case "float32":
|
|
2037
|
-
return import_constants5.
|
|
2027
|
+
return import_constants5.GL.FLOAT;
|
|
2038
2028
|
default:
|
|
2039
|
-
return import_constants5.
|
|
2029
|
+
return import_constants5.GL.UNSIGNED_BYTE;
|
|
2040
2030
|
}
|
|
2041
2031
|
}
|
|
2042
2032
|
|
|
2043
2033
|
// src/adapter/device-helpers/device-features.ts
|
|
2044
|
-
function getDeviceFeatures(
|
|
2045
|
-
const features = getWebGLFeatures(
|
|
2046
|
-
for (const textureFeature of getTextureFeatures(
|
|
2034
|
+
function getDeviceFeatures(gl2) {
|
|
2035
|
+
const features = getWebGLFeatures(gl2);
|
|
2036
|
+
for (const textureFeature of getTextureFeatures(gl2)) {
|
|
2047
2037
|
features.add(textureFeature);
|
|
2048
2038
|
}
|
|
2049
2039
|
return features;
|
|
2050
2040
|
}
|
|
2051
|
-
function getWebGLFeatures(
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2041
|
+
function getWebGLFeatures(gl2) {
|
|
2042
|
+
gl2.getExtension("EXT_color_buffer_float");
|
|
2043
|
+
gl2.getExtension("WEBGL_color_buffer_float");
|
|
2044
|
+
gl2.getExtension("EXT_float_blend");
|
|
2055
2045
|
const features = /* @__PURE__ */ new Set();
|
|
2056
2046
|
for (const feature of Object.keys(WEBGL_FEATURES)) {
|
|
2057
|
-
if (isFeatureSupported(
|
|
2047
|
+
if (isFeatureSupported(gl2, feature)) {
|
|
2058
2048
|
features.add(feature);
|
|
2059
2049
|
}
|
|
2060
2050
|
}
|
|
2061
2051
|
return features;
|
|
2062
2052
|
}
|
|
2063
|
-
function isFeatureSupported(
|
|
2053
|
+
function isFeatureSupported(gl2, feature) {
|
|
2064
2054
|
const featureInfo = WEBGL_FEATURES[feature];
|
|
2065
2055
|
if (!featureInfo) {
|
|
2066
2056
|
return false;
|
|
2067
2057
|
}
|
|
2068
2058
|
const [webgl1Feature, webgl2Feature] = featureInfo || [];
|
|
2069
|
-
const featureDefinition = isWebGL2(
|
|
2059
|
+
const featureDefinition = isWebGL2(gl2) ? webgl2Feature : webgl1Feature;
|
|
2070
2060
|
if (typeof featureDefinition === "boolean") {
|
|
2071
2061
|
return featureDefinition;
|
|
2072
2062
|
}
|
|
2073
2063
|
switch (feature) {
|
|
2074
2064
|
case "texture-renderable-rgba32float-webgl":
|
|
2075
|
-
return isWebGL2(
|
|
2065
|
+
return isWebGL2(gl2) ? Boolean(gl2.getExtension(featureDefinition)) : _checkFloat32ColorAttachment(gl2);
|
|
2076
2066
|
case "glsl-derivatives":
|
|
2077
|
-
return canCompileGLSLExtension(
|
|
2067
|
+
return canCompileGLSLExtension(gl2, featureDefinition);
|
|
2078
2068
|
case "glsl-frag-data":
|
|
2079
|
-
return canCompileGLSLExtension(
|
|
2069
|
+
return canCompileGLSLExtension(gl2, featureDefinition, { behavior: "require" });
|
|
2080
2070
|
case "glsl-frag-depth":
|
|
2081
|
-
return canCompileGLSLExtension(
|
|
2071
|
+
return canCompileGLSLExtension(gl2, featureDefinition);
|
|
2082
2072
|
default:
|
|
2083
|
-
return Boolean(
|
|
2073
|
+
return Boolean(gl2.getExtension(featureDefinition));
|
|
2084
2074
|
}
|
|
2085
2075
|
}
|
|
2086
2076
|
var compiledGLSLExtensions = {};
|
|
2087
|
-
function canCompileGLSLExtension(
|
|
2077
|
+
function canCompileGLSLExtension(gl2, extensionName, opts = {}) {
|
|
2088
2078
|
if (!isOldIE(opts)) {
|
|
2089
2079
|
return true;
|
|
2090
2080
|
}
|
|
@@ -2094,14 +2084,14 @@ function canCompileGLSLExtension(gl, extensionName, opts = {}) {
|
|
|
2094
2084
|
const behavior = opts.behavior || "enable";
|
|
2095
2085
|
const source = `#extension GL_${extensionName} : ${behavior}
|
|
2096
2086
|
void main(void) {}`;
|
|
2097
|
-
const shader =
|
|
2087
|
+
const shader = gl2.createShader(gl2.VERTEX_SHADER);
|
|
2098
2088
|
if (!shader) {
|
|
2099
2089
|
throw new Error("shader");
|
|
2100
2090
|
}
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
const canCompile =
|
|
2104
|
-
|
|
2091
|
+
gl2.shaderSource(shader, source);
|
|
2092
|
+
gl2.compileShader(shader);
|
|
2093
|
+
const canCompile = gl2.getShaderParameter(shader, gl2.COMPILE_STATUS);
|
|
2094
|
+
gl2.deleteShader(shader);
|
|
2105
2095
|
compiledGLSLExtensions[extensionName] = canCompile;
|
|
2106
2096
|
return canCompile;
|
|
2107
2097
|
}
|
|
@@ -2138,39 +2128,39 @@ var WEBGL_FEATURES = {
|
|
|
2138
2128
|
};
|
|
2139
2129
|
|
|
2140
2130
|
// src/adapter/device-helpers/device-limits.ts
|
|
2141
|
-
var import_constants6 =
|
|
2142
|
-
function getDeviceLimits(
|
|
2143
|
-
const
|
|
2131
|
+
var import_constants6 = require("@luma.gl/constants");
|
|
2132
|
+
function getDeviceLimits(gl2) {
|
|
2133
|
+
const gl22 = getWebGL2Context(gl2);
|
|
2144
2134
|
return {
|
|
2145
2135
|
maxTextureDimension1D: 0,
|
|
2146
2136
|
// WebGL does not support 1D textures
|
|
2147
|
-
maxTextureDimension2D:
|
|
2148
|
-
maxTextureDimension3D:
|
|
2149
|
-
maxTextureArrayLayers:
|
|
2137
|
+
maxTextureDimension2D: gl2.getParameter(import_constants6.GL.MAX_TEXTURE_SIZE),
|
|
2138
|
+
maxTextureDimension3D: gl22 ? gl22.getParameter(import_constants6.GL.MAX_3D_TEXTURE_SIZE) : 0,
|
|
2139
|
+
maxTextureArrayLayers: gl22 ? gl22.getParameter(import_constants6.GL.MAX_ARRAY_TEXTURE_LAYERS) : 0,
|
|
2150
2140
|
maxBindGroups: 1,
|
|
2151
2141
|
// TBD
|
|
2152
2142
|
maxDynamicUniformBuffersPerPipelineLayout: 0,
|
|
2153
2143
|
// TBD
|
|
2154
2144
|
maxDynamicStorageBuffersPerPipelineLayout: 0,
|
|
2155
2145
|
// TBD
|
|
2156
|
-
maxSampledTexturesPerShaderStage:
|
|
2146
|
+
maxSampledTexturesPerShaderStage: gl2.getParameter(import_constants6.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
|
|
2157
2147
|
// TBD
|
|
2158
|
-
maxSamplersPerShaderStage:
|
|
2148
|
+
maxSamplersPerShaderStage: gl2.getParameter(import_constants6.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
|
|
2159
2149
|
maxStorageBuffersPerShaderStage: 0,
|
|
2160
2150
|
// TBD
|
|
2161
2151
|
maxStorageTexturesPerShaderStage: 0,
|
|
2162
2152
|
// TBD
|
|
2163
|
-
maxUniformBuffersPerShaderStage:
|
|
2164
|
-
maxUniformBufferBindingSize:
|
|
2153
|
+
maxUniformBuffersPerShaderStage: gl22 ? gl22.getParameter(import_constants6.GL.MAX_UNIFORM_BUFFER_BINDINGS) : 0,
|
|
2154
|
+
maxUniformBufferBindingSize: gl22 ? gl22.getParameter(import_constants6.GL.MAX_UNIFORM_BLOCK_SIZE) : 0,
|
|
2165
2155
|
maxStorageBufferBindingSize: 0,
|
|
2166
|
-
minUniformBufferOffsetAlignment:
|
|
2156
|
+
minUniformBufferOffsetAlignment: gl22 ? gl22.getParameter(import_constants6.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT) : 0,
|
|
2167
2157
|
minStorageBufferOffsetAlignment: 0,
|
|
2168
2158
|
// TBD
|
|
2169
2159
|
maxVertexBuffers: 0,
|
|
2170
|
-
maxVertexAttributes:
|
|
2160
|
+
maxVertexAttributes: gl2.getParameter(import_constants6.GL.MAX_VERTEX_ATTRIBS),
|
|
2171
2161
|
maxVertexBufferArrayStride: 2048,
|
|
2172
2162
|
// TBD, this is just the default value from WebGPU
|
|
2173
|
-
maxInterStageShaderComponents:
|
|
2163
|
+
maxInterStageShaderComponents: gl22 ? gl22.getParameter(import_constants6.GL.MAX_VARYING_COMPONENTS) : 0,
|
|
2174
2164
|
maxComputeWorkgroupStorageSize: 0,
|
|
2175
2165
|
// WebGL does not support compute shaders
|
|
2176
2166
|
maxComputeInvocationsPerWorkgroup: 0,
|
|
@@ -2185,98 +2175,98 @@ function getDeviceLimits(gl) {
|
|
|
2185
2175
|
// WebGL does not support compute shaders
|
|
2186
2176
|
};
|
|
2187
2177
|
}
|
|
2188
|
-
function getWebGLLimits(
|
|
2189
|
-
const
|
|
2178
|
+
function getWebGLLimits(gl2) {
|
|
2179
|
+
const gl22 = getWebGL2Context(gl2);
|
|
2190
2180
|
function get(pname) {
|
|
2191
|
-
return
|
|
2181
|
+
return gl2.getParameter(pname);
|
|
2192
2182
|
}
|
|
2193
2183
|
function get2(pname, defaultValue) {
|
|
2194
|
-
return
|
|
2184
|
+
return gl22 ? gl22.getParameter(pname) : defaultValue || 0;
|
|
2195
2185
|
}
|
|
2196
2186
|
return {
|
|
2197
|
-
[import_constants6.
|
|
2198
|
-
[import_constants6.
|
|
2199
|
-
[import_constants6.
|
|
2200
|
-
[import_constants6.
|
|
2187
|
+
[import_constants6.GL.ALIASED_LINE_WIDTH_RANGE]: get(import_constants6.GL.ALIASED_LINE_WIDTH_RANGE),
|
|
2188
|
+
[import_constants6.GL.ALIASED_POINT_SIZE_RANGE]: get(import_constants6.GL.ALIASED_POINT_SIZE_RANGE),
|
|
2189
|
+
[import_constants6.GL.MAX_TEXTURE_SIZE]: get(import_constants6.GL.MAX_TEXTURE_SIZE),
|
|
2190
|
+
[import_constants6.GL.MAX_CUBE_MAP_TEXTURE_SIZE]: get(import_constants6.GL.MAX_CUBE_MAP_TEXTURE_SIZE),
|
|
2201
2191
|
// GLint
|
|
2202
|
-
[import_constants6.
|
|
2192
|
+
[import_constants6.GL.MAX_TEXTURE_IMAGE_UNITS]: get(import_constants6.GL.MAX_TEXTURE_IMAGE_UNITS),
|
|
2203
2193
|
// GLint
|
|
2204
|
-
[import_constants6.
|
|
2194
|
+
[import_constants6.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS]: get(import_constants6.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
|
|
2205
2195
|
// GLint
|
|
2206
|
-
[import_constants6.
|
|
2196
|
+
[import_constants6.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS]: get(import_constants6.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
|
|
2207
2197
|
// GLint
|
|
2208
|
-
[import_constants6.
|
|
2198
|
+
[import_constants6.GL.MAX_RENDERBUFFER_SIZE]: get(import_constants6.GL.MAX_RENDERBUFFER_SIZE),
|
|
2209
2199
|
// GLint
|
|
2210
|
-
[import_constants6.
|
|
2200
|
+
[import_constants6.GL.MAX_VARYING_VECTORS]: get(import_constants6.GL.MAX_VARYING_VECTORS),
|
|
2211
2201
|
// GLint
|
|
2212
|
-
[import_constants6.
|
|
2202
|
+
[import_constants6.GL.MAX_VERTEX_ATTRIBS]: get(import_constants6.GL.MAX_VERTEX_ATTRIBS),
|
|
2213
2203
|
// GLint
|
|
2214
|
-
[import_constants6.
|
|
2204
|
+
[import_constants6.GL.MAX_VERTEX_UNIFORM_VECTORS]: get(import_constants6.GL.MAX_VERTEX_UNIFORM_VECTORS),
|
|
2215
2205
|
// GLint
|
|
2216
|
-
[import_constants6.
|
|
2206
|
+
[import_constants6.GL.MAX_FRAGMENT_UNIFORM_VECTORS]: get(import_constants6.GL.MAX_FRAGMENT_UNIFORM_VECTORS),
|
|
2217
2207
|
// GLint
|
|
2218
|
-
[import_constants6.
|
|
2208
|
+
[import_constants6.GL.MAX_VIEWPORT_DIMS]: get(import_constants6.GL.MAX_VIEWPORT_DIMS),
|
|
2219
2209
|
// Extensions
|
|
2220
|
-
[import_constants6.
|
|
2210
|
+
[import_constants6.GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT]: get(import_constants6.GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT),
|
|
2221
2211
|
// getMaxAnistropy(),
|
|
2222
2212
|
// WebGL2 Limits
|
|
2223
|
-
[import_constants6.
|
|
2213
|
+
[import_constants6.GL.MAX_3D_TEXTURE_SIZE]: get2(import_constants6.GL.MAX_3D_TEXTURE_SIZE),
|
|
2224
2214
|
// GLint
|
|
2225
|
-
[import_constants6.
|
|
2215
|
+
[import_constants6.GL.MAX_ARRAY_TEXTURE_LAYERS]: get2(import_constants6.GL.MAX_ARRAY_TEXTURE_LAYERS),
|
|
2226
2216
|
// GLint
|
|
2227
|
-
[import_constants6.
|
|
2217
|
+
[import_constants6.GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: get2(import_constants6.GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL),
|
|
2228
2218
|
// GLint64
|
|
2229
|
-
[import_constants6.
|
|
2219
|
+
[import_constants6.GL.MAX_COLOR_ATTACHMENTS]: get2(import_constants6.GL.MAX_COLOR_ATTACHMENTS),
|
|
2230
2220
|
// GLint
|
|
2231
|
-
[import_constants6.
|
|
2221
|
+
[import_constants6.GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: get2(import_constants6.GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS),
|
|
2232
2222
|
// GLint64
|
|
2233
|
-
[import_constants6.
|
|
2223
|
+
[import_constants6.GL.MAX_COMBINED_UNIFORM_BLOCKS]: get2(import_constants6.GL.MAX_COMBINED_UNIFORM_BLOCKS),
|
|
2234
2224
|
// GLint
|
|
2235
|
-
[import_constants6.
|
|
2225
|
+
[import_constants6.GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]: get2(import_constants6.GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS),
|
|
2236
2226
|
// GLint64
|
|
2237
|
-
[import_constants6.
|
|
2227
|
+
[import_constants6.GL.MAX_DRAW_BUFFERS]: get2(import_constants6.GL.MAX_DRAW_BUFFERS),
|
|
2238
2228
|
// GLint
|
|
2239
|
-
[import_constants6.
|
|
2229
|
+
[import_constants6.GL.MAX_ELEMENT_INDEX]: get2(import_constants6.GL.MAX_ELEMENT_INDEX),
|
|
2240
2230
|
// GLint64
|
|
2241
|
-
[import_constants6.
|
|
2231
|
+
[import_constants6.GL.MAX_ELEMENTS_INDICES]: get2(import_constants6.GL.MAX_ELEMENTS_INDICES),
|
|
2242
2232
|
// GLint
|
|
2243
|
-
[import_constants6.
|
|
2233
|
+
[import_constants6.GL.MAX_ELEMENTS_VERTICES]: get2(import_constants6.GL.MAX_ELEMENTS_VERTICES),
|
|
2244
2234
|
// GLint
|
|
2245
|
-
[import_constants6.
|
|
2235
|
+
[import_constants6.GL.MAX_FRAGMENT_INPUT_COMPONENTS]: get2(import_constants6.GL.MAX_FRAGMENT_INPUT_COMPONENTS),
|
|
2246
2236
|
// GLint
|
|
2247
|
-
[import_constants6.
|
|
2237
|
+
[import_constants6.GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: get2(import_constants6.GL.MAX_FRAGMENT_UNIFORM_BLOCKS),
|
|
2248
2238
|
// GLint
|
|
2249
|
-
[import_constants6.
|
|
2239
|
+
[import_constants6.GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]: get2(import_constants6.GL.MAX_FRAGMENT_UNIFORM_COMPONENTS),
|
|
2250
2240
|
// GLint
|
|
2251
|
-
[import_constants6.
|
|
2241
|
+
[import_constants6.GL.MAX_SAMPLES]: get2(import_constants6.GL.MAX_SAMPLES),
|
|
2252
2242
|
// GLint
|
|
2253
|
-
[import_constants6.
|
|
2243
|
+
[import_constants6.GL.MAX_SERVER_WAIT_TIMEOUT]: get2(import_constants6.GL.MAX_SERVER_WAIT_TIMEOUT),
|
|
2254
2244
|
// GLint64
|
|
2255
|
-
[import_constants6.
|
|
2245
|
+
[import_constants6.GL.MAX_TEXTURE_LOD_BIAS]: get2(import_constants6.GL.MAX_TEXTURE_LOD_BIAS),
|
|
2256
2246
|
// GLfloat
|
|
2257
|
-
[import_constants6.
|
|
2247
|
+
[import_constants6.GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: get2(import_constants6.GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS),
|
|
2258
2248
|
// GLint
|
|
2259
|
-
[import_constants6.
|
|
2249
|
+
[import_constants6.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]: get2(import_constants6.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS),
|
|
2260
2250
|
// GLint
|
|
2261
|
-
[import_constants6.
|
|
2251
|
+
[import_constants6.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]: get2(import_constants6.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS),
|
|
2262
2252
|
// GLint
|
|
2263
|
-
[import_constants6.
|
|
2253
|
+
[import_constants6.GL.MAX_UNIFORM_BLOCK_SIZE]: get2(import_constants6.GL.MAX_UNIFORM_BLOCK_SIZE),
|
|
2264
2254
|
// GLint64
|
|
2265
|
-
[import_constants6.
|
|
2255
|
+
[import_constants6.GL.MAX_UNIFORM_BUFFER_BINDINGS]: get2(import_constants6.GL.MAX_UNIFORM_BUFFER_BINDINGS),
|
|
2266
2256
|
// GLint
|
|
2267
|
-
[import_constants6.
|
|
2257
|
+
[import_constants6.GL.MAX_VARYING_COMPONENTS]: get2(import_constants6.GL.MAX_VARYING_COMPONENTS),
|
|
2268
2258
|
// GLint
|
|
2269
|
-
[import_constants6.
|
|
2259
|
+
[import_constants6.GL.MAX_VERTEX_OUTPUT_COMPONENTS]: get2(import_constants6.GL.MAX_VERTEX_OUTPUT_COMPONENTS),
|
|
2270
2260
|
// GLint
|
|
2271
|
-
[import_constants6.
|
|
2261
|
+
[import_constants6.GL.MAX_VERTEX_UNIFORM_BLOCKS]: get2(import_constants6.GL.MAX_VERTEX_UNIFORM_BLOCKS),
|
|
2272
2262
|
// GLint
|
|
2273
|
-
[import_constants6.
|
|
2263
|
+
[import_constants6.GL.MAX_VERTEX_UNIFORM_COMPONENTS]: get2(import_constants6.GL.MAX_VERTEX_UNIFORM_COMPONENTS),
|
|
2274
2264
|
// GLint
|
|
2275
|
-
[import_constants6.
|
|
2265
|
+
[import_constants6.GL.MIN_PROGRAM_TEXEL_OFFSET]: get2(import_constants6.GL.MIN_PROGRAM_TEXEL_OFFSET),
|
|
2276
2266
|
// GLint
|
|
2277
|
-
[import_constants6.
|
|
2267
|
+
[import_constants6.GL.MAX_PROGRAM_TEXEL_OFFSET]: get2(import_constants6.GL.MAX_PROGRAM_TEXEL_OFFSET),
|
|
2278
2268
|
// GLint
|
|
2279
|
-
[import_constants6.
|
|
2269
|
+
[import_constants6.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]: get2(import_constants6.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT)
|
|
2280
2270
|
// GLint
|
|
2281
2271
|
};
|
|
2282
2272
|
}
|
|
@@ -2286,7 +2276,7 @@ var import_api15 = require("@luma.gl/api");
|
|
|
2286
2276
|
|
|
2287
2277
|
// src/adapter/resources/webgl-framebuffer.ts
|
|
2288
2278
|
var import_api14 = require("@luma.gl/api");
|
|
2289
|
-
var import_constants13 =
|
|
2279
|
+
var import_constants13 = require("@luma.gl/constants");
|
|
2290
2280
|
|
|
2291
2281
|
// src/adapter/resources/webgl-texture.ts
|
|
2292
2282
|
var import_api9 = require("@luma.gl/api");
|
|
@@ -2296,22 +2286,22 @@ var import_constants11 = require("@luma.gl/constants");
|
|
|
2296
2286
|
// src/context/state-tracker/with-parameters.ts
|
|
2297
2287
|
function withParameters(device, parameters, func) {
|
|
2298
2288
|
const webglDevice = WebGLDevice.attach(device);
|
|
2299
|
-
const
|
|
2289
|
+
const gl2 = webglDevice.gl;
|
|
2300
2290
|
if (isObjectEmpty2(parameters)) {
|
|
2301
2291
|
return func(device);
|
|
2302
2292
|
}
|
|
2303
2293
|
const { nocatch = true } = parameters;
|
|
2304
|
-
pushContextState(
|
|
2305
|
-
setParameters(
|
|
2294
|
+
pushContextState(gl2);
|
|
2295
|
+
setParameters(gl2, parameters);
|
|
2306
2296
|
let value;
|
|
2307
2297
|
if (nocatch) {
|
|
2308
|
-
value = func(
|
|
2309
|
-
popContextState(
|
|
2298
|
+
value = func(gl2);
|
|
2299
|
+
popContextState(gl2);
|
|
2310
2300
|
} else {
|
|
2311
2301
|
try {
|
|
2312
|
-
value = func(
|
|
2302
|
+
value = func(gl2);
|
|
2313
2303
|
} finally {
|
|
2314
|
-
popContextState(
|
|
2304
|
+
popContextState(gl2);
|
|
2315
2305
|
}
|
|
2316
2306
|
}
|
|
2317
2307
|
return value;
|
|
@@ -2328,7 +2318,7 @@ var import_constants8 = require("@luma.gl/constants");
|
|
|
2328
2318
|
|
|
2329
2319
|
// src/adapter/converters/device-parameters.ts
|
|
2330
2320
|
var import_api6 = require("@luma.gl/api");
|
|
2331
|
-
var import_constants7 =
|
|
2321
|
+
var import_constants7 = require("@luma.gl/constants");
|
|
2332
2322
|
function withGLParameters(device, parameters, func) {
|
|
2333
2323
|
if ((0, import_api6.isObjectEmpty)(parameters)) {
|
|
2334
2324
|
return func(device);
|
|
@@ -2355,44 +2345,44 @@ function withDeviceParameters(device, parameters, func) {
|
|
|
2355
2345
|
}
|
|
2356
2346
|
function setDeviceParameters(device, parameters) {
|
|
2357
2347
|
const webglDevice = WebGLDevice.attach(device);
|
|
2358
|
-
const { gl } = webglDevice;
|
|
2348
|
+
const { gl: gl2 } = webglDevice;
|
|
2359
2349
|
if (parameters.cullMode) {
|
|
2360
2350
|
switch (parameters.cullMode) {
|
|
2361
2351
|
case "none":
|
|
2362
|
-
|
|
2352
|
+
gl2.disable(import_constants7.GL.CULL_FACE);
|
|
2363
2353
|
break;
|
|
2364
2354
|
case "front":
|
|
2365
|
-
|
|
2366
|
-
|
|
2355
|
+
gl2.enable(import_constants7.GL.CULL_FACE);
|
|
2356
|
+
gl2.cullFace(import_constants7.GL.FRONT);
|
|
2367
2357
|
break;
|
|
2368
2358
|
case "back":
|
|
2369
|
-
|
|
2370
|
-
|
|
2359
|
+
gl2.enable(import_constants7.GL.CULL_FACE);
|
|
2360
|
+
gl2.cullFace(import_constants7.GL.BACK);
|
|
2371
2361
|
break;
|
|
2372
2362
|
}
|
|
2373
2363
|
}
|
|
2374
2364
|
if (parameters.frontFace) {
|
|
2375
|
-
|
|
2365
|
+
gl2.frontFace(
|
|
2376
2366
|
map("frontFace", parameters.frontFace, {
|
|
2377
|
-
ccw: import_constants7.
|
|
2378
|
-
cw: import_constants7.
|
|
2367
|
+
ccw: import_constants7.GL.CCW,
|
|
2368
|
+
cw: import_constants7.GL.CW
|
|
2379
2369
|
})
|
|
2380
2370
|
);
|
|
2381
2371
|
}
|
|
2382
2372
|
if (parameters.depthBias !== void 0) {
|
|
2383
|
-
|
|
2373
|
+
gl2.polygonOffset(parameters.depthBias, parameters.depthBiasSlopeScale || 0);
|
|
2384
2374
|
}
|
|
2385
2375
|
if (parameters.depthWriteEnabled !== void 0) {
|
|
2386
|
-
|
|
2376
|
+
gl2.depthMask(mapBoolean("depthWriteEnabled", parameters.depthWriteEnabled));
|
|
2387
2377
|
}
|
|
2388
2378
|
if (parameters.depthCompare) {
|
|
2389
|
-
parameters.depthCompare !== "always" ?
|
|
2390
|
-
|
|
2379
|
+
parameters.depthCompare !== "always" ? gl2.enable(import_constants7.GL.DEPTH_TEST) : gl2.disable(import_constants7.GL.DEPTH_TEST);
|
|
2380
|
+
gl2.depthFunc(convertCompareFunction("depthCompare", parameters.depthCompare));
|
|
2391
2381
|
}
|
|
2392
2382
|
if (parameters.stencilWriteMask) {
|
|
2393
2383
|
const mask = parameters.stencilWriteMask;
|
|
2394
|
-
|
|
2395
|
-
|
|
2384
|
+
gl2.stencilMaskSeparate(import_constants7.GL.FRONT, mask);
|
|
2385
|
+
gl2.stencilMaskSeparate(import_constants7.GL.BACK, mask);
|
|
2396
2386
|
}
|
|
2397
2387
|
if (parameters.stencilReadMask) {
|
|
2398
2388
|
import_api6.log.warn("stencilReadMask not supported under WebGL");
|
|
@@ -2400,9 +2390,9 @@ function setDeviceParameters(device, parameters) {
|
|
|
2400
2390
|
if (parameters.stencilCompare) {
|
|
2401
2391
|
const mask = parameters.stencilReadMask || 4294967295;
|
|
2402
2392
|
const glValue = convertCompareFunction("depthCompare", parameters.stencilCompare);
|
|
2403
|
-
parameters.stencilCompare !== "always" ?
|
|
2404
|
-
|
|
2405
|
-
|
|
2393
|
+
parameters.stencilCompare !== "always" ? gl2.enable(import_constants7.GL.STENCIL_TEST) : gl2.disable(import_constants7.GL.STENCIL_TEST);
|
|
2394
|
+
gl2.stencilFuncSeparate(import_constants7.GL.FRONT, glValue, 0, mask);
|
|
2395
|
+
gl2.stencilFuncSeparate(import_constants7.GL.BACK, glValue, 0, mask);
|
|
2406
2396
|
}
|
|
2407
2397
|
if (parameters.stencilPassOperation && parameters.stencilFailOperation && parameters.stencilDepthFailOperation) {
|
|
2408
2398
|
const dppass = convertStencilOperation("stencilPassOperation", parameters.stencilPassOperation);
|
|
@@ -2411,32 +2401,32 @@ function setDeviceParameters(device, parameters) {
|
|
|
2411
2401
|
"stencilDepthFailOperation",
|
|
2412
2402
|
parameters.stencilDepthFailOperation
|
|
2413
2403
|
);
|
|
2414
|
-
|
|
2415
|
-
|
|
2404
|
+
gl2.stencilOpSeparate(import_constants7.GL.FRONT, sfail, dpfail, dppass);
|
|
2405
|
+
gl2.stencilOpSeparate(import_constants7.GL.BACK, sfail, dpfail, dppass);
|
|
2416
2406
|
}
|
|
2417
2407
|
}
|
|
2418
2408
|
function convertCompareFunction(parameter, value) {
|
|
2419
2409
|
return map(parameter, value, {
|
|
2420
|
-
never: import_constants7.
|
|
2421
|
-
less: import_constants7.
|
|
2422
|
-
equal: import_constants7.
|
|
2423
|
-
"less-equal": import_constants7.
|
|
2424
|
-
greater: import_constants7.
|
|
2425
|
-
"not-equal": import_constants7.
|
|
2426
|
-
"greater-equal": import_constants7.
|
|
2427
|
-
always: import_constants7.
|
|
2410
|
+
never: import_constants7.GL.NEVER,
|
|
2411
|
+
less: import_constants7.GL.LESS,
|
|
2412
|
+
equal: import_constants7.GL.EQUAL,
|
|
2413
|
+
"less-equal": import_constants7.GL.LEQUAL,
|
|
2414
|
+
greater: import_constants7.GL.GREATER,
|
|
2415
|
+
"not-equal": import_constants7.GL.NOTEQUAL,
|
|
2416
|
+
"greater-equal": import_constants7.GL.GEQUAL,
|
|
2417
|
+
always: import_constants7.GL.ALWAYS
|
|
2428
2418
|
});
|
|
2429
2419
|
}
|
|
2430
2420
|
function convertStencilOperation(parameter, value) {
|
|
2431
2421
|
return map(parameter, value, {
|
|
2432
|
-
keep: import_constants7.
|
|
2433
|
-
zero: import_constants7.
|
|
2434
|
-
replace: import_constants7.
|
|
2435
|
-
invert: import_constants7.
|
|
2436
|
-
"increment-clamp": import_constants7.
|
|
2437
|
-
"decrement-clamp": import_constants7.
|
|
2438
|
-
"increment-wrap": import_constants7.
|
|
2439
|
-
"decrement-wrap": import_constants7.
|
|
2422
|
+
keep: import_constants7.GL.KEEP,
|
|
2423
|
+
zero: import_constants7.GL.ZERO,
|
|
2424
|
+
replace: import_constants7.GL.REPLACE,
|
|
2425
|
+
invert: import_constants7.GL.INVERT,
|
|
2426
|
+
"increment-clamp": import_constants7.GL.INCR,
|
|
2427
|
+
"decrement-clamp": import_constants7.GL.DECR,
|
|
2428
|
+
"increment-wrap": import_constants7.GL.INCR_WRAP,
|
|
2429
|
+
"decrement-wrap": import_constants7.GL.DECR_WRAP
|
|
2440
2430
|
});
|
|
2441
2431
|
}
|
|
2442
2432
|
function message(parameter, value) {
|
|
@@ -2528,7 +2518,7 @@ function updateSamplerParametersForNPOT(parameters) {
|
|
|
2528
2518
|
|
|
2529
2519
|
// src/adapter/resources/webgl-buffer.ts
|
|
2530
2520
|
var import_api7 = require("@luma.gl/api");
|
|
2531
|
-
var import_constants9 =
|
|
2521
|
+
var import_constants9 = require("@luma.gl/constants");
|
|
2532
2522
|
var DEBUG_DATA_LENGTH = 10;
|
|
2533
2523
|
var WEBGLBuffer = class extends import_api7.Buffer {
|
|
2534
2524
|
// accessor: {};
|
|
@@ -2593,7 +2583,7 @@ var WEBGLBuffer = class extends import_api7.Buffer {
|
|
|
2593
2583
|
write(data, byteOffset = 0) {
|
|
2594
2584
|
const srcOffset = 0;
|
|
2595
2585
|
const byteLength = void 0;
|
|
2596
|
-
const target = this.device.isWebGL2 ? import_constants9.
|
|
2586
|
+
const target = this.device.isWebGL2 ? import_constants9.GL.COPY_WRITE_BUFFER : this.target;
|
|
2597
2587
|
this.gl.bindBuffer(target, this.handle);
|
|
2598
2588
|
if (srcOffset !== 0 || byteLength !== void 0) {
|
|
2599
2589
|
this.device.assertWebGL2();
|
|
@@ -2609,9 +2599,9 @@ var WEBGLBuffer = class extends import_api7.Buffer {
|
|
|
2609
2599
|
this.device.assertWebGL2();
|
|
2610
2600
|
const data = new Uint8Array(byteLength);
|
|
2611
2601
|
const dstOffset = 0;
|
|
2612
|
-
this.gl.bindBuffer(import_constants9.
|
|
2613
|
-
this.gl2.getBufferSubData(import_constants9.
|
|
2614
|
-
this.gl.bindBuffer(import_constants9.
|
|
2602
|
+
this.gl.bindBuffer(import_constants9.GL.COPY_READ_BUFFER, this.handle);
|
|
2603
|
+
this.gl2.getBufferSubData(import_constants9.GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);
|
|
2604
|
+
this.gl.bindBuffer(import_constants9.GL.COPY_READ_BUFFER, null);
|
|
2615
2605
|
return data;
|
|
2616
2606
|
});
|
|
2617
2607
|
}
|
|
@@ -2628,27 +2618,27 @@ var WEBGLBuffer = class extends import_api7.Buffer {
|
|
|
2628
2618
|
};
|
|
2629
2619
|
function getWebGLTarget(usage) {
|
|
2630
2620
|
if (usage & import_api7.Buffer.INDEX) {
|
|
2631
|
-
return import_constants9.
|
|
2621
|
+
return import_constants9.GL.ELEMENT_ARRAY_BUFFER;
|
|
2632
2622
|
}
|
|
2633
2623
|
if (usage & import_api7.Buffer.VERTEX) {
|
|
2634
|
-
return import_constants9.
|
|
2624
|
+
return import_constants9.GL.ARRAY_BUFFER;
|
|
2635
2625
|
}
|
|
2636
2626
|
if (usage & import_api7.Buffer.UNIFORM) {
|
|
2637
|
-
return import_constants9.
|
|
2627
|
+
return import_constants9.GL.UNIFORM_BUFFER;
|
|
2638
2628
|
}
|
|
2639
|
-
return import_constants9.
|
|
2629
|
+
return import_constants9.GL.ARRAY_BUFFER;
|
|
2640
2630
|
}
|
|
2641
2631
|
function getWebGLUsage(usage) {
|
|
2642
2632
|
if (usage & import_api7.Buffer.INDEX) {
|
|
2643
|
-
return import_constants9.
|
|
2633
|
+
return import_constants9.GL.STATIC_DRAW;
|
|
2644
2634
|
}
|
|
2645
2635
|
if (usage & import_api7.Buffer.VERTEX) {
|
|
2646
|
-
return import_constants9.
|
|
2636
|
+
return import_constants9.GL.STATIC_DRAW;
|
|
2647
2637
|
}
|
|
2648
2638
|
if (usage & import_api7.Buffer.UNIFORM) {
|
|
2649
|
-
return import_constants9.
|
|
2639
|
+
return import_constants9.GL.DYNAMIC_DRAW;
|
|
2650
2640
|
}
|
|
2651
|
-
return import_constants9.
|
|
2641
|
+
return import_constants9.GL.DYNAMIC_DRAW;
|
|
2652
2642
|
}
|
|
2653
2643
|
|
|
2654
2644
|
// src/adapter/resources/webgl-sampler.ts
|
|
@@ -2958,18 +2948,18 @@ var _WEBGLTexture = class extends import_api10.Texture {
|
|
|
2958
2948
|
width,
|
|
2959
2949
|
height
|
|
2960
2950
|
}));
|
|
2961
|
-
const { gl } = this;
|
|
2962
|
-
|
|
2951
|
+
const { gl: gl2 } = this;
|
|
2952
|
+
gl2.bindTexture(this.target, this.handle);
|
|
2963
2953
|
let dataType = null;
|
|
2964
2954
|
({ data, dataType } = this._getDataType({ data, compressed }));
|
|
2965
|
-
let
|
|
2955
|
+
let gl22;
|
|
2966
2956
|
withParameters(this.gl, parameters, () => {
|
|
2967
2957
|
switch (dataType) {
|
|
2968
2958
|
case "null":
|
|
2969
|
-
|
|
2959
|
+
gl2.texImage2D(target, level, glFormat, width, height, 0, dataFormat, type, data);
|
|
2970
2960
|
break;
|
|
2971
2961
|
case "typed-array":
|
|
2972
|
-
|
|
2962
|
+
gl2.texImage2D(
|
|
2973
2963
|
target,
|
|
2974
2964
|
level,
|
|
2975
2965
|
glFormat,
|
|
@@ -2985,9 +2975,9 @@ var _WEBGLTexture = class extends import_api10.Texture {
|
|
|
2985
2975
|
);
|
|
2986
2976
|
break;
|
|
2987
2977
|
case "buffer":
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2978
|
+
gl22 = this.device.assertWebGL2();
|
|
2979
|
+
gl22.bindBuffer(import_constants11.GL.PIXEL_UNPACK_BUFFER, data.handle || data);
|
|
2980
|
+
gl22.texImage2D(
|
|
2991
2981
|
target,
|
|
2992
2982
|
level,
|
|
2993
2983
|
glFormat,
|
|
@@ -2998,11 +2988,11 @@ var _WEBGLTexture = class extends import_api10.Texture {
|
|
|
2998
2988
|
type,
|
|
2999
2989
|
offset
|
|
3000
2990
|
);
|
|
3001
|
-
|
|
2991
|
+
gl22.bindBuffer(import_constants11.GL.PIXEL_UNPACK_BUFFER, null);
|
|
3002
2992
|
break;
|
|
3003
2993
|
case "browser-object":
|
|
3004
2994
|
if (this.device.isWebGL2) {
|
|
3005
|
-
|
|
2995
|
+
gl2.texImage2D(
|
|
3006
2996
|
target,
|
|
3007
2997
|
level,
|
|
3008
2998
|
glFormat,
|
|
@@ -3014,12 +3004,12 @@ var _WEBGLTexture = class extends import_api10.Texture {
|
|
|
3014
3004
|
data
|
|
3015
3005
|
);
|
|
3016
3006
|
} else {
|
|
3017
|
-
|
|
3007
|
+
gl2.texImage2D(target, level, glFormat, dataFormat, type, data);
|
|
3018
3008
|
}
|
|
3019
3009
|
break;
|
|
3020
3010
|
case "compressed":
|
|
3021
3011
|
for (const [levelIndex, levelData] of data.entries()) {
|
|
3022
|
-
|
|
3012
|
+
gl2.compressedTexImage2D(
|
|
3023
3013
|
target,
|
|
3024
3014
|
levelIndex,
|
|
3025
3015
|
levelData.format,
|
|
@@ -3126,21 +3116,21 @@ var _WEBGLTexture = class extends import_api10.Texture {
|
|
|
3126
3116
|
return this.gl.getParameter(import_constants11.GL.ACTIVE_TEXTURE) - import_constants11.GL.TEXTURE0;
|
|
3127
3117
|
}
|
|
3128
3118
|
bind(textureUnit = this.textureUnit) {
|
|
3129
|
-
const { gl } = this;
|
|
3119
|
+
const { gl: gl2 } = this;
|
|
3130
3120
|
if (textureUnit !== void 0) {
|
|
3131
3121
|
this.textureUnit = textureUnit;
|
|
3132
|
-
|
|
3122
|
+
gl2.activeTexture(gl2.TEXTURE0 + textureUnit);
|
|
3133
3123
|
}
|
|
3134
|
-
|
|
3124
|
+
gl2.bindTexture(this.target, this.handle);
|
|
3135
3125
|
return textureUnit;
|
|
3136
3126
|
}
|
|
3137
3127
|
unbind(textureUnit = this.textureUnit) {
|
|
3138
|
-
const { gl } = this;
|
|
3128
|
+
const { gl: gl2 } = this;
|
|
3139
3129
|
if (textureUnit !== void 0) {
|
|
3140
3130
|
this.textureUnit = textureUnit;
|
|
3141
|
-
|
|
3131
|
+
gl2.activeTexture(gl2.TEXTURE0 + textureUnit);
|
|
3142
3132
|
}
|
|
3143
|
-
|
|
3133
|
+
gl2.bindTexture(this.target, null);
|
|
3144
3134
|
return textureUnit;
|
|
3145
3135
|
}
|
|
3146
3136
|
// PRIVATE METHODS
|
|
@@ -3206,7 +3196,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
|
|
|
3206
3196
|
/* eslint-disable max-statements, max-len */
|
|
3207
3197
|
setCubeMapImageData(options) {
|
|
3208
3198
|
return __async(this, null, function* () {
|
|
3209
|
-
const { gl } = this;
|
|
3199
|
+
const { gl: gl2 } = this;
|
|
3210
3200
|
const { width, height, pixels, data, format = import_constants11.GL.RGBA, type = import_constants11.GL.UNSIGNED_BYTE } = options;
|
|
3211
3201
|
const imageDataMap = pixels || data;
|
|
3212
3202
|
const resolvedFaces = yield Promise.all(
|
|
@@ -3222,9 +3212,9 @@ var _WEBGLTexture = class extends import_api10.Texture {
|
|
|
3222
3212
|
}
|
|
3223
3213
|
resolvedFaces[index].forEach((image, lodLevel) => {
|
|
3224
3214
|
if (width && height) {
|
|
3225
|
-
|
|
3215
|
+
gl2.texImage2D(face, lodLevel, format, width, height, 0, format, type, image);
|
|
3226
3216
|
} else {
|
|
3227
|
-
|
|
3217
|
+
gl2.texImage2D(face, lodLevel, format, format, type, image);
|
|
3228
3218
|
}
|
|
3229
3219
|
});
|
|
3230
3220
|
});
|
|
@@ -3243,7 +3233,7 @@ var _WEBGLTexture = class extends import_api10.Texture {
|
|
|
3243
3233
|
type = import_constants11.GL.UNSIGNED_BYTE
|
|
3244
3234
|
// generateMipmap = false // TODO
|
|
3245
3235
|
} = options;
|
|
3246
|
-
const { gl } = this;
|
|
3236
|
+
const { gl: gl2 } = this;
|
|
3247
3237
|
const imageData = pixels || data;
|
|
3248
3238
|
this.bind();
|
|
3249
3239
|
if (imageData instanceof Promise) {
|
|
@@ -3257,9 +3247,9 @@ var _WEBGLTexture = class extends import_api10.Texture {
|
|
|
3257
3247
|
)
|
|
3258
3248
|
);
|
|
3259
3249
|
} else if (this.width || this.height) {
|
|
3260
|
-
|
|
3250
|
+
gl2.texImage2D(face, 0, format, width, height, 0, format, type, imageData);
|
|
3261
3251
|
} else {
|
|
3262
|
-
|
|
3252
|
+
gl2.texImage2D(face, 0, format, format, type, imageData);
|
|
3263
3253
|
}
|
|
3264
3254
|
return this;
|
|
3265
3255
|
}
|
|
@@ -3410,14 +3400,14 @@ function logParameters(parameters) {
|
|
|
3410
3400
|
|
|
3411
3401
|
// src/adapter/objects/webgl-renderbuffer.ts
|
|
3412
3402
|
var import_api13 = require("@luma.gl/api");
|
|
3413
|
-
var import_constants12 =
|
|
3403
|
+
var import_constants12 = require("@luma.gl/constants");
|
|
3414
3404
|
|
|
3415
3405
|
// src/adapter/objects/webgl-resource.ts
|
|
3416
3406
|
var import_api12 = require("@luma.gl/api");
|
|
3417
3407
|
|
|
3418
3408
|
// src/adapter/objects/constants-to-keys.ts
|
|
3419
3409
|
var import_api11 = require("@luma.gl/api");
|
|
3420
|
-
function getKeyValue(
|
|
3410
|
+
function getKeyValue(gl2, name) {
|
|
3421
3411
|
if (typeof name !== "string") {
|
|
3422
3412
|
return name;
|
|
3423
3413
|
}
|
|
@@ -3426,7 +3416,7 @@ function getKeyValue(gl, name) {
|
|
|
3426
3416
|
return number;
|
|
3427
3417
|
}
|
|
3428
3418
|
name = name.replace(/^.*\./, "");
|
|
3429
|
-
const value =
|
|
3419
|
+
const value = gl2[name];
|
|
3430
3420
|
(0, import_api11.assert)(value !== void 0, `Accessing undefined constant GL.${name}`);
|
|
3431
3421
|
return value;
|
|
3432
3422
|
}
|
|
@@ -3440,11 +3430,11 @@ var WebGLResource = class extends import_api12.Resource {
|
|
|
3440
3430
|
// Only meaningful for resources that allocate GPU memory
|
|
3441
3431
|
this.byteLength = 0;
|
|
3442
3432
|
this.device = WebGLDevice.attach(device);
|
|
3443
|
-
const
|
|
3444
|
-
assertWebGLContext(
|
|
3433
|
+
const gl2 = this.device.gl;
|
|
3434
|
+
assertWebGLContext(gl2);
|
|
3445
3435
|
const { id } = props || {};
|
|
3446
|
-
this.gl =
|
|
3447
|
-
this.gl2 =
|
|
3436
|
+
this.gl = gl2;
|
|
3437
|
+
this.gl2 = gl2;
|
|
3448
3438
|
this.id = id || (0, import_api12.uid)(this.constructor.name);
|
|
3449
3439
|
this._handle = props == null ? void 0 : props.handle;
|
|
3450
3440
|
if (this._handle === void 0) {
|
|
@@ -3676,13 +3666,13 @@ var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
|
3676
3666
|
const { format, width, height, samples } = props;
|
|
3677
3667
|
(0, import_api13.assert)(format, "Needs format");
|
|
3678
3668
|
this.trackDeallocatedMemory();
|
|
3679
|
-
this.gl.bindRenderbuffer(import_constants12.
|
|
3669
|
+
this.gl.bindRenderbuffer(import_constants12.GL.RENDERBUFFER, this.handle);
|
|
3680
3670
|
if (samples !== 0 && this.device.isWebGL2) {
|
|
3681
|
-
this.gl2.renderbufferStorageMultisample(import_constants12.
|
|
3671
|
+
this.gl2.renderbufferStorageMultisample(import_constants12.GL.RENDERBUFFER, samples, this.glFormat, width, height);
|
|
3682
3672
|
} else {
|
|
3683
|
-
this.gl.renderbufferStorage(import_constants12.
|
|
3673
|
+
this.gl.renderbufferStorage(import_constants12.GL.RENDERBUFFER, this.glFormat, width, height);
|
|
3684
3674
|
}
|
|
3685
|
-
this.gl.bindRenderbuffer(import_constants12.
|
|
3675
|
+
this.gl.bindRenderbuffer(import_constants12.GL.RENDERBUFFER, null);
|
|
3686
3676
|
this.trackAllocatedMemory(
|
|
3687
3677
|
width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2)
|
|
3688
3678
|
);
|
|
@@ -3696,7 +3686,7 @@ var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
|
3696
3686
|
this.trackDeallocatedMemory();
|
|
3697
3687
|
}
|
|
3698
3688
|
_bindHandle(handle) {
|
|
3699
|
-
this.gl.bindRenderbuffer(import_constants12.
|
|
3689
|
+
this.gl.bindRenderbuffer(import_constants12.GL.RENDERBUFFER, handle);
|
|
3700
3690
|
}
|
|
3701
3691
|
};
|
|
3702
3692
|
var WEBGLRenderbuffer = _WEBGLRenderbuffer;
|
|
@@ -3722,10 +3712,10 @@ var WEBGLFramebuffer = class extends import_api14.Framebuffer {
|
|
|
3722
3712
|
if (!isDefaultFramebuffer) {
|
|
3723
3713
|
device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
|
|
3724
3714
|
this.autoCreateAttachmentTextures();
|
|
3725
|
-
this.gl.bindFramebuffer(import_constants13.
|
|
3715
|
+
this.gl.bindFramebuffer(import_constants13.GL.FRAMEBUFFER, this.handle);
|
|
3726
3716
|
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
3727
3717
|
const attachment = this.colorAttachments[i];
|
|
3728
|
-
const attachmentPoint = import_constants13.
|
|
3718
|
+
const attachmentPoint = import_constants13.GL.COLOR_ATTACHMENT0 + i;
|
|
3729
3719
|
if (attachment) {
|
|
3730
3720
|
this._attachOne(attachmentPoint, attachment);
|
|
3731
3721
|
}
|
|
@@ -3736,7 +3726,7 @@ var WEBGLFramebuffer = class extends import_api14.Framebuffer {
|
|
|
3736
3726
|
this.depthStencilAttachment
|
|
3737
3727
|
);
|
|
3738
3728
|
}
|
|
3739
|
-
this.gl.bindFramebuffer(import_constants13.
|
|
3729
|
+
this.gl.bindFramebuffer(import_constants13.GL.FRAMEBUFFER, null);
|
|
3740
3730
|
}
|
|
3741
3731
|
if (props.check !== false) {
|
|
3742
3732
|
this._checkStatus();
|
|
@@ -3755,11 +3745,11 @@ var WEBGLFramebuffer = class extends import_api14.Framebuffer {
|
|
|
3755
3745
|
// PRIVATE
|
|
3756
3746
|
/** Check the status */
|
|
3757
3747
|
_checkStatus() {
|
|
3758
|
-
const { gl } = this;
|
|
3759
|
-
const prevHandle2 =
|
|
3760
|
-
const status =
|
|
3761
|
-
|
|
3762
|
-
if (status !==
|
|
3748
|
+
const { gl: gl2 } = this;
|
|
3749
|
+
const prevHandle2 = gl2.bindFramebuffer(import_constants13.GL.FRAMEBUFFER, this.handle);
|
|
3750
|
+
const status = gl2.checkFramebufferStatus(import_constants13.GL.FRAMEBUFFER);
|
|
3751
|
+
gl2.bindFramebuffer(import_constants13.GL.FRAMEBUFFER, prevHandle2 || null);
|
|
3752
|
+
if (status !== gl2.FRAMEBUFFER_COMPLETE) {
|
|
3763
3753
|
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
3764
3754
|
}
|
|
3765
3755
|
}
|
|
@@ -3815,9 +3805,9 @@ var WEBGLFramebuffer = class extends import_api14.Framebuffer {
|
|
|
3815
3805
|
}
|
|
3816
3806
|
_attachWEBGLRenderbuffer(attachment, renderbuffer) {
|
|
3817
3807
|
this.gl.framebufferRenderbuffer(
|
|
3818
|
-
import_constants13.
|
|
3808
|
+
import_constants13.GL.FRAMEBUFFER,
|
|
3819
3809
|
attachment,
|
|
3820
|
-
import_constants13.
|
|
3810
|
+
import_constants13.GL.RENDERBUFFER,
|
|
3821
3811
|
renderbuffer.handle
|
|
3822
3812
|
);
|
|
3823
3813
|
}
|
|
@@ -3828,43 +3818,43 @@ var WEBGLFramebuffer = class extends import_api14.Framebuffer {
|
|
|
3828
3818
|
* @param level = 0 - mipmapLevel (must be 0 in WebGL1)
|
|
3829
3819
|
*/
|
|
3830
3820
|
_attachTexture(attachment, texture, layer, level) {
|
|
3831
|
-
const { gl, gl2 } = this.device;
|
|
3832
|
-
|
|
3821
|
+
const { gl: gl2, gl2: gl22 } = this.device;
|
|
3822
|
+
gl2.bindTexture(texture.target, texture.handle);
|
|
3833
3823
|
switch (texture.target) {
|
|
3834
|
-
case import_constants13.
|
|
3835
|
-
case import_constants13.
|
|
3824
|
+
case import_constants13.GL.TEXTURE_2D_ARRAY:
|
|
3825
|
+
case import_constants13.GL.TEXTURE_3D:
|
|
3836
3826
|
this.device.assertWebGL2();
|
|
3837
|
-
|
|
3827
|
+
gl22 == null ? void 0 : gl22.framebufferTextureLayer(import_constants13.GL.FRAMEBUFFER, attachment, texture.target, level, layer);
|
|
3838
3828
|
break;
|
|
3839
|
-
case import_constants13.
|
|
3829
|
+
case import_constants13.GL.TEXTURE_CUBE_MAP:
|
|
3840
3830
|
const face = mapIndexToCubeMapFace(layer);
|
|
3841
|
-
|
|
3831
|
+
gl2.framebufferTexture2D(import_constants13.GL.FRAMEBUFFER, attachment, face, texture.handle, level);
|
|
3842
3832
|
break;
|
|
3843
|
-
case import_constants13.
|
|
3844
|
-
|
|
3833
|
+
case import_constants13.GL.TEXTURE_2D:
|
|
3834
|
+
gl2.framebufferTexture2D(import_constants13.GL.FRAMEBUFFER, attachment, import_constants13.GL.TEXTURE_2D, texture.handle, level);
|
|
3845
3835
|
break;
|
|
3846
3836
|
default:
|
|
3847
3837
|
(0, import_api14.assert)(false, "Illegal texture type");
|
|
3848
3838
|
}
|
|
3849
|
-
|
|
3839
|
+
gl2.bindTexture(texture.target, null);
|
|
3850
3840
|
}
|
|
3851
3841
|
};
|
|
3852
3842
|
function mapIndexToCubeMapFace(layer) {
|
|
3853
|
-
return layer < import_constants13.
|
|
3843
|
+
return layer < import_constants13.GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + import_constants13.GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;
|
|
3854
3844
|
}
|
|
3855
3845
|
function _getFrameBufferStatus(status) {
|
|
3856
3846
|
switch (status) {
|
|
3857
|
-
case import_constants13.
|
|
3847
|
+
case import_constants13.GL.FRAMEBUFFER_COMPLETE:
|
|
3858
3848
|
return "success";
|
|
3859
|
-
case import_constants13.
|
|
3849
|
+
case import_constants13.GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
|
3860
3850
|
return "Mismatched attachments";
|
|
3861
|
-
case import_constants13.
|
|
3851
|
+
case import_constants13.GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
|
3862
3852
|
return "No attachments";
|
|
3863
|
-
case import_constants13.
|
|
3853
|
+
case import_constants13.GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
|
|
3864
3854
|
return "Height/width mismatch";
|
|
3865
|
-
case import_constants13.
|
|
3855
|
+
case import_constants13.GL.FRAMEBUFFER_UNSUPPORTED:
|
|
3866
3856
|
return "Unsupported or split attachments";
|
|
3867
|
-
case import_constants13.
|
|
3857
|
+
case import_constants13.GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
|
|
3868
3858
|
return "Samples mismatch";
|
|
3869
3859
|
default:
|
|
3870
3860
|
return `${status}`;
|
|
@@ -3908,6 +3898,7 @@ var WebGLCanvasContext = class extends import_api15.CanvasContext {
|
|
|
3908
3898
|
*/
|
|
3909
3899
|
resize(options) {
|
|
3910
3900
|
if (this.canvas) {
|
|
3901
|
+
const devicePixelRatio = this.getDevicePixelRatio(options == null ? void 0 : options.useDevicePixels);
|
|
3911
3902
|
this.setDevicePixelRatio(devicePixelRatio, options);
|
|
3912
3903
|
return;
|
|
3913
3904
|
}
|
|
@@ -3981,11 +3972,11 @@ function initializeSpectorJS(props) {
|
|
|
3981
3972
|
|
|
3982
3973
|
// src/context/debug/webgl-developer-tools.ts
|
|
3983
3974
|
var import_api17 = require("@luma.gl/api");
|
|
3984
|
-
var import_constants14 =
|
|
3975
|
+
var import_constants14 = require("@luma.gl/constants");
|
|
3985
3976
|
var WEBGL_DEBUG_CDN_URL = "https://unpkg.com/webgl-debug@2.0.1/index.js";
|
|
3986
|
-
function getContextData2(
|
|
3987
|
-
|
|
3988
|
-
return
|
|
3977
|
+
function getContextData2(gl2) {
|
|
3978
|
+
gl2.luma = gl2.luma || {};
|
|
3979
|
+
return gl2.luma;
|
|
3989
3980
|
}
|
|
3990
3981
|
function loadWebGLDeveloperTools() {
|
|
3991
3982
|
return __async(this, null, function* () {
|
|
@@ -3996,42 +3987,42 @@ function loadWebGLDeveloperTools() {
|
|
|
3996
3987
|
}
|
|
3997
3988
|
});
|
|
3998
3989
|
}
|
|
3999
|
-
function makeDebugContext(
|
|
4000
|
-
if (!
|
|
3990
|
+
function makeDebugContext(gl2, props = {}) {
|
|
3991
|
+
if (!gl2) {
|
|
4001
3992
|
return null;
|
|
4002
3993
|
}
|
|
4003
|
-
return props.debug ? getDebugContext(
|
|
3994
|
+
return props.debug ? getDebugContext(gl2, props) : getRealContext(gl2);
|
|
4004
3995
|
}
|
|
4005
|
-
function getRealContext(
|
|
4006
|
-
const data = getContextData2(
|
|
4007
|
-
return data.realContext ? data.realContext :
|
|
3996
|
+
function getRealContext(gl2) {
|
|
3997
|
+
const data = getContextData2(gl2);
|
|
3998
|
+
return data.realContext ? data.realContext : gl2;
|
|
4008
3999
|
}
|
|
4009
|
-
function getDebugContext(
|
|
4000
|
+
function getDebugContext(gl2, props) {
|
|
4010
4001
|
if (!globalThis.WebGLDebugUtils) {
|
|
4011
4002
|
import_api17.log.warn("webgl-debug not loaded")();
|
|
4012
|
-
return
|
|
4003
|
+
return gl2;
|
|
4013
4004
|
}
|
|
4014
|
-
const data = getContextData2(
|
|
4005
|
+
const data = getContextData2(gl2);
|
|
4015
4006
|
if (data.debugContext) {
|
|
4016
4007
|
return data.debugContext;
|
|
4017
4008
|
}
|
|
4018
|
-
globalThis.WebGLDebugUtils.init(__spreadValues(__spreadValues({}, import_constants14.
|
|
4009
|
+
globalThis.WebGLDebugUtils.init(__spreadValues(__spreadValues({}, import_constants14.GL), gl2));
|
|
4019
4010
|
const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(
|
|
4020
|
-
|
|
4011
|
+
gl2,
|
|
4021
4012
|
onGLError.bind(null, props),
|
|
4022
4013
|
onValidateGLFunc.bind(null, props)
|
|
4023
4014
|
);
|
|
4024
|
-
for (const key in import_constants14.
|
|
4025
|
-
if (!(key in glDebug) && typeof import_constants14.
|
|
4026
|
-
glDebug[key] = import_constants14.
|
|
4015
|
+
for (const key in import_constants14.GL) {
|
|
4016
|
+
if (!(key in glDebug) && typeof import_constants14.GL[key] === "number") {
|
|
4017
|
+
glDebug[key] = import_constants14.GL[key];
|
|
4027
4018
|
}
|
|
4028
4019
|
}
|
|
4029
4020
|
class WebGLDebugContext {
|
|
4030
4021
|
}
|
|
4031
|
-
Object.setPrototypeOf(glDebug, Object.getPrototypeOf(
|
|
4022
|
+
Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl2));
|
|
4032
4023
|
Object.setPrototypeOf(WebGLDebugContext, glDebug);
|
|
4033
4024
|
const debugContext = Object.create(WebGLDebugContext);
|
|
4034
|
-
data.realContext =
|
|
4025
|
+
data.realContext = gl2;
|
|
4035
4026
|
data.debugContext = debugContext;
|
|
4036
4027
|
debugContext.debug = true;
|
|
4037
4028
|
return debugContext;
|
|
@@ -4080,13 +4071,13 @@ function onValidateGLFunc(props, functionName, functionArgs) {
|
|
|
4080
4071
|
}
|
|
4081
4072
|
}
|
|
4082
4073
|
|
|
4083
|
-
// src/classic/buffer.ts
|
|
4074
|
+
// src/classic/buffer-with-accessor.ts
|
|
4084
4075
|
var import_api19 = require("@luma.gl/api");
|
|
4085
|
-
var import_constants17 =
|
|
4076
|
+
var import_constants17 = require("@luma.gl/constants");
|
|
4086
4077
|
|
|
4087
4078
|
// src/classic/accessor.ts
|
|
4088
4079
|
var import_api18 = require("@luma.gl/api");
|
|
4089
|
-
var import_constants16 =
|
|
4080
|
+
var import_constants16 = require("@luma.gl/constants");
|
|
4090
4081
|
|
|
4091
4082
|
// src/classic/typed-array-utils.ts
|
|
4092
4083
|
var import_constants15 = require("@luma.gl/constants");
|
|
@@ -4143,7 +4134,7 @@ function getTypedArrayFromGLType(glType, options) {
|
|
|
4143
4134
|
var DEFAULT_ACCESSOR_VALUES = {
|
|
4144
4135
|
offset: 0,
|
|
4145
4136
|
stride: 0,
|
|
4146
|
-
type: import_constants16.
|
|
4137
|
+
type: import_constants16.GL.FLOAT,
|
|
4147
4138
|
size: 1,
|
|
4148
4139
|
divisor: 0,
|
|
4149
4140
|
normalized: false,
|
|
@@ -4157,12 +4148,12 @@ var PROP_CHECKS = {
|
|
|
4157
4148
|
};
|
|
4158
4149
|
var Accessor = class {
|
|
4159
4150
|
static getBytesPerElement(accessor) {
|
|
4160
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants16.
|
|
4151
|
+
const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants16.GL.FLOAT);
|
|
4161
4152
|
return ArrayType.BYTES_PER_ELEMENT;
|
|
4162
4153
|
}
|
|
4163
4154
|
static getBytesPerVertex(accessor) {
|
|
4164
4155
|
(0, import_api18.assert)(accessor.size);
|
|
4165
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants16.
|
|
4156
|
+
const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants16.GL.FLOAT);
|
|
4166
4157
|
return ArrayType.BYTES_PER_ELEMENT * accessor.size;
|
|
4167
4158
|
}
|
|
4168
4159
|
// Combines (merges) a list of accessors. On top of default values
|
|
@@ -4193,7 +4184,7 @@ var Accessor = class {
|
|
|
4193
4184
|
props = (0, import_api18.checkProps)("Accessor", props, PROP_CHECKS);
|
|
4194
4185
|
if (props.type !== void 0) {
|
|
4195
4186
|
this.type = props.type;
|
|
4196
|
-
if (props.type === import_constants16.
|
|
4187
|
+
if (props.type === import_constants16.GL.INT || props.type === import_constants16.GL.UNSIGNED_INT) {
|
|
4197
4188
|
this.integer = true;
|
|
4198
4189
|
}
|
|
4199
4190
|
}
|
|
@@ -4256,7 +4247,7 @@ var Accessor = class {
|
|
|
4256
4247
|
}
|
|
4257
4248
|
};
|
|
4258
4249
|
|
|
4259
|
-
// src/classic/buffer.ts
|
|
4250
|
+
// src/classic/buffer-with-accessor.ts
|
|
4260
4251
|
var DEBUG_DATA_LENGTH2 = 10;
|
|
4261
4252
|
var DEPRECATED_PROPS = {
|
|
4262
4253
|
offset: "accessor.offset",
|
|
@@ -4294,7 +4285,7 @@ function getWEBGLBufferProps(props) {
|
|
|
4294
4285
|
}
|
|
4295
4286
|
return bufferProps;
|
|
4296
4287
|
}
|
|
4297
|
-
var
|
|
4288
|
+
var BufferWithAccessor = class extends WEBGLBuffer {
|
|
4298
4289
|
constructor(device, props = {}) {
|
|
4299
4290
|
super(WebGLDevice.attach(device), getWEBGLBufferProps(props));
|
|
4300
4291
|
this.setAccessor(Object.assign({}, props, props.accessor));
|
|
@@ -4328,7 +4319,7 @@ var ClassicBuffer = class extends WEBGLBuffer {
|
|
|
4328
4319
|
props = { byteLength: props };
|
|
4329
4320
|
}
|
|
4330
4321
|
props = (0, import_api19.checkProps)("Buffer", props, PROP_CHECKS_INITIALIZE);
|
|
4331
|
-
this.webglUsage = props.webglUsage || import_constants17.
|
|
4322
|
+
this.webglUsage = props.webglUsage || import_constants17.GL.STATIC_DRAW;
|
|
4332
4323
|
this.debugData = null;
|
|
4333
4324
|
this.setAccessor(Object.assign({}, props, props.accessor));
|
|
4334
4325
|
if (props.data) {
|
|
@@ -4382,7 +4373,7 @@ var ClassicBuffer = class extends WEBGLBuffer {
|
|
|
4382
4373
|
const { data, offset = 0, srcOffset = 0 } = options;
|
|
4383
4374
|
const byteLength = options.byteLength || options.length;
|
|
4384
4375
|
(0, import_api19.assert)(data);
|
|
4385
|
-
const target = this.gl.webgl2 ? import_constants17.
|
|
4376
|
+
const target = this.gl.webgl2 ? import_constants17.GL.COPY_WRITE_BUFFER : this.target;
|
|
4386
4377
|
this.gl.bindBuffer(target, this.handle);
|
|
4387
4378
|
if (srcOffset !== 0 || byteLength !== void 0) {
|
|
4388
4379
|
assertWebGL2Context(this.gl);
|
|
@@ -4401,13 +4392,13 @@ var ClassicBuffer = class extends WEBGLBuffer {
|
|
|
4401
4392
|
*/
|
|
4402
4393
|
copyData(options) {
|
|
4403
4394
|
const { sourceBuffer, readOffset = 0, writeOffset = 0, size } = options;
|
|
4404
|
-
const { gl, gl2 } = this;
|
|
4405
|
-
assertWebGL2Context(
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4395
|
+
const { gl: gl2, gl2: gl22 } = this;
|
|
4396
|
+
assertWebGL2Context(gl2);
|
|
4397
|
+
gl2.bindBuffer(import_constants17.GL.COPY_READ_BUFFER, sourceBuffer.handle);
|
|
4398
|
+
gl2.bindBuffer(import_constants17.GL.COPY_WRITE_BUFFER, this.handle);
|
|
4399
|
+
gl22 == null ? void 0 : gl22.copyBufferSubData(import_constants17.GL.COPY_READ_BUFFER, import_constants17.GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);
|
|
4400
|
+
gl2.bindBuffer(import_constants17.GL.COPY_READ_BUFFER, null);
|
|
4401
|
+
gl2.bindBuffer(import_constants17.GL.COPY_WRITE_BUFFER, null);
|
|
4411
4402
|
this.debugData = null;
|
|
4412
4403
|
return this;
|
|
4413
4404
|
}
|
|
@@ -4420,7 +4411,7 @@ var ClassicBuffer = class extends WEBGLBuffer {
|
|
|
4420
4411
|
let { dstData = null, length = 0 } = options || {};
|
|
4421
4412
|
const { srcByteOffset = 0, dstOffset = 0 } = options || {};
|
|
4422
4413
|
assertWebGL2Context(this.gl);
|
|
4423
|
-
const ArrayType = getTypedArrayFromGLType(this.accessor.type || import_constants17.
|
|
4414
|
+
const ArrayType = getTypedArrayFromGLType(this.accessor.type || import_constants17.GL.FLOAT, { clamped: false });
|
|
4424
4415
|
const sourceAvailableElementCount = this._getAvailableElementCount(srcByteOffset);
|
|
4425
4416
|
const dstElementOffset = dstOffset;
|
|
4426
4417
|
let dstAvailableElementCount;
|
|
@@ -4439,9 +4430,9 @@ var ClassicBuffer = class extends WEBGLBuffer {
|
|
|
4439
4430
|
length = length || copyElementCount;
|
|
4440
4431
|
(0, import_api19.assert)(length <= copyElementCount);
|
|
4441
4432
|
dstData = dstData || new ArrayType(dstElementCount);
|
|
4442
|
-
this.gl.bindBuffer(import_constants17.
|
|
4443
|
-
(_a = this.gl2) == null ? void 0 : _a.getBufferSubData(import_constants17.
|
|
4444
|
-
this.gl.bindBuffer(import_constants17.
|
|
4433
|
+
this.gl.bindBuffer(import_constants17.GL.COPY_READ_BUFFER, this.handle);
|
|
4434
|
+
(_a = this.gl2) == null ? void 0 : _a.getBufferSubData(import_constants17.GL.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);
|
|
4435
|
+
this.gl.bindBuffer(import_constants17.GL.COPY_READ_BUFFER, null);
|
|
4445
4436
|
return dstData;
|
|
4446
4437
|
}
|
|
4447
4438
|
/**
|
|
@@ -4461,7 +4452,7 @@ var ClassicBuffer = class extends WEBGLBuffer {
|
|
|
4461
4452
|
offset = 0,
|
|
4462
4453
|
size
|
|
4463
4454
|
} = options || {};
|
|
4464
|
-
if (target === import_constants17.
|
|
4455
|
+
if (target === import_constants17.GL.UNIFORM_BUFFER || target === import_constants17.GL.TRANSFORM_FEEDBACK_BUFFER) {
|
|
4465
4456
|
if (size !== void 0) {
|
|
4466
4457
|
(_a = this.gl2) == null ? void 0 : _a.bindBufferRange(target, index, this.handle, offset, size);
|
|
4467
4458
|
} else {
|
|
@@ -4476,7 +4467,7 @@ var ClassicBuffer = class extends WEBGLBuffer {
|
|
|
4476
4467
|
unbind(options) {
|
|
4477
4468
|
var _a;
|
|
4478
4469
|
const { target = this.target, index = this.accessor && this.accessor.index } = options || {};
|
|
4479
|
-
const isIndexedBuffer = target === import_constants17.
|
|
4470
|
+
const isIndexedBuffer = target === import_constants17.GL.UNIFORM_BUFFER || target === import_constants17.GL.TRANSFORM_FEEDBACK_BUFFER;
|
|
4480
4471
|
if (isIndexedBuffer) {
|
|
4481
4472
|
(_a = this.gl2) == null ? void 0 : _a.bindBufferBase(target, index, null);
|
|
4482
4473
|
} else {
|
|
@@ -4537,10 +4528,10 @@ var ClassicBuffer = class extends WEBGLBuffer {
|
|
|
4537
4528
|
// Binding a buffer for the first time locks the type
|
|
4538
4529
|
// In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type
|
|
4539
4530
|
_getTarget() {
|
|
4540
|
-
return this.gl.webgl2 ? import_constants17.
|
|
4531
|
+
return this.gl.webgl2 ? import_constants17.GL.COPY_WRITE_BUFFER : this.target;
|
|
4541
4532
|
}
|
|
4542
4533
|
_getAvailableElementCount(srcByteOffset) {
|
|
4543
|
-
const ArrayType = getTypedArrayFromGLType(this.accessor.type || import_constants17.
|
|
4534
|
+
const ArrayType = getTypedArrayFromGLType(this.accessor.type || import_constants17.GL.FLOAT, { clamped: false });
|
|
4544
4535
|
const sourceElementOffset = srcByteOffset / ArrayType.BYTES_PER_ELEMENT;
|
|
4545
4536
|
return this.getElementCount() - sourceElementOffset;
|
|
4546
4537
|
}
|
|
@@ -4567,7 +4558,7 @@ var ClassicBuffer = class extends WEBGLBuffer {
|
|
|
4567
4558
|
|
|
4568
4559
|
// src/adapter/resources/webgl-shader.ts
|
|
4569
4560
|
var import_api20 = require("@luma.gl/api");
|
|
4570
|
-
var import_constants18 =
|
|
4561
|
+
var import_constants18 = require("@luma.gl/constants");
|
|
4571
4562
|
|
|
4572
4563
|
// src/adapter/helpers/get-shader-info.ts
|
|
4573
4564
|
function getShaderInfo(source, defaultName) {
|
|
@@ -4633,10 +4624,10 @@ var WEBGLShader = class extends import_api20.Shader {
|
|
|
4633
4624
|
this.device = device;
|
|
4634
4625
|
switch (this.props.stage) {
|
|
4635
4626
|
case "vertex":
|
|
4636
|
-
this.handle = this.props.handle || this.device.gl.createShader(import_constants18.
|
|
4627
|
+
this.handle = this.props.handle || this.device.gl.createShader(import_constants18.GL.VERTEX_SHADER);
|
|
4637
4628
|
break;
|
|
4638
4629
|
case "fragment":
|
|
4639
|
-
this.handle = this.props.handle || this.device.gl.createShader(import_constants18.
|
|
4630
|
+
this.handle = this.props.handle || this.device.gl.createShader(import_constants18.GL.FRAGMENT_SHADER);
|
|
4640
4631
|
break;
|
|
4641
4632
|
default:
|
|
4642
4633
|
throw new Error(this.props.stage);
|
|
@@ -4661,12 +4652,12 @@ var WEBGLShader = class extends import_api20.Shader {
|
|
|
4661
4652
|
const addGLSLVersion = (source2) => source2.startsWith("#version ") ? source2 : `#version 100
|
|
4662
4653
|
${source2}`;
|
|
4663
4654
|
source = addGLSLVersion(source);
|
|
4664
|
-
const { gl } = this.device;
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
const compileStatus =
|
|
4655
|
+
const { gl: gl2 } = this.device;
|
|
4656
|
+
gl2.shaderSource(this.handle, source);
|
|
4657
|
+
gl2.compileShader(this.handle);
|
|
4658
|
+
const compileStatus = gl2.getShaderParameter(this.handle, import_constants18.GL.COMPILE_STATUS);
|
|
4668
4659
|
if (!compileStatus) {
|
|
4669
|
-
const shaderLog =
|
|
4660
|
+
const shaderLog = gl2.getShaderInfoLog(this.handle);
|
|
4670
4661
|
const parsedLog = shaderLog ? parseShaderCompilerLog(shaderLog) : [];
|
|
4671
4662
|
const messages = parsedLog.filter((message2) => message2.type === "error");
|
|
4672
4663
|
const formattedLog = (0, import_api20.formatCompilerLog)(messages, source);
|
|
@@ -4804,10 +4795,10 @@ var WEBGLRenderPass = class extends import_api21.RenderPass {
|
|
|
4804
4795
|
|
|
4805
4796
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
4806
4797
|
var import_api23 = require("@luma.gl/api");
|
|
4807
|
-
var import_constants25 =
|
|
4798
|
+
var import_constants25 = require("@luma.gl/constants");
|
|
4808
4799
|
|
|
4809
4800
|
// src/adapter/helpers/get-shader-layout.ts
|
|
4810
|
-
var import_constants22 =
|
|
4801
|
+
var import_constants22 = require("@luma.gl/constants");
|
|
4811
4802
|
|
|
4812
4803
|
// src/adapter/helpers/uniforms.ts
|
|
4813
4804
|
var import_constants20 = require("@luma.gl/constants");
|
|
@@ -4885,7 +4876,7 @@ function decodeAttributeType(attributeType) {
|
|
|
4885
4876
|
}
|
|
4886
4877
|
|
|
4887
4878
|
// src/adapter/converters/vertex-formats.ts
|
|
4888
|
-
var import_constants21 =
|
|
4879
|
+
var import_constants21 = require("@luma.gl/constants");
|
|
4889
4880
|
function getVertexFormat(type, components) {
|
|
4890
4881
|
const base = getDataFormat(type);
|
|
4891
4882
|
switch (components) {
|
|
@@ -4903,11 +4894,11 @@ function getVertexFormat(type, components) {
|
|
|
4903
4894
|
}
|
|
4904
4895
|
function getDataFormat(type) {
|
|
4905
4896
|
switch (type) {
|
|
4906
|
-
case import_constants21.
|
|
4897
|
+
case import_constants21.GL.INT:
|
|
4907
4898
|
return "sint32";
|
|
4908
|
-
case import_constants21.
|
|
4899
|
+
case import_constants21.GL.UNSIGNED_INT:
|
|
4909
4900
|
return "uint32";
|
|
4910
|
-
case import_constants21.
|
|
4901
|
+
case import_constants21.GL.FLOAT:
|
|
4911
4902
|
return "float32";
|
|
4912
4903
|
default:
|
|
4913
4904
|
throw new Error(String(type));
|
|
@@ -4915,9 +4906,9 @@ function getDataFormat(type) {
|
|
|
4915
4906
|
}
|
|
4916
4907
|
|
|
4917
4908
|
// src/adapter/helpers/get-shader-layout.ts
|
|
4918
|
-
function getShaderLayout(
|
|
4909
|
+
function getShaderLayout(gl2, program) {
|
|
4919
4910
|
var _a, _b;
|
|
4920
|
-
const programBindings = getProgramBindings(
|
|
4911
|
+
const programBindings = getProgramBindings(gl2, program);
|
|
4921
4912
|
const shaderLayout = {
|
|
4922
4913
|
attributes: [],
|
|
4923
4914
|
bindings: []
|
|
@@ -4926,7 +4917,7 @@ function getShaderLayout(gl, program) {
|
|
|
4926
4917
|
const size = Math.min(attribute.accessor.size, 4);
|
|
4927
4918
|
const format = (
|
|
4928
4919
|
// attribute.accessor.format ||
|
|
4929
|
-
getVertexFormat(attribute.accessor.type || import_constants22.
|
|
4920
|
+
getVertexFormat(attribute.accessor.type || import_constants22.GL.FLOAT, size)
|
|
4930
4921
|
);
|
|
4931
4922
|
shaderLayout.attributes.push({
|
|
4932
4923
|
name: attribute.name,
|
|
@@ -4976,26 +4967,26 @@ function getShaderLayout(gl, program) {
|
|
|
4976
4967
|
}
|
|
4977
4968
|
return shaderLayout;
|
|
4978
4969
|
}
|
|
4979
|
-
function getProgramBindings(
|
|
4970
|
+
function getProgramBindings(gl2, program) {
|
|
4980
4971
|
const config = {
|
|
4981
|
-
attributes: readAttributeBindings(
|
|
4982
|
-
uniforms: readUniformBindings(
|
|
4983
|
-
uniformBlocks: readUniformBlocks(
|
|
4984
|
-
varyings: readVaryings(
|
|
4972
|
+
attributes: readAttributeBindings(gl2, program),
|
|
4973
|
+
uniforms: readUniformBindings(gl2, program),
|
|
4974
|
+
uniformBlocks: readUniformBlocks(gl2, program),
|
|
4975
|
+
varyings: readVaryings(gl2, program)
|
|
4985
4976
|
};
|
|
4986
4977
|
Object.seal(config);
|
|
4987
4978
|
return config;
|
|
4988
4979
|
}
|
|
4989
|
-
function readAttributeBindings(
|
|
4980
|
+
function readAttributeBindings(gl2, program) {
|
|
4990
4981
|
const attributes = [];
|
|
4991
|
-
const count =
|
|
4982
|
+
const count = gl2.getProgramParameter(program, gl2.ACTIVE_ATTRIBUTES);
|
|
4992
4983
|
for (let index = 0; index < count; index++) {
|
|
4993
|
-
const activeInfo =
|
|
4984
|
+
const activeInfo = gl2.getActiveAttrib(program, index);
|
|
4994
4985
|
if (!activeInfo) {
|
|
4995
4986
|
throw new Error("activeInfo");
|
|
4996
4987
|
}
|
|
4997
4988
|
const { name, type: compositeType, size } = activeInfo;
|
|
4998
|
-
const location =
|
|
4989
|
+
const location = gl2.getAttribLocation(program, name);
|
|
4999
4990
|
if (location >= 0) {
|
|
5000
4991
|
const { glType, components } = decodeAttributeType(compositeType);
|
|
5001
4992
|
const accessor = { type: glType, size: size * components };
|
|
@@ -5009,15 +5000,15 @@ function readAttributeBindings(gl, program) {
|
|
|
5009
5000
|
attributes.sort((a, b) => a.location - b.location);
|
|
5010
5001
|
return attributes;
|
|
5011
5002
|
}
|
|
5012
|
-
function readVaryings(
|
|
5013
|
-
if (!isWebGL2(
|
|
5003
|
+
function readVaryings(gl2, program) {
|
|
5004
|
+
if (!isWebGL2(gl2)) {
|
|
5014
5005
|
return [];
|
|
5015
5006
|
}
|
|
5016
|
-
const
|
|
5007
|
+
const gl22 = gl2;
|
|
5017
5008
|
const varyings = [];
|
|
5018
|
-
const count =
|
|
5009
|
+
const count = gl2.getProgramParameter(program, import_constants22.GL.TRANSFORM_FEEDBACK_VARYINGS);
|
|
5019
5010
|
for (let location = 0; location < count; location++) {
|
|
5020
|
-
const activeInfo =
|
|
5011
|
+
const activeInfo = gl22.getTransformFeedbackVarying(program, location);
|
|
5021
5012
|
if (!activeInfo) {
|
|
5022
5013
|
throw new Error("activeInfo");
|
|
5023
5014
|
}
|
|
@@ -5030,17 +5021,17 @@ function readVaryings(gl, program) {
|
|
|
5030
5021
|
varyings.sort((a, b) => a.location - b.location);
|
|
5031
5022
|
return varyings;
|
|
5032
5023
|
}
|
|
5033
|
-
function readUniformBindings(
|
|
5024
|
+
function readUniformBindings(gl2, program) {
|
|
5034
5025
|
const uniforms = [];
|
|
5035
|
-
const uniformCount =
|
|
5026
|
+
const uniformCount = gl2.getProgramParameter(program, import_constants22.GL.ACTIVE_UNIFORMS);
|
|
5036
5027
|
for (let i = 0; i < uniformCount; i++) {
|
|
5037
|
-
const activeInfo =
|
|
5028
|
+
const activeInfo = gl2.getActiveUniform(program, i);
|
|
5038
5029
|
if (!activeInfo) {
|
|
5039
5030
|
throw new Error("activeInfo");
|
|
5040
5031
|
}
|
|
5041
5032
|
const { name: rawName, size, type } = activeInfo;
|
|
5042
5033
|
const { name, isArray: isArray2 } = parseUniformName(rawName);
|
|
5043
|
-
let webglLocation =
|
|
5034
|
+
let webglLocation = gl2.getUniformLocation(program, name);
|
|
5044
5035
|
const uniformInfo = {
|
|
5045
5036
|
// WebGL locations are uniquely typed but just numbers
|
|
5046
5037
|
location: webglLocation,
|
|
@@ -5053,7 +5044,7 @@ function readUniformBindings(gl, program) {
|
|
|
5053
5044
|
if (uniformInfo.size > 1) {
|
|
5054
5045
|
for (let j = 0; j < uniformInfo.size; j++) {
|
|
5055
5046
|
const elementName = `${name}[${j}]`;
|
|
5056
|
-
webglLocation =
|
|
5047
|
+
webglLocation = gl2.getUniformLocation(program, elementName);
|
|
5057
5048
|
const arrayElementUniformInfo = __spreadProps(__spreadValues({}, uniformInfo), {
|
|
5058
5049
|
name: elementName,
|
|
5059
5050
|
location: webglLocation
|
|
@@ -5064,31 +5055,31 @@ function readUniformBindings(gl, program) {
|
|
|
5064
5055
|
}
|
|
5065
5056
|
return uniforms;
|
|
5066
5057
|
}
|
|
5067
|
-
function readUniformBlocks(
|
|
5068
|
-
if (!isWebGL2(
|
|
5058
|
+
function readUniformBlocks(gl2, program) {
|
|
5059
|
+
if (!isWebGL2(gl2)) {
|
|
5069
5060
|
return [];
|
|
5070
5061
|
}
|
|
5071
|
-
const
|
|
5072
|
-
const getBlockParameter = (blockIndex, pname) =>
|
|
5062
|
+
const gl22 = gl2;
|
|
5063
|
+
const getBlockParameter = (blockIndex, pname) => gl22.getActiveUniformBlockParameter(program, blockIndex, pname);
|
|
5073
5064
|
const uniformBlocks = [];
|
|
5074
|
-
const blockCount =
|
|
5065
|
+
const blockCount = gl22.getProgramParameter(program, import_constants22.GL.ACTIVE_UNIFORM_BLOCKS);
|
|
5075
5066
|
for (let blockIndex = 0; blockIndex < blockCount; blockIndex++) {
|
|
5076
5067
|
const blockInfo = {
|
|
5077
|
-
name:
|
|
5078
|
-
location: getBlockParameter(blockIndex, import_constants22.
|
|
5079
|
-
byteLength: getBlockParameter(blockIndex, import_constants22.
|
|
5080
|
-
vertex: getBlockParameter(blockIndex, import_constants22.
|
|
5081
|
-
fragment: getBlockParameter(blockIndex, import_constants22.
|
|
5082
|
-
uniformCount: getBlockParameter(blockIndex, import_constants22.
|
|
5068
|
+
name: gl22.getActiveUniformBlockName(program, blockIndex) || "",
|
|
5069
|
+
location: getBlockParameter(blockIndex, import_constants22.GL.UNIFORM_BLOCK_BINDING),
|
|
5070
|
+
byteLength: getBlockParameter(blockIndex, import_constants22.GL.UNIFORM_BLOCK_DATA_SIZE),
|
|
5071
|
+
vertex: getBlockParameter(blockIndex, import_constants22.GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),
|
|
5072
|
+
fragment: getBlockParameter(blockIndex, import_constants22.GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),
|
|
5073
|
+
uniformCount: getBlockParameter(blockIndex, import_constants22.GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),
|
|
5083
5074
|
uniforms: []
|
|
5084
5075
|
};
|
|
5085
|
-
const uniformIndices = getBlockParameter(blockIndex, import_constants22.
|
|
5086
|
-
const uniformType =
|
|
5087
|
-
const uniformArrayLength =
|
|
5088
|
-
const uniformOffset =
|
|
5089
|
-
const uniformStride =
|
|
5076
|
+
const uniformIndices = getBlockParameter(blockIndex, import_constants22.GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES) || [];
|
|
5077
|
+
const uniformType = gl22.getActiveUniforms(program, uniformIndices, import_constants22.GL.UNIFORM_TYPE);
|
|
5078
|
+
const uniformArrayLength = gl22.getActiveUniforms(program, uniformIndices, import_constants22.GL.UNIFORM_SIZE);
|
|
5079
|
+
const uniformOffset = gl22.getActiveUniforms(program, uniformIndices, import_constants22.GL.UNIFORM_OFFSET);
|
|
5080
|
+
const uniformStride = gl22.getActiveUniforms(program, uniformIndices, import_constants22.GL.UNIFORM_ARRAY_STRIDE);
|
|
5090
5081
|
for (let i = 0; i < blockInfo.uniformCount; ++i) {
|
|
5091
|
-
const activeInfo =
|
|
5082
|
+
const activeInfo = gl22.getActiveUniform(program, uniformIndices[i]);
|
|
5092
5083
|
if (!activeInfo) {
|
|
5093
5084
|
throw new Error("activeInfo");
|
|
5094
5085
|
}
|
|
@@ -5109,21 +5100,21 @@ function readUniformBlocks(gl, program) {
|
|
|
5109
5100
|
return uniformBlocks;
|
|
5110
5101
|
}
|
|
5111
5102
|
var SAMPLER_UNIFORMS_GL_TO_GPU = {
|
|
5112
|
-
[import_constants22.
|
|
5113
|
-
[import_constants22.
|
|
5114
|
-
[import_constants22.
|
|
5115
|
-
[import_constants22.
|
|
5116
|
-
[import_constants22.
|
|
5117
|
-
[import_constants22.
|
|
5118
|
-
[import_constants22.
|
|
5119
|
-
[import_constants22.
|
|
5120
|
-
[import_constants22.
|
|
5121
|
-
[import_constants22.
|
|
5122
|
-
[import_constants22.
|
|
5123
|
-
[import_constants22.
|
|
5124
|
-
[import_constants22.
|
|
5125
|
-
[import_constants22.
|
|
5126
|
-
[import_constants22.
|
|
5103
|
+
[import_constants22.GL.SAMPLER_2D]: ["2d", "float"],
|
|
5104
|
+
[import_constants22.GL.SAMPLER_CUBE]: ["cube", "float"],
|
|
5105
|
+
[import_constants22.GL.SAMPLER_3D]: ["3d", "float"],
|
|
5106
|
+
[import_constants22.GL.SAMPLER_2D_SHADOW]: ["3d", "depth"],
|
|
5107
|
+
[import_constants22.GL.SAMPLER_2D_ARRAY]: ["2d-array", "float"],
|
|
5108
|
+
[import_constants22.GL.SAMPLER_2D_ARRAY_SHADOW]: ["2d-array", "depth"],
|
|
5109
|
+
[import_constants22.GL.SAMPLER_CUBE_SHADOW]: ["cube", "float"],
|
|
5110
|
+
[import_constants22.GL.INT_SAMPLER_2D]: ["2d", "sint"],
|
|
5111
|
+
[import_constants22.GL.INT_SAMPLER_3D]: ["3d", "sint"],
|
|
5112
|
+
[import_constants22.GL.INT_SAMPLER_CUBE]: ["cube", "sint"],
|
|
5113
|
+
[import_constants22.GL.INT_SAMPLER_2D_ARRAY]: ["2d-array", "uint"],
|
|
5114
|
+
[import_constants22.GL.UNSIGNED_INT_SAMPLER_2D]: ["2d", "uint"],
|
|
5115
|
+
[import_constants22.GL.UNSIGNED_INT_SAMPLER_3D]: ["3d", "uint"],
|
|
5116
|
+
[import_constants22.GL.UNSIGNED_INT_SAMPLER_CUBE]: ["cube", "uint"],
|
|
5117
|
+
[import_constants22.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: ["2d-array", "uint"]
|
|
5127
5118
|
};
|
|
5128
5119
|
function getSamplerInfo(type) {
|
|
5129
5120
|
const sampler = SAMPLER_UNIFORMS_GL_TO_GPU[type];
|
|
@@ -5154,27 +5145,27 @@ function parseUniformName(name) {
|
|
|
5154
5145
|
}
|
|
5155
5146
|
|
|
5156
5147
|
// src/adapter/helpers/set-uniform.ts
|
|
5157
|
-
var import_constants23 =
|
|
5158
|
-
function setUniform(
|
|
5159
|
-
const
|
|
5148
|
+
var import_constants23 = require("@luma.gl/constants");
|
|
5149
|
+
function setUniform(gl2, location, type, value) {
|
|
5150
|
+
const gl22 = gl2;
|
|
5160
5151
|
if (typeof value === "number") {
|
|
5161
5152
|
switch (type) {
|
|
5162
|
-
case import_constants23.
|
|
5163
|
-
case import_constants23.
|
|
5164
|
-
case import_constants23.
|
|
5165
|
-
case import_constants23.
|
|
5166
|
-
case import_constants23.
|
|
5167
|
-
case import_constants23.
|
|
5168
|
-
case import_constants23.
|
|
5169
|
-
case import_constants23.
|
|
5170
|
-
case import_constants23.
|
|
5171
|
-
case import_constants23.
|
|
5172
|
-
case import_constants23.
|
|
5173
|
-
case import_constants23.
|
|
5174
|
-
case import_constants23.
|
|
5175
|
-
case import_constants23.
|
|
5176
|
-
case import_constants23.
|
|
5177
|
-
return
|
|
5153
|
+
case import_constants23.GL.SAMPLER_2D:
|
|
5154
|
+
case import_constants23.GL.SAMPLER_CUBE:
|
|
5155
|
+
case import_constants23.GL.SAMPLER_3D:
|
|
5156
|
+
case import_constants23.GL.SAMPLER_2D_SHADOW:
|
|
5157
|
+
case import_constants23.GL.SAMPLER_2D_ARRAY:
|
|
5158
|
+
case import_constants23.GL.SAMPLER_2D_ARRAY_SHADOW:
|
|
5159
|
+
case import_constants23.GL.SAMPLER_CUBE_SHADOW:
|
|
5160
|
+
case import_constants23.GL.INT_SAMPLER_2D:
|
|
5161
|
+
case import_constants23.GL.INT_SAMPLER_3D:
|
|
5162
|
+
case import_constants23.GL.INT_SAMPLER_CUBE:
|
|
5163
|
+
case import_constants23.GL.INT_SAMPLER_2D_ARRAY:
|
|
5164
|
+
case import_constants23.GL.UNSIGNED_INT_SAMPLER_2D:
|
|
5165
|
+
case import_constants23.GL.UNSIGNED_INT_SAMPLER_3D:
|
|
5166
|
+
case import_constants23.GL.UNSIGNED_INT_SAMPLER_CUBE:
|
|
5167
|
+
case import_constants23.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
|
5168
|
+
return gl2.uniform1i(location, value);
|
|
5178
5169
|
}
|
|
5179
5170
|
}
|
|
5180
5171
|
if (value === true) {
|
|
@@ -5185,63 +5176,63 @@ function setUniform(gl, location, type, value) {
|
|
|
5185
5176
|
}
|
|
5186
5177
|
const arrayValue = typeof value === "number" ? [value] : value;
|
|
5187
5178
|
switch (type) {
|
|
5188
|
-
case import_constants23.
|
|
5189
|
-
return
|
|
5190
|
-
case import_constants23.
|
|
5191
|
-
return
|
|
5192
|
-
case import_constants23.
|
|
5193
|
-
return
|
|
5194
|
-
case import_constants23.
|
|
5195
|
-
return
|
|
5196
|
-
case import_constants23.
|
|
5197
|
-
return
|
|
5198
|
-
case import_constants23.
|
|
5199
|
-
return
|
|
5200
|
-
case import_constants23.
|
|
5201
|
-
return
|
|
5202
|
-
case import_constants23.
|
|
5203
|
-
return
|
|
5204
|
-
case import_constants23.
|
|
5205
|
-
return
|
|
5206
|
-
case import_constants23.
|
|
5207
|
-
return
|
|
5208
|
-
case import_constants23.
|
|
5209
|
-
return
|
|
5210
|
-
case import_constants23.
|
|
5211
|
-
return
|
|
5212
|
-
case import_constants23.
|
|
5213
|
-
return
|
|
5214
|
-
case import_constants23.
|
|
5215
|
-
return
|
|
5216
|
-
case import_constants23.
|
|
5217
|
-
return
|
|
5218
|
-
case import_constants23.
|
|
5219
|
-
return
|
|
5220
|
-
case import_constants23.
|
|
5221
|
-
return
|
|
5222
|
-
case import_constants23.
|
|
5223
|
-
return
|
|
5224
|
-
case import_constants23.
|
|
5225
|
-
return
|
|
5226
|
-
case import_constants23.
|
|
5227
|
-
return
|
|
5228
|
-
case import_constants23.
|
|
5229
|
-
return
|
|
5230
|
-
case import_constants23.
|
|
5231
|
-
return
|
|
5232
|
-
case import_constants23.
|
|
5233
|
-
return
|
|
5234
|
-
case import_constants23.
|
|
5235
|
-
return
|
|
5236
|
-
case import_constants23.
|
|
5237
|
-
return
|
|
5179
|
+
case import_constants23.GL.FLOAT:
|
|
5180
|
+
return gl2.uniform1fv(location, arrayValue);
|
|
5181
|
+
case import_constants23.GL.FLOAT_VEC2:
|
|
5182
|
+
return gl2.uniform2fv(location, arrayValue);
|
|
5183
|
+
case import_constants23.GL.FLOAT_VEC3:
|
|
5184
|
+
return gl2.uniform3fv(location, arrayValue);
|
|
5185
|
+
case import_constants23.GL.FLOAT_VEC4:
|
|
5186
|
+
return gl2.uniform4fv(location, arrayValue);
|
|
5187
|
+
case import_constants23.GL.INT:
|
|
5188
|
+
return gl2.uniform1iv(location, arrayValue);
|
|
5189
|
+
case import_constants23.GL.INT_VEC2:
|
|
5190
|
+
return gl2.uniform2iv(location, arrayValue);
|
|
5191
|
+
case import_constants23.GL.INT_VEC3:
|
|
5192
|
+
return gl2.uniform3iv(location, arrayValue);
|
|
5193
|
+
case import_constants23.GL.INT_VEC4:
|
|
5194
|
+
return gl2.uniform4iv(location, arrayValue);
|
|
5195
|
+
case import_constants23.GL.BOOL:
|
|
5196
|
+
return gl2.uniform1iv(location, arrayValue);
|
|
5197
|
+
case import_constants23.GL.BOOL_VEC2:
|
|
5198
|
+
return gl2.uniform2iv(location, arrayValue);
|
|
5199
|
+
case import_constants23.GL.BOOL_VEC3:
|
|
5200
|
+
return gl2.uniform3iv(location, arrayValue);
|
|
5201
|
+
case import_constants23.GL.BOOL_VEC4:
|
|
5202
|
+
return gl2.uniform4iv(location, arrayValue);
|
|
5203
|
+
case import_constants23.GL.UNSIGNED_INT:
|
|
5204
|
+
return gl22.uniform1uiv(location, arrayValue, 1);
|
|
5205
|
+
case import_constants23.GL.UNSIGNED_INT_VEC2:
|
|
5206
|
+
return gl22.uniform2uiv(location, arrayValue, 2);
|
|
5207
|
+
case import_constants23.GL.UNSIGNED_INT_VEC3:
|
|
5208
|
+
return gl22.uniform3uiv(location, arrayValue, 3);
|
|
5209
|
+
case import_constants23.GL.UNSIGNED_INT_VEC4:
|
|
5210
|
+
return gl22.uniform4uiv(location, arrayValue, 4);
|
|
5211
|
+
case import_constants23.GL.FLOAT_MAT2:
|
|
5212
|
+
return gl2.uniformMatrix2fv(location, false, arrayValue);
|
|
5213
|
+
case import_constants23.GL.FLOAT_MAT3:
|
|
5214
|
+
return gl2.uniformMatrix3fv(location, false, arrayValue);
|
|
5215
|
+
case import_constants23.GL.FLOAT_MAT4:
|
|
5216
|
+
return gl2.uniformMatrix4fv(location, false, arrayValue);
|
|
5217
|
+
case import_constants23.GL.FLOAT_MAT2x3:
|
|
5218
|
+
return gl22.uniformMatrix2x3fv(location, false, arrayValue);
|
|
5219
|
+
case import_constants23.GL.FLOAT_MAT2x4:
|
|
5220
|
+
return gl22.uniformMatrix2x4fv(location, false, arrayValue);
|
|
5221
|
+
case import_constants23.GL.FLOAT_MAT3x2:
|
|
5222
|
+
return gl22.uniformMatrix3x2fv(location, false, arrayValue);
|
|
5223
|
+
case import_constants23.GL.FLOAT_MAT3x4:
|
|
5224
|
+
return gl22.uniformMatrix3x4fv(location, false, arrayValue);
|
|
5225
|
+
case import_constants23.GL.FLOAT_MAT4x2:
|
|
5226
|
+
return gl22.uniformMatrix4x2fv(location, false, arrayValue);
|
|
5227
|
+
case import_constants23.GL.FLOAT_MAT4x3:
|
|
5228
|
+
return gl22.uniformMatrix4x3fv(location, false, arrayValue);
|
|
5238
5229
|
}
|
|
5239
5230
|
throw new Error("Illegal uniform");
|
|
5240
5231
|
}
|
|
5241
5232
|
|
|
5242
5233
|
// src/adapter/objects/webgl-vertex-array-object.ts
|
|
5243
5234
|
var import_api22 = require("@luma.gl/api");
|
|
5244
|
-
var import_constants24 =
|
|
5235
|
+
var import_constants24 = require("@luma.gl/constants");
|
|
5245
5236
|
var import_env = require("@probe.gl/env");
|
|
5246
5237
|
var ERR_ELEMENTS = "elements must be GL.ELEMENT_ARRAY_BUFFER";
|
|
5247
5238
|
var WEBGLVertexArrayObject = class extends WebGLResource {
|
|
@@ -5264,30 +5255,30 @@ var WEBGLVertexArrayObject = class extends WebGLResource {
|
|
|
5264
5255
|
// Set (bind) an elements buffer, for indexed rendering.
|
|
5265
5256
|
// Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported
|
|
5266
5257
|
setElementBuffer(elementBuffer = null, opts = {}) {
|
|
5267
|
-
(0, import_api22.assert)(!elementBuffer || elementBuffer.target === import_constants24.
|
|
5258
|
+
(0, import_api22.assert)(!elementBuffer || elementBuffer.target === import_constants24.GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);
|
|
5268
5259
|
this.bind(() => {
|
|
5269
|
-
this.gl.bindBuffer(import_constants24.
|
|
5260
|
+
this.gl.bindBuffer(import_constants24.GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);
|
|
5270
5261
|
});
|
|
5271
5262
|
return this;
|
|
5272
5263
|
}
|
|
5273
5264
|
/** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
|
|
5274
5265
|
setBuffer(location, buffer, accessor) {
|
|
5275
|
-
if (buffer.target === import_constants24.
|
|
5266
|
+
if (buffer.target === import_constants24.GL.ELEMENT_ARRAY_BUFFER) {
|
|
5276
5267
|
return this.setElementBuffer(buffer, accessor);
|
|
5277
5268
|
}
|
|
5278
5269
|
const { size, type, stride, offset, normalized, integer, divisor } = accessor;
|
|
5279
|
-
const { gl, gl2 } = this;
|
|
5270
|
+
const { gl: gl2, gl2: gl22 } = this;
|
|
5280
5271
|
location = Number(location);
|
|
5281
5272
|
this.bind(() => {
|
|
5282
|
-
|
|
5273
|
+
gl2.bindBuffer(gl2.ARRAY_BUFFER, buffer.handle);
|
|
5283
5274
|
if (integer) {
|
|
5284
5275
|
this.device.assertWebGL2();
|
|
5285
|
-
|
|
5276
|
+
gl22.vertexAttribIPointer(location, size, type, stride, offset);
|
|
5286
5277
|
} else {
|
|
5287
|
-
|
|
5278
|
+
gl2.vertexAttribPointer(location, size, type, normalized, stride, offset);
|
|
5288
5279
|
}
|
|
5289
|
-
|
|
5290
|
-
|
|
5280
|
+
gl2.enableVertexAttribArray(location);
|
|
5281
|
+
gl22.vertexAttribDivisor(location, divisor || 0);
|
|
5291
5282
|
});
|
|
5292
5283
|
return this;
|
|
5293
5284
|
}
|
|
@@ -5331,7 +5322,7 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5331
5322
|
this.device.setSpectorMetadata(this.handle, { id: this.props.id });
|
|
5332
5323
|
this.vs = (0, import_api23.cast)(props.vs);
|
|
5333
5324
|
this.fs = (0, import_api23.cast)(props.fs);
|
|
5334
|
-
const { varyings, bufferMode = import_constants25.
|
|
5325
|
+
const { varyings, bufferMode = import_constants25.GL.SEPARATE_ATTRIBS } = props;
|
|
5335
5326
|
if (varyings && varyings.length > 0) {
|
|
5336
5327
|
this.device.assertWebGL2();
|
|
5337
5328
|
this.varyings = varyings;
|
|
@@ -5428,7 +5419,7 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5428
5419
|
} = options;
|
|
5429
5420
|
const drawMode = getDrawMode(this.props.topology);
|
|
5430
5421
|
const isIndexed = Boolean(this._indexBuffer);
|
|
5431
|
-
const indexType = ((_a = this._indexBuffer) == null ? void 0 : _a.props.indexType) === "uint16" ? import_constants25.
|
|
5422
|
+
const indexType = ((_a = this._indexBuffer) == null ? void 0 : _a.props.indexType) === "uint16" ? import_constants25.GL.UNSIGNED_SHORT : import_constants25.GL.UNSIGNED_INT;
|
|
5432
5423
|
const isInstanced = Number(options.instanceCount) > 0;
|
|
5433
5424
|
if (!this._areTexturesRenderable() || options.vertexCount === 0) {
|
|
5434
5425
|
return false;
|
|
@@ -5473,21 +5464,21 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5473
5464
|
// setAttributes(attributes: Record<string, Buffer>): void {}
|
|
5474
5465
|
// setBindings(bindings: Record<string, Binding>): void {}
|
|
5475
5466
|
_compileAndLink() {
|
|
5476
|
-
const { gl } = this.device;
|
|
5477
|
-
|
|
5478
|
-
|
|
5467
|
+
const { gl: gl2 } = this.device;
|
|
5468
|
+
gl2.attachShader(this.handle, this.vs.handle);
|
|
5469
|
+
gl2.attachShader(this.handle, this.fs.handle);
|
|
5479
5470
|
import_api23.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
5480
|
-
|
|
5471
|
+
gl2.linkProgram(this.handle);
|
|
5481
5472
|
import_api23.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
5482
|
-
if (
|
|
5483
|
-
const linked =
|
|
5473
|
+
if (gl2.debug || import_api23.log.level > 0) {
|
|
5474
|
+
const linked = gl2.getProgramParameter(this.handle, gl2.LINK_STATUS);
|
|
5484
5475
|
if (!linked) {
|
|
5485
|
-
throw new Error(`Error linking: ${
|
|
5476
|
+
throw new Error(`Error linking: ${gl2.getProgramInfoLog(this.handle)}`);
|
|
5486
5477
|
}
|
|
5487
|
-
|
|
5488
|
-
const validated =
|
|
5478
|
+
gl2.validateProgram(this.handle);
|
|
5479
|
+
const validated = gl2.getProgramParameter(this.handle, gl2.VALIDATE_STATUS);
|
|
5489
5480
|
if (!validated) {
|
|
5490
|
-
throw new Error(`Error validating: ${
|
|
5481
|
+
throw new Error(`Error validating: ${gl2.getProgramInfoLog(this.handle)}`);
|
|
5491
5482
|
}
|
|
5492
5483
|
}
|
|
5493
5484
|
}
|
|
@@ -5528,15 +5519,15 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5528
5519
|
case "uniform":
|
|
5529
5520
|
const { name } = binding;
|
|
5530
5521
|
const location = gl2.getUniformBlockIndex(this.handle, name);
|
|
5531
|
-
if (location === import_constants25.
|
|
5522
|
+
if (location === import_constants25.GL.INVALID_INDEX) {
|
|
5532
5523
|
throw new Error(`Invalid uniform block name ${name}`);
|
|
5533
5524
|
}
|
|
5534
5525
|
gl2.uniformBlockBinding(this.handle, uniformBufferIndex, location);
|
|
5535
5526
|
if (value instanceof WEBGLBuffer) {
|
|
5536
|
-
gl2.bindBufferBase(import_constants25.
|
|
5527
|
+
gl2.bindBufferBase(import_constants25.GL.UNIFORM_BUFFER, uniformBufferIndex, value.handle);
|
|
5537
5528
|
} else {
|
|
5538
5529
|
gl2.bindBufferRange(
|
|
5539
|
-
import_constants25.
|
|
5530
|
+
import_constants25.GL.UNIFORM_BUFFER,
|
|
5540
5531
|
uniformBufferIndex,
|
|
5541
5532
|
value.buffer.handle,
|
|
5542
5533
|
value.offset || 0,
|
|
@@ -5550,7 +5541,7 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5550
5541
|
throw new Error("texture");
|
|
5551
5542
|
}
|
|
5552
5543
|
const texture = value;
|
|
5553
|
-
gl2.activeTexture(import_constants25.
|
|
5544
|
+
gl2.activeTexture(import_constants25.GL.TEXTURE0 + textureUnit);
|
|
5554
5545
|
gl2.bindTexture(texture.target, texture.handle);
|
|
5555
5546
|
textureUnit += 1;
|
|
5556
5547
|
break;
|
|
@@ -5576,19 +5567,19 @@ var WEBGLRenderPipeline = class extends import_api23.RenderPipeline {
|
|
|
5576
5567
|
function getDrawMode(topology) {
|
|
5577
5568
|
switch (topology) {
|
|
5578
5569
|
case "point-list":
|
|
5579
|
-
return import_constants25.
|
|
5570
|
+
return import_constants25.GL.POINTS;
|
|
5580
5571
|
case "line-list":
|
|
5581
|
-
return import_constants25.
|
|
5572
|
+
return import_constants25.GL.LINES;
|
|
5582
5573
|
case "line-strip":
|
|
5583
|
-
return import_constants25.
|
|
5574
|
+
return import_constants25.GL.LINE_STRIP;
|
|
5584
5575
|
case "line-loop":
|
|
5585
|
-
return import_constants25.
|
|
5576
|
+
return import_constants25.GL.LINE_LOOP;
|
|
5586
5577
|
case "triangle-list":
|
|
5587
|
-
return import_constants25.
|
|
5578
|
+
return import_constants25.GL.TRIANGLES;
|
|
5588
5579
|
case "triangle-strip":
|
|
5589
|
-
return import_constants25.
|
|
5580
|
+
return import_constants25.GL.TRIANGLE_STRIP;
|
|
5590
5581
|
case "triangle-fan":
|
|
5591
|
-
return import_constants25.
|
|
5582
|
+
return import_constants25.GL.TRIANGLE_FAN;
|
|
5592
5583
|
default:
|
|
5593
5584
|
throw new Error(topology);
|
|
5594
5585
|
}
|
|
@@ -5596,19 +5587,19 @@ function getDrawMode(topology) {
|
|
|
5596
5587
|
function getGLPrimitive(topology) {
|
|
5597
5588
|
switch (topology) {
|
|
5598
5589
|
case "point-list":
|
|
5599
|
-
return import_constants25.
|
|
5590
|
+
return import_constants25.GL.POINTS;
|
|
5600
5591
|
case "line-list":
|
|
5601
|
-
return import_constants25.
|
|
5592
|
+
return import_constants25.GL.LINES;
|
|
5602
5593
|
case "line-strip":
|
|
5603
|
-
return import_constants25.
|
|
5594
|
+
return import_constants25.GL.LINES;
|
|
5604
5595
|
case "line-loop":
|
|
5605
|
-
return import_constants25.
|
|
5596
|
+
return import_constants25.GL.LINES;
|
|
5606
5597
|
case "triangle-list":
|
|
5607
|
-
return import_constants25.
|
|
5598
|
+
return import_constants25.GL.TRIANGLES;
|
|
5608
5599
|
case "triangle-strip":
|
|
5609
|
-
return import_constants25.
|
|
5600
|
+
return import_constants25.GL.TRIANGLES;
|
|
5610
5601
|
case "triangle-fan":
|
|
5611
|
-
return import_constants25.
|
|
5602
|
+
return import_constants25.GL.TRIANGLES;
|
|
5612
5603
|
default:
|
|
5613
5604
|
throw new Error(topology);
|
|
5614
5605
|
}
|
|
@@ -5622,7 +5613,7 @@ var import_api25 = require("@luma.gl/api");
|
|
|
5622
5613
|
|
|
5623
5614
|
// src/adapter/resources/webgl-command-buffer.ts
|
|
5624
5615
|
var import_api24 = require("@luma.gl/api");
|
|
5625
|
-
var import_constants26 =
|
|
5616
|
+
var import_constants26 = require("@luma.gl/constants");
|
|
5626
5617
|
function cast3(value) {
|
|
5627
5618
|
return value;
|
|
5628
5619
|
}
|
|
@@ -5657,17 +5648,17 @@ function _copyBufferToBuffer(device, options) {
|
|
|
5657
5648
|
const destination = cast3(options.destination);
|
|
5658
5649
|
const gl2 = device.assertWebGL2();
|
|
5659
5650
|
if (gl2) {
|
|
5660
|
-
gl2.bindBuffer(import_constants26.
|
|
5661
|
-
gl2.bindBuffer(import_constants26.
|
|
5651
|
+
gl2.bindBuffer(import_constants26.GL.COPY_READ_BUFFER, source.handle);
|
|
5652
|
+
gl2.bindBuffer(import_constants26.GL.COPY_WRITE_BUFFER, destination.handle);
|
|
5662
5653
|
gl2.copyBufferSubData(
|
|
5663
|
-
import_constants26.
|
|
5664
|
-
import_constants26.
|
|
5654
|
+
import_constants26.GL.COPY_READ_BUFFER,
|
|
5655
|
+
import_constants26.GL.COPY_WRITE_BUFFER,
|
|
5665
5656
|
(_a = options.sourceOffset) != null ? _a : 0,
|
|
5666
5657
|
(_b = options.destinationOffset) != null ? _b : 0,
|
|
5667
5658
|
options.size
|
|
5668
5659
|
);
|
|
5669
|
-
gl2.bindBuffer(import_constants26.
|
|
5670
|
-
gl2.bindBuffer(import_constants26.
|
|
5660
|
+
gl2.bindBuffer(import_constants26.GL.COPY_READ_BUFFER, null);
|
|
5661
|
+
gl2.bindBuffer(import_constants26.GL.COPY_WRITE_BUFFER, null);
|
|
5671
5662
|
} else {
|
|
5672
5663
|
throw new Error("copyBufferToBuffer not implemented in WebGL1");
|
|
5673
5664
|
}
|
|
@@ -5718,10 +5709,10 @@ function _copyTextureToBuffer(device, options) {
|
|
|
5718
5709
|
const webglBuffer = destination;
|
|
5719
5710
|
const sourceWidth = width || framebuffer.width;
|
|
5720
5711
|
const sourceHeight = height || framebuffer.height;
|
|
5721
|
-
const sourceFormat = import_constants26.
|
|
5722
|
-
const sourceType = import_constants26.
|
|
5723
|
-
gl2.bindBuffer(import_constants26.
|
|
5724
|
-
gl2.bindFramebuffer(import_constants26.
|
|
5712
|
+
const sourceFormat = import_constants26.GL.RGBA;
|
|
5713
|
+
const sourceType = import_constants26.GL.UNSIGNED_BYTE;
|
|
5714
|
+
gl2.bindBuffer(import_constants26.GL.PIXEL_PACK_BUFFER, webglBuffer.handle);
|
|
5715
|
+
gl2.bindFramebuffer(import_constants26.GL.FRAMEBUFFER, framebuffer.handle);
|
|
5725
5716
|
gl2.readPixels(
|
|
5726
5717
|
origin[0],
|
|
5727
5718
|
origin[1],
|
|
@@ -5732,8 +5723,8 @@ function _copyTextureToBuffer(device, options) {
|
|
|
5732
5723
|
byteOffset
|
|
5733
5724
|
);
|
|
5734
5725
|
} finally {
|
|
5735
|
-
gl2.bindBuffer(import_constants26.
|
|
5736
|
-
gl2.bindFramebuffer(import_constants26.
|
|
5726
|
+
gl2.bindBuffer(import_constants26.GL.PIXEL_PACK_BUFFER, null);
|
|
5727
|
+
gl2.bindFramebuffer(import_constants26.GL.FRAMEBUFFER, null);
|
|
5737
5728
|
if (destroyFramebuffer) {
|
|
5738
5729
|
framebuffer.destroy();
|
|
5739
5730
|
}
|
|
@@ -5764,11 +5755,11 @@ function _copyTextureToTexture(device, options) {
|
|
|
5764
5755
|
// depthOrArrayLayers = 0
|
|
5765
5756
|
} = options;
|
|
5766
5757
|
const destinationMipmaplevel = 0;
|
|
5767
|
-
const destinationInternalFormat = import_constants26.
|
|
5758
|
+
const destinationInternalFormat = import_constants26.GL.RGBA;
|
|
5768
5759
|
const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
|
|
5769
5760
|
const [sourceX, sourceY] = origin;
|
|
5770
5761
|
const isSubCopy = false;
|
|
5771
|
-
device.gl.bindFramebuffer(import_constants26.
|
|
5762
|
+
device.gl.bindFramebuffer(import_constants26.GL.FRAMEBUFFER, framebuffer.handle);
|
|
5772
5763
|
let texture = null;
|
|
5773
5764
|
let textureTarget;
|
|
5774
5765
|
if (destination instanceof WEBGLTexture) {
|
|
@@ -5797,7 +5788,7 @@ function _copyTextureToTexture(device, options) {
|
|
|
5797
5788
|
if (texture) {
|
|
5798
5789
|
texture.unbind();
|
|
5799
5790
|
}
|
|
5800
|
-
device.gl.bindFramebuffer(import_constants26.
|
|
5791
|
+
device.gl.bindFramebuffer(import_constants26.GL.FRAMEBUFFER, prevHandle || null);
|
|
5801
5792
|
if (destroyFramebuffer) {
|
|
5802
5793
|
framebuffer.destroy();
|
|
5803
5794
|
}
|
|
@@ -5893,13 +5884,13 @@ var _WebGLDevice = class extends import_api26.Device {
|
|
|
5893
5884
|
message: "Computer entered sleep mode, or too many apps or browser tabs are using the GPU."
|
|
5894
5885
|
});
|
|
5895
5886
|
};
|
|
5896
|
-
let
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
if (!
|
|
5887
|
+
let gl2 = props.gl || null;
|
|
5888
|
+
gl2 = gl2 || ((0, import_env2.isBrowser)() ? createBrowserContext(this.canvasContext.canvas, __spreadProps(__spreadValues({}, props), { onContextLost })) : null);
|
|
5889
|
+
gl2 = gl2 || (!(0, import_env2.isBrowser)() ? createHeadlessContext(__spreadProps(__spreadValues({}, props), { onContextLost })) : null);
|
|
5890
|
+
if (!gl2) {
|
|
5900
5891
|
throw new Error("WebGL context creation failed");
|
|
5901
5892
|
}
|
|
5902
|
-
this.handle =
|
|
5893
|
+
this.handle = gl2;
|
|
5903
5894
|
this.gl = this.handle;
|
|
5904
5895
|
this.gl2 = this.gl;
|
|
5905
5896
|
this.isWebGL2 = isWebGL22(this.gl);
|
|
@@ -5949,17 +5940,17 @@ var _WebGLDevice = class extends import_api26.Device {
|
|
|
5949
5940
|
* @param gl
|
|
5950
5941
|
* @returns
|
|
5951
5942
|
*/
|
|
5952
|
-
static attach(
|
|
5953
|
-
if (
|
|
5954
|
-
return
|
|
5943
|
+
static attach(gl2) {
|
|
5944
|
+
if (gl2 instanceof _WebGLDevice) {
|
|
5945
|
+
return gl2;
|
|
5955
5946
|
}
|
|
5956
|
-
if ((
|
|
5957
|
-
return
|
|
5947
|
+
if ((gl2 == null ? void 0 : gl2.device) instanceof import_api26.Device) {
|
|
5948
|
+
return gl2.device;
|
|
5958
5949
|
}
|
|
5959
|
-
if (!isWebGL3(
|
|
5950
|
+
if (!isWebGL3(gl2)) {
|
|
5960
5951
|
throw new Error("Invalid WebGLRenderingContext");
|
|
5961
5952
|
}
|
|
5962
|
-
return new _WebGLDevice({ gl });
|
|
5953
|
+
return new _WebGLDevice({ gl: gl2 });
|
|
5963
5954
|
}
|
|
5964
5955
|
static create() {
|
|
5965
5956
|
return __async(this, arguments, function* (props = {}) {
|
|
@@ -6019,7 +6010,7 @@ var _WebGLDevice = class extends import_api26.Device {
|
|
|
6019
6010
|
}
|
|
6020
6011
|
createBuffer(props) {
|
|
6021
6012
|
const newProps = this._getBufferProps(props);
|
|
6022
|
-
return new
|
|
6013
|
+
return new BufferWithAccessor(this, newProps);
|
|
6023
6014
|
}
|
|
6024
6015
|
_createTexture(props) {
|
|
6025
6016
|
return new WEBGLTexture(this, props);
|
|
@@ -6110,11 +6101,11 @@ var _WebGLDevice = class extends import_api26.Device {
|
|
|
6110
6101
|
* Be aware that there are some duplicates especially for constants that are 0,
|
|
6111
6102
|
* so this isn't guaranteed to return the right key in all cases.
|
|
6112
6103
|
*/
|
|
6113
|
-
getGLKey(value,
|
|
6114
|
-
|
|
6104
|
+
getGLKey(value, gl2) {
|
|
6105
|
+
gl2 = gl2 || this.gl2 || this.gl;
|
|
6115
6106
|
const number = Number(value);
|
|
6116
|
-
for (const key in
|
|
6117
|
-
if (
|
|
6107
|
+
for (const key in gl2) {
|
|
6108
|
+
if (gl2[key] === number) {
|
|
6118
6109
|
return `GL.${key}`;
|
|
6119
6110
|
}
|
|
6120
6111
|
}
|
|
@@ -6126,20 +6117,20 @@ var WebGLDevice = _WebGLDevice;
|
|
|
6126
6117
|
// Public `Device` API
|
|
6127
6118
|
//
|
|
6128
6119
|
WebGLDevice.type = "webgl";
|
|
6129
|
-
function isWebGL3(
|
|
6130
|
-
if (typeof WebGLRenderingContext !== "undefined" &&
|
|
6120
|
+
function isWebGL3(gl2) {
|
|
6121
|
+
if (typeof WebGLRenderingContext !== "undefined" && gl2 instanceof WebGLRenderingContext) {
|
|
6131
6122
|
return true;
|
|
6132
6123
|
}
|
|
6133
|
-
if (typeof WebGL2RenderingContext !== "undefined" &&
|
|
6124
|
+
if (typeof WebGL2RenderingContext !== "undefined" && gl2 instanceof WebGL2RenderingContext) {
|
|
6134
6125
|
return true;
|
|
6135
6126
|
}
|
|
6136
|
-
return Boolean(
|
|
6127
|
+
return Boolean(gl2 && Number.isFinite(gl2._version));
|
|
6137
6128
|
}
|
|
6138
|
-
function isWebGL22(
|
|
6139
|
-
if (typeof WebGL2RenderingContext !== "undefined" &&
|
|
6129
|
+
function isWebGL22(gl2) {
|
|
6130
|
+
if (typeof WebGL2RenderingContext !== "undefined" && gl2 instanceof WebGL2RenderingContext) {
|
|
6140
6131
|
return true;
|
|
6141
6132
|
}
|
|
6142
|
-
return Boolean(
|
|
6133
|
+
return Boolean(gl2 && gl2._version === 2);
|
|
6143
6134
|
}
|
|
6144
6135
|
|
|
6145
6136
|
// src/classic/clear.ts
|
|
@@ -6148,8 +6139,8 @@ var GL_DEPTH_BUFFER_BIT2 = 256;
|
|
|
6148
6139
|
var GL_STENCIL_BUFFER_BIT2 = 1024;
|
|
6149
6140
|
var GL_COLOR_BUFFER_BIT2 = 16384;
|
|
6150
6141
|
var ERR_ARGUMENTS = "clear: bad arguments";
|
|
6151
|
-
function clear(
|
|
6152
|
-
const device = WebGLDevice.attach(
|
|
6142
|
+
function clear(gl2, options) {
|
|
6143
|
+
const device = WebGLDevice.attach(gl2);
|
|
6153
6144
|
const { framebuffer = null, color = null, depth = null, stencil = null } = options || {};
|
|
6154
6145
|
const parameters = {};
|
|
6155
6146
|
if (framebuffer) {
|
|
@@ -6182,25 +6173,25 @@ function clear(gl, options) {
|
|
|
6182
6173
|
|
|
6183
6174
|
// src/classic/copy-and-blit.ts
|
|
6184
6175
|
var import_api29 = require("@luma.gl/api");
|
|
6185
|
-
var import_constants28 =
|
|
6176
|
+
var import_constants28 = require("@luma.gl/constants");
|
|
6186
6177
|
|
|
6187
6178
|
// src/classic/format-utils.ts
|
|
6188
6179
|
var import_api28 = require("@luma.gl/api");
|
|
6189
|
-
var import_constants27 =
|
|
6180
|
+
var import_constants27 = require("@luma.gl/constants");
|
|
6190
6181
|
function glFormatToComponents(format) {
|
|
6191
6182
|
switch (format) {
|
|
6192
|
-
case import_constants27.
|
|
6193
|
-
case import_constants27.
|
|
6194
|
-
case import_constants27.
|
|
6183
|
+
case import_constants27.GL.ALPHA:
|
|
6184
|
+
case import_constants27.GL.R32F:
|
|
6185
|
+
case import_constants27.GL.RED:
|
|
6195
6186
|
return 1;
|
|
6196
|
-
case import_constants27.
|
|
6197
|
-
case import_constants27.
|
|
6187
|
+
case import_constants27.GL.RG32F:
|
|
6188
|
+
case import_constants27.GL.RG:
|
|
6198
6189
|
return 2;
|
|
6199
|
-
case import_constants27.
|
|
6200
|
-
case import_constants27.
|
|
6190
|
+
case import_constants27.GL.RGB:
|
|
6191
|
+
case import_constants27.GL.RGB32F:
|
|
6201
6192
|
return 3;
|
|
6202
|
-
case import_constants27.
|
|
6203
|
-
case import_constants27.
|
|
6193
|
+
case import_constants27.GL.RGBA:
|
|
6194
|
+
case import_constants27.GL.RGBA32F:
|
|
6204
6195
|
return 4;
|
|
6205
6196
|
default:
|
|
6206
6197
|
(0, import_api28.assert)(false);
|
|
@@ -6209,13 +6200,13 @@ function glFormatToComponents(format) {
|
|
|
6209
6200
|
}
|
|
6210
6201
|
function glTypeToBytes(type) {
|
|
6211
6202
|
switch (type) {
|
|
6212
|
-
case import_constants27.
|
|
6203
|
+
case import_constants27.GL.UNSIGNED_BYTE:
|
|
6213
6204
|
return 1;
|
|
6214
|
-
case import_constants27.
|
|
6215
|
-
case import_constants27.
|
|
6216
|
-
case import_constants27.
|
|
6205
|
+
case import_constants27.GL.UNSIGNED_SHORT_5_6_5:
|
|
6206
|
+
case import_constants27.GL.UNSIGNED_SHORT_4_4_4_4:
|
|
6207
|
+
case import_constants27.GL.UNSIGNED_SHORT_5_5_5_1:
|
|
6217
6208
|
return 2;
|
|
6218
|
-
case import_constants27.
|
|
6209
|
+
case import_constants27.GL.FLOAT:
|
|
6219
6210
|
return 4;
|
|
6220
6211
|
default:
|
|
6221
6212
|
(0, import_api28.assert)(false);
|
|
@@ -6225,9 +6216,9 @@ function glTypeToBytes(type) {
|
|
|
6225
6216
|
|
|
6226
6217
|
// src/classic/copy-and-blit.ts
|
|
6227
6218
|
function readPixelsToArray(source, options) {
|
|
6228
|
-
const { sourceX = 0, sourceY = 0, sourceFormat = import_constants28.
|
|
6219
|
+
const { sourceX = 0, sourceY = 0, sourceFormat = import_constants28.GL.RGBA } = options || {};
|
|
6229
6220
|
let {
|
|
6230
|
-
sourceAttachment = import_constants28.
|
|
6221
|
+
sourceAttachment = import_constants28.GL.COLOR_ATTACHMENT0,
|
|
6231
6222
|
// TODO - support gl.readBuffer
|
|
6232
6223
|
target = null,
|
|
6233
6224
|
// following parameters are auto deduced if not provided
|
|
@@ -6237,26 +6228,26 @@ function readPixelsToArray(source, options) {
|
|
|
6237
6228
|
} = options || {};
|
|
6238
6229
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
6239
6230
|
(0, import_api29.assert)(framebuffer);
|
|
6240
|
-
const { gl, handle } = framebuffer;
|
|
6231
|
+
const { gl: gl2, handle } = framebuffer;
|
|
6241
6232
|
sourceWidth = sourceWidth || framebuffer.width;
|
|
6242
6233
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
6243
|
-
if (sourceAttachment === import_constants28.
|
|
6244
|
-
sourceAttachment = import_constants28.
|
|
6234
|
+
if (sourceAttachment === import_constants28.GL.COLOR_ATTACHMENT0 && handle === null) {
|
|
6235
|
+
sourceAttachment = import_constants28.GL.FRONT;
|
|
6245
6236
|
}
|
|
6246
|
-
const attachment = sourceAttachment - import_constants28.
|
|
6237
|
+
const attachment = sourceAttachment - import_constants28.GL.COLOR_ATTACHMENT0;
|
|
6247
6238
|
sourceType = sourceType || framebuffer.colorAttachments[attachment].type;
|
|
6248
6239
|
target = getPixelArray(target, sourceType, sourceFormat, sourceWidth, sourceHeight);
|
|
6249
6240
|
sourceType = sourceType || getGLTypeFromTypedArray(target);
|
|
6250
|
-
const prevHandle2 =
|
|
6251
|
-
|
|
6252
|
-
|
|
6241
|
+
const prevHandle2 = gl2.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, handle);
|
|
6242
|
+
gl2.readPixels(sourceX, sourceY, sourceWidth, sourceHeight, sourceFormat, sourceType, target);
|
|
6243
|
+
gl2.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, prevHandle2 || null);
|
|
6253
6244
|
if (deleteFramebuffer) {
|
|
6254
6245
|
framebuffer.destroy();
|
|
6255
6246
|
}
|
|
6256
6247
|
return target;
|
|
6257
6248
|
}
|
|
6258
6249
|
function readPixelsToBuffer(source, options) {
|
|
6259
|
-
const { sourceX = 0, sourceY = 0, sourceFormat = import_constants28.
|
|
6250
|
+
const { sourceX = 0, sourceY = 0, sourceFormat = import_constants28.GL.RGBA, targetByteOffset = 0 } = options || {};
|
|
6260
6251
|
let { target, sourceWidth, sourceHeight, sourceType } = options || {};
|
|
6261
6252
|
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
6262
6253
|
(0, import_api29.assert)(framebuffer);
|
|
@@ -6264,14 +6255,14 @@ function readPixelsToBuffer(source, options) {
|
|
|
6264
6255
|
sourceHeight = sourceHeight || framebuffer.height;
|
|
6265
6256
|
const webglFramebuffer = framebuffer;
|
|
6266
6257
|
const gl2 = webglFramebuffer.device.assertWebGL2();
|
|
6267
|
-
sourceType = sourceType || (target ? target.type : import_constants28.
|
|
6258
|
+
sourceType = sourceType || (target ? target.type : import_constants28.GL.UNSIGNED_BYTE);
|
|
6268
6259
|
if (!target) {
|
|
6269
6260
|
const components = glFormatToComponents(sourceFormat);
|
|
6270
6261
|
const byteCount = glTypeToBytes(sourceType);
|
|
6271
6262
|
const byteLength = targetByteOffset + sourceWidth * sourceHeight * components * byteCount;
|
|
6272
|
-
target = new
|
|
6263
|
+
target = new BufferWithAccessor(gl2, { byteLength, accessor: { type: sourceType, size: components } });
|
|
6273
6264
|
}
|
|
6274
|
-
target.bind({ target: import_constants28.
|
|
6265
|
+
target.bind({ target: import_constants28.GL.PIXEL_PACK_BUFFER });
|
|
6275
6266
|
withParameters(gl2, { framebuffer }, () => {
|
|
6276
6267
|
gl2.readPixels(
|
|
6277
6268
|
sourceX,
|
|
@@ -6283,12 +6274,104 @@ function readPixelsToBuffer(source, options) {
|
|
|
6283
6274
|
targetByteOffset
|
|
6284
6275
|
);
|
|
6285
6276
|
});
|
|
6286
|
-
target.unbind({ target: import_constants28.
|
|
6277
|
+
target.unbind({ target: import_constants28.GL.PIXEL_PACK_BUFFER });
|
|
6287
6278
|
if (deleteFramebuffer) {
|
|
6288
6279
|
framebuffer.destroy();
|
|
6289
6280
|
}
|
|
6290
6281
|
return target;
|
|
6291
6282
|
}
|
|
6283
|
+
function copyToTexture(source, target, options) {
|
|
6284
|
+
const {
|
|
6285
|
+
sourceX = 0,
|
|
6286
|
+
sourceY = 0,
|
|
6287
|
+
// attachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer
|
|
6288
|
+
targetMipmaplevel = 0,
|
|
6289
|
+
targetInternalFormat = import_constants28.GL.RGBA
|
|
6290
|
+
} = options || {};
|
|
6291
|
+
let {
|
|
6292
|
+
targetX,
|
|
6293
|
+
targetY,
|
|
6294
|
+
targetZ,
|
|
6295
|
+
width,
|
|
6296
|
+
// defaults to target width
|
|
6297
|
+
height
|
|
6298
|
+
// defaults to target height
|
|
6299
|
+
} = options || {};
|
|
6300
|
+
const { framebuffer, deleteFramebuffer } = getFramebuffer2(source);
|
|
6301
|
+
(0, import_api29.assert)(framebuffer);
|
|
6302
|
+
const webglFramebuffer = framebuffer;
|
|
6303
|
+
const { device, handle } = webglFramebuffer;
|
|
6304
|
+
const isSubCopy = typeof targetX !== "undefined" || typeof targetY !== "undefined" || typeof targetZ !== "undefined";
|
|
6305
|
+
targetX = targetX || 0;
|
|
6306
|
+
targetY = targetY || 0;
|
|
6307
|
+
targetZ = targetZ || 0;
|
|
6308
|
+
const prevHandle2 = device.gl.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, handle);
|
|
6309
|
+
(0, import_api29.assert)(target);
|
|
6310
|
+
let texture = null;
|
|
6311
|
+
let textureTarget;
|
|
6312
|
+
if (target instanceof import_api29.Texture) {
|
|
6313
|
+
texture = target;
|
|
6314
|
+
width = Number.isFinite(width) ? width : texture.width;
|
|
6315
|
+
height = Number.isFinite(height) ? height : texture.height;
|
|
6316
|
+
texture.bind(0);
|
|
6317
|
+
textureTarget = texture.target;
|
|
6318
|
+
} else {
|
|
6319
|
+
textureTarget = target;
|
|
6320
|
+
}
|
|
6321
|
+
if (!isSubCopy) {
|
|
6322
|
+
device.gl.copyTexImage2D(
|
|
6323
|
+
textureTarget,
|
|
6324
|
+
targetMipmaplevel,
|
|
6325
|
+
targetInternalFormat,
|
|
6326
|
+
sourceX,
|
|
6327
|
+
sourceY,
|
|
6328
|
+
width,
|
|
6329
|
+
height,
|
|
6330
|
+
0
|
|
6331
|
+
/* border must be 0 */
|
|
6332
|
+
);
|
|
6333
|
+
} else {
|
|
6334
|
+
switch (textureTarget) {
|
|
6335
|
+
case import_constants28.GL.TEXTURE_2D:
|
|
6336
|
+
case import_constants28.GL.TEXTURE_CUBE_MAP:
|
|
6337
|
+
device.gl.copyTexSubImage2D(
|
|
6338
|
+
textureTarget,
|
|
6339
|
+
targetMipmaplevel,
|
|
6340
|
+
targetX,
|
|
6341
|
+
targetY,
|
|
6342
|
+
sourceX,
|
|
6343
|
+
sourceY,
|
|
6344
|
+
width,
|
|
6345
|
+
height
|
|
6346
|
+
);
|
|
6347
|
+
break;
|
|
6348
|
+
case import_constants28.GL.TEXTURE_2D_ARRAY:
|
|
6349
|
+
case import_constants28.GL.TEXTURE_3D:
|
|
6350
|
+
device.assertWebGL2();
|
|
6351
|
+
device.gl2.copyTexSubImage3D(
|
|
6352
|
+
textureTarget,
|
|
6353
|
+
targetMipmaplevel,
|
|
6354
|
+
targetX,
|
|
6355
|
+
targetY,
|
|
6356
|
+
targetZ,
|
|
6357
|
+
sourceX,
|
|
6358
|
+
sourceY,
|
|
6359
|
+
width,
|
|
6360
|
+
height
|
|
6361
|
+
);
|
|
6362
|
+
break;
|
|
6363
|
+
default:
|
|
6364
|
+
}
|
|
6365
|
+
}
|
|
6366
|
+
if (texture) {
|
|
6367
|
+
texture.unbind();
|
|
6368
|
+
}
|
|
6369
|
+
gl.bindFramebuffer(import_constants28.GL.FRAMEBUFFER, prevHandle2 || null);
|
|
6370
|
+
if (deleteFramebuffer) {
|
|
6371
|
+
framebuffer.destroy();
|
|
6372
|
+
}
|
|
6373
|
+
return texture;
|
|
6374
|
+
}
|
|
6292
6375
|
function getFramebuffer2(source) {
|
|
6293
6376
|
if (!(source instanceof import_api29.Framebuffer)) {
|
|
6294
6377
|
return { framebuffer: toFramebuffer(source), deleteFramebuffer: true };
|
|
@@ -6313,7 +6396,7 @@ function getPixelArray(pixelArray, type, format, width, height) {
|
|
|
6313
6396
|
if (pixelArray) {
|
|
6314
6397
|
return pixelArray;
|
|
6315
6398
|
}
|
|
6316
|
-
type = type || import_constants28.
|
|
6399
|
+
type = type || import_constants28.GL.UNSIGNED_BYTE;
|
|
6317
6400
|
const ArrayType = getTypedArrayFromGLType(type, { clamped: false });
|
|
6318
6401
|
const components = glFormatToComponents(format);
|
|
6319
6402
|
return new ArrayType(width * height * components);
|