@galacean/engine-rhi-webgl 0.0.0-experimental-renderSort.4 → 0.0.0-experimental-shaderlab.2
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/miniprogram.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var engineMiniprogramAdapter = require('@galacean/engine-miniprogram-adapter');
|
|
6
|
-
var miniprogram = require('@galacean/engine-math/dist/miniprogram');
|
|
7
6
|
var miniprogram$1 = require('@galacean/engine-core/dist/miniprogram');
|
|
7
|
+
var miniprogram = require('@galacean/engine-math/dist/miniprogram');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Smoothing plug-in.
|
|
@@ -87,6 +87,26 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
87
87
|
return Constructor;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
function _set_prototype_of(o, p) {
|
|
91
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
92
|
+
o.__proto__ = p;
|
|
93
|
+
|
|
94
|
+
return o;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return _set_prototype_of(o, p);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function _inherits(subClass, superClass) {
|
|
101
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
102
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
106
|
+
|
|
107
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
108
|
+
}
|
|
109
|
+
|
|
90
110
|
function _instanceof(left, right) {
|
|
91
111
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
92
112
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -95,14 +115,18 @@ function _instanceof(left, right) {
|
|
|
95
115
|
|
|
96
116
|
/**
|
|
97
117
|
* The canvas used on the web, which can support HTMLCanvasElement and OffscreenCanvas.
|
|
98
|
-
*/ var WebCanvas = /*#__PURE__*/ function() {
|
|
118
|
+
*/ var WebCanvas = /*#__PURE__*/ function(Canvas1) {
|
|
119
|
+
_inherits(WebCanvas, Canvas1);
|
|
99
120
|
function WebCanvas(webCanvas) {
|
|
100
|
-
|
|
121
|
+
var _this;
|
|
122
|
+
_this = Canvas1.call(this) || this;
|
|
123
|
+
_this._scale = new miniprogram.Vector2();
|
|
101
124
|
var width = webCanvas.width;
|
|
102
125
|
var height = webCanvas.height;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
126
|
+
_this._webCanvas = webCanvas;
|
|
127
|
+
_this.width = width;
|
|
128
|
+
_this.height = height;
|
|
129
|
+
return _this;
|
|
106
130
|
}
|
|
107
131
|
var _proto = WebCanvas.prototype;
|
|
108
132
|
/**
|
|
@@ -112,8 +136,10 @@ function _instanceof(left, right) {
|
|
|
112
136
|
if (pixelRatio === void 0) pixelRatio = engineMiniprogramAdapter.window.devicePixelRatio;
|
|
113
137
|
var webCanvas = this._webCanvas;
|
|
114
138
|
if (typeof engineMiniprogramAdapter.OffscreenCanvas === "undefined" || !_instanceof(webCanvas, engineMiniprogramAdapter.OffscreenCanvas)) {
|
|
115
|
-
|
|
116
|
-
|
|
139
|
+
var exportWidth = webCanvas.clientWidth * pixelRatio;
|
|
140
|
+
var exportHeight = webCanvas.clientHeight * pixelRatio;
|
|
141
|
+
this.width = exportWidth;
|
|
142
|
+
this.height = exportHeight;
|
|
117
143
|
}
|
|
118
144
|
};
|
|
119
145
|
/**
|
|
@@ -124,35 +150,13 @@ function _instanceof(left, right) {
|
|
|
124
150
|
this._scale.set(x, y);
|
|
125
151
|
this.scale = this._scale;
|
|
126
152
|
};
|
|
153
|
+
_proto._onWidthChanged = function _onWidthChanged(value) {
|
|
154
|
+
this._webCanvas.width = value;
|
|
155
|
+
};
|
|
156
|
+
_proto._onHeightChange = function _onHeightChange(value) {
|
|
157
|
+
this._webCanvas.height = value;
|
|
158
|
+
};
|
|
127
159
|
_create_class(WebCanvas, [
|
|
128
|
-
{
|
|
129
|
-
key: "width",
|
|
130
|
-
get: /**
|
|
131
|
-
* @inheritdoc
|
|
132
|
-
*/ function get() {
|
|
133
|
-
return this._width;
|
|
134
|
-
},
|
|
135
|
-
set: function set(value) {
|
|
136
|
-
if (this._width !== value) {
|
|
137
|
-
this._webCanvas.width = value;
|
|
138
|
-
this._width = value;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
key: "height",
|
|
144
|
-
get: /**
|
|
145
|
-
* @inheritdoc
|
|
146
|
-
*/ function get() {
|
|
147
|
-
return this._height;
|
|
148
|
-
},
|
|
149
|
-
set: function set(value) {
|
|
150
|
-
if (this._height !== value) {
|
|
151
|
-
this._webCanvas.height = value;
|
|
152
|
-
this._height = value;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
160
|
{
|
|
157
161
|
key: "scale",
|
|
158
162
|
get: /**
|
|
@@ -175,27 +179,7 @@ function _instanceof(left, right) {
|
|
|
175
179
|
}
|
|
176
180
|
]);
|
|
177
181
|
return WebCanvas;
|
|
178
|
-
}();
|
|
179
|
-
|
|
180
|
-
function _set_prototype_of(o, p) {
|
|
181
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
182
|
-
o.__proto__ = p;
|
|
183
|
-
|
|
184
|
-
return o;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
return _set_prototype_of(o, p);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function _inherits(subClass, superClass) {
|
|
191
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
192
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
|
|
196
|
-
|
|
197
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
198
|
-
}
|
|
182
|
+
}(miniprogram$1.Canvas);
|
|
199
183
|
|
|
200
184
|
/**
|
|
201
185
|
* WebGL platform engine,support includes WebGL1.0 and WebGL2.0.
|
|
@@ -367,7 +351,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
367
351
|
var cap = this.capabilityList;
|
|
368
352
|
var isWebGL2 = this.rhi.isWebGL2;
|
|
369
353
|
var requireExtension = this.rhi.requireExtension.bind(this.rhi);
|
|
370
|
-
var shaderVertexID = miniprogram$1.GLCapabilityType.shaderVertexID, standardDerivatives = miniprogram$1.GLCapabilityType.standardDerivatives, shaderTextureLod = miniprogram$1.GLCapabilityType.shaderTextureLod, elementIndexUint = miniprogram$1.GLCapabilityType.elementIndexUint, depthTexture = miniprogram$1.GLCapabilityType.depthTexture, vertexArrayObject = miniprogram$1.GLCapabilityType.vertexArrayObject, instancedArrays = miniprogram$1.GLCapabilityType.instancedArrays, multipleSample = miniprogram$1.GLCapabilityType.multipleSample, drawBuffers = miniprogram$1.GLCapabilityType.drawBuffers, astc = miniprogram$1.GLCapabilityType.astc, astc_webkit = miniprogram$1.GLCapabilityType.astc_webkit, etc = miniprogram$1.GLCapabilityType.etc, etc_webkit = miniprogram$1.GLCapabilityType.etc_webkit, etc1 = miniprogram$1.GLCapabilityType.etc1, etc1_webkit = miniprogram$1.GLCapabilityType.etc1_webkit, pvrtc = miniprogram$1.GLCapabilityType.pvrtc, pvrtc_webkit = miniprogram$1.GLCapabilityType.pvrtc_webkit, s3tc = miniprogram$1.GLCapabilityType.s3tc, s3tc_webkit = miniprogram$1.GLCapabilityType.s3tc_webkit, bptc = miniprogram$1.GLCapabilityType.bptc, textureFloat = miniprogram$1.GLCapabilityType.textureFloat, textureHalfFloat = miniprogram$1.GLCapabilityType.textureHalfFloat, textureFloatLinear = miniprogram$1.GLCapabilityType.textureFloatLinear, textureHalfFloatLinear = miniprogram$1.GLCapabilityType.textureHalfFloatLinear, WEBGL_colorBufferFloat = miniprogram$1.GLCapabilityType.WEBGL_colorBufferFloat, colorBufferFloat = miniprogram$1.GLCapabilityType.colorBufferFloat, colorBufferHalfFloat = miniprogram$1.GLCapabilityType.colorBufferHalfFloat, textureFilterAnisotropic = miniprogram$1.GLCapabilityType.textureFilterAnisotropic;
|
|
354
|
+
var shaderVertexID = miniprogram$1.GLCapabilityType.shaderVertexID, standardDerivatives = miniprogram$1.GLCapabilityType.standardDerivatives, shaderTextureLod = miniprogram$1.GLCapabilityType.shaderTextureLod, elementIndexUint = miniprogram$1.GLCapabilityType.elementIndexUint, depthTexture = miniprogram$1.GLCapabilityType.depthTexture, vertexArrayObject = miniprogram$1.GLCapabilityType.vertexArrayObject, instancedArrays = miniprogram$1.GLCapabilityType.instancedArrays, multipleSample = miniprogram$1.GLCapabilityType.multipleSample, drawBuffers = miniprogram$1.GLCapabilityType.drawBuffers, blendMinMax = miniprogram$1.GLCapabilityType.blendMinMax, astc = miniprogram$1.GLCapabilityType.astc, astc_webkit = miniprogram$1.GLCapabilityType.astc_webkit, etc = miniprogram$1.GLCapabilityType.etc, etc_webkit = miniprogram$1.GLCapabilityType.etc_webkit, etc1 = miniprogram$1.GLCapabilityType.etc1, etc1_webkit = miniprogram$1.GLCapabilityType.etc1_webkit, pvrtc = miniprogram$1.GLCapabilityType.pvrtc, pvrtc_webkit = miniprogram$1.GLCapabilityType.pvrtc_webkit, s3tc = miniprogram$1.GLCapabilityType.s3tc, s3tc_webkit = miniprogram$1.GLCapabilityType.s3tc_webkit, bptc = miniprogram$1.GLCapabilityType.bptc, textureFloat = miniprogram$1.GLCapabilityType.textureFloat, textureHalfFloat = miniprogram$1.GLCapabilityType.textureHalfFloat, textureFloatLinear = miniprogram$1.GLCapabilityType.textureFloatLinear, textureHalfFloatLinear = miniprogram$1.GLCapabilityType.textureHalfFloatLinear, WEBGL_colorBufferFloat = miniprogram$1.GLCapabilityType.WEBGL_colorBufferFloat, colorBufferFloat = miniprogram$1.GLCapabilityType.colorBufferFloat, colorBufferHalfFloat = miniprogram$1.GLCapabilityType.colorBufferHalfFloat, textureFilterAnisotropic = miniprogram$1.GLCapabilityType.textureFilterAnisotropic, fragDepth = miniprogram$1.GLCapabilityType.fragDepth;
|
|
371
355
|
cap.set(shaderVertexID, isWebGL2);
|
|
372
356
|
cap.set(standardDerivatives, isWebGL2 || !!requireExtension(standardDerivatives));
|
|
373
357
|
cap.set(shaderTextureLod, isWebGL2 || !!requireExtension(shaderTextureLod));
|
|
@@ -377,6 +361,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
377
361
|
cap.set(instancedArrays, isWebGL2 || !!requireExtension(instancedArrays));
|
|
378
362
|
cap.set(multipleSample, isWebGL2);
|
|
379
363
|
cap.set(drawBuffers, isWebGL2 || !!requireExtension(drawBuffers));
|
|
364
|
+
cap.set(blendMinMax, isWebGL2 || !!requireExtension(blendMinMax));
|
|
380
365
|
cap.set(textureFloat, isWebGL2 || !!requireExtension(textureFloat));
|
|
381
366
|
cap.set(textureHalfFloat, isWebGL2 || !!requireExtension(textureHalfFloat));
|
|
382
367
|
cap.set(textureFloatLinear, !!requireExtension(textureFloatLinear));
|
|
@@ -384,6 +369,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
384
369
|
cap.set(colorBufferFloat, isWebGL2 && !!requireExtension(colorBufferFloat) || !!requireExtension(WEBGL_colorBufferFloat));
|
|
385
370
|
cap.set(colorBufferHalfFloat, isWebGL2 && !!requireExtension(colorBufferFloat) || !!requireExtension(colorBufferHalfFloat));
|
|
386
371
|
cap.set(textureFilterAnisotropic, !!requireExtension(textureFilterAnisotropic));
|
|
372
|
+
cap.set(fragDepth, isWebGL2 || !!requireExtension(fragDepth));
|
|
387
373
|
cap.set(astc, !!(requireExtension(astc) || requireExtension(astc_webkit)));
|
|
388
374
|
cap.set(etc, !!(requireExtension(etc) || requireExtension(etc_webkit)));
|
|
389
375
|
cap.set(etc1, !!(requireExtension(etc1) || requireExtension(etc1_webkit)));
|
|
@@ -417,9 +403,13 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
417
403
|
}
|
|
418
404
|
};
|
|
419
405
|
_proto._compatibleAllInterface = function _compatibleAllInterface() {
|
|
420
|
-
var depthTexture = miniprogram$1.GLCapabilityType.depthTexture, vertexArrayObject = miniprogram$1.GLCapabilityType.vertexArrayObject, instancedArrays = miniprogram$1.GLCapabilityType.instancedArrays, drawBuffers = miniprogram$1.GLCapabilityType.drawBuffers, textureFilterAnisotropic = miniprogram$1.GLCapabilityType.textureFilterAnisotropic, textureHalfFloat = miniprogram$1.GLCapabilityType.textureHalfFloat, colorBufferHalfFloat = miniprogram$1.GLCapabilityType.colorBufferHalfFloat, WEBGL_colorBufferFloat = miniprogram$1.GLCapabilityType.WEBGL_colorBufferFloat;
|
|
406
|
+
var depthTexture = miniprogram$1.GLCapabilityType.depthTexture, vertexArrayObject = miniprogram$1.GLCapabilityType.vertexArrayObject, instancedArrays = miniprogram$1.GLCapabilityType.instancedArrays, drawBuffers = miniprogram$1.GLCapabilityType.drawBuffers, textureFilterAnisotropic = miniprogram$1.GLCapabilityType.textureFilterAnisotropic, textureHalfFloat = miniprogram$1.GLCapabilityType.textureHalfFloat, colorBufferHalfFloat = miniprogram$1.GLCapabilityType.colorBufferHalfFloat, WEBGL_colorBufferFloat = miniprogram$1.GLCapabilityType.WEBGL_colorBufferFloat, blendMinMax = miniprogram$1.GLCapabilityType.blendMinMax;
|
|
421
407
|
var isWebGL2 = this.rhi.isWebGL2;
|
|
422
408
|
if (!isWebGL2) {
|
|
409
|
+
this._compatibleInterface(blendMinMax, {
|
|
410
|
+
MIN: "MIN_EXT",
|
|
411
|
+
MAX: "MAX_EXT"
|
|
412
|
+
});
|
|
423
413
|
this._compatibleInterface(depthTexture, {
|
|
424
414
|
UNSIGNED_INT_24_8: "UNSIGNED_INT_24_8_WEBGL"
|
|
425
415
|
});
|
|
@@ -932,6 +922,13 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
932
922
|
dataType: gl.FLOAT,
|
|
933
923
|
isCompressed: false
|
|
934
924
|
};
|
|
925
|
+
case miniprogram$1.TextureFormat.R32G32B32A32_UInt:
|
|
926
|
+
return {
|
|
927
|
+
internalFormat: isWebGL2 ? gl.RGBA32UI : gl.NONE,
|
|
928
|
+
baseFormat: gl.RGBA_INTEGER,
|
|
929
|
+
dataType: gl.UNSIGNED_INT,
|
|
930
|
+
isCompressed: false
|
|
931
|
+
};
|
|
935
932
|
case miniprogram$1.TextureFormat.BC1:
|
|
936
933
|
return {
|
|
937
934
|
internalFormat: exports.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,
|
|
@@ -1082,7 +1079,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1082
1079
|
* @internal
|
|
1083
1080
|
*/ GLTexture._getRenderBufferDepthFormatDetail = function _getRenderBufferDepthFormatDetail(format, gl, isWebGL2) {
|
|
1084
1081
|
switch(format){
|
|
1085
|
-
case miniprogram$1.
|
|
1082
|
+
case miniprogram$1.TextureFormat.Depth:
|
|
1086
1083
|
return {
|
|
1087
1084
|
internalFormat: isWebGL2 ? gl.DEPTH_COMPONENT32F : gl.DEPTH_COMPONENT16,
|
|
1088
1085
|
baseFormat: gl.DEPTH_COMPONENT,
|
|
@@ -1090,7 +1087,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1090
1087
|
isCompressed: false,
|
|
1091
1088
|
attachment: gl.DEPTH_ATTACHMENT
|
|
1092
1089
|
};
|
|
1093
|
-
case miniprogram$1.
|
|
1090
|
+
case miniprogram$1.TextureFormat.DepthStencil:
|
|
1094
1091
|
return {
|
|
1095
1092
|
internalFormat: isWebGL2 ? gl.DEPTH32F_STENCIL8 : gl.DEPTH_STENCIL,
|
|
1096
1093
|
baseFormat: gl.DEPTH_STENCIL,
|
|
@@ -1098,7 +1095,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1098
1095
|
isCompressed: false,
|
|
1099
1096
|
attachment: gl.DEPTH_STENCIL_ATTACHMENT
|
|
1100
1097
|
};
|
|
1101
|
-
case miniprogram$1.
|
|
1098
|
+
case miniprogram$1.TextureFormat.Stencil:
|
|
1102
1099
|
return {
|
|
1103
1100
|
internalFormat: gl.STENCIL_INDEX8,
|
|
1104
1101
|
baseFormat: gl.STENCIL_ATTACHMENT,
|
|
@@ -1106,7 +1103,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1106
1103
|
isCompressed: false,
|
|
1107
1104
|
attachment: gl.STENCIL_ATTACHMENT
|
|
1108
1105
|
};
|
|
1109
|
-
case miniprogram$1.
|
|
1106
|
+
case miniprogram$1.TextureFormat.Depth16:
|
|
1110
1107
|
return {
|
|
1111
1108
|
internalFormat: gl.DEPTH_COMPONENT16,
|
|
1112
1109
|
baseFormat: gl.DEPTH_COMPONENT,
|
|
@@ -1114,7 +1111,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1114
1111
|
isCompressed: false,
|
|
1115
1112
|
attachment: gl.DEPTH_ATTACHMENT
|
|
1116
1113
|
};
|
|
1117
|
-
case miniprogram$1.
|
|
1114
|
+
case miniprogram$1.TextureFormat.Depth24Stencil8:
|
|
1118
1115
|
return {
|
|
1119
1116
|
internalFormat: isWebGL2 ? gl.DEPTH24_STENCIL8 : gl.DEPTH_STENCIL,
|
|
1120
1117
|
baseFormat: gl.DEPTH_STENCIL,
|
|
@@ -1122,7 +1119,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1122
1119
|
isCompressed: false,
|
|
1123
1120
|
attachment: gl.DEPTH_STENCIL_ATTACHMENT
|
|
1124
1121
|
};
|
|
1125
|
-
case miniprogram$1.
|
|
1122
|
+
case miniprogram$1.TextureFormat.Depth24:
|
|
1126
1123
|
return {
|
|
1127
1124
|
internalFormat: gl.DEPTH_COMPONENT24,
|
|
1128
1125
|
baseFormat: gl.DEPTH_COMPONENT,
|
|
@@ -1130,7 +1127,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1130
1127
|
isCompressed: false,
|
|
1131
1128
|
attachment: gl.DEPTH_ATTACHMENT
|
|
1132
1129
|
};
|
|
1133
|
-
case miniprogram$1.
|
|
1130
|
+
case miniprogram$1.TextureFormat.Depth32:
|
|
1134
1131
|
return {
|
|
1135
1132
|
internalFormat: gl.DEPTH_COMPONENT32F,
|
|
1136
1133
|
baseFormat: gl.DEPTH_COMPONENT,
|
|
@@ -1138,7 +1135,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1138
1135
|
isCompressed: false,
|
|
1139
1136
|
attachment: gl.DEPTH_ATTACHMENT
|
|
1140
1137
|
};
|
|
1141
|
-
case miniprogram$1.
|
|
1138
|
+
case miniprogram$1.TextureFormat.Depth32Stencil8:
|
|
1142
1139
|
return {
|
|
1143
1140
|
internalFormat: gl.DEPTH32F_STENCIL8,
|
|
1144
1141
|
baseFormat: gl.DEPTH_STENCIL,
|
|
@@ -1173,6 +1170,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1173
1170
|
return false;
|
|
1174
1171
|
}
|
|
1175
1172
|
break;
|
|
1173
|
+
case miniprogram$1.TextureFormat.R32G32B32A32_UInt:
|
|
1176
1174
|
case miniprogram$1.TextureFormat.Depth24:
|
|
1177
1175
|
case miniprogram$1.TextureFormat.Depth32:
|
|
1178
1176
|
case miniprogram$1.TextureFormat.Depth32Stencil8:
|
|
@@ -1207,9 +1205,9 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1207
1205
|
*/ GLTexture._supportRenderBufferDepthFormat = function _supportRenderBufferDepthFormat(format, rhi) {
|
|
1208
1206
|
if (!rhi.isWebGL2) {
|
|
1209
1207
|
switch(format){
|
|
1210
|
-
case miniprogram$1.
|
|
1211
|
-
case miniprogram$1.
|
|
1212
|
-
case miniprogram$1.
|
|
1208
|
+
case miniprogram$1.TextureFormat.Depth24:
|
|
1209
|
+
case miniprogram$1.TextureFormat.Depth32:
|
|
1210
|
+
case miniprogram$1.TextureFormat.Depth32Stencil8:
|
|
1213
1211
|
return false;
|
|
1214
1212
|
}
|
|
1215
1213
|
}
|
|
@@ -1312,6 +1310,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1312
1310
|
function GLRenderTarget(rhi, target) {
|
|
1313
1311
|
this._MSAAColorRenderBuffers = [];
|
|
1314
1312
|
this._curMipLevel = 0;
|
|
1313
|
+
this._curFaceIndex = undefined;
|
|
1315
1314
|
this._gl = rhi.gl;
|
|
1316
1315
|
this._isWebGL2 = rhi.isWebGL2;
|
|
1317
1316
|
this._target = target;
|
|
@@ -1363,21 +1362,23 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1363
1362
|
var _proto = GLRenderTarget.prototype;
|
|
1364
1363
|
/**
|
|
1365
1364
|
* Set which face and mipLevel of the cube texture to render to.
|
|
1366
|
-
* @param faceIndex - Cube texture face
|
|
1367
1365
|
* @param mipLevel - Set mip level the data want to write
|
|
1368
|
-
|
|
1366
|
+
* @param faceIndex - Cube texture face
|
|
1367
|
+
*/ _proto.activeRenderTarget = function activeRenderTarget(mipLevel, faceIndex) {
|
|
1368
|
+
// @todo: support MRT
|
|
1369
1369
|
var _this = this, gl = _this._gl, target = _this._target;
|
|
1370
|
-
var depthTexture = target.depthTexture;
|
|
1371
|
-
var colorTexture = target.getColorTexture(0);
|
|
1372
|
-
var mipChanged = mipLevel !== this._curMipLevel;
|
|
1373
1370
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
1371
|
+
var mipChanged = mipLevel !== this._curMipLevel;
|
|
1372
|
+
var faceChanged = faceIndex !== this._curFaceIndex;
|
|
1373
|
+
var colorTexture = target.getColorTexture(0);
|
|
1374
1374
|
if (colorTexture) {
|
|
1375
1375
|
var isCube = _instanceof(colorTexture, miniprogram$1.TextureCube);
|
|
1376
|
-
if (mipChanged || isCube) {
|
|
1376
|
+
if (mipChanged || isCube && faceChanged) {
|
|
1377
1377
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, isCube ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D, // @ts-ignore
|
|
1378
1378
|
colorTexture._platformTexture._glTexture, mipLevel);
|
|
1379
1379
|
}
|
|
1380
1380
|
}
|
|
1381
|
+
var depthTexture = target.depthTexture;
|
|
1381
1382
|
if (depthTexture) {
|
|
1382
1383
|
var isCube1 = _instanceof(depthTexture, miniprogram$1.TextureCube);
|
|
1383
1384
|
if (mipChanged || isCube1) {
|
|
@@ -1394,8 +1395,10 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1394
1395
|
}
|
|
1395
1396
|
}
|
|
1396
1397
|
this._curMipLevel = mipLevel;
|
|
1397
|
-
|
|
1398
|
-
this.
|
|
1398
|
+
this._curFaceIndex = faceIndex;
|
|
1399
|
+
if (this._MSAAFrameBuffer) {
|
|
1400
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this._MSAAFrameBuffer);
|
|
1401
|
+
}
|
|
1399
1402
|
};
|
|
1400
1403
|
/**
|
|
1401
1404
|
* Blit FBO.
|
|
@@ -1433,20 +1436,6 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1433
1436
|
this._MSAAColorRenderBuffers.length = 0;
|
|
1434
1437
|
this._MSAADepthRenderBuffer = null;
|
|
1435
1438
|
};
|
|
1436
|
-
/**
|
|
1437
|
-
* Activate this RenderTarget.
|
|
1438
|
-
* @internal
|
|
1439
|
-
* @remarks
|
|
1440
|
-
* If MSAA is turned on, MSAA FBO is activated, and then this._blitRenderTarget() is performed to exchange FBO.
|
|
1441
|
-
* If MSAA is not turned on, activate the main FBO.
|
|
1442
|
-
*/ _proto._activeRenderTarget = function _activeRenderTarget() {
|
|
1443
|
-
var gl = this._gl;
|
|
1444
|
-
if (this._MSAAFrameBuffer) {
|
|
1445
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, this._MSAAFrameBuffer);
|
|
1446
|
-
} else {
|
|
1447
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
1448
|
-
}
|
|
1449
|
-
};
|
|
1450
1439
|
_proto._bindMainFBO = function _bindMainFBO() {
|
|
1451
1440
|
var gl = this._gl;
|
|
1452
1441
|
var isWebGL2 = this._isWebGL2;
|
|
@@ -1756,6 +1745,9 @@ exports.WebGLMode = void 0;
|
|
|
1756
1745
|
function WebGLGraphicDevice(initializeOptions) {
|
|
1757
1746
|
if (initializeOptions === void 0) initializeOptions = {};
|
|
1758
1747
|
/** @internal */ this._readFrameBuffer = null;
|
|
1748
|
+
/** @internal */ this._mainFrameBuffer = null;
|
|
1749
|
+
/** @internal */ this._mainFrameWidth = 0;
|
|
1750
|
+
/** @internal */ this._mainFrameHeight = 0;
|
|
1759
1751
|
/** @internal */ this._enableGlobalDepthBias = false;
|
|
1760
1752
|
this._activeTextures = new Array(32);
|
|
1761
1753
|
this._lastViewport = new miniprogram.Vector4(null, null, null, null);
|
|
@@ -1918,23 +1910,30 @@ exports.WebGLMode = void 0;
|
|
|
1918
1910
|
miniprogram$1.Logger.error("draw primitive failed.");
|
|
1919
1911
|
}
|
|
1920
1912
|
};
|
|
1921
|
-
_proto.
|
|
1922
|
-
|
|
1913
|
+
_proto.getMainFrameBufferWidth = function getMainFrameBufferWidth() {
|
|
1914
|
+
return this._mainFrameWidth || this._gl.drawingBufferWidth;
|
|
1915
|
+
};
|
|
1916
|
+
_proto.getMainFrameBufferHeight = function getMainFrameBufferHeight() {
|
|
1917
|
+
return this._mainFrameHeight || this._gl.drawingBufferHeight;
|
|
1918
|
+
};
|
|
1919
|
+
_proto.activeRenderTarget = function activeRenderTarget(renderTarget, viewport, isFlipProjection, mipLevel, faceIndex) {
|
|
1923
1920
|
var bufferWidth, bufferHeight;
|
|
1924
1921
|
if (renderTarget) {
|
|
1925
|
-
|
|
1926
|
-
|
|
1922
|
+
/** @ts-ignore */ renderTarget._isContentLost = false;
|
|
1923
|
+
/** @ts-ignore */ var platformRenderTarget = renderTarget._platformRenderTarget;
|
|
1924
|
+
platformRenderTarget.activeRenderTarget(mipLevel, faceIndex);
|
|
1927
1925
|
bufferWidth = renderTarget.width >> mipLevel;
|
|
1928
1926
|
bufferHeight = renderTarget.height >> mipLevel;
|
|
1929
1927
|
} else {
|
|
1930
|
-
gl.
|
|
1931
|
-
|
|
1932
|
-
|
|
1928
|
+
var gl = this._gl;
|
|
1929
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this._mainFrameBuffer);
|
|
1930
|
+
bufferWidth = this.getMainFrameBufferWidth();
|
|
1931
|
+
bufferHeight = this.getMainFrameBufferHeight();
|
|
1933
1932
|
}
|
|
1934
1933
|
var width = bufferWidth * viewport.z;
|
|
1935
1934
|
var height = bufferHeight * viewport.w;
|
|
1936
1935
|
var x = viewport.x * bufferWidth;
|
|
1937
|
-
var y = bufferHeight - viewport.y * bufferHeight - height;
|
|
1936
|
+
var y = isFlipProjection ? viewport.y * bufferHeight : bufferHeight - viewport.y * bufferHeight - height;
|
|
1938
1937
|
this.viewport(x, y, width, height);
|
|
1939
1938
|
this.scissor(x, y, width, height);
|
|
1940
1939
|
};
|