Browse Source

Perf improvement for texture binding

David Catuhe 7 năm trước cách đây
mục cha
commit
3c06881cee
33 tập tin đã thay đổi với 18826 bổ sung18004 xóa
  1. 7891 7679
      Playground/babylon.d.txt
  2. 2 1
      Tools/Gulp/config.json
  3. 4543 4362
      dist/preview release/babylon.d.ts
  4. 49 49
      dist/preview release/babylon.js
  5. 123 16
      dist/preview release/babylon.max.js
  6. 50 50
      dist/preview release/babylon.worker.js
  7. 5433 5252
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  8. 53 53
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  9. 123 16
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  10. 125 18
      dist/preview release/customConfigurations/minimalGLTFViewer/es6.js
  11. 125 18
      dist/preview release/es6.js
  12. 3 3
      dist/preview release/gui/babylon.gui.min.js
  13. 4 4
      dist/preview release/inspector/babylon.inspector.bundle.js
  14. 3 3
      dist/preview release/inspector/babylon.inspector.min.js
  15. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  16. 2 2
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  17. 3 3
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  18. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  19. 3 3
      dist/preview release/loaders/babylonjs.loaders.min.js
  20. 1 1
      dist/preview release/materialsLibrary/babylon.customMaterial.min.js
  21. 1 1
      dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js
  22. 1 1
      dist/preview release/materialsLibrary/babylon.waterMaterial.min.js
  23. 3 3
      dist/preview release/materialsLibrary/babylonjs.materials.min.js
  24. 1 1
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  25. 1 1
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  26. 1 1
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js
  27. 1 1
      dist/preview release/serializers/babylon.glTF2Serializer.min.js
  28. 1 1
      dist/preview release/serializers/babylonjs.serializers.min.js
  29. 2 379
      dist/preview release/typedocValidationBaseline.json
  30. 59 59
      dist/preview release/viewer/babylon.viewer.js
  31. 33 18
      src/Engine/babylon.engine.ts
  32. 154 2
      src/Materials/Textures/babylon.internalTexture.ts
  33. 29 0
      src/Materials/Textures/babylon.internalTextureTracker.ts

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 7891 - 7679
Playground/babylon.d.txt


+ 2 - 1
Tools/Gulp/config.json

@@ -16,7 +16,7 @@
         "srcOutputDirectory": "../../src/",
         "currentConfig": "all",
         "typedocJSON": "../../.temp/babylon.typedoc.json",
-        "typedocValidationBaseline": "../../dist/preview release/typedocValidationBaseline.json" 
+        "typedocValidationBaseline": "../../dist/preview release/typedocValidationBaseline.json"
     },
     "buildConfigurations": {
         "all": [
@@ -195,6 +195,7 @@
                 "../../src/babylon.assetContainer.js",
                 "../../src/Mesh/babylon.buffer.js",
                 "../../src/Mesh/babylon.vertexBuffer.js",
+                "../../src/Materials/Textures/babylon.internalTextureTracker.js",
                 "../../src/Materials/Textures/babylon.internalTexture.js",
                 "../../src/Materials/Textures/babylon.baseTexture.js",
                 "../../src/Materials/Textures/babylon.texture.js",

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 4543 - 4362
dist/preview release/babylon.d.ts


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 49 - 49
dist/preview release/babylon.js


+ 123 - 16
dist/preview release/babylon.max.js

@@ -9013,7 +9013,6 @@ var BABYLON;
             this._activeChannel = 0;
             this._currentTextureChannel = -1;
             this._boundTexturesCache = {};
-            this._boundTexturesStack = new Array();
             this._compiledEffects = {};
             this._vertexAttribArraysEnabled = [];
             this._uintIndicesCurrentlySet = false;
@@ -9021,6 +9020,8 @@ var BABYLON;
             this._currentBufferPointers = new Array();
             this._currentInstanceLocations = new Array();
             this._currentInstanceBuffers = new Array();
+            this._firstBoundInternalTextureTracker = new BABYLON.DummyInternalTextureTracker();
+            this._lastBoundInternalTextureTracker = new BABYLON.DummyInternalTextureTracker();
             this._vaoRecordInProgress = false;
             this._mustWipeVertexAttributes = false;
             this._nextFreeTextureSlots = new Array();
@@ -9264,6 +9265,7 @@ var BABYLON;
             for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
                 this._currentBufferPointers[i] = new BufferPointer();
             }
+            this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
             // Load WebVR Devices
             if (options.autoEnableWebVR) {
                 this.initWebVR();
@@ -9599,7 +9601,7 @@ var BABYLON;
         });
         Object.defineProperty(Engine, "Version", {
             get: function () {
-                return "3.2.0-alpha4";
+                return "3.2.0-alpha5";
             },
             enumerable: true,
             configurable: true
@@ -12705,11 +12707,15 @@ var BABYLON;
             this._currentEffect = null;
         };
         Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
-            var index = this._boundTexturesStack.indexOf(internalTexture);
-            if (index > -1 && index !== this._boundTexturesStack.length - 1) {
-                this._boundTexturesStack.splice(index, 1);
-                this._boundTexturesStack.push(internalTexture);
+            if (this._lastBoundInternalTextureTracker.previous === internalTexture) {
+                return;
             }
+            // Remove
+            this._linkTrackers(internalTexture.previous, internalTexture.next);
+            // Bind last to it
+            this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
+            // Bind to dummy
+            this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
         };
         Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
             if (!internalTexture) {
@@ -12733,23 +12739,27 @@ var BABYLON;
                         }
                         // We need to recycle the oldest bound texture, sorry.
                         this._textureCollisions.addCount(1, false);
-                        return this._removeDesignatedSlot(this._boundTexturesStack[0]);
+                        return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
                     }
                 }
             }
             return channel;
         };
+        Engine.prototype._linkTrackers = function (previous, next) {
+            previous.next = next;
+            next.previous = previous;
+        };
         Engine.prototype._removeDesignatedSlot = function (internalTexture) {
             var currentSlot = internalTexture._designatedSlot;
-            internalTexture._designatedSlot = -1;
-            var index = this._boundTexturesStack.indexOf(internalTexture);
-            if (index > -1) {
-                this._boundTexturesStack.splice(index, 1);
-                if (currentSlot > -1) {
-                    this._boundTexturesCache[currentSlot] = null;
-                    this._nextFreeTextureSlots.push(currentSlot);
-                }
+            if (currentSlot === -1) {
+                return -1;
             }
+            internalTexture._designatedSlot = -1;
+            // Remove from bound list
+            this._linkTrackers(internalTexture.previous, internalTexture.next);
+            // Free the slot
+            this._boundTexturesCache[currentSlot] = null;
+            this._nextFreeTextureSlots.push(currentSlot);
             return currentSlot;
         };
         Engine.prototype._activateCurrentTexture = function () {
@@ -12778,7 +12788,8 @@ var BABYLON;
                         if (slotIndex > -1) {
                             this._nextFreeTextureSlots.splice(slotIndex, 1);
                         }
-                        this._boundTexturesStack.push(texture);
+                        this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
+                        this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
                     }
                     texture._designatedSlot = this._activeChannel;
                 }
@@ -23792,28 +23803,87 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
+    /**
+     * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
+     */
+    var DummyInternalTextureTracker = /** @class */ (function () {
+        function DummyInternalTextureTracker() {
+            /**
+             * Gets or set the previous tracker in the list
+             */
+            this.previous = null;
+            /**
+             * Gets or set the next tracker in the list
+             */
+            this.next = null;
+        }
+        return DummyInternalTextureTracker;
+    }());
+    BABYLON.DummyInternalTextureTracker = DummyInternalTextureTracker;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.internalTextureTracker.js.map
+
+var BABYLON;
+(function (BABYLON) {
+    /**
+     * Class used to store data associated with WebGL texture data for the engine
+     * This class should not be used directly
+     */
     var InternalTexture = /** @class */ (function () {
+        /**
+         * Creates a new InternalTexture
+         * @param engine defines the engine to use
+         * @param dataSource defines the type of data that will be used
+         */
         function InternalTexture(engine, dataSource) {
+            /**
+             * Observable called when the texture is loaded
+             */
             this.onLoadedObservable = new BABYLON.Observable();
+            /**
+             * Gets or set the previous tracker in the list
+             */
+            this.previous = null;
+            /**
+             * Gets or set the next tracker in the list
+             */
+            this.next = null;
             // Private
+            /** @ignore */
             this._initialSlot = -1;
+            /** @ignore */
             this._designatedSlot = -1;
+            /** @ignore */
             this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
+            /** @ignore */
             this._references = 1;
             this._engine = engine;
             this._dataSource = dataSource;
             this._webGLTexture = engine._createTexture();
         }
         Object.defineProperty(InternalTexture.prototype, "dataSource", {
+            /**
+             * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
+             */
             get: function () {
                 return this._dataSource;
             },
             enumerable: true,
             configurable: true
         });
+        /**
+         * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
+         */
         InternalTexture.prototype.incrementReferences = function () {
             this._references++;
         };
+        /**
+         * Change the size of the texture (not the size of the content)
+         * @param width defines the new width
+         * @param height defines the new height
+         * @param depth defines the new depth (1 by default)
+         */
         InternalTexture.prototype.updateSize = function (width, height, depth) {
             if (depth === void 0) { depth = 1; }
             this.width = width;
@@ -23824,6 +23894,7 @@ var BABYLON;
             this.baseDepth = depth;
             this._size = width * height * depth;
         };
+        /** @ignore */
         InternalTexture.prototype._rebuild = function () {
             var _this = this;
             var proxy;
@@ -23929,6 +24000,9 @@ var BABYLON;
                 cache.splice(index, 1);
             }
         };
+        /**
+         * Dispose the current allocated resources
+         */
         InternalTexture.prototype.dispose = function () {
             if (!this._webGLTexture) {
                 return;
@@ -23939,16 +24013,49 @@ var BABYLON;
                 this._webGLTexture = null;
             }
         };
+        /**
+         * The source of the texture data is unknown
+         */
         InternalTexture.DATASOURCE_UNKNOWN = 0;
+        /**
+         * Texture data comes from an URL
+         */
         InternalTexture.DATASOURCE_URL = 1;
+        /**
+         * Texture data is only used for temporary storage
+         */
         InternalTexture.DATASOURCE_TEMP = 2;
+        /**
+         * Texture data comes from raw data (ArrayBuffer)
+         */
         InternalTexture.DATASOURCE_RAW = 3;
+        /**
+         * Texture content is dynamic (video or dynamic texture)
+         */
         InternalTexture.DATASOURCE_DYNAMIC = 4;
+        /**
+         * Texture content is generated by rendering to it
+         */
         InternalTexture.DATASOURCE_RENDERTARGET = 5;
+        /**
+         * Texture content is part of a multi render target process
+         */
         InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
+        /**
+         * Texture data comes from a cube data file
+         */
         InternalTexture.DATASOURCE_CUBE = 7;
+        /**
+         * Texture data comes from a raw cube data
+         */
         InternalTexture.DATASOURCE_CUBERAW = 8;
+        /**
+         * Texture data come from a prefiltered cube data file
+         */
         InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
+        /**
+         * Texture content is raw 3D data
+         */
         InternalTexture.DATASOURCE_RAW3D = 10;
         return InternalTexture;
     }());

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 50 - 50
dist/preview release/babylon.worker.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 5433 - 5252
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 53 - 53
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 123 - 16
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -9013,7 +9013,6 @@ var BABYLON;
             this._activeChannel = 0;
             this._currentTextureChannel = -1;
             this._boundTexturesCache = {};
-            this._boundTexturesStack = new Array();
             this._compiledEffects = {};
             this._vertexAttribArraysEnabled = [];
             this._uintIndicesCurrentlySet = false;
@@ -9021,6 +9020,8 @@ var BABYLON;
             this._currentBufferPointers = new Array();
             this._currentInstanceLocations = new Array();
             this._currentInstanceBuffers = new Array();
+            this._firstBoundInternalTextureTracker = new BABYLON.DummyInternalTextureTracker();
+            this._lastBoundInternalTextureTracker = new BABYLON.DummyInternalTextureTracker();
             this._vaoRecordInProgress = false;
             this._mustWipeVertexAttributes = false;
             this._nextFreeTextureSlots = new Array();
@@ -9264,6 +9265,7 @@ var BABYLON;
             for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
                 this._currentBufferPointers[i] = new BufferPointer();
             }
+            this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
             // Load WebVR Devices
             if (options.autoEnableWebVR) {
                 this.initWebVR();
@@ -9599,7 +9601,7 @@ var BABYLON;
         });
         Object.defineProperty(Engine, "Version", {
             get: function () {
-                return "3.2.0-alpha4";
+                return "3.2.0-alpha5";
             },
             enumerable: true,
             configurable: true
@@ -12705,11 +12707,15 @@ var BABYLON;
             this._currentEffect = null;
         };
         Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
-            var index = this._boundTexturesStack.indexOf(internalTexture);
-            if (index > -1 && index !== this._boundTexturesStack.length - 1) {
-                this._boundTexturesStack.splice(index, 1);
-                this._boundTexturesStack.push(internalTexture);
+            if (this._lastBoundInternalTextureTracker.previous === internalTexture) {
+                return;
             }
+            // Remove
+            this._linkTrackers(internalTexture.previous, internalTexture.next);
+            // Bind last to it
+            this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
+            // Bind to dummy
+            this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
         };
         Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
             if (!internalTexture) {
@@ -12733,23 +12739,27 @@ var BABYLON;
                         }
                         // We need to recycle the oldest bound texture, sorry.
                         this._textureCollisions.addCount(1, false);
-                        return this._removeDesignatedSlot(this._boundTexturesStack[0]);
+                        return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
                     }
                 }
             }
             return channel;
         };
+        Engine.prototype._linkTrackers = function (previous, next) {
+            previous.next = next;
+            next.previous = previous;
+        };
         Engine.prototype._removeDesignatedSlot = function (internalTexture) {
             var currentSlot = internalTexture._designatedSlot;
-            internalTexture._designatedSlot = -1;
-            var index = this._boundTexturesStack.indexOf(internalTexture);
-            if (index > -1) {
-                this._boundTexturesStack.splice(index, 1);
-                if (currentSlot > -1) {
-                    this._boundTexturesCache[currentSlot] = null;
-                    this._nextFreeTextureSlots.push(currentSlot);
-                }
+            if (currentSlot === -1) {
+                return -1;
             }
+            internalTexture._designatedSlot = -1;
+            // Remove from bound list
+            this._linkTrackers(internalTexture.previous, internalTexture.next);
+            // Free the slot
+            this._boundTexturesCache[currentSlot] = null;
+            this._nextFreeTextureSlots.push(currentSlot);
             return currentSlot;
         };
         Engine.prototype._activateCurrentTexture = function () {
@@ -12778,7 +12788,8 @@ var BABYLON;
                         if (slotIndex > -1) {
                             this._nextFreeTextureSlots.splice(slotIndex, 1);
                         }
-                        this._boundTexturesStack.push(texture);
+                        this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
+                        this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
                     }
                     texture._designatedSlot = this._activeChannel;
                 }
@@ -23792,28 +23803,87 @@ var BABYLON;
 
 var BABYLON;
 (function (BABYLON) {
+    /**
+     * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
+     */
+    var DummyInternalTextureTracker = /** @class */ (function () {
+        function DummyInternalTextureTracker() {
+            /**
+             * Gets or set the previous tracker in the list
+             */
+            this.previous = null;
+            /**
+             * Gets or set the next tracker in the list
+             */
+            this.next = null;
+        }
+        return DummyInternalTextureTracker;
+    }());
+    BABYLON.DummyInternalTextureTracker = DummyInternalTextureTracker;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.internalTextureTracker.js.map
+
+var BABYLON;
+(function (BABYLON) {
+    /**
+     * Class used to store data associated with WebGL texture data for the engine
+     * This class should not be used directly
+     */
     var InternalTexture = /** @class */ (function () {
+        /**
+         * Creates a new InternalTexture
+         * @param engine defines the engine to use
+         * @param dataSource defines the type of data that will be used
+         */
         function InternalTexture(engine, dataSource) {
+            /**
+             * Observable called when the texture is loaded
+             */
             this.onLoadedObservable = new BABYLON.Observable();
+            /**
+             * Gets or set the previous tracker in the list
+             */
+            this.previous = null;
+            /**
+             * Gets or set the next tracker in the list
+             */
+            this.next = null;
             // Private
+            /** @ignore */
             this._initialSlot = -1;
+            /** @ignore */
             this._designatedSlot = -1;
+            /** @ignore */
             this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
+            /** @ignore */
             this._references = 1;
             this._engine = engine;
             this._dataSource = dataSource;
             this._webGLTexture = engine._createTexture();
         }
         Object.defineProperty(InternalTexture.prototype, "dataSource", {
+            /**
+             * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
+             */
             get: function () {
                 return this._dataSource;
             },
             enumerable: true,
             configurable: true
         });
+        /**
+         * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
+         */
         InternalTexture.prototype.incrementReferences = function () {
             this._references++;
         };
+        /**
+         * Change the size of the texture (not the size of the content)
+         * @param width defines the new width
+         * @param height defines the new height
+         * @param depth defines the new depth (1 by default)
+         */
         InternalTexture.prototype.updateSize = function (width, height, depth) {
             if (depth === void 0) { depth = 1; }
             this.width = width;
@@ -23824,6 +23894,7 @@ var BABYLON;
             this.baseDepth = depth;
             this._size = width * height * depth;
         };
+        /** @ignore */
         InternalTexture.prototype._rebuild = function () {
             var _this = this;
             var proxy;
@@ -23929,6 +24000,9 @@ var BABYLON;
                 cache.splice(index, 1);
             }
         };
+        /**
+         * Dispose the current allocated resources
+         */
         InternalTexture.prototype.dispose = function () {
             if (!this._webGLTexture) {
                 return;
@@ -23939,16 +24013,49 @@ var BABYLON;
                 this._webGLTexture = null;
             }
         };
+        /**
+         * The source of the texture data is unknown
+         */
         InternalTexture.DATASOURCE_UNKNOWN = 0;
+        /**
+         * Texture data comes from an URL
+         */
         InternalTexture.DATASOURCE_URL = 1;
+        /**
+         * Texture data is only used for temporary storage
+         */
         InternalTexture.DATASOURCE_TEMP = 2;
+        /**
+         * Texture data comes from raw data (ArrayBuffer)
+         */
         InternalTexture.DATASOURCE_RAW = 3;
+        /**
+         * Texture content is dynamic (video or dynamic texture)
+         */
         InternalTexture.DATASOURCE_DYNAMIC = 4;
+        /**
+         * Texture content is generated by rendering to it
+         */
         InternalTexture.DATASOURCE_RENDERTARGET = 5;
+        /**
+         * Texture content is part of a multi render target process
+         */
         InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
+        /**
+         * Texture data comes from a cube data file
+         */
         InternalTexture.DATASOURCE_CUBE = 7;
+        /**
+         * Texture data comes from a raw cube data
+         */
         InternalTexture.DATASOURCE_CUBERAW = 8;
+        /**
+         * Texture data come from a prefiltered cube data file
+         */
         InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
+        /**
+         * Texture content is raw 3D data
+         */
         InternalTexture.DATASOURCE_RAW3D = 10;
         return InternalTexture;
     }());

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 125 - 18
dist/preview release/customConfigurations/minimalGLTFViewer/es6.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 125 - 18
dist/preview release/es6.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 3 - 3
dist/preview release/gui/babylon.gui.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 4 - 4
dist/preview release/inspector/babylon.inspector.bundle.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 3 - 3
dist/preview release/inspector/babylon.inspector.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 2 - 2
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 2 - 2
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 3 - 3
dist/preview release/loaders/babylon.glTFFileLoader.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 3 - 3
dist/preview release/loaders/babylonjs.loaders.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/materialsLibrary/babylon.customMaterial.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/materialsLibrary/babylon.waterMaterial.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 3 - 3
dist/preview release/materialsLibrary/babylonjs.materials.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/serializers/babylon.glTF2Serializer.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/serializers/babylonjs.serializers.min.js


+ 2 - 379
dist/preview release/typedocValidationBaseline.json

@@ -1,7 +1,7 @@
 {
-  "errors": 10946,
+  "errors": 10873,
   "babylon.typedoc.json": {
-    "errors": 10946,
+    "errors": 10873,
     "AnimationKeyInterpolation": {
       "Enumeration": {
         "Comments": {
@@ -21293,383 +21293,6 @@
         }
       }
     },
-    "InternalTexture": {
-      "Class": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Constructor": {
-        "new InternalTexture": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "engine": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "dataSource": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      },
-      "Property": {
-        "_MSAAFramebuffer": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_MSAARenderBuffer": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_attachments": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_buffer": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_bufferView": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_bufferViewArray": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_cachedAnisotropicFilteringLevel": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_cachedCoordinatesMode": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_cachedWrapR": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_cachedWrapU": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_cachedWrapV": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_compression": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_dataSource": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_depthStencilBuffer": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_designatedSlot": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_extension": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_files": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_framebuffer": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_generateDepthBuffer": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_generateStencilBuffer": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_initialSlot": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_isDisabled": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_lodGenerationOffset": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_lodGenerationScale": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_lodTextureHigh": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_lodTextureLow": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_lodTextureMid": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_references": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_size": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_sphericalPolynomial": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_webGLTexture": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_workingCanvas": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "_workingContext": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "baseDepth": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "baseHeight": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "baseWidth": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "dataSource": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "depth": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "format": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "generateMipMaps": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "height": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "invertY": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "is3D": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "isCube": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "isReady": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "onLoadedObservable": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "samples": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "samplingMode": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "type": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "url": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "width": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "DATASOURCE_CUBE": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "DATASOURCE_CUBEPREFILTERED": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "DATASOURCE_CUBERAW": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "DATASOURCE_DYNAMIC": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "DATASOURCE_MULTIRENDERTARGET": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "DATASOURCE_RAW": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "DATASOURCE_RAW3D": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "DATASOURCE_RENDERTARGET": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "DATASOURCE_TEMP": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "DATASOURCE_UNKNOWN": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "DATASOURCE_URL": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "_rebuild": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "dispose": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "incrementReferences": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "updateSize": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "width": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "height": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "depth": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        }
-      }
-    },
     "InterpolateValueAction": {
       "Class": {
         "Comments": {

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 59 - 59
dist/preview release/viewer/babylon.viewer.js


+ 33 - 18
src/Engine/babylon.engine.ts

@@ -539,7 +539,7 @@
         }
 
         public static get Version(): string {
-            return "3.2.0-alpha4";
+            return "3.2.0-alpha5";
         }
 
         // Updatable statics so stick with vars here
@@ -733,7 +733,6 @@
         protected _activeChannel = 0;
         private _currentTextureChannel = -1;
         protected _boundTexturesCache: { [key: string]: Nullable<InternalTexture> } = {};
-        protected _boundTexturesStack = new Array<InternalTexture>();
         protected _currentEffect: Nullable<Effect>;
         protected _currentProgram: Nullable<WebGLProgram>;
         private _compiledEffects: { [key: string]: Effect } = {}
@@ -751,6 +750,8 @@
         private _currentInstanceLocations = new Array<number>();
         private _currentInstanceBuffers = new Array<WebGLBuffer>();
         private _textureUnits: Int32Array;
+        private _firstBoundInternalTextureTracker = new DummyInternalTextureTracker();
+        private _lastBoundInternalTextureTracker = new DummyInternalTextureTracker();
 
         private _workingCanvas: Nullable<HTMLCanvasElement>;
         private _workingContext: Nullable<CanvasRenderingContext2D>;
@@ -1091,6 +1092,8 @@
                 this._currentBufferPointers[i] = new BufferPointer();
             }
 
+            this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
+
             // Load WebVR Devices
             if (options.autoEnableWebVR) {
                 this.initWebVR();
@@ -4740,14 +4743,19 @@
         }
 
         private _moveBoundTextureOnTop(internalTexture: InternalTexture): void {
-            let index = this._boundTexturesStack.indexOf(internalTexture);
-
-            if (index > -1 && index !== this._boundTexturesStack.length - 1) {
-                this._boundTexturesStack.splice(index, 1);
-                this._boundTexturesStack.push(internalTexture);
+            if (this._lastBoundInternalTextureTracker.previous === internalTexture) {
+                return;
             }
-        }
 
+            // Remove
+            this._linkTrackers(internalTexture.previous, internalTexture.next);
+
+            // Bind last to it
+            this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
+
+            // Bind to dummy
+            this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
+        }
 
         private _getCorrectTextureChannel(channel: number, internalTexture: Nullable<InternalTexture>): number {
             if (!internalTexture) {
@@ -4772,7 +4780,7 @@
 
                         // We need to recycle the oldest bound texture, sorry.
                         this._textureCollisions.addCount(1, false);
-                        return this._removeDesignatedSlot(this._boundTexturesStack[0]);
+                        return this._removeDesignatedSlot(<InternalTexture>this._firstBoundInternalTextureTracker.next);
                     }
                 }
             }
@@ -4780,20 +4788,25 @@
             return channel;
         }
 
+        private _linkTrackers(previous: Nullable<IInternalTextureTracker>, next: Nullable<IInternalTextureTracker>) {
+            previous!.next = next;
+            next!.previous = previous;
+        }
 
         private _removeDesignatedSlot(internalTexture: InternalTexture): number {
             let currentSlot = internalTexture._designatedSlot;
+            if (currentSlot === -1) {
+                return -1;
+            }
 
             internalTexture._designatedSlot = -1;
-            let index = this._boundTexturesStack.indexOf(internalTexture);
 
-            if (index > -1) {
-                this._boundTexturesStack.splice(index, 1);
-                if (currentSlot > -1) {
-                    this._boundTexturesCache[currentSlot] = null;
-                    this._nextFreeTextureSlots.push(currentSlot);
-                }
-            }
+            // Remove from bound list
+            this._linkTrackers(internalTexture.previous, internalTexture.next);
+
+            // Free the slot
+            this._boundTexturesCache[currentSlot] = null;
+            this._nextFreeTextureSlots.push(currentSlot);
 
             return currentSlot;
         }
@@ -4829,7 +4842,9 @@
                         if (slotIndex > -1) {
                             this._nextFreeTextureSlots.splice(slotIndex, 1);
                         }
-                        this._boundTexturesStack.push(texture);
+
+                        this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
+                        this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
                     }
 
                     texture._designatedSlot = this._activeChannel;

+ 154 - 2
src/Materials/Textures/babylon.internalTexture.ts

@@ -1,80 +1,219 @@
 module BABYLON {
-    export class InternalTexture {
-
+    /**
+     * Class used to store data associated with WebGL texture data for the engine
+     * This class should not be used directly
+     */
+    export class InternalTexture implements IInternalTextureTracker {
+
+        /**
+         * The source of the texture data is unknown
+         */
         public static DATASOURCE_UNKNOWN = 0;
+        /**
+         * Texture data comes from an URL
+         */
         public static DATASOURCE_URL = 1;
+        /**
+         * Texture data is only used for temporary storage
+         */
         public static DATASOURCE_TEMP = 2;
+        /**
+         * Texture data comes from raw data (ArrayBuffer)
+         */
         public static DATASOURCE_RAW = 3;
+        /**
+         * Texture content is dynamic (video or dynamic texture)
+         */
         public static DATASOURCE_DYNAMIC = 4;
+        /**
+         * Texture content is generated by rendering to it
+         */
         public static DATASOURCE_RENDERTARGET = 5;
+        /**
+         * Texture content is part of a multi render target process
+         */
         public static DATASOURCE_MULTIRENDERTARGET = 6;
+        /**
+         * Texture data comes from a cube data file
+         */
         public static DATASOURCE_CUBE = 7;
+        /**
+         * Texture data comes from a raw cube data
+         */
         public static DATASOURCE_CUBERAW = 8;
+        /**
+         * Texture data come from a prefiltered cube data file
+         */
         public static DATASOURCE_CUBEPREFILTERED = 9;
+        /**
+         * Texture content is raw 3D data
+         */
         public static DATASOURCE_RAW3D = 10;
 
+        /**
+         * Defines if the texture is ready
+         */
         public isReady: boolean;
+        /**
+         * Defines if the texture is a cube texture
+         */
         public isCube: boolean;
+        /**
+         * Defines if the texture contains 3D data
+         */
         public is3D: boolean;
+        /**
+         * Gets the URL used to load this texture
+         */
         public url: string;
+        /**
+         * Gets the sampling mode of the texture
+         */
         public samplingMode: number;
+        /**
+         * Gets a boolean indicating if the texture needs mipmaps generation
+         */
         public generateMipMaps: boolean;
+        /**
+         * Gets the number of samples used by the texture (WebGL2+ only)
+         */
         public samples: number;
+        /**
+         * Gets the type of the texture
+         */
         public type: number;
+        /**
+         * Gets the format of the texture 
+         */
         public format: number;
+        /**
+         * Observable called when the texture is loaded
+         */
         public onLoadedObservable = new Observable<InternalTexture>();
+        /**
+         * Gets the width of the texture
+         */
         public width: number;
+        /**
+         * Gets the height of the texture
+         */
         public height: number;
+        /**
+         * Gets the depth of the texture
+         */
         public depth: number;
+        /**
+         * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
+         */
         public baseWidth: number;
+        /**
+         * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
+         */
         public baseHeight: number;
+        /**
+         * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
+         */
         public baseDepth: number;
+        /**
+         * Gets a boolean indicating if the texture is inverted on Y axis
+         */
         public invertY: boolean;
 
+        /**
+         * Gets or set the previous tracker in the list
+         */
+        public previous: Nullable<IInternalTextureTracker> = null
+        /**
+         * Gets or set the next tracker in the list
+         */
+        public next: Nullable<IInternalTextureTracker> = null
+
         // Private
+        /** @ignore */
         public _initialSlot = -1;
+        /** @ignore */
         public _designatedSlot = -1;
+        /** @ignore */
         public _dataSource = InternalTexture.DATASOURCE_UNKNOWN;
+        /** @ignore */
         public _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
+        /** @ignore */
         public _bufferView: Nullable<ArrayBufferView>;
+        /** @ignore */
         public _bufferViewArray: Nullable<ArrayBufferView[]>;
+        /** @ignore */
         public _size: number;
+        /** @ignore */
         public _extension: string;
+        /** @ignore */
         public _files: Nullable<string[]>;
+        /** @ignore */
         public _workingCanvas: HTMLCanvasElement;
+        /** @ignore */
         public _workingContext: CanvasRenderingContext2D;
+        /** @ignore */
         public _framebuffer: Nullable<WebGLFramebuffer>;
+        /** @ignore */
         public _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
+        /** @ignore */
         public _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
+        /** @ignore */
         public _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
+        /** @ignore */
         public _attachments: Nullable<number[]>;
+        /** @ignore */
         public _cachedCoordinatesMode: Nullable<number>;
+        /** @ignore */
         public _cachedWrapU: Nullable<number>;
+        /** @ignore */
         public _cachedWrapV: Nullable<number>;
+        /** @ignore */
         public _cachedWrapR: Nullable<number>;
+        /** @ignore */
         public _cachedAnisotropicFilteringLevel: Nullable<number>;
+        /** @ignore */
         public _isDisabled: boolean;
+        /** @ignore */
         public _compression: Nullable<string>;
+        /** @ignore */
         public _generateStencilBuffer: boolean;
+        /** @ignore */
         public _generateDepthBuffer: boolean;
+        /** @ignore */
         public _sphericalPolynomial: Nullable<SphericalPolynomial>;
+        /** @ignore */
         public _lodGenerationScale: number;
+        /** @ignore */
         public _lodGenerationOffset: number;
+
         // The following three fields helps sharing generated fixed LODs for texture filtering
         // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.
         // They are at the level of the gl texture to benefit from the cache.
+        /** @ignore */
         public _lodTextureHigh: BaseTexture;
+        /** @ignore */
         public _lodTextureMid: BaseTexture;
+        /** @ignore */
         public _lodTextureLow: BaseTexture;
 
+        /** @ignore */
         public _webGLTexture: Nullable<WebGLTexture>;
+        /** @ignore */
         public _references: number = 1;
         private _engine: Engine;
 
+        /**
+         * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
+         */
         public get dataSource(): number {
             return this._dataSource;
         }
 
+        /**
+         * Creates a new InternalTexture
+         * @param engine defines the engine to use
+         * @param dataSource defines the type of data that will be used
+         */
         constructor(engine: Engine, dataSource: number) {
             this._engine = engine;
             this._dataSource = dataSource;
@@ -82,10 +221,19 @@ module BABYLON {
             this._webGLTexture = engine._createTexture();
         }
 
+        /**
+         * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
+         */
         public incrementReferences(): void {
             this._references++;
         }
 
+        /**
+         * Change the size of the texture (not the size of the content)
+         * @param width defines the new width
+         * @param height defines the new height
+         * @param depth defines the new depth (1 by default)
+         */
         public updateSize(width: int, height: int, depth: int = 1): void {
             this.width = width;
             this.height = height;
@@ -98,6 +246,7 @@ module BABYLON {
             this._size = width * height * depth;
         }
 
+        /** @ignore */
         public _rebuild(): void {
             var proxy: InternalTexture;
             this.isReady = false;
@@ -228,6 +377,9 @@ module BABYLON {
             }
         }
 
+        /**
+         * Dispose the current allocated resources
+         */
         public dispose(): void {
             if (!this._webGLTexture) {
                 return;

+ 29 - 0
src/Materials/Textures/babylon.internalTextureTracker.ts

@@ -0,0 +1,29 @@
+module BABYLON {
+    /**
+     * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
+     */
+    export interface IInternalTextureTracker {
+        /**
+         * Gets or set the previous tracker in the list
+         */
+        previous: Nullable<IInternalTextureTracker>;
+        /**
+         * Gets or set the next tracker in the list
+         */
+        next: Nullable<IInternalTextureTracker>;
+    }
+
+    /**
+     * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
+     */
+    export class DummyInternalTextureTracker {
+        /**
+         * Gets or set the previous tracker in the list
+         */
+        public previous: Nullable<IInternalTextureTracker> = null;
+        /**
+         * Gets or set the next tracker in the list
+         */
+        public next: Nullable<IInternalTextureTracker> = null;
+    }
+}