@galacean/engine-rhi-webgl 1.1.0-alpha.2 → 1.1.0-alpha.4
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 +17 -24
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +17 -24
- package/dist/module.js +17 -24
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/WebGLGraphicDevice.d.ts +2 -1
package/dist/main.js
CHANGED
|
@@ -561,7 +561,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
561
561
|
this._vaoMap = new Map();
|
|
562
562
|
this._primitive = primitive;
|
|
563
563
|
this._canUseInstancedArrays = rhi.canIUse(engineCore.GLCapabilityType.instancedArrays);
|
|
564
|
-
this.
|
|
564
|
+
this._isSupportVAO = rhi.canIUse(engineCore.GLCapabilityType.vertexArrayObject);
|
|
565
565
|
this._gl = rhi.gl;
|
|
566
566
|
}
|
|
567
567
|
var _proto = GLPrimitive.prototype;
|
|
@@ -570,10 +570,8 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
570
570
|
*/ _proto.draw = function draw(shaderProgram, subMesh) {
|
|
571
571
|
var gl = this._gl;
|
|
572
572
|
var primitive = this._primitive;
|
|
573
|
-
|
|
574
|
-
var useVao = this._useVao && primitive._enableVAO;
|
|
573
|
+
var useVao = this._isSupportVAO && primitive.enableVAO;
|
|
575
574
|
if (useVao) {
|
|
576
|
-
// @ts-ignore
|
|
577
575
|
if (primitive._bufferStructChanged) {
|
|
578
576
|
this._clearVAO();
|
|
579
577
|
}
|
|
@@ -585,15 +583,14 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
585
583
|
} else {
|
|
586
584
|
this._bindBufferAndAttrib(shaderProgram);
|
|
587
585
|
}
|
|
588
|
-
|
|
589
|
-
var _indexBufferBinding = primitive._indexBufferBinding, _instanceCount = primitive._instanceCount, _glIndexType = primitive._glIndexType, _glIndexByteCount = primitive._glIndexByteCount;
|
|
586
|
+
var indexBufferBinding = primitive.indexBufferBinding, instanceCount = primitive.instanceCount, _glIndexType = primitive._glIndexType, _glIndexByteCount = primitive._glIndexByteCount;
|
|
590
587
|
var topology = subMesh.topology, start = subMesh.start, count = subMesh.count;
|
|
591
|
-
if (!
|
|
592
|
-
if (
|
|
588
|
+
if (!instanceCount) {
|
|
589
|
+
if (indexBufferBinding) {
|
|
593
590
|
if (useVao) {
|
|
594
591
|
gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
|
|
595
592
|
} else {
|
|
596
|
-
var _glBuffer =
|
|
593
|
+
var _glBuffer = indexBufferBinding.buffer._platformBuffer._glBuffer;
|
|
597
594
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _glBuffer);
|
|
598
595
|
gl.drawElements(topology, count, _glIndexType, start * _glIndexByteCount);
|
|
599
596
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
@@ -603,17 +600,17 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
603
600
|
}
|
|
604
601
|
} else {
|
|
605
602
|
if (this._canUseInstancedArrays) {
|
|
606
|
-
if (
|
|
603
|
+
if (indexBufferBinding) {
|
|
607
604
|
if (useVao) {
|
|
608
|
-
gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount,
|
|
605
|
+
gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, instanceCount);
|
|
609
606
|
} else {
|
|
610
|
-
var _glBuffer1 =
|
|
607
|
+
var _glBuffer1 = indexBufferBinding.buffer._platformBuffer._glBuffer;
|
|
611
608
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _glBuffer1);
|
|
612
|
-
gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount,
|
|
609
|
+
gl.drawElementsInstanced(topology, count, _glIndexType, start * _glIndexByteCount, instanceCount);
|
|
613
610
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
614
611
|
}
|
|
615
612
|
} else {
|
|
616
|
-
gl.drawArraysInstanced(topology, start, count,
|
|
613
|
+
gl.drawArraysInstanced(topology, start, count, instanceCount);
|
|
617
614
|
}
|
|
618
615
|
} else {
|
|
619
616
|
engineCore.Logger.error("ANGLE_instanced_arrays extension is not supported");
|
|
@@ -627,18 +624,16 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
627
624
|
}
|
|
628
625
|
};
|
|
629
626
|
_proto.destroy = function destroy() {
|
|
630
|
-
this.
|
|
627
|
+
this._isSupportVAO && this._clearVAO();
|
|
631
628
|
};
|
|
632
629
|
/**
|
|
633
630
|
* Bind buffer and attribute.
|
|
634
631
|
*/ _proto._bindBufferAndAttrib = function _bindBufferAndAttrib(shaderProgram) {
|
|
635
632
|
var gl = this._gl;
|
|
636
633
|
var primitive = this._primitive;
|
|
637
|
-
|
|
638
|
-
var vertexBufferBindings = primitive._vertexBufferBindings;
|
|
634
|
+
var vertexBufferBindings = primitive.vertexBufferBindings;
|
|
639
635
|
this._attribLocArray.length = 0;
|
|
640
636
|
var attributeLocation = shaderProgram.attributeLocation;
|
|
641
|
-
// @ts-ignore
|
|
642
637
|
var attributes = primitive._vertexElementMap;
|
|
643
638
|
var vbo;
|
|
644
639
|
var lastBoundVbo;
|
|
@@ -677,10 +672,9 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
677
672
|
var gl = this._gl;
|
|
678
673
|
var vao = gl.createVertexArray();
|
|
679
674
|
/** register VAO */ gl.bindVertexArray(vao);
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _indexBufferBinding.buffer._platformBuffer._glBuffer);
|
|
675
|
+
var indexBufferBinding = this._primitive.indexBufferBinding;
|
|
676
|
+
if (indexBufferBinding) {
|
|
677
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBufferBinding.buffer._platformBuffer._glBuffer);
|
|
684
678
|
}
|
|
685
679
|
this._bindBufferAndAttrib(shaderProgram);
|
|
686
680
|
/** unbind */ gl.bindVertexArray(null);
|
|
@@ -1917,8 +1911,7 @@ exports.WebGLMode = void 0;
|
|
|
1917
1911
|
_proto.drawPrimitive = function drawPrimitive(primitive, subPrimitive, shaderProgram) {
|
|
1918
1912
|
// todo: VAO not support morph animation
|
|
1919
1913
|
if (primitive) {
|
|
1920
|
-
|
|
1921
|
-
primitive._draw(shaderProgram, subPrimitive);
|
|
1914
|
+
primitive.draw(shaderProgram, subPrimitive);
|
|
1922
1915
|
} else {
|
|
1923
1916
|
engineCore.Logger.error("draw primitive failed.");
|
|
1924
1917
|
}
|