@galacean/engine-rhi-webgl 0.0.0-experimental-renderSort.4 → 0.0.0-experimental-stateMachine.0
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/LICENSE +2 -2
- package/dist/main.js +99 -100
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +99 -100
- package/dist/module.js +99 -100
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/GLRenderTarget.d.ts +3 -2
- package/types/WebCanvas.d.ts +3 -13
- package/types/WebGLGraphicDevice.d.ts +5 -3
package/dist/module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Canvas, Scene, Engine, BufferUsage, BufferBindFlag, SetDataOptions, GLCapabilityType, Logger, TextureUsage, TextureWrapMode, TextureFormat, TextureFilterMode, TextureDepthCompareFunction, Texture, TextureCube, CameraClearFlags, ColorWriteMask, SystemInfo, Platform } from '@galacean/engine-core';
|
|
1
2
|
import { Vector2, Vector4, Color } from '@galacean/engine-math';
|
|
2
|
-
import { Scene, Engine, BufferUsage, BufferBindFlag, SetDataOptions, GLCapabilityType, Logger, TextureUsage, TextureWrapMode, TextureFormat, RenderBufferDepthFormat, TextureFilterMode, TextureDepthCompareFunction, Texture, TextureCube, CameraClearFlags, ColorWriteMask, SystemInfo, Platform } from '@galacean/engine-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Smoothing plug-in.
|
|
@@ -82,6 +82,26 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
82
82
|
return Constructor;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
function _set_prototype_of(o, p) {
|
|
86
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
87
|
+
o.__proto__ = p;
|
|
88
|
+
|
|
89
|
+
return o;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return _set_prototype_of(o, p);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _inherits(subClass, superClass) {
|
|
96
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
97
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
101
|
+
|
|
102
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
103
|
+
}
|
|
104
|
+
|
|
85
105
|
function _instanceof(left, right) {
|
|
86
106
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
87
107
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -90,14 +110,18 @@ function _instanceof(left, right) {
|
|
|
90
110
|
|
|
91
111
|
/**
|
|
92
112
|
* The canvas used on the web, which can support HTMLCanvasElement and OffscreenCanvas.
|
|
93
|
-
*/ var WebCanvas = /*#__PURE__*/ function() {
|
|
113
|
+
*/ var WebCanvas = /*#__PURE__*/ function(Canvas1) {
|
|
114
|
+
_inherits(WebCanvas, Canvas1);
|
|
94
115
|
function WebCanvas(webCanvas) {
|
|
95
|
-
|
|
116
|
+
var _this;
|
|
117
|
+
_this = Canvas1.call(this) || this;
|
|
118
|
+
_this._scale = new Vector2();
|
|
96
119
|
var width = webCanvas.width;
|
|
97
120
|
var height = webCanvas.height;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
121
|
+
_this._webCanvas = webCanvas;
|
|
122
|
+
_this.width = width;
|
|
123
|
+
_this.height = height;
|
|
124
|
+
return _this;
|
|
101
125
|
}
|
|
102
126
|
var _proto = WebCanvas.prototype;
|
|
103
127
|
/**
|
|
@@ -107,8 +131,10 @@ function _instanceof(left, right) {
|
|
|
107
131
|
if (pixelRatio === void 0) pixelRatio = window.devicePixelRatio;
|
|
108
132
|
var webCanvas = this._webCanvas;
|
|
109
133
|
if (typeof OffscreenCanvas === "undefined" || !_instanceof(webCanvas, OffscreenCanvas)) {
|
|
110
|
-
|
|
111
|
-
|
|
134
|
+
var exportWidth = webCanvas.clientWidth * pixelRatio;
|
|
135
|
+
var exportHeight = webCanvas.clientHeight * pixelRatio;
|
|
136
|
+
this.width = exportWidth;
|
|
137
|
+
this.height = exportHeight;
|
|
112
138
|
}
|
|
113
139
|
};
|
|
114
140
|
/**
|
|
@@ -119,35 +145,13 @@ function _instanceof(left, right) {
|
|
|
119
145
|
this._scale.set(x, y);
|
|
120
146
|
this.scale = this._scale;
|
|
121
147
|
};
|
|
148
|
+
_proto._onWidthChanged = function _onWidthChanged(value) {
|
|
149
|
+
this._webCanvas.width = value;
|
|
150
|
+
};
|
|
151
|
+
_proto._onHeightChange = function _onHeightChange(value) {
|
|
152
|
+
this._webCanvas.height = value;
|
|
153
|
+
};
|
|
122
154
|
_create_class(WebCanvas, [
|
|
123
|
-
{
|
|
124
|
-
key: "width",
|
|
125
|
-
get: /**
|
|
126
|
-
* @inheritdoc
|
|
127
|
-
*/ function get() {
|
|
128
|
-
return this._width;
|
|
129
|
-
},
|
|
130
|
-
set: function set(value) {
|
|
131
|
-
if (this._width !== value) {
|
|
132
|
-
this._webCanvas.width = value;
|
|
133
|
-
this._width = value;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
key: "height",
|
|
139
|
-
get: /**
|
|
140
|
-
* @inheritdoc
|
|
141
|
-
*/ function get() {
|
|
142
|
-
return this._height;
|
|
143
|
-
},
|
|
144
|
-
set: function set(value) {
|
|
145
|
-
if (this._height !== value) {
|
|
146
|
-
this._webCanvas.height = value;
|
|
147
|
-
this._height = value;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
155
|
{
|
|
152
156
|
key: "scale",
|
|
153
157
|
get: /**
|
|
@@ -170,27 +174,7 @@ function _instanceof(left, right) {
|
|
|
170
174
|
}
|
|
171
175
|
]);
|
|
172
176
|
return WebCanvas;
|
|
173
|
-
}();
|
|
174
|
-
|
|
175
|
-
function _set_prototype_of(o, p) {
|
|
176
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
177
|
-
o.__proto__ = p;
|
|
178
|
-
|
|
179
|
-
return o;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
return _set_prototype_of(o, p);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function _inherits(subClass, superClass) {
|
|
186
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
187
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
191
|
-
|
|
192
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
193
|
-
}
|
|
177
|
+
}(Canvas);
|
|
194
178
|
|
|
195
179
|
/**
|
|
196
180
|
* WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
|
|
@@ -362,7 +346,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
362
346
|
var cap = this.capabilityList;
|
|
363
347
|
var isWebGL2 = this.rhi.isWebGL2;
|
|
364
348
|
var requireExtension = this.rhi.requireExtension.bind(this.rhi);
|
|
365
|
-
var shaderVertexID = GLCapabilityType.shaderVertexID, standardDerivatives = GLCapabilityType.standardDerivatives, shaderTextureLod = GLCapabilityType.shaderTextureLod, elementIndexUint = GLCapabilityType.elementIndexUint, depthTexture = GLCapabilityType.depthTexture, vertexArrayObject = GLCapabilityType.vertexArrayObject, instancedArrays = GLCapabilityType.instancedArrays, multipleSample = GLCapabilityType.multipleSample, drawBuffers = GLCapabilityType.drawBuffers, astc = GLCapabilityType.astc, astc_webkit = GLCapabilityType.astc_webkit, etc = GLCapabilityType.etc, etc_webkit = GLCapabilityType.etc_webkit, etc1 = GLCapabilityType.etc1, etc1_webkit = GLCapabilityType.etc1_webkit, pvrtc = GLCapabilityType.pvrtc, pvrtc_webkit = GLCapabilityType.pvrtc_webkit, s3tc = GLCapabilityType.s3tc, s3tc_webkit = GLCapabilityType.s3tc_webkit, bptc = GLCapabilityType.bptc, textureFloat = GLCapabilityType.textureFloat, textureHalfFloat = GLCapabilityType.textureHalfFloat, textureFloatLinear = GLCapabilityType.textureFloatLinear, textureHalfFloatLinear = GLCapabilityType.textureHalfFloatLinear, WEBGL_colorBufferFloat = GLCapabilityType.WEBGL_colorBufferFloat, colorBufferFloat = GLCapabilityType.colorBufferFloat, colorBufferHalfFloat = GLCapabilityType.colorBufferHalfFloat, textureFilterAnisotropic = GLCapabilityType.textureFilterAnisotropic;
|
|
349
|
+
var shaderVertexID = GLCapabilityType.shaderVertexID, standardDerivatives = GLCapabilityType.standardDerivatives, shaderTextureLod = GLCapabilityType.shaderTextureLod, elementIndexUint = GLCapabilityType.elementIndexUint, depthTexture = GLCapabilityType.depthTexture, vertexArrayObject = GLCapabilityType.vertexArrayObject, instancedArrays = GLCapabilityType.instancedArrays, multipleSample = GLCapabilityType.multipleSample, drawBuffers = GLCapabilityType.drawBuffers, blendMinMax = GLCapabilityType.blendMinMax, astc = GLCapabilityType.astc, astc_webkit = GLCapabilityType.astc_webkit, etc = GLCapabilityType.etc, etc_webkit = GLCapabilityType.etc_webkit, etc1 = GLCapabilityType.etc1, etc1_webkit = GLCapabilityType.etc1_webkit, pvrtc = GLCapabilityType.pvrtc, pvrtc_webkit = GLCapabilityType.pvrtc_webkit, s3tc = GLCapabilityType.s3tc, s3tc_webkit = GLCapabilityType.s3tc_webkit, bptc = GLCapabilityType.bptc, textureFloat = GLCapabilityType.textureFloat, textureHalfFloat = GLCapabilityType.textureHalfFloat, textureFloatLinear = GLCapabilityType.textureFloatLinear, textureHalfFloatLinear = GLCapabilityType.textureHalfFloatLinear, WEBGL_colorBufferFloat = GLCapabilityType.WEBGL_colorBufferFloat, colorBufferFloat = GLCapabilityType.colorBufferFloat, colorBufferHalfFloat = GLCapabilityType.colorBufferHalfFloat, textureFilterAnisotropic = GLCapabilityType.textureFilterAnisotropic, fragDepth = GLCapabilityType.fragDepth;
|
|
366
350
|
cap.set(shaderVertexID, isWebGL2);
|
|
367
351
|
cap.set(standardDerivatives, isWebGL2 || !!requireExtension(standardDerivatives));
|
|
368
352
|
cap.set(shaderTextureLod, isWebGL2 || !!requireExtension(shaderTextureLod));
|
|
@@ -372,6 +356,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
372
356
|
cap.set(instancedArrays, isWebGL2 || !!requireExtension(instancedArrays));
|
|
373
357
|
cap.set(multipleSample, isWebGL2);
|
|
374
358
|
cap.set(drawBuffers, isWebGL2 || !!requireExtension(drawBuffers));
|
|
359
|
+
cap.set(blendMinMax, isWebGL2 || !!requireExtension(blendMinMax));
|
|
375
360
|
cap.set(textureFloat, isWebGL2 || !!requireExtension(textureFloat));
|
|
376
361
|
cap.set(textureHalfFloat, isWebGL2 || !!requireExtension(textureHalfFloat));
|
|
377
362
|
cap.set(textureFloatLinear, !!requireExtension(textureFloatLinear));
|
|
@@ -379,6 +364,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
379
364
|
cap.set(colorBufferFloat, isWebGL2 && !!requireExtension(colorBufferFloat) || !!requireExtension(WEBGL_colorBufferFloat));
|
|
380
365
|
cap.set(colorBufferHalfFloat, isWebGL2 && !!requireExtension(colorBufferFloat) || !!requireExtension(colorBufferHalfFloat));
|
|
381
366
|
cap.set(textureFilterAnisotropic, !!requireExtension(textureFilterAnisotropic));
|
|
367
|
+
cap.set(fragDepth, isWebGL2 || !!requireExtension(fragDepth));
|
|
382
368
|
cap.set(astc, !!(requireExtension(astc) || requireExtension(astc_webkit)));
|
|
383
369
|
cap.set(etc, !!(requireExtension(etc) || requireExtension(etc_webkit)));
|
|
384
370
|
cap.set(etc1, !!(requireExtension(etc1) || requireExtension(etc1_webkit)));
|
|
@@ -412,9 +398,13 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
412
398
|
}
|
|
413
399
|
};
|
|
414
400
|
_proto._compatibleAllInterface = function _compatibleAllInterface() {
|
|
415
|
-
var depthTexture = GLCapabilityType.depthTexture, vertexArrayObject = GLCapabilityType.vertexArrayObject, instancedArrays = GLCapabilityType.instancedArrays, drawBuffers = GLCapabilityType.drawBuffers, textureFilterAnisotropic = GLCapabilityType.textureFilterAnisotropic, textureHalfFloat = GLCapabilityType.textureHalfFloat, colorBufferHalfFloat = GLCapabilityType.colorBufferHalfFloat, WEBGL_colorBufferFloat = GLCapabilityType.WEBGL_colorBufferFloat;
|
|
401
|
+
var depthTexture = GLCapabilityType.depthTexture, vertexArrayObject = GLCapabilityType.vertexArrayObject, instancedArrays = GLCapabilityType.instancedArrays, drawBuffers = GLCapabilityType.drawBuffers, textureFilterAnisotropic = GLCapabilityType.textureFilterAnisotropic, textureHalfFloat = GLCapabilityType.textureHalfFloat, colorBufferHalfFloat = GLCapabilityType.colorBufferHalfFloat, WEBGL_colorBufferFloat = GLCapabilityType.WEBGL_colorBufferFloat, blendMinMax = GLCapabilityType.blendMinMax;
|
|
416
402
|
var isWebGL2 = this.rhi.isWebGL2;
|
|
417
403
|
if (!isWebGL2) {
|
|
404
|
+
this._compatibleInterface(blendMinMax, {
|
|
405
|
+
MIN: "MIN_EXT",
|
|
406
|
+
MAX: "MAX_EXT"
|
|
407
|
+
});
|
|
418
408
|
this._compatibleInterface(depthTexture, {
|
|
419
409
|
UNSIGNED_INT_24_8: "UNSIGNED_INT_24_8_WEBGL"
|
|
420
410
|
});
|
|
@@ -927,6 +917,13 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
927
917
|
dataType: gl.FLOAT,
|
|
928
918
|
isCompressed: false
|
|
929
919
|
};
|
|
920
|
+
case TextureFormat.R32G32B32A32_UInt:
|
|
921
|
+
return {
|
|
922
|
+
internalFormat: isWebGL2 ? gl.RGBA32UI : gl.NONE,
|
|
923
|
+
baseFormat: gl.RGBA_INTEGER,
|
|
924
|
+
dataType: gl.UNSIGNED_INT,
|
|
925
|
+
isCompressed: false
|
|
926
|
+
};
|
|
930
927
|
case TextureFormat.BC1:
|
|
931
928
|
return {
|
|
932
929
|
internalFormat: GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,
|
|
@@ -1077,7 +1074,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1077
1074
|
* @internal
|
|
1078
1075
|
*/ GLTexture._getRenderBufferDepthFormatDetail = function _getRenderBufferDepthFormatDetail(format, gl, isWebGL2) {
|
|
1079
1076
|
switch(format){
|
|
1080
|
-
case
|
|
1077
|
+
case TextureFormat.Depth:
|
|
1081
1078
|
return {
|
|
1082
1079
|
internalFormat: isWebGL2 ? gl.DEPTH_COMPONENT32F : gl.DEPTH_COMPONENT16,
|
|
1083
1080
|
baseFormat: gl.DEPTH_COMPONENT,
|
|
@@ -1085,7 +1082,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1085
1082
|
isCompressed: false,
|
|
1086
1083
|
attachment: gl.DEPTH_ATTACHMENT
|
|
1087
1084
|
};
|
|
1088
|
-
case
|
|
1085
|
+
case TextureFormat.DepthStencil:
|
|
1089
1086
|
return {
|
|
1090
1087
|
internalFormat: isWebGL2 ? gl.DEPTH32F_STENCIL8 : gl.DEPTH_STENCIL,
|
|
1091
1088
|
baseFormat: gl.DEPTH_STENCIL,
|
|
@@ -1093,7 +1090,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1093
1090
|
isCompressed: false,
|
|
1094
1091
|
attachment: gl.DEPTH_STENCIL_ATTACHMENT
|
|
1095
1092
|
};
|
|
1096
|
-
case
|
|
1093
|
+
case TextureFormat.Stencil:
|
|
1097
1094
|
return {
|
|
1098
1095
|
internalFormat: gl.STENCIL_INDEX8,
|
|
1099
1096
|
baseFormat: gl.STENCIL_ATTACHMENT,
|
|
@@ -1101,7 +1098,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1101
1098
|
isCompressed: false,
|
|
1102
1099
|
attachment: gl.STENCIL_ATTACHMENT
|
|
1103
1100
|
};
|
|
1104
|
-
case
|
|
1101
|
+
case TextureFormat.Depth16:
|
|
1105
1102
|
return {
|
|
1106
1103
|
internalFormat: gl.DEPTH_COMPONENT16,
|
|
1107
1104
|
baseFormat: gl.DEPTH_COMPONENT,
|
|
@@ -1109,7 +1106,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1109
1106
|
isCompressed: false,
|
|
1110
1107
|
attachment: gl.DEPTH_ATTACHMENT
|
|
1111
1108
|
};
|
|
1112
|
-
case
|
|
1109
|
+
case TextureFormat.Depth24Stencil8:
|
|
1113
1110
|
return {
|
|
1114
1111
|
internalFormat: isWebGL2 ? gl.DEPTH24_STENCIL8 : gl.DEPTH_STENCIL,
|
|
1115
1112
|
baseFormat: gl.DEPTH_STENCIL,
|
|
@@ -1117,7 +1114,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1117
1114
|
isCompressed: false,
|
|
1118
1115
|
attachment: gl.DEPTH_STENCIL_ATTACHMENT
|
|
1119
1116
|
};
|
|
1120
|
-
case
|
|
1117
|
+
case TextureFormat.Depth24:
|
|
1121
1118
|
return {
|
|
1122
1119
|
internalFormat: gl.DEPTH_COMPONENT24,
|
|
1123
1120
|
baseFormat: gl.DEPTH_COMPONENT,
|
|
@@ -1125,7 +1122,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1125
1122
|
isCompressed: false,
|
|
1126
1123
|
attachment: gl.DEPTH_ATTACHMENT
|
|
1127
1124
|
};
|
|
1128
|
-
case
|
|
1125
|
+
case TextureFormat.Depth32:
|
|
1129
1126
|
return {
|
|
1130
1127
|
internalFormat: gl.DEPTH_COMPONENT32F,
|
|
1131
1128
|
baseFormat: gl.DEPTH_COMPONENT,
|
|
@@ -1133,7 +1130,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1133
1130
|
isCompressed: false,
|
|
1134
1131
|
attachment: gl.DEPTH_ATTACHMENT
|
|
1135
1132
|
};
|
|
1136
|
-
case
|
|
1133
|
+
case TextureFormat.Depth32Stencil8:
|
|
1137
1134
|
return {
|
|
1138
1135
|
internalFormat: gl.DEPTH32F_STENCIL8,
|
|
1139
1136
|
baseFormat: gl.DEPTH_STENCIL,
|
|
@@ -1168,6 +1165,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1168
1165
|
return false;
|
|
1169
1166
|
}
|
|
1170
1167
|
break;
|
|
1168
|
+
case TextureFormat.R32G32B32A32_UInt:
|
|
1171
1169
|
case TextureFormat.Depth24:
|
|
1172
1170
|
case TextureFormat.Depth32:
|
|
1173
1171
|
case TextureFormat.Depth32Stencil8:
|
|
@@ -1202,9 +1200,9 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1202
1200
|
*/ GLTexture._supportRenderBufferDepthFormat = function _supportRenderBufferDepthFormat(format, rhi) {
|
|
1203
1201
|
if (!rhi.isWebGL2) {
|
|
1204
1202
|
switch(format){
|
|
1205
|
-
case
|
|
1206
|
-
case
|
|
1207
|
-
case
|
|
1203
|
+
case TextureFormat.Depth24:
|
|
1204
|
+
case TextureFormat.Depth32:
|
|
1205
|
+
case TextureFormat.Depth32Stencil8:
|
|
1208
1206
|
return false;
|
|
1209
1207
|
}
|
|
1210
1208
|
}
|
|
@@ -1307,6 +1305,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1307
1305
|
function GLRenderTarget(rhi, target) {
|
|
1308
1306
|
this._MSAAColorRenderBuffers = [];
|
|
1309
1307
|
this._curMipLevel = 0;
|
|
1308
|
+
this._curFaceIndex = undefined;
|
|
1310
1309
|
this._gl = rhi.gl;
|
|
1311
1310
|
this._isWebGL2 = rhi.isWebGL2;
|
|
1312
1311
|
this._target = target;
|
|
@@ -1358,21 +1357,23 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1358
1357
|
var _proto = GLRenderTarget.prototype;
|
|
1359
1358
|
/**
|
|
1360
1359
|
* Set which face and mipLevel of the cube texture to render to.
|
|
1361
|
-
* @param faceIndex - Cube texture face
|
|
1362
1360
|
* @param mipLevel - Set mip level the data want to write
|
|
1363
|
-
|
|
1361
|
+
* @param faceIndex - Cube texture face
|
|
1362
|
+
*/ _proto.activeRenderTarget = function activeRenderTarget(mipLevel, faceIndex) {
|
|
1363
|
+
// @todo: support MRT
|
|
1364
1364
|
var _this = this, gl = _this._gl, target = _this._target;
|
|
1365
|
-
var depthTexture = target.depthTexture;
|
|
1366
|
-
var colorTexture = target.getColorTexture(0);
|
|
1367
|
-
var mipChanged = mipLevel !== this._curMipLevel;
|
|
1368
1365
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
1366
|
+
var mipChanged = mipLevel !== this._curMipLevel;
|
|
1367
|
+
var faceChanged = faceIndex !== this._curFaceIndex;
|
|
1368
|
+
var colorTexture = target.getColorTexture(0);
|
|
1369
1369
|
if (colorTexture) {
|
|
1370
1370
|
var isCube = _instanceof(colorTexture, TextureCube);
|
|
1371
|
-
if (mipChanged || isCube) {
|
|
1371
|
+
if (mipChanged || isCube && faceChanged) {
|
|
1372
1372
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, isCube ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D, // @ts-ignore
|
|
1373
1373
|
colorTexture._platformTexture._glTexture, mipLevel);
|
|
1374
1374
|
}
|
|
1375
1375
|
}
|
|
1376
|
+
var depthTexture = target.depthTexture;
|
|
1376
1377
|
if (depthTexture) {
|
|
1377
1378
|
var isCube1 = _instanceof(depthTexture, TextureCube);
|
|
1378
1379
|
if (mipChanged || isCube1) {
|
|
@@ -1389,8 +1390,10 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1389
1390
|
}
|
|
1390
1391
|
}
|
|
1391
1392
|
this._curMipLevel = mipLevel;
|
|
1392
|
-
|
|
1393
|
-
this.
|
|
1393
|
+
this._curFaceIndex = faceIndex;
|
|
1394
|
+
if (this._MSAAFrameBuffer) {
|
|
1395
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this._MSAAFrameBuffer);
|
|
1396
|
+
}
|
|
1394
1397
|
};
|
|
1395
1398
|
/**
|
|
1396
1399
|
* Blit FBO.
|
|
@@ -1428,20 +1431,6 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1428
1431
|
this._MSAAColorRenderBuffers.length = 0;
|
|
1429
1432
|
this._MSAADepthRenderBuffer = null;
|
|
1430
1433
|
};
|
|
1431
|
-
/**
|
|
1432
|
-
* Activate this RenderTarget.
|
|
1433
|
-
* @internal
|
|
1434
|
-
* @remarks
|
|
1435
|
-
* If MSAA is turned on, MSAA FBO is activated, and then this._blitRenderTarget() is performed to exchange FBO.
|
|
1436
|
-
* If MSAA is not turned on, activate the main FBO.
|
|
1437
|
-
*/ _proto._activeRenderTarget = function _activeRenderTarget() {
|
|
1438
|
-
var gl = this._gl;
|
|
1439
|
-
if (this._MSAAFrameBuffer) {
|
|
1440
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, this._MSAAFrameBuffer);
|
|
1441
|
-
} else {
|
|
1442
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
1443
|
-
}
|
|
1444
|
-
};
|
|
1445
1434
|
_proto._bindMainFBO = function _bindMainFBO() {
|
|
1446
1435
|
var gl = this._gl;
|
|
1447
1436
|
var isWebGL2 = this._isWebGL2;
|
|
@@ -1751,6 +1740,9 @@ var WebGLMode;
|
|
|
1751
1740
|
function WebGLGraphicDevice(initializeOptions) {
|
|
1752
1741
|
if (initializeOptions === void 0) initializeOptions = {};
|
|
1753
1742
|
/** @internal */ this._readFrameBuffer = null;
|
|
1743
|
+
/** @internal */ this._mainFrameBuffer = null;
|
|
1744
|
+
/** @internal */ this._mainFrameWidth = 0;
|
|
1745
|
+
/** @internal */ this._mainFrameHeight = 0;
|
|
1754
1746
|
/** @internal */ this._enableGlobalDepthBias = false;
|
|
1755
1747
|
this._activeTextures = new Array(32);
|
|
1756
1748
|
this._lastViewport = new Vector4(null, null, null, null);
|
|
@@ -1913,23 +1905,30 @@ var WebGLMode;
|
|
|
1913
1905
|
Logger.error("draw primitive failed.");
|
|
1914
1906
|
}
|
|
1915
1907
|
};
|
|
1916
|
-
_proto.
|
|
1917
|
-
|
|
1908
|
+
_proto.getMainFrameBufferWidth = function getMainFrameBufferWidth() {
|
|
1909
|
+
return this._mainFrameWidth || this._gl.drawingBufferWidth;
|
|
1910
|
+
};
|
|
1911
|
+
_proto.getMainFrameBufferHeight = function getMainFrameBufferHeight() {
|
|
1912
|
+
return this._mainFrameHeight || this._gl.drawingBufferHeight;
|
|
1913
|
+
};
|
|
1914
|
+
_proto.activeRenderTarget = function activeRenderTarget(renderTarget, viewport, isFlipProjection, mipLevel, faceIndex) {
|
|
1918
1915
|
var bufferWidth, bufferHeight;
|
|
1919
1916
|
if (renderTarget) {
|
|
1920
|
-
|
|
1921
|
-
|
|
1917
|
+
/** @ts-ignore */ renderTarget._isContentLost = false;
|
|
1918
|
+
/** @ts-ignore */ var platformRenderTarget = renderTarget._platformRenderTarget;
|
|
1919
|
+
platformRenderTarget.activeRenderTarget(mipLevel, faceIndex);
|
|
1922
1920
|
bufferWidth = renderTarget.width >> mipLevel;
|
|
1923
1921
|
bufferHeight = renderTarget.height >> mipLevel;
|
|
1924
1922
|
} else {
|
|
1925
|
-
gl.
|
|
1926
|
-
|
|
1927
|
-
|
|
1923
|
+
var gl = this._gl;
|
|
1924
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this._mainFrameBuffer);
|
|
1925
|
+
bufferWidth = this.getMainFrameBufferWidth();
|
|
1926
|
+
bufferHeight = this.getMainFrameBufferHeight();
|
|
1928
1927
|
}
|
|
1929
1928
|
var width = bufferWidth * viewport.z;
|
|
1930
1929
|
var height = bufferHeight * viewport.w;
|
|
1931
1930
|
var x = viewport.x * bufferWidth;
|
|
1932
|
-
var y = bufferHeight - viewport.y * bufferHeight - height;
|
|
1931
|
+
var y = isFlipProjection ? viewport.y * bufferHeight : bufferHeight - viewport.y * bufferHeight - height;
|
|
1933
1932
|
this.viewport(x, y, width, height);
|
|
1934
1933
|
this.scissor(x, y, width, height);
|
|
1935
1934
|
};
|