Pārlūkot izejas kodu

feat(mrt) : Store attachment locations within textures to avoid creating array each frame.

pierre 7 gadi atpakaļ
vecāks
revīzija
38c030580c

+ 6 - 3
src/Engine/babylon.engine.ts

@@ -1917,7 +1917,11 @@
                 gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
                 gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
 
-                var attachments = new Array(textures.length);
+                var attachments = textures[0]._attachments;
+                if(!attachments) {
+                    attachments = new Array(textures.length);
+                    textures[0]._attachments = attachments;
+                }
 
                 for(var i = 0; i < textures.length; i++) {
                     var texture = textures[i];
@@ -1958,8 +1962,6 @@
             }
 
             this.bindUnboundFramebuffer(null);
-
-
         }
 
         public generateMipMapsForCubemap(texture: InternalTexture) {
@@ -3716,6 +3718,7 @@
                 texture.type = type;
                 texture._generateDepthBuffer = generateDepthBuffer;
                 texture._generateStencilBuffer = generateStencilBuffer;
+                texture._attachments = attachments;
 
                 this._internalTexturesCache.push(texture);
             }

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

@@ -47,6 +47,7 @@ module BABYLON {
         public _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
         public _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
         public _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
+        public _attachments: Nullable<number[]>;
         public _cachedCoordinatesMode: Nullable<number>;
         public _cachedWrapU: Nullable<number>;
         public _cachedWrapV: Nullable<number>;
@@ -239,4 +240,4 @@ module BABYLON {
             }
         }
     }
-}
+}