@luma.gl/webgl 9.0.0-alpha.30 → 9.0.0-alpha.32
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/shader-formats.d.ts +9 -0
- package/dist/adapter/converters/shader-formats.d.ts.map +1 -0
- package/dist/adapter/converters/shader-formats.js +53 -0
- package/dist/adapter/converters/shader-formats.js.map +1 -0
- package/dist/adapter/converters/texture-formats.d.ts +1 -2
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +2 -23
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts +8 -2
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +47 -9
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/helpers/{uniforms.d.ts → decode-webgl-types.d.ts} +9 -8
- package/dist/adapter/helpers/decode-webgl-types.d.ts.map +1 -0
- package/dist/adapter/helpers/{uniforms.js → decode-webgl-types.js} +14 -13
- package/dist/adapter/helpers/decode-webgl-types.js.map +1 -0
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -51
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +14 -86
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/set-uniform.d.ts +3 -2
- package/dist/adapter/helpers/set-uniform.d.ts.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +25 -25
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/helpers/{attribute-utils.d.ts → webgl-topology-utils.d.ts} +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.d.ts.map +1 -0
- package/dist/adapter/helpers/{attribute-utils.js → webgl-topology-utils.js} +1 -1
- package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -0
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts +2 -1
- package/dist/adapter/objects/webgl-vertex-array-object.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +16 -10
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +58 -59
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/classic/buffer-with-accessor.d.ts +0 -1
- package/dist/classic/buffer-with-accessor.d.ts.map +1 -1
- package/dist/classic/buffer-with-accessor.js +0 -1
- package/dist/classic/buffer-with-accessor.js.map +1 -1
- package/dist/dist.dev.js +513 -418
- package/dist/index.cjs +670 -722
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist.min.js +22 -22
- package/package.json +5 -5
- package/src/adapter/converters/shader-formats.ts +41 -0
- package/src/adapter/converters/texture-formats.ts +3 -16
- package/src/adapter/converters/vertex-formats.ts +67 -10
- package/src/adapter/helpers/{uniforms.ts → decode-webgl-types.ts} +22 -17
- package/src/adapter/helpers/get-shader-layout.ts +51 -159
- package/src/adapter/helpers/set-uniform.ts +33 -33
- package/src/adapter/objects/webgl-vertex-array-object.ts +2 -1
- package/src/adapter/resources/webgl-command-encoder.ts +1 -1
- package/src/adapter/resources/webgl-render-pipeline.ts +125 -82
- package/src/classic/buffer-with-accessor.ts +0 -1
- package/src/index.ts +1 -1
- package/src/types.ts +2 -0
- package/dist/adapter/helpers/attribute-utils.d.ts.map +0 -1
- package/dist/adapter/helpers/attribute-utils.js.map +0 -1
- package/dist/adapter/helpers/uniforms.d.ts.map +0 -1
- package/dist/adapter/helpers/uniforms.js.map +0 -1
- /package/src/adapter/helpers/{attribute-utils.ts → webgl-topology-utils.ts} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -20,8 +20,8 @@ var __spreadValues = (a, b) => {
|
|
|
20
20
|
};
|
|
21
21
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
22
|
var __export = (target, all) => {
|
|
23
|
-
for (var
|
|
24
|
-
__defProp(target,
|
|
23
|
+
for (var name2 in all)
|
|
24
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
25
25
|
};
|
|
26
26
|
var __copyProps = (to, from, except, desc) => {
|
|
27
27
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -84,7 +84,6 @@ __export(src_exports, {
|
|
|
84
84
|
getWebGL2Context: () => getWebGL2Context,
|
|
85
85
|
isWebGL: () => isWebGL,
|
|
86
86
|
isWebGL2: () => isWebGL2,
|
|
87
|
-
mergeShaderLayout: () => mergeShaderLayout,
|
|
88
87
|
polyfillContext: () => polyfillContext,
|
|
89
88
|
popContextState: () => popContextState,
|
|
90
89
|
pushContextState: () => pushContextState,
|
|
@@ -405,12 +404,12 @@ function polyfillVertexArrayObject(gl2) {
|
|
|
405
404
|
return list;
|
|
406
405
|
};
|
|
407
406
|
const original_getExtension = gl2.getExtension;
|
|
408
|
-
gl2.getExtension = function getExtension(
|
|
409
|
-
const ext = original_getExtension.call(this,
|
|
407
|
+
gl2.getExtension = function getExtension(name2) {
|
|
408
|
+
const ext = original_getExtension.call(this, name2);
|
|
410
409
|
if (ext) {
|
|
411
410
|
return ext;
|
|
412
411
|
}
|
|
413
|
-
if (
|
|
412
|
+
if (name2 !== "OES_vertex_array_object") {
|
|
414
413
|
return null;
|
|
415
414
|
}
|
|
416
415
|
if (!gl2.__OESVertexArrayObject) {
|
|
@@ -1358,7 +1357,7 @@ var GLState = class {
|
|
|
1358
1357
|
constructor(gl2, {
|
|
1359
1358
|
copyState = false,
|
|
1360
1359
|
// Copy cache from params (slow) or initialize from WebGL defaults (fast)
|
|
1361
|
-
log:
|
|
1360
|
+
log: log9 = () => {
|
|
1362
1361
|
}
|
|
1363
1362
|
// Logging function, called when gl parameter change calls are actually issued
|
|
1364
1363
|
} = {}) {
|
|
@@ -1367,7 +1366,7 @@ var GLState = class {
|
|
|
1367
1366
|
this.enable = true;
|
|
1368
1367
|
this.gl = gl2;
|
|
1369
1368
|
this.cache = copyState ? getParameters(gl2) : Object.assign({}, GL_PARAMETER_DEFAULTS);
|
|
1370
|
-
this.log =
|
|
1369
|
+
this.log = log9;
|
|
1371
1370
|
this._updateCache = this._updateCache.bind(this);
|
|
1372
1371
|
Object.seal(this);
|
|
1373
1372
|
}
|
|
@@ -1596,7 +1595,41 @@ function isOldIE(opts = {}) {
|
|
|
1596
1595
|
|
|
1597
1596
|
// src/adapter/converters/texture-formats.ts
|
|
1598
1597
|
var import_core5 = require("@luma.gl/core");
|
|
1598
|
+
var import_constants6 = require("@luma.gl/constants");
|
|
1599
|
+
|
|
1600
|
+
// src/adapter/converters/vertex-formats.ts
|
|
1599
1601
|
var import_constants5 = require("@luma.gl/constants");
|
|
1602
|
+
function getGLFromVertexType(dataType) {
|
|
1603
|
+
switch (dataType) {
|
|
1604
|
+
case "uint8":
|
|
1605
|
+
return import_constants5.GL.UNSIGNED_BYTE;
|
|
1606
|
+
case "sint8":
|
|
1607
|
+
return import_constants5.GL.BYTE;
|
|
1608
|
+
case "unorm8":
|
|
1609
|
+
return import_constants5.GL.UNSIGNED_BYTE;
|
|
1610
|
+
case "snorm8":
|
|
1611
|
+
return import_constants5.GL.BYTE;
|
|
1612
|
+
case "uint16":
|
|
1613
|
+
return import_constants5.GL.UNSIGNED_SHORT;
|
|
1614
|
+
case "sint16":
|
|
1615
|
+
return import_constants5.GL.SHORT;
|
|
1616
|
+
case "unorm16":
|
|
1617
|
+
return import_constants5.GL.UNSIGNED_SHORT;
|
|
1618
|
+
case "snorm16":
|
|
1619
|
+
return import_constants5.GL.SHORT;
|
|
1620
|
+
case "uint32":
|
|
1621
|
+
return import_constants5.GL.UNSIGNED_INT;
|
|
1622
|
+
case "sint32":
|
|
1623
|
+
return import_constants5.GL.INT;
|
|
1624
|
+
case "float16":
|
|
1625
|
+
return import_constants5.GL.HALF_FLOAT;
|
|
1626
|
+
case "float32":
|
|
1627
|
+
return import_constants5.GL.FLOAT;
|
|
1628
|
+
}
|
|
1629
|
+
throw new Error(String(dataType));
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
// src/adapter/converters/texture-formats.ts
|
|
1600
1633
|
var texture_compression_bc = "texture-compression-bc";
|
|
1601
1634
|
var texture_compression_astc = "texture-compression-astc";
|
|
1602
1635
|
var texture_compression_etc2 = "texture-compression-etc2";
|
|
@@ -1655,206 +1688,206 @@ var TEXTURE_FORMATS = {
|
|
|
1655
1688
|
// TODO - Fix bpp constants
|
|
1656
1689
|
// 'r8unorm-unsized': {gl: GL.LUMINANCE, b: 4, c: 2, bpp: 4},
|
|
1657
1690
|
"rgb8unorm-unsized": {
|
|
1658
|
-
gl:
|
|
1659
|
-
gl1:
|
|
1691
|
+
gl: import_constants6.GL.RGB,
|
|
1692
|
+
gl1: import_constants6.GL.RGB,
|
|
1660
1693
|
b: 4,
|
|
1661
1694
|
c: 2,
|
|
1662
1695
|
bpp: 4,
|
|
1663
|
-
dataFormat:
|
|
1664
|
-
types: [
|
|
1696
|
+
dataFormat: import_constants6.GL.RGB,
|
|
1697
|
+
types: [import_constants6.GL.UNSIGNED_BYTE, import_constants6.GL.UNSIGNED_SHORT_5_6_5]
|
|
1665
1698
|
},
|
|
1666
1699
|
"rgba8unorm-unsized": {
|
|
1667
|
-
gl:
|
|
1668
|
-
gl1:
|
|
1700
|
+
gl: import_constants6.GL.RGBA,
|
|
1701
|
+
gl1: import_constants6.GL.RGBA,
|
|
1669
1702
|
b: 4,
|
|
1670
1703
|
c: 2,
|
|
1671
1704
|
bpp: 4,
|
|
1672
|
-
dataFormat:
|
|
1673
|
-
types: [
|
|
1705
|
+
dataFormat: import_constants6.GL.RGBA,
|
|
1706
|
+
types: [import_constants6.GL.UNSIGNED_BYTE, import_constants6.GL.UNSIGNED_SHORT_4_4_4_4, import_constants6.GL.UNSIGNED_SHORT_5_5_5_1]
|
|
1674
1707
|
},
|
|
1675
1708
|
// 'rgb8unorm-srgb-unsized': {gl: GL.SRGB_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
1676
1709
|
// 'rgba8unorm-srgb-unsized': {gl: GL.SRGB_ALPHA_EXT, b: 4, c: 2, bpp: 4, gl1Ext: SRGB},
|
|
1677
1710
|
// 8-bit formats
|
|
1678
|
-
"r8unorm": { gl:
|
|
1679
|
-
"r8snorm": { gl:
|
|
1680
|
-
"r8uint": { gl:
|
|
1681
|
-
"r8sint": { gl:
|
|
1711
|
+
"r8unorm": { gl: import_constants6.GL.R8, b: 1, c: 1, renderbuffer: true },
|
|
1712
|
+
"r8snorm": { gl: import_constants6.GL.R8_SNORM, b: 1, c: 1 },
|
|
1713
|
+
"r8uint": { gl: import_constants6.GL.R8UI, b: 1, c: 1, renderbuffer: true },
|
|
1714
|
+
"r8sint": { gl: import_constants6.GL.R8I, b: 1, c: 1, renderbuffer: true },
|
|
1682
1715
|
// 16-bit formats
|
|
1683
|
-
"rg8unorm": { gl:
|
|
1684
|
-
"rg8snorm": { gl:
|
|
1685
|
-
"rg8uint": { gl:
|
|
1686
|
-
"rg8sint": { gl:
|
|
1687
|
-
"r16uint": { gl:
|
|
1688
|
-
"r16sint": { gl:
|
|
1689
|
-
"r16float": { gl:
|
|
1690
|
-
"r16unorm-webgl": { gl:
|
|
1691
|
-
"r16snorm-webgl": { gl:
|
|
1716
|
+
"rg8unorm": { gl: import_constants6.GL.RG8, b: 2, c: 2, renderbuffer: true },
|
|
1717
|
+
"rg8snorm": { gl: import_constants6.GL.RG8_SNORM, b: 2, c: 2 },
|
|
1718
|
+
"rg8uint": { gl: import_constants6.GL.RG8UI, b: 2, c: 2, renderbuffer: true },
|
|
1719
|
+
"rg8sint": { gl: import_constants6.GL.RG8I, b: 2, c: 2, renderbuffer: true },
|
|
1720
|
+
"r16uint": { gl: import_constants6.GL.R16UI, b: 2, c: 1, renderbuffer: true },
|
|
1721
|
+
"r16sint": { gl: import_constants6.GL.R16I, b: 2, c: 1, renderbuffer: true },
|
|
1722
|
+
"r16float": { gl: import_constants6.GL.R16F, b: 2, c: 1, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl", renderbuffer: true },
|
|
1723
|
+
"r16unorm-webgl": { gl: import_constants6.GL.R16_EXT, b: 2, c: 1, f: "texture-formats-norm16-webgl", renderbuffer: true, x: EXT_TEXTURE_NORM16 },
|
|
1724
|
+
"r16snorm-webgl": { gl: import_constants6.GL.R16_SNORM_EXT, b: 2, c: 1, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
|
|
1692
1725
|
// Packed 16-bit formats
|
|
1693
|
-
"rgba4unorm-webgl": { gl:
|
|
1694
|
-
"rgb565unorm-webgl": { gl:
|
|
1695
|
-
"rgb5a1unorm-webgl": { gl:
|
|
1726
|
+
"rgba4unorm-webgl": { gl: import_constants6.GL.RGBA4, b: 2, c: 4, wgpu: false, renderbuffer: true },
|
|
1727
|
+
"rgb565unorm-webgl": { gl: import_constants6.GL.RGB565, b: 2, c: 4, wgpu: false, renderbuffer: true },
|
|
1728
|
+
"rgb5a1unorm-webgl": { gl: import_constants6.GL.RGB5_A1, b: 2, c: 4, wgpu: false, renderbuffer: true },
|
|
1696
1729
|
// 24-bit formats
|
|
1697
|
-
"rgb8unorm-webgl": { gl:
|
|
1698
|
-
"rgb8snorm-webgl": { gl:
|
|
1730
|
+
"rgb8unorm-webgl": { gl: import_constants6.GL.RGB8, b: 3, c: 3, wgpu: false },
|
|
1731
|
+
"rgb8snorm-webgl": { gl: import_constants6.GL.RGB8_SNORM, b: 3, c: 3, wgpu: false },
|
|
1699
1732
|
// 32-bit formats
|
|
1700
|
-
"rgba8unorm": { gl:
|
|
1701
|
-
"rgba8unorm-srgb": { gl:
|
|
1702
|
-
"rgba8snorm": { gl:
|
|
1703
|
-
"rgba8uint": { gl:
|
|
1704
|
-
"rgba8sint": { gl:
|
|
1733
|
+
"rgba8unorm": { gl: import_constants6.GL.RGBA8, gl1: import_constants6.GL.RGBA, b: 4, c: 2, bpp: 4 },
|
|
1734
|
+
"rgba8unorm-srgb": { gl: import_constants6.GL.SRGB8_ALPHA8, gl1: import_constants6.GL.SRGB_ALPHA_EXT, b: 4, c: 4, gl1ext: EXT_SRGB, bpp: 4 },
|
|
1735
|
+
"rgba8snorm": { gl: import_constants6.GL.RGBA8_SNORM, b: 4, c: 4 },
|
|
1736
|
+
"rgba8uint": { gl: import_constants6.GL.RGBA8UI, b: 4, c: 4, bpp: 4 },
|
|
1737
|
+
"rgba8sint": { gl: import_constants6.GL.RGBA8I, b: 4, c: 4, bpp: 4 },
|
|
1705
1738
|
// reverse colors, webgpu only
|
|
1706
1739
|
"bgra8unorm": { b: 4, c: 4 },
|
|
1707
1740
|
"bgra8unorm-srgb": { b: 4, c: 4 },
|
|
1708
|
-
"rg16uint": { gl:
|
|
1709
|
-
"rg16sint": { gl:
|
|
1741
|
+
"rg16uint": { gl: import_constants6.GL.RG16UI, b: 4, c: 1, bpp: 4 },
|
|
1742
|
+
"rg16sint": { gl: import_constants6.GL.RG16I, b: 4, c: 2, bpp: 4 },
|
|
1710
1743
|
// When using a WebGL 2 context and the EXT_color_buffer_float WebGL2 extension
|
|
1711
|
-
"rg16float": { gl:
|
|
1712
|
-
"rg16unorm-webgl": { gl:
|
|
1713
|
-
"rg16snorm-webgl": { gl:
|
|
1714
|
-
"r32uint": { gl:
|
|
1715
|
-
"r32sint": { gl:
|
|
1716
|
-
"r32float": { gl:
|
|
1744
|
+
"rg16float": { gl: import_constants6.GL.RG16F, bpp: 4, b: 4, c: 2, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl", renderbuffer: true },
|
|
1745
|
+
"rg16unorm-webgl": { gl: import_constants6.GL.RG16_EXT, b: 2, c: 2, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
|
|
1746
|
+
"rg16snorm-webgl": { gl: import_constants6.GL.RG16_SNORM_EXT, b: 2, c: 2, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
|
|
1747
|
+
"r32uint": { gl: import_constants6.GL.R32UI, b: 4, c: 1, bpp: 4, renderbuffer: true },
|
|
1748
|
+
"r32sint": { gl: import_constants6.GL.R32I, b: 4, c: 1, bpp: 4, renderbuffer: true },
|
|
1749
|
+
"r32float": { gl: import_constants6.GL.R32F, bpp: 4, b: 4, c: 1, render: "texture-renderable-float32-webgl", filter: "texture-filter-linear-float32-webgl" },
|
|
1717
1750
|
// Packed 32-bit formats
|
|
1718
|
-
"rgb9e5ufloat": { gl:
|
|
1719
|
-
"rg11b10ufloat": { gl:
|
|
1720
|
-
"rgb10a2unorm": { gl:
|
|
1751
|
+
"rgb9e5ufloat": { gl: import_constants6.GL.RGB9_E5, b: 4, c: 3, p: 1, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl" },
|
|
1752
|
+
"rg11b10ufloat": { gl: import_constants6.GL.R11F_G11F_B10F, b: 4, c: 3, p: 1, render: "texture-renderable-float32-webgl", renderbuffer: true },
|
|
1753
|
+
"rgb10a2unorm": { gl: import_constants6.GL.RGB10_A2, b: 4, c: 4, p: 1, renderbuffer: true },
|
|
1721
1754
|
// webgl2 only
|
|
1722
|
-
"rgb10a2unorm-webgl": { b: 4, c: 4, gl:
|
|
1755
|
+
"rgb10a2unorm-webgl": { b: 4, c: 4, gl: import_constants6.GL.RGB10_A2UI, p: 1, wgpu: false, bpp: 4, renderbuffer: true },
|
|
1723
1756
|
// 48-bit formats
|
|
1724
|
-
"rgb16unorm-webgl": { gl:
|
|
1725
|
-
"rgb16snorm-webgl": { gl:
|
|
1757
|
+
"rgb16unorm-webgl": { gl: import_constants6.GL.RGB16_EXT, b: 2, c: 3, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
|
|
1758
|
+
"rgb16snorm-webgl": { gl: import_constants6.GL.RGB16_SNORM_EXT, b: 2, c: 3, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
|
|
1726
1759
|
// 64-bit formats
|
|
1727
|
-
"rg32uint": { gl:
|
|
1728
|
-
"rg32sint": { gl:
|
|
1729
|
-
"rg32float": { gl:
|
|
1730
|
-
"rgba16uint": { gl:
|
|
1731
|
-
"rgba16sint": { gl:
|
|
1732
|
-
"rgba16float": { gl:
|
|
1733
|
-
"rgba16unorm-webgl": { gl:
|
|
1734
|
-
"rgba16snorm-webgl": { gl:
|
|
1760
|
+
"rg32uint": { gl: import_constants6.GL.RG32UI, b: 8, c: 2, renderbuffer: true },
|
|
1761
|
+
"rg32sint": { gl: import_constants6.GL.RG32I, b: 8, c: 2, renderbuffer: true },
|
|
1762
|
+
"rg32float": { gl: import_constants6.GL.RG32F, b: 8, c: 2, render: "texture-renderable-float32-webgl", filter: "texture-filter-linear-float32-webgl", renderbuffer: true },
|
|
1763
|
+
"rgba16uint": { gl: import_constants6.GL.RGBA16UI, b: 8, c: 4, renderbuffer: true },
|
|
1764
|
+
"rgba16sint": { gl: import_constants6.GL.RGBA16I, b: 8, c: 4, renderbuffer: true },
|
|
1765
|
+
"rgba16float": { gl: import_constants6.GL.RGBA16F, gl1: import_constants6.GL.RGBA, b: 8, c: 4, render: "texture-renderable-float16-webgl", filter: "texture-filter-linear-float16-webgl" },
|
|
1766
|
+
"rgba16unorm-webgl": { gl: import_constants6.GL.RGBA16_EXT, b: 2, c: 4, f: "texture-formats-norm16-webgl", renderbuffer: true, x: EXT_TEXTURE_NORM16 },
|
|
1767
|
+
"rgba16snorm-webgl": { gl: import_constants6.GL.RGBA16_SNORM_EXT, b: 2, c: 4, f: "texture-formats-norm16-webgl", x: EXT_TEXTURE_NORM16 },
|
|
1735
1768
|
// 96-bit formats (deprecated!)
|
|
1736
1769
|
"rgb32float-webgl": {
|
|
1737
|
-
gl:
|
|
1738
|
-
gl1:
|
|
1770
|
+
gl: import_constants6.GL.RGB32F,
|
|
1771
|
+
gl1: import_constants6.GL.RGB,
|
|
1739
1772
|
render: "texture-renderable-float32-webgl",
|
|
1740
1773
|
filter: "texture-filter-linear-float32-webgl",
|
|
1741
1774
|
gl2ext: EXT_FLOAT_RENDER_WEBGL2,
|
|
1742
1775
|
gl1ext: EXT_FLOAT_WEBGL1,
|
|
1743
1776
|
// WebGL1 render buffers are supported with GL.RGB32F
|
|
1744
|
-
dataFormat:
|
|
1745
|
-
types: [
|
|
1777
|
+
dataFormat: import_constants6.GL.RGB,
|
|
1778
|
+
types: [import_constants6.GL.FLOAT]
|
|
1746
1779
|
},
|
|
1747
1780
|
// 128-bit formats
|
|
1748
|
-
"rgba32uint": { gl:
|
|
1749
|
-
"rgba32sint": { gl:
|
|
1750
|
-
"rgba32float": { gl:
|
|
1781
|
+
"rgba32uint": { gl: import_constants6.GL.RGBA32UI, b: 16, c: 4, renderbuffer: true },
|
|
1782
|
+
"rgba32sint": { gl: import_constants6.GL.RGBA32I, b: 16, c: 4, renderbuffer: true },
|
|
1783
|
+
"rgba32float": { gl: import_constants6.GL.RGBA32F, b: 16, c: 4, render: "texture-renderable-float32-webgl", filter: "texture-filter-linear-float32-webgl", renderbuffer: true },
|
|
1751
1784
|
// Depth and stencil formats
|
|
1752
|
-
"stencil8": { gl:
|
|
1785
|
+
"stencil8": { gl: import_constants6.GL.STENCIL_INDEX8, gl1: import_constants6.GL.STENCIL_INDEX8, b: 1, c: 1, attachment: import_constants6.GL.STENCIL_ATTACHMENT, renderbuffer: true },
|
|
1753
1786
|
// 8 stencil bits
|
|
1754
|
-
"depth16unorm": { gl:
|
|
1787
|
+
"depth16unorm": { gl: import_constants6.GL.DEPTH_COMPONENT16, gl1: import_constants6.GL.DEPTH_COMPONENT16, b: 2, c: 1, attachment: import_constants6.GL.DEPTH_ATTACHMENT, renderbuffer: true },
|
|
1755
1788
|
// 16 depth bits
|
|
1756
|
-
"depth24plus": { gl:
|
|
1757
|
-
"depth32float": { gl:
|
|
1789
|
+
"depth24plus": { gl: import_constants6.GL.DEPTH_COMPONENT24, b: 3, c: 1, attachment: import_constants6.GL.DEPTH_ATTACHMENT },
|
|
1790
|
+
"depth32float": { gl: import_constants6.GL.DEPTH_COMPONENT32F, b: 4, c: 1, attachment: import_constants6.GL.DEPTH_ATTACHMENT, renderbuffer: true },
|
|
1758
1791
|
// The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
|
|
1759
|
-
"depth24plus-stencil8": { gl:
|
|
1792
|
+
"depth24plus-stencil8": { gl: import_constants6.GL.DEPTH_STENCIL, gl1: import_constants6.GL.DEPTH_STENCIL, b: 4, c: 2, p: 1, attachment: import_constants6.GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true, depthTexture: true },
|
|
1760
1793
|
// "depth24unorm-stencil8" feature
|
|
1761
|
-
"depth24unorm-stencil8": { gl:
|
|
1794
|
+
"depth24unorm-stencil8": { gl: import_constants6.GL.DEPTH24_STENCIL8, b: 4, c: 2, p: 1, attachment: import_constants6.GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true },
|
|
1762
1795
|
// "depth32float-stencil8" feature
|
|
1763
|
-
"depth32float-stencil8": { gl:
|
|
1796
|
+
"depth32float-stencil8": { gl: import_constants6.GL.DEPTH32F_STENCIL8, b: 5, c: 2, p: 1, attachment: import_constants6.GL.DEPTH_STENCIL_ATTACHMENT, renderbuffer: true },
|
|
1764
1797
|
// BC compressed formats: check device.features.has("texture-compression-bc");
|
|
1765
|
-
"bc1-rgb-unorm-webgl": { gl:
|
|
1766
|
-
"bc1-rgb-unorm-srgb-webgl": { gl:
|
|
1767
|
-
"bc1-rgba-unorm": { gl:
|
|
1768
|
-
"bc1-rgba-unorm-srgb": { gl:
|
|
1769
|
-
"bc2-rgba-unorm": { gl:
|
|
1770
|
-
"bc2-rgba-unorm-srgb": { gl:
|
|
1771
|
-
"bc3-rgba-unorm": { gl:
|
|
1772
|
-
"bc3-rgba-unorm-srgb": { gl:
|
|
1773
|
-
"bc4-r-unorm": { gl:
|
|
1774
|
-
"bc4-r-snorm": { gl:
|
|
1775
|
-
"bc5-rg-unorm": { gl:
|
|
1776
|
-
"bc5-rg-snorm": { gl:
|
|
1777
|
-
"bc6h-rgb-ufloat": { gl:
|
|
1778
|
-
"bc6h-rgb-float": { gl:
|
|
1779
|
-
"bc7-rgba-unorm": { gl:
|
|
1780
|
-
"bc7-rgba-unorm-srgb": { gl:
|
|
1798
|
+
"bc1-rgb-unorm-webgl": { gl: import_constants6.GL.COMPRESSED_RGB_S3TC_DXT1_EXT, x: X_S3TC, f: texture_compression_bc },
|
|
1799
|
+
"bc1-rgb-unorm-srgb-webgl": { gl: import_constants6.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
1800
|
+
"bc1-rgba-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_S3TC_DXT1_EXT, x: X_S3TC, f: texture_compression_bc },
|
|
1801
|
+
"bc1-rgba-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
1802
|
+
"bc2-rgba-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_S3TC_DXT3_EXT, x: X_S3TC, f: texture_compression_bc },
|
|
1803
|
+
"bc2-rgba-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
1804
|
+
"bc3-rgba-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_S3TC_DXT5_EXT, x: X_S3TC, f: texture_compression_bc },
|
|
1805
|
+
"bc3-rgba-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, x: X_S3TC_SRGB, f: texture_compression_bc },
|
|
1806
|
+
"bc4-r-unorm": { gl: import_constants6.GL.COMPRESSED_RED_RGTC1_EXT, x: X_RGTC, f: texture_compression_bc },
|
|
1807
|
+
"bc4-r-snorm": { gl: import_constants6.GL.COMPRESSED_SIGNED_RED_RGTC1_EXT, x: X_RGTC, f: texture_compression_bc },
|
|
1808
|
+
"bc5-rg-unorm": { gl: import_constants6.GL.COMPRESSED_RED_GREEN_RGTC2_EXT, x: X_RGTC, f: texture_compression_bc },
|
|
1809
|
+
"bc5-rg-snorm": { gl: import_constants6.GL.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, x: X_RGTC, f: texture_compression_bc },
|
|
1810
|
+
"bc6h-rgb-ufloat": { gl: import_constants6.GL.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, x: X_BPTC, f: texture_compression_bc },
|
|
1811
|
+
"bc6h-rgb-float": { gl: import_constants6.GL.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, x: X_BPTC, f: texture_compression_bc },
|
|
1812
|
+
"bc7-rgba-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_BPTC_UNORM_EXT, x: X_BPTC, f: texture_compression_bc },
|
|
1813
|
+
"bc7-rgba-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, x: X_BPTC, f: texture_compression_bc },
|
|
1781
1814
|
// WEBGL_compressed_texture_etc: device.features.has("texture-compression-etc2")
|
|
1782
1815
|
// Note: Supposedly guaranteed availability compressed formats in WebGL2, but through CPU decompression
|
|
1783
|
-
"etc2-rgb8unorm": { gl:
|
|
1784
|
-
"etc2-rgb8unorm-srgb": { gl:
|
|
1785
|
-
"etc2-rgb8a1unorm": { gl:
|
|
1786
|
-
"etc2-rgb8a1unorm-srgb": { gl:
|
|
1787
|
-
"etc2-rgba8unorm": { gl:
|
|
1788
|
-
"etc2-rgba8unorm-srgb": { gl:
|
|
1789
|
-
"eac-r11unorm": { gl:
|
|
1790
|
-
"eac-r11snorm": { gl:
|
|
1791
|
-
"eac-rg11unorm": { gl:
|
|
1792
|
-
"eac-rg11snorm": { gl:
|
|
1816
|
+
"etc2-rgb8unorm": { gl: import_constants6.GL.COMPRESSED_RGB8_ETC2, f: texture_compression_etc2 },
|
|
1817
|
+
"etc2-rgb8unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ETC2, f: texture_compression_etc2 },
|
|
1818
|
+
"etc2-rgb8a1unorm": { gl: import_constants6.GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, f: texture_compression_etc2 },
|
|
1819
|
+
"etc2-rgb8a1unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, f: texture_compression_etc2 },
|
|
1820
|
+
"etc2-rgba8unorm": { gl: import_constants6.GL.COMPRESSED_RGBA8_ETC2_EAC, f: texture_compression_etc2 },
|
|
1821
|
+
"etc2-rgba8unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, f: texture_compression_etc2 },
|
|
1822
|
+
"eac-r11unorm": { gl: import_constants6.GL.COMPRESSED_R11_EAC, f: texture_compression_etc2 },
|
|
1823
|
+
"eac-r11snorm": { gl: import_constants6.GL.COMPRESSED_SIGNED_R11_EAC, f: texture_compression_etc2 },
|
|
1824
|
+
"eac-rg11unorm": { gl: import_constants6.GL.COMPRESSED_RG11_EAC, f: texture_compression_etc2 },
|
|
1825
|
+
"eac-rg11snorm": { gl: import_constants6.GL.COMPRESSED_SIGNED_RG11_EAC, f: texture_compression_etc2 },
|
|
1793
1826
|
// X_ASTC compressed formats: device.features.has("texture-compression-astc")
|
|
1794
|
-
"astc-4x4-unorm": { gl:
|
|
1795
|
-
"astc-4x4-unorm-srgb": { gl:
|
|
1796
|
-
"astc-5x4-unorm": { gl:
|
|
1797
|
-
"astc-5x4-unorm-srgb": { gl:
|
|
1798
|
-
"astc-5x5-unorm": { gl:
|
|
1799
|
-
"astc-5x5-unorm-srgb": { gl:
|
|
1800
|
-
"astc-6x5-unorm": { gl:
|
|
1801
|
-
"astc-6x5-unorm-srgb": { gl:
|
|
1802
|
-
"astc-6x6-unorm": { gl:
|
|
1803
|
-
"astc-6x6-unorm-srgb": { gl:
|
|
1804
|
-
"astc-8x5-unorm": { gl:
|
|
1805
|
-
"astc-8x5-unorm-srgb": { gl:
|
|
1806
|
-
"astc-8x6-unorm": { gl:
|
|
1807
|
-
"astc-8x6-unorm-srgb": { gl:
|
|
1808
|
-
"astc-8x8-unorm": { gl:
|
|
1809
|
-
"astc-8x8-unorm-srgb": { gl:
|
|
1810
|
-
"astc-10x5-unorm": { gl:
|
|
1811
|
-
"astc-10x5-unorm-srgb": { gl:
|
|
1812
|
-
"astc-10x6-unorm": { gl:
|
|
1813
|
-
"astc-10x6-unorm-srgb": { gl:
|
|
1814
|
-
"astc-10x8-unorm": { gl:
|
|
1815
|
-
"astc-10x8-unorm-srgb": { gl:
|
|
1816
|
-
"astc-10x10-unorm": { gl:
|
|
1817
|
-
"astc-10x10-unorm-srgb": { gl:
|
|
1818
|
-
"astc-12x10-unorm": { gl:
|
|
1819
|
-
"astc-12x10-unorm-srgb": { gl:
|
|
1820
|
-
"astc-12x12-unorm": { gl:
|
|
1821
|
-
"astc-12x12-unorm-srgb": { gl:
|
|
1827
|
+
"astc-4x4-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_4x4_KHR, f: texture_compression_astc },
|
|
1828
|
+
"astc-4x4-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, f: texture_compression_astc },
|
|
1829
|
+
"astc-5x4-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_5x4_KHR, f: texture_compression_astc },
|
|
1830
|
+
"astc-5x4-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, f: texture_compression_astc },
|
|
1831
|
+
"astc-5x5-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_5x5_KHR, f: texture_compression_astc },
|
|
1832
|
+
"astc-5x5-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, f: texture_compression_astc },
|
|
1833
|
+
"astc-6x5-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_6x5_KHR, f: texture_compression_astc },
|
|
1834
|
+
"astc-6x5-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, f: texture_compression_astc },
|
|
1835
|
+
"astc-6x6-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_6x6_KHR, f: texture_compression_astc },
|
|
1836
|
+
"astc-6x6-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, f: texture_compression_astc },
|
|
1837
|
+
"astc-8x5-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_8x5_KHR, f: texture_compression_astc },
|
|
1838
|
+
"astc-8x5-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, f: texture_compression_astc },
|
|
1839
|
+
"astc-8x6-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_8x6_KHR, f: texture_compression_astc },
|
|
1840
|
+
"astc-8x6-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, f: texture_compression_astc },
|
|
1841
|
+
"astc-8x8-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_8x8_KHR, f: texture_compression_astc },
|
|
1842
|
+
"astc-8x8-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, f: texture_compression_astc },
|
|
1843
|
+
"astc-10x5-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_10x10_KHR, f: texture_compression_astc },
|
|
1844
|
+
"astc-10x5-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, f: texture_compression_astc },
|
|
1845
|
+
"astc-10x6-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_10x6_KHR, f: texture_compression_astc },
|
|
1846
|
+
"astc-10x6-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, f: texture_compression_astc },
|
|
1847
|
+
"astc-10x8-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_10x8_KHR, f: texture_compression_astc },
|
|
1848
|
+
"astc-10x8-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, f: texture_compression_astc },
|
|
1849
|
+
"astc-10x10-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_10x10_KHR, f: texture_compression_astc },
|
|
1850
|
+
"astc-10x10-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, f: texture_compression_astc },
|
|
1851
|
+
"astc-12x10-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_12x10_KHR, f: texture_compression_astc },
|
|
1852
|
+
"astc-12x10-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, f: texture_compression_astc },
|
|
1853
|
+
"astc-12x12-unorm": { gl: import_constants6.GL.COMPRESSED_RGBA_ASTC_12x12_KHR, f: texture_compression_astc },
|
|
1854
|
+
"astc-12x12-unorm-srgb": { gl: import_constants6.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, f: texture_compression_astc },
|
|
1822
1855
|
// WEBGL_compressed_texture_pvrtc
|
|
1823
|
-
"pvrtc-rgb4unorm-webgl": { gl:
|
|
1824
|
-
"pvrtc-rgba4unorm-webgl": { gl:
|
|
1825
|
-
"pvrtc-rbg2unorm-webgl": { gl:
|
|
1826
|
-
"pvrtc-rgba2unorm-webgl": { gl:
|
|
1856
|
+
"pvrtc-rgb4unorm-webgl": { gl: import_constants6.GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG, f: texture_compression_pvrtc_webgl },
|
|
1857
|
+
"pvrtc-rgba4unorm-webgl": { gl: import_constants6.GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, f: texture_compression_pvrtc_webgl },
|
|
1858
|
+
"pvrtc-rbg2unorm-webgl": { gl: import_constants6.GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG, f: texture_compression_pvrtc_webgl },
|
|
1859
|
+
"pvrtc-rgba2unorm-webgl": { gl: import_constants6.GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, f: texture_compression_pvrtc_webgl },
|
|
1827
1860
|
// WEBGL_compressed_texture_etc1
|
|
1828
|
-
"etc1-rbg-unorm-webgl": { gl:
|
|
1861
|
+
"etc1-rbg-unorm-webgl": { gl: import_constants6.GL.COMPRESSED_RGB_ETC1_WEBGL, f: texture_compression_etc1_webgl },
|
|
1829
1862
|
// WEBGL_compressed_texture_atc
|
|
1830
|
-
"atc-rgb-unorm-webgl": { gl:
|
|
1831
|
-
"atc-rgba-unorm-webgl": { gl:
|
|
1832
|
-
"atc-rgbai-unorm-webgl": { gl:
|
|
1863
|
+
"atc-rgb-unorm-webgl": { gl: import_constants6.GL.COMPRESSED_RGB_ATC_WEBGL, f: texture_compression_atc_webgl },
|
|
1864
|
+
"atc-rgba-unorm-webgl": { gl: import_constants6.GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL, f: texture_compression_atc_webgl },
|
|
1865
|
+
"atc-rgbai-unorm-webgl": { gl: import_constants6.GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL, f: texture_compression_atc_webgl }
|
|
1833
1866
|
};
|
|
1834
1867
|
var DATA_FORMAT_CHANNELS = {
|
|
1835
|
-
[
|
|
1836
|
-
[
|
|
1837
|
-
[
|
|
1838
|
-
[
|
|
1839
|
-
[
|
|
1840
|
-
[
|
|
1841
|
-
[
|
|
1842
|
-
[
|
|
1843
|
-
[
|
|
1844
|
-
[
|
|
1845
|
-
[
|
|
1846
|
-
[
|
|
1847
|
-
[
|
|
1868
|
+
[import_constants6.GL.RED]: 1,
|
|
1869
|
+
[import_constants6.GL.RED_INTEGER]: 1,
|
|
1870
|
+
[import_constants6.GL.RG]: 2,
|
|
1871
|
+
[import_constants6.GL.RG_INTEGER]: 2,
|
|
1872
|
+
[import_constants6.GL.RGB]: 3,
|
|
1873
|
+
[import_constants6.GL.RGB_INTEGER]: 3,
|
|
1874
|
+
[import_constants6.GL.RGBA]: 4,
|
|
1875
|
+
[import_constants6.GL.RGBA_INTEGER]: 4,
|
|
1876
|
+
[import_constants6.GL.DEPTH_COMPONENT]: 1,
|
|
1877
|
+
[import_constants6.GL.DEPTH_STENCIL]: 1,
|
|
1878
|
+
[import_constants6.GL.ALPHA]: 1,
|
|
1879
|
+
[import_constants6.GL.LUMINANCE]: 1,
|
|
1880
|
+
[import_constants6.GL.LUMINANCE_ALPHA]: 2
|
|
1848
1881
|
};
|
|
1849
1882
|
var TYPE_SIZES = {
|
|
1850
|
-
[
|
|
1851
|
-
[
|
|
1852
|
-
[
|
|
1853
|
-
[
|
|
1854
|
-
[
|
|
1855
|
-
[
|
|
1856
|
-
[
|
|
1857
|
-
[
|
|
1883
|
+
[import_constants6.GL.FLOAT]: 4,
|
|
1884
|
+
[import_constants6.GL.UNSIGNED_INT]: 4,
|
|
1885
|
+
[import_constants6.GL.INT]: 4,
|
|
1886
|
+
[import_constants6.GL.UNSIGNED_SHORT]: 2,
|
|
1887
|
+
[import_constants6.GL.SHORT]: 2,
|
|
1888
|
+
[import_constants6.GL.HALF_FLOAT]: 2,
|
|
1889
|
+
[import_constants6.GL.BYTE]: 1,
|
|
1890
|
+
[import_constants6.GL.UNSIGNED_BYTE]: 1
|
|
1858
1891
|
};
|
|
1859
1892
|
function isTextureFormatSupported(gl2, formatOrGL) {
|
|
1860
1893
|
const format = convertGLToTextureFormat(formatOrGL);
|
|
@@ -1938,7 +1971,8 @@ function getWebGLTextureParameters(formatOrGL, isWebGL23) {
|
|
|
1938
1971
|
decoded.normalized,
|
|
1939
1972
|
webglFormat
|
|
1940
1973
|
),
|
|
1941
|
-
type
|
|
1974
|
+
// depth formats don't have a type
|
|
1975
|
+
type: decoded.dataType ? getGLFromVertexType(decoded.dataType) : import_constants6.GL.UNSIGNED_BYTE,
|
|
1942
1976
|
// @ts-expect-error
|
|
1943
1977
|
compressed: decoded.compressed
|
|
1944
1978
|
};
|
|
@@ -1950,12 +1984,12 @@ function getDepthStencilAttachmentWebGL(format) {
|
|
|
1950
1984
|
}
|
|
1951
1985
|
return info.attachment;
|
|
1952
1986
|
}
|
|
1953
|
-
function _checkFloat32ColorAttachment(gl2, internalFormat = gl2.RGBA, srcFormat =
|
|
1987
|
+
function _checkFloat32ColorAttachment(gl2, internalFormat = gl2.RGBA, srcFormat = import_constants6.GL.RGBA, srcType = import_constants6.GL.UNSIGNED_BYTE) {
|
|
1954
1988
|
let texture = null;
|
|
1955
1989
|
let framebuffer = null;
|
|
1956
1990
|
try {
|
|
1957
1991
|
texture = gl2.createTexture();
|
|
1958
|
-
gl2.bindTexture(
|
|
1992
|
+
gl2.bindTexture(import_constants6.GL.TEXTURE_2D, texture);
|
|
1959
1993
|
const level = 0;
|
|
1960
1994
|
const width = 1;
|
|
1961
1995
|
const height = 1;
|
|
@@ -1973,10 +2007,10 @@ function _checkFloat32ColorAttachment(gl2, internalFormat = gl2.RGBA, srcFormat
|
|
|
1973
2007
|
pixel
|
|
1974
2008
|
);
|
|
1975
2009
|
framebuffer = gl2.createFramebuffer();
|
|
1976
|
-
gl2.bindFramebuffer(
|
|
1977
|
-
gl2.framebufferTexture2D(
|
|
1978
|
-
const status = gl2.checkFramebufferStatus(
|
|
1979
|
-
gl2.bindTexture(
|
|
2010
|
+
gl2.bindFramebuffer(import_constants6.GL.FRAMEBUFFER, framebuffer);
|
|
2011
|
+
gl2.framebufferTexture2D(import_constants6.GL.FRAMEBUFFER, import_constants6.GL.COLOR_ATTACHMENT0, import_constants6.GL.TEXTURE_2D, texture, 0);
|
|
2012
|
+
const status = gl2.checkFramebufferStatus(import_constants6.GL.FRAMEBUFFER) === import_constants6.GL.FRAMEBUFFER_COMPLETE;
|
|
2013
|
+
gl2.bindTexture(import_constants6.GL.TEXTURE_2D, null);
|
|
1980
2014
|
return status;
|
|
1981
2015
|
} finally {
|
|
1982
2016
|
gl2.deleteTexture(texture);
|
|
@@ -1991,42 +2025,20 @@ function getTextureFormatBytesPerPixel(formatOrGL, isWebGL23) {
|
|
|
1991
2025
|
return channels * channelSize;
|
|
1992
2026
|
}
|
|
1993
2027
|
function getWebGLPixelDataFormat(dataFormat, integer, normalized, format) {
|
|
1994
|
-
if (format ===
|
|
2028
|
+
if (format === import_constants6.GL.RGBA || format === import_constants6.GL.RGB) {
|
|
1995
2029
|
return format;
|
|
1996
2030
|
}
|
|
1997
2031
|
switch (dataFormat) {
|
|
1998
2032
|
case "r":
|
|
1999
|
-
return integer && !normalized ?
|
|
2033
|
+
return integer && !normalized ? import_constants6.GL.RED_INTEGER : import_constants6.GL.RED;
|
|
2000
2034
|
case "rg":
|
|
2001
|
-
return integer && !normalized ?
|
|
2035
|
+
return integer && !normalized ? import_constants6.GL.RG_INTEGER : import_constants6.GL.RG;
|
|
2002
2036
|
case "rgb":
|
|
2003
|
-
return integer && !normalized ?
|
|
2037
|
+
return integer && !normalized ? import_constants6.GL.RGB_INTEGER : import_constants6.GL.RGB;
|
|
2004
2038
|
case "rgba":
|
|
2005
|
-
return integer && !normalized ?
|
|
2006
|
-
default:
|
|
2007
|
-
return import_constants5.GL.RGBA;
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
function getWebGLDataType(dataType) {
|
|
2011
|
-
switch (dataType) {
|
|
2012
|
-
case "uint8":
|
|
2013
|
-
return import_constants5.GL.UNSIGNED_BYTE;
|
|
2014
|
-
case "sint8":
|
|
2015
|
-
return import_constants5.GL.BYTE;
|
|
2016
|
-
case "uint16":
|
|
2017
|
-
return import_constants5.GL.UNSIGNED_SHORT;
|
|
2018
|
-
case "sint16":
|
|
2019
|
-
return import_constants5.GL.SHORT;
|
|
2020
|
-
case "uint32":
|
|
2021
|
-
return import_constants5.GL.UNSIGNED_INT;
|
|
2022
|
-
case "sint32":
|
|
2023
|
-
return import_constants5.GL.INT;
|
|
2024
|
-
case "float16":
|
|
2025
|
-
return import_constants5.GL.HALF_FLOAT;
|
|
2026
|
-
case "float32":
|
|
2027
|
-
return import_constants5.GL.FLOAT;
|
|
2039
|
+
return integer && !normalized ? import_constants6.GL.RGBA_INTEGER : import_constants6.GL.RGBA;
|
|
2028
2040
|
default:
|
|
2029
|
-
return
|
|
2041
|
+
return import_constants6.GL.RGBA;
|
|
2030
2042
|
}
|
|
2031
2043
|
}
|
|
2032
2044
|
|
|
@@ -2128,39 +2140,39 @@ var WEBGL_FEATURES = {
|
|
|
2128
2140
|
};
|
|
2129
2141
|
|
|
2130
2142
|
// src/adapter/device-helpers/device-limits.ts
|
|
2131
|
-
var
|
|
2143
|
+
var import_constants7 = require("@luma.gl/constants");
|
|
2132
2144
|
function getDeviceLimits(gl2) {
|
|
2133
2145
|
const gl22 = getWebGL2Context(gl2);
|
|
2134
2146
|
return {
|
|
2135
2147
|
maxTextureDimension1D: 0,
|
|
2136
2148
|
// WebGL does not support 1D textures
|
|
2137
|
-
maxTextureDimension2D: gl2.getParameter(
|
|
2138
|
-
maxTextureDimension3D: gl22 ? gl22.getParameter(
|
|
2139
|
-
maxTextureArrayLayers: gl22 ? gl22.getParameter(
|
|
2149
|
+
maxTextureDimension2D: gl2.getParameter(import_constants7.GL.MAX_TEXTURE_SIZE),
|
|
2150
|
+
maxTextureDimension3D: gl22 ? gl22.getParameter(import_constants7.GL.MAX_3D_TEXTURE_SIZE) : 0,
|
|
2151
|
+
maxTextureArrayLayers: gl22 ? gl22.getParameter(import_constants7.GL.MAX_ARRAY_TEXTURE_LAYERS) : 0,
|
|
2140
2152
|
maxBindGroups: 1,
|
|
2141
2153
|
// TBD
|
|
2142
2154
|
maxDynamicUniformBuffersPerPipelineLayout: 0,
|
|
2143
2155
|
// TBD
|
|
2144
2156
|
maxDynamicStorageBuffersPerPipelineLayout: 0,
|
|
2145
2157
|
// TBD
|
|
2146
|
-
maxSampledTexturesPerShaderStage: gl2.getParameter(
|
|
2158
|
+
maxSampledTexturesPerShaderStage: gl2.getParameter(import_constants7.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
|
|
2147
2159
|
// TBD
|
|
2148
|
-
maxSamplersPerShaderStage: gl2.getParameter(
|
|
2160
|
+
maxSamplersPerShaderStage: gl2.getParameter(import_constants7.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
|
|
2149
2161
|
maxStorageBuffersPerShaderStage: 0,
|
|
2150
2162
|
// TBD
|
|
2151
2163
|
maxStorageTexturesPerShaderStage: 0,
|
|
2152
2164
|
// TBD
|
|
2153
|
-
maxUniformBuffersPerShaderStage: gl22 ? gl22.getParameter(
|
|
2154
|
-
maxUniformBufferBindingSize: gl22 ? gl22.getParameter(
|
|
2165
|
+
maxUniformBuffersPerShaderStage: gl22 ? gl22.getParameter(import_constants7.GL.MAX_UNIFORM_BUFFER_BINDINGS) : 0,
|
|
2166
|
+
maxUniformBufferBindingSize: gl22 ? gl22.getParameter(import_constants7.GL.MAX_UNIFORM_BLOCK_SIZE) : 0,
|
|
2155
2167
|
maxStorageBufferBindingSize: 0,
|
|
2156
|
-
minUniformBufferOffsetAlignment: gl22 ? gl22.getParameter(
|
|
2168
|
+
minUniformBufferOffsetAlignment: gl22 ? gl22.getParameter(import_constants7.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT) : 0,
|
|
2157
2169
|
minStorageBufferOffsetAlignment: 0,
|
|
2158
2170
|
// TBD
|
|
2159
2171
|
maxVertexBuffers: 0,
|
|
2160
|
-
maxVertexAttributes: gl2.getParameter(
|
|
2172
|
+
maxVertexAttributes: gl2.getParameter(import_constants7.GL.MAX_VERTEX_ATTRIBS),
|
|
2161
2173
|
maxVertexBufferArrayStride: 2048,
|
|
2162
2174
|
// TBD, this is just the default value from WebGPU
|
|
2163
|
-
maxInterStageShaderComponents: gl22 ? gl22.getParameter(
|
|
2175
|
+
maxInterStageShaderComponents: gl22 ? gl22.getParameter(import_constants7.GL.MAX_VARYING_COMPONENTS) : 0,
|
|
2164
2176
|
maxComputeWorkgroupStorageSize: 0,
|
|
2165
2177
|
// WebGL does not support compute shaders
|
|
2166
2178
|
maxComputeInvocationsPerWorkgroup: 0,
|
|
@@ -2184,89 +2196,89 @@ function getWebGLLimits(gl2) {
|
|
|
2184
2196
|
return gl22 ? gl22.getParameter(pname) : defaultValue || 0;
|
|
2185
2197
|
}
|
|
2186
2198
|
return {
|
|
2187
|
-
[
|
|
2188
|
-
[
|
|
2189
|
-
[
|
|
2190
|
-
[
|
|
2199
|
+
[import_constants7.GL.ALIASED_LINE_WIDTH_RANGE]: get(import_constants7.GL.ALIASED_LINE_WIDTH_RANGE),
|
|
2200
|
+
[import_constants7.GL.ALIASED_POINT_SIZE_RANGE]: get(import_constants7.GL.ALIASED_POINT_SIZE_RANGE),
|
|
2201
|
+
[import_constants7.GL.MAX_TEXTURE_SIZE]: get(import_constants7.GL.MAX_TEXTURE_SIZE),
|
|
2202
|
+
[import_constants7.GL.MAX_CUBE_MAP_TEXTURE_SIZE]: get(import_constants7.GL.MAX_CUBE_MAP_TEXTURE_SIZE),
|
|
2191
2203
|
// GLint
|
|
2192
|
-
[
|
|
2204
|
+
[import_constants7.GL.MAX_TEXTURE_IMAGE_UNITS]: get(import_constants7.GL.MAX_TEXTURE_IMAGE_UNITS),
|
|
2193
2205
|
// GLint
|
|
2194
|
-
[
|
|
2206
|
+
[import_constants7.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS]: get(import_constants7.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
|
|
2195
2207
|
// GLint
|
|
2196
|
-
[
|
|
2208
|
+
[import_constants7.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS]: get(import_constants7.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
|
|
2197
2209
|
// GLint
|
|
2198
|
-
[
|
|
2210
|
+
[import_constants7.GL.MAX_RENDERBUFFER_SIZE]: get(import_constants7.GL.MAX_RENDERBUFFER_SIZE),
|
|
2199
2211
|
// GLint
|
|
2200
|
-
[
|
|
2212
|
+
[import_constants7.GL.MAX_VARYING_VECTORS]: get(import_constants7.GL.MAX_VARYING_VECTORS),
|
|
2201
2213
|
// GLint
|
|
2202
|
-
[
|
|
2214
|
+
[import_constants7.GL.MAX_VERTEX_ATTRIBS]: get(import_constants7.GL.MAX_VERTEX_ATTRIBS),
|
|
2203
2215
|
// GLint
|
|
2204
|
-
[
|
|
2216
|
+
[import_constants7.GL.MAX_VERTEX_UNIFORM_VECTORS]: get(import_constants7.GL.MAX_VERTEX_UNIFORM_VECTORS),
|
|
2205
2217
|
// GLint
|
|
2206
|
-
[
|
|
2218
|
+
[import_constants7.GL.MAX_FRAGMENT_UNIFORM_VECTORS]: get(import_constants7.GL.MAX_FRAGMENT_UNIFORM_VECTORS),
|
|
2207
2219
|
// GLint
|
|
2208
|
-
[
|
|
2220
|
+
[import_constants7.GL.MAX_VIEWPORT_DIMS]: get(import_constants7.GL.MAX_VIEWPORT_DIMS),
|
|
2209
2221
|
// Extensions
|
|
2210
|
-
[
|
|
2222
|
+
[import_constants7.GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT]: get(import_constants7.GL.MAX_TEXTURE_MAX_ANISOTROPY_EXT),
|
|
2211
2223
|
// getMaxAnistropy(),
|
|
2212
2224
|
// WebGL2 Limits
|
|
2213
|
-
[
|
|
2225
|
+
[import_constants7.GL.MAX_3D_TEXTURE_SIZE]: get2(import_constants7.GL.MAX_3D_TEXTURE_SIZE),
|
|
2214
2226
|
// GLint
|
|
2215
|
-
[
|
|
2227
|
+
[import_constants7.GL.MAX_ARRAY_TEXTURE_LAYERS]: get2(import_constants7.GL.MAX_ARRAY_TEXTURE_LAYERS),
|
|
2216
2228
|
// GLint
|
|
2217
|
-
[
|
|
2229
|
+
[import_constants7.GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL]: get2(import_constants7.GL.MAX_CLIENT_WAIT_TIMEOUT_WEBGL),
|
|
2218
2230
|
// GLint64
|
|
2219
|
-
[
|
|
2231
|
+
[import_constants7.GL.MAX_COLOR_ATTACHMENTS]: get2(import_constants7.GL.MAX_COLOR_ATTACHMENTS),
|
|
2220
2232
|
// GLint
|
|
2221
|
-
[
|
|
2233
|
+
[import_constants7.GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS]: get2(import_constants7.GL.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS),
|
|
2222
2234
|
// GLint64
|
|
2223
|
-
[
|
|
2235
|
+
[import_constants7.GL.MAX_COMBINED_UNIFORM_BLOCKS]: get2(import_constants7.GL.MAX_COMBINED_UNIFORM_BLOCKS),
|
|
2224
2236
|
// GLint
|
|
2225
|
-
[
|
|
2237
|
+
[import_constants7.GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS]: get2(import_constants7.GL.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS),
|
|
2226
2238
|
// GLint64
|
|
2227
|
-
[
|
|
2239
|
+
[import_constants7.GL.MAX_DRAW_BUFFERS]: get2(import_constants7.GL.MAX_DRAW_BUFFERS),
|
|
2228
2240
|
// GLint
|
|
2229
|
-
[
|
|
2241
|
+
[import_constants7.GL.MAX_ELEMENT_INDEX]: get2(import_constants7.GL.MAX_ELEMENT_INDEX),
|
|
2230
2242
|
// GLint64
|
|
2231
|
-
[
|
|
2243
|
+
[import_constants7.GL.MAX_ELEMENTS_INDICES]: get2(import_constants7.GL.MAX_ELEMENTS_INDICES),
|
|
2232
2244
|
// GLint
|
|
2233
|
-
[
|
|
2245
|
+
[import_constants7.GL.MAX_ELEMENTS_VERTICES]: get2(import_constants7.GL.MAX_ELEMENTS_VERTICES),
|
|
2234
2246
|
// GLint
|
|
2235
|
-
[
|
|
2247
|
+
[import_constants7.GL.MAX_FRAGMENT_INPUT_COMPONENTS]: get2(import_constants7.GL.MAX_FRAGMENT_INPUT_COMPONENTS),
|
|
2236
2248
|
// GLint
|
|
2237
|
-
[
|
|
2249
|
+
[import_constants7.GL.MAX_FRAGMENT_UNIFORM_BLOCKS]: get2(import_constants7.GL.MAX_FRAGMENT_UNIFORM_BLOCKS),
|
|
2238
2250
|
// GLint
|
|
2239
|
-
[
|
|
2251
|
+
[import_constants7.GL.MAX_FRAGMENT_UNIFORM_COMPONENTS]: get2(import_constants7.GL.MAX_FRAGMENT_UNIFORM_COMPONENTS),
|
|
2240
2252
|
// GLint
|
|
2241
|
-
[
|
|
2253
|
+
[import_constants7.GL.MAX_SAMPLES]: get2(import_constants7.GL.MAX_SAMPLES),
|
|
2242
2254
|
// GLint
|
|
2243
|
-
[
|
|
2255
|
+
[import_constants7.GL.MAX_SERVER_WAIT_TIMEOUT]: get2(import_constants7.GL.MAX_SERVER_WAIT_TIMEOUT),
|
|
2244
2256
|
// GLint64
|
|
2245
|
-
[
|
|
2257
|
+
[import_constants7.GL.MAX_TEXTURE_LOD_BIAS]: get2(import_constants7.GL.MAX_TEXTURE_LOD_BIAS),
|
|
2246
2258
|
// GLfloat
|
|
2247
|
-
[
|
|
2259
|
+
[import_constants7.GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS]: get2(import_constants7.GL.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS),
|
|
2248
2260
|
// GLint
|
|
2249
|
-
[
|
|
2261
|
+
[import_constants7.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS]: get2(import_constants7.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS),
|
|
2250
2262
|
// GLint
|
|
2251
|
-
[
|
|
2263
|
+
[import_constants7.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS]: get2(import_constants7.GL.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS),
|
|
2252
2264
|
// GLint
|
|
2253
|
-
[
|
|
2265
|
+
[import_constants7.GL.MAX_UNIFORM_BLOCK_SIZE]: get2(import_constants7.GL.MAX_UNIFORM_BLOCK_SIZE),
|
|
2254
2266
|
// GLint64
|
|
2255
|
-
[
|
|
2267
|
+
[import_constants7.GL.MAX_UNIFORM_BUFFER_BINDINGS]: get2(import_constants7.GL.MAX_UNIFORM_BUFFER_BINDINGS),
|
|
2256
2268
|
// GLint
|
|
2257
|
-
[
|
|
2269
|
+
[import_constants7.GL.MAX_VARYING_COMPONENTS]: get2(import_constants7.GL.MAX_VARYING_COMPONENTS),
|
|
2258
2270
|
// GLint
|
|
2259
|
-
[
|
|
2271
|
+
[import_constants7.GL.MAX_VERTEX_OUTPUT_COMPONENTS]: get2(import_constants7.GL.MAX_VERTEX_OUTPUT_COMPONENTS),
|
|
2260
2272
|
// GLint
|
|
2261
|
-
[
|
|
2273
|
+
[import_constants7.GL.MAX_VERTEX_UNIFORM_BLOCKS]: get2(import_constants7.GL.MAX_VERTEX_UNIFORM_BLOCKS),
|
|
2262
2274
|
// GLint
|
|
2263
|
-
[
|
|
2275
|
+
[import_constants7.GL.MAX_VERTEX_UNIFORM_COMPONENTS]: get2(import_constants7.GL.MAX_VERTEX_UNIFORM_COMPONENTS),
|
|
2264
2276
|
// GLint
|
|
2265
|
-
[
|
|
2277
|
+
[import_constants7.GL.MIN_PROGRAM_TEXEL_OFFSET]: get2(import_constants7.GL.MIN_PROGRAM_TEXEL_OFFSET),
|
|
2266
2278
|
// GLint
|
|
2267
|
-
[
|
|
2279
|
+
[import_constants7.GL.MAX_PROGRAM_TEXEL_OFFSET]: get2(import_constants7.GL.MAX_PROGRAM_TEXEL_OFFSET),
|
|
2268
2280
|
// GLint
|
|
2269
|
-
[
|
|
2281
|
+
[import_constants7.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT]: get2(import_constants7.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT)
|
|
2270
2282
|
// GLint
|
|
2271
2283
|
};
|
|
2272
2284
|
}
|
|
@@ -2276,12 +2288,12 @@ var import_core15 = require("@luma.gl/core");
|
|
|
2276
2288
|
|
|
2277
2289
|
// src/adapter/resources/webgl-framebuffer.ts
|
|
2278
2290
|
var import_core14 = require("@luma.gl/core");
|
|
2279
|
-
var
|
|
2291
|
+
var import_constants14 = require("@luma.gl/constants");
|
|
2280
2292
|
|
|
2281
2293
|
// src/adapter/resources/webgl-texture.ts
|
|
2282
2294
|
var import_core9 = require("@luma.gl/core");
|
|
2283
2295
|
var import_core10 = require("@luma.gl/core");
|
|
2284
|
-
var
|
|
2296
|
+
var import_constants12 = require("@luma.gl/constants");
|
|
2285
2297
|
|
|
2286
2298
|
// src/context/state-tracker/with-parameters.ts
|
|
2287
2299
|
function withParameters(device, parameters, func) {
|
|
@@ -2314,11 +2326,11 @@ function isObjectEmpty2(object) {
|
|
|
2314
2326
|
}
|
|
2315
2327
|
|
|
2316
2328
|
// src/adapter/converters/sampler-parameters.ts
|
|
2317
|
-
var
|
|
2329
|
+
var import_constants9 = require("@luma.gl/constants");
|
|
2318
2330
|
|
|
2319
2331
|
// src/adapter/converters/device-parameters.ts
|
|
2320
2332
|
var import_core6 = require("@luma.gl/core");
|
|
2321
|
-
var
|
|
2333
|
+
var import_constants8 = require("@luma.gl/constants");
|
|
2322
2334
|
function withGLParameters(device, parameters, func) {
|
|
2323
2335
|
if ((0, import_core6.isObjectEmpty)(parameters)) {
|
|
2324
2336
|
return func(device);
|
|
@@ -2349,23 +2361,23 @@ function setDeviceParameters(device, parameters) {
|
|
|
2349
2361
|
if (parameters.cullMode) {
|
|
2350
2362
|
switch (parameters.cullMode) {
|
|
2351
2363
|
case "none":
|
|
2352
|
-
gl2.disable(
|
|
2364
|
+
gl2.disable(import_constants8.GL.CULL_FACE);
|
|
2353
2365
|
break;
|
|
2354
2366
|
case "front":
|
|
2355
|
-
gl2.enable(
|
|
2356
|
-
gl2.cullFace(
|
|
2367
|
+
gl2.enable(import_constants8.GL.CULL_FACE);
|
|
2368
|
+
gl2.cullFace(import_constants8.GL.FRONT);
|
|
2357
2369
|
break;
|
|
2358
2370
|
case "back":
|
|
2359
|
-
gl2.enable(
|
|
2360
|
-
gl2.cullFace(
|
|
2371
|
+
gl2.enable(import_constants8.GL.CULL_FACE);
|
|
2372
|
+
gl2.cullFace(import_constants8.GL.BACK);
|
|
2361
2373
|
break;
|
|
2362
2374
|
}
|
|
2363
2375
|
}
|
|
2364
2376
|
if (parameters.frontFace) {
|
|
2365
2377
|
gl2.frontFace(
|
|
2366
2378
|
map("frontFace", parameters.frontFace, {
|
|
2367
|
-
ccw:
|
|
2368
|
-
cw:
|
|
2379
|
+
ccw: import_constants8.GL.CCW,
|
|
2380
|
+
cw: import_constants8.GL.CW
|
|
2369
2381
|
})
|
|
2370
2382
|
);
|
|
2371
2383
|
}
|
|
@@ -2376,13 +2388,13 @@ function setDeviceParameters(device, parameters) {
|
|
|
2376
2388
|
gl2.depthMask(mapBoolean("depthWriteEnabled", parameters.depthWriteEnabled));
|
|
2377
2389
|
}
|
|
2378
2390
|
if (parameters.depthCompare) {
|
|
2379
|
-
parameters.depthCompare !== "always" ? gl2.enable(
|
|
2391
|
+
parameters.depthCompare !== "always" ? gl2.enable(import_constants8.GL.DEPTH_TEST) : gl2.disable(import_constants8.GL.DEPTH_TEST);
|
|
2380
2392
|
gl2.depthFunc(convertCompareFunction("depthCompare", parameters.depthCompare));
|
|
2381
2393
|
}
|
|
2382
2394
|
if (parameters.stencilWriteMask) {
|
|
2383
2395
|
const mask = parameters.stencilWriteMask;
|
|
2384
|
-
gl2.stencilMaskSeparate(
|
|
2385
|
-
gl2.stencilMaskSeparate(
|
|
2396
|
+
gl2.stencilMaskSeparate(import_constants8.GL.FRONT, mask);
|
|
2397
|
+
gl2.stencilMaskSeparate(import_constants8.GL.BACK, mask);
|
|
2386
2398
|
}
|
|
2387
2399
|
if (parameters.stencilReadMask) {
|
|
2388
2400
|
import_core6.log.warn("stencilReadMask not supported under WebGL");
|
|
@@ -2390,9 +2402,9 @@ function setDeviceParameters(device, parameters) {
|
|
|
2390
2402
|
if (parameters.stencilCompare) {
|
|
2391
2403
|
const mask = parameters.stencilReadMask || 4294967295;
|
|
2392
2404
|
const glValue = convertCompareFunction("depthCompare", parameters.stencilCompare);
|
|
2393
|
-
parameters.stencilCompare !== "always" ? gl2.enable(
|
|
2394
|
-
gl2.stencilFuncSeparate(
|
|
2395
|
-
gl2.stencilFuncSeparate(
|
|
2405
|
+
parameters.stencilCompare !== "always" ? gl2.enable(import_constants8.GL.STENCIL_TEST) : gl2.disable(import_constants8.GL.STENCIL_TEST);
|
|
2406
|
+
gl2.stencilFuncSeparate(import_constants8.GL.FRONT, glValue, 0, mask);
|
|
2407
|
+
gl2.stencilFuncSeparate(import_constants8.GL.BACK, glValue, 0, mask);
|
|
2396
2408
|
}
|
|
2397
2409
|
if (parameters.stencilPassOperation && parameters.stencilFailOperation && parameters.stencilDepthFailOperation) {
|
|
2398
2410
|
const dppass = convertStencilOperation("stencilPassOperation", parameters.stencilPassOperation);
|
|
@@ -2401,32 +2413,32 @@ function setDeviceParameters(device, parameters) {
|
|
|
2401
2413
|
"stencilDepthFailOperation",
|
|
2402
2414
|
parameters.stencilDepthFailOperation
|
|
2403
2415
|
);
|
|
2404
|
-
gl2.stencilOpSeparate(
|
|
2405
|
-
gl2.stencilOpSeparate(
|
|
2416
|
+
gl2.stencilOpSeparate(import_constants8.GL.FRONT, sfail, dpfail, dppass);
|
|
2417
|
+
gl2.stencilOpSeparate(import_constants8.GL.BACK, sfail, dpfail, dppass);
|
|
2406
2418
|
}
|
|
2407
2419
|
}
|
|
2408
2420
|
function convertCompareFunction(parameter, value) {
|
|
2409
2421
|
return map(parameter, value, {
|
|
2410
|
-
never:
|
|
2411
|
-
less:
|
|
2412
|
-
equal:
|
|
2413
|
-
"less-equal":
|
|
2414
|
-
greater:
|
|
2415
|
-
"not-equal":
|
|
2416
|
-
"greater-equal":
|
|
2417
|
-
always:
|
|
2422
|
+
never: import_constants8.GL.NEVER,
|
|
2423
|
+
less: import_constants8.GL.LESS,
|
|
2424
|
+
equal: import_constants8.GL.EQUAL,
|
|
2425
|
+
"less-equal": import_constants8.GL.LEQUAL,
|
|
2426
|
+
greater: import_constants8.GL.GREATER,
|
|
2427
|
+
"not-equal": import_constants8.GL.NOTEQUAL,
|
|
2428
|
+
"greater-equal": import_constants8.GL.GEQUAL,
|
|
2429
|
+
always: import_constants8.GL.ALWAYS
|
|
2418
2430
|
});
|
|
2419
2431
|
}
|
|
2420
2432
|
function convertStencilOperation(parameter, value) {
|
|
2421
2433
|
return map(parameter, value, {
|
|
2422
|
-
keep:
|
|
2423
|
-
zero:
|
|
2424
|
-
replace:
|
|
2425
|
-
invert:
|
|
2426
|
-
"increment-clamp":
|
|
2427
|
-
"decrement-clamp":
|
|
2428
|
-
"increment-wrap":
|
|
2429
|
-
"decrement-wrap":
|
|
2434
|
+
keep: import_constants8.GL.KEEP,
|
|
2435
|
+
zero: import_constants8.GL.ZERO,
|
|
2436
|
+
replace: import_constants8.GL.REPLACE,
|
|
2437
|
+
invert: import_constants8.GL.INVERT,
|
|
2438
|
+
"increment-clamp": import_constants8.GL.INCR,
|
|
2439
|
+
"decrement-clamp": import_constants8.GL.DECR,
|
|
2440
|
+
"increment-wrap": import_constants8.GL.INCR_WRAP,
|
|
2441
|
+
"decrement-wrap": import_constants8.GL.DECR_WRAP
|
|
2430
2442
|
});
|
|
2431
2443
|
}
|
|
2432
2444
|
function message(parameter, value) {
|
|
@@ -2446,53 +2458,53 @@ function mapBoolean(parameter, value) {
|
|
|
2446
2458
|
function convertSamplerParametersToWebGL(props) {
|
|
2447
2459
|
const params = {};
|
|
2448
2460
|
if (props.addressModeU) {
|
|
2449
|
-
params[
|
|
2461
|
+
params[import_constants9.GL.TEXTURE_WRAP_S] = convertAddressMode(props.addressModeU);
|
|
2450
2462
|
}
|
|
2451
2463
|
if (props.addressModeV) {
|
|
2452
|
-
params[
|
|
2464
|
+
params[import_constants9.GL.TEXTURE_WRAP_T] = convertAddressMode(props.addressModeV);
|
|
2453
2465
|
}
|
|
2454
2466
|
if (props.addressModeW) {
|
|
2455
|
-
params[
|
|
2467
|
+
params[import_constants9.GL.TEXTURE_WRAP_R] = convertAddressMode(props.addressModeW);
|
|
2456
2468
|
}
|
|
2457
2469
|
if (props.magFilter) {
|
|
2458
|
-
params[
|
|
2470
|
+
params[import_constants9.GL.TEXTURE_MAG_FILTER] = convertMaxFilterMode(props.magFilter);
|
|
2459
2471
|
}
|
|
2460
2472
|
if (props.minFilter || props.mipmapFilter) {
|
|
2461
|
-
params[
|
|
2473
|
+
params[import_constants9.GL.TEXTURE_MIN_FILTER] = convertMinFilterMode(props.minFilter || "linear", props.mipmapFilter);
|
|
2462
2474
|
}
|
|
2463
2475
|
if (props.lodMinClamp !== void 0) {
|
|
2464
|
-
params[
|
|
2476
|
+
params[import_constants9.GL.TEXTURE_MIN_LOD] = props.lodMinClamp;
|
|
2465
2477
|
}
|
|
2466
2478
|
if (props.lodMaxClamp !== void 0) {
|
|
2467
|
-
params[
|
|
2479
|
+
params[import_constants9.GL.TEXTURE_MAX_LOD] = props.lodMaxClamp;
|
|
2468
2480
|
}
|
|
2469
2481
|
if (props.type === "comparison-sampler") {
|
|
2470
|
-
params[
|
|
2482
|
+
params[import_constants9.GL.TEXTURE_COMPARE_MODE] = import_constants9.GL.COMPARE_REF_TO_TEXTURE;
|
|
2471
2483
|
}
|
|
2472
2484
|
if (props.compare) {
|
|
2473
|
-
params[
|
|
2485
|
+
params[import_constants9.GL.TEXTURE_COMPARE_FUNC] = convertCompareFunction("compare", props.compare);
|
|
2474
2486
|
}
|
|
2475
2487
|
if (props.maxAnisotropy) {
|
|
2476
|
-
params[
|
|
2488
|
+
params[import_constants9.GL.TEXTURE_MAX_ANISOTROPY_EXT] = props.maxAnisotropy;
|
|
2477
2489
|
}
|
|
2478
2490
|
return params;
|
|
2479
2491
|
}
|
|
2480
2492
|
function convertAddressMode(addressMode) {
|
|
2481
2493
|
switch (addressMode) {
|
|
2482
2494
|
case "clamp-to-edge":
|
|
2483
|
-
return
|
|
2495
|
+
return import_constants9.GL.CLAMP_TO_EDGE;
|
|
2484
2496
|
case "repeat":
|
|
2485
|
-
return
|
|
2497
|
+
return import_constants9.GL.REPEAT;
|
|
2486
2498
|
case "mirror-repeat":
|
|
2487
|
-
return
|
|
2499
|
+
return import_constants9.GL.MIRRORED_REPEAT;
|
|
2488
2500
|
}
|
|
2489
2501
|
}
|
|
2490
2502
|
function convertMaxFilterMode(maxFilter) {
|
|
2491
2503
|
switch (maxFilter) {
|
|
2492
2504
|
case "nearest":
|
|
2493
|
-
return
|
|
2505
|
+
return import_constants9.GL.NEAREST;
|
|
2494
2506
|
case "linear":
|
|
2495
|
-
return
|
|
2507
|
+
return import_constants9.GL.LINEAR;
|
|
2496
2508
|
}
|
|
2497
2509
|
}
|
|
2498
2510
|
function convertMinFilterMode(minFilter, mipmapFilter) {
|
|
@@ -2501,30 +2513,30 @@ function convertMinFilterMode(minFilter, mipmapFilter) {
|
|
|
2501
2513
|
}
|
|
2502
2514
|
switch (minFilter) {
|
|
2503
2515
|
case "nearest":
|
|
2504
|
-
return mipmapFilter === "nearest" ?
|
|
2516
|
+
return mipmapFilter === "nearest" ? import_constants9.GL.NEAREST_MIPMAP_NEAREST : import_constants9.GL.NEAREST_MIPMAP_LINEAR;
|
|
2505
2517
|
case "linear":
|
|
2506
|
-
return mipmapFilter === "nearest" ?
|
|
2518
|
+
return mipmapFilter === "nearest" ? import_constants9.GL.LINEAR_MIPMAP_NEAREST : import_constants9.GL.LINEAR_MIPMAP_LINEAR;
|
|
2507
2519
|
}
|
|
2508
2520
|
}
|
|
2509
2521
|
function updateSamplerParametersForNPOT(parameters) {
|
|
2510
2522
|
const newParameters = __spreadValues({}, parameters);
|
|
2511
|
-
if (parameters[
|
|
2512
|
-
newParameters[
|
|
2523
|
+
if (parameters[import_constants9.GL.TEXTURE_MIN_FILTER] !== import_constants9.GL.NEAREST) {
|
|
2524
|
+
newParameters[import_constants9.GL.TEXTURE_MIN_FILTER] = import_constants9.GL.LINEAR;
|
|
2513
2525
|
}
|
|
2514
|
-
newParameters[
|
|
2515
|
-
newParameters[
|
|
2526
|
+
newParameters[import_constants9.GL.TEXTURE_WRAP_S] = import_constants9.GL.CLAMP_TO_EDGE;
|
|
2527
|
+
newParameters[import_constants9.GL.TEXTURE_WRAP_T] = import_constants9.GL.CLAMP_TO_EDGE;
|
|
2516
2528
|
return newParameters;
|
|
2517
2529
|
}
|
|
2518
2530
|
|
|
2519
2531
|
// src/adapter/resources/webgl-buffer.ts
|
|
2520
2532
|
var import_core7 = require("@luma.gl/core");
|
|
2521
|
-
var
|
|
2533
|
+
var import_constants10 = require("@luma.gl/constants");
|
|
2522
2534
|
var DEBUG_DATA_LENGTH = 10;
|
|
2523
2535
|
var WEBGLBuffer = class extends import_core7.Buffer {
|
|
2524
2536
|
constructor(device, props = {}) {
|
|
2525
2537
|
super(device, props);
|
|
2526
2538
|
/** Index type is needed when issuing draw calls, so we pre-compute it */
|
|
2527
|
-
this.glIndexType =
|
|
2539
|
+
this.glIndexType = import_constants10.GL.UNSIGNED_SHORT;
|
|
2528
2540
|
/** A partial CPU-side copy of the data in this buffer, for debugging purposes */
|
|
2529
2541
|
this.debugData = null;
|
|
2530
2542
|
this.device = device;
|
|
@@ -2535,7 +2547,7 @@ var WEBGLBuffer = class extends import_core7.Buffer {
|
|
|
2535
2547
|
device.setSpectorMetadata(this.handle, __spreadProps(__spreadValues({}, this.props), { data: typeof this.props.data }));
|
|
2536
2548
|
this.glTarget = getWebGLTarget(this.props.usage);
|
|
2537
2549
|
this.glUsage = getWebGLUsage(this.props.usage);
|
|
2538
|
-
this.glIndexType = this.props.indexType === "uint32" ?
|
|
2550
|
+
this.glIndexType = this.props.indexType === "uint32" ? import_constants10.GL.UNSIGNED_INT : import_constants10.GL.UNSIGNED_SHORT;
|
|
2539
2551
|
this.debugData = null;
|
|
2540
2552
|
if (props.data) {
|
|
2541
2553
|
this._initWithData(props.data, props.byteOffset, props.byteLength);
|
|
@@ -2586,7 +2598,7 @@ var WEBGLBuffer = class extends import_core7.Buffer {
|
|
|
2586
2598
|
write(data, byteOffset = 0) {
|
|
2587
2599
|
const srcOffset = 0;
|
|
2588
2600
|
const byteLength = void 0;
|
|
2589
|
-
const glTarget = this.device.isWebGL2 ?
|
|
2601
|
+
const glTarget = this.device.isWebGL2 ? import_constants10.GL.COPY_WRITE_BUFFER : this.glTarget;
|
|
2590
2602
|
this.gl.bindBuffer(glTarget, this.handle);
|
|
2591
2603
|
if (srcOffset !== 0 || byteLength !== void 0) {
|
|
2592
2604
|
this.device.assertWebGL2();
|
|
@@ -2602,9 +2614,9 @@ var WEBGLBuffer = class extends import_core7.Buffer {
|
|
|
2602
2614
|
this.device.assertWebGL2();
|
|
2603
2615
|
const data = new Uint8Array(byteLength);
|
|
2604
2616
|
const dstOffset = 0;
|
|
2605
|
-
this.gl.bindBuffer(
|
|
2606
|
-
this.gl2.getBufferSubData(
|
|
2607
|
-
this.gl.bindBuffer(
|
|
2617
|
+
this.gl.bindBuffer(import_constants10.GL.COPY_READ_BUFFER, this.handle);
|
|
2618
|
+
this.gl2.getBufferSubData(import_constants10.GL.COPY_READ_BUFFER, byteOffset, data, dstOffset, byteLength);
|
|
2619
|
+
this.gl.bindBuffer(import_constants10.GL.COPY_READ_BUFFER, null);
|
|
2608
2620
|
return data;
|
|
2609
2621
|
});
|
|
2610
2622
|
}
|
|
@@ -2621,32 +2633,32 @@ var WEBGLBuffer = class extends import_core7.Buffer {
|
|
|
2621
2633
|
};
|
|
2622
2634
|
function getWebGLTarget(usage) {
|
|
2623
2635
|
if (usage & import_core7.Buffer.INDEX) {
|
|
2624
|
-
return
|
|
2636
|
+
return import_constants10.GL.ELEMENT_ARRAY_BUFFER;
|
|
2625
2637
|
}
|
|
2626
2638
|
if (usage & import_core7.Buffer.VERTEX) {
|
|
2627
|
-
return
|
|
2639
|
+
return import_constants10.GL.ARRAY_BUFFER;
|
|
2628
2640
|
}
|
|
2629
2641
|
if (usage & import_core7.Buffer.UNIFORM) {
|
|
2630
|
-
return
|
|
2642
|
+
return import_constants10.GL.UNIFORM_BUFFER;
|
|
2631
2643
|
}
|
|
2632
|
-
return
|
|
2644
|
+
return import_constants10.GL.ARRAY_BUFFER;
|
|
2633
2645
|
}
|
|
2634
2646
|
function getWebGLUsage(usage) {
|
|
2635
2647
|
if (usage & import_core7.Buffer.INDEX) {
|
|
2636
|
-
return
|
|
2648
|
+
return import_constants10.GL.STATIC_DRAW;
|
|
2637
2649
|
}
|
|
2638
2650
|
if (usage & import_core7.Buffer.VERTEX) {
|
|
2639
|
-
return
|
|
2651
|
+
return import_constants10.GL.STATIC_DRAW;
|
|
2640
2652
|
}
|
|
2641
2653
|
if (usage & import_core7.Buffer.UNIFORM) {
|
|
2642
|
-
return
|
|
2654
|
+
return import_constants10.GL.DYNAMIC_DRAW;
|
|
2643
2655
|
}
|
|
2644
|
-
return
|
|
2656
|
+
return import_constants10.GL.STATIC_DRAW;
|
|
2645
2657
|
}
|
|
2646
2658
|
|
|
2647
2659
|
// src/adapter/resources/webgl-sampler.ts
|
|
2648
2660
|
var import_core8 = require("@luma.gl/core");
|
|
2649
|
-
var
|
|
2661
|
+
var import_constants11 = require("@luma.gl/constants");
|
|
2650
2662
|
var WEBGLSampler = class extends import_core8.Sampler {
|
|
2651
2663
|
constructor(device, props) {
|
|
2652
2664
|
super(device, props);
|
|
@@ -2671,8 +2683,8 @@ var WEBGLSampler = class extends import_core8.Sampler {
|
|
|
2671
2683
|
for (const [pname, value] of Object.entries(parameters)) {
|
|
2672
2684
|
const param = Number(pname);
|
|
2673
2685
|
switch (param) {
|
|
2674
|
-
case
|
|
2675
|
-
case
|
|
2686
|
+
case import_constants11.GL.TEXTURE_MIN_LOD:
|
|
2687
|
+
case import_constants11.GL.TEXTURE_MAX_LOD:
|
|
2676
2688
|
this.device.gl2.samplerParameterf(this.handle, param, value);
|
|
2677
2689
|
break;
|
|
2678
2690
|
default:
|
|
@@ -2717,7 +2729,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
2717
2729
|
this.gl2 = this.device.gl2;
|
|
2718
2730
|
this.handle = this.props.handle || this.gl.createTexture();
|
|
2719
2731
|
this.device.setSpectorMetadata(this.handle, __spreadProps(__spreadValues({}, this.props), { data: typeof this.props.data }));
|
|
2720
|
-
this.glFormat =
|
|
2732
|
+
this.glFormat = import_constants12.GL.RGBA;
|
|
2721
2733
|
this.target = getWebGLTextureTarget(this.props);
|
|
2722
2734
|
this.loaded = false;
|
|
2723
2735
|
if (typeof ((_a = this.props) == null ? void 0 : _a.data) === "string") {
|
|
@@ -2788,7 +2800,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
2788
2800
|
this.dataFormat = dataFormat;
|
|
2789
2801
|
this.textureUnit = textureUnit;
|
|
2790
2802
|
if (Number.isFinite(this.textureUnit)) {
|
|
2791
|
-
this.gl.activeTexture(
|
|
2803
|
+
this.gl.activeTexture(import_constants12.GL.TEXTURE0 + this.textureUnit);
|
|
2792
2804
|
this.gl.bindTexture(this.target, this.handle);
|
|
2793
2805
|
}
|
|
2794
2806
|
if (mipmaps && this.device.isWebGL1 && isNPOT(this.width, this.height)) {
|
|
@@ -2979,7 +2991,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
2979
2991
|
break;
|
|
2980
2992
|
case "buffer":
|
|
2981
2993
|
gl22 = this.device.assertWebGL2();
|
|
2982
|
-
gl22.bindBuffer(
|
|
2994
|
+
gl22.bindBuffer(import_constants12.GL.PIXEL_UNPACK_BUFFER, data.handle || data);
|
|
2983
2995
|
gl22.texImage2D(
|
|
2984
2996
|
target,
|
|
2985
2997
|
level,
|
|
@@ -2991,7 +3003,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
2991
3003
|
type,
|
|
2992
3004
|
offset
|
|
2993
3005
|
);
|
|
2994
|
-
gl22.bindBuffer(
|
|
3006
|
+
gl22.bindBuffer(import_constants12.GL.PIXEL_UNPACK_BUFFER, null);
|
|
2995
3007
|
break;
|
|
2996
3008
|
case "browser-object":
|
|
2997
3009
|
if (this.device.isWebGL2) {
|
|
@@ -3089,9 +3101,9 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3089
3101
|
this.gl.texSubImage2D(target, level, x, y, width, height, dataFormat, type, data, offset);
|
|
3090
3102
|
} else if (typeof WebGLBuffer !== "undefined" && data instanceof WebGLBuffer) {
|
|
3091
3103
|
const gl2 = this.device.assertWebGL2();
|
|
3092
|
-
gl2.bindBuffer(
|
|
3104
|
+
gl2.bindBuffer(import_constants12.GL.PIXEL_UNPACK_BUFFER, data);
|
|
3093
3105
|
gl2.texSubImage2D(target, level, x, y, width, height, dataFormat, type, offset);
|
|
3094
|
-
gl2.bindBuffer(
|
|
3106
|
+
gl2.bindBuffer(import_constants12.GL.PIXEL_UNPACK_BUFFER, null);
|
|
3095
3107
|
} else if (this.device.isWebGL2) {
|
|
3096
3108
|
const gl2 = this.device.assertWebGL2();
|
|
3097
3109
|
gl2.texSubImage2D(target, level, x, y, width, height, dataFormat, type, data);
|
|
@@ -3116,7 +3128,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3116
3128
|
return null;
|
|
3117
3129
|
}
|
|
3118
3130
|
getActiveUnit() {
|
|
3119
|
-
return this.gl.getParameter(
|
|
3131
|
+
return this.gl.getParameter(import_constants12.GL.ACTIVE_TEXTURE) - import_constants12.GL.TEXTURE0;
|
|
3120
3132
|
}
|
|
3121
3133
|
bind(textureUnit = this.textureUnit) {
|
|
3122
3134
|
const { gl: gl2 } = this;
|
|
@@ -3200,7 +3212,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3200
3212
|
setCubeMapImageData(options) {
|
|
3201
3213
|
return __async(this, null, function* () {
|
|
3202
3214
|
const { gl: gl2 } = this;
|
|
3203
|
-
const { width, height, pixels, data, format =
|
|
3215
|
+
const { width, height, pixels, data, format = import_constants12.GL.RGBA, type = import_constants12.GL.UNSIGNED_BYTE } = options;
|
|
3204
3216
|
const imageDataMap = pixels || data;
|
|
3205
3217
|
const resolvedFaces = yield Promise.all(
|
|
3206
3218
|
_WEBGLTexture.FACES.map((face) => {
|
|
@@ -3232,8 +3244,8 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3232
3244
|
height,
|
|
3233
3245
|
pixels,
|
|
3234
3246
|
data,
|
|
3235
|
-
format =
|
|
3236
|
-
type =
|
|
3247
|
+
format = import_constants12.GL.RGBA,
|
|
3248
|
+
type = import_constants12.GL.UNSIGNED_BYTE
|
|
3237
3249
|
// generateMipmap = false // TODO
|
|
3238
3250
|
} = options;
|
|
3239
3251
|
const { gl: gl2 } = this;
|
|
@@ -3291,7 +3303,7 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3291
3303
|
);
|
|
3292
3304
|
}
|
|
3293
3305
|
if (data instanceof WEBGLBuffer) {
|
|
3294
|
-
this.gl.bindBuffer(
|
|
3306
|
+
this.gl.bindBuffer(import_constants12.GL.PIXEL_UNPACK_BUFFER, data.handle);
|
|
3295
3307
|
this.gl.texImage3D(
|
|
3296
3308
|
this.target,
|
|
3297
3309
|
level,
|
|
@@ -3333,8 +3345,8 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3333
3345
|
const param = Number(pname);
|
|
3334
3346
|
const value = pvalue;
|
|
3335
3347
|
switch (param) {
|
|
3336
|
-
case
|
|
3337
|
-
case
|
|
3348
|
+
case import_constants12.GL.TEXTURE_MIN_LOD:
|
|
3349
|
+
case import_constants12.GL.TEXTURE_MAX_LOD:
|
|
3338
3350
|
this.gl.texParameterf(this.target, param, value);
|
|
3339
3351
|
break;
|
|
3340
3352
|
default:
|
|
@@ -3350,14 +3362,14 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3350
3362
|
const npot = this.device.isWebGL1 && isNPOT(this.width, this.height);
|
|
3351
3363
|
if (npot) {
|
|
3352
3364
|
switch (pname) {
|
|
3353
|
-
case
|
|
3354
|
-
if (value !==
|
|
3355
|
-
return
|
|
3365
|
+
case import_constants12.GL.TEXTURE_MIN_FILTER:
|
|
3366
|
+
if (value !== import_constants12.GL.LINEAR && value !== import_constants12.GL.NEAREST) {
|
|
3367
|
+
return import_constants12.GL.LINEAR;
|
|
3356
3368
|
}
|
|
3357
3369
|
break;
|
|
3358
|
-
case
|
|
3359
|
-
case
|
|
3360
|
-
return
|
|
3370
|
+
case import_constants12.GL.TEXTURE_WRAP_S:
|
|
3371
|
+
case import_constants12.GL.TEXTURE_WRAP_T:
|
|
3372
|
+
return import_constants12.GL.CLAMP_TO_EDGE;
|
|
3361
3373
|
default:
|
|
3362
3374
|
break;
|
|
3363
3375
|
}
|
|
@@ -3368,23 +3380,23 @@ var _WEBGLTexture = class extends import_core10.Texture {
|
|
|
3368
3380
|
var WEBGLTexture = _WEBGLTexture;
|
|
3369
3381
|
// TODO - remove?
|
|
3370
3382
|
WEBGLTexture.FACES = [
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3383
|
+
import_constants12.GL.TEXTURE_CUBE_MAP_POSITIVE_X,
|
|
3384
|
+
import_constants12.GL.TEXTURE_CUBE_MAP_NEGATIVE_X,
|
|
3385
|
+
import_constants12.GL.TEXTURE_CUBE_MAP_POSITIVE_Y,
|
|
3386
|
+
import_constants12.GL.TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
|
3387
|
+
import_constants12.GL.TEXTURE_CUBE_MAP_POSITIVE_Z,
|
|
3388
|
+
import_constants12.GL.TEXTURE_CUBE_MAP_NEGATIVE_Z
|
|
3377
3389
|
];
|
|
3378
3390
|
function getWebGLTextureTarget(props) {
|
|
3379
3391
|
switch (props.dimension) {
|
|
3380
3392
|
case "2d":
|
|
3381
|
-
return
|
|
3393
|
+
return import_constants12.GL.TEXTURE_2D;
|
|
3382
3394
|
case "cube":
|
|
3383
|
-
return
|
|
3395
|
+
return import_constants12.GL.TEXTURE_CUBE_MAP;
|
|
3384
3396
|
case "2d-array":
|
|
3385
|
-
return
|
|
3397
|
+
return import_constants12.GL.TEXTURE_2D_ARRAY;
|
|
3386
3398
|
case "3d":
|
|
3387
|
-
return
|
|
3399
|
+
return import_constants12.GL.TEXTURE_3D;
|
|
3388
3400
|
case "1d":
|
|
3389
3401
|
case "cube-array":
|
|
3390
3402
|
default:
|
|
@@ -3403,24 +3415,24 @@ function logParameters(parameters) {
|
|
|
3403
3415
|
|
|
3404
3416
|
// src/adapter/objects/webgl-renderbuffer.ts
|
|
3405
3417
|
var import_core13 = require("@luma.gl/core");
|
|
3406
|
-
var
|
|
3418
|
+
var import_constants13 = require("@luma.gl/constants");
|
|
3407
3419
|
|
|
3408
3420
|
// src/adapter/objects/webgl-resource.ts
|
|
3409
3421
|
var import_core12 = require("@luma.gl/core");
|
|
3410
3422
|
|
|
3411
3423
|
// src/adapter/objects/constants-to-keys.ts
|
|
3412
3424
|
var import_core11 = require("@luma.gl/core");
|
|
3413
|
-
function getKeyValue(gl2,
|
|
3414
|
-
if (typeof
|
|
3415
|
-
return
|
|
3425
|
+
function getKeyValue(gl2, name2) {
|
|
3426
|
+
if (typeof name2 !== "string") {
|
|
3427
|
+
return name2;
|
|
3416
3428
|
}
|
|
3417
|
-
const number = Number(
|
|
3429
|
+
const number = Number(name2);
|
|
3418
3430
|
if (!isNaN(number)) {
|
|
3419
3431
|
return number;
|
|
3420
3432
|
}
|
|
3421
|
-
|
|
3422
|
-
const value = gl2[
|
|
3423
|
-
(0, import_core11.assert)(value !== void 0, `Accessing undefined constant GL.${
|
|
3433
|
+
name2 = name2.replace(/^.*\./, "");
|
|
3434
|
+
const value = gl2[name2];
|
|
3435
|
+
(0, import_core11.assert)(value !== void 0, `Accessing undefined constant GL.${name2}`);
|
|
3424
3436
|
return value;
|
|
3425
3437
|
}
|
|
3426
3438
|
|
|
@@ -3669,13 +3681,13 @@ var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
|
3669
3681
|
const { format, width, height, samples } = props;
|
|
3670
3682
|
(0, import_core13.assert)(format, "Needs format");
|
|
3671
3683
|
this.trackDeallocatedMemory();
|
|
3672
|
-
this.gl.bindRenderbuffer(
|
|
3684
|
+
this.gl.bindRenderbuffer(import_constants13.GL.RENDERBUFFER, this.handle);
|
|
3673
3685
|
if (samples !== 0 && this.device.isWebGL2) {
|
|
3674
|
-
this.gl2.renderbufferStorageMultisample(
|
|
3686
|
+
this.gl2.renderbufferStorageMultisample(import_constants13.GL.RENDERBUFFER, samples, this.glFormat, width, height);
|
|
3675
3687
|
} else {
|
|
3676
|
-
this.gl.renderbufferStorage(
|
|
3688
|
+
this.gl.renderbufferStorage(import_constants13.GL.RENDERBUFFER, this.glFormat, width, height);
|
|
3677
3689
|
}
|
|
3678
|
-
this.gl.bindRenderbuffer(
|
|
3690
|
+
this.gl.bindRenderbuffer(import_constants13.GL.RENDERBUFFER, null);
|
|
3679
3691
|
this.trackAllocatedMemory(
|
|
3680
3692
|
width * height * (samples || 1) * getTextureFormatBytesPerPixel(this.glFormat, this.device.isWebGL2)
|
|
3681
3693
|
);
|
|
@@ -3689,7 +3701,7 @@ var _WEBGLRenderbuffer = class extends WebGLResource {
|
|
|
3689
3701
|
this.trackDeallocatedMemory();
|
|
3690
3702
|
}
|
|
3691
3703
|
_bindHandle(handle) {
|
|
3692
|
-
this.gl.bindRenderbuffer(
|
|
3704
|
+
this.gl.bindRenderbuffer(import_constants13.GL.RENDERBUFFER, handle);
|
|
3693
3705
|
}
|
|
3694
3706
|
};
|
|
3695
3707
|
var WEBGLRenderbuffer = _WEBGLRenderbuffer;
|
|
@@ -3715,10 +3727,10 @@ var WEBGLFramebuffer = class extends import_core14.Framebuffer {
|
|
|
3715
3727
|
if (!isDefaultFramebuffer) {
|
|
3716
3728
|
device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
|
|
3717
3729
|
this.autoCreateAttachmentTextures();
|
|
3718
|
-
this.gl.bindFramebuffer(
|
|
3730
|
+
this.gl.bindFramebuffer(import_constants14.GL.FRAMEBUFFER, this.handle);
|
|
3719
3731
|
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
3720
3732
|
const attachment = this.colorAttachments[i];
|
|
3721
|
-
const attachmentPoint =
|
|
3733
|
+
const attachmentPoint = import_constants14.GL.COLOR_ATTACHMENT0 + i;
|
|
3722
3734
|
if (attachment) {
|
|
3723
3735
|
this._attachOne(attachmentPoint, attachment);
|
|
3724
3736
|
}
|
|
@@ -3729,7 +3741,7 @@ var WEBGLFramebuffer = class extends import_core14.Framebuffer {
|
|
|
3729
3741
|
this.depthStencilAttachment
|
|
3730
3742
|
);
|
|
3731
3743
|
}
|
|
3732
|
-
this.gl.bindFramebuffer(
|
|
3744
|
+
this.gl.bindFramebuffer(import_constants14.GL.FRAMEBUFFER, null);
|
|
3733
3745
|
}
|
|
3734
3746
|
if (props.check !== false) {
|
|
3735
3747
|
this._checkStatus();
|
|
@@ -3749,9 +3761,9 @@ var WEBGLFramebuffer = class extends import_core14.Framebuffer {
|
|
|
3749
3761
|
/** Check the status */
|
|
3750
3762
|
_checkStatus() {
|
|
3751
3763
|
const { gl: gl2 } = this;
|
|
3752
|
-
const prevHandle2 = gl2.bindFramebuffer(
|
|
3753
|
-
const status = gl2.checkFramebufferStatus(
|
|
3754
|
-
gl2.bindFramebuffer(
|
|
3764
|
+
const prevHandle2 = gl2.bindFramebuffer(import_constants14.GL.FRAMEBUFFER, this.handle);
|
|
3765
|
+
const status = gl2.checkFramebufferStatus(import_constants14.GL.FRAMEBUFFER);
|
|
3766
|
+
gl2.bindFramebuffer(import_constants14.GL.FRAMEBUFFER, prevHandle2 || null);
|
|
3755
3767
|
if (status !== gl2.FRAMEBUFFER_COMPLETE) {
|
|
3756
3768
|
throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
|
|
3757
3769
|
}
|
|
@@ -3808,9 +3820,9 @@ var WEBGLFramebuffer = class extends import_core14.Framebuffer {
|
|
|
3808
3820
|
}
|
|
3809
3821
|
_attachWEBGLRenderbuffer(attachment, renderbuffer) {
|
|
3810
3822
|
this.gl.framebufferRenderbuffer(
|
|
3811
|
-
|
|
3823
|
+
import_constants14.GL.FRAMEBUFFER,
|
|
3812
3824
|
attachment,
|
|
3813
|
-
|
|
3825
|
+
import_constants14.GL.RENDERBUFFER,
|
|
3814
3826
|
renderbuffer.handle
|
|
3815
3827
|
);
|
|
3816
3828
|
}
|
|
@@ -3824,17 +3836,17 @@ var WEBGLFramebuffer = class extends import_core14.Framebuffer {
|
|
|
3824
3836
|
const { gl: gl2, gl2: gl22 } = this.device;
|
|
3825
3837
|
gl2.bindTexture(texture.target, texture.handle);
|
|
3826
3838
|
switch (texture.target) {
|
|
3827
|
-
case
|
|
3828
|
-
case
|
|
3839
|
+
case import_constants14.GL.TEXTURE_2D_ARRAY:
|
|
3840
|
+
case import_constants14.GL.TEXTURE_3D:
|
|
3829
3841
|
this.device.assertWebGL2();
|
|
3830
|
-
gl22 == null ? void 0 : gl22.framebufferTextureLayer(
|
|
3842
|
+
gl22 == null ? void 0 : gl22.framebufferTextureLayer(import_constants14.GL.FRAMEBUFFER, attachment, texture.target, level, layer);
|
|
3831
3843
|
break;
|
|
3832
|
-
case
|
|
3844
|
+
case import_constants14.GL.TEXTURE_CUBE_MAP:
|
|
3833
3845
|
const face = mapIndexToCubeMapFace(layer);
|
|
3834
|
-
gl2.framebufferTexture2D(
|
|
3846
|
+
gl2.framebufferTexture2D(import_constants14.GL.FRAMEBUFFER, attachment, face, texture.handle, level);
|
|
3835
3847
|
break;
|
|
3836
|
-
case
|
|
3837
|
-
gl2.framebufferTexture2D(
|
|
3848
|
+
case import_constants14.GL.TEXTURE_2D:
|
|
3849
|
+
gl2.framebufferTexture2D(import_constants14.GL.FRAMEBUFFER, attachment, import_constants14.GL.TEXTURE_2D, texture.handle, level);
|
|
3838
3850
|
break;
|
|
3839
3851
|
default:
|
|
3840
3852
|
(0, import_core14.assert)(false, "Illegal texture type");
|
|
@@ -3843,21 +3855,21 @@ var WEBGLFramebuffer = class extends import_core14.Framebuffer {
|
|
|
3843
3855
|
}
|
|
3844
3856
|
};
|
|
3845
3857
|
function mapIndexToCubeMapFace(layer) {
|
|
3846
|
-
return layer <
|
|
3858
|
+
return layer < import_constants14.GL.TEXTURE_CUBE_MAP_POSITIVE_X ? layer + import_constants14.GL.TEXTURE_CUBE_MAP_POSITIVE_X : layer;
|
|
3847
3859
|
}
|
|
3848
3860
|
function _getFrameBufferStatus(status) {
|
|
3849
3861
|
switch (status) {
|
|
3850
|
-
case
|
|
3862
|
+
case import_constants14.GL.FRAMEBUFFER_COMPLETE:
|
|
3851
3863
|
return "success";
|
|
3852
|
-
case
|
|
3864
|
+
case import_constants14.GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
|
3853
3865
|
return "Mismatched attachments";
|
|
3854
|
-
case
|
|
3866
|
+
case import_constants14.GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
|
3855
3867
|
return "No attachments";
|
|
3856
|
-
case
|
|
3868
|
+
case import_constants14.GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
|
|
3857
3869
|
return "Height/width mismatch";
|
|
3858
|
-
case
|
|
3870
|
+
case import_constants14.GL.FRAMEBUFFER_UNSUPPORTED:
|
|
3859
3871
|
return "Unsupported or split attachments";
|
|
3860
|
-
case
|
|
3872
|
+
case import_constants14.GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
|
|
3861
3873
|
return "Samples mismatch";
|
|
3862
3874
|
default:
|
|
3863
3875
|
return `${status}`;
|
|
@@ -3975,7 +3987,7 @@ function initializeSpectorJS(props) {
|
|
|
3975
3987
|
|
|
3976
3988
|
// src/context/debug/webgl-developer-tools.ts
|
|
3977
3989
|
var import_core17 = require("@luma.gl/core");
|
|
3978
|
-
var
|
|
3990
|
+
var import_constants15 = require("@luma.gl/constants");
|
|
3979
3991
|
var import_env = require("@probe.gl/env");
|
|
3980
3992
|
var WEBGL_DEBUG_CDN_URL = "https://unpkg.com/webgl-debug@2.0.1/index.js";
|
|
3981
3993
|
function getContextData2(gl2) {
|
|
@@ -4010,15 +4022,15 @@ function getDebugContext(gl2, props) {
|
|
|
4010
4022
|
if (data.debugContext) {
|
|
4011
4023
|
return data.debugContext;
|
|
4012
4024
|
}
|
|
4013
|
-
globalThis.WebGLDebugUtils.init(__spreadValues(__spreadValues({},
|
|
4025
|
+
globalThis.WebGLDebugUtils.init(__spreadValues(__spreadValues({}, import_constants15.GL), gl2));
|
|
4014
4026
|
const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(
|
|
4015
4027
|
gl2,
|
|
4016
4028
|
onGLError.bind(null, props),
|
|
4017
4029
|
onValidateGLFunc.bind(null, props)
|
|
4018
4030
|
);
|
|
4019
|
-
for (const key in
|
|
4020
|
-
if (!(key in glDebug) && typeof
|
|
4021
|
-
glDebug[key] =
|
|
4031
|
+
for (const key in import_constants15.GL) {
|
|
4032
|
+
if (!(key in glDebug) && typeof import_constants15.GL[key] === "number") {
|
|
4033
|
+
glDebug[key] = import_constants15.GL[key];
|
|
4022
4034
|
}
|
|
4023
4035
|
}
|
|
4024
4036
|
class WebGLDebugContext {
|
|
@@ -4077,34 +4089,34 @@ function onValidateGLFunc(props, functionName, functionArgs) {
|
|
|
4077
4089
|
|
|
4078
4090
|
// src/classic/buffer-with-accessor.ts
|
|
4079
4091
|
var import_core19 = require("@luma.gl/core");
|
|
4080
|
-
var
|
|
4092
|
+
var import_constants18 = require("@luma.gl/constants");
|
|
4081
4093
|
|
|
4082
4094
|
// src/classic/accessor.ts
|
|
4083
4095
|
var import_core18 = require("@luma.gl/core");
|
|
4084
|
-
var
|
|
4096
|
+
var import_constants17 = require("@luma.gl/constants");
|
|
4085
4097
|
|
|
4086
4098
|
// src/classic/typed-array-utils.ts
|
|
4087
|
-
var
|
|
4099
|
+
var import_constants16 = require("@luma.gl/constants");
|
|
4088
4100
|
var ERR_TYPE_DEDUCTION = "Failed to deduce GL constant from typed array";
|
|
4089
4101
|
function getGLTypeFromTypedArray(arrayOrType) {
|
|
4090
4102
|
const type = ArrayBuffer.isView(arrayOrType) ? arrayOrType.constructor : arrayOrType;
|
|
4091
4103
|
switch (type) {
|
|
4092
4104
|
case Float32Array:
|
|
4093
|
-
return
|
|
4105
|
+
return import_constants16.GL.FLOAT;
|
|
4094
4106
|
case Uint16Array:
|
|
4095
|
-
return
|
|
4107
|
+
return import_constants16.GL.UNSIGNED_SHORT;
|
|
4096
4108
|
case Uint32Array:
|
|
4097
|
-
return
|
|
4109
|
+
return import_constants16.GL.UNSIGNED_INT;
|
|
4098
4110
|
case Uint8Array:
|
|
4099
|
-
return
|
|
4111
|
+
return import_constants16.GL.UNSIGNED_BYTE;
|
|
4100
4112
|
case Uint8ClampedArray:
|
|
4101
|
-
return
|
|
4113
|
+
return import_constants16.GL.UNSIGNED_BYTE;
|
|
4102
4114
|
case Int8Array:
|
|
4103
|
-
return
|
|
4115
|
+
return import_constants16.GL.BYTE;
|
|
4104
4116
|
case Int16Array:
|
|
4105
|
-
return
|
|
4117
|
+
return import_constants16.GL.SHORT;
|
|
4106
4118
|
case Int32Array:
|
|
4107
|
-
return
|
|
4119
|
+
return import_constants16.GL.INT;
|
|
4108
4120
|
default:
|
|
4109
4121
|
throw new Error(ERR_TYPE_DEDUCTION);
|
|
4110
4122
|
}
|
|
@@ -4112,22 +4124,22 @@ function getGLTypeFromTypedArray(arrayOrType) {
|
|
|
4112
4124
|
function getTypedArrayFromGLType(glType, options) {
|
|
4113
4125
|
const { clamped = true } = options || {};
|
|
4114
4126
|
switch (glType) {
|
|
4115
|
-
case
|
|
4127
|
+
case import_constants16.GL.FLOAT:
|
|
4116
4128
|
return Float32Array;
|
|
4117
|
-
case
|
|
4118
|
-
case
|
|
4119
|
-
case
|
|
4120
|
-
case
|
|
4129
|
+
case import_constants16.GL.UNSIGNED_SHORT:
|
|
4130
|
+
case import_constants16.GL.UNSIGNED_SHORT_5_6_5:
|
|
4131
|
+
case import_constants16.GL.UNSIGNED_SHORT_4_4_4_4:
|
|
4132
|
+
case import_constants16.GL.UNSIGNED_SHORT_5_5_5_1:
|
|
4121
4133
|
return Uint16Array;
|
|
4122
|
-
case
|
|
4134
|
+
case import_constants16.GL.UNSIGNED_INT:
|
|
4123
4135
|
return Uint32Array;
|
|
4124
|
-
case
|
|
4136
|
+
case import_constants16.GL.UNSIGNED_BYTE:
|
|
4125
4137
|
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
4126
|
-
case
|
|
4138
|
+
case import_constants16.GL.BYTE:
|
|
4127
4139
|
return Int8Array;
|
|
4128
|
-
case
|
|
4140
|
+
case import_constants16.GL.SHORT:
|
|
4129
4141
|
return Int16Array;
|
|
4130
|
-
case
|
|
4142
|
+
case import_constants16.GL.INT:
|
|
4131
4143
|
return Int32Array;
|
|
4132
4144
|
default:
|
|
4133
4145
|
throw new Error("Failed to deduce typed array type from GL constant");
|
|
@@ -4138,7 +4150,7 @@ function getTypedArrayFromGLType(glType, options) {
|
|
|
4138
4150
|
var DEFAULT_ACCESSOR_VALUES = {
|
|
4139
4151
|
offset: 0,
|
|
4140
4152
|
stride: 0,
|
|
4141
|
-
type:
|
|
4153
|
+
type: import_constants17.GL.FLOAT,
|
|
4142
4154
|
size: 1,
|
|
4143
4155
|
divisor: 0,
|
|
4144
4156
|
normalized: false,
|
|
@@ -4152,12 +4164,12 @@ var PROP_CHECKS = {
|
|
|
4152
4164
|
};
|
|
4153
4165
|
var Accessor = class {
|
|
4154
4166
|
static getBytesPerElement(accessor) {
|
|
4155
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type ||
|
|
4167
|
+
const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants17.GL.FLOAT);
|
|
4156
4168
|
return ArrayType.BYTES_PER_ELEMENT;
|
|
4157
4169
|
}
|
|
4158
4170
|
static getBytesPerVertex(accessor) {
|
|
4159
4171
|
(0, import_core18.assert)(accessor.size);
|
|
4160
|
-
const ArrayType = getTypedArrayFromGLType(accessor.type ||
|
|
4172
|
+
const ArrayType = getTypedArrayFromGLType(accessor.type || import_constants17.GL.FLOAT);
|
|
4161
4173
|
return ArrayType.BYTES_PER_ELEMENT * accessor.size;
|
|
4162
4174
|
}
|
|
4163
4175
|
// Combines (merges) a list of accessors. On top of default values
|
|
@@ -4188,7 +4200,7 @@ var Accessor = class {
|
|
|
4188
4200
|
props = (0, import_core18.checkProps)("Accessor", props, PROP_CHECKS);
|
|
4189
4201
|
if (props.type !== void 0) {
|
|
4190
4202
|
this.type = props.type;
|
|
4191
|
-
if (props.type ===
|
|
4203
|
+
if (props.type === import_constants17.GL.INT || props.type === import_constants17.GL.UNSIGNED_INT) {
|
|
4192
4204
|
this.integer = true;
|
|
4193
4205
|
}
|
|
4194
4206
|
}
|
|
@@ -4320,7 +4332,7 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4320
4332
|
props = { byteLength: props };
|
|
4321
4333
|
}
|
|
4322
4334
|
props = (0, import_core19.checkProps)("Buffer", props, PROP_CHECKS_INITIALIZE);
|
|
4323
|
-
this.glUsage = props.glUsage ||
|
|
4335
|
+
this.glUsage = props.glUsage || import_constants18.GL.STATIC_DRAW;
|
|
4324
4336
|
this.debugData = null;
|
|
4325
4337
|
this.setAccessor(Object.assign({}, props, props.accessor));
|
|
4326
4338
|
if (props.data) {
|
|
@@ -4374,7 +4386,7 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4374
4386
|
const { data, offset = 0, srcOffset = 0 } = options;
|
|
4375
4387
|
const byteLength = options.byteLength || options.length;
|
|
4376
4388
|
(0, import_core19.assert)(data);
|
|
4377
|
-
const glTarget = this.gl.webgl2 ?
|
|
4389
|
+
const glTarget = this.gl.webgl2 ? import_constants18.GL.COPY_WRITE_BUFFER : this.glTarget;
|
|
4378
4390
|
this.gl.bindBuffer(glTarget, this.handle);
|
|
4379
4391
|
if (srcOffset !== 0 || byteLength !== void 0) {
|
|
4380
4392
|
assertWebGL2Context(this.gl);
|
|
@@ -4395,11 +4407,11 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4395
4407
|
const { sourceBuffer, readOffset = 0, writeOffset = 0, size } = options;
|
|
4396
4408
|
const { gl: gl2, gl2: gl22 } = this;
|
|
4397
4409
|
assertWebGL2Context(gl2);
|
|
4398
|
-
gl2.bindBuffer(
|
|
4399
|
-
gl2.bindBuffer(
|
|
4400
|
-
gl22 == null ? void 0 : gl22.copyBufferSubData(
|
|
4401
|
-
gl2.bindBuffer(
|
|
4402
|
-
gl2.bindBuffer(
|
|
4410
|
+
gl2.bindBuffer(import_constants18.GL.COPY_READ_BUFFER, sourceBuffer.handle);
|
|
4411
|
+
gl2.bindBuffer(import_constants18.GL.COPY_WRITE_BUFFER, this.handle);
|
|
4412
|
+
gl22 == null ? void 0 : gl22.copyBufferSubData(import_constants18.GL.COPY_READ_BUFFER, import_constants18.GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);
|
|
4413
|
+
gl2.bindBuffer(import_constants18.GL.COPY_READ_BUFFER, null);
|
|
4414
|
+
gl2.bindBuffer(import_constants18.GL.COPY_WRITE_BUFFER, null);
|
|
4403
4415
|
this.debugData = null;
|
|
4404
4416
|
return this;
|
|
4405
4417
|
}
|
|
@@ -4412,7 +4424,7 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4412
4424
|
let { dstData = null, length = 0 } = options || {};
|
|
4413
4425
|
const { srcByteOffset = 0, dstOffset = 0 } = options || {};
|
|
4414
4426
|
assertWebGL2Context(this.gl);
|
|
4415
|
-
const ArrayType = getTypedArrayFromGLType(this.accessor.type ||
|
|
4427
|
+
const ArrayType = getTypedArrayFromGLType(this.accessor.type || import_constants18.GL.FLOAT, { clamped: false });
|
|
4416
4428
|
const sourceAvailableElementCount = this._getAvailableElementCount(srcByteOffset);
|
|
4417
4429
|
const dstElementOffset = dstOffset;
|
|
4418
4430
|
let dstAvailableElementCount;
|
|
@@ -4431,9 +4443,9 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4431
4443
|
length = length || copyElementCount;
|
|
4432
4444
|
(0, import_core19.assert)(length <= copyElementCount);
|
|
4433
4445
|
dstData = dstData || new ArrayType(dstElementCount);
|
|
4434
|
-
this.gl.bindBuffer(
|
|
4435
|
-
(_a = this.gl2) == null ? void 0 : _a.getBufferSubData(
|
|
4436
|
-
this.gl.bindBuffer(
|
|
4446
|
+
this.gl.bindBuffer(import_constants18.GL.COPY_READ_BUFFER, this.handle);
|
|
4447
|
+
(_a = this.gl2) == null ? void 0 : _a.getBufferSubData(import_constants18.GL.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);
|
|
4448
|
+
this.gl.bindBuffer(import_constants18.GL.COPY_READ_BUFFER, null);
|
|
4437
4449
|
return dstData;
|
|
4438
4450
|
}
|
|
4439
4451
|
/**
|
|
@@ -4453,7 +4465,7 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4453
4465
|
offset = 0,
|
|
4454
4466
|
size
|
|
4455
4467
|
} = options || {};
|
|
4456
|
-
if (glTarget ===
|
|
4468
|
+
if (glTarget === import_constants18.GL.UNIFORM_BUFFER || glTarget === import_constants18.GL.TRANSFORM_FEEDBACK_BUFFER) {
|
|
4457
4469
|
if (size !== void 0) {
|
|
4458
4470
|
(_a = this.gl2) == null ? void 0 : _a.bindBufferRange(glTarget, index, this.handle, offset, size);
|
|
4459
4471
|
} else {
|
|
@@ -4468,7 +4480,7 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4468
4480
|
unbind(options) {
|
|
4469
4481
|
var _a;
|
|
4470
4482
|
const { glTarget = this.glTarget, index = this.accessor && this.accessor.index } = options || {};
|
|
4471
|
-
const isIndexedBuffer = glTarget ===
|
|
4483
|
+
const isIndexedBuffer = glTarget === import_constants18.GL.UNIFORM_BUFFER || glTarget === import_constants18.GL.TRANSFORM_FEEDBACK_BUFFER;
|
|
4472
4484
|
if (isIndexedBuffer) {
|
|
4473
4485
|
(_a = this.gl2) == null ? void 0 : _a.bindBufferBase(glTarget, index, null);
|
|
4474
4486
|
} else {
|
|
@@ -4528,10 +4540,10 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4528
4540
|
// Binding a buffer for the first time locks the type
|
|
4529
4541
|
// In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type
|
|
4530
4542
|
_getTarget() {
|
|
4531
|
-
return this.gl.webgl2 ?
|
|
4543
|
+
return this.gl.webgl2 ? import_constants18.GL.COPY_WRITE_BUFFER : this.glTarget;
|
|
4532
4544
|
}
|
|
4533
4545
|
_getAvailableElementCount(srcByteOffset) {
|
|
4534
|
-
const ArrayType = getTypedArrayFromGLType(this.accessor.type ||
|
|
4546
|
+
const ArrayType = getTypedArrayFromGLType(this.accessor.type || import_constants18.GL.FLOAT, { clamped: false });
|
|
4535
4547
|
const sourceElementOffset = srcByteOffset / ArrayType.BYTES_PER_ELEMENT;
|
|
4536
4548
|
return this.getElementCount() - sourceElementOffset;
|
|
4537
4549
|
}
|
|
@@ -4558,7 +4570,7 @@ var BufferWithAccessor = class extends WEBGLBuffer {
|
|
|
4558
4570
|
|
|
4559
4571
|
// src/adapter/resources/webgl-shader.ts
|
|
4560
4572
|
var import_core20 = require("@luma.gl/core");
|
|
4561
|
-
var
|
|
4573
|
+
var import_constants19 = require("@luma.gl/constants");
|
|
4562
4574
|
|
|
4563
4575
|
// src/adapter/helpers/get-shader-info.ts
|
|
4564
4576
|
function getShaderInfo(source, defaultName) {
|
|
@@ -4624,10 +4636,10 @@ var WEBGLShader = class extends import_core20.Shader {
|
|
|
4624
4636
|
this.device = device;
|
|
4625
4637
|
switch (this.props.stage) {
|
|
4626
4638
|
case "vertex":
|
|
4627
|
-
this.handle = this.props.handle || this.device.gl.createShader(
|
|
4639
|
+
this.handle = this.props.handle || this.device.gl.createShader(import_constants19.GL.VERTEX_SHADER);
|
|
4628
4640
|
break;
|
|
4629
4641
|
case "fragment":
|
|
4630
|
-
this.handle = this.props.handle || this.device.gl.createShader(
|
|
4642
|
+
this.handle = this.props.handle || this.device.gl.createShader(import_constants19.GL.FRAGMENT_SHADER);
|
|
4631
4643
|
break;
|
|
4632
4644
|
default:
|
|
4633
4645
|
throw new Error(this.props.stage);
|
|
@@ -4643,8 +4655,8 @@ var WEBGLShader = class extends import_core20.Shader {
|
|
|
4643
4655
|
}
|
|
4644
4656
|
compilationInfo() {
|
|
4645
4657
|
return __async(this, null, function* () {
|
|
4646
|
-
const
|
|
4647
|
-
return
|
|
4658
|
+
const log9 = this.device.gl.getShaderInfoLog(this.handle);
|
|
4659
|
+
return log9 ? parseShaderCompilerLog(log9) : [];
|
|
4648
4660
|
});
|
|
4649
4661
|
}
|
|
4650
4662
|
// PRIVATE METHODS
|
|
@@ -4655,7 +4667,7 @@ ${source2}`;
|
|
|
4655
4667
|
const { gl: gl2 } = this.device;
|
|
4656
4668
|
gl2.shaderSource(this.handle, source);
|
|
4657
4669
|
gl2.compileShader(this.handle);
|
|
4658
|
-
const compileStatus = gl2.getShaderParameter(this.handle,
|
|
4670
|
+
const compileStatus = gl2.getShaderParameter(this.handle, import_constants19.GL.COMPILE_STATUS);
|
|
4659
4671
|
if (!compileStatus) {
|
|
4660
4672
|
const shaderLog = gl2.getShaderInfoLog(this.handle);
|
|
4661
4673
|
const parsedLog = shaderLog ? parseShaderCompilerLog(shaderLog) : [];
|
|
@@ -4675,7 +4687,7 @@ function getShaderIdFromProps(props) {
|
|
|
4675
4687
|
|
|
4676
4688
|
// src/adapter/resources/webgl-render-pass.ts
|
|
4677
4689
|
var import_core21 = require("@luma.gl/core");
|
|
4678
|
-
var
|
|
4690
|
+
var import_constants20 = require("@luma.gl/constants");
|
|
4679
4691
|
var GL_DEPTH_BUFFER_BIT = 256;
|
|
4680
4692
|
var GL_STENCIL_BUFFER_BIT = 1024;
|
|
4681
4693
|
var GL_COLOR_BUFFER_BIT = 16384;
|
|
@@ -4711,7 +4723,7 @@ var WEBGLRenderPass = class extends import_core21.RenderPass {
|
|
|
4711
4723
|
glParameters.depthMask = !this.props.depthReadOnly;
|
|
4712
4724
|
}
|
|
4713
4725
|
glParameters.stencilMask = this.props.stencilReadOnly ? 0 : 1;
|
|
4714
|
-
glParameters[
|
|
4726
|
+
glParameters[import_constants20.GL.RASTERIZER_DISCARD] = this.props.discard;
|
|
4715
4727
|
if (parameters.viewport) {
|
|
4716
4728
|
if (parameters.viewport.length >= 6) {
|
|
4717
4729
|
glParameters.viewport = parameters.viewport.slice(0, 4);
|
|
@@ -4729,7 +4741,7 @@ var WEBGLRenderPass = class extends import_core21.RenderPass {
|
|
|
4729
4741
|
}
|
|
4730
4742
|
if (parameters.stencilReference) {
|
|
4731
4743
|
console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL");
|
|
4732
|
-
parameters[
|
|
4744
|
+
parameters[import_constants20.GL.STENCIL_REF] = parameters.stencilReference;
|
|
4733
4745
|
}
|
|
4734
4746
|
this.glParameters = glParameters;
|
|
4735
4747
|
}
|
|
@@ -4798,116 +4810,88 @@ var WEBGLRenderPass = class extends import_core21.RenderPass {
|
|
|
4798
4810
|
};
|
|
4799
4811
|
|
|
4800
4812
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
4813
|
+
var import_core23 = require("@luma.gl/core");
|
|
4801
4814
|
var import_core24 = require("@luma.gl/core");
|
|
4802
4815
|
var import_constants25 = require("@luma.gl/constants");
|
|
4803
4816
|
|
|
4804
4817
|
// src/adapter/helpers/get-shader-layout.ts
|
|
4805
|
-
var import_core22 = require("@luma.gl/core");
|
|
4806
4818
|
var import_constants22 = require("@luma.gl/constants");
|
|
4807
4819
|
|
|
4808
|
-
// src/adapter/helpers/
|
|
4809
|
-
var
|
|
4820
|
+
// src/adapter/helpers/decode-webgl-types.ts
|
|
4821
|
+
var import_constants21 = require("@luma.gl/constants");
|
|
4810
4822
|
function isSamplerUniform(type) {
|
|
4811
4823
|
return SAMPLER_TYPES.includes(type);
|
|
4812
4824
|
}
|
|
4813
4825
|
var SAMPLER_TYPES = [
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4826
|
+
import_constants21.GL.SAMPLER_2D,
|
|
4827
|
+
import_constants21.GL.SAMPLER_CUBE,
|
|
4828
|
+
import_constants21.GL.SAMPLER_3D,
|
|
4829
|
+
import_constants21.GL.SAMPLER_2D_SHADOW,
|
|
4830
|
+
import_constants21.GL.SAMPLER_2D_ARRAY,
|
|
4831
|
+
import_constants21.GL.SAMPLER_2D_ARRAY_SHADOW,
|
|
4832
|
+
import_constants21.GL.SAMPLER_CUBE_SHADOW,
|
|
4833
|
+
import_constants21.GL.INT_SAMPLER_2D,
|
|
4834
|
+
import_constants21.GL.INT_SAMPLER_3D,
|
|
4835
|
+
import_constants21.GL.INT_SAMPLER_CUBE,
|
|
4836
|
+
import_constants21.GL.INT_SAMPLER_2D_ARRAY,
|
|
4837
|
+
import_constants21.GL.UNSIGNED_INT_SAMPLER_2D,
|
|
4838
|
+
import_constants21.GL.UNSIGNED_INT_SAMPLER_3D,
|
|
4839
|
+
import_constants21.GL.UNSIGNED_INT_SAMPLER_CUBE,
|
|
4840
|
+
import_constants21.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY
|
|
4829
4841
|
];
|
|
4830
4842
|
var COMPOSITE_GL_TYPES = {
|
|
4831
|
-
[
|
|
4832
|
-
[
|
|
4833
|
-
[
|
|
4834
|
-
[
|
|
4835
|
-
[
|
|
4836
|
-
[
|
|
4837
|
-
[
|
|
4838
|
-
[
|
|
4839
|
-
[
|
|
4840
|
-
[
|
|
4841
|
-
[
|
|
4842
|
-
[
|
|
4843
|
-
[
|
|
4844
|
-
[
|
|
4845
|
-
[
|
|
4846
|
-
[
|
|
4847
|
-
|
|
4843
|
+
[import_constants21.GL.FLOAT]: [import_constants21.GL.FLOAT, 1, "float", "f32", "float32"],
|
|
4844
|
+
[import_constants21.GL.FLOAT_VEC2]: [import_constants21.GL.FLOAT, 2, "vec2", "vec2<f32>", "float32x2"],
|
|
4845
|
+
[import_constants21.GL.FLOAT_VEC3]: [import_constants21.GL.FLOAT, 3, "vec3", "vec3<f32>", "float32x3"],
|
|
4846
|
+
[import_constants21.GL.FLOAT_VEC4]: [import_constants21.GL.FLOAT, 4, "vec4", "vec4<f32>", "float32x4"],
|
|
4847
|
+
[import_constants21.GL.INT]: [import_constants21.GL.INT, 1, "int", "i32", "sint32"],
|
|
4848
|
+
[import_constants21.GL.INT_VEC2]: [import_constants21.GL.INT, 2, "ivec2", "vec2<i32>", "sint32x2"],
|
|
4849
|
+
[import_constants21.GL.INT_VEC3]: [import_constants21.GL.INT, 3, "ivec3", "vec3<i32>", "sint32x3"],
|
|
4850
|
+
[import_constants21.GL.INT_VEC4]: [import_constants21.GL.INT, 4, "ivec4", "vec4<i32>", "sint32x4"],
|
|
4851
|
+
[import_constants21.GL.UNSIGNED_INT]: [import_constants21.GL.UNSIGNED_INT, 1, "uint", "u32", "uint32"],
|
|
4852
|
+
[import_constants21.GL.UNSIGNED_INT_VEC2]: [import_constants21.GL.UNSIGNED_INT, 2, "uvec2", "vec2<u32>", "uint32x2"],
|
|
4853
|
+
[import_constants21.GL.UNSIGNED_INT_VEC3]: [import_constants21.GL.UNSIGNED_INT, 3, "uvec3", "vec3<u32>", "uint32x3"],
|
|
4854
|
+
[import_constants21.GL.UNSIGNED_INT_VEC4]: [import_constants21.GL.UNSIGNED_INT, 4, "uvec4", "vec4<u32>", "uint32x4"],
|
|
4855
|
+
[import_constants21.GL.BOOL]: [import_constants21.GL.FLOAT, 1, "bool", "f32", "float32"],
|
|
4856
|
+
[import_constants21.GL.BOOL_VEC2]: [import_constants21.GL.FLOAT, 2, "bvec2", "vec2<f32>", "float32x2"],
|
|
4857
|
+
[import_constants21.GL.BOOL_VEC3]: [import_constants21.GL.FLOAT, 3, "bvec3", "vec3<f32>", "float32x3"],
|
|
4858
|
+
[import_constants21.GL.BOOL_VEC4]: [import_constants21.GL.FLOAT, 4, "bvec4", "vec4<f32>", "float32x4"],
|
|
4859
|
+
// TODO - are sizes/components below correct?
|
|
4860
|
+
[import_constants21.GL.FLOAT_MAT2]: [import_constants21.GL.FLOAT, 8, "mat2", "mat2x2<f32>"],
|
|
4848
4861
|
// 4
|
|
4849
|
-
[
|
|
4862
|
+
[import_constants21.GL.FLOAT_MAT2x3]: [import_constants21.GL.FLOAT, 8, "mat2x3", "mat2x3<f32>"],
|
|
4850
4863
|
// 6
|
|
4851
|
-
[
|
|
4864
|
+
[import_constants21.GL.FLOAT_MAT2x4]: [import_constants21.GL.FLOAT, 8, "mat2x4", "mat2x4<f32>"],
|
|
4852
4865
|
// 8
|
|
4853
|
-
[
|
|
4866
|
+
[import_constants21.GL.FLOAT_MAT3x2]: [import_constants21.GL.FLOAT, 12, "mat3x2", "mat3x2<f32>"],
|
|
4854
4867
|
// 6
|
|
4855
|
-
[
|
|
4868
|
+
[import_constants21.GL.FLOAT_MAT3]: [import_constants21.GL.FLOAT, 12, "mat3", "mat3x3<f32>"],
|
|
4856
4869
|
// 9
|
|
4857
|
-
[
|
|
4870
|
+
[import_constants21.GL.FLOAT_MAT3x4]: [import_constants21.GL.FLOAT, 12, "mat3x4", "mat3x4<f32>"],
|
|
4858
4871
|
// 12
|
|
4859
|
-
[
|
|
4872
|
+
[import_constants21.GL.FLOAT_MAT4x2]: [import_constants21.GL.FLOAT, 16, "mat4x2", "mat4x2<f32>"],
|
|
4860
4873
|
// 8
|
|
4861
|
-
[
|
|
4874
|
+
[import_constants21.GL.FLOAT_MAT4x3]: [import_constants21.GL.FLOAT, 16, "mat4x3", "mat4x3<f32>"],
|
|
4862
4875
|
// 12
|
|
4863
|
-
[
|
|
4876
|
+
[import_constants21.GL.FLOAT_MAT4]: [import_constants21.GL.FLOAT, 16, "mat4", "mat4x4<f32>"]
|
|
4864
4877
|
// 16
|
|
4865
4878
|
};
|
|
4866
|
-
function
|
|
4867
|
-
const typeAndSize = COMPOSITE_GL_TYPES[
|
|
4879
|
+
function decodeGLUniformType(glUniformType) {
|
|
4880
|
+
const typeAndSize = COMPOSITE_GL_TYPES[glUniformType];
|
|
4868
4881
|
if (!typeAndSize) {
|
|
4869
4882
|
throw new Error("uniform");
|
|
4870
4883
|
}
|
|
4871
4884
|
const [glType, components, , format] = typeAndSize;
|
|
4872
4885
|
return { format, components, glType };
|
|
4873
4886
|
}
|
|
4874
|
-
function
|
|
4875
|
-
const typeAndSize = COMPOSITE_GL_TYPES[
|
|
4887
|
+
function decodeGLAttributeType(glAttributeType) {
|
|
4888
|
+
const typeAndSize = COMPOSITE_GL_TYPES[glAttributeType];
|
|
4876
4889
|
if (!typeAndSize) {
|
|
4877
4890
|
throw new Error("attribute");
|
|
4878
4891
|
}
|
|
4879
|
-
const [
|
|
4880
|
-
|
|
4881
|
-
}
|
|
4882
|
-
|
|
4883
|
-
// src/adapter/converters/vertex-formats.ts
|
|
4884
|
-
var import_constants21 = require("@luma.gl/constants");
|
|
4885
|
-
function getVertexFormat(type, components) {
|
|
4886
|
-
const base = getDataFormat(type);
|
|
4887
|
-
switch (components) {
|
|
4888
|
-
case 1:
|
|
4889
|
-
return base;
|
|
4890
|
-
case 2:
|
|
4891
|
-
return `${base}x2`;
|
|
4892
|
-
case 3:
|
|
4893
|
-
return `${base}x3`;
|
|
4894
|
-
case 4:
|
|
4895
|
-
return `${base}x4`;
|
|
4896
|
-
default:
|
|
4897
|
-
throw new Error(String(components));
|
|
4898
|
-
}
|
|
4899
|
-
}
|
|
4900
|
-
function getDataFormat(type) {
|
|
4901
|
-
switch (type) {
|
|
4902
|
-
case import_constants21.GL.INT:
|
|
4903
|
-
return "sint32";
|
|
4904
|
-
case import_constants21.GL.UNSIGNED_INT:
|
|
4905
|
-
return "uint32";
|
|
4906
|
-
case import_constants21.GL.FLOAT:
|
|
4907
|
-
return "float32";
|
|
4908
|
-
default:
|
|
4909
|
-
throw new Error(String(type));
|
|
4910
|
-
}
|
|
4892
|
+
const [, components, , shaderType, vertexFormat] = typeAndSize;
|
|
4893
|
+
const attributeType = shaderType;
|
|
4894
|
+
return { attributeType, vertexFormat, components };
|
|
4911
4895
|
}
|
|
4912
4896
|
|
|
4913
4897
|
// src/adapter/helpers/get-shader-layout.ts
|
|
@@ -4916,20 +4900,7 @@ function getShaderLayout(gl2, program) {
|
|
|
4916
4900
|
attributes: [],
|
|
4917
4901
|
bindings: []
|
|
4918
4902
|
};
|
|
4919
|
-
|
|
4920
|
-
for (const attribute of attributes) {
|
|
4921
|
-
const size = Math.min(attribute.accessor.size, 4);
|
|
4922
|
-
const format = (
|
|
4923
|
-
// attribute.accessor.format ||
|
|
4924
|
-
getVertexFormat(attribute.accessor.type || import_constants22.GL.FLOAT, size)
|
|
4925
|
-
);
|
|
4926
|
-
shaderLayout.attributes.push({
|
|
4927
|
-
name: attribute.name,
|
|
4928
|
-
location: attribute.location,
|
|
4929
|
-
format,
|
|
4930
|
-
stepMode: attribute.accessor.divisor === 1 ? "instance" : "vertex"
|
|
4931
|
-
});
|
|
4932
|
-
}
|
|
4903
|
+
shaderLayout.attributes = readAttributeDeclarations(gl2, program);
|
|
4933
4904
|
const uniformBlocks = readUniformBlocks(gl2, program);
|
|
4934
4905
|
for (const uniformBlock of uniformBlocks) {
|
|
4935
4906
|
const uniforms2 = uniformBlock.uniforms.map((uniform) => ({
|
|
@@ -4973,52 +4944,7 @@ function getShaderLayout(gl2, program) {
|
|
|
4973
4944
|
}
|
|
4974
4945
|
return shaderLayout;
|
|
4975
4946
|
}
|
|
4976
|
-
function
|
|
4977
|
-
const mergedLayout = __spreadProps(__spreadValues({}, baseLayout), {
|
|
4978
|
-
attributes: baseLayout.attributes.map((attribute) => __spreadValues({}, attribute))
|
|
4979
|
-
});
|
|
4980
|
-
for (const attribute of (overrideLayout == null ? void 0 : overrideLayout.attributes) || []) {
|
|
4981
|
-
const baseAttribute = mergedLayout.attributes.find((attr) => attr.name === attribute.name);
|
|
4982
|
-
if (!baseAttribute) {
|
|
4983
|
-
import_core22.log.warn(`shader layout attribute ${attribute.name} not present in shader`);
|
|
4984
|
-
} else {
|
|
4985
|
-
baseAttribute.format = attribute.format || baseAttribute.format;
|
|
4986
|
-
baseAttribute.stepMode = attribute.stepMode || baseAttribute.stepMode;
|
|
4987
|
-
}
|
|
4988
|
-
}
|
|
4989
|
-
return mergedLayout;
|
|
4990
|
-
}
|
|
4991
|
-
function mergeBufferMap(baseLayout, bufferMap) {
|
|
4992
|
-
const mergedLayout = __spreadProps(__spreadValues({}, baseLayout), {
|
|
4993
|
-
attributes: baseLayout.attributes.map((attribute) => __spreadValues({}, attribute))
|
|
4994
|
-
});
|
|
4995
|
-
for (const bufferMapping of bufferMap) {
|
|
4996
|
-
switch (bufferMapping.type) {
|
|
4997
|
-
case "interleave":
|
|
4998
|
-
for (const attributeOverride of bufferMapping.attributes) {
|
|
4999
|
-
overrideShaderLayoutAttribute(mergedLayout, attributeOverride);
|
|
5000
|
-
}
|
|
5001
|
-
break;
|
|
5002
|
-
default:
|
|
5003
|
-
overrideShaderLayoutAttribute(mergedLayout, bufferMapping);
|
|
5004
|
-
}
|
|
5005
|
-
}
|
|
5006
|
-
return mergedLayout;
|
|
5007
|
-
}
|
|
5008
|
-
function overrideShaderLayoutAttribute(layout, attributeOverride) {
|
|
5009
|
-
const attribute = getAttributeFromLayout(layout, attributeOverride.name);
|
|
5010
|
-
if (attribute && attributeOverride.format) {
|
|
5011
|
-
attribute.format = attributeOverride.format;
|
|
5012
|
-
}
|
|
5013
|
-
}
|
|
5014
|
-
function getAttributeFromLayout(shaderLayout, name) {
|
|
5015
|
-
const attribute = shaderLayout.attributes.find((attr) => attr.name === name);
|
|
5016
|
-
if (!attribute) {
|
|
5017
|
-
import_core22.log.warn(`shader layout attribute "${name}" not present in shader`);
|
|
5018
|
-
}
|
|
5019
|
-
return attribute || null;
|
|
5020
|
-
}
|
|
5021
|
-
function readAttributeBindings(gl2, program) {
|
|
4947
|
+
function readAttributeDeclarations(gl2, program) {
|
|
5022
4948
|
const attributes = [];
|
|
5023
4949
|
const count = gl2.getProgramParameter(program, gl2.ACTIVE_ATTRIBUTES);
|
|
5024
4950
|
for (let index = 0; index < count; index++) {
|
|
@@ -5026,16 +4952,22 @@ function readAttributeBindings(gl2, program) {
|
|
|
5026
4952
|
if (!activeInfo) {
|
|
5027
4953
|
throw new Error("activeInfo");
|
|
5028
4954
|
}
|
|
5029
|
-
const {
|
|
5030
|
-
|
|
4955
|
+
const {
|
|
4956
|
+
name: name2,
|
|
4957
|
+
type: compositeType
|
|
4958
|
+
/* , size*/
|
|
4959
|
+
} = activeInfo;
|
|
4960
|
+
const location = gl2.getAttribLocation(program, name2);
|
|
5031
4961
|
if (location >= 0) {
|
|
5032
|
-
const {
|
|
5033
|
-
const
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
4962
|
+
const { attributeType } = decodeGLAttributeType(compositeType);
|
|
4963
|
+
const stepMode = /instance/i.test(name2) ? "instance" : "vertex";
|
|
4964
|
+
attributes.push({
|
|
4965
|
+
name: name2,
|
|
4966
|
+
location,
|
|
4967
|
+
stepMode,
|
|
4968
|
+
type: attributeType
|
|
4969
|
+
// size - for arrays, size is the number of elements in the array
|
|
4970
|
+
});
|
|
5039
4971
|
}
|
|
5040
4972
|
}
|
|
5041
4973
|
attributes.sort((a, b) => a.location - b.location);
|
|
@@ -5053,10 +4985,10 @@ function readVaryings(gl2, program) {
|
|
|
5053
4985
|
if (!activeInfo) {
|
|
5054
4986
|
throw new Error("activeInfo");
|
|
5055
4987
|
}
|
|
5056
|
-
const { name, type: compositeType, size } = activeInfo;
|
|
5057
|
-
const { glType, components } =
|
|
4988
|
+
const { name: name2, type: compositeType, size } = activeInfo;
|
|
4989
|
+
const { glType, components } = decodeGLUniformType(compositeType);
|
|
5058
4990
|
const accessor = new Accessor({ type: glType, size: size * components });
|
|
5059
|
-
const varying = { location, name, accessor };
|
|
4991
|
+
const varying = { location, name: name2, accessor };
|
|
5060
4992
|
varyings.push(varying);
|
|
5061
4993
|
}
|
|
5062
4994
|
varyings.sort((a, b) => a.location - b.location);
|
|
@@ -5071,12 +5003,12 @@ function readUniformBindings(gl2, program) {
|
|
|
5071
5003
|
throw new Error("activeInfo");
|
|
5072
5004
|
}
|
|
5073
5005
|
const { name: rawName, size, type } = activeInfo;
|
|
5074
|
-
const { name, isArray: isArray2 } = parseUniformName(rawName);
|
|
5075
|
-
let webglLocation = gl2.getUniformLocation(program,
|
|
5006
|
+
const { name: name2, isArray: isArray2 } = parseUniformName(rawName);
|
|
5007
|
+
let webglLocation = gl2.getUniformLocation(program, name2);
|
|
5076
5008
|
const uniformInfo = {
|
|
5077
5009
|
// WebGL locations are uniquely typed but just numbers
|
|
5078
5010
|
location: webglLocation,
|
|
5079
|
-
name,
|
|
5011
|
+
name: name2,
|
|
5080
5012
|
size,
|
|
5081
5013
|
type,
|
|
5082
5014
|
isArray: isArray2
|
|
@@ -5084,7 +5016,7 @@ function readUniformBindings(gl2, program) {
|
|
|
5084
5016
|
uniforms.push(uniformInfo);
|
|
5085
5017
|
if (uniformInfo.size > 1) {
|
|
5086
5018
|
for (let j = 0; j < uniformInfo.size; j++) {
|
|
5087
|
-
const elementName = `${
|
|
5019
|
+
const elementName = `${name2}[${j}]`;
|
|
5088
5020
|
webglLocation = gl2.getUniformLocation(program, elementName);
|
|
5089
5021
|
const arrayElementUniformInfo = __spreadProps(__spreadValues({}, uniformInfo), {
|
|
5090
5022
|
name: elementName,
|
|
@@ -5126,7 +5058,7 @@ function readUniformBlocks(gl2, program) {
|
|
|
5126
5058
|
}
|
|
5127
5059
|
blockInfo.uniforms.push({
|
|
5128
5060
|
name: activeInfo.name,
|
|
5129
|
-
format:
|
|
5061
|
+
format: decodeGLUniformType(uniformType[i]).format,
|
|
5130
5062
|
type: uniformType[i],
|
|
5131
5063
|
arrayLength: uniformArrayLength[i],
|
|
5132
5064
|
byteOffset: uniformOffset[i],
|
|
@@ -5165,18 +5097,18 @@ function getSamplerInfo(type) {
|
|
|
5165
5097
|
const [viewDimension, sampleType] = sampler;
|
|
5166
5098
|
return { viewDimension, sampleType };
|
|
5167
5099
|
}
|
|
5168
|
-
function parseUniformName(
|
|
5169
|
-
if (
|
|
5100
|
+
function parseUniformName(name2) {
|
|
5101
|
+
if (name2[name2.length - 1] !== "]") {
|
|
5170
5102
|
return {
|
|
5171
|
-
name,
|
|
5103
|
+
name: name2,
|
|
5172
5104
|
length: 1,
|
|
5173
5105
|
isArray: false
|
|
5174
5106
|
};
|
|
5175
5107
|
}
|
|
5176
5108
|
const UNIFORM_NAME_REGEXP = /([^[]*)(\[[0-9]+\])?/;
|
|
5177
|
-
const matches = UNIFORM_NAME_REGEXP.exec(
|
|
5109
|
+
const matches = UNIFORM_NAME_REGEXP.exec(name2);
|
|
5178
5110
|
if (!matches || matches.length < 2) {
|
|
5179
|
-
throw new Error(`Failed to parse GLSL uniform name ${
|
|
5111
|
+
throw new Error(`Failed to parse GLSL uniform name ${name2}`);
|
|
5180
5112
|
}
|
|
5181
5113
|
return {
|
|
5182
5114
|
name: matches[1],
|
|
@@ -5189,34 +5121,34 @@ function parseUniformName(name) {
|
|
|
5189
5121
|
var import_constants23 = require("@luma.gl/constants");
|
|
5190
5122
|
function setUniform(gl2, location, type, value) {
|
|
5191
5123
|
const gl22 = gl2;
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
case import_constants23.GL.SAMPLER_CUBE_SHADOW:
|
|
5201
|
-
case import_constants23.GL.INT_SAMPLER_2D:
|
|
5202
|
-
case import_constants23.GL.INT_SAMPLER_3D:
|
|
5203
|
-
case import_constants23.GL.INT_SAMPLER_CUBE:
|
|
5204
|
-
case import_constants23.GL.INT_SAMPLER_2D_ARRAY:
|
|
5205
|
-
case import_constants23.GL.UNSIGNED_INT_SAMPLER_2D:
|
|
5206
|
-
case import_constants23.GL.UNSIGNED_INT_SAMPLER_3D:
|
|
5207
|
-
case import_constants23.GL.UNSIGNED_INT_SAMPLER_CUBE:
|
|
5208
|
-
case import_constants23.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
|
5209
|
-
return gl2.uniform1i(location, value);
|
|
5210
|
-
}
|
|
5211
|
-
}
|
|
5212
|
-
if (value === true) {
|
|
5213
|
-
value = 1;
|
|
5214
|
-
}
|
|
5215
|
-
if (value === false) {
|
|
5216
|
-
value = 0;
|
|
5217
|
-
}
|
|
5218
|
-
const arrayValue = typeof value === "number" ? [value] : value;
|
|
5124
|
+
let uniformValue = value;
|
|
5125
|
+
if (uniformValue === true) {
|
|
5126
|
+
uniformValue = 1;
|
|
5127
|
+
}
|
|
5128
|
+
if (uniformValue === false) {
|
|
5129
|
+
uniformValue = 0;
|
|
5130
|
+
}
|
|
5131
|
+
const arrayValue = typeof uniformValue === "number" ? [uniformValue] : uniformValue;
|
|
5219
5132
|
switch (type) {
|
|
5133
|
+
case import_constants23.GL.SAMPLER_2D:
|
|
5134
|
+
case import_constants23.GL.SAMPLER_CUBE:
|
|
5135
|
+
case import_constants23.GL.SAMPLER_3D:
|
|
5136
|
+
case import_constants23.GL.SAMPLER_2D_SHADOW:
|
|
5137
|
+
case import_constants23.GL.SAMPLER_2D_ARRAY:
|
|
5138
|
+
case import_constants23.GL.SAMPLER_2D_ARRAY_SHADOW:
|
|
5139
|
+
case import_constants23.GL.SAMPLER_CUBE_SHADOW:
|
|
5140
|
+
case import_constants23.GL.INT_SAMPLER_2D:
|
|
5141
|
+
case import_constants23.GL.INT_SAMPLER_3D:
|
|
5142
|
+
case import_constants23.GL.INT_SAMPLER_CUBE:
|
|
5143
|
+
case import_constants23.GL.INT_SAMPLER_2D_ARRAY:
|
|
5144
|
+
case import_constants23.GL.UNSIGNED_INT_SAMPLER_2D:
|
|
5145
|
+
case import_constants23.GL.UNSIGNED_INT_SAMPLER_3D:
|
|
5146
|
+
case import_constants23.GL.UNSIGNED_INT_SAMPLER_CUBE:
|
|
5147
|
+
case import_constants23.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:
|
|
5148
|
+
if (typeof value !== "number") {
|
|
5149
|
+
throw new Error("samplers must be set to integers");
|
|
5150
|
+
}
|
|
5151
|
+
return gl2.uniform1i(location, value);
|
|
5220
5152
|
case import_constants23.GL.FLOAT:
|
|
5221
5153
|
return gl2.uniform1fv(location, arrayValue);
|
|
5222
5154
|
case import_constants23.GL.FLOAT_VEC2:
|
|
@@ -5272,14 +5204,14 @@ function setUniform(gl2, location, type, value) {
|
|
|
5272
5204
|
}
|
|
5273
5205
|
|
|
5274
5206
|
// src/adapter/objects/webgl-vertex-array-object.ts
|
|
5275
|
-
var
|
|
5207
|
+
var import_core22 = require("@luma.gl/core");
|
|
5276
5208
|
var import_constants24 = require("@luma.gl/constants");
|
|
5277
5209
|
var import_env2 = require("@probe.gl/env");
|
|
5278
5210
|
var ERR_ELEMENTS = "elements must be GL.ELEMENT_ARRAY_BUFFER";
|
|
5279
5211
|
var WEBGLVertexArrayObject = class extends WebGLResource {
|
|
5280
5212
|
// Create a VertexArray
|
|
5281
5213
|
constructor(device, props) {
|
|
5282
|
-
super(device, props, __spreadProps(__spreadValues({},
|
|
5214
|
+
super(device, props, __spreadProps(__spreadValues({}, import_core22.Resource.defaultProps), { constantAttributeZero: false }));
|
|
5283
5215
|
/** Buffer constant */
|
|
5284
5216
|
this.buffer = null;
|
|
5285
5217
|
this.bufferValue = null;
|
|
@@ -5327,7 +5259,7 @@ var WEBGLVertexArrayObject = class extends WebGLResource {
|
|
|
5327
5259
|
// Set (bind) an elements buffer, for indexed rendering.
|
|
5328
5260
|
// Must be a Buffer bound to GL.ELEMENT_ARRAY_BUFFER. Constants not supported
|
|
5329
5261
|
setElementBuffer(elementBuffer = null, opts = {}) {
|
|
5330
|
-
(0,
|
|
5262
|
+
(0, import_core22.assert)(!elementBuffer || elementBuffer.glTarget === import_constants24.GL.ELEMENT_ARRAY_BUFFER, ERR_ELEMENTS);
|
|
5331
5263
|
this.bind(() => {
|
|
5332
5264
|
this.gl.bindBuffer(import_constants24.GL.ELEMENT_ARRAY_BUFFER, elementBuffer ? elementBuffer.handle : null);
|
|
5333
5265
|
});
|
|
@@ -5376,7 +5308,7 @@ var WEBGLVertexArrayObject = class extends WebGLResource {
|
|
|
5376
5308
|
setConstantUintArray(this.device, location, array);
|
|
5377
5309
|
break;
|
|
5378
5310
|
default:
|
|
5379
|
-
(0,
|
|
5311
|
+
(0, import_core22.assert)(false);
|
|
5380
5312
|
}
|
|
5381
5313
|
}
|
|
5382
5314
|
/**
|
|
@@ -5394,8 +5326,8 @@ var WEBGLVertexArrayObject = class extends WebGLResource {
|
|
|
5394
5326
|
updateNeeded = updateNeeded || this.buffer.reallocate(byteLength);
|
|
5395
5327
|
updateNeeded = updateNeeded || !compareConstantArrayValues(constantValue, this.bufferValue);
|
|
5396
5328
|
if (updateNeeded) {
|
|
5397
|
-
const typedArray = (0,
|
|
5398
|
-
(0,
|
|
5329
|
+
const typedArray = (0, import_core22.getScratchArray)(value.constructor, length);
|
|
5330
|
+
(0, import_core22.fillArray)({ target: typedArray, source: constantValue, start: 0, count: length });
|
|
5399
5331
|
this.buffer.subData(typedArray);
|
|
5400
5332
|
this.bufferValue = value;
|
|
5401
5333
|
}
|
|
@@ -5417,7 +5349,7 @@ function setConstantFloatArray(device, location, array) {
|
|
|
5417
5349
|
device.gl.vertexAttrib4fv(location, array);
|
|
5418
5350
|
break;
|
|
5419
5351
|
default:
|
|
5420
|
-
(0,
|
|
5352
|
+
(0, import_core22.assert)(false);
|
|
5421
5353
|
}
|
|
5422
5354
|
}
|
|
5423
5355
|
function setConstantIntArray(device, location, array) {
|
|
@@ -5450,7 +5382,7 @@ function compareConstantArrayValues(v1, v2) {
|
|
|
5450
5382
|
|
|
5451
5383
|
// src/adapter/resources/webgl-render-pipeline.ts
|
|
5452
5384
|
var LOG_PROGRAM_PERF_PRIORITY = 4;
|
|
5453
|
-
var WEBGLRenderPipeline = class extends
|
|
5385
|
+
var WEBGLRenderPipeline = class extends import_core23.RenderPipeline {
|
|
5454
5386
|
// TODO are these used?
|
|
5455
5387
|
constructor(device, props) {
|
|
5456
5388
|
var _a;
|
|
@@ -5470,8 +5402,8 @@ var WEBGLRenderPipeline = class extends import_core24.RenderPipeline {
|
|
|
5470
5402
|
this.device = device;
|
|
5471
5403
|
this.handle = this.props.handle || this.device.gl.createProgram();
|
|
5472
5404
|
this.device.setSpectorMetadata(this.handle, { id: this.props.id });
|
|
5473
|
-
this.vs = (0,
|
|
5474
|
-
this.fs = (0,
|
|
5405
|
+
this.vs = (0, import_core23.cast)(props.vs);
|
|
5406
|
+
this.fs = (0, import_core23.cast)(props.fs);
|
|
5475
5407
|
const { varyings, bufferMode = import_constants25.GL.SEPARATE_ATTRIBS } = props;
|
|
5476
5408
|
if (varyings && varyings.length > 0) {
|
|
5477
5409
|
this.device.assertWebGL2();
|
|
@@ -5480,9 +5412,8 @@ var WEBGLRenderPipeline = class extends import_core24.RenderPipeline {
|
|
|
5480
5412
|
}
|
|
5481
5413
|
this._compileAndLink();
|
|
5482
5414
|
this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
|
|
5483
|
-
this.
|
|
5484
|
-
this.
|
|
5485
|
-
this.layout = mergeBufferMap(this.layout, this.bufferMap);
|
|
5415
|
+
this.shaderLayout = (0, import_core24.mergeShaderLayout)(this.introspectedLayout, props.shaderLayout);
|
|
5416
|
+
this.bufferLayout = props.bufferLayout || [];
|
|
5486
5417
|
this.vertexArrayObject = new WEBGLVertexArrayObject(this.device);
|
|
5487
5418
|
}
|
|
5488
5419
|
destroy() {
|
|
@@ -5492,75 +5423,82 @@ var WEBGLRenderPipeline = class extends import_core24.RenderPipeline {
|
|
|
5492
5423
|
}
|
|
5493
5424
|
}
|
|
5494
5425
|
setIndexBuffer(indexBuffer) {
|
|
5495
|
-
const webglBuffer = (0,
|
|
5426
|
+
const webglBuffer = (0, import_core23.cast)(indexBuffer);
|
|
5496
5427
|
this.vertexArrayObject.setElementBuffer(webglBuffer);
|
|
5497
5428
|
this._indexBuffer = webglBuffer;
|
|
5498
5429
|
}
|
|
5499
5430
|
/** @todo needed for portable model */
|
|
5500
|
-
setAttributes(
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5431
|
+
setAttributes(buffers) {
|
|
5432
|
+
const attributeInfos = (0, import_core24.getAttributeInfosFromLayouts)(this.shaderLayout, this.bufferLayout);
|
|
5433
|
+
for (const [bufferName, buffer] of Object.entries(buffers)) {
|
|
5434
|
+
let set = false;
|
|
5435
|
+
for (const attributeInfo of Object.values(attributeInfos)) {
|
|
5436
|
+
if (attributeInfo.bufferName !== bufferName) {
|
|
5437
|
+
continue;
|
|
5438
|
+
}
|
|
5439
|
+
const webglBuffer = (0, import_core23.cast)(buffer);
|
|
5440
|
+
const glType = getGLFromVertexType(attributeInfo.bufferDataType);
|
|
5441
|
+
import_core23.log.log(1, {
|
|
5442
|
+
setAttribute: attributeInfo.name,
|
|
5443
|
+
toBuffer: bufferName,
|
|
5444
|
+
size: attributeInfo.bufferComponents,
|
|
5445
|
+
type: glType,
|
|
5446
|
+
stride: attributeInfo.byteStride,
|
|
5447
|
+
offset: attributeInfo.byteOffset,
|
|
5448
|
+
normalized: attributeInfo.normalized,
|
|
5449
|
+
// it is the shader attribute declaration, not the vertex memory format,
|
|
5450
|
+
// that determines if the data in the buffer will be treated as integers.
|
|
5451
|
+
// /
|
|
5452
|
+
// Also note that WebGL supports assigning non-normalized integer data to floating point attributes,
|
|
5453
|
+
// but as far as we can tell, WebGPU does not.
|
|
5454
|
+
integer: attributeInfo.integer,
|
|
5455
|
+
divisor: attributeInfo.stepMode === "instance" ? 1 : 0
|
|
5456
|
+
})();
|
|
5457
|
+
this.vertexArrayObject.setBuffer(attributeInfo.location, webglBuffer, {
|
|
5458
|
+
size: attributeInfo.bufferComponents,
|
|
5459
|
+
type: glType,
|
|
5460
|
+
stride: attributeInfo.byteStride,
|
|
5461
|
+
offset: attributeInfo.byteOffset,
|
|
5462
|
+
normalized: attributeInfo.normalized,
|
|
5463
|
+
// it is the shader attribute declaration, not the vertex memory format,
|
|
5464
|
+
// that determines if the data in the buffer will be treated as integers.
|
|
5465
|
+
// /
|
|
5466
|
+
// Also note that WebGL supports assigning non-normalized integer data to floating point attributes,
|
|
5467
|
+
// but as far as we can tell, WebGPU does not.
|
|
5468
|
+
integer: attributeInfo.integer,
|
|
5469
|
+
divisor: attributeInfo.stepMode === "instance" ? 1 : 0
|
|
5470
|
+
});
|
|
5471
|
+
set = true;
|
|
5472
|
+
}
|
|
5473
|
+
if (!set) {
|
|
5474
|
+
import_core23.log.warn(
|
|
5475
|
+
`setAttributes(): Ignoring (buffer "${buffer.id}" for unknown attribute "${name}" in pipeline "${this.id}"`
|
|
5476
|
+
)();
|
|
5507
5477
|
}
|
|
5508
|
-
const decoded = (0, import_core24.decodeVertexFormat)(attribute.format);
|
|
5509
|
-
const {
|
|
5510
|
-
type: typeString,
|
|
5511
|
-
components: size,
|
|
5512
|
-
byteLength: stride,
|
|
5513
|
-
normalized
|
|
5514
|
-
/* , integer*/
|
|
5515
|
-
} = decoded;
|
|
5516
|
-
const divisor = attribute.stepMode === "instance" ? 1 : 0;
|
|
5517
|
-
const type = getWebGLDataType(typeString);
|
|
5518
|
-
this.vertexArrayObject.setBuffer(attribute.location, webglBuffer, {
|
|
5519
|
-
size,
|
|
5520
|
-
type,
|
|
5521
|
-
stride,
|
|
5522
|
-
offset: 0,
|
|
5523
|
-
normalized,
|
|
5524
|
-
// it is the shader attribute declaration, not the vertex memory format,
|
|
5525
|
-
// that determines if the data in the buffer will be treated as integers.
|
|
5526
|
-
// /
|
|
5527
|
-
// Also note that WebGL supports assigning non-normalized integer data to floating point attributes,
|
|
5528
|
-
// but as far as we can tell, WebGPU does not.
|
|
5529
|
-
integer: false,
|
|
5530
|
-
divisor
|
|
5531
|
-
});
|
|
5532
5478
|
}
|
|
5533
5479
|
}
|
|
5534
5480
|
/**
|
|
5535
5481
|
* Constant attributes are only supported in WebGL, not in WebGPU
|
|
5536
5482
|
* Any attribute that is disabled in the current vertex array object
|
|
5537
5483
|
* is read from the context's global constant value for that attribute location.
|
|
5538
|
-
* @param attributes
|
|
5484
|
+
* @param attributes
|
|
5539
5485
|
*/
|
|
5540
5486
|
setConstantAttributes(attributes) {
|
|
5541
|
-
for (const [name, value] of Object.entries(attributes)) {
|
|
5542
|
-
const attribute = getAttributeLayout(this.layout, name);
|
|
5543
|
-
if (!attribute) {
|
|
5544
|
-
import_core24.log.warn(`Ignoring constant value supplied for unknown attribute "${name}" in pipeline "${this.id}"`)();
|
|
5545
|
-
continue;
|
|
5546
|
-
}
|
|
5547
|
-
this.vertexArrayObject.setConstant(attribute.location, value);
|
|
5548
|
-
}
|
|
5549
5487
|
Object.assign(this.constantAttributes, attributes);
|
|
5550
5488
|
}
|
|
5551
|
-
/**
|
|
5489
|
+
/**
|
|
5552
5490
|
* Bindings include: textures, samplers and uniform buffers
|
|
5553
|
-
* @todo needed for portable model
|
|
5491
|
+
* @todo needed for portable model
|
|
5554
5492
|
*/
|
|
5555
5493
|
setBindings(bindings) {
|
|
5556
|
-
for (const [
|
|
5557
|
-
const binding = this.
|
|
5494
|
+
for (const [name2, value] of Object.entries(bindings)) {
|
|
5495
|
+
const binding = this.shaderLayout.bindings.find((binding2) => binding2.name === name2);
|
|
5558
5496
|
if (!binding) {
|
|
5559
|
-
|
|
5497
|
+
import_core23.log.warn(`Unknown binding ${name2} in render pipeline ${this.id}`)();
|
|
5560
5498
|
continue;
|
|
5561
5499
|
}
|
|
5562
5500
|
if (!value) {
|
|
5563
|
-
|
|
5501
|
+
import_core23.log.warn(`Unsetting binding ${name2} in render pipeline ${this.id}`)();
|
|
5564
5502
|
}
|
|
5565
5503
|
switch (binding.type) {
|
|
5566
5504
|
case "uniform":
|
|
@@ -5574,12 +5512,12 @@ var WEBGLRenderPipeline = class extends import_core24.RenderPipeline {
|
|
|
5574
5512
|
}
|
|
5575
5513
|
break;
|
|
5576
5514
|
case "sampler":
|
|
5577
|
-
|
|
5515
|
+
import_core23.log.warn(`Ignoring sampler ${name2}`)();
|
|
5578
5516
|
break;
|
|
5579
5517
|
default:
|
|
5580
5518
|
throw new Error(binding.type);
|
|
5581
5519
|
}
|
|
5582
|
-
this.bindings[
|
|
5520
|
+
this.bindings[name2] = value;
|
|
5583
5521
|
}
|
|
5584
5522
|
}
|
|
5585
5523
|
setUniforms(uniforms) {
|
|
@@ -5601,7 +5539,7 @@ var WEBGLRenderPipeline = class extends import_core24.RenderPipeline {
|
|
|
5601
5539
|
// firstInstance,
|
|
5602
5540
|
// baseVertex
|
|
5603
5541
|
} = options;
|
|
5604
|
-
const drawMode =
|
|
5542
|
+
const drawMode = getGLDrawMode(this.props.topology);
|
|
5605
5543
|
const isIndexed = Boolean(this._indexBuffer);
|
|
5606
5544
|
const indexType = (_a = this._indexBuffer) == null ? void 0 : _a.glIndexType;
|
|
5607
5545
|
const isInstanced = Number(options.instanceCount) > 0;
|
|
@@ -5634,7 +5572,12 @@ var WEBGLRenderPipeline = class extends import_core24.RenderPipeline {
|
|
|
5634
5572
|
} else if (isIndexed) {
|
|
5635
5573
|
this.device.gl.drawElements(drawMode, vertexCount || 0, indexType, firstVertex);
|
|
5636
5574
|
} else if (isInstanced) {
|
|
5637
|
-
(_b = this.device.gl2) == null ? void 0 : _b.drawArraysInstanced(
|
|
5575
|
+
(_b = this.device.gl2) == null ? void 0 : _b.drawArraysInstanced(
|
|
5576
|
+
drawMode,
|
|
5577
|
+
firstVertex,
|
|
5578
|
+
vertexCount || 0,
|
|
5579
|
+
instanceCount || 0
|
|
5580
|
+
);
|
|
5638
5581
|
} else {
|
|
5639
5582
|
this.device.gl.drawArrays(drawMode, firstVertex, vertexCount || 0);
|
|
5640
5583
|
}
|
|
@@ -5652,10 +5595,10 @@ var WEBGLRenderPipeline = class extends import_core24.RenderPipeline {
|
|
|
5652
5595
|
const { gl: gl2 } = this.device;
|
|
5653
5596
|
gl2.attachShader(this.handle, this.vs.handle);
|
|
5654
5597
|
gl2.attachShader(this.handle, this.fs.handle);
|
|
5655
|
-
|
|
5598
|
+
import_core23.log.time(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
5656
5599
|
gl2.linkProgram(this.handle);
|
|
5657
|
-
|
|
5658
|
-
if (gl2.debug ||
|
|
5600
|
+
import_core23.log.timeEnd(LOG_PROGRAM_PERF_PRIORITY, `linkProgram for ${this.id}`)();
|
|
5601
|
+
if (gl2.debug || import_core23.log.level > 0) {
|
|
5659
5602
|
const linked = gl2.getProgramParameter(this.handle, gl2.LINK_STATUS);
|
|
5660
5603
|
if (!linked) {
|
|
5661
5604
|
throw new Error(`Error linking: ${gl2.getProgramInfoLog(this.handle)}`);
|
|
@@ -5686,7 +5629,26 @@ var WEBGLRenderPipeline = class extends import_core24.RenderPipeline {
|
|
|
5686
5629
|
}
|
|
5687
5630
|
return texturesRenderable;
|
|
5688
5631
|
}
|
|
5689
|
-
/**
|
|
5632
|
+
/**
|
|
5633
|
+
* Constant attributes need to be reset before every draw call
|
|
5634
|
+
* Any attribute that is disabled in the current vertex array object
|
|
5635
|
+
* is read from the context's global constant value for that attribute location.
|
|
5636
|
+
* @note Constant attributes are only supported in WebGL, not in WebGPU
|
|
5637
|
+
*/
|
|
5638
|
+
_applyConstantAttributes() {
|
|
5639
|
+
const attributeInfos = (0, import_core24.getAttributeInfosFromLayouts)(this.shaderLayout, this.bufferLayout);
|
|
5640
|
+
for (const [name2, value] of Object.entries(this.constantAttributes)) {
|
|
5641
|
+
const attributeInfo = attributeInfos[name2];
|
|
5642
|
+
if (!attributeInfo) {
|
|
5643
|
+
import_core23.log.warn(
|
|
5644
|
+
`Ignoring constant value supplied for unknown attribute "${name2}" in pipeline "${this.id}"`
|
|
5645
|
+
)();
|
|
5646
|
+
continue;
|
|
5647
|
+
}
|
|
5648
|
+
this.vertexArrayObject.setConstant(attributeInfo.location, value);
|
|
5649
|
+
}
|
|
5650
|
+
}
|
|
5651
|
+
/** Apply any bindings (before each draw call) */
|
|
5690
5652
|
_applyBindings() {
|
|
5691
5653
|
this.device.gl.useProgram(this.handle);
|
|
5692
5654
|
const { gl2 } = this.device;
|
|
@@ -5695,17 +5657,17 @@ var WEBGLRenderPipeline = class extends import_core24.RenderPipeline {
|
|
|
5695
5657
|
}
|
|
5696
5658
|
let textureUnit = 0;
|
|
5697
5659
|
let uniformBufferIndex = 0;
|
|
5698
|
-
for (const binding of this.
|
|
5660
|
+
for (const binding of this.shaderLayout.bindings) {
|
|
5699
5661
|
const value = this.bindings[binding.name];
|
|
5700
5662
|
if (!value) {
|
|
5701
5663
|
throw new Error(`No value for binding ${binding.name} in ${this.id}`);
|
|
5702
5664
|
}
|
|
5703
5665
|
switch (binding.type) {
|
|
5704
5666
|
case "uniform":
|
|
5705
|
-
const { name } = binding;
|
|
5706
|
-
const location = gl2.getUniformBlockIndex(this.handle,
|
|
5667
|
+
const { name: name2 } = binding;
|
|
5668
|
+
const location = gl2.getUniformBlockIndex(this.handle, name2);
|
|
5707
5669
|
if (location === import_constants25.GL.INVALID_INDEX) {
|
|
5708
|
-
throw new Error(`Invalid uniform block name ${
|
|
5670
|
+
throw new Error(`Invalid uniform block name ${name2}`);
|
|
5709
5671
|
}
|
|
5710
5672
|
gl2.uniformBlockBinding(this.handle, uniformBufferIndex, location);
|
|
5711
5673
|
if (value instanceof WEBGLBuffer) {
|
|
@@ -5738,33 +5700,22 @@ var WEBGLRenderPipeline = class extends import_core24.RenderPipeline {
|
|
|
5738
5700
|
}
|
|
5739
5701
|
}
|
|
5740
5702
|
}
|
|
5703
|
+
/**
|
|
5704
|
+
* Due to program sharing, uniforms need to be reset before every draw call
|
|
5705
|
+
* (though caching will avoid redundant WebGL calls)
|
|
5706
|
+
*/
|
|
5741
5707
|
_applyUniforms() {
|
|
5742
5708
|
var _a;
|
|
5743
|
-
for (const uniformLayout of this.
|
|
5744
|
-
const { name, location, type, textureUnit } = uniformLayout;
|
|
5745
|
-
const value = (_a = this.uniforms[
|
|
5709
|
+
for (const uniformLayout of this.shaderLayout.uniforms || []) {
|
|
5710
|
+
const { name: name2, location, type, textureUnit } = uniformLayout;
|
|
5711
|
+
const value = (_a = this.uniforms[name2]) != null ? _a : textureUnit;
|
|
5746
5712
|
if (value !== void 0) {
|
|
5747
5713
|
setUniform(this.device.gl, location, type, value);
|
|
5748
5714
|
}
|
|
5749
5715
|
}
|
|
5750
5716
|
}
|
|
5751
|
-
/**
|
|
5752
|
-
* Constant attributes are only supported in WebGL, not in WebGPU
|
|
5753
|
-
* Any attribute that is disabled in the current vertex array object
|
|
5754
|
-
* is read from the context's global constant value for that attribute location.
|
|
5755
|
-
*/
|
|
5756
|
-
_applyConstantAttributes() {
|
|
5757
|
-
for (const [name, value] of Object.entries(this.constantAttributes)) {
|
|
5758
|
-
const attribute = getAttributeLayout(this.layout, name);
|
|
5759
|
-
if (!attribute) {
|
|
5760
|
-
import_core24.log.warn(`Ignoring constant value supplied for unknown attribute "${name}" in pipeline "${this.id}"`)();
|
|
5761
|
-
continue;
|
|
5762
|
-
}
|
|
5763
|
-
this.vertexArrayObject.setConstant(attribute.location, value);
|
|
5764
|
-
}
|
|
5765
|
-
}
|
|
5766
5717
|
};
|
|
5767
|
-
function
|
|
5718
|
+
function getGLDrawMode(topology) {
|
|
5768
5719
|
switch (topology) {
|
|
5769
5720
|
case "point-list":
|
|
5770
5721
|
return import_constants25.GL.POINTS;
|
|
@@ -5804,9 +5755,6 @@ function getGLPrimitive(topology) {
|
|
|
5804
5755
|
throw new Error(topology);
|
|
5805
5756
|
}
|
|
5806
5757
|
}
|
|
5807
|
-
function getAttributeLayout(layout, name) {
|
|
5808
|
-
return layout.attributes.find((binding) => binding.name === name) || null;
|
|
5809
|
-
}
|
|
5810
5758
|
|
|
5811
5759
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
5812
5760
|
var import_core26 = require("@luma.gl/core");
|
|
@@ -6011,7 +5959,7 @@ function getFramebuffer(source) {
|
|
|
6011
5959
|
// src/adapter/resources/webgl-command-encoder.ts
|
|
6012
5960
|
var WEBGLCommandEncoder = class extends import_core26.CommandEncoder {
|
|
6013
5961
|
constructor(device, props) {
|
|
6014
|
-
super(props);
|
|
5962
|
+
super(device, props);
|
|
6015
5963
|
this.device = device;
|
|
6016
5964
|
this.commandBuffer = new WEBGLCommandBuffer(device);
|
|
6017
5965
|
}
|