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