@galacean/engine-rhi-webgl 2.0.0-alpha.5 → 2.0.0-alpha.51

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/main.js CHANGED
@@ -73,24 +73,6 @@ var engineMath = require('@galacean/engine-math');
73
73
  return GLCompressedTextureInternalFormat;
74
74
  }({});
75
75
 
76
- function _defineProperties(target, props) {
77
- for (var i = 0; i < props.length; i++) {
78
- var descriptor = props[i];
79
- descriptor.enumerable = descriptor.enumerable || false;
80
- descriptor.configurable = true;
81
-
82
- if ("value" in descriptor) descriptor.writable = true;
83
-
84
- Object.defineProperty(target, descriptor.key, descriptor);
85
- }
86
- }
87
- function _create_class(Constructor, protoProps, staticProps) {
88
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
89
- if (staticProps) _defineProperties(Constructor, staticProps);
90
-
91
- return Constructor;
92
- }
93
-
94
76
  function _set_prototype_of(o, p) {
95
77
  _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
96
78
  o.__proto__ = p;
@@ -123,69 +105,134 @@ function _instanceof(left, right) {
123
105
  _inherits(WebCanvas, Canvas);
124
106
  function WebCanvas(webCanvas) {
125
107
  var _this;
126
- _this = Canvas.call(this) || this, _this._scale = new engineMath.Vector2();
127
- var width = webCanvas.width;
128
- var height = webCanvas.height;
108
+ _this = Canvas.call(this) || this, _this._autoResolutionScale = 1, _this._resolutionDirty = false, _this._pendingDevicePixelWidth = 0, _this._pendingDevicePixelHeight = 0;
129
109
  _this._webCanvas = webCanvas;
130
- _this.width = width;
131
- _this.height = height;
110
+ _this._setResolution(webCanvas.width, webCanvas.height);
132
111
  return _this;
133
112
  }
134
113
  var _proto = WebCanvas.prototype;
135
114
  /**
136
- * Resize the rendering size according to the clientWidth and clientHeight of the canvas.
137
- * @param pixelRatio - Pixel ratio
138
- */ _proto.resizeByClientSize = function resizeByClientSize(pixelRatio) {
139
- if (pixelRatio === void 0) pixelRatio = window.devicePixelRatio;
140
- var webCanvas = this._webCanvas;
141
- if (typeof OffscreenCanvas === "undefined" || !_instanceof(webCanvas, OffscreenCanvas)) {
142
- var exportWidth = webCanvas.clientWidth * pixelRatio;
143
- var exportHeight = webCanvas.clientHeight * pixelRatio;
144
- this.width = exportWidth;
145
- this.height = exportHeight;
115
+ * @inheritdoc
116
+ *
117
+ * @remarks
118
+ * The canvas must have a CSS-constrained display size; otherwise auto-resolution disables itself.
119
+ */ _proto.setAutoResolution = function setAutoResolution(scale) {
120
+ var _this = this;
121
+ if (scale === void 0) scale = 1;
122
+ if (!Number.isFinite(scale) || scale <= 0) {
123
+ throw new Error("WebCanvas.setAutoResolution: invalid scale " + scale);
124
+ }
125
+ // OffscreenCanvas has no display size to follow
126
+ if (this._isOffscreenCanvas()) return;
127
+ this._autoResolutionScale = scale;
128
+ if (this._resizeObserver) {
129
+ this._resolutionDirty = true;
130
+ } else if (typeof ResizeObserver !== "undefined") {
131
+ // observe() fires an initial entry, which sets the pending device pixel size
132
+ this._resizeObserver = new ResizeObserver(function(entries) {
133
+ var _entries__devicePixelContentBoxSize;
134
+ var box = (_entries__devicePixelContentBoxSize = entries[entries.length - 1].devicePixelContentBoxSize) == null ? void 0 : _entries__devicePixelContentBoxSize[0];
135
+ _this._pendingDevicePixelWidth = box ? box.inlineSize : 0;
136
+ _this._pendingDevicePixelHeight = box ? box.blockSize : 0;
137
+ _this._resolutionDirty = true;
138
+ });
139
+ // Observe exact device pixels where supported, otherwise the content-box and size from the client size
140
+ if (WebCanvas._supportsDevicePixelContentBox()) {
141
+ this._resizeObserver.observe(this._webCanvas, {
142
+ box: "device-pixel-content-box"
143
+ });
144
+ } else {
145
+ this._resizeObserver.observe(this._webCanvas);
146
+ }
147
+ } else {
148
+ // ResizeObserver is unavailable (e.g. mini-programs, iOS Safari < 13.4): size once from the client size
149
+ console.warn("ResizeObserver is not supported in this environment. Falling back to one-time clientWidth × devicePixelRatio × scale sizing");
150
+ this._setResolutionByClientSizeFallback(scale);
146
151
  }
147
152
  };
148
153
  /**
149
- * Set scale.
150
- * @param x - Scale along the X axis
151
- * @param y - Scale along the Y axis
152
- */ _proto.setScale = function setScale(x, y) {
153
- this._scale.set(x, y);
154
- this.scale = this._scale;
154
+ * @internal
155
+ */ _proto._isOffscreenCanvas = function _isOffscreenCanvas() {
156
+ return typeof OffscreenCanvas !== "undefined" && _instanceof(this._webCanvas, OffscreenCanvas);
155
157
  };
156
- _proto._onWidthChanged = function _onWidthChanged(value) {
157
- this._webCanvas.width = value;
158
+ /**
159
+ * @internal
160
+ */ _proto._pumpPendingResolution = function _pumpPendingResolution() {
161
+ if (!this._resolutionDirty) return;
162
+ var webCanvas = this._webCanvas;
163
+ if (webCanvas.clientWidth === 0 || webCanvas.clientHeight === 0) return;
164
+ this._resolutionDirty = false;
165
+ var scale = this._autoResolutionScale;
166
+ // Snapshot the display size to detect a layout feedback loop after applying the buffer size below
167
+ var prevClientWidth = webCanvas.clientWidth;
168
+ var prevClientHeight = webCanvas.clientHeight;
169
+ if (this._pendingDevicePixelWidth > 0 && this._pendingDevicePixelHeight > 0) {
170
+ // Device pixels already fold in the device pixel ratio, so only the scale is applied
171
+ this._setResolution(Math.round(this._pendingDevicePixelWidth * scale), Math.round(this._pendingDevicePixelHeight * scale));
172
+ } else {
173
+ this._setResolutionByClientSizeFallback(scale);
174
+ }
175
+ // If setting the buffer moved the display size, the canvas has no CSS size constraint and would grow
176
+ // unboundedly; exit auto-resolution instead
177
+ if (webCanvas.clientWidth !== prevClientWidth || webCanvas.clientHeight !== prevClientHeight) {
178
+ console.warn("Auto-resolution disabled: the canvas has no CSS width/height, so sizing the buffer grows its display size. " + "Set a CSS width/height on the canvas, then call setResolution() or setAutoResolution().");
179
+ this._exitAutoResolution();
180
+ }
158
181
  };
159
- _proto._onHeightChange = function _onHeightChange(value) {
160
- this._webCanvas.height = value;
182
+ _proto._setResolutionByClientSizeFallback = function _setResolutionByClientSizeFallback(scale) {
183
+ var webCanvas = this._webCanvas;
184
+ if (webCanvas.clientWidth <= 0 || webCanvas.clientHeight <= 0) return;
185
+ var pixelRatio = window.devicePixelRatio * scale;
186
+ this._setResolution(Math.round(webCanvas.clientWidth * pixelRatio), Math.round(webCanvas.clientHeight * pixelRatio));
161
187
  };
162
- _create_class(WebCanvas, [
163
- {
164
- key: "scale",
165
- get: /**
166
- * The scale of canvas, the value is visible width/height divide the render width/height.
167
- * @remarks Need to re-assign after modification to ensure that the modification takes effect.
168
- */ function get() {
169
- var webCanvas = this._webCanvas;
170
- if (typeof OffscreenCanvas === "undefined" || !_instanceof(webCanvas, OffscreenCanvas)) {
171
- this._scale.set(webCanvas.clientWidth * devicePixelRatio / webCanvas.width, webCanvas.clientHeight * devicePixelRatio / webCanvas.height);
172
- }
173
- return this._scale;
174
- },
175
- set: function set(value) {
176
- var webCanvas = this._webCanvas;
177
- if (typeof OffscreenCanvas === "undefined" || !_instanceof(webCanvas, OffscreenCanvas)) {
178
- webCanvas.style.transformOrigin = "left top";
179
- webCanvas.style.transform = "scale(" + value.x + ", " + value.y + ")";
180
- }
181
- }
188
+ /**
189
+ * @internal
190
+ */ _proto._destroy = function _destroy() {
191
+ this._exitAutoResolution();
192
+ };
193
+ _proto._exitAutoResolution = function _exitAutoResolution() {
194
+ if (this._resizeObserver) {
195
+ this._resizeObserver.disconnect();
196
+ this._resizeObserver = undefined;
182
197
  }
183
- ]);
198
+ this._resolutionDirty = false;
199
+ this._pendingDevicePixelWidth = 0;
200
+ this._pendingDevicePixelHeight = 0;
201
+ };
202
+ _proto._onResolutionChanged = function _onResolutionChanged(width, height) {
203
+ var webCanvas = this._webCanvas;
204
+ webCanvas.width = width;
205
+ webCanvas.height = height;
206
+ };
207
+ WebCanvas._supportsDevicePixelContentBox = function _supportsDevicePixelContentBox() {
208
+ var _this__devicePixelContentBoxSupported;
209
+ // Passing { box: "device-pixel-content-box" } to observe() throws on browsers whose
210
+ // ResizeObserverBoxOptions enum lacks that value (Safari, Firefox < 93), so callers must gate on this
211
+ return (_this__devicePixelContentBoxSupported = this._devicePixelContentBoxSupported) != null ? _this__devicePixelContentBoxSupported : this._devicePixelContentBoxSupported = typeof ResizeObserverEntry !== "undefined" && "devicePixelContentBoxSize" in ResizeObserverEntry.prototype;
212
+ };
184
213
  return WebCanvas;
185
214
  }(engineCore.Canvas);
186
215
 
216
+ function _defineProperties(target, props) {
217
+ for (var i = 0; i < props.length; i++) {
218
+ var descriptor = props[i];
219
+ descriptor.enumerable = descriptor.enumerable || false;
220
+ descriptor.configurable = true;
221
+
222
+ if ("value" in descriptor) descriptor.writable = true;
223
+
224
+ Object.defineProperty(target, descriptor.key, descriptor);
225
+ }
226
+ }
227
+ function _create_class(Constructor, protoProps, staticProps) {
228
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
229
+ if (staticProps) _defineProperties(Constructor, staticProps);
230
+
231
+ return Constructor;
232
+ }
233
+
187
234
  /**
188
- * WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
235
+ * WebGL platform engine, supports WebGL 1.0 and WebGL 2.0.
189
236
  */ var WebGLEngine = /*#__PURE__*/ function(Engine) {
190
237
  _inherits(WebGLEngine, Engine);
191
238
  function WebGLEngine() {
@@ -200,7 +247,7 @@ function _instanceof(left, right) {
200
247
  var webCanvas = new WebCanvas(typeof canvas === "string" ? document.getElementById(canvas) : canvas);
201
248
  var webGLGraphicDevice = new WebGLGraphicDevice(configuration.graphicDeviceOptions);
202
249
  var engine = new WebGLEngine(webCanvas, webGLGraphicDevice, configuration);
203
- // @ts-ignore
250
+ webCanvas.setAutoResolution();
204
251
  var promise = engine._initialize(configuration);
205
252
  return promise.then(function() {
206
253
  engine.sceneManager.addScene(new engineCore.Scene(engine, "DefaultScene"));
@@ -211,9 +258,8 @@ function _instanceof(left, right) {
211
258
  {
212
259
  key: "canvas",
213
260
  get: /**
214
- * Web canvas.
261
+ * The web canvas the engine renders to.
215
262
  */ function get() {
216
- // @ts-ignore
217
263
  return this._canvas;
218
264
  }
219
265
  }
@@ -240,7 +286,18 @@ var GLBuffer = /*#__PURE__*/ function() {
240
286
  var gl = rhi.gl;
241
287
  var glBuffer = gl.createBuffer();
242
288
  var glBufferUsage = this._getGLBufferUsage(gl, bufferUsage);
243
- var glBindTarget = type === engineCore.BufferBindFlag.VertexBuffer ? gl.ARRAY_BUFFER : gl.ELEMENT_ARRAY_BUFFER;
289
+ var glBindTarget;
290
+ switch(type){
291
+ case engineCore.BufferBindFlag.VertexBuffer:
292
+ glBindTarget = gl.ARRAY_BUFFER;
293
+ break;
294
+ case engineCore.BufferBindFlag.IndexBuffer:
295
+ glBindTarget = gl.ELEMENT_ARRAY_BUFFER;
296
+ break;
297
+ case engineCore.BufferBindFlag.ConstantBuffer:
298
+ glBindTarget = gl.UNIFORM_BUFFER;
299
+ break;
300
+ }
244
301
  this._gl = gl;
245
302
  this._glBuffer = glBuffer;
246
303
  this._glBufferUsage = glBufferUsage;
@@ -290,6 +347,14 @@ var GLBuffer = /*#__PURE__*/ function() {
290
347
  throw "Buffer is write-only on WebGL1.0 platforms.";
291
348
  }
292
349
  };
350
+ _proto.copyFromBuffer = function copyFromBuffer(srcBuffer, srcByteOffset, dstByteOffset, byteLength) {
351
+ var gl = this._gl;
352
+ gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer._glBuffer);
353
+ gl.bindBuffer(gl.COPY_WRITE_BUFFER, this._glBuffer);
354
+ gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, srcByteOffset, dstByteOffset, byteLength);
355
+ gl.bindBuffer(gl.COPY_READ_BUFFER, null);
356
+ gl.bindBuffer(gl.COPY_WRITE_BUFFER, null);
357
+ };
293
358
  _proto.destroy = function destroy() {
294
359
  this._gl.deleteBuffer(this._glBuffer);
295
360
  this._gl = null;
@@ -394,8 +459,8 @@ var GLBuffer = /*#__PURE__*/ function() {
394
459
  */ _proto._compatibleInterface = function _compatibleInterface(capabilityType, flatItem) {
395
460
  var rhi = this.rhi;
396
461
  var gl = rhi.gl;
397
- var ext = null;
398
- if (ext = rhi.requireExtension(capabilityType)) {
462
+ var ext = rhi.requireExtension(capabilityType);
463
+ if (ext) {
399
464
  for(var glKey in flatItem){
400
465
  var extensionKey = flatItem[glKey];
401
466
  var extensionVal = ext[extensionKey];
@@ -775,7 +840,6 @@ var GLBuffer = /*#__PURE__*/ function() {
775
840
  * Generate multi-level textures based on the 0th level data.
776
841
  */ _proto.generateMipmaps = function generateMipmaps() {
777
842
  var texture = this._texture;
778
- //@ts-ignore
779
843
  var mipmap = texture._mipmap;
780
844
  if (!engineCore.TextureUtils.supportGenerateMipmaps(texture.format, mipmap, texture.isSRGBColorSpace, this._isWebGL2)) {
781
845
  engineCore.Logger.warn("Auto-generating mipmaps for sRGB textures is only supported in [WebGL2 + R8G8B8A8], you must generate mipmaps manually.");
@@ -796,7 +860,6 @@ var GLBuffer = /*#__PURE__*/ function() {
796
860
  var gl = this._gl;
797
861
  var isWebGL2 = this._isWebGL2;
798
862
  var _this__formatDetail = this._formatDetail, internalFormat = _this__formatDetail.internalFormat, baseFormat = _this__formatDetail.baseFormat, dataType = _this__formatDetail.dataType;
799
- // @ts-ignore
800
863
  var _this__texture = this._texture, mipmapCount = _this__texture.mipmapCount, width = _this__texture.width, height = _this__texture.height, usage = _this__texture.usage, _isDepthTexture = _this__texture._isDepthTexture;
801
864
  this._bind();
802
865
  if (isWebGL2 && !(baseFormat === gl.LUMINANCE_ALPHA || baseFormat === gl.ALPHA) && usage !== engineCore.TextureUsage.Dynamic) {
@@ -868,11 +931,10 @@ var GLBuffer = /*#__PURE__*/ function() {
868
931
  }
869
932
  var isWebGL2 = rhi.isWebGL2;
870
933
  // Validate mipmap
871
- // @ts-ignore
872
934
  var mipmap = texture._mipmap;
873
935
  if (mipmap && !engineCore.TextureUtils.supportMipmaps(width, height, isWebGL2)) {
874
936
  engineCore.Logger.warn("Non-power-2 texture is not supported for mipmap in WebGL1, and has automatically downgraded to non-mipmap");
875
- /** @ts-ignore */ texture._mipmap = false;
937
+ texture._mipmap = false;
876
938
  /** @ts-ignore */ texture._mipmapCount = texture._getMipmapCount();
877
939
  }
878
940
  };
@@ -906,7 +968,7 @@ var GLBuffer = /*#__PURE__*/ function() {
906
968
  return {
907
969
  internalFormat: isSRGBColorSpace ? gl.SRGB8 : isWebGL2 ? gl.RGB8 : gl.RGB,
908
970
  baseFormat: isSRGBColorSpace ? isWebGL2 ? gl.RGB : gl.SRGB8 : gl.RGB,
909
- readFormat: gl.RGB,
971
+ readFormat: isWebGL2 ? gl.RGBA : gl.RGB,
910
972
  dataType: gl.UNSIGNED_BYTE,
911
973
  isCompressed: false,
912
974
  alignment: 1
@@ -981,6 +1043,7 @@ var GLBuffer = /*#__PURE__*/ function() {
981
1043
  return {
982
1044
  internalFormat: gl.R11F_G11F_B10F,
983
1045
  baseFormat: gl.RGB,
1046
+ readFormat: gl.RGBA,
984
1047
  dataType: gl.FLOAT,
985
1048
  isCompressed: false,
986
1049
  alignment: 4
@@ -1044,7 +1107,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1044
1107
  };
1045
1108
  case engineCore.TextureFormat.ETC2_RGBA5:
1046
1109
  return {
1047
- internalFormat: GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
1110
+ internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 : GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
1048
1111
  isCompressed: true
1049
1112
  };
1050
1113
  case engineCore.TextureFormat.ETC2_RGBA8:
@@ -1079,27 +1142,27 @@ var GLBuffer = /*#__PURE__*/ function() {
1079
1142
  };
1080
1143
  case engineCore.TextureFormat.ASTC_5x5:
1081
1144
  return {
1082
- internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR,
1145
+ internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_5X5_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR,
1083
1146
  isCompressed: true
1084
1147
  };
1085
1148
  case engineCore.TextureFormat.ASTC_6x6:
1086
1149
  return {
1087
- internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR,
1150
+ internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_6X6_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR,
1088
1151
  isCompressed: true
1089
1152
  };
1090
1153
  case engineCore.TextureFormat.ASTC_8x8:
1091
1154
  return {
1092
- internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR,
1155
+ internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_8X8_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR,
1093
1156
  isCompressed: true
1094
1157
  };
1095
1158
  case engineCore.TextureFormat.ASTC_10x10:
1096
1159
  return {
1097
- internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR,
1160
+ internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_10X10_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR,
1098
1161
  isCompressed: true
1099
1162
  };
1100
1163
  case engineCore.TextureFormat.ASTC_12x12:
1101
1164
  return {
1102
- internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,
1165
+ internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_12X12_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,
1103
1166
  isCompressed: true
1104
1167
  };
1105
1168
  case engineCore.TextureFormat.Depth:
@@ -1304,7 +1367,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1304
1367
  */ function set(value) {
1305
1368
  var gl = this._gl;
1306
1369
  var target = this._target;
1307
- /** @ts-ignore */ var _mipmap = this._texture._mipmap;
1370
+ var _mipmap = this._texture._mipmap;
1308
1371
  this._bind();
1309
1372
  switch(value){
1310
1373
  case engineCore.TextureFilterMode.Point:
@@ -1393,7 +1456,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1393
1456
  throw new Error("If you want to use sRGB color space, only R8G8B8A8 format is supported in RenderTarget");
1394
1457
  }
1395
1458
  }
1396
- if (!isDepthTexture && !GLTexture._supportRenderBufferDepthFormat(_depth, rhi)) {
1459
+ if (!isDepthTexture && _depth !== null && !GLTexture._supportRenderBufferDepthFormat(_depth, rhi)) {
1397
1460
  throw new Error("TextureFormat is not supported:" + engineCore.TextureFormat[_depth] + " in RenderTarget");
1398
1461
  }
1399
1462
  if (_colorTextures.length > 1 && !rhi.canIUse(engineCore.GLCapabilityType.drawBuffers)) {
@@ -1437,15 +1500,13 @@ var GLBuffer = /*#__PURE__*/ function() {
1437
1500
  if (colorTexture) {
1438
1501
  var isCube = _instanceof(colorTexture, engineCore.TextureCube);
1439
1502
  if (mipChanged || isCube && faceChanged) {
1440
- gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, isCube ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D, // @ts-ignore
1441
- colorTexture._platformTexture._glTexture, mipLevel);
1503
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, isCube ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D, colorTexture._platformTexture._glTexture, mipLevel);
1442
1504
  }
1443
1505
  }
1444
1506
  var depthTexture = target.depthTexture;
1445
1507
  if (depthTexture) {
1446
1508
  var isCube1 = _instanceof(depthTexture, engineCore.TextureCube);
1447
1509
  if (mipChanged || isCube1) {
1448
- // @ts-ignore
1449
1510
  var platformTexture = depthTexture._platformTexture;
1450
1511
  gl.framebufferTexture2D(gl.FRAMEBUFFER, platformTexture._formatDetail.attachment, isCube1 ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D, platformTexture._glTexture, mipLevel);
1451
1512
  }
@@ -1502,7 +1563,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1502
1563
  _proto._bindMainFBO = function _bindMainFBO() {
1503
1564
  var gl = this._gl;
1504
1565
  var isWebGL2 = this._isWebGL2;
1505
- /** @ts-ignore */ var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount, width = _this__target.width, height = _this__target.height;
1566
+ var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount; _this__target.width; _this__target.height;
1506
1567
  var drawBuffers = new Array(colorTextureCount);
1507
1568
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
1508
1569
  /** color render buffer */ for(var i = 0; i < colorTextureCount; i++){
@@ -1510,7 +1571,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1510
1571
  var attachment = gl.COLOR_ATTACHMENT0 + i;
1511
1572
  drawBuffers[i] = attachment;
1512
1573
  if (!_instanceof(colorTexture, engineCore.TextureCube)) {
1513
- gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, /** @ts-ignore */ colorTexture._platformTexture._glTexture, 0);
1574
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, colorTexture._platformTexture._glTexture, 0);
1514
1575
  }
1515
1576
  }
1516
1577
  if (colorTextureCount > 1) {
@@ -1518,17 +1579,14 @@ var GLBuffer = /*#__PURE__*/ function() {
1518
1579
  }
1519
1580
  this._oriDrawBuffers = drawBuffers;
1520
1581
  /** depth render buffer */ if (_depth !== null) {
1521
- if (_instanceof(_depth, engineCore.Texture) && !_instanceof(_depth, engineCore.TextureCube)) {
1522
- // @ts-ignore
1523
- var platformTexture = _depth._platformTexture;
1524
- gl.framebufferTexture2D(gl.FRAMEBUFFER, platformTexture._formatDetail.attachment, gl.TEXTURE_2D, platformTexture._glTexture, 0);
1582
+ if (_instanceof(_depth, engineCore.Texture)) {
1583
+ if (!_instanceof(_depth, engineCore.TextureCube)) {
1584
+ var platformTexture = _depth._platformTexture;
1585
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, platformTexture._formatDetail.attachment, gl.TEXTURE_2D, platformTexture._glTexture, 0);
1586
+ }
1525
1587
  } else if (this._target.antiAliasing <= 1) {
1526
1588
  var _GLTexture__getRenderBufferDepthFormatDetail = GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2), internalFormat = _GLTexture__getRenderBufferDepthFormatDetail.internalFormat, attachment1 = _GLTexture__getRenderBufferDepthFormatDetail.attachment;
1527
- var depthRenderBuffer = gl.createRenderbuffer();
1528
- this._depthRenderBuffer = depthRenderBuffer;
1529
- gl.bindRenderbuffer(gl.RENDERBUFFER, depthRenderBuffer);
1530
- gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, width, height);
1531
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment1, gl.RENDERBUFFER, depthRenderBuffer);
1589
+ this._depthRenderBuffer = this._createRenderBuffer(internalFormat, attachment1);
1532
1590
  }
1533
1591
  }
1534
1592
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
@@ -1537,32 +1595,38 @@ var GLBuffer = /*#__PURE__*/ function() {
1537
1595
  _proto._bindMSAAFBO = function _bindMSAAFBO() {
1538
1596
  var gl = this._gl;
1539
1597
  var isWebGL2 = this._isWebGL2;
1540
- var MSAADepthRenderBuffer = gl.createRenderbuffer();
1541
- /** @ts-ignore */ var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount, antiAliasing = _this__target.antiAliasing, width = _this__target.width, height = _this__target.height;
1598
+ var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount;
1542
1599
  this._blitDrawBuffers = new Array(colorTextureCount);
1543
- this._MSAADepthRenderBuffer = MSAADepthRenderBuffer;
1544
1600
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._MSAAFrameBuffer);
1545
1601
  // prepare MRT+MSAA color RBOs
1546
1602
  for(var i = 0; i < colorTextureCount; i++){
1547
- var MSAAColorRenderBuffer = gl.createRenderbuffer();
1548
- this._MSAAColorRenderBuffers[i] = MSAAColorRenderBuffer;
1549
1603
  this._blitDrawBuffers[i] = gl.NONE;
1550
- gl.bindRenderbuffer(gl.RENDERBUFFER, MSAAColorRenderBuffer);
1551
- gl.renderbufferStorageMultisample(gl.RENDERBUFFER, antiAliasing, /** @ts-ignore */ this._target.getColorTexture(i)._platformTexture._formatDetail.internalFormat, width, height);
1552
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, MSAAColorRenderBuffer);
1604
+ var internalFormat = this._target.getColorTexture(i)._platformTexture._formatDetail.internalFormat;
1605
+ this._MSAAColorRenderBuffers[i] = this._createRenderBuffer(internalFormat, gl.COLOR_ATTACHMENT0 + i);
1553
1606
  }
1554
1607
  gl.drawBuffers(this._oriDrawBuffers);
1555
1608
  // prepare MSAA depth RBO
1556
1609
  if (_depth !== null) {
1557
- var _ref = _instanceof(_depth, engineCore.Texture) ? /** @ts-ignore */ _depth._platformTexture._formatDetail : GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2), internalFormat = _ref.internalFormat, attachment = _ref.attachment;
1558
- gl.bindRenderbuffer(gl.RENDERBUFFER, MSAADepthRenderBuffer);
1559
- gl.renderbufferStorageMultisample(gl.RENDERBUFFER, antiAliasing, internalFormat, width, height);
1560
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, MSAADepthRenderBuffer);
1610
+ var _ref = _instanceof(_depth, engineCore.Texture) ? _depth._platformTexture._formatDetail : GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2), internalFormat1 = _ref.internalFormat, attachment = _ref.attachment;
1611
+ this._MSAADepthRenderBuffer = this._createRenderBuffer(internalFormat1, attachment);
1561
1612
  }
1562
1613
  this._checkFrameBuffer();
1563
1614
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
1564
1615
  gl.bindRenderbuffer(gl.RENDERBUFFER, null);
1565
1616
  };
1617
+ _proto._createRenderBuffer = function _createRenderBuffer(internalFormat, attachment) {
1618
+ var gl = this._gl;
1619
+ var _this__target = this._target, width = _this__target.width, height = _this__target.height, antiAliasing = _this__target.antiAliasing;
1620
+ var renderBuffer = gl.createRenderbuffer();
1621
+ gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer);
1622
+ if (antiAliasing > 1) {
1623
+ gl.renderbufferStorageMultisample(gl.RENDERBUFFER, antiAliasing, internalFormat, width, height);
1624
+ } else {
1625
+ gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, width, height);
1626
+ }
1627
+ gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, renderBuffer);
1628
+ return renderBuffer;
1629
+ };
1566
1630
  _proto._checkFrameBuffer = function _checkFrameBuffer() {
1567
1631
  var gl = this._gl;
1568
1632
  var e = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
@@ -1680,12 +1744,12 @@ var GLBuffer = /*#__PURE__*/ function() {
1680
1744
  height = height || Math.max(1, this._texture.height >> mipLevel) - y;
1681
1745
  length = length || this._texture.length;
1682
1746
  this._bind();
1683
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
1684
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
1685
- gl.pixelStorei(gl.UNPACK_ALIGNMENT, formatDetail.alignment);
1686
1747
  if (isCompressed) {
1687
1748
  gl.compressedTexSubImage3D(target, mipLevel, x, y, offsetIndex, width, height, length, internalFormat, colorBuffer);
1688
1749
  } else {
1750
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
1751
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
1752
+ gl.pixelStorei(gl.UNPACK_ALIGNMENT, formatDetail.alignment);
1689
1753
  gl.texSubImage3D(target, mipLevel, x, y, offsetIndex, width, height, length, baseFormat, dataType, colorBuffer);
1690
1754
  }
1691
1755
  };
@@ -1760,9 +1824,6 @@ var GLBuffer = /*#__PURE__*/ function() {
1760
1824
  width = width || mipSize - x;
1761
1825
  height = height || mipSize - y;
1762
1826
  this._bind();
1763
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
1764
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
1765
- gl.pixelStorei(gl.UNPACK_ALIGNMENT, formatDetail.alignment);
1766
1827
  if (isCompressed) {
1767
1828
  var mipBit = 1 << mipLevel;
1768
1829
  if (isWebGL2 || this._compressedFaceFilled[face] & mipBit) {
@@ -1772,6 +1833,9 @@ var GLBuffer = /*#__PURE__*/ function() {
1772
1833
  this._compressedFaceFilled[face] |= mipBit;
1773
1834
  }
1774
1835
  } else {
1836
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
1837
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
1838
+ gl.pixelStorei(gl.UNPACK_ALIGNMENT, formatDetail.alignment);
1775
1839
  gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, mipLevel, x, y, width, height, baseFormat, dataType, colorBuffer);
1776
1840
  }
1777
1841
  };
@@ -1796,6 +1860,157 @@ var GLBuffer = /*#__PURE__*/ function() {
1796
1860
  return GLTextureCube;
1797
1861
  }(GLTexture);
1798
1862
 
1863
+ /**
1864
+ * @internal
1865
+ * WebGL2 implementation of Transform Feedback.
1866
+ */ var GLTransformFeedback = /*#__PURE__*/ function() {
1867
+ function GLTransformFeedback(rhi) {
1868
+ var gl = rhi.gl;
1869
+ this._gl = gl;
1870
+ this._glTransformFeedback = gl.createTransformFeedback();
1871
+ }
1872
+ var _proto = GLTransformFeedback.prototype;
1873
+ _proto.bindBufferRange = function bindBufferRange(index, buffer, byteOffset, byteSize) {
1874
+ var gl = this._gl;
1875
+ gl.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, index, buffer._glBuffer, byteOffset, byteSize);
1876
+ };
1877
+ _proto.unbindBuffer = function unbindBuffer(index) {
1878
+ var gl = this._gl;
1879
+ gl.bindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, index, null);
1880
+ };
1881
+ _proto.begin = function begin(primitiveMode) {
1882
+ this._gl.beginTransformFeedback(primitiveMode);
1883
+ };
1884
+ _proto.end = function end() {
1885
+ this._gl.endTransformFeedback();
1886
+ };
1887
+ _proto.bind = function bind() {
1888
+ var gl = this._gl;
1889
+ gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, this._glTransformFeedback);
1890
+ };
1891
+ _proto.unbind = function unbind() {
1892
+ var gl = this._gl;
1893
+ gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, null);
1894
+ };
1895
+ _proto.destroy = function destroy() {
1896
+ if (this._glTransformFeedback) {
1897
+ this._gl.deleteTransformFeedback(this._glTransformFeedback);
1898
+ this._glTransformFeedback = null;
1899
+ }
1900
+ };
1901
+ return GLTransformFeedback;
1902
+ }();
1903
+
1904
+ function _array_like_to_array(arr, len) {
1905
+ if (len == null || len > arr.length) len = arr.length;
1906
+
1907
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1908
+
1909
+ return arr2;
1910
+ }
1911
+
1912
+ function _unsupported_iterable_to_array(o, minLen) {
1913
+ if (!o) return;
1914
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
1915
+
1916
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1917
+
1918
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1919
+ if (n === "Map" || n === "Set") return Array.from(n);
1920
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
1921
+ }
1922
+
1923
+ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
1924
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1925
+
1926
+ if (it) return (it = it.call(o)).next.bind(it);
1927
+ // Fallback for engines without symbol support
1928
+ if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
1929
+ if (it) o = it;
1930
+
1931
+ var i = 0;
1932
+
1933
+ return function() {
1934
+ if (i >= o.length) return { done: true };
1935
+
1936
+ return { done: false, value: o[i++] };
1937
+ };
1938
+ }
1939
+
1940
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1941
+ }
1942
+
1943
+ /**
1944
+ * @internal
1945
+ * WebGL2 implementation of Transform Feedback primitive.
1946
+ * Maintains two VAOs (one per read direction), auto-rebuilds when program changes.
1947
+ */ var GLTransformFeedbackPrimitive = /*#__PURE__*/ function() {
1948
+ function GLTransformFeedbackPrimitive(gl) {
1949
+ this._lastProgramId = -1;
1950
+ this._gl = gl;
1951
+ }
1952
+ var _proto = GLTransformFeedbackPrimitive.prototype;
1953
+ _proto.updateVertexLayout = function updateVertexLayout(program, readBinding, writeBinding, feedbackElements, inputBinding, inputElements) {
1954
+ if (program.id === this._lastProgramId) return;
1955
+ this._deleteVAOs();
1956
+ var attribs = program.attributeLocation;
1957
+ this._vaoA = this._createVAO(attribs, readBinding, feedbackElements, inputBinding, inputElements);
1958
+ this._vaoB = this._createVAO(attribs, writeBinding, feedbackElements, inputBinding, inputElements);
1959
+ this._lastProgramId = program.id;
1960
+ this._gl.bindVertexArray(null);
1961
+ };
1962
+ _proto.bind = function bind(readIsA) {
1963
+ this._gl.bindVertexArray(readIsA ? this._vaoA : this._vaoB);
1964
+ };
1965
+ _proto.unbind = function unbind() {
1966
+ this._gl.bindVertexArray(null);
1967
+ };
1968
+ _proto.draw = function draw(mode, first, count) {
1969
+ this._gl.drawArrays(mode, first, count);
1970
+ };
1971
+ _proto.invalidate = function invalidate() {
1972
+ this._deleteVAOs();
1973
+ };
1974
+ _proto.destroy = function destroy() {
1975
+ this._deleteVAOs();
1976
+ };
1977
+ _proto._deleteVAOs = function _deleteVAOs() {
1978
+ var gl = this._gl;
1979
+ if (this._vaoA) {
1980
+ gl.deleteVertexArray(this._vaoA);
1981
+ this._vaoA = null;
1982
+ }
1983
+ if (this._vaoB) {
1984
+ gl.deleteVertexArray(this._vaoB);
1985
+ this._vaoB = null;
1986
+ }
1987
+ this._lastProgramId = -1;
1988
+ };
1989
+ _proto._createVAO = function _createVAO(attribs, feedbackBinding, feedbackElements, inputBinding, inputElements) {
1990
+ var gl = this._gl;
1991
+ var vao = gl.createVertexArray();
1992
+ gl.bindVertexArray(vao);
1993
+ gl.bindBuffer(gl.ARRAY_BUFFER, feedbackBinding.buffer._platformBuffer._glBuffer);
1994
+ this._bindElements(gl, attribs, feedbackElements, feedbackBinding.stride);
1995
+ gl.bindBuffer(gl.ARRAY_BUFFER, inputBinding.buffer._platformBuffer._glBuffer);
1996
+ this._bindElements(gl, attribs, inputElements, inputBinding.stride);
1997
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
1998
+ return vao;
1999
+ };
2000
+ _proto._bindElements = function _bindElements(gl, attribs, elements, stride) {
2001
+ for(var _iterator = _create_for_of_iterator_helper_loose(elements), _step; !(_step = _iterator()).done;){
2002
+ var element = _step.value;
2003
+ var loc = attribs[element.attribute];
2004
+ if (loc !== undefined && loc !== -1) {
2005
+ var info = element._formatMetaInfo;
2006
+ gl.enableVertexAttribArray(loc);
2007
+ gl.vertexAttribPointer(loc, info.size, info.type, info.normalized, stride, element.offset);
2008
+ }
2009
+ }
2010
+ };
2011
+ return GLTransformFeedbackPrimitive;
2012
+ }();
2013
+
1799
2014
  /**
1800
2015
  * WebGL mode.
1801
2016
  */ var WebGLMode = /*#__PURE__*/ function(WebGLMode) {
@@ -1874,7 +2089,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1874
2089
  var gl;
1875
2090
  if (webGLMode == 0 || webGLMode == 1) {
1876
2091
  gl = webCanvas.getContext("webgl2", webGLOptions);
1877
- if (!gl && (typeof OffscreenCanvas === "undefined" || !_instanceof(webCanvas, OffscreenCanvas))) {
2092
+ if (!gl && !canvas._isOffscreenCanvas()) {
1878
2093
  gl = webCanvas.getContext("experimental-webgl2", webGLOptions);
1879
2094
  }
1880
2095
  this._isWebGL2 = true;
@@ -1886,7 +2101,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1886
2101
  if (!gl) {
1887
2102
  if (webGLMode == 0 || webGLMode == 2) {
1888
2103
  gl = webCanvas.getContext("webgl", webGLOptions);
1889
- if (!gl && (typeof OffscreenCanvas === "undefined" || !_instanceof(webCanvas, OffscreenCanvas))) {
2104
+ if (!gl && !canvas._isOffscreenCanvas()) {
1890
2105
  gl = webCanvas.getContext("experimental-webgl", webGLOptions);
1891
2106
  }
1892
2107
  this._isWebGL2 = false;
@@ -1917,6 +2132,49 @@ var GLBuffer = /*#__PURE__*/ function() {
1917
2132
  if (bufferUsage === void 0) bufferUsage = engineCore.BufferUsage.Static;
1918
2133
  return new GLBuffer(this, type, byteLength, bufferUsage, data);
1919
2134
  };
2135
+ _proto.createPlatformTransformFeedback = function createPlatformTransformFeedback() {
2136
+ return new GLTransformFeedback(this);
2137
+ };
2138
+ _proto.createPlatformTransformFeedbackPrimitive = function createPlatformTransformFeedbackPrimitive() {
2139
+ return new GLTransformFeedbackPrimitive(this._gl);
2140
+ };
2141
+ _proto.bindUniformBufferBase = function bindUniformBufferBase(bindingPoint, buffer) {
2142
+ var gl = this._gl;
2143
+ gl.bindBufferBase(gl.UNIFORM_BUFFER, bindingPoint, buffer._glBuffer);
2144
+ };
2145
+ _proto.bindUniformBlock = function bindUniformBlock(program, blockName, bindingPoint) {
2146
+ var gl = this._gl;
2147
+ var blockIndex = gl.getUniformBlockIndex(program, blockName);
2148
+ if (blockIndex !== gl.INVALID_INDEX) {
2149
+ gl.uniformBlockBinding(program, blockIndex, bindingPoint);
2150
+ }
2151
+ return blockIndex;
2152
+ };
2153
+ /**
2154
+ * Enable GL_RASTERIZER_DISCARD (WebGL2 only).
2155
+ */ _proto.enableRasterizerDiscard = function enableRasterizerDiscard() {
2156
+ if (this._isWebGL2) {
2157
+ var gl = this._gl;
2158
+ gl.enable(gl.RASTERIZER_DISCARD);
2159
+ }
2160
+ };
2161
+ /**
2162
+ * Disable GL_RASTERIZER_DISCARD (WebGL2 only).
2163
+ */ _proto.disableRasterizerDiscard = function disableRasterizerDiscard() {
2164
+ if (this._isWebGL2) {
2165
+ var gl = this._gl;
2166
+ gl.disable(gl.RASTERIZER_DISCARD);
2167
+ }
2168
+ };
2169
+ /**
2170
+ * Invalidate the cached shader program state.
2171
+ * Call this after using a custom program (e.g., Transform Feedback) outside the engine's pipeline.
2172
+ */ _proto.invalidateShaderProgramState = function invalidateShaderProgramState() {
2173
+ if (this._currentBindShaderProgram) {
2174
+ this._gl.useProgram(null);
2175
+ this._currentBindShaderProgram = null;
2176
+ }
2177
+ };
1920
2178
  _proto.requireExtension = function requireExtension(ext) {
1921
2179
  return this._extensions.requireExtension(ext);
1922
2180
  };
@@ -2005,8 +2263,8 @@ var GLBuffer = /*#__PURE__*/ function() {
2005
2263
  _proto.activeRenderTarget = function activeRenderTarget(renderTarget, viewport, isFlipProjection, mipLevel, faceIndex) {
2006
2264
  var bufferWidth, bufferHeight;
2007
2265
  if (renderTarget) {
2008
- /** @ts-ignore */ renderTarget._isContentLost = false;
2009
- /** @ts-ignore */ var platformRenderTarget = renderTarget._platformRenderTarget;
2266
+ renderTarget._isContentLost = false;
2267
+ var platformRenderTarget = renderTarget._platformRenderTarget;
2010
2268
  platformRenderTarget.activeRenderTarget(mipLevel, faceIndex);
2011
2269
  bufferWidth = renderTarget.width >> mipLevel;
2012
2270
  bufferHeight = renderTarget.height >> mipLevel;
@@ -2047,7 +2305,6 @@ var GLBuffer = /*#__PURE__*/ function() {
2047
2305
  gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, destFrameBuffer);
2048
2306
  var blitMask = needBlitColor ? gl.COLOR_BUFFER_BIT : 0;
2049
2307
  if (needBlitDepth || needBlitStencil) {
2050
- // @ts-ignore
2051
2308
  var depthFormat = destRT._depthFormat;
2052
2309
  if (needBlitDepth) {
2053
2310
  if (depthFormat === engineCore.TextureFormat.Depth || depthFormat >= engineCore.TextureFormat.DepthStencil && depthFormat <= engineCore.TextureFormat.Depth32Stencil8) {
@@ -2084,11 +2341,9 @@ var GLBuffer = /*#__PURE__*/ function() {
2084
2341
  var _srcRT__platformRenderTarget__frameBuffer;
2085
2342
  // @ts-ignore
2086
2343
  var frameBuffer = (_srcRT__platformRenderTarget__frameBuffer = srcRT == null ? void 0 : srcRT._platformRenderTarget._frameBuffer) != null ? _srcRT__platformRenderTarget__frameBuffer : this._mainFrameBuffer;
2087
- // @ts-ignore
2088
2344
  gl.bindFramebuffer(gl.FRAMEBUFFER, frameBuffer);
2089
- // @ts-ignore
2090
2345
  var glTexture = grabTexture._platformTexture;
2091
- glTexture._bind();
2346
+ this.bindTexture(glTexture);
2092
2347
  gl.copyTexSubImage2D(glTexture._target, 0, 0, 0, xStart, yStart, copyWidth, copyHeight);
2093
2348
  };
2094
2349
  _proto.activeTexture = function activeTexture(textureID) {
@@ -2157,6 +2412,9 @@ var GLBuffer = /*#__PURE__*/ function() {
2157
2412
  if (debugRenderInfo != null) {
2158
2413
  this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
2159
2414
  }
2415
+ if (this._isWebGL2) {
2416
+ this.maxUniformBlockSize = gl.getParameter(gl.MAX_UNIFORM_BLOCK_SIZE);
2417
+ }
2160
2418
  };
2161
2419
  _proto.destroy = function destroy() {
2162
2420
  var webCanvas = this._webCanvas;