@galacean/engine-rhi-webgl 1.0.0-beta.10 → 1.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -778,9 +778,9 @@ var GLBuffer = /*#__PURE__*/ function() {
778
778
  var isWebGL2 = this._isWebGL2;
779
779
  var _this__formatDetail = this._formatDetail, internalFormat = _this__formatDetail.internalFormat, baseFormat = _this__formatDetail.baseFormat, dataType = _this__formatDetail.dataType;
780
780
  // @ts-ignore
781
- var _this__texture = this._texture, mipmapCount = _this__texture.mipmapCount, width = _this__texture.width, height = _this__texture.height, _isDepthTexture = _this__texture._isDepthTexture;
781
+ 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;
782
782
  this._bind();
783
- if (isWebGL2 && !(baseFormat === gl.LUMINANCE_ALPHA || baseFormat === gl.ALPHA)) {
783
+ if (isWebGL2 && !(baseFormat === gl.LUMINANCE_ALPHA || baseFormat === gl.ALPHA) && usage !== engineCore.TextureUsage.Dynamic) {
784
784
  gl.texStorage2D(this._target, mipmapCount, internalFormat, width, height);
785
785
  } else {
786
786
  if (!isCube) {
@@ -1575,11 +1575,15 @@ var GLBuffer = /*#__PURE__*/ function() {
1575
1575
  * {@inheritDoc IPlatformTexture2D.setImageSource}
1576
1576
  */ _proto.setImageSource = function setImageSource(imageSource, mipLevel, flipY, premultiplyAlpha, x, y) {
1577
1577
  var gl = this._gl;
1578
- var _this__formatDetail = this._formatDetail, baseFormat = _this__formatDetail.baseFormat, dataType = _this__formatDetail.dataType;
1578
+ var _this__formatDetail = this._formatDetail, internalFormat = _this__formatDetail.internalFormat, baseFormat = _this__formatDetail.baseFormat, dataType = _this__formatDetail.dataType;
1579
1579
  this._bind();
1580
1580
  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, +flipY);
1581
1581
  gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, +premultiplyAlpha);
1582
- gl.texSubImage2D(this._target, mipLevel, x || 0, y || 0, baseFormat, dataType, imageSource);
1582
+ if (this._texture.usage === engineCore.TextureUsage.Dynamic) {
1583
+ gl.texImage2D(this._target, mipLevel, internalFormat, baseFormat, dataType, imageSource);
1584
+ } else {
1585
+ gl.texSubImage2D(this._target, mipLevel, x || 0, y || 0, baseFormat, dataType, imageSource);
1586
+ }
1583
1587
  };
1584
1588
  /**
1585
1589
  * {@inheritDoc IPlatformTexture2D.getPixelBuffer }