@luma.gl/webgl 9.0.0-alpha.10 → 9.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/converters/device-parameters.js +1 -12
- package/dist/adapter/converters/device-parameters.js.map +1 -1
- package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
- package/dist/adapter/converters/texture-formats.js +0 -9
- package/dist/adapter/converters/texture-formats.js.map +1 -1
- package/dist/adapter/converters/vertex-formats.d.ts.map +1 -1
- package/dist/adapter/converters/vertex-formats.js +3 -0
- package/dist/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/adapter/device-helpers/device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/adapter/device-helpers/get-device-info.js +4 -0
- package/dist/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +2 -4
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/adapter/helpers/set-uniform.js +1 -1
- package/dist/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/adapter/objects/constants-to-keys.d.ts.map +1 -1
- package/dist/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js +1 -1
- package/dist/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/adapter/objects/webgl-resource.d.ts +2 -4
- package/dist/adapter/objects/webgl-resource.d.ts.map +1 -1
- package/dist/adapter/objects/webgl-resource.js +1 -7
- package/dist/adapter/objects/webgl-resource.js.map +1 -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-buffer.d.ts +0 -1
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +0 -2
- package/dist/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts +0 -1
- package/dist/adapter/resources/webgl-framebuffer.d.ts.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-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +4 -32
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgl-sampler.d.ts +1 -0
- package/dist/adapter/resources/webgl-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-sampler.js +4 -0
- package/dist/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/adapter/resources/webgl-texture.d.ts +2 -2
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +1 -3
- package/dist/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +4 -3
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts +34 -29
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +37 -28
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/classic/buffer.d.ts.map +1 -1
- package/dist/classic/buffer.js.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +1 -7
- package/dist/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
- package/dist/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts +103 -103
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +15 -14
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/context/polyfill/context-data.d.ts +13 -0
- package/dist/context/polyfill/context-data.d.ts.map +1 -0
- package/dist/context/polyfill/context-data.js +14 -0
- package/dist/context/polyfill/context-data.js.map +1 -0
- package/dist/context/polyfill/get-parameter-polyfill.d.ts +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.d.ts.map +1 -1
- package/dist/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/context/polyfill/polyfill-context.js +4 -4
- package/dist/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/context/polyfill/polyfill-table.d.ts +7 -7
- package/dist/context/polyfill/polyfill-table.d.ts.map +1 -1
- package/dist/context/polyfill/polyfill-table.js +5 -4
- package/dist/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/context/state-tracker/track-context-state.d.ts.map +1 -1
- package/dist/context/state-tracker/track-context-state.js +0 -1
- package/dist/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +1 -1
- package/dist/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/es5/adapter/converters/device-parameters.js +1 -12
- package/dist/es5/adapter/converters/device-parameters.js.map +1 -1
- package/dist/es5/adapter/converters/texture-formats.js +1 -10
- package/dist/es5/adapter/converters/texture-formats.js.map +1 -1
- package/dist/es5/adapter/converters/vertex-formats.js +3 -0
- package/dist/es5/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/es5/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/es5/adapter/device-helpers/get-device-info.js +4 -0
- package/dist/es5/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/es5/adapter/helpers/get-shader-layout.js +2 -4
- package/dist/es5/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/es5/adapter/helpers/set-uniform.js +1 -1
- package/dist/es5/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/es5/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/es5/adapter/objects/webgl-renderbuffer.js +1 -1
- package/dist/es5/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/es5/adapter/objects/webgl-resource.js +1 -6
- package/dist/es5/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/es5/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-buffer.js +0 -1
- package/dist/es5/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-framebuffer.js +2 -1
- package/dist/es5/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-render-pipeline.js +2 -38
- package/dist/es5/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-sampler.js +5 -0
- package/dist/es5/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/es5/adapter/resources/webgl-texture.js +1 -7
- package/dist/es5/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/es5/adapter/webgl-canvas-context.js +3 -4
- package/dist/es5/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/es5/adapter/webgl-device.js +38 -27
- package/dist/es5/adapter/webgl-device.js.map +1 -1
- package/dist/es5/classic/buffer.js.map +1 -1
- package/dist/es5/context/debug/webgl-developer-tools.js +1 -7
- package/dist/es5/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/es5/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/es5/context/parameters/webgl-parameter-tables.js +10 -9
- package/dist/es5/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/es5/context/polyfill/context-data.js +21 -0
- package/dist/es5/context/polyfill/context-data.js.map +1 -0
- package/dist/es5/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/es5/context/polyfill/polyfill-context.js +4 -4
- package/dist/es5/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/es5/context/polyfill/polyfill-table.js +5 -4
- package/dist/es5/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/es5/context/state-tracker/track-context-state.js +0 -1
- package/dist/es5/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/es5/context/state-tracker/with-parameters.js +4 -2
- package/dist/es5/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/es5/index.js +0 -14
- package/dist/es5/index.js.map +1 -1
- package/dist/esm/adapter/converters/device-parameters.js +1 -12
- package/dist/esm/adapter/converters/device-parameters.js.map +1 -1
- package/dist/esm/adapter/converters/texture-formats.js +0 -9
- package/dist/esm/adapter/converters/texture-formats.js.map +1 -1
- package/dist/esm/adapter/converters/vertex-formats.js +3 -0
- package/dist/esm/adapter/converters/vertex-formats.js.map +1 -1
- package/dist/esm/adapter/device-helpers/device-features.js.map +1 -1
- package/dist/esm/adapter/device-helpers/get-device-info.js +4 -0
- package/dist/esm/adapter/device-helpers/get-device-info.js.map +1 -1
- package/dist/esm/adapter/helpers/get-shader-layout.js +2 -4
- package/dist/esm/adapter/helpers/get-shader-layout.js.map +1 -1
- package/dist/esm/adapter/helpers/set-uniform.js +1 -1
- package/dist/esm/adapter/helpers/set-uniform.js.map +1 -1
- package/dist/esm/adapter/objects/constants-to-keys.js.map +1 -1
- package/dist/esm/adapter/objects/webgl-renderbuffer.js +1 -1
- package/dist/esm/adapter/objects/webgl-renderbuffer.js.map +1 -1
- package/dist/esm/adapter/objects/webgl-resource.js +1 -7
- package/dist/esm/adapter/objects/webgl-resource.js.map +1 -1
- package/dist/esm/adapter/objects/webgl-vertex-array-object.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-buffer.js +0 -2
- package/dist/esm/adapter/resources/webgl-buffer.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-command-encoder.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-framebuffer.js +2 -2
- package/dist/esm/adapter/resources/webgl-framebuffer.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-render-pipeline.js +4 -32
- package/dist/esm/adapter/resources/webgl-render-pipeline.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-sampler.js +4 -0
- package/dist/esm/adapter/resources/webgl-sampler.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-shader.js.map +1 -1
- package/dist/esm/adapter/resources/webgl-texture.js +1 -3
- package/dist/esm/adapter/resources/webgl-texture.js.map +1 -1
- package/dist/esm/adapter/webgl-canvas-context.js +4 -3
- package/dist/esm/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/esm/adapter/webgl-device.js +37 -28
- package/dist/esm/adapter/webgl-device.js.map +1 -1
- package/dist/esm/classic/buffer.js.map +1 -1
- package/dist/esm/context/debug/webgl-developer-tools.js +1 -7
- package/dist/esm/context/debug/webgl-developer-tools.js.map +1 -1
- package/dist/esm/context/parameters/unified-parameter-api.js.map +1 -1
- package/dist/esm/context/parameters/webgl-parameter-tables.js +15 -14
- package/dist/esm/context/parameters/webgl-parameter-tables.js.map +1 -1
- package/dist/esm/context/polyfill/context-data.js +14 -0
- package/dist/esm/context/polyfill/context-data.js.map +1 -0
- package/dist/esm/context/polyfill/get-parameter-polyfill.js.map +1 -1
- package/dist/esm/context/polyfill/polyfill-context.js +4 -4
- package/dist/esm/context/polyfill/polyfill-context.js.map +1 -1
- package/dist/esm/context/polyfill/polyfill-table.js +5 -4
- package/dist/esm/context/polyfill/polyfill-table.js.map +1 -1
- package/dist/esm/context/state-tracker/track-context-state.js +0 -1
- package/dist/esm/context/state-tracker/track-context-state.js.map +1 -1
- package/dist/esm/context/state-tracker/with-parameters.js +1 -1
- package/dist/esm/context/state-tracker/with-parameters.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/adapter/converters/device-parameters.ts +11 -11
- package/src/adapter/converters/texture-formats.ts +12 -12
- package/src/adapter/converters/vertex-formats.ts +1 -0
- package/src/adapter/device-helpers/device-features.ts +0 -1
- package/src/adapter/device-helpers/get-device-info.ts +5 -1
- package/src/adapter/helpers/get-shader-layout.ts +18 -15
- package/src/adapter/helpers/set-uniform.ts +1 -1
- package/src/adapter/objects/constants-to-keys.ts +4 -1
- package/src/adapter/objects/webgl-renderbuffer.ts +5 -5
- package/src/adapter/objects/webgl-resource.ts +7 -12
- package/src/adapter/objects/webgl-vertex-array-object.ts +4 -4
- package/src/adapter/resources/webgl-buffer.ts +4 -4
- package/src/adapter/resources/webgl-command-encoder.ts +4 -4
- package/src/adapter/resources/webgl-framebuffer.ts +6 -5
- package/src/adapter/resources/webgl-render-pipeline.ts +24 -23
- package/src/adapter/resources/webgl-sampler.ts +5 -1
- package/src/adapter/resources/webgl-shader.ts +1 -1
- package/src/adapter/resources/webgl-texture.ts +5 -7
- package/src/adapter/webgl-canvas-context.ts +2 -3
- package/src/adapter/webgl-device.ts +69 -59
- package/src/classic/buffer.ts +7 -4
- package/src/context/debug/webgl-developer-tools.ts +7 -7
- package/src/context/parameters/unified-parameter-api.ts +1 -1
- package/src/context/parameters/webgl-parameter-tables.ts +113 -94
- package/src/context/polyfill/context-data.ts +27 -0
- package/src/context/polyfill/get-parameter-polyfill.ts +7 -6
- package/src/context/polyfill/polyfill-context.ts +5 -5
- package/src/context/polyfill/polyfill-table.ts +14 -13
- package/src/context/state-tracker/track-context-state.ts +0 -1
- package/src/context/state-tracker/with-parameters.ts +2 -1
- package/src/index.ts +0 -3
- package/dist/context/context/context-state.d.ts +0 -18
- package/dist/context/context/context-state.d.ts.map +0 -1
- package/dist/context/context/context-state.js +0 -26
- package/dist/context/context/context-state.js.map +0 -1
- package/dist/context/context/device-pixels.d.ts +0 -25
- package/dist/context/context/device-pixels.d.ts.map +0 -1
- package/dist/context/context/device-pixels.js +0 -103
- package/dist/context/context/device-pixels.js.map +0 -1
- package/dist/es5/context/context/context-state.js +0 -31
- package/dist/es5/context/context/context-state.js.map +0 -1
- package/dist/es5/context/context/device-pixels.js +0 -121
- package/dist/es5/context/context/device-pixels.js.map +0 -1
- package/dist/esm/context/context/context-state.js +0 -26
- package/dist/esm/context/context/context-state.js.map +0 -1
- package/dist/esm/context/context/device-pixels.js +0 -103
- package/dist/esm/context/context/device-pixels.js.map +0 -1
- package/src/context/context/context-state.ts +0 -41
- package/src/context/context/device-pixels.ts +0 -158
|
@@ -74,7 +74,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
74
74
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
75
75
|
|
|
76
76
|
var LOG_LEVEL = 1;
|
|
77
|
-
var counter = 0;
|
|
78
77
|
|
|
79
78
|
var WebGLDevice = function (_Device) {
|
|
80
79
|
(0, _inherits2.default)(WebGLDevice, _Device);
|
|
@@ -87,7 +86,9 @@ var WebGLDevice = function (_Device) {
|
|
|
87
86
|
var _this;
|
|
88
87
|
|
|
89
88
|
(0, _classCallCheck2.default)(this, WebGLDevice);
|
|
90
|
-
_this = _super.call(this, props)
|
|
89
|
+
_this = _super.call(this, _objectSpread(_objectSpread({}, props), {}, {
|
|
90
|
+
id: props.id || (0, _api.uid)('webgl-device')
|
|
91
|
+
}));
|
|
91
92
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "info", void 0);
|
|
92
93
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "canvasContext", void 0);
|
|
93
94
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handle", void 0);
|
|
@@ -95,12 +96,12 @@ var WebGLDevice = function (_Device) {
|
|
|
95
96
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_resolveContextLost", void 0);
|
|
96
97
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_features", void 0);
|
|
97
98
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_limits", void 0);
|
|
99
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderPass", null);
|
|
98
100
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "gl", void 0);
|
|
99
101
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "gl2", null);
|
|
100
102
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "debug", false);
|
|
101
103
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isWebGL1", void 0);
|
|
102
104
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isWebGL2", void 0);
|
|
103
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_webglLimits", void 0);
|
|
104
105
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_canvasSizeInfo", {
|
|
105
106
|
clientWidth: 0,
|
|
106
107
|
clientHeight: 0,
|
|
@@ -109,7 +110,7 @@ var WebGLDevice = function (_Device) {
|
|
|
109
110
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_extensions", {});
|
|
110
111
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_polyfilled", false);
|
|
111
112
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "spector", void 0);
|
|
112
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
113
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_webglLimits", void 0);
|
|
113
114
|
var device = (_props$gl = props.gl) === null || _props$gl === void 0 ? void 0 : _props$gl.device;
|
|
114
115
|
|
|
115
116
|
if (device) {
|
|
@@ -130,7 +131,7 @@ var WebGLDevice = function (_Device) {
|
|
|
130
131
|
});
|
|
131
132
|
};
|
|
132
133
|
|
|
133
|
-
var gl = props.gl;
|
|
134
|
+
var gl = props.gl || null;
|
|
134
135
|
gl = gl || ((0, _env.isBrowser)() ? (0, _createBrowserContext.createBrowserContext)(_this.canvasContext.canvas, _objectSpread(_objectSpread({}, props), {}, {
|
|
135
136
|
onContextLost: onContextLost
|
|
136
137
|
})) : null);
|
|
@@ -207,12 +208,6 @@ var WebGLDevice = function (_Device) {
|
|
|
207
208
|
this._limits = this._limits || (0, _deviceLimits.getDeviceLimits)(this.gl);
|
|
208
209
|
return this._limits;
|
|
209
210
|
}
|
|
210
|
-
}, {
|
|
211
|
-
key: "webglLimits",
|
|
212
|
-
get: function get() {
|
|
213
|
-
this._webglLimits = this._webglLimits || (0, _deviceLimits.getWebGLLimits)(this.gl);
|
|
214
|
-
return this._webglLimits;
|
|
215
|
-
}
|
|
216
211
|
}, {
|
|
217
212
|
key: "destroy",
|
|
218
213
|
value: function destroy() {
|
|
@@ -222,22 +217,6 @@ var WebGLDevice = function (_Device) {
|
|
|
222
217
|
ext.destroy();
|
|
223
218
|
}
|
|
224
219
|
}
|
|
225
|
-
}, {
|
|
226
|
-
key: "loseDevice",
|
|
227
|
-
value: function loseDevice() {
|
|
228
|
-
var _this$_resolveContext2;
|
|
229
|
-
|
|
230
|
-
var ext = this.gl.getExtension('WEBGL_lose_context');
|
|
231
|
-
|
|
232
|
-
if (ext) {
|
|
233
|
-
ext.loseContext();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
(_this$_resolveContext2 = this._resolveContextLost) === null || _this$_resolveContext2 === void 0 ? void 0 : _this$_resolveContext2.call(this, {
|
|
237
|
-
reason: 'destroyed',
|
|
238
|
-
message: 'Application triggered context loss'
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
220
|
}, {
|
|
242
221
|
key: "isLost",
|
|
243
222
|
get: function get() {
|
|
@@ -343,6 +322,38 @@ var WebGLDevice = function (_Device) {
|
|
|
343
322
|
(_this$renderPass = this.renderPass) === null || _this$renderPass === void 0 ? void 0 : _this$renderPass.endPass();
|
|
344
323
|
this.renderPass = null;
|
|
345
324
|
}
|
|
325
|
+
}, {
|
|
326
|
+
key: "webglLimits",
|
|
327
|
+
get: function get() {
|
|
328
|
+
this._webglLimits = this._webglLimits || (0, _deviceLimits.getWebGLLimits)(this.gl);
|
|
329
|
+
return this._webglLimits;
|
|
330
|
+
}
|
|
331
|
+
}, {
|
|
332
|
+
key: "loseDevice",
|
|
333
|
+
value: function loseDevice() {
|
|
334
|
+
var _this$_resolveContext2;
|
|
335
|
+
|
|
336
|
+
var ext = this.gl.getExtension('WEBGL_lose_context');
|
|
337
|
+
|
|
338
|
+
if (ext) {
|
|
339
|
+
ext.loseContext();
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
(_this$_resolveContext2 = this._resolveContextLost) === null || _this$_resolveContext2 === void 0 ? void 0 : _this$_resolveContext2.call(this, {
|
|
343
|
+
reason: 'destroyed',
|
|
344
|
+
message: 'Application triggered context loss'
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}, {
|
|
348
|
+
key: "pushState",
|
|
349
|
+
value: function pushState() {
|
|
350
|
+
(0, _trackContextState.pushContextState)(this.gl);
|
|
351
|
+
}
|
|
352
|
+
}, {
|
|
353
|
+
key: "popState",
|
|
354
|
+
value: function popState() {
|
|
355
|
+
(0, _trackContextState.popContextState)(this.gl);
|
|
356
|
+
}
|
|
346
357
|
}], [{
|
|
347
358
|
key: "isSupported",
|
|
348
359
|
value: function isSupported() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapter/webgl-device.ts"],"names":["LOG_LEVEL","counter","WebGLDevice","props","clientWidth","clientHeight","devicePixelRatio","device","gl","Error","id","canvasContext","WebGLCanvasContext","lost","Promise","resolve","_resolveContextLost","onContextLost","event","reason","message","canvas","handle","gl2","isWebGL2","isWebGL1","info","_version","enable","copyState","log","args","debug","webgl2","throwOnError","level","Math","max","warn","spector","type","vendor","renderer","probe","groupEnd","_features","_limits","_webglLimits","ext","getExtension","destroy","loseContext","isContextLost","drawingBufferWidth","drawingBufferHeight","format","ClassicBuffer","WEBGLTexture","WEBGLSampler","WEBGLShader","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLRenderPass","renderPass","beginRenderPass","framebuffer","getCurrentFramebuffer","endPass","WebGLRenderingContext","Device","isWebGL","groupCollapsed","CanvasContext","pageLoaded","attach","WebGL2RenderingContext","Boolean","Number","isFinite"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA0BA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,SAAS,GAAG,CAAlB;AAEA,IAAIC,OAAO,GAAG,CAAd;;IAGqBC,W;;;;;AAwHnB,uBAAYC,KAAZ,EAAgC;AAAA;;AAAA;;AAAA;AAC9B,8BAAMA,KAAN;AAD8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sFAjFc,IAiFd;AAAA,wFAhFN,KAgFM;AAAA;AAAA;AAAA;AAAA,kGAjEL;AAACC,MAAAA,WAAW,EAAE,CAAd;AAAiBC,MAAAA,YAAY,EAAE,CAA/B;AAAkCC,MAAAA,gBAAgB,EAAE;AAApD,KAiEK;AAAA,8FA/DY,EA+DZ;AAAA,8FA9DT,KA8DS;AAAA;AAAA,6FA0La,IA1Lb;AAK9B,QAAMC,MAA+B,gBAAGJ,KAAK,CAACK,EAAT,8CAAG,UAAUD,MAAlD;;AACA,QAAIA,MAAJ,EAAY;AACV,YAAM,IAAIE,KAAJ,oDAAsDF,MAAM,CAACG,EAA7D,EAAN;AACD;;AAGD,UAAKC,aAAL,GAAqB,IAAIC,2BAAJ,8CAA6BT,KAA7B,CAArB;AAEA,UAA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;AAAA,uBAeU,6BAfV;;AAAA;AAkBET,yBAAIa,KAAJ,CAAU3C,SAAS,GAAG,CAAtB,EAAyB,eAAzB;;AAlBF,sBAqBMG,KAAK,CAACK,EAAN,IAAYL,KAAK,CAACK,EAAN,CAASD,MArB3B;AAAA;AAAA;AAAA;;AAAA,iDAsBWL,WAAW,CAACwE,MAAZ,CAAmBvE,KAAK,CAACK,EAAzB,CAtBX;;AAAA;AAAA,iDAyBS,IAAIN,WAAJ,CAAgBC,KAAhB,CAzBT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EAxFuCkE,W;;;8BAApBnE,W,UAKG,O;;AAqUxB,SAASoE,OAAT,CAAiB9D,EAAjB,EAAmC;AACjC,MAAI,OAAO4D,qBAAP,KAAiC,WAAjC,IAAgD5D,EAAE,YAAY4D,qBAAlE,EAAyF;AACvF,WAAO,IAAP;AACD;;AACD,MAAI,OAAOO,sBAAP,KAAkC,WAAlC,IAAiDnE,EAAE,YAAYmE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACpE,EAAE,IAAIqE,MAAM,CAACC,QAAP,CAAgBtE,EAAE,CAACmB,QAAnB,CAAP,CAAd;AACD;;AAGD,SAASH,QAAT,CAAkBhB,EAAlB,EAAoC;AAClC,MAAI,OAAOmE,sBAAP,KAAkC,WAAlC,IAAiDnE,EAAE,YAAYmE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACpE,EAAE,IAAIA,EAAE,CAACmB,QAAH,KAAgB,CAAvB,CAAd;AACD","sourcesContent":["// luma.gl, MIT license\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, assert} from '@luma.gl/api';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {trackContextState} from '../context/state-tracker/track-context-state';\nimport {ContextState} from '../context/context/context-state';\nimport {createBrowserContext} from '../context/context/create-browser-context';\nimport {\n createHeadlessContext,\n isHeadlessGLRegistered\n} from '../context/context/create-headless-context';\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\nimport WebGLCanvasContext from './webgl-canvas-context';\nimport {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';\nimport {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';\nimport {\n isTextureFormatSupported,\n isTextureFormatRenderable,\n isTextureFormatFilterable\n} from './converters/texture-formats';\n\n// WebGL classes\nimport type {\n BufferProps,\n ShaderProps,\n Sampler,\n SamplerProps,\n TextureProps,\n ExternalTexture,\n ExternalTextureProps,\n FramebufferProps,\n RenderPipeline,\n RenderPipelineProps,\n ComputePipeline,\n ComputePipelineProps,\n RenderPass,\n RenderPassProps,\n ComputePass,\n ComputePassProps\n} from '@luma.gl/api';\n\nimport ClassicBuffer from '../classic/buffer';\nimport WEBGLBuffer from './resources/webgl-buffer';\nimport WEBGLShader from './resources/webgl-shader';\nimport WEBGLSampler from './resources/webgl-sampler';\nimport WEBGLTexture from './resources/webgl-texture';\nimport WEBGLFramebuffer from './resources/webgl-framebuffer';\nimport WEBGLRenderPass from './resources/webgl-render-pass';\nimport WEBGLRenderPipeline from './resources/webgl-render-pipeline';\n\nconst LOG_LEVEL = 1;\n\nlet counter = 0;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device implements ContextState {\n //\n // Public `Device` API\n //\n\n static type: string = 'webgl';\n\n static isSupported(): boolean {\n return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();\n }\n\n readonly info: DeviceInfo;\n readonly canvasContext: WebGLCanvasContext;\n\n readonly handle: WebGLRenderingContext;\n\n get features(): Set<DeviceFeature> {\n this._features = this._features || getDeviceFeatures(this.gl);\n return this._features;\n }\n\n get limits(): DeviceLimits {\n this._limits = this._limits || getDeviceLimits(this.gl);\n return this._limits;\n }\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;\n private _features?: Set<DeviceFeature>;\n private _limits?: DeviceLimits;\n\n //\n // WebGL-only API (not part of `Device` API)\n //\n\n /** WebGL1 typed context. Can always be used. */\n readonly gl: WebGLRenderingContext;\n /** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */\n readonly gl2: WebGL2RenderingContext | null = null;\n readonly debug: boolean = false;\n\n /** `true` if this is a WebGL1 context. @note `false` if WebGL2 */\n readonly isWebGL1: boolean;\n /** `true` if this is a WebGL2 context. @note `false` if WebGL1 */\n readonly isWebGL2: boolean;\n\n get webglLimits(): WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n private _webglLimits?: WebGLLimits;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n /** State used by luma.gl classes */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\n\n //\n // Static methods, expected to be present by `luma.createDevice()`\n //\n\n /**\n * Get a device instance from a GL context\n * Creates and instruments the device if not already created\n * @param gl\n * @returns\n */\n static attach(gl: Device | WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice {\n if (gl instanceof WebGLDevice) {\n return gl;\n }\n // @ts-expect-error\n if (gl?.device instanceof Device) {\n // @ts-expect-error\n return gl.device as WebGLDevice;\n }\n if (!isWebGL(gl)) {\n throw new Error('Invalid WebGLRenderingContext');\n }\n return new WebGLDevice({gl: gl as WebGLRenderingContext});\n }\n\n static async create(props: DeviceProps = {}): Promise<WebGLDevice> {\n log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');\n\n // Wait for page to load. Only wait when props. canvas is string\n // to avoid setting page onload callback unless necessary\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n }\n\n // Load webgl and spector debug scripts from CDN if requested\n if (props.debug) {\n await loadWebGLDeveloperTools();\n }\n // @ts-expect-error spector not on props\n if (props.spector) {\n await loadSpectorJS();\n }\n\n log.probe(LOG_LEVEL + 1, 'DOM is loaded')();\n\n // @ts-expect-error\n if (props.gl && props.gl.device) {\n return WebGLDevice.attach(props.gl);\n }\n\n return new WebGLDevice(props);\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super(props);\n\n // If attaching to an already attached context, return the attached device\n // @ts-expect-error device is attached to context\n const device: WebGLDevice | undefined = props.gl?.device;\n if (device) {\n throw new Error(`WebGL context already attached to device ${device.id}`);\n }\n\n // Create and instrument context\n this.canvasContext = new WebGLCanvasContext(this, props);\n\n this.lost = new Promise<{reason: 'destroyed'; message: string}>((resolve) => {\n this._resolveContextLost = resolve;\n });\n\n const onContextLost = (event: Event) =>\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'\n });\n\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl;\n gl =\n gl ||\n (isBrowser() ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost}) : null);\n gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);\n\n if (!gl) {\n throw new Error('WebGL context creation failed');\n }\n\n this.handle = gl;\n this.gl = this.handle;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this.isWebGL1 = !this.isWebGL2;\n\n // luma Device fields\n this.info = getDeviceInfo(this.gl);\n\n // @ts-expect-error Link webgl context back to device\n this.gl.device = this;\n // @ts-expect-error Annotate webgl context to handle\n this.gl._version = this.isWebGL2 ? 2 : 1;\n\n // Add subset of WebGL2 methods to WebGL1 context\n polyfillContext(this.gl);\n\n // Install context state tracking\n // @ts-expect-error - hidden parameters\n const {enable = true, copyState = false} = props;\n trackContextState(this.gl, {\n enable,\n copyState,\n log: (...args: any[]) => log.log(1, ...args)()\n });\n\n // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1\n if (isBrowser() && props.debug) {\n this.gl = makeDebugContext(this.gl, {...props, webgl2: this.isWebGL2, throwOnError: true});\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.debug = true;\n log.level = Math.max(log.level, 1);\n log.warn('WebGL debug mode activated. Performance reduced.')();\n }\n\n // @ts-expect-error spector not on props\n if (isBrowser() && props.spector) {\n const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);\n this.spector = initializeSpectorJS({...this.props, canvas});\n }\n\n // Log some debug info about the newly created context\n const message = `\\\nCreated ${this.info.type}${this.debug ? ' debug' : ''} context: \\\n${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n\n log.groupEnd(LOG_LEVEL)();\n }\n\n /**\n * Destroys the context\n * @note Has no effect for browser contexts, there is no browser API for destroying contexts\n */\n destroy() {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n /**\n * Loses the context\n * @note Triggers context loss, mainly for testing\n */\n loseDevice() {\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n ext.loseContext();\n }\n // loseContext should trigger context loss callback but \n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\n });\n }\n\n get isLost(): boolean {\n return this.gl.isContextLost();\n }\n\n getSize(): [number, number] {\n return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return isTextureFormatSupported(this.gl, format);\n }\n\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return isTextureFormatFilterable(this.gl, format);\n }\n\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return isTextureFormatRenderable(this.gl, format);\n }\n\n // WEBGL SPECIFIC METHODS\n\n /** Returns a WebGL2RenderingContext or throws an error */\n assertWebGL2(): WebGL2RenderingContext {\n if (!this.gl2) {\n throw new Error('Requires WebGL2');\n }\n return this.gl2;\n }\n\n // IMPLEMENTATION OF ABSTRACT DEVICE\n\n createCanvasContext(props?: CanvasContextProps): CanvasContext {\n throw new Error('WebGL only supports a single canvas');\n }\n\n _createBuffer(props: BufferProps): WEBGLBuffer {\n return new ClassicBuffer(this, props);\n }\n\n _createTexture(props: TextureProps): WEBGLTexture {\n return new WEBGLTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): ExternalTexture {\n throw new Error('createExternalTexture() not implemented'); // return new Program(props);\n }\n\n createSampler(props: SamplerProps): WEBGLSampler {\n return new WEBGLSampler(this, props);\n }\n\n createShader(props: ShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WEBGLFramebuffer {\n return new WEBGLFramebuffer(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n beginRenderPass(props: RenderPassProps): WEBGLRenderPass {\n return new WEBGLRenderPass(this, props);\n }\n\n createComputePipeline(props?: ComputePipelineProps): ComputePipeline {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n\n beginComputePass(props: ComputePassProps): ComputePass {\n throw new Error('compute shaders not supported in WebGL');\n }\n\n private renderPass: WEBGLRenderPass | null = null;\n\n getDefaultRenderPass(): WEBGLRenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n submit(): void {\n this.renderPass?.endPass();\n this.renderPass = null;\n // this.canvasContext.commit();\n }\n}\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nfunction isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nfunction isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\n}\n"],"file":"webgl-device.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/adapter/webgl-device.ts"],"names":["LOG_LEVEL","WebGLDevice","props","id","clientWidth","clientHeight","devicePixelRatio","device","gl","Error","canvasContext","WebGLCanvasContext","lost","Promise","resolve","_resolveContextLost","onContextLost","event","reason","message","canvas","handle","gl2","isWebGL2","isWebGL1","info","_version","enable","copyState","log","args","debug","webgl2","throwOnError","level","Math","max","warn","spector","type","vendor","renderer","probe","groupEnd","_features","_limits","ext","getExtension","destroy","isContextLost","drawingBufferWidth","drawingBufferHeight","format","ClassicBuffer","WEBGLTexture","WEBGLSampler","WEBGLShader","WEBGLFramebuffer","WEBGLRenderPipeline","WEBGLRenderPass","renderPass","beginRenderPass","framebuffer","getCurrentFramebuffer","endPass","_webglLimits","loseContext","WebGLRenderingContext","Device","isWebGL","groupCollapsed","CanvasContext","pageLoaded","attach","WebGL2RenderingContext","Boolean","Number","isFinite"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA0BA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,SAAS,GAAG,CAAlB;;IAGqBC,W;;;;;AAyFnB,uBAAYC,KAAZ,EAAgC;A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jC,MAAI,OAAO2D,qBAAP,KAAiC,WAAjC,IAAgD3D,EAAE,YAAY2D,qBAAlE,EAAyF;AACvF,WAAO,IAAP;AACD;;AACD,MAAI,OAAOO,sBAAP,KAAkC,WAAlC,IAAiDlE,EAAE,YAAYkE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACnE,EAAE,IAAIoE,MAAM,CAACC,QAAP,CAAgBrE,EAAE,CAACkB,QAAnB,CAAP,CAAd;AACD;;AAGD,SAASH,QAAT,CAAkBf,EAAlB,EAAoC;AAClC,MAAI,OAAOkE,sBAAP,KAAkC,WAAlC,IAAiDlE,EAAE,YAAYkE,sBAAnE,EAA2F;AACzF,WAAO,IAAP;AACD;;AAED,SAAOC,OAAO,CAACnE,EAAE,IAAIA,EAAE,CAACkB,QAAH,KAAgB,CAAvB,CAAd;AACD","sourcesContent":["// luma.gl, MIT license\nimport type {\n DeviceProps,\n DeviceInfo,\n DeviceLimits,\n DeviceFeature,\n CanvasContextProps,\n TextureFormat\n} from '@luma.gl/api';\nimport {Device, CanvasContext, log, uid} from '@luma.gl/api';\nimport {isBrowser} from '@probe.gl/env';\nimport {polyfillContext} from '../context/polyfill/polyfill-context';\nimport {popContextState, pushContextState, trackContextState} from '../context/state-tracker/track-context-state';\nimport {createBrowserContext} from '../context/context/create-browser-context';\nimport {\n createHeadlessContext,\n isHeadlessGLRegistered\n} from '../context/context/create-headless-context';\nimport {getDeviceInfo} from './device-helpers/get-device-info';\nimport {getDeviceFeatures} from './device-helpers/device-features';\nimport {getDeviceLimits, getWebGLLimits, WebGLLimits} from './device-helpers/device-limits';\nimport WebGLCanvasContext from './webgl-canvas-context';\nimport {loadSpectorJS, initializeSpectorJS} from '../context/debug/spector';\nimport {loadWebGLDeveloperTools, makeDebugContext} from '../context/debug/webgl-developer-tools';\nimport {\n isTextureFormatSupported,\n isTextureFormatRenderable,\n isTextureFormatFilterable\n} from './converters/texture-formats';\n\n// WebGL classes\nimport type {\n BufferProps,\n ShaderProps,\n // Sampler,\n SamplerProps,\n TextureProps,\n ExternalTexture,\n ExternalTextureProps,\n FramebufferProps,\n // RenderPipeline,\n RenderPipelineProps,\n ComputePipeline,\n ComputePipelineProps,\n // RenderPass,\n RenderPassProps,\n ComputePass,\n ComputePassProps\n} from '@luma.gl/api';\n\nimport ClassicBuffer from '../classic/buffer';\nimport WEBGLBuffer from './resources/webgl-buffer';\nimport WEBGLShader from './resources/webgl-shader';\nimport WEBGLSampler from './resources/webgl-sampler';\nimport WEBGLTexture from './resources/webgl-texture';\nimport WEBGLFramebuffer from './resources/webgl-framebuffer';\nimport WEBGLRenderPass from './resources/webgl-render-pass';\nimport WEBGLRenderPipeline from './resources/webgl-render-pipeline';\n\nconst LOG_LEVEL = 1;\n\n/** WebGPU style Device API for a WebGL context */\nexport default class WebGLDevice extends Device {\n //\n // Public `Device` API\n //\n\n static type: string = 'webgl';\n\n static isSupported(): boolean {\n return typeof WebGLRenderingContext !== 'undefined' || isHeadlessGLRegistered();\n }\n\n readonly info: DeviceInfo;\n readonly canvasContext: WebGLCanvasContext;\n\n readonly handle: WebGLRenderingContext;\n\n get features(): Set<DeviceFeature> {\n this._features = this._features || getDeviceFeatures(this.gl);\n return this._features;\n }\n\n get limits(): DeviceLimits {\n this._limits = this._limits || getDeviceLimits(this.gl);\n return this._limits;\n }\n\n readonly lost: Promise<{reason: 'destroyed'; message: string}>;\n\n private _resolveContextLost?: (value: {reason: 'destroyed'; message: string}) => void;\n private _features?: Set<DeviceFeature>;\n private _limits?: DeviceLimits;\n\n //\n // Static methods, expected to be present by `luma.createDevice()`\n //\n\n /**\n * Get a device instance from a GL context\n * Creates and instruments the device if not already created\n * @param gl\n * @returns\n */\n static attach(gl: Device | WebGLRenderingContext | WebGL2RenderingContext): WebGLDevice {\n if (gl instanceof WebGLDevice) {\n return gl;\n }\n // @ts-expect-error\n if (gl?.device instanceof Device) {\n // @ts-expect-error\n return gl.device as WebGLDevice;\n }\n if (!isWebGL(gl)) {\n throw new Error('Invalid WebGLRenderingContext');\n }\n return new WebGLDevice({gl: gl as WebGLRenderingContext});\n }\n\n static async create(props: DeviceProps = {}): Promise<WebGLDevice> {\n log.groupCollapsed(LOG_LEVEL, 'WebGLDevice created');\n\n // Wait for page to load. Only wait when props. canvas is string\n // to avoid setting page onload callback unless necessary\n if (typeof props.canvas === 'string') {\n await CanvasContext.pageLoaded;\n }\n\n // Load webgl and spector debug scripts from CDN if requested\n if (props.debug) {\n await loadWebGLDeveloperTools();\n }\n // @ts-expect-error spector not on props\n if (props.spector) {\n await loadSpectorJS();\n }\n\n log.probe(LOG_LEVEL + 1, 'DOM is loaded')();\n\n // @ts-expect-error\n if (props.gl && props.gl.device) {\n return WebGLDevice.attach(props.gl);\n }\n\n return new WebGLDevice(props);\n }\n\n //\n // Public API\n //\n\n constructor(props: DeviceProps) {\n super({...props, id: props.id || uid('webgl-device')});\n\n // If attaching to an already attached context, return the attached device\n // @ts-expect-error device is attached to context\n const device: WebGLDevice | undefined = props.gl?.device;\n if (device) {\n throw new Error(`WebGL context already attached to device ${device.id}`);\n }\n\n // Create and instrument context\n this.canvasContext = new WebGLCanvasContext(this, props);\n\n this.lost = new Promise<{reason: 'destroyed'; message: string}>((resolve) => {\n this._resolveContextLost = resolve;\n });\n\n const onContextLost = (event: Event) =>\n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Computer entered sleep mode, or too many apps or browser tabs are using the GPU.'\n });\n\n let gl: WebGLRenderingContext | WebGL2RenderingContext | null = props.gl || null;\n gl =\n gl ||\n (isBrowser() ? createBrowserContext(this.canvasContext.canvas, {...props, onContextLost}) : null);\n gl = gl || (!isBrowser() ? createHeadlessContext({...props, onContextLost}) : null);\n\n if (!gl) {\n throw new Error('WebGL context creation failed');\n }\n\n this.handle = gl;\n this.gl = this.handle;\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.isWebGL2 = isWebGL2(this.gl);\n this.isWebGL1 = !this.isWebGL2;\n\n // luma Device fields\n this.info = getDeviceInfo(this.gl);\n\n // @ts-expect-error Link webgl context back to device\n this.gl.device = this;\n // @ts-expect-error Annotate webgl context to handle\n this.gl._version = this.isWebGL2 ? 2 : 1;\n\n // Add subset of WebGL2 methods to WebGL1 context\n polyfillContext(this.gl);\n\n // Install context state tracking\n // @ts-expect-error - hidden parameters\n const {enable = true, copyState = false} = props;\n trackContextState(this.gl, {\n enable,\n copyState,\n log: (...args: any[]) => log.log(1, ...args)()\n });\n\n // DEBUG contexts: Add debug instrumentation to the context, force log level to at least 1\n if (isBrowser() && props.debug) {\n this.gl = makeDebugContext(this.gl, {...props, webgl2: this.isWebGL2, throwOnError: true});\n this.gl2 = this.gl as WebGL2RenderingContext;\n this.debug = true;\n log.level = Math.max(log.level, 1);\n log.warn('WebGL debug mode activated. Performance reduced.')();\n }\n\n // @ts-expect-error spector not on props\n if (isBrowser() && props.spector) {\n const canvas = this.handle.canvas || (props.canvas as HTMLCanvasElement);\n this.spector = initializeSpectorJS({...this.props, canvas});\n }\n\n // Log some debug info about the newly created context\n const message = `\\\nCreated ${this.info.type}${this.debug ? ' debug' : ''} context: \\\n${this.info.vendor}, ${this.info.renderer} for canvas: ${this.canvasContext.id}`;\n log.probe(LOG_LEVEL, message)();\n\n log.groupEnd(LOG_LEVEL)();\n }\n\n /**\n * Destroys the context\n * @note Has no effect for browser contexts, there is no browser API for destroying contexts\n */\n destroy(): void {\n const ext = this.gl.getExtension('STACKGL_destroy_context');\n if (ext) {\n ext.destroy();\n }\n }\n\n get isLost(): boolean {\n return this.gl.isContextLost();\n }\n\n getSize(): [number, number] {\n return [this.gl.drawingBufferWidth, this.gl.drawingBufferHeight];\n }\n\n isTextureFormatSupported(format: TextureFormat): boolean {\n return isTextureFormatSupported(this.gl, format);\n }\n\n isTextureFormatFilterable(format: TextureFormat): boolean {\n return isTextureFormatFilterable(this.gl, format);\n }\n\n isTextureFormatRenderable(format: TextureFormat): boolean {\n return isTextureFormatRenderable(this.gl, format);\n }\n\n // WEBGL SPECIFIC METHODS\n\n /** Returns a WebGL2RenderingContext or throws an error */\n assertWebGL2(): WebGL2RenderingContext {\n if (!this.gl2) {\n throw new Error('Requires WebGL2');\n }\n return this.gl2;\n }\n\n // IMPLEMENTATION OF ABSTRACT DEVICE\n\n createCanvasContext(props?: CanvasContextProps): CanvasContext {\n throw new Error('WebGL only supports a single canvas');\n }\n\n _createBuffer(props: BufferProps): WEBGLBuffer {\n return new ClassicBuffer(this, props);\n }\n\n _createTexture(props: TextureProps): WEBGLTexture {\n return new WEBGLTexture(this, props);\n }\n\n createExternalTexture(props: ExternalTextureProps): ExternalTexture {\n throw new Error('createExternalTexture() not implemented'); // return new Program(props);\n }\n\n createSampler(props: SamplerProps): WEBGLSampler {\n return new WEBGLSampler(this, props);\n }\n\n createShader(props: ShaderProps): WEBGLShader {\n return new WEBGLShader(this, props);\n }\n\n createFramebuffer(props: FramebufferProps): WEBGLFramebuffer {\n return new WEBGLFramebuffer(this, props);\n }\n\n createRenderPipeline(props: RenderPipelineProps): WEBGLRenderPipeline {\n return new WEBGLRenderPipeline(this, props);\n }\n\n beginRenderPass(props: RenderPassProps): WEBGLRenderPass {\n return new WEBGLRenderPass(this, props);\n }\n\n createComputePipeline(props?: ComputePipelineProps): ComputePipeline {\n throw new Error('ComputePipeline not supported in WebGL');\n }\n\n beginComputePass(props: ComputePassProps): ComputePass {\n throw new Error('compute shaders not supported in WebGL');\n }\n\n private renderPass: WEBGLRenderPass | null = null;\n\n getDefaultRenderPass(): WEBGLRenderPass {\n this.renderPass =\n this.renderPass ||\n this.beginRenderPass({\n framebuffer: this.canvasContext.getCurrentFramebuffer()\n });\n return this.renderPass;\n }\n\n /**\n * Offscreen Canvas Support: Commit the frame\n * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/commit\n * Chrome's offscreen canvas does not require gl.commit\n */\n submit(): void {\n this.renderPass?.endPass();\n this.renderPass = null;\n // this.canvasContext.commit();\n }\n\n //\n // WebGL-only API (not part of `Device` API)\n //\n\n /** WebGL1 typed context. Can always be used. */\n readonly gl: WebGLRenderingContext;\n /** WebGL2 typed context. Need to check isWebGL2 or isWebGL1 before using. */\n readonly gl2: WebGL2RenderingContext | null = null;\n readonly debug: boolean = false;\n\n /** `true` if this is a WebGL1 context. @note `false` if WebGL2 */\n readonly isWebGL1: boolean;\n /** `true` if this is a WebGL2 context. @note `false` if WebGL1 */\n readonly isWebGL2: boolean;\n\n /** State used by luma.gl classes: TODO - move to canvasContext*/\n readonly _canvasSizeInfo = {clientWidth: 0, clientHeight: 0, devicePixelRatio: 1};\n\n /** State used by luma.gl classes - TODO - not used? */\n readonly _extensions: Record<string, any> = {};\n _polyfilled: boolean = false;\n\n /** Instance of Spector.js (if initialized) */\n spector;\n\n private _webglLimits?: WebGLLimits;\n\n /** Return WebGL specific limits */\n get webglLimits() : WebGLLimits {\n this._webglLimits = this._webglLimits || getWebGLLimits(this.gl);\n return this._webglLimits;\n }\n\n /**\n * Loses the context\n * @note Triggers context loss, mainly for testing\n * @todo Promote to `Device` API?\n */\n loseDevice(): void {\n const ext = this.gl.getExtension('WEBGL_lose_context');\n if (ext) {\n ext.loseContext();\n }\n // loseContext should trigger context loss callback but \n this._resolveContextLost?.({\n reason: 'destroyed',\n message: 'Application triggered context loss'\n });\n }\n\n /** Save current WebGL context state onto an internal stack */\n pushState(): void {\n pushContextState(this.gl);\n }\n\n /** Restores previously saved context state */\n popState(): void {\n popContextState(this.gl);\n }\n}\n\n/** Check if supplied parameter is a WebGLRenderingContext */\nfunction isWebGL(gl: any): boolean {\n if (typeof WebGLRenderingContext !== 'undefined' && gl instanceof WebGLRenderingContext) {\n return true;\n }\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && Number.isFinite(gl._version));\n}\n\n/** Check if supplied parameter is a WebGL2RenderingContext */\nfunction isWebGL2(gl: any): boolean {\n if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {\n return true;\n }\n // Look for debug contexts, headless gl etc\n return Boolean(gl && gl._version === 2);\n}\n"],"file":"webgl-device.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/classic/buffer.ts"],"names":["DEBUG_DATA_LENGTH","DEPRECATED_PROPS","offset","stride","type","size","divisor","normalized","integer","instanced","isInstanced","PROP_CHECKS_INITIALIZE","removedProps","replacedProps","bytes","deprecatedProps","PROP_CHECKS_SET_PROPS","getWEBGLBufferProps","props","ArrayBuffer","isView","data","byteLength","bufferProps","byteOffset","ClassicBuffer","device","WebGLDevice","attach","setAccessor","Object","assign","accessor","Accessor","seal","handle","removeStats","trackDeallocatedMemory","gl","deleteBuffer","destroyed","subData","Math","round","getBytesPerElement","getBytesPerVertex","Number","isFinite","webglUsage","GL","STATIC_DRAW","debugData","_setData","_setByteLength","buffer","bytesUsed","initialize","options","srcOffset","length","target","webgl2","COPY_WRITE_BUFFER","bindBuffer","undefined","bufferSubData","_inferType","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","bindBufferRange","bindBufferBase","isIndexedBuffer","getData","changed","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getElementCount","pname","value","getBufferParameter","WEBGLBuffer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,IAAMA,iBAAiB,GAAG,EAA1B;AAGA,IAAMC,gBAAgB,GAAG;AACvBC,EAAAA,MAAM,EAAE,iBADe;AAEvBC,EAAAA,MAAM,EAAE,iBAFe;AAGvBC,EAAAA,I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,KAAKF,MAApD;AACD;;;WAED,mCAA0Bc,aAA1B,EAAiD;AAC/C,UAAME,SAAS,GAAG,8CAAwB,KAAK5C,QAAL,CAAc5B,IAAd,IAAsB6C,mBAAG4B,KAAjD,EAAwD;AAACC,QAAAA,OAAO,EAAE;AAAV,OAAxD,CAAlB;AACA,UAAMsB,mBAAmB,GAAG1B,aAAa,GAAGE,SAAS,CAACyB,iBAAtD;AACA,aAAO,KAAKC,eAAL,KAAyBF,mBAAhC;AACD;;;WAID,oBAAW/E,IAAX,EAAiB;AACf,UAAI,CAAC,KAAKW,QAAL,CAAc5B,IAAnB,EAAyB;AACvB,aAAKyB,WAAL,CAAiB,IAAII,iBAAJ,CAAa,KAAKD,QAAlB,EAA4B;AAAC5B,UAAAA,IAAI,EAAE,8CAAwBiB,IAAxB;AAAP,SAA5B,CAAjB;AACD;AACF;;;WAID,sBAAakF,KAAb,EAA6B;AAC3B,WAAKjE,EAAL,CAAQyB,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,KAAKzB,MAArC;AACA,UAAMqE,KAAK,GAAG,KAAKlE,EAAL,CAAQmE,kBAAR,CAA2B,KAAK7C,MAAhC,EAAwC2C,KAAxC,CAAd;AACA,WAAKjE,EAAL,CAAQyB,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,IAAhC;AACA,aAAO4C,KAAP;AACD;;;SAID,eAAW;AACT,aAAO,KAAKxE,QAAL,CAAc5B,IAArB;AACD;;;EAvYwCsG,oB","sourcesContent":["import type {Device, BufferProps, TypedArray} from '@luma.gl/api';\nimport {Buffer, log, assert, checkProps} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {assertWebGL2Context} from '../context/context/webgl-checks';\nimport {AccessorObject} from '../types';\nimport Accessor from './accessor';\nimport {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';\n\nimport WebGLDevice from '../adapter/webgl-device';\nimport WEBGLBuffer from '../adapter/resources/webgl-buffer';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n// Shared prop checks for constructor and setProps\nconst DEPRECATED_PROPS = {\n offset: 'accessor.offset',\n stride: 'accessor.stride',\n type: 'accessor.type',\n size: 'accessor.size',\n divisor: 'accessor.divisor',\n normalized: 'accessor.normalized',\n integer: 'accessor.integer',\n instanced: 'accessor.divisor',\n isInstanced: 'accessor.divisor'\n};\n\n// Prop checks for constructor\nconst PROP_CHECKS_INITIALIZE = {\n removedProps: {},\n replacedProps: {\n bytes: 'byteLength'\n },\n // new Buffer() with individual accessor props is still used in apps, emit warnings\n deprecatedProps: DEPRECATED_PROPS\n};\n\n// Prop checks for setProps\nconst PROP_CHECKS_SET_PROPS = {\n // Buffer.setProps() with individual accessor props is rare => emit errors\n removedProps: DEPRECATED_PROPS\n};\n\nfunction getWEBGLBufferProps(props: ClassicBufferProps | ArrayBufferView | number): BufferProps {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n return {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n else if (typeof props === 'number') {\n return {byteLength: props as number};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props as ClassicBufferProps};\n if (bufferProps.offset) {\n bufferProps.byteOffset = bufferProps.offset;\n }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type ClassicBufferProps = BufferProps & {\n handle?: WebGLBuffer;\n\n target?: number;\n webglUsage?: number;\n\n accessor?: AccessorObject;\n\n /** @deprecated */\n index?: number;\n /** @deprecated */\n offset?: number;\n /** @deprecated */\n size?: number;\n /** @deprecated */\n type?: number\n}\n\n/** WebGL Buffer interface */\nexport default class ClassicBuffer extends WEBGLBuffer {\n usage: number;\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: ClassicBufferProps);\n constructor(device: Device | WebGLRenderingContext, data: ArrayBufferView | number[]);\n constructor(device: Device | WebGLRenderingContext, byteLength: number);\n\n constructor(device: Device | WebGLRenderingContext, props = {}) {\n super(WebGLDevice.attach(device), getWEBGLBufferProps(props));\n\n // Base class initializes\n // this.initialize(props);\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, (props as ClassicBufferProps).accessor));\n\n // infer GL type from supplied typed array\n if (this.props.data) {\n const type = getGLTypeFromTypedArray(this.props.data as TypedArray);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n }\n\n Object.seal(this);\n }\n\n destroy(): void {\n if (this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n write(data: TypedArray, byteOffset?: number): void {\n this.subData({data, offset: byteOffset});\n }\n // returns number of elements in the buffer (assuming that the full buffer is used)\n getElementCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerElement(accessor));\n }\n\n // returns number of vertices in the buffer (assuming that the full buffer is used)\n getVertexCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerVertex(accessor));\n }\n\n // Creates and initializes the buffer object's data store.\n // Signature: `new Buffer(gl, {data: new Float32Array(...)})`\n // Signature: `new Buffer(gl, new Float32Array(...))`\n // Signature: `new Buffer(gl, 100)`\n initialize(props: ClassicBufferProps = {}): this {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n props = {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n if (Number.isFinite(props)) {\n // @ts-expect-error\n props = {byteLength: props};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n\n // Initialize member fields\n this.webglUsage = props.webglUsage || GL.STATIC_DRAW;\n this.debugData = null;\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, props.accessor));\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._setData(props.data, props.offset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: ClassicBufferProps): this {\n props = checkProps('Buffer', props, PROP_CHECKS_SET_PROPS);\n\n if ('accessor' in props) {\n this.setAccessor(props.accessor);\n }\n\n return this;\n }\n\n // Optionally stores an accessor with the buffer, makes it easier to use it as an attribute later\n // {type, size = 1, offset = 0, stride = 0, normalized = false, integer = false, divisor = 0}\n setAccessor(accessor: AccessorObject | Accessor): this {\n // NOTE: From luma.gl v7.0, Accessors have an optional `buffer `field\n // (mainly to support \"interleaving\")\n // To avoid confusion, ensure `buffer.accessor` does not have a `buffer.accessor.buffer` field:\n accessor = Object.assign({}, accessor);\n // @ts-expect-error\n delete accessor.buffer;\n\n // This new statement ensures that an \"accessor object\" is re-packaged as an Accessor instance\n this.accessor = new Accessor(accessor);\n return this;\n }\n\n // Allocate a bigger GPU buffer (if the current buffer is not big enough).\n // If a reallocation is triggered it clears the buffer\n // Returns:\n // `true`: buffer was reallocated, data was cleared\n // `false`: buffer was big enough, data is intact\n reallocate(byteLength: number): boolean {\n if (byteLength > this.byteLength) {\n this._setByteLength(byteLength);\n return true;\n }\n this.bytesUsed = byteLength;\n return false;\n }\n\n // Update with new data. Reinitializes the buffer\n setData(props: ClassicBufferProps) {\n return this.initialize(props);\n }\n\n // Updates a subset of a buffer object's data store.\n // Data (Typed Array or ArrayBuffer), length is inferred unless provided\n // Offset into buffer\n // WebGL2 only: Offset into srcData\n // WebGL2 only: Number of bytes to be copied\n subData(options: TypedArray | {data: TypedArray, offset?: number; srcOffset?: number; byteLength?: number, length?: number}) {\n // Signature: buffer.subData(new Float32Array([...]))\n if (ArrayBuffer.isView(options)) {\n options = {data: options};\n }\n\n const {data, offset = 0, srcOffset = 0} = options;\n const byteLength = options.byteLength || options.length;\n\n assert(data);\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n // @ts-expect-error\n const target = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n assertWebGL2Context(this.gl);\n // @ts-expect-error\n this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, offset, data);\n }\n this.gl.bindBuffer(target, null);\n\n // TODO - update local `data` if offsets are right\n this.debugData = null;\n\n this._inferType(data);\n\n return this;\n }\n\n /**\n * Copies part of the data of another buffer into this buffer\n * @note WEBGL2 ONLY\n */\n copyData(options: {\n sourceBuffer: any;\n readOffset?: number;\n writeOffset?: number;\n size: any;\n }): this {\n const {sourceBuffer, readOffset = 0, writeOffset = 0, size} = options;\n const {gl, gl2} = this;\n assertWebGL2Context(gl);\n\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl.bindBuffer(GL.COPY_READ_BUFFER, sourceBuffer.handle);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, this.handle);\n gl2?.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);\n gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n this.debugData = null;\n\n return this;\n }\n\n /**\n * Reads data from buffer into an ArrayBufferView or SharedArrayBuffer.\n * @note WEBGL2 ONLY\n */\n getData(options?: {\n dstData?: any;\n srcByteOffset?: number;\n dstOffset?: number;\n length?: number;\n }): any {\n let {dstData = null, length = 0} = options || {};\n const {srcByteOffset = 0, dstOffset = 0} = options || {};\n assertWebGL2Context(this.gl);\n\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceAvailableElementCount = this._getAvailableElementCount(srcByteOffset);\n\n const dstElementOffset = dstOffset;\n\n let dstAvailableElementCount;\n let dstElementCount;\n if (dstData) {\n dstElementCount = dstData.length;\n dstAvailableElementCount = dstElementCount - dstElementOffset;\n } else {\n // Allocate ArrayBufferView with enough size to copy all eligible data.\n dstAvailableElementCount = Math.min(\n sourceAvailableElementCount,\n length || sourceAvailableElementCount\n );\n dstElementCount = dstElementOffset + dstAvailableElementCount;\n }\n\n const copyElementCount = Math.min(sourceAvailableElementCount, dstAvailableElementCount);\n length = length || copyElementCount;\n assert(length <= copyElementCount);\n dstData = dstData || new ArrayType(dstElementCount);\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2?.getBufferSubData(GL.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n return dstData;\n }\n\n /**\n * Binds a buffer to a given binding point (target).\n * GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER take an index, and optionally a range.\n * - GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER need an index to affect state\n * - GL.UNIFORM_BUFFER: `offset` must be aligned to GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT.\n * - GL.UNIFORM_BUFFER: `size` must be a minimum of GL.UNIFORM_BLOCK_SIZE_DATA.\n */\n bind(options?: {target?: number; index?: any; offset?: number; size: any}): this {\n const {\n target = this.target, // target for the bind operation\n index = this.accessor && this.accessor.index, // index = index of target (indexed bind point)\n offset = 0,\n size\n } = options || {};\n // NOTE: While GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER could\n // be used as direct binding points, they will not affect transform feedback or\n // uniform buffer state. Instead indexed bindings need to be made.\n if (target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(target, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(target, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(target, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {target?: any; index?: any}): this {\n const {target = this.target, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(target, index, null);\n } else {\n this.gl.bindBuffer(target, null);\n }\n return this;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n // Returns a short initial data array\n getDebugData(): {\n data: any;\n changed: boolean;\n } {\n if (!this.debugData) {\n this.debugData = this.getData({length: Math.min(DEBUG_DATA_LENGTH, this.byteLength)});\n return {data: this.debugData, changed: true};\n }\n return {data: this.debugData, changed: false};\n }\n\n invalidateDebugData() {\n this.debugData = null;\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _setData(data, offset: number = 0, byteLength: number = data.byteLength + offset): this {\n assert(ArrayBuffer.isView(data));\n\n this.trackDeallocatedMemory();\n\n const target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.webglUsage);\n this.gl.bufferSubData(target, offset, data);\n this.gl.bindBuffer(target, null);\n\n this.debugData = data.slice(0, DEBUG_DATA_LENGTH);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this.trackAllocatedMemory(byteLength);\n\n // infer GL type from supplied typed array\n const type = getGLTypeFromTypedArray(data);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _setByteLength(byteLength: number, webglUsage = this.webglUsage): this {\n assert(byteLength >= 0);\n\n this.trackDeallocatedMemory();\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.webglUsage = webglUsage;\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n _getTarget() {\n // @ts-expect-error\n return this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n }\n\n _getAvailableElementCount(srcByteOffset: number) {\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceElementOffset = srcByteOffset / ArrayType.BYTES_PER_ELEMENT;\n return this.getElementCount() - sourceElementOffset;\n }\n\n // Automatically infers type from typed array passed to setData\n // Note: No longer that useful, since type is now autodeduced from the compiled shaders\n _inferType(data) {\n if (!this.accessor.type) {\n this.setAccessor(new Accessor(this.accessor, {type: getGLTypeFromTypedArray(data)}));\n }\n }\n\n // RESOURCE METHODS\n\n getParameter(pname: GL): any {\n this.gl.bindBuffer(this.target, this.handle);\n const value = this.gl.getBufferParameter(this.target, pname);\n this.gl.bindBuffer(this.target, null);\n return value;\n }\n\n // DEPRECATIONS - v7.0\n /** @deprecated Use Buffer.accessor.type */\n get type() {\n return this.accessor.type;\n }\n}\n"],"file":"buffer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/classic/buffer.ts"],"names":["DEBUG_DATA_LENGTH","DEPRECATED_PROPS","offset","stride","type","size","divisor","normalized","integer","instanced","isInstanced","PROP_CHECKS_INITIALIZE","removedProps","replacedProps","bytes","deprecatedProps","PROP_CHECKS_SET_PROPS","getWEBGLBufferProps","props","ArrayBuffer","isView","data","byteLength","bufferProps","byteOffset","ClassicBuffer","device","WebGLDevice","attach","setAccessor","Object","assign","accessor","Accessor","seal","handle","removeStats","trackDeallocatedMemory","gl","deleteBuffer","destroyed","subData","Math","round","getBytesPerElement","getBytesPerVertex","Number","isFinite","webglUsage","GL","STATIC_DRAW","debugData","_setData","_setByteLength","buffer","bytesUsed","initialize","options","srcOffset","length","target","webgl2","COPY_WRITE_BUFFER","bindBuffer","undefined","bufferSubData","_inferType","sourceBuffer","readOffset","writeOffset","gl2","COPY_READ_BUFFER","copyBufferSubData","dstData","srcByteOffset","dstOffset","ArrayType","FLOAT","clamped","sourceAvailableElementCount","_getAvailableElementCount","dstElementOffset","dstAvailableElementCount","dstElementCount","min","copyElementCount","getBufferSubData","index","UNIFORM_BUFFER","TRANSFORM_FEEDBACK_BUFFER","bindBufferRange","bindBufferBase","isIndexedBuffer","getData","changed","_getTarget","bufferData","slice","trackAllocatedMemory","Float32Array","sourceElementOffset","BYTES_PER_ELEMENT","getElementCount","pname","value","getBufferParameter","WEBGLBuffer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,IAAMA,iBAAiB,GAAG,EAA1B;AAGA,IAAMC,gBAAgB,GAAG;AACvBC,EAAAA,MAAM,EAAE,iBADe;AAEvBC,EAAAA,MAAM,EAAE,iBAFe;AAGvBC,EAAAA,IAAI,EAAE,eAHiB;AAIvBC,EAAAA,IAAI,EAAE,eAJiB;AAKvBC,EAAAA,OAAO,EAAE,kBALc;AAMvBC,EAAAA,UAAU,EAAE,qBANW;AAOvBC,EAAAA,OAAO,EAAE,kBAPc;AAQvBC,EAAAA,SAAS,EAAE,kBARY;AASvBC,EAAAA,WAAW,EAAE;AATU,CAAzB;AAaA,IAAMC,sBAAsB,GAAG;AAC7BC,EAAAA,YAAY,EAAE,EADe;AAE7BC,EAAAA,aAAa,EAAE;AACbC,IAAAA,KAAK,EAAE;AADM,GAFc;AAM7BC,EAAAA,eAAe,EAAEd;AANY,CAA/B;AAUA,IAAMe,qBAAqB,GAAG;AAE5BJ,EAAAA,YAAY,EAAEX;AAFc,CAA9B;;AAKA,SAASgB,mBAAT,CAA6BC,KAA7B,EAAgG;AAE9F,MAAIC,WAAW,CAACC,MAAZ,CAAmBF,KAAnB,CAAJ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A6B;AAC3B,WAAKjE,EAAL,CAAQyB,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,KAAKzB,MAArC;AACA,UAAMqE,KAAK,GAAG,KAAKlE,EAAL,CAAQmE,kBAAR,CAA2B,KAAK7C,MAAhC,EAAwC2C,KAAxC,CAAd;AACA,WAAKjE,EAAL,CAAQyB,UAAR,CAAmB,KAAKH,MAAxB,EAAgC,IAAhC;AACA,aAAO4C,KAAP;AACD;;;SAID,eAAW;AACT,aAAO,KAAKxE,QAAL,CAAc5B,IAArB;AACD;;;EAxYwCsG,oB","sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, BufferProps, TypedArray} from '@luma.gl/api';\nimport {assert, checkProps} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\nimport {assertWebGL2Context} from '../context/context/webgl-checks';\nimport {AccessorObject} from '../types';\nimport Accessor from './accessor';\nimport {getGLTypeFromTypedArray, getTypedArrayFromGLType} from './typed-array-utils';\n\nimport WebGLDevice from '../adapter/webgl-device';\nimport WEBGLBuffer from '../adapter/resources/webgl-buffer';\n\nconst DEBUG_DATA_LENGTH = 10;\n\n// Shared prop checks for constructor and setProps\nconst DEPRECATED_PROPS = {\n offset: 'accessor.offset',\n stride: 'accessor.stride',\n type: 'accessor.type',\n size: 'accessor.size',\n divisor: 'accessor.divisor',\n normalized: 'accessor.normalized',\n integer: 'accessor.integer',\n instanced: 'accessor.divisor',\n isInstanced: 'accessor.divisor'\n};\n\n// Prop checks for constructor\nconst PROP_CHECKS_INITIALIZE = {\n removedProps: {},\n replacedProps: {\n bytes: 'byteLength'\n },\n // new Buffer() with individual accessor props is still used in apps, emit warnings\n deprecatedProps: DEPRECATED_PROPS\n};\n\n// Prop checks for setProps\nconst PROP_CHECKS_SET_PROPS = {\n // Buffer.setProps() with individual accessor props is rare => emit errors\n removedProps: DEPRECATED_PROPS\n};\n\nfunction getWEBGLBufferProps(props: ClassicBufferProps | ArrayBufferView | number): BufferProps {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n return {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n else if (typeof props === 'number') {\n return {byteLength: props as number};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n const bufferProps = {...props as ClassicBufferProps};\n if (bufferProps.offset) {\n bufferProps.byteOffset = bufferProps.offset;\n }\n return bufferProps;\n}\n\n/** WebGL Buffer interface */\nexport type ClassicBufferProps = BufferProps & {\n handle?: WebGLBuffer;\n\n target?: number;\n webglUsage?: number;\n\n accessor?: AccessorObject;\n\n /** @deprecated */\n index?: number;\n /** @deprecated */\n offset?: number;\n /** @deprecated */\n size?: number;\n /** @deprecated */\n type?: number\n}\n\n/** WebGL Buffer interface */\nexport default class ClassicBuffer extends WEBGLBuffer {\n usage: number;\n accessor: Accessor;\n\n constructor(device: Device | WebGLRenderingContext, props?: ClassicBufferProps);\n constructor(device: Device | WebGLRenderingContext, data: ArrayBufferView | number[]);\n constructor(device: Device | WebGLRenderingContext, byteLength: number);\n\n constructor(device: Device | WebGLRenderingContext, props = {}) {\n super(WebGLDevice.attach(device), getWEBGLBufferProps(props));\n\n // Base class initializes\n // this.initialize(props);\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, (props as ClassicBufferProps).accessor));\n\n // infer GL type from supplied typed array\n if (this.props.data) {\n const type = getGLTypeFromTypedArray(this.props.data as TypedArray);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n }\n\n Object.seal(this);\n }\n\n override destroy(): void {\n if (this.handle) {\n this.removeStats();\n this.trackDeallocatedMemory();\n this.gl.deleteBuffer(this.handle);\n // this.handle = null;\n this.destroyed = true;\n }\n }\n\n override write(data: TypedArray, byteOffset?: number): void {\n this.subData({data, offset: byteOffset});\n }\n\n // returns number of elements in the buffer (assuming that the full buffer is used)\n getElementCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerElement(accessor));\n }\n\n // returns number of vertices in the buffer (assuming that the full buffer is used)\n getVertexCount(accessor: AccessorObject = this.accessor): number {\n return Math.round(this.byteLength / Accessor.getBytesPerVertex(accessor));\n }\n\n // Creates and initializes the buffer object's data store.\n // Signature: `new Buffer(gl, {data: new Float32Array(...)})`\n // Signature: `new Buffer(gl, new Float32Array(...))`\n // Signature: `new Buffer(gl, 100)`\n initialize(props: ClassicBufferProps = {}): this {\n // Signature `new Buffer(gl, new Float32Array(...)`\n if (ArrayBuffer.isView(props)) {\n props = {data: props};\n }\n\n // Signature: `new Buffer(gl, 100)`\n if (Number.isFinite(props)) {\n // @ts-expect-error\n props = {byteLength: props};\n }\n\n props = checkProps('Buffer', props, PROP_CHECKS_INITIALIZE);\n\n // Initialize member fields\n this.webglUsage = props.webglUsage || GL.STATIC_DRAW;\n this.debugData = null;\n\n // Deprecated: Merge main props and accessor\n this.setAccessor(Object.assign({}, props, props.accessor));\n\n // Set data: (re)initializes the buffer\n if (props.data) {\n this._setData(props.data, props.offset, props.byteLength);\n } else {\n this._setByteLength(props.byteLength || 0);\n }\n\n return this;\n }\n\n setProps(props: ClassicBufferProps): this {\n props = checkProps('Buffer', props, PROP_CHECKS_SET_PROPS);\n\n if ('accessor' in props) {\n this.setAccessor(props.accessor);\n }\n\n return this;\n }\n\n // Optionally stores an accessor with the buffer, makes it easier to use it as an attribute later\n // {type, size = 1, offset = 0, stride = 0, normalized = false, integer = false, divisor = 0}\n setAccessor(accessor: AccessorObject | Accessor): this {\n // NOTE: From luma.gl v7.0, Accessors have an optional `buffer `field\n // (mainly to support \"interleaving\")\n // To avoid confusion, ensure `buffer.accessor` does not have a `buffer.accessor.buffer` field:\n accessor = Object.assign({}, accessor);\n // @ts-expect-error\n delete accessor.buffer;\n\n // This new statement ensures that an \"accessor object\" is re-packaged as an Accessor instance\n this.accessor = new Accessor(accessor);\n return this;\n }\n\n // Allocate a bigger GPU buffer (if the current buffer is not big enough).\n // If a reallocation is triggered it clears the buffer\n // Returns:\n // `true`: buffer was reallocated, data was cleared\n // `false`: buffer was big enough, data is intact\n reallocate(byteLength: number): boolean {\n if (byteLength > this.byteLength) {\n this._setByteLength(byteLength);\n return true;\n }\n this.bytesUsed = byteLength;\n return false;\n }\n\n // Update with new data. Reinitializes the buffer\n setData(props: ClassicBufferProps) {\n return this.initialize(props);\n }\n\n // Updates a subset of a buffer object's data store.\n // Data (Typed Array or ArrayBuffer), length is inferred unless provided\n // Offset into buffer\n // WebGL2 only: Offset into srcData\n // WebGL2 only: Number of bytes to be copied\n subData(options: TypedArray | {data: TypedArray, offset?: number; srcOffset?: number; byteLength?: number, length?: number}) {\n // Signature: buffer.subData(new Float32Array([...]))\n if (ArrayBuffer.isView(options)) {\n options = {data: options};\n }\n\n const {data, offset = 0, srcOffset = 0} = options;\n const byteLength = options.byteLength || options.length;\n\n assert(data);\n\n // Create the buffer - binding it here for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n // @ts-expect-error\n const target = this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n this.gl.bindBuffer(target, this.handle);\n // WebGL2: subData supports additional srcOffset and length parameters\n if (srcOffset !== 0 || byteLength !== undefined) {\n assertWebGL2Context(this.gl);\n // @ts-expect-error\n this.gl.bufferSubData(this.target, offset, data, srcOffset, byteLength);\n } else {\n this.gl.bufferSubData(target, offset, data);\n }\n this.gl.bindBuffer(target, null);\n\n // TODO - update local `data` if offsets are right\n this.debugData = null;\n\n this._inferType(data);\n\n return this;\n }\n\n /**\n * Copies part of the data of another buffer into this buffer\n * @note WEBGL2 ONLY\n */\n copyData(options: {\n sourceBuffer: any;\n readOffset?: number;\n writeOffset?: number;\n size: any;\n }): this {\n const {sourceBuffer, readOffset = 0, writeOffset = 0, size} = options;\n const {gl, gl2} = this;\n assertWebGL2Context(gl);\n\n // Use GL.COPY_READ_BUFFER+GL.COPY_WRITE_BUFFER avoid disturbing other targets and locking type\n gl.bindBuffer(GL.COPY_READ_BUFFER, sourceBuffer.handle);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, this.handle);\n gl2?.copyBufferSubData(GL.COPY_READ_BUFFER, GL.COPY_WRITE_BUFFER, readOffset, writeOffset, size);\n gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n gl.bindBuffer(GL.COPY_WRITE_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n this.debugData = null;\n\n return this;\n }\n\n /**\n * Reads data from buffer into an ArrayBufferView or SharedArrayBuffer.\n * @note WEBGL2 ONLY\n */\n override getData(options?: {\n dstData?: any;\n srcByteOffset?: number;\n dstOffset?: number;\n length?: number;\n }): any {\n let {dstData = null, length = 0} = options || {};\n const {srcByteOffset = 0, dstOffset = 0} = options || {};\n assertWebGL2Context(this.gl);\n\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceAvailableElementCount = this._getAvailableElementCount(srcByteOffset);\n\n const dstElementOffset = dstOffset;\n\n let dstAvailableElementCount;\n let dstElementCount;\n if (dstData) {\n dstElementCount = dstData.length;\n dstAvailableElementCount = dstElementCount - dstElementOffset;\n } else {\n // Allocate ArrayBufferView with enough size to copy all eligible data.\n dstAvailableElementCount = Math.min(\n sourceAvailableElementCount,\n length || sourceAvailableElementCount\n );\n dstElementCount = dstElementOffset + dstAvailableElementCount;\n }\n\n const copyElementCount = Math.min(sourceAvailableElementCount, dstAvailableElementCount);\n length = length || copyElementCount;\n assert(length <= copyElementCount);\n dstData = dstData || new ArrayType(dstElementCount);\n\n // Use GL.COPY_READ_BUFFER to avoid disturbing other targets and locking type\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, this.handle);\n this.gl2?.getBufferSubData(GL.COPY_READ_BUFFER, srcByteOffset, dstData, dstOffset, length);\n this.gl.bindBuffer(GL.COPY_READ_BUFFER, null);\n\n // TODO - update local `data` if offsets are 0\n return dstData;\n }\n\n /**\n * Binds a buffer to a given binding point (target).\n * GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER take an index, and optionally a range.\n * - GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER need an index to affect state\n * - GL.UNIFORM_BUFFER: `offset` must be aligned to GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT.\n * - GL.UNIFORM_BUFFER: `size` must be a minimum of GL.UNIFORM_BLOCK_SIZE_DATA.\n */\n bind(options?: {target?: number; index?: any; offset?: number; size: any}): this {\n const {\n target = this.target, // target for the bind operation\n index = this.accessor && this.accessor.index, // index = index of target (indexed bind point)\n offset = 0,\n size\n } = options || {};\n // NOTE: While GL.TRANSFORM_FEEDBACK_BUFFER and GL.UNIFORM_BUFFER could\n // be used as direct binding points, they will not affect transform feedback or\n // uniform buffer state. Instead indexed bindings need to be made.\n if (target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER) {\n if (size !== undefined) {\n this.gl2?.bindBufferRange(target, index, this.handle, offset, size);\n } else {\n assert(offset === 0); // Make sure offset wasn't supplied\n this.gl2?.bindBufferBase(target, index, this.handle);\n }\n } else {\n this.gl.bindBuffer(target, this.handle);\n }\n\n return this;\n }\n\n unbind(options?: {target?: any; index?: any}): this {\n const {target = this.target, index = this.accessor && this.accessor.index} = options || {};\n const isIndexedBuffer = target === GL.UNIFORM_BUFFER || target === GL.TRANSFORM_FEEDBACK_BUFFER;\n if (isIndexedBuffer) {\n this.gl2?.bindBufferBase(target, index, null);\n } else {\n this.gl.bindBuffer(target, null);\n }\n return this;\n }\n\n // PROTECTED METHODS (INTENDED FOR USE BY OTHER FRAMEWORK CODE ONLY)\n\n // Returns a short initial data array\n getDebugData(): {\n data: any;\n changed: boolean;\n } {\n if (!this.debugData) {\n this.debugData = this.getData({length: Math.min(DEBUG_DATA_LENGTH, this.byteLength)});\n return {data: this.debugData, changed: true};\n }\n return {data: this.debugData, changed: false};\n }\n\n invalidateDebugData() {\n this.debugData = null;\n }\n\n // PRIVATE METHODS\n\n // Allocate a new buffer and initialize to contents of typed array\n _setData(data, offset: number = 0, byteLength: number = data.byteLength + offset): this {\n assert(ArrayBuffer.isView(data));\n\n this.trackDeallocatedMemory();\n\n const target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, byteLength, this.webglUsage);\n this.gl.bufferSubData(target, offset, data);\n this.gl.bindBuffer(target, null);\n\n this.debugData = data.slice(0, DEBUG_DATA_LENGTH);\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n this.trackAllocatedMemory(byteLength);\n\n // infer GL type from supplied typed array\n const type = getGLTypeFromTypedArray(data);\n assert(type);\n this.setAccessor(new Accessor(this.accessor, {type}));\n return this;\n }\n\n // Allocate a GPU buffer of specified size.\n _setByteLength(byteLength: number, webglUsage = this.webglUsage): this {\n assert(byteLength >= 0);\n\n this.trackDeallocatedMemory();\n\n // Workaround needed for Safari (#291):\n // gl.bufferData with size equal to 0 crashes. Instead create zero sized array.\n let data = byteLength;\n if (byteLength === 0) {\n // @ts-expect-error\n data = new Float32Array(0);\n }\n\n const target = this._getTarget();\n this.gl.bindBuffer(target, this.handle);\n this.gl.bufferData(target, data, webglUsage);\n this.gl.bindBuffer(target, null);\n\n this.webglUsage = webglUsage;\n this.debugData = null;\n this.bytesUsed = byteLength;\n this.byteLength = byteLength;\n\n this.trackAllocatedMemory(byteLength);\n\n return this;\n }\n\n // Binding a buffer for the first time locks the type\n // In WebGL2, use GL.COPY_WRITE_BUFFER to avoid locking the type\n _getTarget() {\n // @ts-expect-error\n return this.gl.webgl2 ? GL.COPY_WRITE_BUFFER : this.target;\n }\n\n _getAvailableElementCount(srcByteOffset: number) {\n const ArrayType = getTypedArrayFromGLType(this.accessor.type || GL.FLOAT, {clamped: false});\n const sourceElementOffset = srcByteOffset / ArrayType.BYTES_PER_ELEMENT;\n return this.getElementCount() - sourceElementOffset;\n }\n\n // Automatically infers type from typed array passed to setData\n // Note: No longer that useful, since type is now autodeduced from the compiled shaders\n _inferType(data) {\n if (!this.accessor.type) {\n this.setAccessor(new Accessor(this.accessor, {type: getGLTypeFromTypedArray(data)}));\n }\n }\n\n // RESOURCE METHODS\n\n getParameter(pname: GL): any {\n this.gl.bindBuffer(this.target, this.handle);\n const value = this.gl.getBufferParameter(this.target, pname);\n this.gl.bindBuffer(this.target, null);\n return value;\n }\n\n // DEPRECATIONS - v7.0\n /** @deprecated Use Buffer.accessor.type */\n get type() {\n return this.accessor.type;\n }\n}\n"],"file":"buffer.js"}
|
|
@@ -16,7 +16,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
16
16
|
|
|
17
17
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
18
18
|
|
|
19
|
-
var _api = require("@luma.gl/api
|
|
19
|
+
var _api = require("@luma.gl/api");
|
|
20
20
|
|
|
21
21
|
var _constants = _interopRequireDefault(require("@luma.gl/constants"));
|
|
22
22
|
|
|
@@ -31,12 +31,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
31
31
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
32
32
|
|
|
33
33
|
var WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';
|
|
34
|
-
var DEFAULT_DEBUG_CONTEXT_PROPS = {
|
|
35
|
-
debug: true,
|
|
36
|
-
throwOnError: false,
|
|
37
|
-
break: [],
|
|
38
|
-
webgl2: false
|
|
39
|
-
};
|
|
40
34
|
|
|
41
35
|
function getContextData(gl) {
|
|
42
36
|
gl.luma = gl.luma || {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/debug/webgl-developer-tools.ts"],"names":["WEBGL_DEBUG_CDN_URL","DEFAULT_DEBUG_CONTEXT_PROPS","debug","throwOnError","break","webgl2","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","getDebugContext","getRealContext","data","realContext","log","warn","debugContext","init","GL","glDebug","onGLError","bind","onValidateGLFunc","key","WebGLDebugContext","Object","setPrototypeOf","getPrototypeOf","create","getFunctionString","functionName","functionArgs","Array","from","map","arg","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","message","error","Error","functionString","level","isBreakpoint","every","breakOn","indexOf"],"mappings":";;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAMA,mBAAmB,GAAG,8CAA5B;AASA,IAAMC,2BAAwD,GAAG;AAC/DC,EAAAA,KAAK,EAAE,IADwD;AAE/DC,EAAAA,YAAY,EAAE,KAFiD;AAG/DC,EAAAA,KAAK,EAAE,EAHwD;AAI/DC,EAAAA,MAAM,EAAE;AAJuD,CAAjE;;AAQA,SAASC,cAAT,CAAwBC,EAAxB,EAAiC;AAC/BA,EAAAA,EAAE,CAACC,IAAH,GAAUD,EAAE,CAACC,IAAH,IAAW,EAArB;AACA,SAAOD,EAAE,CAACC,IAAV;AACD;;SAYqBC,uB;;;;;uFAAf;AAAA;AAAA;AAAA;AAAA;AAAA,gBACAC,UAAU,CAACC,eADX;AAAA;AAAA;AAAA;;AAGHD,YAAAA,UAAU,CAACE,MAAX,GAAoBF,UAAU,CAACE,MAAX,IAAqBF,UAAzC;AAEAA,YAAAA,UAAU,CAACE,MAAX,CAAkBC,MAAlB,GAA2B,EAA3B;AALG;AAAA,mBAMG,qBAAWb,mBAAX,CANH;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;AAYA,SAASc,gBAAT,CAA0BP,EAA1B,EAAkH;AAAA,MAA7DQ,KAA6D,uEAAlC,EAAkC;;A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C,YAAf,CAApD;;AACA,YAAItB,KAAK,CAACZ,YAAV,EAAwB;AACtB,gBAAM,IAAIkD,KAAJ,+BAAiCC,cAAjC,EAAN;AACD,SAFD,MAEO;AACLlC,mBAAIgC,KAAJ,+BAAiCE,cAAjC;;AACA;AACD;AACF;AACF;AA1BkG;AAAA;AAAA;AAAA;AAAA;AA2BpG","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api/';\nimport GL from '@luma.gl/constants';\n\nconst WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';\n\ntype DebugContextProps = {\n debug?: boolean;\n throwOnError?: boolean;\n break?: string[];\n webgl2?: boolean;\n};\n\nconst DEFAULT_DEBUG_CONTEXT_PROPS: Required<DebugContextProps> = {\n debug: true,\n throwOnError: false,\n break: [],\n webgl2: false,\n}\n\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\n var WebGLDebugUtils: any;\n}\n\n/**\n * Loads Khronos WebGLDeveloperTools from CDN if not already installed \n * const WebGLDebugUtils = require('webgl-debug');\n * @see https://github.com/KhronosGroup/WebGLDeveloperTools\n * @see https://github.com/vorg/webgl-debug\n */\nexport async function loadWebGLDeveloperTools(): Promise<void> {\n if (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global = globalThis.global || globalThis;\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global.module = {};\n await loadScript(WEBGL_DEBUG_CDN_URL);\n }\n}\n\n// Returns (a potentially new) context with debug instrumentation turned off or on.\n// Note that this actually returns a new context\nexport function makeDebugContext(gl: WebGLRenderingContext, props: DebugContextProps = {}): WebGLRenderingContext | null {\n // Return null to ensure we don't try to create a context in this case (TODO what case is that?)\n if (!gl) {\n return null;\n }\n\n return props.debug ? getDebugContext(gl, props) : getRealContext(gl);\n}\n\n// Returns the real context from either of the real/debug contexts\nfunction getRealContext(gl: WebGLRenderingContext): WebGLRenderingContext {\n const data = getContextData(gl);\n // If the context has a realContext member, it is a debug context so return the realContext\n return data.realContext ? data.realContext : gl;\n}\n\n// Returns the debug context from either of the real/debug contexts\nfunction getDebugContext(gl: WebGLRenderingContext, props: DebugContextProps): WebGLRenderingContext {\n if (!globalThis.WebGLDebugUtils) {\n log.warn('webgl-debug not loaded')();\n return gl;\n }\n\n const data = getContextData(gl);\n\n // If this already has a debug context, return it.\n if (data.debugContext) {\n return data.debugContext;\n }\n\n // Create a new debug context\n globalThis.WebGLDebugUtils.init({...GL, ...gl});\n const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(\n gl,\n onGLError.bind(null, props),\n onValidateGLFunc.bind(null, props)\n );\n\n // Make sure we have all WebGL2 and extension constants (todo dynamic import to circumvent minification?)\n for (const key in GL) {\n if (!(key in glDebug) && typeof GL[key] === 'number') {\n glDebug[key] = GL[key];\n }\n }\n \n // Ensure we have a clean prototype on the instrumented object\n // Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction\n // by synchronizing the WebGL errors after each WebGL call.\n class WebGLDebugContext {}\n Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));\n Object.setPrototypeOf(WebGLDebugContext, glDebug);\n const debugContext = Object.create(WebGLDebugContext);\n // Store the debug context\n data.realContext = gl;\n data.debugContext = debugContext;\n debugContext.debug = true;\n\n // Return it\n return debugContext;\n}\n\n// DEBUG TRACING\n\nfunction getFunctionString(functionName: string, functionArgs): string {\n // Cover bug in webgl-debug-tools\n functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);\n let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);\n args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;\n return `gl.${functionName}(${args})`;\n}\n\nfunction onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {\n // Cover bug in webgl-debug-tools\n args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);\n const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);\n const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);\n const glName = props.webgl2 ? 'gl2' : 'gl1';\n const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;\n log.error(message)();\n debugger; // eslint-disable-line\n if (props.throwOnError) {\n throw new Error(message);\n }\n}\n\n// Don't generate function string until it is needed\nfunction onValidateGLFunc(props: DebugContextProps, functionName: string, functionArgs: any[]): void {\n let functionString: string = '';\n if (log.level >= 1) {\n functionString = getFunctionString(functionName, functionArgs);\n log.log(1, functionString)();\n }\n\n if (props.break) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint =\n props.break && props.break.every((breakOn: string) => functionString.indexOf(breakOn) !== -1);\n if (isBreakpoint) {\n debugger; // eslint-disable-line\n }\n }\n\n for (const arg of functionArgs) {\n if (arg === undefined) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n if (props.throwOnError) {\n throw new Error(`Undefined argument: ${functionString}`);\n } else {\n log.error(`Undefined argument: ${functionString}`)();\n debugger; // eslint-disable-line\n }\n }\n }\n}\n"],"file":"webgl-developer-tools.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/debug/webgl-developer-tools.ts"],"names":["WEBGL_DEBUG_CDN_URL","getContextData","gl","luma","loadWebGLDeveloperTools","globalThis","WebGLDebugUtils","global","module","makeDebugContext","props","debug","getDebugContext","getRealContext","data","realContext","log","warn","debugContext","init","GL","glDebug","onGLError","bind","onValidateGLFunc","key","WebGLDebugContext","Object","setPrototypeOf","getPrototypeOf","create","getFunctionString","functionName","functionArgs","Array","from","map","arg","undefined","args","glFunctionArgsToString","slice","length","err","errorMessage","glEnumToString","glName","webgl2","message","error","throwOnError","Error","functionString","level","break","isBreakpoint","every","breakOn","indexOf"],"mappings":";;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAMA,mBAAmB,GAAG,8CAA5B;;AAiBA,SAASC,cAAT,CAAwBC,EA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AAV,EAAiB;AACfF,IAAAA,cAAc,GAAGA,cAAc,IAAIrB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;AACA,QAAMsB,YAAY,GAChB7C,KAAK,CAAC4C,KAAN,IAAe5C,KAAK,CAAC4C,KAAN,CAAYE,KAAZ,CAAkB,UAACC,OAAD;AAAA,aAAqBL,cAAc,CAACM,OAAf,CAAuBD,OAAvB,MAAoC,CAAC,CAA1D;AAAA,KAAlB,CADjB;;AAEA,QAAIF,YAAJ,EAAkB;AAChB;AACD;AACF;;AAdkG,6CAgBjFtB,YAhBiF;AAAA;;AAAA;AAgBnG,wDAAgC;AAAA,UAArBI,GAAqB;;AAC9B,UAAIA,GAAG,KAAKC,SAAZ,EAAuB;AACrBc,QAAAA,cAAc,GAAGA,cAAc,IAAIrB,iBAAiB,CAACC,YAAD,EAAeC,YAAf,CAApD;;AACA,YAAIvB,KAAK,CAACwC,YAAV,EAAwB;AACtB,gBAAM,IAAIC,KAAJ,+BAAiCC,cAAjC,EAAN;AACD,SAFD,MAEO;AACLpC,mBAAIiC,KAAJ,+BAAiCG,cAAjC;;AACA;AACD;AACF;AACF;AA1BkG;AAAA;AAAA;AAAA;AAAA;AA2BpG","sourcesContent":["// luma.gl, MIT license\nimport {log, loadScript} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\nconst WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';\n\ntype DebugContextProps = {\n debug?: boolean;\n throwOnError?: boolean;\n break?: string[];\n webgl2?: boolean;\n};\n\n// const DEFAULT_DEBUG_CONTEXT_PROPS: Required<DebugContextProps> = {\n// debug: true,\n// throwOnError: false,\n// break: [],\n// webgl2: false,\n// }\n\n// Helper to get shared context data\nfunction getContextData(gl: any) {\n gl.luma = gl.luma || {};\n return gl.luma;\n}\n\ndeclare global {\n var WebGLDebugUtils: any;\n}\n\n/**\n * Loads Khronos WebGLDeveloperTools from CDN if not already installed \n * const WebGLDebugUtils = require('webgl-debug');\n * @see https://github.com/KhronosGroup/WebGLDeveloperTools\n * @see https://github.com/vorg/webgl-debug\n */\nexport async function loadWebGLDeveloperTools(): Promise<void> {\n if (!globalThis.WebGLDebugUtils) {\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global = globalThis.global || globalThis;\n // @ts-expect-error Developer tools expects global to be set\n globalThis.global.module = {};\n await loadScript(WEBGL_DEBUG_CDN_URL);\n }\n}\n\n// Returns (a potentially new) context with debug instrumentation turned off or on.\n// Note that this actually returns a new context\nexport function makeDebugContext(gl: WebGLRenderingContext, props: DebugContextProps = {}): WebGLRenderingContext | null {\n // Return null to ensure we don't try to create a context in this case (TODO what case is that?)\n if (!gl) {\n return null;\n }\n\n return props.debug ? getDebugContext(gl, props) : getRealContext(gl);\n}\n\n// Returns the real context from either of the real/debug contexts\nfunction getRealContext(gl: WebGLRenderingContext): WebGLRenderingContext {\n const data = getContextData(gl);\n // If the context has a realContext member, it is a debug context so return the realContext\n return data.realContext ? data.realContext : gl;\n}\n\n// Returns the debug context from either of the real/debug contexts\nfunction getDebugContext(gl: WebGLRenderingContext, props: DebugContextProps): WebGLRenderingContext {\n if (!globalThis.WebGLDebugUtils) {\n log.warn('webgl-debug not loaded')();\n return gl;\n }\n\n const data = getContextData(gl);\n\n // If this already has a debug context, return it.\n if (data.debugContext) {\n return data.debugContext;\n }\n\n // Create a new debug context\n globalThis.WebGLDebugUtils.init({...GL, ...gl});\n const glDebug = globalThis.WebGLDebugUtils.makeDebugContext(\n gl,\n onGLError.bind(null, props),\n onValidateGLFunc.bind(null, props)\n );\n\n // Make sure we have all WebGL2 and extension constants (todo dynamic import to circumvent minification?)\n for (const key in GL) {\n if (!(key in glDebug) && typeof GL[key] === 'number') {\n glDebug[key] = GL[key];\n }\n }\n \n // Ensure we have a clean prototype on the instrumented object\n // Note: setPrototypeOf does come with perf warnings, but we already take a bigger perf reduction\n // by synchronizing the WebGL errors after each WebGL call.\n class WebGLDebugContext {}\n Object.setPrototypeOf(glDebug, Object.getPrototypeOf(gl));\n Object.setPrototypeOf(WebGLDebugContext, glDebug);\n const debugContext = Object.create(WebGLDebugContext);\n // Store the debug context\n data.realContext = gl;\n data.debugContext = debugContext;\n debugContext.debug = true;\n\n // Return it\n return debugContext;\n}\n\n// DEBUG TRACING\n\nfunction getFunctionString(functionName: string, functionArgs): string {\n // Cover bug in webgl-debug-tools\n functionArgs = Array.from(functionArgs).map(arg => arg === undefined ? 'undefined' : arg);\n let args = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, functionArgs);\n args = `${args.slice(0, 100)}${args.length > 100 ? '...' : ''}`;\n return `gl.${functionName}(${args})`;\n}\n\nfunction onGLError(props: DebugContextProps, err, functionName: string, args: any[]): void {\n // Cover bug in webgl-debug-tools\n args = Array.from(args).map(arg => arg === undefined ? 'undefined' : arg);\n const errorMessage = globalThis.WebGLDebugUtils.glEnumToString(err);\n const functionArgs = globalThis.WebGLDebugUtils.glFunctionArgsToString(functionName, args);\n const glName = props.webgl2 ? 'gl2' : 'gl1';\n const message = `${errorMessage} in ${glName}.${functionName}(${functionArgs})`;\n log.error(message)();\n debugger; // eslint-disable-line\n if (props.throwOnError) {\n throw new Error(message);\n }\n}\n\n// Don't generate function string until it is needed\nfunction onValidateGLFunc(props: DebugContextProps, functionName: string, functionArgs: any[]): void {\n let functionString: string = '';\n if (log.level >= 1) {\n functionString = getFunctionString(functionName, functionArgs);\n log.log(1, functionString)();\n }\n\n if (props.break) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n const isBreakpoint =\n props.break && props.break.every((breakOn: string) => functionString.indexOf(breakOn) !== -1);\n if (isBreakpoint) {\n debugger; // eslint-disable-line\n }\n }\n\n for (const arg of functionArgs) {\n if (arg === undefined) {\n functionString = functionString || getFunctionString(functionName, functionArgs);\n if (props.throwOnError) {\n throw new Error(`Undefined argument: ${functionString}`);\n } else {\n log.error(`Undefined argument: ${functionString}`)();\n debugger; // eslint-disable-line\n }\n }\n }\n}\n"],"file":"webgl-developer-tools.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/context/parameters/unified-parameter-api.ts"],"names":["setParameters","device","parameters","webglDevice","WebGLDevice","attach","gl","isObjectEmpty","compositeSetters","key","glConstant","Number","setter","GL_PARAMETER_SETTERS","cache","state","compositeSetter","GL_COMPOSITE_PARAMETER_SETTERS","getParameters","GL_PARAMETER_DEFAULTS","getter","GL_PARAMETER_GETTERS","getParameter","parameterKeys","Array","isArray","Object","keys","resetParameters","object"],"mappings":";;;;;;;;;;;AAKA;;
|
|
1
|
+
{"version":3,"sources":["../../../../src/context/parameters/unified-parameter-api.ts"],"names":["setParameters","device","parameters","webglDevice","WebGLDevice","attach","gl","isObjectEmpty","compositeSetters","key","glConstant","Number","setter","GL_PARAMETER_SETTERS","cache","state","compositeSetter","GL_COMPOSITE_PARAMETER_SETTERS","getParameters","GL_PARAMETER_DEFAULTS","getter","GL_PARAMETER_GETTERS","getParameter","parameterKeys","Array","isArray","Object","keys","resetParameters","object"],"mappings":";;;;;;;;;;;AAKA;;AAOA;;;;;;;;AAUO,SAASA,aAAT,CACLC,MADK,EAELC,UAFK,EAGC;AACN,MAAMC,WAAW,GAAGC,qBAAYC,MAAZ,CAAmBJ,MAAnB,CAApB;;AACA,MAAMK,EAAE,GAAGH,WAAW,CAACG,EAAvB;;AAEA,MAAIC,aAAa,CAACL,UAAD,CAAjB,EAA+B;AAC7B;AACD;;AAED,MAAMM,gBAAgB,GAAG,EAAzB;;AAIA,OAAK,IAAMC,GAAX,IAAkBP,UAAlB,EAA8B;AAC5B,QAAMQ,UAAU,GAAGC,MAAM,CAACF,GAAD,CAAzB;AACA,QAAMG,MAAM,GAAGC,2CAAqBJ,GAArB,CAAf;;AACA,QAAIG,MAAJ,EAAY;AAEV,UAAI,OAAOA,MAAP,KAAkB,QAAtB,EAAgC;AAC9BJ,QAAAA,gBAAgB,CAACI,MAAD,CAAhB,GAA2B,IAA3B;AACD,OAFD,MAEO;AAKLA,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AE,CAACgB,YAAH,CAAgBX,MAAM,CAACF,KAAD,CAAtB,CAAhD;AACD;AAnBa;AAAA;AAAA;AAAA;AAAA;;AAoBd,SAAOM,KAAP;AACD;;AAQM,SAASa,eAAT,CAAyB3B,MAAzB,EAAuE;AAC5ED,EAAAA,aAAa,CAACC,MAAD,EAASkB,2CAAT,CAAb;AACD;;AAKD,SAASZ,aAAT,CAAuBsB,MAAvB,EAA+B;AAE7B,OAAK,IAAMpB,GAAX,IAAkBoB,MAAlB,EAA0B;AACxB,WAAO,KAAP;AACD;;AACD,SAAO,IAAP;AACD","sourcesContent":["// Provides a unified API for getting and setting any WebGL parameter\n// Also knows default values of all parameters, enabling fast cache initialization\n// Provides base functionality for the state caching.\nimport {Device} from '@luma.gl/api';\nimport type {GLParameters} from '../../types/webgl';\nimport {\n GL_PARAMETER_DEFAULTS,\n GL_PARAMETER_SETTERS,\n GL_COMPOSITE_PARAMETER_SETTERS,\n GL_PARAMETER_GETTERS\n} from './webgl-parameter-tables';\n\nimport WebGLDevice from '../../adapter/webgl-device';\n\nexport type {GLParameters};\n\n/**\n * Sets any GL parameter regardless of function (gl.blendMode, ...)\n *\n * @note requires a `cache` object to be set on the context (gl.state.cache)\n * This object is used to fill in any missing values for composite setter functions\n */\nexport function setParameters(\n device: Device | WebGLRenderingContext,\n parameters: GLParameters\n): void {\n const webglDevice = WebGLDevice.attach(device);\n const gl = webglDevice.gl;\n\n if (isObjectEmpty(parameters)) {\n return;\n }\n\n const compositeSetters = {};\n\n // HANDLE PRIMITIVE SETTERS (and make note of any composite setters)\n\n for (const key in parameters) {\n const glConstant = Number(key);\n const setter = GL_PARAMETER_SETTERS[key];\n if (setter) {\n // Composite setters should only be called once, so save them\n if (typeof setter === 'string') {\n compositeSetters[setter] = true;\n } else {\n // if (gl[glConstant] !== undefined) {\n // TODO - added above check since this is being called on WebGL2 parameters in WebGL1...\n // TODO - deep equal on values? only call setter if value has changed?\n // NOTE - the setter will automatically update this.state\n setter(gl, parameters[key], glConstant);\n }\n }\n }\n\n // HANDLE COMPOSITE SETTERS\n\n // NOTE: any non-provided values needed by composite setters are filled in from state cache\n // The cache parameter is automatically retrieved from the context\n // This depends on `trackContextState`, which is technically a \"circular\" dependency.\n // But it is too inconvenient to always require a cache parameter here.\n // This is the ONLY external dependency in this module/\n // @ts-expect-error\n const cache = gl.state && gl.state.cache;\n if (cache) {\n for (const key in compositeSetters) {\n // TODO - avoid calling composite setters if values have not changed.\n const compositeSetter = GL_COMPOSITE_PARAMETER_SETTERS[key];\n // Note - if `trackContextState` has been called,\n // the setter will automatically update this.state.cache\n compositeSetter(gl, parameters, cache);\n }\n }\n\n // Add a log for the else case?\n}\n\n/**\n * Reads the entire WebGL state from a context\n\n // default to querying all parameters\n\n * @returns - a newly created map, with values keyed by GL parameters\n *\n * @note Copies the state from a context (gl.getParameter should not be overriden)\n * Reads the entire WebGL state from a context\n *\n * @note This can generates a huge amount of synchronous driver roundtrips and should be\n * considered a very slow operation, to be used only if/when a context already manipulated\n * by external code needs to be synchronized for the first time\n */\nexport function getParameters(\n device: Device | WebGLRenderingContext,\n parameters: keyof GLParameters | (keyof GLParameters)[] | GLParameters = GL_PARAMETER_DEFAULTS\n): GLParameters {\n const webglDevice = WebGLDevice.attach(device);\n const gl = webglDevice.gl;\n\n // support both arrays of parameters and objects (keys represent parameters)\n\n if (typeof parameters === 'number') {\n // single GL enum\n const key = parameters;\n const getter = GL_PARAMETER_GETTERS[key];\n return getter ? getter(gl, key) : gl.getParameter(key);\n }\n\n const parameterKeys = Array.isArray(parameters) ? parameters : Object.keys(parameters);\n\n const state = {};\n for (const key of parameterKeys) {\n const getter = GL_PARAMETER_GETTERS[key];\n state[key] = getter ? getter(gl, Number(key)) : gl.getParameter(Number(key));\n }\n return state;\n}\n\n/**\n * Reset all parameters to a (almost) pure context state\n * @note viewport and scissor will be set to the values in GL_PARAMETER_DEFAULTS,\n * NOT the canvas size dimensions, so they will have to be properly set after\n * calling this function.\n */\nexport function resetParameters(device: Device | WebGLRenderingContext): void {\n setParameters(device, GL_PARAMETER_DEFAULTS);\n}\n\n// Helpers\n\n// Returns true if given object is empty, false otherwise.\nfunction isObjectEmpty(object) {\n // @ts-ignore dummy key variable\n for (const key in object) {\n return false;\n }\n return true;\n}\n"],"file":"unified-parameter-api.js"}
|
|
@@ -47,14 +47,15 @@ var bindFramebuffer = function bindFramebuffer(gl, value, key) {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
var bindBuffer = function bindBuffer(gl, value, key) {
|
|
50
|
-
var
|
|
50
|
+
var _bindingMap;
|
|
51
51
|
|
|
52
|
-
var
|
|
52
|
+
var bindingMap = (_bindingMap = {}, (0, _defineProperty2.default)(_bindingMap, _constants.default.ARRAY_BUFFER_BINDING, _constants.default.ARRAY_BUFFER), (0, _defineProperty2.default)(_bindingMap, _constants.default.COPY_READ_BUFFER_BINDING, _constants.default.COPY_READ_BUFFER), (0, _defineProperty2.default)(_bindingMap, _constants.default.COPY_WRITE_BUFFER_BINDING, _constants.default.COPY_WRITE_BUFFER), (0, _defineProperty2.default)(_bindingMap, _constants.default.PIXEL_PACK_BUFFER_BINDING, _constants.default.PIXEL_PACK_BUFFER), (0, _defineProperty2.default)(_bindingMap, _constants.default.PIXEL_UNPACK_BUFFER_BINDING, _constants.default.PIXEL_UNPACK_BUFFER), _bindingMap);
|
|
53
|
+
var target = bindingMap[key];
|
|
53
54
|
gl.bindBuffer(target, value);
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
function isArray(array) {
|
|
57
|
-
return Array.isArray(array) || ArrayBuffer.isView(array);
|
|
58
|
+
return Array.isArray(array) || ArrayBuffer.isView(array) && !(array instanceof DataView);
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
var GL_PARAMETER_SETTERS = (_GL_PARAMETER_SETTERS = {}, (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.BLEND, enable), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.BLEND_COLOR, function (gl, value) {
|
|
@@ -78,9 +79,9 @@ var GL_PARAMETER_SETTERS = (_GL_PARAMETER_SETTERS = {}, (0, _defineProperty2.def
|
|
|
78
79
|
}), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.RENDERBUFFER_BINDING, function (gl, value) {
|
|
79
80
|
return gl.bindRenderbuffer(_constants.default.RENDERBUFFER, value);
|
|
80
81
|
}), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.TRANSFORM_FEEDBACK_BINDING, function (gl, value) {
|
|
81
|
-
var
|
|
82
|
+
var _bindTransformFeedbac, _ref;
|
|
82
83
|
|
|
83
|
-
return (
|
|
84
|
+
return (_bindTransformFeedbac = (_ref = gl).bindTransformFeedback) === null || _bindTransformFeedbac === void 0 ? void 0 : _bindTransformFeedbac.call(_ref, _constants.default.TRANSFORM_FEEDBACK, value);
|
|
84
85
|
}), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.VERTEX_ARRAY_BINDING, function (gl, value) {
|
|
85
86
|
return gl.bindVertexArray(value);
|
|
86
87
|
}), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.FRAMEBUFFER_BINDING, bindFramebuffer), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.READ_FRAMEBUFFER_BINDING, bindFramebuffer), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.ARRAY_BUFFER_BINDING, bindBuffer), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.COPY_READ_BUFFER_BINDING, bindBuffer), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.COPY_WRITE_BUFFER_BINDING, bindBuffer), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.PIXEL_PACK_BUFFER_BINDING, bindBuffer), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.PIXEL_UNPACK_BUFFER_BINDING, bindBuffer), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, _constants.default.FRONT_FACE, function (gl, value) {
|
|
@@ -105,11 +106,11 @@ var GL_PARAMETER_SETTERS = (_GL_PARAMETER_SETTERS = {}, (0, _defineProperty2.def
|
|
|
105
106
|
}), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, "blendColor", function blendColor(gl, value) {
|
|
106
107
|
return gl.blendColor.apply(gl, (0, _toConsumableArray2.default)(value));
|
|
107
108
|
}), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, "blendEquation", function blendEquation(gl, args) {
|
|
108
|
-
|
|
109
|
-
gl.blendEquationSeparate.apply(gl, (0, _toConsumableArray2.default)(
|
|
109
|
+
var separateModes = typeof args === 'number' ? [args, args] : args;
|
|
110
|
+
gl.blendEquationSeparate.apply(gl, (0, _toConsumableArray2.default)(separateModes));
|
|
110
111
|
}), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, "blendFunc", function blendFunc(gl, args) {
|
|
111
|
-
|
|
112
|
-
gl.blendFuncSeparate.apply(gl, (0, _toConsumableArray2.default)(
|
|
112
|
+
var separateFuncs = (args === null || args === void 0 ? void 0 : args.length) === 2 ? [].concat((0, _toConsumableArray2.default)(args), (0, _toConsumableArray2.default)(args)) : args;
|
|
113
|
+
gl.blendFuncSeparate.apply(gl, (0, _toConsumableArray2.default)(separateFuncs));
|
|
113
114
|
}), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, "clearColor", function clearColor(gl, value) {
|
|
114
115
|
return gl.clearColor.apply(gl, (0, _toConsumableArray2.default)(value));
|
|
115
116
|
}), (0, _defineProperty2.default)(_GL_PARAMETER_SETTERS, "clearDepth", function clearDepth(gl, value) {
|