@galacean/engine-rhi-webgl 1.1.0-alpha.0 → 1.1.0-alpha.1

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
@@ -61,6 +61,11 @@ var engineCore = require('@galacean/engine-core');
61
61
  GLCompressedTextureInternalFormat[GLCompressedTextureInternalFormat["RGBA_S3TC_DXT1_EXT"] = 0x83f1] = "RGBA_S3TC_DXT1_EXT";
62
62
  GLCompressedTextureInternalFormat[GLCompressedTextureInternalFormat["RGBA_S3TC_DXT3_EXT"] = 0x83f2] = "RGBA_S3TC_DXT3_EXT";
63
63
  GLCompressedTextureInternalFormat[GLCompressedTextureInternalFormat["RGBA_S3TC_DXT5_EXT"] = 0x83f3] = "RGBA_S3TC_DXT5_EXT";
64
+ GLCompressedTextureInternalFormat[GLCompressedTextureInternalFormat[// bptc
65
+ "RGBA_BPTC_UNORM_EXT"] = 0x8e8c] = "RGBA_BPTC_UNORM_EXT";
66
+ GLCompressedTextureInternalFormat[GLCompressedTextureInternalFormat["SRGB_ALPHA_BPTC_UNORM_EXT"] = 0x8e8d] = "SRGB_ALPHA_BPTC_UNORM_EXT";
67
+ GLCompressedTextureInternalFormat[GLCompressedTextureInternalFormat["RGB_BPTC_SIGNED_FLOAT_EXT"] = 0x8e8e] = "RGB_BPTC_SIGNED_FLOAT_EXT";
68
+ GLCompressedTextureInternalFormat[GLCompressedTextureInternalFormat["RGB_BPTC_UNSIGNED_FLOAT_EXT"] = 0x8e8f] = "RGB_BPTC_UNSIGNED_FLOAT_EXT";
64
69
  })(exports.GLCompressedTextureInternalFormat || (exports.GLCompressedTextureInternalFormat = {}));
65
70
 
66
71
  function _defineProperties(target, props) {
@@ -297,10 +302,6 @@ var GLBuffer = /*#__PURE__*/ function() {
297
302
  throw "Buffer is write-only on WebGL1.0 platforms.";
298
303
  }
299
304
  };
300
- _proto.resize = function resize(byteLength) {
301
- this.bind();
302
- this._gl.bufferData(this._glBindTarget, byteLength, this._glBufferUsage);
303
- };
304
305
  _proto.destroy = function destroy() {
305
306
  this._gl.deleteBuffer(this._glBuffer);
306
307
  this._gl = null;
@@ -342,7 +343,8 @@ var GLBuffer = /*#__PURE__*/ function() {
342
343
  RGB_ETC1_WEBGL = exports.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL, // etc
343
344
  R11_EAC = exports.GLCompressedTextureInternalFormat.R11_EAC, SRGB8_ALPHA8_ETC2_EAC = exports.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ETC2_EAC, // pvrtc
344
345
  RGB_PVRTC_4BPPV1_IMG = exports.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG, RGBA_PVRTC_2BPPV1_IMG = exports.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG, // s3tc
345
- RGB_S3TC_DXT1_EXT = exports.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT, RGBA_S3TC_DXT5_EXT = exports.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT;
346
+ RGB_S3TC_DXT1_EXT = exports.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT, RGBA_S3TC_DXT5_EXT = exports.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT, // bptc
347
+ RGBA_BPTC_UNORM_EXT = exports.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT, RGB_BPTC_UNSIGNED_FLOAT_EXT = exports.GLCompressedTextureInternalFormat.RGB_BPTC_UNSIGNED_FLOAT_EXT;
346
348
  if (internalType >= RGBA_ASTC_4X4_KHR && RGBA_ASTC_12X12_KHR <= RGBA_ASTC_12X12_KHR || internalType >= SRGB8_ALPHA8_ASTC_4X4_KHR && internalType <= SRGB8_ALPHA8_ASTC_12X12_KHR) {
347
349
  return this.canIUse(engineCore.GLCapabilityType.astc);
348
350
  } else if (internalType === RGB_ETC1_WEBGL) {
@@ -353,6 +355,8 @@ var GLBuffer = /*#__PURE__*/ function() {
353
355
  return this.canIUse(engineCore.GLCapabilityType.pvrtc);
354
356
  } else if (internalType >= RGB_S3TC_DXT1_EXT && internalType <= RGBA_S3TC_DXT5_EXT) {
355
357
  return this.canIUse(engineCore.GLCapabilityType.s3tc);
358
+ } else if (internalType >= RGBA_BPTC_UNORM_EXT && internalType <= RGB_BPTC_UNSIGNED_FLOAT_EXT) {
359
+ return this.canIUse(engineCore.GLCapabilityType.bptc);
356
360
  }
357
361
  return false;
358
362
  };
@@ -362,7 +366,7 @@ var GLBuffer = /*#__PURE__*/ function() {
362
366
  var cap = this.capabilityList;
363
367
  var isWebGL2 = this.rhi.isWebGL2;
364
368
  var requireExtension = this.rhi.requireExtension.bind(this.rhi);
365
- var shaderVertexID = engineCore.GLCapabilityType.shaderVertexID, standardDerivatives = engineCore.GLCapabilityType.standardDerivatives, shaderTextureLod = engineCore.GLCapabilityType.shaderTextureLod, elementIndexUint = engineCore.GLCapabilityType.elementIndexUint, depthTexture = engineCore.GLCapabilityType.depthTexture, vertexArrayObject = engineCore.GLCapabilityType.vertexArrayObject, instancedArrays = engineCore.GLCapabilityType.instancedArrays, multipleSample = engineCore.GLCapabilityType.multipleSample, drawBuffers = engineCore.GLCapabilityType.drawBuffers, astc = engineCore.GLCapabilityType.astc, astc_webkit = engineCore.GLCapabilityType.astc_webkit, etc = engineCore.GLCapabilityType.etc, etc_webkit = engineCore.GLCapabilityType.etc_webkit, etc1 = engineCore.GLCapabilityType.etc1, etc1_webkit = engineCore.GLCapabilityType.etc1_webkit, pvrtc = engineCore.GLCapabilityType.pvrtc, pvrtc_webkit = engineCore.GLCapabilityType.pvrtc_webkit, s3tc = engineCore.GLCapabilityType.s3tc, s3tc_webkit = engineCore.GLCapabilityType.s3tc_webkit, textureFloat = engineCore.GLCapabilityType.textureFloat, textureHalfFloat = engineCore.GLCapabilityType.textureHalfFloat, textureFloatLinear = engineCore.GLCapabilityType.textureFloatLinear, textureHalfFloatLinear = engineCore.GLCapabilityType.textureHalfFloatLinear, WEBGL_colorBufferFloat = engineCore.GLCapabilityType.WEBGL_colorBufferFloat, colorBufferFloat = engineCore.GLCapabilityType.colorBufferFloat, colorBufferHalfFloat = engineCore.GLCapabilityType.colorBufferHalfFloat, textureFilterAnisotropic = engineCore.GLCapabilityType.textureFilterAnisotropic;
369
+ var shaderVertexID = engineCore.GLCapabilityType.shaderVertexID, standardDerivatives = engineCore.GLCapabilityType.standardDerivatives, shaderTextureLod = engineCore.GLCapabilityType.shaderTextureLod, elementIndexUint = engineCore.GLCapabilityType.elementIndexUint, depthTexture = engineCore.GLCapabilityType.depthTexture, vertexArrayObject = engineCore.GLCapabilityType.vertexArrayObject, instancedArrays = engineCore.GLCapabilityType.instancedArrays, multipleSample = engineCore.GLCapabilityType.multipleSample, drawBuffers = engineCore.GLCapabilityType.drawBuffers, astc = engineCore.GLCapabilityType.astc, astc_webkit = engineCore.GLCapabilityType.astc_webkit, etc = engineCore.GLCapabilityType.etc, etc_webkit = engineCore.GLCapabilityType.etc_webkit, etc1 = engineCore.GLCapabilityType.etc1, etc1_webkit = engineCore.GLCapabilityType.etc1_webkit, pvrtc = engineCore.GLCapabilityType.pvrtc, pvrtc_webkit = engineCore.GLCapabilityType.pvrtc_webkit, s3tc = engineCore.GLCapabilityType.s3tc, s3tc_webkit = engineCore.GLCapabilityType.s3tc_webkit, bptc = engineCore.GLCapabilityType.bptc, textureFloat = engineCore.GLCapabilityType.textureFloat, textureHalfFloat = engineCore.GLCapabilityType.textureHalfFloat, textureFloatLinear = engineCore.GLCapabilityType.textureFloatLinear, textureHalfFloatLinear = engineCore.GLCapabilityType.textureHalfFloatLinear, WEBGL_colorBufferFloat = engineCore.GLCapabilityType.WEBGL_colorBufferFloat, colorBufferFloat = engineCore.GLCapabilityType.colorBufferFloat, colorBufferHalfFloat = engineCore.GLCapabilityType.colorBufferHalfFloat, textureFilterAnisotropic = engineCore.GLCapabilityType.textureFilterAnisotropic;
366
370
  cap.set(shaderVertexID, isWebGL2);
367
371
  cap.set(standardDerivatives, isWebGL2 || !!requireExtension(standardDerivatives));
368
372
  cap.set(shaderTextureLod, isWebGL2 || !!requireExtension(shaderTextureLod));
@@ -384,6 +388,7 @@ var GLBuffer = /*#__PURE__*/ function() {
384
388
  cap.set(etc1, !!(requireExtension(etc1) || requireExtension(etc1_webkit)));
385
389
  cap.set(pvrtc, !!(requireExtension(pvrtc) || requireExtension(pvrtc_webkit)));
386
390
  cap.set(s3tc, !!(requireExtension(s3tc) || requireExtension(s3tc_webkit)));
391
+ cap.set(bptc, !!requireExtension(bptc));
387
392
  };
388
393
  /**
389
394
  * If there are extensions that can supplement this ability, smooth out the difference.
@@ -650,7 +655,7 @@ var GLBuffer = /*#__PURE__*/ function() {
650
655
  gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
651
656
  }
652
657
  gl.enableVertexAttribArray(loc);
653
- var elementInfo = element._glElementInfo;
658
+ var elementInfo = element._formatMetaInfo;
654
659
  gl.vertexAttribPointer(loc, elementInfo.size, elementInfo.type, elementInfo.normalized, stride, element.offset);
655
660
  if (this._canUseInstancedArrays) {
656
661
  gl.vertexAttribDivisor(loc, element.instanceStepRate);
@@ -782,9 +787,9 @@ var GLBuffer = /*#__PURE__*/ function() {
782
787
  var isWebGL2 = this._isWebGL2;
783
788
  var _this__formatDetail = this._formatDetail, internalFormat = _this__formatDetail.internalFormat, baseFormat = _this__formatDetail.baseFormat, dataType = _this__formatDetail.dataType;
784
789
  // @ts-ignore
785
- var _this__texture = this._texture, mipmapCount = _this__texture.mipmapCount, width = _this__texture.width, height = _this__texture.height, _isDepthTexture = _this__texture._isDepthTexture;
790
+ 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;
786
791
  this._bind();
787
- if (isWebGL2 && !(baseFormat === gl.LUMINANCE_ALPHA || baseFormat === gl.ALPHA)) {
792
+ if (isWebGL2 && !(baseFormat === gl.LUMINANCE_ALPHA || baseFormat === gl.ALPHA) && usage !== engineCore.TextureUsage.Dynamic) {
788
793
  gl.texStorage2D(this._target, mipmapCount, internalFormat, width, height);
789
794
  } else {
790
795
  if (!isCube) {
@@ -931,16 +936,21 @@ var GLBuffer = /*#__PURE__*/ function() {
931
936
  dataType: gl.FLOAT,
932
937
  isCompressed: false
933
938
  };
934
- case engineCore.TextureFormat.DXT1:
939
+ case engineCore.TextureFormat.BC1:
935
940
  return {
936
941
  internalFormat: exports.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,
937
942
  isCompressed: true
938
943
  };
939
- case engineCore.TextureFormat.DXT5:
944
+ case engineCore.TextureFormat.BC3:
940
945
  return {
941
946
  internalFormat: exports.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT,
942
947
  isCompressed: true
943
948
  };
949
+ case engineCore.TextureFormat.BC7:
950
+ return {
951
+ internalFormat: exports.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT,
952
+ isCompressed: true
953
+ };
944
954
  case engineCore.TextureFormat.ETC1_RGB:
945
955
  return {
946
956
  internalFormat: exports.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL,
@@ -1579,11 +1589,15 @@ var GLBuffer = /*#__PURE__*/ function() {
1579
1589
  * {@inheritDoc IPlatformTexture2D.setImageSource}
1580
1590
  */ _proto.setImageSource = function setImageSource(imageSource, mipLevel, flipY, premultiplyAlpha, x, y) {
1581
1591
  var gl = this._gl;
1582
- var _this__formatDetail = this._formatDetail, baseFormat = _this__formatDetail.baseFormat, dataType = _this__formatDetail.dataType;
1592
+ var _this__formatDetail = this._formatDetail, internalFormat = _this__formatDetail.internalFormat, baseFormat = _this__formatDetail.baseFormat, dataType = _this__formatDetail.dataType;
1583
1593
  this._bind();
1584
1594
  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, +flipY);
1585
1595
  gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, +premultiplyAlpha);
1586
- gl.texSubImage2D(this._target, mipLevel, x || 0, y || 0, baseFormat, dataType, imageSource);
1596
+ if (this._texture.usage === engineCore.TextureUsage.Dynamic) {
1597
+ gl.texImage2D(this._target, mipLevel, internalFormat, baseFormat, dataType, imageSource);
1598
+ } else {
1599
+ gl.texSubImage2D(this._target, mipLevel, x || 0, y || 0, baseFormat, dataType, imageSource);
1600
+ }
1587
1601
  };
1588
1602
  /**
1589
1603
  * {@inheritDoc IPlatformTexture2D.getPixelBuffer }
@@ -1641,7 +1655,8 @@ var GLBuffer = /*#__PURE__*/ function() {
1641
1655
  this._bind();
1642
1656
  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, +flipY);
1643
1657
  gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, +premultiplyAlpha);
1644
- gl.texSubImage3D(this._target, mipLevel, x, y, elementIndex, imageSource.width, imageSource.height, 1, baseFormat, dataType, imageSource);
1658
+ var _imageSource_width, _imageSource_height;
1659
+ gl.texSubImage3D(this._target, mipLevel, x, y, elementIndex, (_imageSource_width = imageSource.width) != null ? _imageSource_width : imageSource.codedWidth, (_imageSource_height = imageSource.height) != null ? _imageSource_height : imageSource.codedHeight, 1, baseFormat, dataType, imageSource);
1645
1660
  };
1646
1661
  /**
1647
1662
  * {@inheritDoc IPlatformTexture2DArray.getPixelBuffer}
@@ -1754,7 +1769,8 @@ exports.WebGLMode = void 0;
1754
1769
  var options = _extends({
1755
1770
  webGLMode: 0,
1756
1771
  stencil: true,
1757
- _forceFlush: false
1772
+ _forceFlush: false,
1773
+ _maxAllowSkinUniformVectorCount: 256
1758
1774
  }, initializeOptions);
1759
1775
  if (engineCore.SystemInfo.platform === engineCore.Platform.IPhone || engineCore.SystemInfo.platform === engineCore.Platform.IPad) {
1760
1776
  var version = engineCore.SystemInfo.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);