浏览代码

Add new engine.disableUniformBuffers to disable uniform buffers with webgl2
Fixes #2721

David Catuhe 8 年之前
父节点
当前提交
8535f530bc

文件差异内容过多而无法显示
+ 3560 - 3558
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 16 - 16
dist/preview release/babylon.js


+ 13 - 5
dist/preview release/babylon.max.js

@@ -7463,6 +7463,7 @@ var BABYLON;
              */
             this.onCanvasBlurObservable = new BABYLON.Observable();
             // Uniform buffers list
+            this.disableUniformBuffers = false;
             this._uniformBuffers = new Array();
             this._windowIsBackground = false;
             this._webGLVersion = 1.0;
@@ -8035,6 +8036,13 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
+            get: function () {
+                return this.webGLVersion > 1 && !this.disableUniformBuffers;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Engine.prototype, "needPOTTextures", {
             get: function () {
                 return this._webGLVersion < 2 || this.forcePOTTextures;
@@ -24373,7 +24381,7 @@ var BABYLON;
                 // Uniform declaration
                 if (includeFile.indexOf("__decl__") !== -1) {
                     includeFile = includeFile.replace(/__decl__/, "");
-                    if (this._engine.webGLVersion != 1) {
+                    if (this._engine.supportsUniformBuffers) {
                         includeFile = includeFile.replace(/Vertex/, "Ubo");
                         includeFile = includeFile.replace(/Fragment/, "Ubo");
                     }
@@ -24402,7 +24410,7 @@ var BABYLON;
                                 maxIndex = this._indexParameters[indexSplits[1]];
                             }
                             for (var i = minIndex; i < maxIndex; i++) {
-                                if (this._engine.webGLVersion === 1) {
+                                if (!this._engine.supportsUniformBuffers) {
                                     // Ubo replacement
                                     sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
                                         return p1 + "{X}";
@@ -24412,7 +24420,7 @@ var BABYLON;
                             }
                         }
                         else {
-                            if (this._engine.webGLVersion === 1) {
+                            if (!this._engine.supportsUniformBuffers) {
                                 // Ubo replacement
                                 includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
                                     return p1 + "{X}";
@@ -25327,7 +25335,7 @@ var BABYLON;
                 this.sideOrientation = Material.CounterClockWiseSideOrientation;
             }
             this._uniformBuffer = new BABYLON.UniformBuffer(this._scene.getEngine());
-            this._useUBO = this.getScene().getEngine().webGLVersion > 1;
+            this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
             if (!doNotAdd) {
                 this._scene.materials.push(this);
             }
@@ -25873,7 +25881,7 @@ var BABYLON;
          */
         function UniformBuffer(engine, data, dynamic) {
             this._engine = engine;
-            this._noUBO = engine.webGLVersion === 1;
+            this._noUBO = !engine.supportsUniformBuffers;
             this._dynamic = dynamic;
             this._data = data || [];
             this._uniformLocations = {};

文件差异内容过多而无法显示
+ 3560 - 3558
dist/preview release/babylon.module.d.ts


文件差异内容过多而无法显示
+ 16 - 16
dist/preview release/babylon.worker.js


文件差异内容过多而无法显示
+ 1318 - 1316
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


文件差异内容过多而无法显示
+ 15 - 15
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 13 - 5
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -7463,6 +7463,7 @@ var BABYLON;
              */
             this.onCanvasBlurObservable = new BABYLON.Observable();
             // Uniform buffers list
+            this.disableUniformBuffers = false;
             this._uniformBuffers = new Array();
             this._windowIsBackground = false;
             this._webGLVersion = 1.0;
@@ -8035,6 +8036,13 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
+            get: function () {
+                return this.webGLVersion > 1 && !this.disableUniformBuffers;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Engine.prototype, "needPOTTextures", {
             get: function () {
                 return this._webGLVersion < 2 || this.forcePOTTextures;
@@ -24373,7 +24381,7 @@ var BABYLON;
                 // Uniform declaration
                 if (includeFile.indexOf("__decl__") !== -1) {
                     includeFile = includeFile.replace(/__decl__/, "");
-                    if (this._engine.webGLVersion != 1) {
+                    if (this._engine.supportsUniformBuffers) {
                         includeFile = includeFile.replace(/Vertex/, "Ubo");
                         includeFile = includeFile.replace(/Fragment/, "Ubo");
                     }
@@ -24402,7 +24410,7 @@ var BABYLON;
                                 maxIndex = this._indexParameters[indexSplits[1]];
                             }
                             for (var i = minIndex; i < maxIndex; i++) {
-                                if (this._engine.webGLVersion === 1) {
+                                if (!this._engine.supportsUniformBuffers) {
                                     // Ubo replacement
                                     sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
                                         return p1 + "{X}";
@@ -24412,7 +24420,7 @@ var BABYLON;
                             }
                         }
                         else {
-                            if (this._engine.webGLVersion === 1) {
+                            if (!this._engine.supportsUniformBuffers) {
                                 // Ubo replacement
                                 includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
                                     return p1 + "{X}";
@@ -25327,7 +25335,7 @@ var BABYLON;
                 this.sideOrientation = Material.CounterClockWiseSideOrientation;
             }
             this._uniformBuffer = new BABYLON.UniformBuffer(this._scene.getEngine());
-            this._useUBO = this.getScene().getEngine().webGLVersion > 1;
+            this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
             if (!doNotAdd) {
                 this._scene.materials.push(this);
             }
@@ -25873,7 +25881,7 @@ var BABYLON;
          */
         function UniformBuffer(engine, data, dynamic) {
             this._engine = engine;
-            this._noUBO = engine.webGLVersion === 1;
+            this._noUBO = !engine.supportsUniformBuffers;
             this._dynamic = dynamic;
             this._data = data || [];
             this._uniformLocations = {};

文件差异内容过多而无法显示
+ 1318 - 1316
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


+ 1 - 1
localDev/index.html

@@ -43,7 +43,7 @@
 	
 	<script>
 		var canvas = document.getElementById("renderCanvas");
-		canvas = WebGLDebugUtils.makeLostContextSimulatingCanvas(canvas);
+		// canvas = WebGLDebugUtils.makeLostContextSimulatingCanvas(canvas);
 		var divFps = document.getElementById("fps");
 
 		// Global to simulate PG.

+ 3 - 3
src/Materials/babylon.effect.ts

@@ -416,7 +416,7 @@
                 // Uniform declaration
                 if (includeFile.indexOf("__decl__") !== -1) {
                     includeFile = includeFile.replace(/__decl__/, "");
-                    if (this._engine.webGLVersion != 1) {
+                    if (this._engine.supportsUniformBuffers) {
                         includeFile = includeFile.replace(/Vertex/, "Ubo");
                         includeFile = includeFile.replace(/Fragment/, "Ubo");
                     }
@@ -452,7 +452,7 @@
                             }
 
                             for (var i = minIndex; i < maxIndex; i++) {
-                                if (this._engine.webGLVersion === 1) {
+                                if (!this._engine.supportsUniformBuffers) {
                                     // Ubo replacement
                                     sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, (str: string, p1: string) => {
                                         return p1 + "{X}";
@@ -461,7 +461,7 @@
                                 includeContent += sourceIncludeContent.replace(/\{X\}/g, i) + "\n";
                             }
                         } else {
-                            if (this._engine.webGLVersion === 1) {
+                            if (!this._engine.supportsUniformBuffers) {
                                 // Ubo replacement
                                 includeContent = includeContent.replace(/light\{X\}.(\w*)/g, (str: string, p1: string) => {
                                     return p1 + "{X}";

+ 1 - 1
src/Materials/babylon.material.ts

@@ -360,7 +360,7 @@
             }
 
             this._uniformBuffer = new UniformBuffer(this._scene.getEngine());
-            this._useUBO = this.getScene().getEngine().webGLVersion > 1;
+            this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
 
             if (!doNotAdd) {
                 this._scene.materials.push(this);

+ 1 - 1
src/Materials/babylon.uniformBuffer.ts

@@ -121,7 +121,7 @@ module BABYLON {
          */
         constructor(engine: Engine, data?: number[], dynamic?: boolean) {
             this._engine = engine;
-            this._noUBO = engine.webGLVersion === 1;
+            this._noUBO = !engine.supportsUniformBuffers;
             this._dynamic = dynamic;
 
             this._data = data || [];

+ 4 - 0
src/babylon.engine.ts

@@ -556,7 +556,11 @@
         private _vrAnimationFrameHandler: number;
 
         // Uniform buffers list
+        public disableUniformBuffers = false;
         public _uniformBuffers = new Array<UniformBuffer>();
+        public get supportsUniformBuffers(): boolean {
+            return this.webGLVersion > 1 && !this.disableUniformBuffers;
+        }
 
         // Private Members
         private _gl: WebGLRenderingContext;