@galacean/engine-rhi-webgl 2.0.0-alpha.44 → 2.0.0-alpha.45
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 +16 -27
- package/dist/main.js.map +1 -1
- package/dist/module.js +16 -27
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/GLBuffer.d.ts +2 -0
- package/types/GLPrimitive.d.ts +33 -1
- package/types/GLTexture.d.ts +38 -1
- package/types/GLTransformFeedback.d.ts +18 -1
- package/types/GLTransformFeedbackPrimitive.d.ts +22 -1
- package/types/WebCanvas.d.ts +12 -0
- package/types/WebGLGraphicDevice.d.ts +26 -2
package/dist/module.js
CHANGED
|
@@ -244,7 +244,6 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
244
244
|
var webGLGraphicDevice = new WebGLGraphicDevice(configuration.graphicDeviceOptions);
|
|
245
245
|
var engine = new WebGLEngine(webCanvas, webGLGraphicDevice, configuration);
|
|
246
246
|
webCanvas.setAutoResolution();
|
|
247
|
-
// @ts-ignore
|
|
248
247
|
var promise = engine._initialize(configuration);
|
|
249
248
|
return promise.then(function() {
|
|
250
249
|
engine.sceneManager.addScene(new Scene(engine, "DefaultScene"));
|
|
@@ -257,7 +256,6 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
257
256
|
get: /**
|
|
258
257
|
* The web canvas the engine renders to.
|
|
259
258
|
*/ function get() {
|
|
260
|
-
// @ts-ignore
|
|
261
259
|
return this._canvas;
|
|
262
260
|
}
|
|
263
261
|
}
|
|
@@ -838,7 +836,6 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
838
836
|
* Generate multi-level textures based on the 0th level data.
|
|
839
837
|
*/ _proto.generateMipmaps = function generateMipmaps() {
|
|
840
838
|
var texture = this._texture;
|
|
841
|
-
//@ts-ignore
|
|
842
839
|
var mipmap = texture._mipmap;
|
|
843
840
|
if (!TextureUtils.supportGenerateMipmaps(texture.format, mipmap, texture.isSRGBColorSpace, this._isWebGL2)) {
|
|
844
841
|
Logger.warn("Auto-generating mipmaps for sRGB textures is only supported in [WebGL2 + R8G8B8A8], you must generate mipmaps manually.");
|
|
@@ -859,7 +856,6 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
859
856
|
var gl = this._gl;
|
|
860
857
|
var isWebGL2 = this._isWebGL2;
|
|
861
858
|
var _this__formatDetail = this._formatDetail, internalFormat = _this__formatDetail.internalFormat, baseFormat = _this__formatDetail.baseFormat, dataType = _this__formatDetail.dataType;
|
|
862
|
-
// @ts-ignore
|
|
863
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;
|
|
864
860
|
this._bind();
|
|
865
861
|
if (isWebGL2 && !(baseFormat === gl.LUMINANCE_ALPHA || baseFormat === gl.ALPHA) && usage !== TextureUsage.Dynamic) {
|
|
@@ -931,11 +927,10 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
931
927
|
}
|
|
932
928
|
var isWebGL2 = rhi.isWebGL2;
|
|
933
929
|
// Validate mipmap
|
|
934
|
-
// @ts-ignore
|
|
935
930
|
var mipmap = texture._mipmap;
|
|
936
931
|
if (mipmap && !TextureUtils.supportMipmaps(width, height, isWebGL2)) {
|
|
937
932
|
Logger.warn("Non-power-2 texture is not supported for mipmap in WebGL1, and has automatically downgraded to non-mipmap");
|
|
938
|
-
|
|
933
|
+
texture._mipmap = false;
|
|
939
934
|
/** @ts-ignore */ texture._mipmapCount = texture._getMipmapCount();
|
|
940
935
|
}
|
|
941
936
|
};
|
|
@@ -1368,7 +1363,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1368
1363
|
*/ function set(value) {
|
|
1369
1364
|
var gl = this._gl;
|
|
1370
1365
|
var target = this._target;
|
|
1371
|
-
|
|
1366
|
+
var _mipmap = this._texture._mipmap;
|
|
1372
1367
|
this._bind();
|
|
1373
1368
|
switch(value){
|
|
1374
1369
|
case TextureFilterMode.Point:
|
|
@@ -1501,15 +1496,13 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1501
1496
|
if (colorTexture) {
|
|
1502
1497
|
var isCube = _instanceof(colorTexture, TextureCube);
|
|
1503
1498
|
if (mipChanged || isCube && faceChanged) {
|
|
1504
|
-
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, isCube ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D,
|
|
1505
|
-
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);
|
|
1506
1500
|
}
|
|
1507
1501
|
}
|
|
1508
1502
|
var depthTexture = target.depthTexture;
|
|
1509
1503
|
if (depthTexture) {
|
|
1510
1504
|
var isCube1 = _instanceof(depthTexture, TextureCube);
|
|
1511
1505
|
if (mipChanged || isCube1) {
|
|
1512
|
-
// @ts-ignore
|
|
1513
1506
|
var platformTexture = depthTexture._platformTexture;
|
|
1514
1507
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, platformTexture._formatDetail.attachment, isCube1 ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D, platformTexture._glTexture, mipLevel);
|
|
1515
1508
|
}
|
|
@@ -1566,7 +1559,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1566
1559
|
_proto._bindMainFBO = function _bindMainFBO() {
|
|
1567
1560
|
var gl = this._gl;
|
|
1568
1561
|
var isWebGL2 = this._isWebGL2;
|
|
1569
|
-
|
|
1562
|
+
var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount; _this__target.width; _this__target.height;
|
|
1570
1563
|
var drawBuffers = new Array(colorTextureCount);
|
|
1571
1564
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
1572
1565
|
/** color render buffer */ for(var i = 0; i < colorTextureCount; i++){
|
|
@@ -1574,7 +1567,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1574
1567
|
var attachment = gl.COLOR_ATTACHMENT0 + i;
|
|
1575
1568
|
drawBuffers[i] = attachment;
|
|
1576
1569
|
if (!_instanceof(colorTexture, TextureCube)) {
|
|
1577
|
-
gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D,
|
|
1570
|
+
gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, colorTexture._platformTexture._glTexture, 0);
|
|
1578
1571
|
}
|
|
1579
1572
|
}
|
|
1580
1573
|
if (colorTextureCount > 1) {
|
|
@@ -1582,10 +1575,11 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1582
1575
|
}
|
|
1583
1576
|
this._oriDrawBuffers = drawBuffers;
|
|
1584
1577
|
/** depth render buffer */ if (_depth !== null) {
|
|
1585
|
-
if (_instanceof(_depth, Texture)
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
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
|
+
}
|
|
1589
1583
|
} else if (this._target.antiAliasing <= 1) {
|
|
1590
1584
|
var _GLTexture__getRenderBufferDepthFormatDetail = GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2), internalFormat = _GLTexture__getRenderBufferDepthFormatDetail.internalFormat, attachment1 = _GLTexture__getRenderBufferDepthFormatDetail.attachment;
|
|
1591
1585
|
this._depthRenderBuffer = this._createRenderBuffer(internalFormat, attachment1);
|
|
@@ -1597,19 +1591,19 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1597
1591
|
_proto._bindMSAAFBO = function _bindMSAAFBO() {
|
|
1598
1592
|
var gl = this._gl;
|
|
1599
1593
|
var isWebGL2 = this._isWebGL2;
|
|
1600
|
-
|
|
1594
|
+
var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount;
|
|
1601
1595
|
this._blitDrawBuffers = new Array(colorTextureCount);
|
|
1602
1596
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._MSAAFrameBuffer);
|
|
1603
1597
|
// prepare MRT+MSAA color RBOs
|
|
1604
1598
|
for(var i = 0; i < colorTextureCount; i++){
|
|
1605
1599
|
this._blitDrawBuffers[i] = gl.NONE;
|
|
1606
|
-
var internalFormat =
|
|
1600
|
+
var internalFormat = this._target.getColorTexture(i)._platformTexture._formatDetail.internalFormat;
|
|
1607
1601
|
this._MSAAColorRenderBuffers[i] = this._createRenderBuffer(internalFormat, gl.COLOR_ATTACHMENT0 + i);
|
|
1608
1602
|
}
|
|
1609
1603
|
gl.drawBuffers(this._oriDrawBuffers);
|
|
1610
1604
|
// prepare MSAA depth RBO
|
|
1611
1605
|
if (_depth !== null) {
|
|
1612
|
-
var _ref = _instanceof(_depth, Texture) ?
|
|
1606
|
+
var _ref = _instanceof(_depth, Texture) ? _depth._platformTexture._formatDetail : GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2), internalFormat1 = _ref.internalFormat, attachment = _ref.attachment;
|
|
1613
1607
|
this._MSAADepthRenderBuffer = this._createRenderBuffer(internalFormat1, attachment);
|
|
1614
1608
|
}
|
|
1615
1609
|
this._checkFrameBuffer();
|
|
@@ -1992,10 +1986,8 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
|
1992
1986
|
var gl = this._gl;
|
|
1993
1987
|
var vao = gl.createVertexArray();
|
|
1994
1988
|
gl.bindVertexArray(vao);
|
|
1995
|
-
// @ts-ignore: Access internal _platformBuffer across packages
|
|
1996
1989
|
gl.bindBuffer(gl.ARRAY_BUFFER, feedbackBinding.buffer._platformBuffer._glBuffer);
|
|
1997
1990
|
this._bindElements(gl, attribs, feedbackElements, feedbackBinding.stride);
|
|
1998
|
-
// @ts-ignore: Access internal _platformBuffer across packages
|
|
1999
1991
|
gl.bindBuffer(gl.ARRAY_BUFFER, inputBinding.buffer._platformBuffer._glBuffer);
|
|
2000
1992
|
this._bindElements(gl, attribs, inputElements, inputBinding.stride);
|
|
2001
1993
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
@@ -2267,8 +2259,8 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
|
2267
2259
|
_proto.activeRenderTarget = function activeRenderTarget(renderTarget, viewport, isFlipProjection, mipLevel, faceIndex) {
|
|
2268
2260
|
var bufferWidth, bufferHeight;
|
|
2269
2261
|
if (renderTarget) {
|
|
2270
|
-
|
|
2271
|
-
|
|
2262
|
+
renderTarget._isContentLost = false;
|
|
2263
|
+
var platformRenderTarget = renderTarget._platformRenderTarget;
|
|
2272
2264
|
platformRenderTarget.activeRenderTarget(mipLevel, faceIndex);
|
|
2273
2265
|
bufferWidth = renderTarget.width >> mipLevel;
|
|
2274
2266
|
bufferHeight = renderTarget.height >> mipLevel;
|
|
@@ -2309,7 +2301,6 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
|
2309
2301
|
gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, destFrameBuffer);
|
|
2310
2302
|
var blitMask = needBlitColor ? gl.COLOR_BUFFER_BIT : 0;
|
|
2311
2303
|
if (needBlitDepth || needBlitStencil) {
|
|
2312
|
-
// @ts-ignore
|
|
2313
2304
|
var depthFormat = destRT._depthFormat;
|
|
2314
2305
|
if (needBlitDepth) {
|
|
2315
2306
|
if (depthFormat === TextureFormat.Depth || depthFormat >= TextureFormat.DepthStencil && depthFormat <= TextureFormat.Depth32Stencil8) {
|
|
@@ -2346,11 +2337,9 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
|
2346
2337
|
var _srcRT__platformRenderTarget__frameBuffer;
|
|
2347
2338
|
// @ts-ignore
|
|
2348
2339
|
var frameBuffer = (_srcRT__platformRenderTarget__frameBuffer = srcRT == null ? void 0 : srcRT._platformRenderTarget._frameBuffer) != null ? _srcRT__platformRenderTarget__frameBuffer : this._mainFrameBuffer;
|
|
2349
|
-
// @ts-ignore
|
|
2350
2340
|
gl.bindFramebuffer(gl.FRAMEBUFFER, frameBuffer);
|
|
2351
|
-
// @ts-ignore
|
|
2352
2341
|
var glTexture = grabTexture._platformTexture;
|
|
2353
|
-
|
|
2342
|
+
this.bindTexture(glTexture);
|
|
2354
2343
|
gl.copyTexSubImage2D(glTexture._target, 0, 0, 0, xStart, yStart, copyWidth, copyHeight);
|
|
2355
2344
|
};
|
|
2356
2345
|
_proto.activeTexture = function activeTexture(textureID) {
|