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

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/module.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Canvas, Scene, Engine, BufferUsage, BufferBindFlag, SetDataOptions, GLCapabilityType, Logger, TextureUtils, TextureUsage, TextureWrapMode, TextureFormat, TextureFilterMode, TextureDepthCompareFunction, Texture, TextureCube, CameraClearFlags, ColorWriteMask, SystemInfo, Platform } from '@galacean/engine-core';
2
- import { Vector2, MathUtil, Vector4, Color } from '@galacean/engine-math';
2
+ import { MathUtil, Vector4, Color } from '@galacean/engine-math';
3
3
 
4
4
  /**
5
5
  * Smoothing plug-in.
@@ -69,24 +69,6 @@ import { Vector2, MathUtil, Vector4, Color } from '@galacean/engine-math';
69
69
  return GLCompressedTextureInternalFormat;
70
70
  }({});
71
71
 
72
- function _defineProperties(target, props) {
73
- for (var i = 0; i < props.length; i++) {
74
- var descriptor = props[i];
75
- descriptor.enumerable = descriptor.enumerable || false;
76
- descriptor.configurable = true;
77
-
78
- if ("value" in descriptor) descriptor.writable = true;
79
-
80
- Object.defineProperty(target, descriptor.key, descriptor);
81
- }
82
- }
83
- function _create_class(Constructor, protoProps, staticProps) {
84
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
85
- if (staticProps) _defineProperties(Constructor, staticProps);
86
-
87
- return Constructor;
88
- }
89
-
90
72
  function _set_prototype_of(o, p) {
91
73
  _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
92
74
  o.__proto__ = p;
@@ -119,69 +101,134 @@ function _instanceof(left, right) {
119
101
  _inherits(WebCanvas, Canvas);
120
102
  function WebCanvas(webCanvas) {
121
103
  var _this;
122
- _this = Canvas.call(this) || this, _this._scale = new Vector2();
123
- var width = webCanvas.width;
124
- var height = webCanvas.height;
104
+ _this = Canvas.call(this) || this, _this._autoResolutionScale = 1, _this._resolutionDirty = false, _this._pendingDevicePixelWidth = 0, _this._pendingDevicePixelHeight = 0;
125
105
  _this._webCanvas = webCanvas;
126
- _this.width = width;
127
- _this.height = height;
106
+ _this._setResolution(webCanvas.width, webCanvas.height);
128
107
  return _this;
129
108
  }
130
109
  var _proto = WebCanvas.prototype;
131
110
  /**
132
- * Resize the rendering size according to the clientWidth and clientHeight of the canvas.
133
- * @param pixelRatio - Pixel ratio
134
- */ _proto.resizeByClientSize = function resizeByClientSize(pixelRatio) {
135
- if (pixelRatio === void 0) pixelRatio = window.devicePixelRatio;
136
- var webCanvas = this._webCanvas;
137
- if (typeof OffscreenCanvas === "undefined" || !_instanceof(webCanvas, OffscreenCanvas)) {
138
- var exportWidth = webCanvas.clientWidth * pixelRatio;
139
- var exportHeight = webCanvas.clientHeight * pixelRatio;
140
- this.width = exportWidth;
141
- this.height = exportHeight;
111
+ * @inheritdoc
112
+ *
113
+ * @remarks
114
+ * The canvas must have a CSS-constrained display size; otherwise auto-resolution disables itself.
115
+ */ _proto.setAutoResolution = function setAutoResolution(scale) {
116
+ var _this = this;
117
+ if (scale === void 0) scale = 1;
118
+ if (!Number.isFinite(scale) || scale <= 0) {
119
+ throw new Error("WebCanvas.setAutoResolution: invalid scale " + scale);
120
+ }
121
+ // OffscreenCanvas has no display size to follow
122
+ if (this._isOffscreenCanvas()) return;
123
+ this._autoResolutionScale = scale;
124
+ if (this._resizeObserver) {
125
+ this._resolutionDirty = true;
126
+ } else if (typeof ResizeObserver !== "undefined") {
127
+ // observe() fires an initial entry, which sets the pending device pixel size
128
+ this._resizeObserver = new ResizeObserver(function(entries) {
129
+ var _entries__devicePixelContentBoxSize;
130
+ var box = (_entries__devicePixelContentBoxSize = entries[entries.length - 1].devicePixelContentBoxSize) == null ? void 0 : _entries__devicePixelContentBoxSize[0];
131
+ _this._pendingDevicePixelWidth = box ? box.inlineSize : 0;
132
+ _this._pendingDevicePixelHeight = box ? box.blockSize : 0;
133
+ _this._resolutionDirty = true;
134
+ });
135
+ // Observe exact device pixels where supported, otherwise the content-box and size from the client size
136
+ if (WebCanvas._supportsDevicePixelContentBox()) {
137
+ this._resizeObserver.observe(this._webCanvas, {
138
+ box: "device-pixel-content-box"
139
+ });
140
+ } else {
141
+ this._resizeObserver.observe(this._webCanvas);
142
+ }
143
+ } else {
144
+ // ResizeObserver is unavailable (e.g. mini-programs, iOS Safari < 13.4): size once from the client size
145
+ console.warn("ResizeObserver is not supported in this environment. Falling back to one-time clientWidth × devicePixelRatio × scale sizing");
146
+ this._setResolutionByClientSizeFallback(scale);
142
147
  }
143
148
  };
144
149
  /**
145
- * Set scale.
146
- * @param x - Scale along the X axis
147
- * @param y - Scale along the Y axis
148
- */ _proto.setScale = function setScale(x, y) {
149
- this._scale.set(x, y);
150
- this.scale = this._scale;
150
+ * @internal
151
+ */ _proto._isOffscreenCanvas = function _isOffscreenCanvas() {
152
+ return typeof OffscreenCanvas !== "undefined" && _instanceof(this._webCanvas, OffscreenCanvas);
151
153
  };
152
- _proto._onWidthChanged = function _onWidthChanged(value) {
153
- this._webCanvas.width = value;
154
+ /**
155
+ * @internal
156
+ */ _proto._pumpPendingResolution = function _pumpPendingResolution() {
157
+ if (!this._resolutionDirty) return;
158
+ var webCanvas = this._webCanvas;
159
+ if (webCanvas.clientWidth === 0 || webCanvas.clientHeight === 0) return;
160
+ this._resolutionDirty = false;
161
+ var scale = this._autoResolutionScale;
162
+ // Snapshot the display size to detect a layout feedback loop after applying the buffer size below
163
+ var prevClientWidth = webCanvas.clientWidth;
164
+ var prevClientHeight = webCanvas.clientHeight;
165
+ if (this._pendingDevicePixelWidth > 0 && this._pendingDevicePixelHeight > 0) {
166
+ // Device pixels already fold in the device pixel ratio, so only the scale is applied
167
+ this._setResolution(Math.round(this._pendingDevicePixelWidth * scale), Math.round(this._pendingDevicePixelHeight * scale));
168
+ } else {
169
+ this._setResolutionByClientSizeFallback(scale);
170
+ }
171
+ // If setting the buffer moved the display size, the canvas has no CSS size constraint and would grow
172
+ // unboundedly; exit auto-resolution instead
173
+ if (webCanvas.clientWidth !== prevClientWidth || webCanvas.clientHeight !== prevClientHeight) {
174
+ 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().");
175
+ this._exitAutoResolution();
176
+ }
154
177
  };
155
- _proto._onHeightChange = function _onHeightChange(value) {
156
- this._webCanvas.height = value;
178
+ _proto._setResolutionByClientSizeFallback = function _setResolutionByClientSizeFallback(scale) {
179
+ var webCanvas = this._webCanvas;
180
+ if (webCanvas.clientWidth <= 0 || webCanvas.clientHeight <= 0) return;
181
+ var pixelRatio = window.devicePixelRatio * scale;
182
+ this._setResolution(Math.round(webCanvas.clientWidth * pixelRatio), Math.round(webCanvas.clientHeight * pixelRatio));
157
183
  };
158
- _create_class(WebCanvas, [
159
- {
160
- key: "scale",
161
- get: /**
162
- * The scale of canvas, the value is visible width/height divide the render width/height.
163
- * @remarks Need to re-assign after modification to ensure that the modification takes effect.
164
- */ function get() {
165
- var webCanvas = this._webCanvas;
166
- if (typeof OffscreenCanvas === "undefined" || !_instanceof(webCanvas, OffscreenCanvas)) {
167
- this._scale.set(webCanvas.clientWidth * devicePixelRatio / webCanvas.width, webCanvas.clientHeight * devicePixelRatio / webCanvas.height);
168
- }
169
- return this._scale;
170
- },
171
- set: function set(value) {
172
- var webCanvas = this._webCanvas;
173
- if (typeof OffscreenCanvas === "undefined" || !_instanceof(webCanvas, OffscreenCanvas)) {
174
- webCanvas.style.transformOrigin = "left top";
175
- webCanvas.style.transform = "scale(" + value.x + ", " + value.y + ")";
176
- }
177
- }
184
+ /**
185
+ * @internal
186
+ */ _proto._destroy = function _destroy() {
187
+ this._exitAutoResolution();
188
+ };
189
+ _proto._exitAutoResolution = function _exitAutoResolution() {
190
+ if (this._resizeObserver) {
191
+ this._resizeObserver.disconnect();
192
+ this._resizeObserver = undefined;
178
193
  }
179
- ]);
194
+ this._resolutionDirty = false;
195
+ this._pendingDevicePixelWidth = 0;
196
+ this._pendingDevicePixelHeight = 0;
197
+ };
198
+ _proto._onResolutionChanged = function _onResolutionChanged(width, height) {
199
+ var webCanvas = this._webCanvas;
200
+ webCanvas.width = width;
201
+ webCanvas.height = height;
202
+ };
203
+ WebCanvas._supportsDevicePixelContentBox = function _supportsDevicePixelContentBox() {
204
+ var _this__devicePixelContentBoxSupported;
205
+ // Passing { box: "device-pixel-content-box" } to observe() throws on browsers whose
206
+ // ResizeObserverBoxOptions enum lacks that value (Safari, Firefox < 93), so callers must gate on this
207
+ return (_this__devicePixelContentBoxSupported = this._devicePixelContentBoxSupported) != null ? _this__devicePixelContentBoxSupported : this._devicePixelContentBoxSupported = typeof ResizeObserverEntry !== "undefined" && "devicePixelContentBoxSize" in ResizeObserverEntry.prototype;
208
+ };
180
209
  return WebCanvas;
181
210
  }(Canvas);
182
211
 
212
+ function _defineProperties(target, props) {
213
+ for (var i = 0; i < props.length; i++) {
214
+ var descriptor = props[i];
215
+ descriptor.enumerable = descriptor.enumerable || false;
216
+ descriptor.configurable = true;
217
+
218
+ if ("value" in descriptor) descriptor.writable = true;
219
+
220
+ Object.defineProperty(target, descriptor.key, descriptor);
221
+ }
222
+ }
223
+ function _create_class(Constructor, protoProps, staticProps) {
224
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
225
+ if (staticProps) _defineProperties(Constructor, staticProps);
226
+
227
+ return Constructor;
228
+ }
229
+
183
230
  /**
184
- * WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
231
+ * WebGL platform engine, supports WebGL 1.0 and WebGL 2.0.
185
232
  */ var WebGLEngine = /*#__PURE__*/ function(Engine) {
186
233
  _inherits(WebGLEngine, Engine);
187
234
  function WebGLEngine() {
@@ -196,7 +243,7 @@ function _instanceof(left, right) {
196
243
  var webCanvas = new WebCanvas(typeof canvas === "string" ? document.getElementById(canvas) : canvas);
197
244
  var webGLGraphicDevice = new WebGLGraphicDevice(configuration.graphicDeviceOptions);
198
245
  var engine = new WebGLEngine(webCanvas, webGLGraphicDevice, configuration);
199
- // @ts-ignore
246
+ webCanvas.setAutoResolution();
200
247
  var promise = engine._initialize(configuration);
201
248
  return promise.then(function() {
202
249
  engine.sceneManager.addScene(new Scene(engine, "DefaultScene"));
@@ -207,9 +254,8 @@ function _instanceof(left, right) {
207
254
  {
208
255
  key: "canvas",
209
256
  get: /**
210
- * Web canvas.
257
+ * The web canvas the engine renders to.
211
258
  */ function get() {
212
- // @ts-ignore
213
259
  return this._canvas;
214
260
  }
215
261
  }
@@ -236,7 +282,18 @@ var GLBuffer = /*#__PURE__*/ function() {
236
282
  var gl = rhi.gl;
237
283
  var glBuffer = gl.createBuffer();
238
284
  var glBufferUsage = this._getGLBufferUsage(gl, bufferUsage);
239
- var glBindTarget = type === BufferBindFlag.VertexBuffer ? gl.ARRAY_BUFFER : gl.ELEMENT_ARRAY_BUFFER;
285
+ var glBindTarget;
286
+ switch(type){
287
+ case BufferBindFlag.VertexBuffer:
288
+ glBindTarget = gl.ARRAY_BUFFER;
289
+ break;
290
+ case BufferBindFlag.IndexBuffer:
291
+ glBindTarget = gl.ELEMENT_ARRAY_BUFFER;
292
+ break;
293
+ case BufferBindFlag.ConstantBuffer:
294
+ glBindTarget = gl.UNIFORM_BUFFER;
295
+ break;
296
+ }
240
297
  this._gl = gl;
241
298
  this._glBuffer = glBuffer;
242
299
  this._glBufferUsage = glBufferUsage;
@@ -286,6 +343,14 @@ var GLBuffer = /*#__PURE__*/ function() {
286
343
  throw "Buffer is write-only on WebGL1.0 platforms.";
287
344
  }
288
345
  };
346
+ _proto.copyFromBuffer = function copyFromBuffer(srcBuffer, srcByteOffset, dstByteOffset, byteLength) {
347
+ var gl = this._gl;
348
+ gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer._glBuffer);
349
+ gl.bindBuffer(gl.COPY_WRITE_BUFFER, this._glBuffer);
350
+ gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, srcByteOffset, dstByteOffset, byteLength);
351
+ gl.bindBuffer(gl.COPY_READ_BUFFER, null);
352
+ gl.bindBuffer(gl.COPY_WRITE_BUFFER, null);
353
+ };
289
354
  _proto.destroy = function destroy() {
290
355
  this._gl.deleteBuffer(this._glBuffer);
291
356
  this._gl = null;
@@ -390,8 +455,8 @@ var GLBuffer = /*#__PURE__*/ function() {
390
455
  */ _proto._compatibleInterface = function _compatibleInterface(capabilityType, flatItem) {
391
456
  var rhi = this.rhi;
392
457
  var gl = rhi.gl;
393
- var ext = null;
394
- if (ext = rhi.requireExtension(capabilityType)) {
458
+ var ext = rhi.requireExtension(capabilityType);
459
+ if (ext) {
395
460
  for(var glKey in flatItem){
396
461
  var extensionKey = flatItem[glKey];
397
462
  var extensionVal = ext[extensionKey];
@@ -771,7 +836,6 @@ var GLBuffer = /*#__PURE__*/ function() {
771
836
  * Generate multi-level textures based on the 0th level data.
772
837
  */ _proto.generateMipmaps = function generateMipmaps() {
773
838
  var texture = this._texture;
774
- //@ts-ignore
775
839
  var mipmap = texture._mipmap;
776
840
  if (!TextureUtils.supportGenerateMipmaps(texture.format, mipmap, texture.isSRGBColorSpace, this._isWebGL2)) {
777
841
  Logger.warn("Auto-generating mipmaps for sRGB textures is only supported in [WebGL2 + R8G8B8A8], you must generate mipmaps manually.");
@@ -792,7 +856,6 @@ var GLBuffer = /*#__PURE__*/ function() {
792
856
  var gl = this._gl;
793
857
  var isWebGL2 = this._isWebGL2;
794
858
  var _this__formatDetail = this._formatDetail, internalFormat = _this__formatDetail.internalFormat, baseFormat = _this__formatDetail.baseFormat, dataType = _this__formatDetail.dataType;
795
- // @ts-ignore
796
859
  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;
797
860
  this._bind();
798
861
  if (isWebGL2 && !(baseFormat === gl.LUMINANCE_ALPHA || baseFormat === gl.ALPHA) && usage !== TextureUsage.Dynamic) {
@@ -864,11 +927,10 @@ var GLBuffer = /*#__PURE__*/ function() {
864
927
  }
865
928
  var isWebGL2 = rhi.isWebGL2;
866
929
  // Validate mipmap
867
- // @ts-ignore
868
930
  var mipmap = texture._mipmap;
869
931
  if (mipmap && !TextureUtils.supportMipmaps(width, height, isWebGL2)) {
870
932
  Logger.warn("Non-power-2 texture is not supported for mipmap in WebGL1, and has automatically downgraded to non-mipmap");
871
- /** @ts-ignore */ texture._mipmap = false;
933
+ texture._mipmap = false;
872
934
  /** @ts-ignore */ texture._mipmapCount = texture._getMipmapCount();
873
935
  }
874
936
  };
@@ -902,7 +964,7 @@ var GLBuffer = /*#__PURE__*/ function() {
902
964
  return {
903
965
  internalFormat: isSRGBColorSpace ? gl.SRGB8 : isWebGL2 ? gl.RGB8 : gl.RGB,
904
966
  baseFormat: isSRGBColorSpace ? isWebGL2 ? gl.RGB : gl.SRGB8 : gl.RGB,
905
- readFormat: gl.RGB,
967
+ readFormat: isWebGL2 ? gl.RGBA : gl.RGB,
906
968
  dataType: gl.UNSIGNED_BYTE,
907
969
  isCompressed: false,
908
970
  alignment: 1
@@ -977,6 +1039,7 @@ var GLBuffer = /*#__PURE__*/ function() {
977
1039
  return {
978
1040
  internalFormat: gl.R11F_G11F_B10F,
979
1041
  baseFormat: gl.RGB,
1042
+ readFormat: gl.RGBA,
980
1043
  dataType: gl.FLOAT,
981
1044
  isCompressed: false,
982
1045
  alignment: 4
@@ -1040,7 +1103,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1040
1103
  };
1041
1104
  case TextureFormat.ETC2_RGBA5:
1042
1105
  return {
1043
- internalFormat: GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
1106
+ internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 : GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
1044
1107
  isCompressed: true
1045
1108
  };
1046
1109
  case TextureFormat.ETC2_RGBA8:
@@ -1075,27 +1138,27 @@ var GLBuffer = /*#__PURE__*/ function() {
1075
1138
  };
1076
1139
  case TextureFormat.ASTC_5x5:
1077
1140
  return {
1078
- internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR,
1141
+ internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_5X5_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR,
1079
1142
  isCompressed: true
1080
1143
  };
1081
1144
  case TextureFormat.ASTC_6x6:
1082
1145
  return {
1083
- internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR,
1146
+ internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_6X6_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR,
1084
1147
  isCompressed: true
1085
1148
  };
1086
1149
  case TextureFormat.ASTC_8x8:
1087
1150
  return {
1088
- internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR,
1151
+ internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_8X8_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR,
1089
1152
  isCompressed: true
1090
1153
  };
1091
1154
  case TextureFormat.ASTC_10x10:
1092
1155
  return {
1093
- internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR,
1156
+ internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_10X10_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR,
1094
1157
  isCompressed: true
1095
1158
  };
1096
1159
  case TextureFormat.ASTC_12x12:
1097
1160
  return {
1098
- internalFormat: GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,
1161
+ internalFormat: isSRGBColorSpace ? GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_12X12_KHR : GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,
1099
1162
  isCompressed: true
1100
1163
  };
1101
1164
  case TextureFormat.Depth:
@@ -1300,7 +1363,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1300
1363
  */ function set(value) {
1301
1364
  var gl = this._gl;
1302
1365
  var target = this._target;
1303
- /** @ts-ignore */ var _mipmap = this._texture._mipmap;
1366
+ var _mipmap = this._texture._mipmap;
1304
1367
  this._bind();
1305
1368
  switch(value){
1306
1369
  case TextureFilterMode.Point:
@@ -1389,7 +1452,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1389
1452
  throw new Error("If you want to use sRGB color space, only R8G8B8A8 format is supported in RenderTarget");
1390
1453
  }
1391
1454
  }
1392
- if (!isDepthTexture && !GLTexture._supportRenderBufferDepthFormat(_depth, rhi)) {
1455
+ if (!isDepthTexture && _depth !== null && !GLTexture._supportRenderBufferDepthFormat(_depth, rhi)) {
1393
1456
  throw new Error("TextureFormat is not supported:" + TextureFormat[_depth] + " in RenderTarget");
1394
1457
  }
1395
1458
  if (_colorTextures.length > 1 && !rhi.canIUse(GLCapabilityType.drawBuffers)) {
@@ -1433,15 +1496,13 @@ var GLBuffer = /*#__PURE__*/ function() {
1433
1496
  if (colorTexture) {
1434
1497
  var isCube = _instanceof(colorTexture, TextureCube);
1435
1498
  if (mipChanged || isCube && faceChanged) {
1436
- gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, isCube ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D, // @ts-ignore
1437
- colorTexture._platformTexture._glTexture, mipLevel);
1499
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, isCube ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D, colorTexture._platformTexture._glTexture, mipLevel);
1438
1500
  }
1439
1501
  }
1440
1502
  var depthTexture = target.depthTexture;
1441
1503
  if (depthTexture) {
1442
1504
  var isCube1 = _instanceof(depthTexture, TextureCube);
1443
1505
  if (mipChanged || isCube1) {
1444
- // @ts-ignore
1445
1506
  var platformTexture = depthTexture._platformTexture;
1446
1507
  gl.framebufferTexture2D(gl.FRAMEBUFFER, platformTexture._formatDetail.attachment, isCube1 ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D, platformTexture._glTexture, mipLevel);
1447
1508
  }
@@ -1498,7 +1559,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1498
1559
  _proto._bindMainFBO = function _bindMainFBO() {
1499
1560
  var gl = this._gl;
1500
1561
  var isWebGL2 = this._isWebGL2;
1501
- /** @ts-ignore */ var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount, width = _this__target.width, height = _this__target.height;
1562
+ var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount; _this__target.width; _this__target.height;
1502
1563
  var drawBuffers = new Array(colorTextureCount);
1503
1564
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
1504
1565
  /** color render buffer */ for(var i = 0; i < colorTextureCount; i++){
@@ -1506,7 +1567,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1506
1567
  var attachment = gl.COLOR_ATTACHMENT0 + i;
1507
1568
  drawBuffers[i] = attachment;
1508
1569
  if (!_instanceof(colorTexture, TextureCube)) {
1509
- gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, /** @ts-ignore */ colorTexture._platformTexture._glTexture, 0);
1570
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, colorTexture._platformTexture._glTexture, 0);
1510
1571
  }
1511
1572
  }
1512
1573
  if (colorTextureCount > 1) {
@@ -1514,17 +1575,14 @@ var GLBuffer = /*#__PURE__*/ function() {
1514
1575
  }
1515
1576
  this._oriDrawBuffers = drawBuffers;
1516
1577
  /** depth render buffer */ if (_depth !== null) {
1517
- if (_instanceof(_depth, Texture) && !_instanceof(_depth, TextureCube)) {
1518
- // @ts-ignore
1519
- var platformTexture = _depth._platformTexture;
1520
- gl.framebufferTexture2D(gl.FRAMEBUFFER, platformTexture._formatDetail.attachment, gl.TEXTURE_2D, platformTexture._glTexture, 0);
1578
+ if (_instanceof(_depth, Texture)) {
1579
+ if (!_instanceof(_depth, TextureCube)) {
1580
+ var platformTexture = _depth._platformTexture;
1581
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, platformTexture._formatDetail.attachment, gl.TEXTURE_2D, platformTexture._glTexture, 0);
1582
+ }
1521
1583
  } else if (this._target.antiAliasing <= 1) {
1522
1584
  var _GLTexture__getRenderBufferDepthFormatDetail = GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2), internalFormat = _GLTexture__getRenderBufferDepthFormatDetail.internalFormat, attachment1 = _GLTexture__getRenderBufferDepthFormatDetail.attachment;
1523
- var depthRenderBuffer = gl.createRenderbuffer();
1524
- this._depthRenderBuffer = depthRenderBuffer;
1525
- gl.bindRenderbuffer(gl.RENDERBUFFER, depthRenderBuffer);
1526
- gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, width, height);
1527
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment1, gl.RENDERBUFFER, depthRenderBuffer);
1585
+ this._depthRenderBuffer = this._createRenderBuffer(internalFormat, attachment1);
1528
1586
  }
1529
1587
  }
1530
1588
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
@@ -1533,32 +1591,38 @@ var GLBuffer = /*#__PURE__*/ function() {
1533
1591
  _proto._bindMSAAFBO = function _bindMSAAFBO() {
1534
1592
  var gl = this._gl;
1535
1593
  var isWebGL2 = this._isWebGL2;
1536
- var MSAADepthRenderBuffer = gl.createRenderbuffer();
1537
- /** @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;
1594
+ var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount;
1538
1595
  this._blitDrawBuffers = new Array(colorTextureCount);
1539
- this._MSAADepthRenderBuffer = MSAADepthRenderBuffer;
1540
1596
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._MSAAFrameBuffer);
1541
1597
  // prepare MRT+MSAA color RBOs
1542
1598
  for(var i = 0; i < colorTextureCount; i++){
1543
- var MSAAColorRenderBuffer = gl.createRenderbuffer();
1544
- this._MSAAColorRenderBuffers[i] = MSAAColorRenderBuffer;
1545
1599
  this._blitDrawBuffers[i] = gl.NONE;
1546
- gl.bindRenderbuffer(gl.RENDERBUFFER, MSAAColorRenderBuffer);
1547
- gl.renderbufferStorageMultisample(gl.RENDERBUFFER, antiAliasing, /** @ts-ignore */ this._target.getColorTexture(i)._platformTexture._formatDetail.internalFormat, width, height);
1548
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, MSAAColorRenderBuffer);
1600
+ var internalFormat = this._target.getColorTexture(i)._platformTexture._formatDetail.internalFormat;
1601
+ this._MSAAColorRenderBuffers[i] = this._createRenderBuffer(internalFormat, gl.COLOR_ATTACHMENT0 + i);
1549
1602
  }
1550
1603
  gl.drawBuffers(this._oriDrawBuffers);
1551
1604
  // prepare MSAA depth RBO
1552
1605
  if (_depth !== null) {
1553
- var _ref = _instanceof(_depth, Texture) ? /** @ts-ignore */ _depth._platformTexture._formatDetail : GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2), internalFormat = _ref.internalFormat, attachment = _ref.attachment;
1554
- gl.bindRenderbuffer(gl.RENDERBUFFER, MSAADepthRenderBuffer);
1555
- gl.renderbufferStorageMultisample(gl.RENDERBUFFER, antiAliasing, internalFormat, width, height);
1556
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, MSAADepthRenderBuffer);
1606
+ var _ref = _instanceof(_depth, Texture) ? _depth._platformTexture._formatDetail : GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2), internalFormat1 = _ref.internalFormat, attachment = _ref.attachment;
1607
+ this._MSAADepthRenderBuffer = this._createRenderBuffer(internalFormat1, attachment);
1557
1608
  }
1558
1609
  this._checkFrameBuffer();
1559
1610
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
1560
1611
  gl.bindRenderbuffer(gl.RENDERBUFFER, null);
1561
1612
  };
1613
+ _proto._createRenderBuffer = function _createRenderBuffer(internalFormat, attachment) {
1614
+ var gl = this._gl;
1615
+ var _this__target = this._target, width = _this__target.width, height = _this__target.height, antiAliasing = _this__target.antiAliasing;
1616
+ var renderBuffer = gl.createRenderbuffer();
1617
+ gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer);
1618
+ if (antiAliasing > 1) {
1619
+ gl.renderbufferStorageMultisample(gl.RENDERBUFFER, antiAliasing, internalFormat, width, height);
1620
+ } else {
1621
+ gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, width, height);
1622
+ }
1623
+ gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, renderBuffer);
1624
+ return renderBuffer;
1625
+ };
1562
1626
  _proto._checkFrameBuffer = function _checkFrameBuffer() {
1563
1627
  var gl = this._gl;
1564
1628
  var e = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
@@ -1676,12 +1740,12 @@ var GLBuffer = /*#__PURE__*/ function() {
1676
1740
  height = height || Math.max(1, this._texture.height >> mipLevel) - y;
1677
1741
  length = length || this._texture.length;
1678
1742
  this._bind();
1679
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
1680
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
1681
- gl.pixelStorei(gl.UNPACK_ALIGNMENT, formatDetail.alignment);
1682
1743
  if (isCompressed) {
1683
1744
  gl.compressedTexSubImage3D(target, mipLevel, x, y, offsetIndex, width, height, length, internalFormat, colorBuffer);
1684
1745
  } else {
1746
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
1747
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
1748
+ gl.pixelStorei(gl.UNPACK_ALIGNMENT, formatDetail.alignment);
1685
1749
  gl.texSubImage3D(target, mipLevel, x, y, offsetIndex, width, height, length, baseFormat, dataType, colorBuffer);
1686
1750
  }
1687
1751
  };
@@ -1756,9 +1820,6 @@ var GLBuffer = /*#__PURE__*/ function() {
1756
1820
  width = width || mipSize - x;
1757
1821
  height = height || mipSize - y;
1758
1822
  this._bind();
1759
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
1760
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
1761
- gl.pixelStorei(gl.UNPACK_ALIGNMENT, formatDetail.alignment);
1762
1823
  if (isCompressed) {
1763
1824
  var mipBit = 1 << mipLevel;
1764
1825
  if (isWebGL2 || this._compressedFaceFilled[face] & mipBit) {
@@ -1768,6 +1829,9 @@ var GLBuffer = /*#__PURE__*/ function() {
1768
1829
  this._compressedFaceFilled[face] |= mipBit;
1769
1830
  }
1770
1831
  } else {
1832
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
1833
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
1834
+ gl.pixelStorei(gl.UNPACK_ALIGNMENT, formatDetail.alignment);
1771
1835
  gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, mipLevel, x, y, width, height, baseFormat, dataType, colorBuffer);
1772
1836
  }
1773
1837
  };
@@ -1792,6 +1856,157 @@ var GLBuffer = /*#__PURE__*/ function() {
1792
1856
  return GLTextureCube;
1793
1857
  }(GLTexture);
1794
1858
 
1859
+ /**
1860
+ * @internal
1861
+ * WebGL2 implementation of Transform Feedback.
1862
+ */ var GLTransformFeedback = /*#__PURE__*/ function() {
1863
+ function GLTransformFeedback(rhi) {
1864
+ var gl = rhi.gl;
1865
+ this._gl = gl;
1866
+ this._glTransformFeedback = gl.createTransformFeedback();
1867
+ }
1868
+ var _proto = GLTransformFeedback.prototype;
1869
+ _proto.bindBufferRange = function bindBufferRange(index, buffer, byteOffset, byteSize) {
1870
+ var gl = this._gl;
1871
+ gl.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, index, buffer._glBuffer, byteOffset, byteSize);
1872
+ };
1873
+ _proto.unbindBuffer = function unbindBuffer(index) {
1874
+ var gl = this._gl;
1875
+ gl.bindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, index, null);
1876
+ };
1877
+ _proto.begin = function begin(primitiveMode) {
1878
+ this._gl.beginTransformFeedback(primitiveMode);
1879
+ };
1880
+ _proto.end = function end() {
1881
+ this._gl.endTransformFeedback();
1882
+ };
1883
+ _proto.bind = function bind() {
1884
+ var gl = this._gl;
1885
+ gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, this._glTransformFeedback);
1886
+ };
1887
+ _proto.unbind = function unbind() {
1888
+ var gl = this._gl;
1889
+ gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, null);
1890
+ };
1891
+ _proto.destroy = function destroy() {
1892
+ if (this._glTransformFeedback) {
1893
+ this._gl.deleteTransformFeedback(this._glTransformFeedback);
1894
+ this._glTransformFeedback = null;
1895
+ }
1896
+ };
1897
+ return GLTransformFeedback;
1898
+ }();
1899
+
1900
+ function _array_like_to_array(arr, len) {
1901
+ if (len == null || len > arr.length) len = arr.length;
1902
+
1903
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1904
+
1905
+ return arr2;
1906
+ }
1907
+
1908
+ function _unsupported_iterable_to_array(o, minLen) {
1909
+ if (!o) return;
1910
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
1911
+
1912
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1913
+
1914
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1915
+ if (n === "Map" || n === "Set") return Array.from(n);
1916
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
1917
+ }
1918
+
1919
+ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
1920
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1921
+
1922
+ if (it) return (it = it.call(o)).next.bind(it);
1923
+ // Fallback for engines without symbol support
1924
+ if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
1925
+ if (it) o = it;
1926
+
1927
+ var i = 0;
1928
+
1929
+ return function() {
1930
+ if (i >= o.length) return { done: true };
1931
+
1932
+ return { done: false, value: o[i++] };
1933
+ };
1934
+ }
1935
+
1936
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1937
+ }
1938
+
1939
+ /**
1940
+ * @internal
1941
+ * WebGL2 implementation of Transform Feedback primitive.
1942
+ * Maintains two VAOs (one per read direction), auto-rebuilds when program changes.
1943
+ */ var GLTransformFeedbackPrimitive = /*#__PURE__*/ function() {
1944
+ function GLTransformFeedbackPrimitive(gl) {
1945
+ this._lastProgramId = -1;
1946
+ this._gl = gl;
1947
+ }
1948
+ var _proto = GLTransformFeedbackPrimitive.prototype;
1949
+ _proto.updateVertexLayout = function updateVertexLayout(program, readBinding, writeBinding, feedbackElements, inputBinding, inputElements) {
1950
+ if (program.id === this._lastProgramId) return;
1951
+ this._deleteVAOs();
1952
+ var attribs = program.attributeLocation;
1953
+ this._vaoA = this._createVAO(attribs, readBinding, feedbackElements, inputBinding, inputElements);
1954
+ this._vaoB = this._createVAO(attribs, writeBinding, feedbackElements, inputBinding, inputElements);
1955
+ this._lastProgramId = program.id;
1956
+ this._gl.bindVertexArray(null);
1957
+ };
1958
+ _proto.bind = function bind(readIsA) {
1959
+ this._gl.bindVertexArray(readIsA ? this._vaoA : this._vaoB);
1960
+ };
1961
+ _proto.unbind = function unbind() {
1962
+ this._gl.bindVertexArray(null);
1963
+ };
1964
+ _proto.draw = function draw(mode, first, count) {
1965
+ this._gl.drawArrays(mode, first, count);
1966
+ };
1967
+ _proto.invalidate = function invalidate() {
1968
+ this._deleteVAOs();
1969
+ };
1970
+ _proto.destroy = function destroy() {
1971
+ this._deleteVAOs();
1972
+ };
1973
+ _proto._deleteVAOs = function _deleteVAOs() {
1974
+ var gl = this._gl;
1975
+ if (this._vaoA) {
1976
+ gl.deleteVertexArray(this._vaoA);
1977
+ this._vaoA = null;
1978
+ }
1979
+ if (this._vaoB) {
1980
+ gl.deleteVertexArray(this._vaoB);
1981
+ this._vaoB = null;
1982
+ }
1983
+ this._lastProgramId = -1;
1984
+ };
1985
+ _proto._createVAO = function _createVAO(attribs, feedbackBinding, feedbackElements, inputBinding, inputElements) {
1986
+ var gl = this._gl;
1987
+ var vao = gl.createVertexArray();
1988
+ gl.bindVertexArray(vao);
1989
+ gl.bindBuffer(gl.ARRAY_BUFFER, feedbackBinding.buffer._platformBuffer._glBuffer);
1990
+ this._bindElements(gl, attribs, feedbackElements, feedbackBinding.stride);
1991
+ gl.bindBuffer(gl.ARRAY_BUFFER, inputBinding.buffer._platformBuffer._glBuffer);
1992
+ this._bindElements(gl, attribs, inputElements, inputBinding.stride);
1993
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
1994
+ return vao;
1995
+ };
1996
+ _proto._bindElements = function _bindElements(gl, attribs, elements, stride) {
1997
+ for(var _iterator = _create_for_of_iterator_helper_loose(elements), _step; !(_step = _iterator()).done;){
1998
+ var element = _step.value;
1999
+ var loc = attribs[element.attribute];
2000
+ if (loc !== undefined && loc !== -1) {
2001
+ var info = element._formatMetaInfo;
2002
+ gl.enableVertexAttribArray(loc);
2003
+ gl.vertexAttribPointer(loc, info.size, info.type, info.normalized, stride, element.offset);
2004
+ }
2005
+ }
2006
+ };
2007
+ return GLTransformFeedbackPrimitive;
2008
+ }();
2009
+
1795
2010
  /**
1796
2011
  * WebGL mode.
1797
2012
  */ var WebGLMode = /*#__PURE__*/ function(WebGLMode) {
@@ -1870,7 +2085,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1870
2085
  var gl;
1871
2086
  if (webGLMode == 0 || webGLMode == 1) {
1872
2087
  gl = webCanvas.getContext("webgl2", webGLOptions);
1873
- if (!gl && (typeof OffscreenCanvas === "undefined" || !_instanceof(webCanvas, OffscreenCanvas))) {
2088
+ if (!gl && !canvas._isOffscreenCanvas()) {
1874
2089
  gl = webCanvas.getContext("experimental-webgl2", webGLOptions);
1875
2090
  }
1876
2091
  this._isWebGL2 = true;
@@ -1882,7 +2097,7 @@ var GLBuffer = /*#__PURE__*/ function() {
1882
2097
  if (!gl) {
1883
2098
  if (webGLMode == 0 || webGLMode == 2) {
1884
2099
  gl = webCanvas.getContext("webgl", webGLOptions);
1885
- if (!gl && (typeof OffscreenCanvas === "undefined" || !_instanceof(webCanvas, OffscreenCanvas))) {
2100
+ if (!gl && !canvas._isOffscreenCanvas()) {
1886
2101
  gl = webCanvas.getContext("experimental-webgl", webGLOptions);
1887
2102
  }
1888
2103
  this._isWebGL2 = false;
@@ -1913,6 +2128,49 @@ var GLBuffer = /*#__PURE__*/ function() {
1913
2128
  if (bufferUsage === void 0) bufferUsage = BufferUsage.Static;
1914
2129
  return new GLBuffer(this, type, byteLength, bufferUsage, data);
1915
2130
  };
2131
+ _proto.createPlatformTransformFeedback = function createPlatformTransformFeedback() {
2132
+ return new GLTransformFeedback(this);
2133
+ };
2134
+ _proto.createPlatformTransformFeedbackPrimitive = function createPlatformTransformFeedbackPrimitive() {
2135
+ return new GLTransformFeedbackPrimitive(this._gl);
2136
+ };
2137
+ _proto.bindUniformBufferBase = function bindUniformBufferBase(bindingPoint, buffer) {
2138
+ var gl = this._gl;
2139
+ gl.bindBufferBase(gl.UNIFORM_BUFFER, bindingPoint, buffer._glBuffer);
2140
+ };
2141
+ _proto.bindUniformBlock = function bindUniformBlock(program, blockName, bindingPoint) {
2142
+ var gl = this._gl;
2143
+ var blockIndex = gl.getUniformBlockIndex(program, blockName);
2144
+ if (blockIndex !== gl.INVALID_INDEX) {
2145
+ gl.uniformBlockBinding(program, blockIndex, bindingPoint);
2146
+ }
2147
+ return blockIndex;
2148
+ };
2149
+ /**
2150
+ * Enable GL_RASTERIZER_DISCARD (WebGL2 only).
2151
+ */ _proto.enableRasterizerDiscard = function enableRasterizerDiscard() {
2152
+ if (this._isWebGL2) {
2153
+ var gl = this._gl;
2154
+ gl.enable(gl.RASTERIZER_DISCARD);
2155
+ }
2156
+ };
2157
+ /**
2158
+ * Disable GL_RASTERIZER_DISCARD (WebGL2 only).
2159
+ */ _proto.disableRasterizerDiscard = function disableRasterizerDiscard() {
2160
+ if (this._isWebGL2) {
2161
+ var gl = this._gl;
2162
+ gl.disable(gl.RASTERIZER_DISCARD);
2163
+ }
2164
+ };
2165
+ /**
2166
+ * Invalidate the cached shader program state.
2167
+ * Call this after using a custom program (e.g., Transform Feedback) outside the engine's pipeline.
2168
+ */ _proto.invalidateShaderProgramState = function invalidateShaderProgramState() {
2169
+ if (this._currentBindShaderProgram) {
2170
+ this._gl.useProgram(null);
2171
+ this._currentBindShaderProgram = null;
2172
+ }
2173
+ };
1916
2174
  _proto.requireExtension = function requireExtension(ext) {
1917
2175
  return this._extensions.requireExtension(ext);
1918
2176
  };
@@ -2001,8 +2259,8 @@ var GLBuffer = /*#__PURE__*/ function() {
2001
2259
  _proto.activeRenderTarget = function activeRenderTarget(renderTarget, viewport, isFlipProjection, mipLevel, faceIndex) {
2002
2260
  var bufferWidth, bufferHeight;
2003
2261
  if (renderTarget) {
2004
- /** @ts-ignore */ renderTarget._isContentLost = false;
2005
- /** @ts-ignore */ var platformRenderTarget = renderTarget._platformRenderTarget;
2262
+ renderTarget._isContentLost = false;
2263
+ var platformRenderTarget = renderTarget._platformRenderTarget;
2006
2264
  platformRenderTarget.activeRenderTarget(mipLevel, faceIndex);
2007
2265
  bufferWidth = renderTarget.width >> mipLevel;
2008
2266
  bufferHeight = renderTarget.height >> mipLevel;
@@ -2043,7 +2301,6 @@ var GLBuffer = /*#__PURE__*/ function() {
2043
2301
  gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, destFrameBuffer);
2044
2302
  var blitMask = needBlitColor ? gl.COLOR_BUFFER_BIT : 0;
2045
2303
  if (needBlitDepth || needBlitStencil) {
2046
- // @ts-ignore
2047
2304
  var depthFormat = destRT._depthFormat;
2048
2305
  if (needBlitDepth) {
2049
2306
  if (depthFormat === TextureFormat.Depth || depthFormat >= TextureFormat.DepthStencil && depthFormat <= TextureFormat.Depth32Stencil8) {
@@ -2080,11 +2337,9 @@ var GLBuffer = /*#__PURE__*/ function() {
2080
2337
  var _srcRT__platformRenderTarget__frameBuffer;
2081
2338
  // @ts-ignore
2082
2339
  var frameBuffer = (_srcRT__platformRenderTarget__frameBuffer = srcRT == null ? void 0 : srcRT._platformRenderTarget._frameBuffer) != null ? _srcRT__platformRenderTarget__frameBuffer : this._mainFrameBuffer;
2083
- // @ts-ignore
2084
2340
  gl.bindFramebuffer(gl.FRAMEBUFFER, frameBuffer);
2085
- // @ts-ignore
2086
2341
  var glTexture = grabTexture._platformTexture;
2087
- glTexture._bind();
2342
+ this.bindTexture(glTexture);
2088
2343
  gl.copyTexSubImage2D(glTexture._target, 0, 0, 0, xStart, yStart, copyWidth, copyHeight);
2089
2344
  };
2090
2345
  _proto.activeTexture = function activeTexture(textureID) {
@@ -2153,6 +2408,9 @@ var GLBuffer = /*#__PURE__*/ function() {
2153
2408
  if (debugRenderInfo != null) {
2154
2409
  this._renderer = gl.getParameter(debugRenderInfo.UNMASKED_RENDERER_WEBGL);
2155
2410
  }
2411
+ if (this._isWebGL2) {
2412
+ this.maxUniformBlockSize = gl.getParameter(gl.MAX_UNIFORM_BLOCK_SIZE);
2413
+ }
2156
2414
  };
2157
2415
  _proto.destroy = function destroy() {
2158
2416
  var webCanvas = this._webCanvas;