فهرست منبع

Revert "Added ability to toggle matrix caching in effects and set NativeEngine to disable it. This is a stopgap measure until we decide what the right way/place to cache uniform values is. This problem arose because the old underlying native layer had different expectations/assumptions than the new, so we just need to reevaluate (and possibly implement) the contract."

This reverts commit baedfc7f2e89104c12ed8009ba8b335caa4336f5.
Gary Hsu 6 سال پیش
والد
کامیت
3835232502
3فایلهای تغییر یافته به همراه4 افزوده شده و 40 حذف شده
  1. 1 1
      src/Engines/engine.ts
  2. 1 35
      src/Engines/nativeEngine.ts
  3. 2 4
      src/Materials/effect.ts

+ 1 - 1
src/Engines/engine.ts

@@ -844,7 +844,7 @@ export class Engine {
     protected _currentEffect: Nullable<Effect>;
     protected _currentEffect: Nullable<Effect>;
     /** @hidden */
     /** @hidden */
     protected _currentProgram: Nullable<WebGLProgram>;
     protected _currentProgram: Nullable<WebGLProgram>;
-    protected _compiledEffects: { [key: string]: Effect } = {};
+    private _compiledEffects: { [key: string]: Effect } = {};
     private _vertexAttribArraysEnabled: boolean[] = [];
     private _vertexAttribArraysEnabled: boolean[] = [];
     /** @hidden */
     /** @hidden */
     protected _cachedViewport: Nullable<Viewport>;
     protected _cachedViewport: Nullable<Viewport>;

+ 1 - 35
src/Engines/nativeEngine.ts

@@ -7,7 +7,7 @@ import { Texture } from "../Materials/Textures/texture";
 import { BaseTexture } from "../Materials/Textures/baseTexture";
 import { BaseTexture } from "../Materials/Textures/baseTexture";
 import { VideoTexture } from "../Materials/Textures/videoTexture";
 import { VideoTexture } from "../Materials/Textures/videoTexture";
 import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
 import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
-import { Effect, EffectCreationOptions, EffectFallbacks } from "../Materials/effect";
+import { Effect } from "../Materials/effect";
 import { DataBuffer } from '../Meshes/dataBuffer';
 import { DataBuffer } from '../Meshes/dataBuffer';
 import { Tools } from "../Misc/tools";
 import { Tools } from "../Misc/tools";
 import { Observer } from "../Misc/observable";
 import { Observer } from "../Misc/observable";
@@ -358,40 +358,6 @@ export class NativeEngine extends Engine {
         // }
         // }
     }
     }
 
 
-    /**
-     * Create a new effect (used to store vertex/fragment shaders)
-     * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
-     * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
-     * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
-     * @param samplers defines an array of string used to represent textures
-     * @param defines defines the string containing the defines to use to compile the shaders
-     * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
-     * @param onCompiled defines a function to call when the effect creation is successful
-     * @param onError defines a function to call when the effect creation has failed
-     * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
-     * @returns the new Effect
-     */
-    public createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks,
-        onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect {
-        var vertex = baseName.vertexElement || baseName.vertex || baseName;
-        var fragment = baseName.fragmentElement || baseName.fragment || baseName;
-
-        var name = vertex + "+" + fragment + "@" + (defines ? defines : (<EffectCreationOptions>attributesNamesOrOptions).defines);
-        if (this._compiledEffects[name]) {
-            var compiledEffect = <Effect>this._compiledEffects[name];
-            if (onCompiled && compiledEffect.isReady()) {
-                onCompiled(compiledEffect);
-            }
-
-            return compiledEffect;
-        }
-        var effect = new Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters, false);
-        effect._key = name;
-        this._compiledEffects[name] = effect;
-
-        return effect;
-    }
-
     public createPipelineContext(): IPipelineContext {
     public createPipelineContext(): IPipelineContext {
         return new NativePipelineContext();
         return new NativePipelineContext();
     }
     }

+ 2 - 4
src/Materials/effect.ts

@@ -272,7 +272,6 @@ export class Effect implements IDisposable {
      * @hidden
      * @hidden
      */
      */
     public _pipelineContext: Nullable<IPipelineContext> = null;
     public _pipelineContext: Nullable<IPipelineContext> = null;
-    private _enableMatrixCaching: boolean;
     private _valueCache: { [key: string]: any } = {};
     private _valueCache: { [key: string]: any } = {};
     private static _baseCache: { [key: number]: DataBuffer } = {};
     private static _baseCache: { [key: number]: DataBuffer } = {};
 
 
@@ -291,9 +290,8 @@ export class Effect implements IDisposable {
      * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
      * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
      */
      */
     constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers: Nullable<string[]> = null, engine?: Engine, defines: Nullable<string> = null,
     constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers: Nullable<string[]> = null, engine?: Engine, defines: Nullable<string> = null,
-        fallbacks: Nullable<EffectFallbacks> = null, onCompiled: Nullable<(effect: Effect) => void> = null, onError: Nullable<(effect: Effect, errors: string) => void> = null, indexParameters?: any, enableMatrixCaching: boolean = true) {
+        fallbacks: Nullable<EffectFallbacks> = null, onCompiled: Nullable<(effect: Effect) => void> = null, onError: Nullable<(effect: Effect, errors: string) => void> = null, indexParameters?: any) {
         this.name = baseName;
         this.name = baseName;
-        this._enableMatrixCaching = enableMatrixCaching;
 
 
         if ((<EffectCreationOptions>attributesNamesOrOptions).attributes) {
         if ((<EffectCreationOptions>attributesNamesOrOptions).attributes) {
             var options = <EffectCreationOptions>attributesNamesOrOptions;
             var options = <EffectCreationOptions>attributesNamesOrOptions;
@@ -1195,7 +1193,7 @@ export class Effect implements IDisposable {
      * @returns this effect.
      * @returns this effect.
      */
      */
     public setMatrix(uniformName: string, matrix: Matrix): Effect {
     public setMatrix(uniformName: string, matrix: Matrix): Effect {
-        if (!this._enableMatrixCaching || this._cacheMatrix(uniformName, matrix)) {
+        if (this._cacheMatrix(uniformName, matrix)) {
             this._engine.setMatrix(this._uniforms[uniformName], matrix);
             this._engine.setMatrix(this._uniforms[uniformName], matrix);
         }
         }
         return this;
         return this;