@luma.gl/webgl 9.1.0-beta.8 → 9.1.0
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/webgl-texture-table.js +1 -1
- package/dist/adapter/converters/webgl-texture-table.js.map +1 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +1 -3
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +2 -2
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +2 -4
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +0 -1
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +4 -11
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +1 -5
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +1 -6
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-adapter.d.ts +2 -1
- package/dist/adapter/webgl-adapter.d.ts.map +1 -1
- package/dist/adapter/webgl-adapter.js +8 -2
- package/dist/adapter/webgl-adapter.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts +6 -3
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +17 -6
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +6 -10
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +25 -23
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/dist.dev.js +44 -44
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +44 -44
- package/dist/index.cjs.map +2 -2
- package/package.json +3 -3
- package/src/adapter/converters/webgl-texture-table.ts +2 -2
- package/src/adapter/resources/webgl-buffer.ts +1 -3
- package/src/adapter/resources/webgl-framebuffer.ts +2 -2
- package/src/adapter/resources/webgl-render-pass.ts +2 -5
- package/src/adapter/resources/webgl-render-pipeline.ts +5 -12
- package/src/adapter/resources/webgl-shader.ts +1 -7
- package/src/adapter/resources/webgl-texture.ts +1 -6
- package/src/adapter/webgl-adapter.ts +10 -3
- package/src/adapter/webgl-canvas-context.ts +19 -8
- package/src/adapter/webgl-device.ts +36 -38
package/dist/index.cjs
CHANGED
|
@@ -963,7 +963,7 @@ var WEBGL_TEXTURE_FORMATS = {
|
|
|
963
963
|
// , filter: true},
|
|
964
964
|
"rg11b10ufloat": { gl: 35898, rb: true },
|
|
965
965
|
"rgb10a2unorm": { gl: 32857, rb: true },
|
|
966
|
-
"rgb10a2uint": { gl: 36975, rb: true },
|
|
966
|
+
"rgb10a2uint-webgl": { gl: 36975, rb: true },
|
|
967
967
|
// 48-bit formats
|
|
968
968
|
"rgb16unorm-webgl": { gl: 32852 },
|
|
969
969
|
// rgb not renderable
|
|
@@ -1345,7 +1345,7 @@ var WEBGLFramebuffer = class extends import_core4.Framebuffer {
|
|
|
1345
1345
|
this.gl = device.gl;
|
|
1346
1346
|
this.handle = this.props.handle || isDefaultFramebuffer ? this.props.handle : this.gl.createFramebuffer();
|
|
1347
1347
|
if (!isDefaultFramebuffer) {
|
|
1348
|
-
device.
|
|
1348
|
+
device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
|
|
1349
1349
|
this.autoCreateAttachmentTextures();
|
|
1350
1350
|
this.updateAttachments();
|
|
1351
1351
|
}
|
|
@@ -1445,7 +1445,9 @@ function _getFrameBufferStatus(status) {
|
|
|
1445
1445
|
// dist/adapter/webgl-canvas-context.js
|
|
1446
1446
|
var WebGLCanvasContext = class extends import_core5.CanvasContext {
|
|
1447
1447
|
device;
|
|
1448
|
-
|
|
1448
|
+
format = "rgba8unorm";
|
|
1449
|
+
depthStencilFormat = "depth24plus";
|
|
1450
|
+
presentationSize;
|
|
1449
1451
|
_framebuffer = null;
|
|
1450
1452
|
get [Symbol.toStringTag]() {
|
|
1451
1453
|
return "WebGLCanvasContext";
|
|
@@ -1453,14 +1455,23 @@ var WebGLCanvasContext = class extends import_core5.CanvasContext {
|
|
|
1453
1455
|
constructor(device, props) {
|
|
1454
1456
|
super(props);
|
|
1455
1457
|
this.device = device;
|
|
1458
|
+
this.presentationSize = [-1, -1];
|
|
1456
1459
|
this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
|
|
1457
|
-
this.
|
|
1460
|
+
this.update();
|
|
1458
1461
|
}
|
|
1459
1462
|
getCurrentFramebuffer() {
|
|
1463
|
+
this.update();
|
|
1460
1464
|
this._framebuffer = this._framebuffer || new WEBGLFramebuffer(this.device, { handle: null });
|
|
1461
1465
|
return this._framebuffer;
|
|
1462
1466
|
}
|
|
1463
|
-
|
|
1467
|
+
/** Resizes and updates render targets if necessary */
|
|
1468
|
+
update() {
|
|
1469
|
+
const size = this.getPixelSize();
|
|
1470
|
+
const sizeChanged = size[0] !== this.presentationSize[0] || size[1] !== this.presentationSize[1];
|
|
1471
|
+
if (sizeChanged) {
|
|
1472
|
+
this.presentationSize = size;
|
|
1473
|
+
this.resize();
|
|
1474
|
+
}
|
|
1464
1475
|
}
|
|
1465
1476
|
/**
|
|
1466
1477
|
* Resize the canvas' drawing buffer.
|
|
@@ -1479,7 +1490,7 @@ var WebGLCanvasContext = class extends import_core5.CanvasContext {
|
|
|
1479
1490
|
return;
|
|
1480
1491
|
if (this.canvas) {
|
|
1481
1492
|
const devicePixelRatio = this.getDevicePixelRatio(options == null ? void 0 : options.useDevicePixels);
|
|
1482
|
-
this.
|
|
1493
|
+
this.setDevicePixelRatio(devicePixelRatio, options);
|
|
1483
1494
|
return;
|
|
1484
1495
|
}
|
|
1485
1496
|
}
|
|
@@ -1681,9 +1692,7 @@ var WEBGLBuffer = class extends import_core8.Buffer {
|
|
|
1681
1692
|
this.gl = this.device.gl;
|
|
1682
1693
|
const handle = typeof props === "object" ? props.handle : void 0;
|
|
1683
1694
|
this.handle = handle || this.gl.createBuffer();
|
|
1684
|
-
device.
|
|
1685
|
-
spector: { ...this.props, data: typeof this.props.data }
|
|
1686
|
-
});
|
|
1695
|
+
device.setSpectorMetadata(this.handle, { ...this.props, data: typeof this.props.data });
|
|
1687
1696
|
this.glTarget = getWebGLTarget(this.props.usage);
|
|
1688
1697
|
this.glUsage = getWebGLUsage(this.props.usage);
|
|
1689
1698
|
this.glIndexType = this.props.indexType === "uint32" ? 5125 : 5123;
|
|
@@ -1850,7 +1859,6 @@ var WEBGLShader = class extends import_core9.Shader {
|
|
|
1850
1859
|
default:
|
|
1851
1860
|
throw new Error(this.props.stage);
|
|
1852
1861
|
}
|
|
1853
|
-
device._setWebGLDebugMetadata(this.handle, this, { spector: this.props });
|
|
1854
1862
|
this._compile(this.source);
|
|
1855
1863
|
}
|
|
1856
1864
|
destroy() {
|
|
@@ -1858,7 +1866,6 @@ var WEBGLShader = class extends import_core9.Shader {
|
|
|
1858
1866
|
this.removeStats();
|
|
1859
1867
|
this.device.gl.deleteShader(this.handle);
|
|
1860
1868
|
this.destroyed = true;
|
|
1861
|
-
this.handle.destroyed = true;
|
|
1862
1869
|
}
|
|
1863
1870
|
}
|
|
1864
1871
|
get asyncCompilationStatus() {
|
|
@@ -2664,12 +2671,7 @@ var WEBGLTexture = class extends import_core14.Texture {
|
|
|
2664
2671
|
// eslint-disable-next-line max-statements
|
|
2665
2672
|
_initialize(propsWithData) {
|
|
2666
2673
|
this.handle = this.props.handle || this.gl.createTexture();
|
|
2667
|
-
this.device.
|
|
2668
|
-
spector: {
|
|
2669
|
-
...this.props,
|
|
2670
|
-
data: propsWithData.data
|
|
2671
|
-
}
|
|
2672
|
-
});
|
|
2674
|
+
this.device.setSpectorMetadata(this.handle, { ...this.props, data: propsWithData.data });
|
|
2673
2675
|
let { width, height } = propsWithData;
|
|
2674
2676
|
if (!width || !height) {
|
|
2675
2677
|
const textureSize = import_core14.Texture.getTextureDataSize(propsWithData.data);
|
|
@@ -2995,14 +2997,13 @@ var WEBGLRenderPass = class extends import_core15.RenderPass {
|
|
|
2995
2997
|
const { width, height } = props.framebuffer;
|
|
2996
2998
|
viewport = [0, 0, width, height];
|
|
2997
2999
|
} else {
|
|
2998
|
-
const [width, height] = device.
|
|
3000
|
+
const [width, height] = device.getCanvasContext().getDrawingBufferSize();
|
|
2999
3001
|
viewport = [0, 0, width, height];
|
|
3000
3002
|
}
|
|
3001
3003
|
}
|
|
3002
3004
|
this.device.pushState();
|
|
3003
3005
|
this.setParameters({ viewport, ...this.props.parameters });
|
|
3004
|
-
|
|
3005
|
-
if (webglFramebuffer == null ? void 0 : webglFramebuffer.handle) {
|
|
3006
|
+
if (this.props.framebuffer) {
|
|
3006
3007
|
const drawBuffers = this.props.framebuffer.colorAttachments.map((_, i) => 36064 + i);
|
|
3007
3008
|
this.device.gl.drawBuffers(drawBuffers);
|
|
3008
3009
|
} else {
|
|
@@ -3587,14 +3588,11 @@ var WEBGLRenderPipeline = class extends import_core16.RenderPipeline {
|
|
|
3587
3588
|
_uniformCount = 0;
|
|
3588
3589
|
_uniformSetters = {};
|
|
3589
3590
|
// TODO are these used?
|
|
3590
|
-
get [Symbol.toStringTag]() {
|
|
3591
|
-
return "WEBGLRenderPipeline";
|
|
3592
|
-
}
|
|
3593
3591
|
constructor(device, props) {
|
|
3594
3592
|
super(device, props);
|
|
3595
3593
|
this.device = device;
|
|
3596
3594
|
this.handle = this.props.handle || this.device.gl.createProgram();
|
|
3597
|
-
this.device.
|
|
3595
|
+
this.device.setSpectorMetadata(this.handle, { id: this.props.id });
|
|
3598
3596
|
this.vs = props.vs;
|
|
3599
3597
|
this.fs = props.fs;
|
|
3600
3598
|
const { varyings, bufferMode = 35981 } = props;
|
|
@@ -3603,18 +3601,15 @@ var WEBGLRenderPipeline = class extends import_core16.RenderPipeline {
|
|
|
3603
3601
|
this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
|
|
3604
3602
|
}
|
|
3605
3603
|
this._linkShaders();
|
|
3606
|
-
import_core16.log.time(
|
|
3604
|
+
import_core16.log.time(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
3607
3605
|
this.introspectedLayout = getShaderLayoutFromGLSL(this.device.gl, this.handle);
|
|
3608
|
-
import_core16.log.timeEnd(
|
|
3606
|
+
import_core16.log.timeEnd(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
|
|
3609
3607
|
this.shaderLayout = mergeShaderLayout(this.introspectedLayout, props.shaderLayout);
|
|
3610
3608
|
}
|
|
3611
3609
|
destroy() {
|
|
3612
3610
|
if (this.handle) {
|
|
3613
|
-
this.device.gl.useProgram(null);
|
|
3614
3611
|
this.device.gl.deleteProgram(this.handle);
|
|
3615
3612
|
this.destroyed = true;
|
|
3616
|
-
this.handle.destroyed = true;
|
|
3617
|
-
this.handle = null;
|
|
3618
3613
|
}
|
|
3619
3614
|
}
|
|
3620
3615
|
/**
|
|
@@ -4654,7 +4649,9 @@ var WEBGLQuerySet = class extends import_core21.QuerySet {
|
|
|
4654
4649
|
|
|
4655
4650
|
// dist/adapter/webgl-device.js
|
|
4656
4651
|
var WebGLDevice = class extends import_core22.Device {
|
|
4652
|
+
//
|
|
4657
4653
|
// Public `Device` API
|
|
4654
|
+
//
|
|
4658
4655
|
/** type of this device */
|
|
4659
4656
|
type = "webgl";
|
|
4660
4657
|
/** The underlying WebGL context */
|
|
@@ -4663,8 +4660,6 @@ var WebGLDevice = class extends import_core22.Device {
|
|
|
4663
4660
|
limits;
|
|
4664
4661
|
info;
|
|
4665
4662
|
canvasContext;
|
|
4666
|
-
preferredColorFormat = "rgba8unorm";
|
|
4667
|
-
preferredDepthFormat = "depth24plus";
|
|
4668
4663
|
lost;
|
|
4669
4664
|
_resolveContextLost;
|
|
4670
4665
|
/** WebGL2 context. */
|
|
@@ -4702,7 +4697,8 @@ var WebGLDevice = class extends import_core22.Device {
|
|
|
4702
4697
|
if (props.powerPreference !== void 0) {
|
|
4703
4698
|
webglContextAttributes.powerPreference = props.powerPreference;
|
|
4704
4699
|
}
|
|
4705
|
-
const
|
|
4700
|
+
const externalGLContext = this.props._handle;
|
|
4701
|
+
const gl = externalGLContext || createBrowserContext(this.canvasContext.canvas, {
|
|
4706
4702
|
onContextLost: (event) => {
|
|
4707
4703
|
var _a2;
|
|
4708
4704
|
return (_a2 = this._resolveContextLost) == null ? void 0 : _a2.call(this, {
|
|
@@ -4731,6 +4727,9 @@ var WebGLDevice = class extends import_core22.Device {
|
|
|
4731
4727
|
if (this.props._initializeFeatures) {
|
|
4732
4728
|
this.features.initializeFeatures();
|
|
4733
4729
|
}
|
|
4730
|
+
if (canvasContextProps.autoResize !== false) {
|
|
4731
|
+
this.canvasContext.resize();
|
|
4732
|
+
}
|
|
4734
4733
|
const glState = new WebGLStateTracker(this.gl, {
|
|
4735
4734
|
log: (...args) => import_core22.log.log(1, ...args)()
|
|
4736
4735
|
});
|
|
@@ -4871,6 +4870,13 @@ var WebGLDevice = class extends import_core22.Device {
|
|
|
4871
4870
|
const webglState = WebGLStateTracker.get(this.gl);
|
|
4872
4871
|
webglState.pop();
|
|
4873
4872
|
}
|
|
4873
|
+
/**
|
|
4874
|
+
* Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
|
|
4875
|
+
* luma.gl ids and props can be inspected
|
|
4876
|
+
*/
|
|
4877
|
+
setSpectorMetadata(handle, props) {
|
|
4878
|
+
handle.__SPECTOR_Metadata = props;
|
|
4879
|
+
}
|
|
4874
4880
|
/**
|
|
4875
4881
|
* Returns the GL.<KEY> constant that corresponds to a numeric value of a GL constant
|
|
4876
4882
|
* Be aware that there are some duplicates especially for constants that are 0,
|
|
@@ -4930,16 +4936,6 @@ var WebGLDevice = class extends import_core22.Device {
|
|
|
4930
4936
|
getWebGLExtension(this.gl, name, this._extensions);
|
|
4931
4937
|
return this._extensions;
|
|
4932
4938
|
}
|
|
4933
|
-
// INTERNAL SUPPORT METHODS FOR WEBGL RESOURCES
|
|
4934
|
-
/**
|
|
4935
|
-
* Storing data on a special field on WebGLObjects makes that data visible in SPECTOR chrome debug extension
|
|
4936
|
-
* luma.gl ids and props can be inspected
|
|
4937
|
-
*/
|
|
4938
|
-
_setWebGLDebugMetadata(handle, resource, options) {
|
|
4939
|
-
handle.luma = resource;
|
|
4940
|
-
const spectorMetadata = { props: options.spector, id: options.spector.id };
|
|
4941
|
-
handle.__SPECTOR_Metadata = spectorMetadata;
|
|
4942
|
-
}
|
|
4943
4939
|
};
|
|
4944
4940
|
function setConstantFloatArray(device, location, array) {
|
|
4945
4941
|
switch (array.length) {
|
|
@@ -5101,7 +5097,8 @@ var WebGLAdapter = class extends import_core23.Adapter {
|
|
|
5101
5097
|
}
|
|
5102
5098
|
/**
|
|
5103
5099
|
* Get a device instance from a GL context
|
|
5104
|
-
* Creates
|
|
5100
|
+
* Creates a WebGLCanvasContext against the contexts canvas
|
|
5101
|
+
* @note autoResize will be disabled, assuming that whoever created the external context will be handling resizes.
|
|
5105
5102
|
* @param gl
|
|
5106
5103
|
* @returns
|
|
5107
5104
|
*/
|
|
@@ -5115,7 +5112,10 @@ var WebGLAdapter = class extends import_core23.Adapter {
|
|
|
5115
5112
|
if (!isWebGL(gl)) {
|
|
5116
5113
|
throw new Error("Invalid WebGL2RenderingContext");
|
|
5117
5114
|
}
|
|
5118
|
-
return new WebGLDevice({
|
|
5115
|
+
return new WebGLDevice({
|
|
5116
|
+
_handle: gl,
|
|
5117
|
+
createCanvasContext: { canvas: gl.canvas, autoResize: false }
|
|
5118
|
+
});
|
|
5119
5119
|
}
|
|
5120
5120
|
async create(props = {}) {
|
|
5121
5121
|
import_core23.log.groupCollapsed(LOG_LEVEL2, "WebGLDevice created")();
|