@galacean/engine-rhi-webgl 2.0.0-alpha.51 → 2.0.0-alpha.53

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/module.js CHANGED
@@ -442,7 +442,7 @@ var GLBuffer = /*#__PURE__*/ function() {
442
442
  cap.set(bptc, !!requireExtension(bptc));
443
443
  var astcExtension = requireExtension(astc) || requireExtension(astc_webkit);
444
444
  cap.set(astc, !!astcExtension);
445
- cap.set(astc_hdr, !!(astcExtension == null ? void 0 : astcExtension.getSupportedProfiles().includes("hdr")));
445
+ cap.set(astc_hdr, typeof (astcExtension == null ? void 0 : astcExtension.getSupportedProfiles) === "function" && astcExtension.getSupportedProfiles().includes("hdr"));
446
446
  cap.set(sRGB, isWebGL2 || !!requireExtension(sRGB));
447
447
  };
448
448
  /**
@@ -1897,65 +1897,44 @@ var GLBuffer = /*#__PURE__*/ function() {
1897
1897
  return GLTransformFeedback;
1898
1898
  }();
1899
1899
 
1900
- function _array_like_to_array(arr, len) {
1901
- if (len == null || len > arr.length) len = arr.length;
1902
-
1903
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1904
-
1905
- return arr2;
1906
- }
1907
-
1908
- function _unsupported_iterable_to_array(o, minLen) {
1909
- if (!o) return;
1910
- if (typeof o === "string") return _array_like_to_array(o, minLen);
1911
-
1912
- var n = Object.prototype.toString.call(o).slice(8, -1);
1913
-
1914
- if (n === "Object" && o.constructor) n = o.constructor.name;
1915
- if (n === "Map" || n === "Set") return Array.from(n);
1916
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
1917
- }
1918
-
1919
- function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
1920
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1921
-
1922
- if (it) return (it = it.call(o)).next.bind(it);
1923
- // Fallback for engines without symbol support
1924
- if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
1925
- if (it) o = it;
1926
-
1927
- var i = 0;
1928
-
1929
- return function() {
1930
- if (i >= o.length) return { done: true };
1931
-
1932
- return { done: false, value: o[i++] };
1933
- };
1934
- }
1935
-
1936
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1937
- }
1938
-
1939
1900
  /**
1940
1901
  * @internal
1941
1902
  * WebGL2 implementation of Transform Feedback primitive.
1942
- * Maintains two VAOs (one per read direction), auto-rebuilds when program changes.
1903
+ * Maintains two VAOs (one per read direction), rebuilding when the program or input bindings change.
1943
1904
  */ var GLTransformFeedbackPrimitive = /*#__PURE__*/ function() {
1944
1905
  function GLTransformFeedbackPrimitive(gl) {
1945
1906
  this._lastProgramId = -1;
1907
+ this._lastInputBindings = [];
1946
1908
  this._gl = gl;
1947
1909
  }
1948
1910
  var _proto = GLTransformFeedbackPrimitive.prototype;
1949
- _proto.updateVertexLayout = function updateVertexLayout(program, readBinding, writeBinding, feedbackElements, inputBinding, inputElements) {
1950
- if (program.id === this._lastProgramId) return;
1951
- this._deleteVAOs();
1952
- var attribs = program.attributeLocation;
1953
- this._vaoA = this._createVAO(attribs, readBinding, feedbackElements, inputBinding, inputElements);
1954
- this._vaoB = this._createVAO(attribs, writeBinding, feedbackElements, inputBinding, inputElements);
1955
- this._lastProgramId = program.id;
1956
- this._gl.bindVertexArray(null);
1957
- };
1958
- _proto.bind = function bind(readIsA) {
1911
+ _proto.bind = function bind(program, bindingA, bindingB, feedbackElements, inputBindings, inputElements, readIsA) {
1912
+ var layoutChanged = program.id !== this._lastProgramId;
1913
+ var lastInputBindings = this._lastInputBindings;
1914
+ if (!layoutChanged) {
1915
+ if (inputBindings.length !== lastInputBindings.length) {
1916
+ layoutChanged = true;
1917
+ } else {
1918
+ for(var i = 0, n = inputBindings.length; i < n; i++){
1919
+ if (inputBindings[i] !== lastInputBindings[i]) {
1920
+ layoutChanged = true;
1921
+ break;
1922
+ }
1923
+ }
1924
+ }
1925
+ }
1926
+ if (layoutChanged) {
1927
+ this._deleteVAOs();
1928
+ var attribs = program.attributeLocation;
1929
+ this._vaoA = this._createVAO(attribs, bindingA, feedbackElements, inputBindings, inputElements);
1930
+ this._vaoB = this._createVAO(attribs, bindingB, feedbackElements, inputBindings, inputElements);
1931
+ this._lastProgramId = program.id;
1932
+ lastInputBindings.length = inputBindings.length;
1933
+ for(var i1 = 0, n1 = inputBindings.length; i1 < n1; i1++){
1934
+ lastInputBindings[i1] = inputBindings[i1];
1935
+ }
1936
+ this._gl.bindVertexArray(null);
1937
+ }
1959
1938
  this._gl.bindVertexArray(readIsA ? this._vaoA : this._vaoB);
1960
1939
  };
1961
1940
  _proto.unbind = function unbind() {
@@ -1981,27 +1960,36 @@ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
1981
1960
  this._vaoB = null;
1982
1961
  }
1983
1962
  this._lastProgramId = -1;
1963
+ this._lastInputBindings.length = 0;
1984
1964
  };
1985
- _proto._createVAO = function _createVAO(attribs, feedbackBinding, feedbackElements, inputBinding, inputElements) {
1965
+ _proto._createVAO = function _createVAO(attribs, feedbackBinding, feedbackElements, inputBindings, inputElements) {
1986
1966
  var gl = this._gl;
1987
1967
  var vao = gl.createVertexArray();
1988
1968
  gl.bindVertexArray(vao);
1989
1969
  gl.bindBuffer(gl.ARRAY_BUFFER, feedbackBinding.buffer._platformBuffer._glBuffer);
1990
- this._bindElements(gl, attribs, feedbackElements, feedbackBinding.stride);
1991
- gl.bindBuffer(gl.ARRAY_BUFFER, inputBinding.buffer._platformBuffer._glBuffer);
1992
- this._bindElements(gl, attribs, inputElements, inputBinding.stride);
1970
+ for(var i = 0, n = feedbackElements.length; i < n; i++){
1971
+ this._bindElement(attribs, feedbackElements[i], feedbackBinding.stride);
1972
+ }
1973
+ var lastInputBinding;
1974
+ for(var i1 = 0, n1 = inputElements.length; i1 < n1; i1++){
1975
+ var element = inputElements[i1];
1976
+ var inputBinding = inputBindings[element.bindingIndex];
1977
+ if (inputBinding !== lastInputBinding) {
1978
+ gl.bindBuffer(gl.ARRAY_BUFFER, inputBinding.buffer._platformBuffer._glBuffer);
1979
+ lastInputBinding = inputBinding;
1980
+ }
1981
+ this._bindElement(attribs, element, inputBinding.stride);
1982
+ }
1993
1983
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
1994
1984
  return vao;
1995
1985
  };
1996
- _proto._bindElements = function _bindElements(gl, attribs, elements, stride) {
1997
- for(var _iterator = _create_for_of_iterator_helper_loose(elements), _step; !(_step = _iterator()).done;){
1998
- var element = _step.value;
1999
- var loc = attribs[element.attribute];
2000
- if (loc !== undefined && loc !== -1) {
2001
- var info = element._formatMetaInfo;
2002
- gl.enableVertexAttribArray(loc);
2003
- gl.vertexAttribPointer(loc, info.size, info.type, info.normalized, stride, element.offset);
2004
- }
1986
+ _proto._bindElement = function _bindElement(attribs, element, stride) {
1987
+ var gl = this._gl;
1988
+ var loc = attribs[element.attribute];
1989
+ if (loc !== undefined && loc !== -1) {
1990
+ var info = element._formatMetaInfo;
1991
+ gl.enableVertexAttribArray(loc);
1992
+ gl.vertexAttribPointer(loc, info.size, info.type, info.normalized, stride, element.offset);
2005
1993
  }
2006
1994
  };
2007
1995
  return GLTransformFeedbackPrimitive;